Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: mode changed after refreshed (#7725)

ecmadao37932b7f259e
diff --git a/frontend/src/layouts/SQLEditorLayout.vue b/frontend/src/layouts/SQLEditorLayout.vue
index 2812017960..9ded2bb7e1 100644
--- a/frontend/src/layouts/SQLEditorLayout.vue
+++ b/frontend/src/layouts/SQLEditorLayout.vue
@@ -24,11 +24,37 @@
</template>
<script lang="ts" setup>
+import { useLocalStorage } from "@vueuse/core";
+import { onMounted } from "vue";
+import { useRoute } from "vue-router";
import BannersWrapper from "@/components/BannersWrapper.vue";
import ProvideSQLEditorContext from "@/components/ProvideSQLEditorContext.vue";
-import { pushNotification, useActuatorV1Store } from "@/store";
+import {
+ pushNotification,
+ useActuatorV1Store,
+ useSQLEditorStore,
+} from "@/store";
+import { SQLEditorMode } from "@/types";
const actuatorStore = useActuatorV1Store();
+const sqlEditorStore = useSQLEditorStore();
+const route = useRoute();
+
+onMounted(() => {
+ let mode = route.query.mode as SQLEditorMode;
+ const storage = useLocalStorage<SQLEditorMode>(
+ "bb.sql-editor.mode",
+ "BUNDLED"
+ );
+ if (mode != "BUNDLED" && mode != "STANDALONE") {
+ mode = storage.value;
+ }
+
+ storage.value = mode;
+ sqlEditorStore.setSQLEditorState({
+ mode,
+ });
+});
const ping = () => {
actuatorStore.fetchServerInfo().then((info) => {
diff --git a/frontend/src/views/sql-editor/SQLEditorPage.vue b/frontend/src/views/sql-editor/SQLEditorPage.vue
index 623bbd1da7..a22d312d9a 100644
--- a/frontend/src/views/sql-editor/SQLEditorPage.vue
+++ b/frontend/src/views/sql-editor/SQLEditorPage.vue
@@ -116,8 +116,7 @@ import { useWindowSize } from "@vueuse/core";
import { NDrawer } from "naive-ui";
import { stringify } from "qs";
import { Splitpanes, Pane } from "splitpanes";
-import { computed, reactive, onMounted } from "vue";
-import { useRoute } from "vue-router";
+import { computed, reactive } from "vue";
import SchemaEditorModal from "@/components/AlterSchemaPrepForm/SchemaEditorModal.vue";
import { Drawer, DrawerContent, InstanceV1Name } from "@/components/v2";
import {
@@ -127,7 +126,7 @@ import {
useSQLEditorStore,
useTabStore,
} from "@/store";
-import { DatabaseId, TabMode, UNKNOWN_ID, SQLEditorMode } from "@/types";
+import { DatabaseId, TabMode, UNKNOWN_ID } from "@/types";
import {
allowUsingSchemaEditorV1,
instanceV1HasReadonlyMode,
@@ -155,7 +154,6 @@ const state = reactive<LocalState>({
sidebarExpanded: false,
});
-const route = useRoute();
const tabStore = useTabStore();
const databaseStore = useDatabaseV1Store();
const sqlEditorStore = useSQLEditorStore();
@@ -166,13 +164,6 @@ const { showPanel: showSheetPanel } = provideSheetContext();
const isDisconnected = computed(() => tabStore.isDisconnected);
const isFetchingSheet = computed(() => sqlEditorStore.isFetchingSheet);
-onMounted(() => {
- const mode = (route.query.mode || "BUNDLED") as SQLEditorMode;
- sqlEditorStore.setSQLEditorState({
- mode,
- });
-});
-
const { width: windowWidth } = useWindowSize();
const allowAccess = computed(() => {