Skip to content

feat: improve distinction between deletion confirmation dialogs #2319

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

Merged
merged 2 commits into from
Oct 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions src/dashboard/Data/Browser/DeleteRowsDialog.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ export default class DeleteRowsDialog extends React.Component {
}

valid() {
if (this.state.confirmation === this.props.className) {
const selectionLength = Object.keys(this.props.selection).length;

if (this.props.selection['*'] && this.state.confirmation.toLowerCase() === 'delete all') {
return true;
}
if (selectionLength >= 10 && this.state.confirmation.toLowerCase() === 'delete selected') {
return true;
}
if (!this.props.selection['*'] && Object.keys(this.props.selection).length < 10) {
if (!this.props.selection['*'] && selectionLength < 10) {
return true;
}
return false;
Expand All @@ -33,17 +38,35 @@ export default class DeleteRowsDialog extends React.Component {
render() {
let content = null;
let selectionLength = Object.keys(this.props.selection).length;
if (this.props.selection['*'] || selectionLength >= 10) {

if (selectionLength >= 10) {
content = (
<Field
label={
<Label
text='Confirm this action'
description='Enter "delete selected" word to continue.' />
}
input={
<TextInput
placeholder='delete selected'
value={this.state.confirmation}
onChange={(confirmation) => this.setState({ confirmation })} />
} />
);
}

if (this.props.selection['*']) {
content = (
<Field
label={
<Label
text='Confirm this action'
description='Enter the current class name to continue.' />
description='Enter "delete all" to continue.' />
}
input={
<TextInput
placeholder='Current class name'
placeholder='delete all'
value={this.state.confirmation}
onChange={(confirmation) => this.setState({ confirmation })} />
} />
Expand Down