Skip to content

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

fix(sql-editor): fixed save button do not work (#761)

Yunwei Xiao309778dad592
diff --git a/frontend/src/views/SqlEditor/EditorPanel/EditorAction.vue b/frontend/src/views/SqlEditor/EditorPanel/EditorAction.vue
index 22a530989f..b7d852b664 100644
--- a/frontend/src/views/SqlEditor/EditorPanel/EditorAction.vue
+++ b/frontend/src/views/SqlEditor/EditorPanel/EditorAction.vue
@@ -64,7 +64,7 @@
strong
type="primary"
:disabled="isEmptyStatement || currentTab.isSaved"
- @click="handleUpsertSheet"
+ @click="handleSave"
>
<carbon:save class="h-5 w-5" /> &nbsp; {{ $t("common.save") }} (⌘+S)
</NButton>
@@ -104,6 +104,7 @@ import {
SqlEditorState,
SqlEditorGetters,
TabGetters,
+ TabActions,
SheetActions,
UNKNOWN_ID,
} from "../../../types";
@@ -125,6 +126,9 @@ const { currentTab } = useNamespacedGetters<TabGetters>("tab", ["currentTab"]);
const { upsertSheet } = useNamespacedActions<SheetActions>("sheet", [
"upsertSheet",
]);
+const { updateCurrentTab } = useNamespacedActions<TabActions>("tab", [
+ "updateCurrentTab",
+]);
const isShowSharePopover = ref(false);
const isEmptyStatement = computed(
@@ -150,13 +154,18 @@ const handleExplainQuery = () => {
execute({ databaseType: selectedInstanceEngine.value }, { explain: true });
};
-const handleUpsertSheet = async () => {
+const handleSave = async () => {
const { name, statement, sheetId } = currentTab.value;
- return upsertSheet({
+ const sheet = await upsertSheet({
id: sheetId,
name,
statement,
});
+
+ updateCurrentTab({
+ sheetId: sheet.id,
+ isSaved: true,
+ });
};
const handleClickoutside = (e: any) => {
diff --git a/frontend/src/views/SqlEditor/EditorPanel/QueryEditor.vue b/frontend/src/views/SqlEditor/EditorPanel/QueryEditor.vue
index 76614e841b..2084ef1a47 100644
--- a/frontend/src/views/SqlEditor/EditorPanel/QueryEditor.vue
+++ b/frontend/src/views/SqlEditor/EditorPanel/QueryEditor.vue
@@ -67,14 +67,14 @@ const handleChangeSelection = debounce((value: string) => {
const handleSave = async (statement: string) => {
const { name, sheetId } = currentTab.value;
- const newSheet = await upsertSheet({
+ const sheet = await upsertSheet({
id: sheetId,
name,
statement,
});
updateCurrentTab({
- sheetId: newSheet.id,
+ sheetId: sheet.id,
isSaved: true,
});
};