Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: copy query history (#426)
STEVEN5f7578b6d31f
diff --git a/frontend/src/locales/en.yml b/frontend/src/locales/en.ymlindex 78614fb1cc..343f899231 100644--- a/frontend/src/locales/en.yml+++ b/frontend/src/locales/en.yml@@ -1102,6 +1102,9 @@ sql-editor:confirm-to-delete-this-history: Confirm to delete this history?confirm-to-delete-this-saved-query: Confirm to delete this saved query?please-input-the-tab-label: Please input the tab label!+ copy-code: Copy code+ notify:+ copy-code-succeed: Copy code succeedlabel:empty-label-value: <Empty Value>no-label: No labelsdiff --git a/frontend/src/locales/zh-CN.yml b/frontend/src/locales/zh-CN.ymlindex bc73f01f25..0692703670 100644--- a/frontend/src/locales/zh-CN.yml+++ b/frontend/src/locales/zh-CN.yml@@ -970,6 +970,9 @@ sql-editor:confirm-to-delete-this-history: 确定删除这条记录?confirm-to-delete-this-saved-query: 确定删除这条查询语句?please-input-the-tab-label: 请输入标签页名称!+ copy-code: 复制代码+ notify:+ copy-code-succeed: 代码复制成功label:empty-label-value: <空值>no-label: 没有标签diff --git a/frontend/src/views/SqlEditor/AsidePanel/QueryHistoryView.vue b/frontend/src/views/SqlEditor/AsidePanel/QueryHistoryView.vueindex f2c342bc01..0d8715f579 100644--- a/frontend/src/views/SqlEditor/AsidePanel/QueryHistoryView.vue+++ b/frontend/src/views/SqlEditor/AsidePanel/QueryHistoryView.vue@@ -74,6 +74,8 @@<script lang="ts" setup>import { computed, reactive } from "vue";import { useI18n } from "vue-i18n";+import { useClipboard } from "@vueuse/core";+import { useStore } from "vuex";import {useNamespacedActions,useNamespacedState,@@ -94,6 +96,7 @@ interface State {}const { t } = useI18n();+const store = useStore();const { queryHistoryList, isFetchingQueryHistory: isLoading } =useNamespacedState<SqlEditorState>("sqlEditor", [@@ -115,6 +118,9 @@ const state = reactive<State>({currentActionHistory: null,});+const { copy: copyTextToClipboard, isSupported: isCopySupported } =+ useClipboard();+const data = computed(() => {const tempData =queryHistoryList.value && queryHistoryList.value.length > 0@@ -150,18 +156,36 @@ const notifyMessage = computed(() => {return "";});-const actionDropdownOptions = computed(() => [- {+const actionDropdownOptions = computed(() => {+ const options = [];++ if (isCopySupported) {+ options.push({+ label: t("sql-editor.copy-code"),+ key: "copy",+ });+ }++ options.push({label: t("common.delete"),key: "delete",- },-]);+ });++ return options;+});const handleActionBtnClick = (key: string, history: QueryHistory) => {state.currentActionHistory = history;if (key === "delete") {state.isShowDeletingHint = true;+ } else if (key === "copy") {+ copyTextToClipboard(history.statement);+ store.dispatch("notification/pushNotification", {+ module: "bytebase",+ style: "SUCCESS",+ title: t("sql-editor.notify.copy-code-succeed"),+ });}};diff --git a/frontend/src/views/SqlEditor/AsidePanel/SavedQueryView.vue b/frontend/src/views/SqlEditor/AsidePanel/SavedQueryView.vueindex 15d8a7a42a..6d4d52d324 100644--- a/frontend/src/views/SqlEditor/AsidePanel/SavedQueryView.vue+++ b/frontend/src/views/SqlEditor/AsidePanel/SavedQueryView.vue@@ -264,14 +264,7 @@ const handleDeleteSavedQuery = () => {};const handleSavedQueryClick = (savedQuery: SavedQuery) => {- if (currentTab.value.currentQueryId === savedQuery.id) {- if (state.editingSavedQueryId !== savedQuery.id) {- updateActiveTab({- label: "Untitled Queries",- currentQueryId: undefined,- });- }- } else {+ if (currentTab.value.currentQueryId !== savedQuery.id) {for (const tab of queryTabList.value) {if (tab.currentQueryId === savedQuery.id) {setActiveTabId(tab.id);