Skip to content
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

Merged

Conversation

prakharporwal
Copy link
Contributor

@prakharporwal prakharporwal commented Oct 28, 2021

Resolves #1655

Summary

  1. For Kanban Card
  2. For Card Dialog

Future Work

On Confirmation Card Dialog Component May be this can work

  1. We can use a redux store to save state of the dialog
  2. make a simple function like window.confirm() within the component which set the state of card to SHOW and pass required props to raise warning wherever its required .

Prakhar and others added 30 commits October 13, 2021 18:32
Confirmation dialog box generalized for use
@sbishel sbishel added 2: Dev Review Requires review by a core committer 1: UX Review Requires review by ux labels Nov 8, 2021
Copy link
Contributor

@asaadmahmood asaadmahmood left a 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.

Screenshot 2021-11-08 at 9 40 16 PM

Copy link
Collaborator

@sbishel sbishel left a 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.

@@ -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: () => {}})
Copy link
Collaborator

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.

Copy link
Contributor Author

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 .

Copy link
Collaborator

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}/>}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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

@chenilim chenilim removed their request for review November 9, 2021 21:06
@prakharporwal
Copy link
Contributor Author

/update-branch

@mattermod
Copy link
Contributor

Error trying to update the PR.
Please do it manually.

Copy link
Collaborator

@sbishel sbishel left a 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}/>}
Copy link
Collaborator

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

@@ -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: () => {}})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below comment

@prakharporwal
Copy link
Contributor Author

@sbishel Got it removed useState hook from cardDialog and kanbanCard.tsx for confirmDialogProps.

@sbishel sbishel merged commit 27ce296 into mattermost-community:main Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1: UX Review Requires review by ux 2: Dev Review Requires review by a core committer Contributor Hacktoberfest hacktoberfest-accepted
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Idea: Show Warning when trying to delete a card
5 participants