Skip to content

Commit

Permalink
refactor(29358): add cloning to the toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
vanch3d committed Jan 16, 2025
1 parent b9a9551 commit 33b208d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FC } from 'react'
import { useTranslation } from 'react-i18next'
import { useNavigate } from 'react-router-dom'
import { Breadcrumb, BreadcrumbItem, ButtonGroup, HStack, Icon, Text, useDisclosure } from '@chakra-ui/react'
import { LuTrash2 } from 'react-icons/lu'
import { LuBookCopy, LuTrash2 } from 'react-icons/lu'
import { PiPencilSimpleLineFill } from 'react-icons/pi'

import IconButton from '@/components/Chakra/IconButton.tsx'
Expand All @@ -27,6 +27,12 @@ const DraftStatus: FC = () => {
setStatus(DesignerStatus.MODIFIED)
}

function onHandleClone() {
setStatus(DesignerStatus.DRAFT, { name: '' })
navigate(`/datahub/${PolicyType.CREATE_POLICY}`)
// TODO[NVL] This is not enough, we should "clean" the id of protected elements
}

function handleConfirmOnClose() {
onConfirmDeleteClose()
}
Expand Down Expand Up @@ -57,11 +63,20 @@ const DraftStatus: FC = () => {
<ButtonGroup role="group" aria-label={t('workspace.toolbars.edit.aria-label')}>
<IconButton
isDisabled={isPolicyEditable}
data-testid="designer-edit-"
data-testid="designer-edit-modify"
onClick={onHandleEdit}
aria-label={t('workspace.controls.edit')}
aria-label={t('workspace.controls.modify')}
icon={<Icon as={PiPencilSimpleLineFill} boxSize="18px" />}
/>

<IconButton
isDisabled={isPolicyEditable}
data-testid="designer-edit-duplicate"
onClick={onHandleClone}
aria-label={t('workspace.controls.clone')}
icon={<Icon as={LuBookCopy} boxSize="18px" />}
/>

<IconButton
data-testid="designer-clear-draft"
onClick={onHandleClear}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@
"fitView": "Fit to the canvas",
"toggleInteractivity": "Lock the canvas",
"clear": "Clear the Designer",
"edit": "Edit the policy",
"modify": "Modify the policy",
"clone": "Clone as a new draft",
"shortcuts": "Help using the Designer"
},

Expand Down

0 comments on commit 33b208d

Please sign in to comment.