fix(settings): confirm before discarding unsaved settings
This commit is contained in:
1 parent
9dbb2ef72f
commit
6a25bd1909
12 files changed
+160
-3
No files matched your search
@@ -126,7 +126,7 @@ import McpConnectionScopePicker from "@/components/settings/McpConnectionScopePi
|
||||
import ScheduledDatabaseBackupSettings from "@/components/backup/ScheduledDatabaseBackupSettings.vue";
|
||||
import SqlFormatterSettingsPanel from "./SqlFormatterSettingsPanel.vue";
|
||||
import { APP_CUSTOM_UI_COLOR_DEFS, APP_THEME_PALETTES, type AppCornerStyle, type AppCustomUiColors, type AppThemeAppearance, type AppThemeMode, type AppThemePalette } from "@/lib/app/appTheme";
|
||||
import { editorSettingsDraftChanged, editorSettingsDraftFromSettings, editorSettingsPatchFromDraft, normalizeQueryResultMaxRowsDraft, normalizeTableOpenPageSizeDraft, type EditorSettingsDraft } from "@/lib/settings/editorSettingsDraft";
|
||||
import { editorSettingsDraftChanged, editorSettingsDraftFromSettings, editorSettingsPatchFromDraft, normalizeQueryResultMaxRowsDraft, normalizeTableOpenPageSizeDraft, shouldConfirmEditorSettingsDialogClose, type EditorSettingsDraft } from "@/lib/settings/editorSettingsDraft";
|
||||
import { useConnectionStore } from "@/stores/connectionStore";
|
||||
import { useSavedSqlStore } from "@/stores/savedSqlStore";
|
||||
import { usePromptTemplateStore } from "@/stores/promptTemplateStore";
|
||||
@@ -221,11 +221,31 @@ const settingsContentClass = computed(() =>
|
||||
);
|
||||
const settingsTitleComponent = computed(() => (isSettingsPage.value ? "h2" : DialogTitle));
|
||||
|
||||
const showUnsavedSettingsCloseConfirm = ref(false);
|
||||
|
||||
function requestCloseSettings(nextOpen: boolean) {
|
||||
if (shouldConfirmEditorSettingsDialogClose(nextOpen, hasChanges())) {
|
||||
showUnsavedSettingsCloseConfirm.value = true;
|
||||
return;
|
||||
}
|
||||
emit("update:open", nextOpen);
|
||||
}
|
||||
|
||||
function onSettingsRootOpenChange(value: boolean) {
|
||||
if (!isSettingsPage.value) emit("update:open", value);
|
||||
if (isSettingsPage.value) return;
|
||||
requestCloseSettings(value);
|
||||
}
|
||||
|
||||
function closeSettings() {
|
||||
requestCloseSettings(false);
|
||||
}
|
||||
|
||||
function cancelUnsavedSettingsClose() {
|
||||
showUnsavedSettingsCloseConfirm.value = false;
|
||||
}
|
||||
|
||||
function discardUnsavedSettingsAndClose() {
|
||||
showUnsavedSettingsCloseConfirm.value = false;
|
||||
emit("update:open", false);
|
||||
}
|
||||
|
||||
@@ -6928,6 +6948,24 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</component>
|
||||
|
||||
<!-- Unsaved settings confirmation: guards every close path (Escape, outside click, the X button, and the footer "Close" button) so an unapplied draft is never silently discarded. -->
|
||||
<Dialog :open="showUnsavedSettingsCloseConfirm" @update:open="(value: boolean) => !value && cancelUnsavedSettingsClose()">
|
||||
<DialogContent class="sm:max-w-[420px]" @interact-outside.prevent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ t("settings.unsavedChangesCloseTitle") }}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<p class="text-sm text-muted-foreground">{{ t("settings.unsavedChangesCloseMessage") }}</p>
|
||||
<DialogFooter class="gap-2">
|
||||
<Button variant="outline" size="sm" @click="cancelUnsavedSettingsClose">
|
||||
{{ t("settings.unsavedChangesCloseCancel") }}
|
||||
</Button>
|
||||
<Button variant="destructive" size="sm" @click="discardUnsavedSettingsAndClose">
|
||||
{{ t("settings.unsavedChangesCloseDiscard") }}
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
<!-- Theme Customizer Dialog -->
|
||||
<ThemeCustomizerDialog v-model:open="showThemeCustomizer" :themes="editCustomThemes" :active-theme-id="editActiveCustomThemeId" @save="handleThemeSave" />
|
||||
|
||||
|
||||
Reference in new issue
Block a user