-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GH-1655] Card Delete : added Confirmation Dialog #1684
[GH-1655] Card Delete : added Confirmation Dialog #1684
Conversation
…orwal/focalboard into confirmation-dialog-512
…orwal/focalboard into confirmation-dialog-512
Confirmation dialog box generalized for use
…into prop-update-warning-1140
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prakharporwal Updated the card modal css to somewhat match the designs, looks good now.
Please pull your branch before you make any changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @prakharporwal, some suggestions.
webapp/src/components/cardDialog.tsx
Outdated
@@ -39,6 +41,9 @@ const CardDialog = (props: Props): JSX.Element => { | |||
const comments = useAppSelector(getCardComments(props.cardId)) | |||
const intl = useIntl() | |||
|
|||
const [showConfirmationDialogBox, setShowConfirmationDialogBox] = useState<boolean>(false) | |||
const [confirmDialogProps, setConfirmDialogProps] = useState<ConfirmationDialogBoxProps>({heading: '', onConfirm: () => {}, onClose: () => {}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to use state for this, just set when showing the dialog box.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typescript raise error when not adding a initial state. I have added non-optional props only .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below comment
</Dialog> | ||
</Dialog> | ||
|
||
{showConfirmationDialogBox && <ConfirmationDialogBox dialogBox={confirmDialogProps}/>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create your confirmDialogProps
here, using state is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State is needed. I set confirmDialogProps when showing Dialog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both cardDialog.tsx
and kanbanCard.tsx
, the state for confirmDialogProps never changes it is always the same. It could actually be set to this value by default. Therefore, storing this in state is unnecessary. Simply create the properties struct when you call <ConfirmationDialogBox>
or create a variable to hold those properties and use it here.
{showConfirmationDialogBox &&
<ConfirmationDialogBox dialogBox={
heading: intl.formatMessage({id: 'CardDialog.delete-confirmation-dialog-heading', defaultMessage: 'Confirm card delete!'}),
confirmButtonText: intl.formatMessage({id: 'CardDialog.delete-confirmation-dialog-button-text', defaultMessage: 'Delete'}),
onConfirm: handleDeleteCard,
onClose: () => {
setShowConfirmationDialogBox(false)
},
}/>
}
Let me know if I'm not understanding something. Thanks
…porwal/focalboard into card-delete-warning-1655
/update-branch |
Error trying to update the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for changes...see additional comments.
</Dialog> | ||
</Dialog> | ||
|
||
{showConfirmationDialogBox && <ConfirmationDialogBox dialogBox={confirmDialogProps}/>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both cardDialog.tsx
and kanbanCard.tsx
, the state for confirmDialogProps never changes it is always the same. It could actually be set to this value by default. Therefore, storing this in state is unnecessary. Simply create the properties struct when you call <ConfirmationDialogBox>
or create a variable to hold those properties and use it here.
{showConfirmationDialogBox &&
<ConfirmationDialogBox dialogBox={
heading: intl.formatMessage({id: 'CardDialog.delete-confirmation-dialog-heading', defaultMessage: 'Confirm card delete!'}),
confirmButtonText: intl.formatMessage({id: 'CardDialog.delete-confirmation-dialog-button-text', defaultMessage: 'Delete'}),
onConfirm: handleDeleteCard,
onClose: () => {
setShowConfirmationDialogBox(false)
},
}/>
}
Let me know if I'm not understanding something. Thanks
webapp/src/components/cardDialog.tsx
Outdated
@@ -39,6 +41,9 @@ const CardDialog = (props: Props): JSX.Element => { | |||
const comments = useAppSelector(getCardComments(props.cardId)) | |||
const intl = useIntl() | |||
|
|||
const [showConfirmationDialogBox, setShowConfirmationDialogBox] = useState<boolean>(false) | |||
const [confirmDialogProps, setConfirmDialogProps] = useState<ConfirmationDialogBoxProps>({heading: '', onConfirm: () => {}, onClose: () => {}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See below comment
@sbishel Got it removed useState hook from cardDialog and kanbanCard.tsx for confirmDialogProps. |
Resolves #1655
Summary
Future Work
On Confirmation Card Dialog Component May be this can work
window.confirm()
within the component which set the state of card toSHOW
and pass required props to raise warning wherever its required .