feat(settings): allow disabling update reminders

This commit is contained in:
t8y2 committed 2026-06-07 01:07:31 +08:00
1 parent 8c0fe3a6e7
commit 3eefe87380
12 files changed
+116 -18

No files matched your search

@@ -56,6 +56,15 @@ const { t } = useI18n();
const { toast } = useToast();
const isWeb = !isTauriRuntime();
const props = withDefaults(
defineProps<{
updateNotificationsEnabled?: boolean;
}>(),
{
updateNotificationsEnabled: true,
},
);
const emit = defineEmits<{
"update-count-change": [count: number];
}>();
@@ -117,7 +126,9 @@ const progressText = computed(() => {
const progressNumber = computed(() => driverInstallProgressPercent(progress.value));
const updatableCount = computed(() => drivers.value.filter((d) => d.update_available).length);
const updatableCount = computed(() =>
props.updateNotificationsEnabled ? drivers.value.filter((d) => d.update_available).length : 0,
);
const usageSummary = computed(() => {
const usage = driverStoreUsage.value;
if (!usage) return [];
@@ -142,10 +153,18 @@ function updateAgentDrivers(nextDrivers: AgentDriverInfo[]) {
emitDriverUpdateCount();
}
const agentTabUpdateCount = computed(() => drivers.value.filter((d) => d.update_available).length);
const jdbcTabUpdateCount = computed(() => (jdbcPluginStatus.value?.update_available ? 1 : 0));
const agentTabUpdateCount = computed(() =>
props.updateNotificationsEnabled ? drivers.value.filter((d) => d.update_available).length : 0,
);
const jdbcTabUpdateCount = computed(() =>
props.updateNotificationsEnabled && jdbcPluginStatus.value?.update_available ? 1 : 0,
);
function emitDriverUpdateCount() {
if (!props.updateNotificationsEnabled) {
emit("update-count-change", 0);
return;
}
emit("update-count-change", countAvailableDriverUpdates(drivers.value, jdbcPluginStatus.value));
}
@@ -722,9 +741,11 @@ onMounted(async () => {
void loadJavaRuntimeConfig();
void loadDriverStoreUsage();
api.listInstalledAgents().then((result) => {
updateAgentDrivers(result);
});
if (props.updateNotificationsEnabled) {
api.listInstalledAgents().then((result) => {
updateAgentDrivers(result);
});
}
unlisten = await api.listenAgentInstallProgress((payload) => {
if (payload.step === "done" || payload.step === "all-done") {
@@ -739,7 +760,7 @@ onMounted(async () => {
}
});
void loadJdbcDrivers();
void loadJdbcPluginStatus();
if (props.updateNotificationsEnabled) void loadJdbcPluginStatus();
});
onUnmounted(() => {
@@ -18,6 +18,7 @@ import type {
TransportLayerConfig,
} from "@/types/database";
import { useConnectionStore } from "@/stores/connectionStore";
import { useSettingsStore } from "@/stores/settingsStore";
import { useToast } from "@/composables/useToast";
import DatabaseIcon from "@/components/icons/DatabaseIcon.vue";
import * as api from "@/lib/api";
@@ -77,6 +78,7 @@ type ConnectionForm = Omit<ConnectionConfig, "id">;
const { t } = useI18n();
const { toast } = useToast();
const settingsStore = useSettingsStore();
const open = defineModel<boolean>("open", { default: false });
const isDesktop = isTauriRuntime();
@@ -1688,6 +1690,7 @@ async function loadJdbcDrivers() {
async function loadAgentDrivers() {
try {
agentDrivers.value = await api.listInstalledAgentsLocal();
if (!settingsStore.editorSettings.updateNotificationsEnabled) return;
api
.listInstalledAgents()
.then((drivers) => {
@@ -127,6 +127,7 @@ const editDisconnectTabHandlingMode = ref<DisconnectTabHandlingMode>(
settingsStore.editorSettings.disconnectTabHandlingMode,
);
const editReuseDataTab = ref(settingsStore.editorSettings.reuseDataTab);
const editUpdateNotificationsEnabled = ref(settingsStore.editorSettings.updateNotificationsEnabled);
const editSidebarHiddenTablePrefixes = ref(settingsStore.editorSettings.sidebarHiddenTablePrefixes.join("\n"));
const editSidebarHideTableComments = ref(settingsStore.editorSettings.sidebarHideTableComments);
const editSidebarAllowHorizontalScroll = ref(settingsStore.editorSettings.sidebarAllowHorizontalScroll);
@@ -279,6 +280,7 @@ watch(
editAutoSelectActiveSidebarNode.value = settingsStore.editorSettings.autoSelectActiveSidebarNode;
editDisconnectTabHandlingMode.value = settingsStore.editorSettings.disconnectTabHandlingMode;
editReuseDataTab.value = settingsStore.editorSettings.reuseDataTab;
editUpdateNotificationsEnabled.value = settingsStore.editorSettings.updateNotificationsEnabled;
editSidebarHiddenTablePrefixes.value = settingsStore.editorSettings.sidebarHiddenTablePrefixes.join("\n");
editSidebarHideTableComments.value = settingsStore.editorSettings.sidebarHideTableComments;
editSidebarAllowHorizontalScroll.value = settingsStore.editorSettings.sidebarAllowHorizontalScroll;
@@ -325,6 +327,7 @@ function hasChanges(): boolean {
editAutoSelectActiveSidebarNode.value !== settingsStore.editorSettings.autoSelectActiveSidebarNode ||
editDisconnectTabHandlingMode.value !== settingsStore.editorSettings.disconnectTabHandlingMode ||
editReuseDataTab.value !== settingsStore.editorSettings.reuseDataTab ||
editUpdateNotificationsEnabled.value !== settingsStore.editorSettings.updateNotificationsEnabled ||
editSidebarHideTableComments.value !== settingsStore.editorSettings.sidebarHideTableComments ||
editSidebarAllowHorizontalScroll.value !== settingsStore.editorSettings.sidebarAllowHorizontalScroll ||
editExportBatchSize.value !== settingsStore.editorSettings.exportBatchSize ||
@@ -358,6 +361,7 @@ async function persistSettings() {
autoSelectActiveSidebarNode: editAutoSelectActiveSidebarNode.value,
disconnectTabHandlingMode: editDisconnectTabHandlingMode.value,
reuseDataTab: editReuseDataTab.value,
updateNotificationsEnabled: editUpdateNotificationsEnabled.value,
sidebarHideTableComments: editSidebarHideTableComments.value,
sidebarAllowHorizontalScroll: editSidebarAllowHorizontalScroll.value,
sidebarHiddenTablePrefixes: normalizeSidebarHiddenTablePrefixes(editSidebarHiddenTablePrefixes.value),
@@ -404,6 +408,7 @@ function resetDefaults() {
editAutoSelectActiveSidebarNode.value = DEFAULT_EDITOR_SETTINGS.autoSelectActiveSidebarNode;
editDisconnectTabHandlingMode.value = DEFAULT_EDITOR_SETTINGS.disconnectTabHandlingMode;
editReuseDataTab.value = DEFAULT_EDITOR_SETTINGS.reuseDataTab;
editUpdateNotificationsEnabled.value = DEFAULT_EDITOR_SETTINGS.updateNotificationsEnabled;
editSidebarHideTableComments.value = DEFAULT_EDITOR_SETTINGS.sidebarHideTableComments;
editSidebarAllowHorizontalScroll.value = DEFAULT_EDITOR_SETTINGS.sidebarAllowHorizontalScroll;
editSidebarHiddenTablePrefixes.value = DEFAULT_EDITOR_SETTINGS.sidebarHiddenTablePrefixes.join("\n");
@@ -1491,6 +1496,16 @@ watch(
<Switch id="show-tray-icon" v-model="editShowTrayIcon" />
</div>
<div class="flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
<div class="space-y-1">
<Label for="update-notifications-enabled">{{ t("settings.updateNotificationsEnabled") }}</Label>
<p class="text-xs text-muted-foreground">
{{ t("settings.updateNotificationsEnabledDescription") }}
</p>
</div>
<Switch id="update-notifications-enabled" v-model="editUpdateNotificationsEnabled" />
</div>
<Separator />
<div class="space-y-3">