Skip to content

Commit

Permalink
feat: add confirmation dialogs for delete actions (#1520)
Browse files Browse the repository at this point in the history
Signed-off-by: Pedro Lamas <[email protected]>
  • Loading branch information
pedrolamas authored Nov 5, 2024
1 parent f0559c5 commit 90beb61
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 13 deletions.
11 changes: 9 additions & 2 deletions src/components/common/SystemPrinters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,15 @@ export default class SystemPrinters extends Mixins(StateMixin) {
}
}
removeInstance (instance: InstanceConfig) {
this.$store.dispatch('config/removeInstance', instance)
async removeInstance (instance: InstanceConfig) {
const result = await this.$confirm(
this.$t('app.general.simple_form.msg.confirm_remove_printer', { name: instance.name }).toString(),
{ title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$error' }
)
if (result) {
this.$store.dispatch('config/removeInstance', instance)
}
}
addInstanceDialog () {
Expand Down
11 changes: 9 additions & 2 deletions src/components/settings/cameras/CameraSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,15 @@ export default class CameraSettings extends Vue {
this.$store.dispatch('webcams/updateWebcam', camera)
}
handleRemoveCamera (camera: WebcamConfig) {
this.$store.dispatch('webcams/removeWebcam', camera.uid)
async handleRemoveCamera (camera: WebcamConfig) {
const result = await this.$confirm(
this.$t('app.general.simple_form.msg.confirm_remove_camera', { name: camera.name }).toString(),
{ title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$error' }
)
if (result) {
this.$store.dispatch('webcams/removeWebcam', camera.uid)
}
}
get defaultFullscreenAction (): string {
Expand Down
11 changes: 9 additions & 2 deletions src/components/settings/console/ConsoleSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,15 @@ export default class ConsoleSettings extends Mixins(StateMixin) {
}
}
handleRemoveFilter (filter: ConsoleFilter) {
this.$store.dispatch('console/onRemoveFilter', filter)
async handleRemoveFilter (filter: ConsoleFilter) {
const result = await this.$confirm(
this.$t('app.general.simple_form.msg.confirm_remove_console_filter', { name: filter.name }).toString(),
{ title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$error' }
)
if (result) {
this.$store.dispatch('console/onRemoveFilter', filter)
}
}
handleSaveFilter (filter: ConsoleFilter) {
Expand Down
11 changes: 9 additions & 2 deletions src/components/settings/macros/MacroSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,15 @@ export default class MacroSettings extends Mixins(StateMixin) {
}
}
handleRemoveCategory (category: MacroCategory) {
this.$store.dispatch('macros/removeCategory', category)
async handleRemoveCategory (category: MacroCategory) {
const result = await this.$confirm(
this.$t('app.general.simple_form.msg.confirm_remove_macro_category', { name: category.name }).toString(),
{ title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$error' }
)
if (result) {
this.$store.dispatch('macros/removeCategory', category)
}
}
handleAddCategory (category: string) {
Expand Down
25 changes: 22 additions & 3 deletions src/components/settings/presets/PresetSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
:key="preset.index"
:title="preset.name"
:r-cols="2"
@click="openEditDialog(preset)"
>
<template #sub-title>
<span
Expand All @@ -45,6 +44,19 @@
</span>
</template>

<app-btn
fab
text
x-small
color=""
class="ms-1"
@click.stop="openEditDialog(preset)"
>
<v-icon color="">
$edit
</v-icon>
</app-btn>

<app-btn
fab
text
Expand Down Expand Up @@ -134,8 +146,15 @@ export default class TemperaturePresetSettings extends Mixins(StateMixin) {
this.$store.dispatch('config/updatePreset', preset)
}
handleRemovePreset (preset: TemperaturePreset) {
this.$store.dispatch('config/removePreset', preset)
async handleRemovePreset (preset: TemperaturePreset) {
const result = await this.$confirm(
this.$t('app.general.simple_form.msg.confirm_remove_thermal_preset', { name: preset.name }).toString(),
{ title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$error' }
)
if (result) {
this.$store.dispatch('config/removePreset', preset)
}
}
}
</script>
Expand Down
11 changes: 9 additions & 2 deletions src/components/widgets/history/JobHistory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,15 @@ export default class JobHistory extends Mixins(FilesMixin) {
return filename.split('/').pop() || ''
}
handleRemoveJob (job: HistoryItem) {
SocketActions.serverHistoryDeleteJob(job.job_id)
async handleRemoveJob (job: HistoryItem) {
const result = await this.$confirm(
this.$tc('app.general.simple_form.msg.confirm_delete', 1),
{ title: this.$tc('app.general.label.confirm'), color: 'card-heading', icon: '$error' }
)
if (result) {
SocketActions.serverHistoryDeleteJob(job.job_id)
}
}
handleJobThumbnailError (job: HistoryItem) {
Expand Down
5 changes: 5 additions & 0 deletions src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ app:
confirm_forcemove_toggle: Are you sure? This can damage the printer.
confirm_load_bedmesh_profile: The printer is currently busy. Are you sure you want to load profile %{name}?
confirm_reboot_host: Are you sure? This will reboot your host system.
confirm_remove_camera: Are you sure you want to remove the camera %{name}?
confirm_remove_console_filter: Are you sure you want to remove the console filter %{name}?
confirm_remove_macro_category: Are you sure you want to remove the macro category %{name}?
confirm_remove_printer: Are you sure you want to remove the printer %{name}?
confirm_remove_thermal_preset: Are you sure you want to remove the thermal preset %{name}?
confirm_remove_user: Are you sure you want to remove user %{username}?
confirm_shutdown_host: Are you sure? This will shutdown your host system.
confirm_service_start: Are you sure you want to start the %{name} service?
Expand Down

0 comments on commit 90beb61

Please sign in to comment.