Skip to content

Commit

Permalink
Get confirmation before deleting a service in EditServices screen
Browse files Browse the repository at this point in the history
  • Loading branch information
vraravam committed Jul 16, 2024
1 parent a9c3bb8 commit db2f325
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/components/settings/services/EditServiceForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { app, dialog } from '@electron/remote';
import { mdiInformation } from '@mdi/js';
import { noop } from 'lodash';
import { observer } from 'mobx-react';
Expand Down Expand Up @@ -34,6 +35,10 @@ const messages = defineMessages({
id: 'settings.service.form.deleteButton',
defaultMessage: 'Delete service',
},
confirmDeleteService: {
id: 'settings.service.form.confirmDeleteService',
defaultMessage: 'Do you really want to delete the {serviceName} service?',
},
openDarkmodeCss: {
id: 'settings.service.form.openDarkmodeCss',
defaultMessage: 'Open darkmode.css',
Expand Down Expand Up @@ -248,7 +253,23 @@ class EditServiceForm extends Component<IProps, IState> {
buttonType="danger"
label={intl.formatMessage(messages.deleteService)}
className="settings__delete-button"
onClick={onDelete}
onClick={() => {
// @ts-expect-error Fix me
const selection = dialog.showMessageBoxSync(app.mainWindow, {
type: 'question',
message: intl.formatMessage(messages.deleteService),
detail: intl.formatMessage(messages.confirmDeleteService, {
serviceName: service?.name || recipe.name,
}),
buttons: [
intl.formatMessage(globalMessages.yes),
intl.formatMessage(globalMessages.no),
],
});
if (selection === 0) {
onDelete();
}
}}
/>
);

Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@
"settings.service.error.message": "Could not load service recipe.",
"settings.service.form.addServiceHeadline": "Add {name}",
"settings.service.form.availableServices": "Available services",
"settings.service.form.confirmDeleteService": "Do you really want to delete the {serviceName} service?",
"settings.service.form.customUrl": "Custom server",
"settings.service.form.customUrlValidationError": "Could not validate custom {name} server.",
"settings.service.form.darkReaderBrightness": "Dark Reader Brightness",
Expand Down

0 comments on commit db2f325

Please sign in to comment.