Skip to content

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

chore: history pane improvements (#11507)

Liu Jif56f75540480
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index bbb29aa8c0..d51897707d 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2229,7 +2229,8 @@
"view-table-detail": "View table detail",
"view-database-detail": "View database detail",
"copy-all-column-names": "Copy all column names",
- "view-schema-text": "View schema text"
+ "view-schema-text": "View schema text",
+ "override-current-statement": "Override current statement"
},
"schema-editor": {
"self": "Schema Editor",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index f665b6e0b6..8d5a17c072 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2229,7 +2229,8 @@
"view-table-detail": "Ver detalle de la tabla",
"view-database-detail": "Ver detalle de la base de datos",
"copy-all-column-names": "Copiar todos los nombres de las columnas",
- "view-schema-text": "Ver texto del esquema"
+ "view-schema-text": "Ver texto del esquema",
+ "override-current-statement": "Anular la declaración actual"
},
"schema-editor": {
"self": "Editor de esquema",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index d53e4e59ed..9bcdcd35a2 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2229,7 +2229,8 @@
"view-table-detail": "テーブルの詳細を表示する",
"view-database-detail": "データベースの詳細を表示する",
"copy-all-column-names": "すべての列名をコピーします",
- "view-schema-text": "スキーマテキストの表示"
+ "view-schema-text": "スキーマテキストの表示",
+ "override-current-statement": "現在のステートメントをオーバーライドする"
},
"schema-editor": {
"self": "スキーマエディター",
diff --git a/frontend/src/locales/sql-review/zh-CN.json b/frontend/src/locales/sql-review/zh-CN.json
index 47e85d6e13..cb8f9e5824 100644
--- a/frontend/src/locales/sql-review/zh-CN.json
+++ b/frontend/src/locales/sql-review/zh-CN.json
@@ -623,4 +623,4 @@
"warning": "警告",
"disabled": "禁用"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 1943764cd6..d051fadbb7 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2229,7 +2229,8 @@
"view-table-detail": "Xem chi tiết bảng",
"view-database-detail": "Xem chi tiết cơ sở dữ liệu",
"copy-all-column-names": "Sao chép tất cả tên cột",
- "view-schema-text": "Xem văn bản lược đồ"
+ "view-schema-text": "Xem văn bản lược đồ",
+ "override-current-statement": "Ghi đè câu lệnh hiện tại"
},
"schema-editor": {
"self": "Trình chỉnh sửa lược đồ",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 049d4c50af..05e62b3e32 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2229,7 +2229,8 @@
"view-table-detail": "查看表详情",
"view-database-detail": "查看数据库详情",
"copy-all-column-names": "复制所有列名",
- "view-schema-text": "查看文本 Schema"
+ "view-schema-text": "查看文本 Schema",
+ "override-current-statement": "覆盖当前语句"
},
"schema-editor": {
"self": "Schema 编辑器",
diff --git a/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue b/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue
index 3970fd55c9..4ff3f7296a 100644
--- a/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue
+++ b/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue
@@ -18,7 +18,6 @@
>
<div class="w-full flex flex-row justify-between items-center">
<div class="flex items-start gap-x-1">
- <HistoryConnectionIcon :query-history="history" />
<span class="text-xs text-gray-500">
{{ titleOfQueryHistory(history) }}
</span>
@@ -56,7 +55,8 @@
<script lang="ts" setup>
import { useClipboard } from "@vueuse/core";
import dayjs from "dayjs";
-import { escape } from "lodash-es";
+import { escape, uniqBy } from "lodash-es";
+import { useDialog } from "naive-ui";
import { storeToRefs } from "pinia";
import { computed, onMounted, reactive } from "vue";
import { useI18n } from "vue-i18n";
@@ -67,12 +67,9 @@ import {
useSQLEditorQueryHistoryStore,
useSQLEditorTabStore,
} from "@/store";
+import type { SQLEditorTab } from "@/types";
import type { QueryHistory } from "@/types/proto/v1/sql_service";
-import {
- getHighlightHTMLByKeyWords,
- extractDatabaseResourceName,
-} from "@/utils";
-import HistoryConnectionIcon from "./HistoryConnectionIcon.vue";
+import { getHighlightHTMLByKeyWords, defer } from "@/utils";
interface State {
search: string;
@@ -83,6 +80,7 @@ const { t } = useI18n();
const tabStore = useSQLEditorTabStore();
const queryHistoryStore = useSQLEditorQueryHistoryStore();
const { isFetching, queryHistoryList } = storeToRefs(queryHistoryStore);
+const $d = useDialog();
const state = reactive<State>({
search: "",
@@ -103,8 +101,9 @@ const data = computed(() => {
return t;
});
+ const distinctData = uniqBy(tempData, (history) => history.statement);
- return tempData.map((history) => {
+ return distinctData.map((history) => {
return {
...history,
formattedStatement: state.search
@@ -151,18 +150,53 @@ const handleCopy = (history: QueryHistory) => {
});
};
+const confirmOverrideCurrentStatement = () => {
+ const d = defer<boolean>();
+ $d.warning({
+ title: t("common.warning"),
+ content: () => t("sql-editor.override-current-statement"),
+ style: "z-index: 100000",
+ negativeText: t("common.cancel"),
+ positiveText: t("common.confirm"),
+ onNegativeClick: () => {
+ d.resolve(false);
+ },
+ onPositiveClick: () => {
+ d.resolve(true);
+ },
+ });
+ return d.promise;
+};
+
const handleQueryHistoryClick = async (queryHistory: QueryHistory) => {
- const { database, statement } = queryHistory;
+ const { statement } = queryHistory;
// Open a new tab with the connection and statement.
- tabStore.addTab({
- title: `Query history at ${titleOfQueryHistory(queryHistory)}`,
- connection: {
- instance: extractDatabaseResourceName(database).instance,
- database,
- },
- statement,
- });
+ const tab = tabStore.currentTab;
+
+ const openInNewTab = () => {
+ tabStore.addTab(
+ {
+ title: `Query history at ${titleOfQueryHistory(queryHistory)}`,
+ statement,
+ },
+ /* beside */ true
+ );
+ };
+ const openInCurrentTab = async (tab: SQLEditorTab) => {
+ if (tab.statement) {
+ if (!(await confirmOverrideCurrentStatement())) {
+ return;
+ }
+ }
+ tab.statement = statement;
+ };
+
+ if (tab) {
+ openInCurrentTab(tab);
+ } else {
+ openInNewTab();
+ }
};
onMounted(async () => {