UI [CODE-1216] : Fix modal close and disable side menu on comment deletion (#913)

This commit is contained in:
Ritik Kapoor 2023-12-18 07:15:57 +00:00 committed by Harness
parent 9ea75dd327
commit b24729d608
2 changed files with 38 additions and 36 deletions

View File

@ -380,43 +380,44 @@ const CommentsThread = <T = unknown,>({
{outlets[CommentBoxOutletPosition.LEFT_OF_OPTIONS_MENU]} {outlets[CommentBoxOutletPosition.LEFT_OF_OPTIONS_MENU]}
</Container> </Container>
</Render> </Render>
<OptionsMenuButton <Render when={!commentItem?.deleted}>
isDark={true} <OptionsMenuButton
icon="Options" isDark={true}
iconProps={{ size: 14 }} icon="Options"
style={{ padding: '5px' }} iconProps={{ size: 14 }}
disabled={!!commentItem?.deleted} style={{ padding: '5px' }}
width="100px" width="100px"
items={[ items={[
{ {
hasIcon: true, hasIcon: true,
className: css.optionMenuIcon, className: css.optionMenuIcon,
iconName: 'Edit', iconName: 'Edit',
text: getString('edit'), text: getString('edit'),
onClick: () => setEditIndexes({ ...editIndexes, ...{ [index]: true } }) onClick: () => setEditIndexes({ ...editIndexes, ...{ [index]: true } })
}, },
{ {
hasIcon: true, hasIcon: true,
className: css.optionMenuIcon, className: css.optionMenuIcon,
iconName: 'code-quote', iconName: 'code-quote',
text: getString('quote'), text: getString('quote'),
onClick: () => onQuote(commentItem?.content) onClick: () => onQuote(commentItem?.content)
}, },
'-', '-',
{ {
className: css.deleteIcon, className: css.deleteIcon,
hasIcon: true, hasIcon: true,
iconName: 'main-trash', iconName: 'main-trash',
isDanger: true, isDanger: true,
text: getString('delete'), text: getString('delete'),
onClick: async () => { onClick: async () => {
if (await handleAction(CommentAction.DELETE, '', commentItem)) { if (await handleAction(CommentAction.DELETE, '', commentItem)) {
resetStateAtIndex(index) resetStateAtIndex(index)
}
} }
} }
} ]}
]} />
/> </Render>
</Layout.Horizontal> </Layout.Horizontal>
</Layout.Horizontal> </Layout.Horizontal>
} }

View File

@ -83,8 +83,9 @@ export const useConfirmationDialog = (props: UseConfirmationDialogProps): UseCon
const onClose = React.useCallback( const onClose = React.useCallback(
(isConfirmed: boolean): void => { (isConfirmed: boolean): void => {
onCloseDialog?.(isConfirmed) onCloseDialog?.(isConfirmed)
hideModal()
if (persistDialog) showModal()
if (!isConfirmed) hideModal() if (!isConfirmed) hideModal()
else if (persistDialog) showModal()
}, },
[hideModal, onCloseDialog, persistDialog] [hideModal, onCloseDialog, persistDialog]
) )