Skip to content

feat: have user type name of thing to delete for extra safety - #4080

Merged
presleyp merged 12 commits into
mainfrom
presleyp/destructive-dialog
Sep 20, 2022
Merged

presleyp merged 12 commits into
mainfrom
presleyp/destructive-dialog

Conversation

@presleyp

Copy link
Copy Markdown
Contributor

Closes #3384

@bpmct

bpmct commented Sep 19, 2022

Copy link
Copy Markdown
Member

this PR title made me smile, idk why :D

@presleyp
presleyp marked this pull request as ready for review September 20, 2022 20:28
@presleyp
presleyp requested a review from a team as a code owner September 20, 2022 20:28
@presleyp
presleyp requested review from BrunoQuaresma and code-asher and removed request for a team and code-asher September 20, 2022 20:28
})

it("disables confirm button when the text field is filled incorrectly", async () => {
const { t } = i18next

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

<Maybe condition={info !== undefined}>
<Typography className={styles.warning}>{info}</Typography>
</Maybe>
<Typography>{t("deleteDialog.confirm", { entity })}</Typography>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I love how we're not passing whole strings in so that the language will stay consistent.

title,
description,
entity,
info,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What kind of info is this? A description?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's intended to help the user identify the entity to delete, so they don't delete the wrong one by accident. @bpmct suggested this on the basis of an article about making the wrong repo private and thus losing all their github stars.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's the orange text here. Note storybook isn't showing buttons; that's been going on for a while and so far doesn't mean the buttons are actually gone.
Screen Shot 2022-09-20 at 4 52 28 PM

fireEvent.click(moreButton)
const moreButtons = await screen.findAllByLabelText("more")
const suspendedMoreButton = moreButtons[2]
fireEvent.click(suspendedMoreButton)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious why we're using a fireEvent instead of an await user.click like above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It should be fine to do so - I just didn't make as many changes in this test. I wanted to switch to getting the "more" buttons everywhere because they load later than users, but the userEvent change was more of a hygiene thing than a cause of bugs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Got it! Thanks

@Kira-Pilot Kira-Pilot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This was satisfying to review!!! Thanks for doing it.

@presleyp
presleyp merged commit 0899548 into main Sep 20, 2022
@presleyp
presleyp deleted the presleyp/destructive-dialog branch September 20, 2022 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Require that user input object name in destructive actions

3 participants