Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: copy button (#16588)
ecmadaoed82dd77e408
diff --git a/frontend/src/components/AdvancedSearch/AdvancedSearch.vue b/frontend/src/components/AdvancedSearch/AdvancedSearch.vueindex 50d72c4d6c..e27be1aca7 100644--- a/frontend/src/components/AdvancedSearch/AdvancedSearch.vue+++ b/frontend/src/components/AdvancedSearch/AdvancedSearch.vue@@ -110,7 +110,7 @@ import type { ScopeOption } from "./types";const props = withDefaults(defineProps<{params: SearchParams;- scopeOptions: ScopeOption[];+ scopeOptions?: ScopeOption[];placeholder?: string | undefined;autofocus?: boolean;}>(),diff --git a/frontend/src/components/Changelog/ChangelogDetail.vue b/frontend/src/components/Changelog/ChangelogDetail.vueindex 820846ff0d..2407ee1d1e 100644--- a/frontend/src/components/Changelog/ChangelogDetail.vue+++ b/frontend/src/components/Changelog/ChangelogDetail.vue@@ -67,15 +67,9 @@</div></div><div class="flex flex-col gap-y-2">- <p class="flex items-center text-lg text-main capitalize">+ <p class="flex items-center text-lg text-main capitalize gap-x-2">{{ $t("common.statement") }}- <button- tabindex="-1"- class="btn-icon ml-1"- @click.prevent="copyStatement"- >- <ClipboardIcon class="w-5 h-5" />- </button>+ <CopyButton size="small" :content="changelogStatement" /></p><MonacoEditorclass="h-auto max-h-[480px] min-h-[120px] border rounded-[3px] text-sm overflow-clip relative"@@ -85,15 +79,9 @@/></div><div v-if="showSchemaSnapshot" class="flex flex-col gap-y-2">- <p class="flex items-center text-lg text-main capitalize">+ <p class="flex items-center text-lg text-main capitalize gap-x-2">Schema {{ $t("common.snapshot") }}- <button- tabindex="-1"- class="btn-icon ml-1"- @click.prevent="copySchema"- >- <ClipboardIcon class="w-5 h-5" />- </button>+ <CopyButton size="small" :content="changelogSchema" /></p><div class="flex flex-row items-center gap-x-2"><div v-if="allowShowDiff" class="flex space-x-1 items-center">@@ -140,13 +128,12 @@</template><script lang="ts" setup>-import { ClipboardIcon } from "lucide-vue-next";import { NSwitch, NTag } from "naive-ui";import { computed, reactive, watch, unref } from "vue";import { BBSpin } from "@/bbkit";import { DiffEditor, MonacoEditor } from "@/components/MonacoEditor";+import { CopyButton } from "@/components/v2";import {- pushNotification,useChangelogStore,useDBSchemaV1Store,useDatabaseV1ByName,@@ -160,7 +147,6 @@ import {} from "@/types/proto/v1/database_service";import {extractIssueUID,- toClipboard,getStatementSize,hasProjectPermissionV2,getAffectedTableDisplayName,@@ -246,32 +232,6 @@ const allowShowDiff = computed((): boolean => {return getChangelogChangeType(changelog.value.type) === "DDL";});-const copyStatement = async () => {- if (!changelogStatement.value) {- return false;- }- toClipboard(changelogStatement.value).then(() => {- pushNotification({- module: "bytebase",- style: "INFO",- title: `Statement copied to clipboard.`,- });- });-};--const copySchema = async () => {- if (!changelogSchema.value) {- return false;- }- toClipboard(changelogSchema.value).then(() => {- pushNotification({- module: "bytebase",- style: "INFO",- title: `Schema copied to clipboard.`,- });- });-};-watch([database.value.name, changelogName],async () => {diff --git a/frontend/src/components/IdentityProvider/IdentityProviderExternalURL.vue b/frontend/src/components/IdentityProvider/IdentityProviderExternalURL.vueindex 87d7f6daca..fb816cbbaf 100644--- a/frontend/src/components/IdentityProvider/IdentityProviderExternalURL.vue+++ b/frontend/src/components/IdentityProvider/IdentityProviderExternalURL.vue@@ -11,7 +11,7 @@<p class="text-sm text-gray-600 mb-3">{{ $t("settings.sso.form.redirect-url-description") }}</p>-+<div class="flex items-center space-x-3"><div class="flex-1"><label class="block text-sm font-medium text-gray-700 mb-1">@@ -23,13 +23,9 @@readonlyclass="block w-full px-3 py-2 border border-gray-300 rounded-md bg-white text-sm font-mono text-gray-700 pr-10"/>- <button- type="button"- class="absolute inset-y-0 right-0 px-3 flex items-center text-gray-400 hover:text-gray-600"- @click="copyRedirectUrl"- >- <ClipboardIcon class="w-4 h-4" />- </button>+ <div class="absolute inset-y-0 right-2 top-2">+ <CopyButton :content="redirectUrl" />+ </div></div></div></div>@@ -39,19 +35,16 @@</template><script setup lang="ts">-import { ClipboardIcon, InfoIcon } from "lucide-vue-next";+import { InfoIcon } from "lucide-vue-next";import { computed } from "vue";-import { useI18n } from "vue-i18n";-import { pushNotification, useActuatorV1Store } from "@/store";+import { CopyButton } from "@/components/v2";+import { useActuatorV1Store } from "@/store";import { IdentityProviderType } from "@/types/proto/v1/idp_service";-import { toClipboard } from "@/utils";const props = defineProps<{type: IdentityProviderType;}>();-const { t } = useI18n();-const externalUrl = computed(() => useActuatorV1Store().serverInfo?.externalUrl ?? "");@@ -67,14 +60,4 @@ const redirectUrl = computed(() => {return "";}});--const copyRedirectUrl = () => {- toClipboard(redirectUrl.value).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("settings.sso.copy-redirect-url"),- });- });-};-</script>\ No newline at end of file+</script>diff --git a/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue b/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vueindex 86faea3571..7e05829d5d 100644--- a/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue+++ b/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue@@ -193,13 +193,11 @@:code="grantStatement"/></NConfigProvider>- <button- tabindex="-1"- class="-ml-px px-2 py-2 border border-gray-300 text-sm font-medium text-control-light disabled:text-gray-300 bg-gray-50 hover:bg-gray-100 disabled:bg-gray-50 focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-1 disabled:cursor-not-allowed rounded-r-[3px]"- @click.prevent="copyGrantStatement"+ <div+ class="flex items-center -ml-px px-2 py-2 border border-gray-300 text-sm font-medium text-control-light disabled:text-gray-300 bg-gray-50 hover:bg-gray-100 disabled:bg-gray-50 focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-1 disabled:cursor-not-allowed rounded-r-[3px]">- <heroicons-outline:clipboard class="w-6 h-6" />- </button>+ <CopyButton :content="grantStatement" />+ </div></div></div></div>@@ -209,9 +207,8 @@import hljs from "highlight.js/lib/core";import { NCode, NConfigProvider } from "naive-ui";import { reactive, computed } from "vue";-import { useI18n } from "vue-i18n";import { BBAttention } from "@/bbkit";-import { pushNotification } from "@/store";+import { CopyButton } from "@/components/v2";import {languageOfEngineV1,DATASOURCE_ADMIN_USER_NAME,@@ -222,7 +219,6 @@ import {DataSourceType,DataSource_AuthenticationType,} from "@/types/proto/v1/instance_service";-import { engineNameV1, toClipboard } from "@/utils";interface LocalState {showCreateUserExample: boolean;@@ -244,8 +240,6 @@ const props = withDefaults(});-const { t } = useI18n();-const state = reactive<LocalState>({showCreateUserExample: props.createInstanceFlag,});@@ -602,16 +596,4 @@ db.createUser({const toggleCreateUserExample = () => {state.showCreateUserExample = !state.showCreateUserExample;};--const copyGrantStatement = () => {- toClipboard(grantStatement.value).then(() => {- pushNotification({- module: "bytebase",- style: "INFO",- title: t("instance.copy-grant-statement", {- engine: engineNameV1(props.engine),- }),- });- });-};</script>diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/StatementCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/StatementCell.vueindex 511acae4f4..c36ab4f943 100644--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/StatementCell.vue+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunLogTable/StatementCell.vue@@ -15,25 +15,12 @@<span class="line-clamp-1">{{ displayContent }}</span>- <NButton- text- size="tiny"- class="invisible group-hover:visible"- @click="copyStatement"- >- <template #icon>- <CopyIcon class="w-3 h-3" />- </template>- </NButton>+ <CopyButton :content="statement.trim()" /></span></template><template #popover-header><div class="absolute bottom-1 right-1">- <NButton text size="tiny" @click="copyStatement">- <template #icon>- <CopyIcon class="w-3 h-3" />- </template>- </NButton>+ <CopyButton :content="statement.trim()" /></div></template></TextOverflowPopover>@@ -42,15 +29,12 @@</template><script setup lang="ts">-import { CopyIcon } from "lucide-vue-next";-import { NButton } from "naive-ui";import { computed } from "vue";-import { useI18n } from "vue-i18n";import TextOverflowPopover from "@/components/misc/TextOverflowPopover.vue";-import { pushNotification } from "@/store";+import { CopyButton } from "@/components/v2";import { TaskRunLogEntry_Type } from "@/types/proto/v1/rollout_service";import type { Sheet } from "@/types/proto/v1/sheet_service";-import { extractSheetCommandByIndex, toClipboard } from "@/utils";+import { extractSheetCommandByIndex } from "@/utils";import type { FlattenLogEntry } from "./common";const props = defineProps<{@@ -58,8 +42,6 @@ const props = defineProps<{sheet?: Sheet;}>();-const { t } = useI18n();-const statement = computed(() => {const { entry, sheet } = props;if (entry.type === TaskRunLogEntry_Type.SCHEMA_DUMP && entry.schemaDump) {@@ -81,14 +63,4 @@ const statement = computed(() => {}return "";});--const copyStatement = () => {- toClipboard(statement.value.trim()).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.copied"),- });- });-};</script>diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunSession/Cells/StatementCell.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunSession/Cells/StatementCell.vueindex f132f47885..490145487c 100644--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunSession/Cells/StatementCell.vue+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunSession/Cells/StatementCell.vue@@ -15,25 +15,12 @@<span class="line-clamp-1">{{ displayContent }}</span>- <NButton- text- size="tiny"- class="invisible group-hover:visible"- @click="copyStatement"- >- <template #icon>- <CopyIcon class="w-3 h-3" />- </template>- </NButton>+ <CopyButton :content="query.trim()" /></span></template><template #popover-header><div class="absolute bottom-1 right-1">- <NButton text size="tiny" @click="copyStatement">- <template #icon>- <CopyIcon class="w-3 h-3" />- </template>- </NButton>+ <CopyButton :content="query.trim()" /></div></template></TextOverflowPopover>@@ -42,26 +29,10 @@</template><script setup lang="ts">-import { CopyIcon } from "lucide-vue-next";-import { NButton } from "naive-ui";-import { useI18n } from "vue-i18n";import TextOverflowPopover from "@/components/misc/TextOverflowPopover.vue";-import { pushNotification } from "@/store";-import { toClipboard } from "@/utils";+import { CopyButton } from "@/components/v2";-const props = defineProps<{+defineProps<{query: string;}>();--const { t } = useI18n();--const copyStatement = () => {- toClipboard(props.query.trim()).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.copied"),- });- });-};</script>diff --git a/frontend/src/components/Release/ReleaseDetail/ReleaseFileTable/ReleaseFileDetailPanel.vue b/frontend/src/components/Release/ReleaseDetail/ReleaseFileTable/ReleaseFileDetailPanel.vueindex ca83b08475..4a61059bb1 100644--- a/frontend/src/components/Release/ReleaseDetail/ReleaseFileTable/ReleaseFileDetailPanel.vue+++ b/frontend/src/components/Release/ReleaseDetail/ReleaseFileTable/ReleaseFileDetailPanel.vue@@ -17,15 +17,9 @@<NDivider /><div class="flex flex-col gap-y-2">- <p class="w-auto flex items-center text-base text-main mb-2">+ <p class="w-auto flex items-center text-base text-main mb-2 gap-x-2">{{ $t("common.statement") }}- <button- tabindex="-1"- class="btn-icon ml-1"- @click.prevent="copyStatement"- >- <ClipboardIcon class="w-4 h-4" />- </button>+ <CopyButton :content="statement" /></p><MonacoEditorclass="h-auto max-h-[480px] min-h-[120px] border rounded-[3px] text-sm overflow-clip relative"@@ -37,14 +31,13 @@</template><script lang="ts" setup>-import { ClipboardIcon } from "lucide-vue-next";import { NDivider } from "naive-ui";import { computed } from "vue";import { MonacoEditor } from "@/components/MonacoEditor";-import { pushNotification } from "@/store";+import { CopyButton } from "@/components/v2";import { type ComposedRelease } from "@/types";import type { Release_File } from "@/types/proto/v1/release_service";-import { getReleaseFileStatement, toClipboard } from "@/utils";+import { getReleaseFileStatement } from "@/utils";const props = defineProps<{release: ComposedRelease;@@ -52,14 +45,4 @@ const props = defineProps<{}>();const statement = computed(() => getReleaseFileStatement(props.releaseFile));--const copyStatement = async () => {- toClipboard(statement.value).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: `Statement copied to clipboard.`,- });- });-};</script>diff --git a/frontend/src/components/Revision/RevisionDetailPanel.vue b/frontend/src/components/Revision/RevisionDetailPanel.vueindex aaddcf9d04..24eef75704 100644--- a/frontend/src/components/Revision/RevisionDetailPanel.vue+++ b/frontend/src/components/Revision/RevisionDetailPanel.vue@@ -25,12 +25,9 @@<NDivider /><div class="flex flex-col">- <p class="w-auto flex items-center text-base text-main mb-2">+ <p class="w-auto flex items-center text-base text-main mb-2 gap-x-2"><span>{{ $t("common.statement") }}</span>- <ClipboardIcon- class="ml-1 w-4 h-4 cursor-pointer hover:opacity-80"- @click.prevent="copyStatement"- />+ <CopyButton :content="statement" /></p><MonacoEditorclass="h-auto max-h-[480px] min-h-[120px] border rounded-[3px] text-sm overflow-clip relative"@@ -51,23 +48,15 @@</template><script lang="ts" setup>-import { ClipboardIcon } from "lucide-vue-next";import { NDivider } from "naive-ui";import { computed, reactive, ref, watch } from "vue";import { MonacoEditor } from "@/components/MonacoEditor";+import { CopyButton } from "@/components/v2";import { rolloutServiceClient } from "@/grpcweb";-import {- pushNotification,- useRevisionStore,- useSheetV1Store,-} from "@/store";+import { useRevisionStore, useSheetV1Store } from "@/store";import { getDateForPbTimestamp, type ComposedDatabase } from "@/types";import type { TaskRun } from "@/types/proto/v1/rollout_service";-import {- extractIssueUID,- getSheetStatement,- toClipboard,-} from "@/utils";+import { extractIssueUID, getSheetStatement } from "@/utils";import TaskRunLogTable from "../IssueV1/components/TaskRunSection/TaskRunLogTable/TaskRunLogTable.vue";import HumanizeDate from "../misc/HumanizeDate.vue";@@ -131,14 +120,4 @@ const relatedIssueUID = computed(() => {if (!uid) return null;return uid;});--const copyStatement = async () => {- toClipboard(statement.value).then(() => {- pushNotification({- module: "bytebase",- style: "INFO",- title: `Statement copied to clipboard.`,- });- });-};</script>diff --git a/frontend/src/components/Rollout/RolloutDetail/TaskDetail/Panels/Overview.vue b/frontend/src/components/Rollout/RolloutDetail/TaskDetail/Panels/Overview.vueindex 5757713c7e..4172f1b43a 100644--- a/frontend/src/components/Rollout/RolloutDetail/TaskDetail/Panels/Overview.vue+++ b/frontend/src/components/Rollout/RolloutDetail/TaskDetail/Panels/Overview.vue@@ -14,13 +14,9 @@<ExternalLinkIcon class="ml-1" :size="16" /></router-link></NAlert>- <p class="w-auto flex items-center mb-2">+ <p class="w-auto flex items-center mb-2 gap-x-2"><span class="text-base text-main">{{ $t("common.statement") }}</span>- <NButton class="ml-1" text @click.prevent="copyStatement">- <template #icon>- <ClipboardIcon class="w-4 h-4" />- </template>- </NButton>+ <CopyButton :content="statement" /></p><MonacoEditorclass="h-auto max-h-[480px] min-h-[120px] border rounded-[3px] text-sm overflow-clip relative"@@ -32,12 +28,13 @@<script lang="ts" setup>import { head } from "lodash-es";-import { ClipboardIcon, ExternalLinkIcon } from "lucide-vue-next";-import { NAlert, NButton } from "naive-ui";+import { ExternalLinkIcon } from "lucide-vue-next";+import { NAlert } from "naive-ui";import { computed, watchEffect } from "vue";import { MonacoEditor } from "@/components/MonacoEditor";-import { pushNotification, useSheetV1Store } from "@/store";-import { getSheetStatement, sheetNameOfTaskV1, toClipboard } from "@/utils";+import { CopyButton } from "@/components/v2";+import { useSheetV1Store } from "@/store";+import { getSheetStatement, sheetNameOfTaskV1 } from "@/utils";import { useTaskDetailContext } from "../context";const { task, taskRuns } = useTaskDetailContext();@@ -54,16 +51,6 @@ const statement = computed(() => {// The latest task run of the task.const taskRun = computed(() => head(taskRuns.value));-const copyStatement = async () => {- toClipboard(statement.value).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: `Statement copied to clipboard.`,- });- });-};-watchEffect(async () => {// Prepare the sheet for the task.const sheet = sheetNameOfTaskV1(task.value);diff --git a/frontend/src/components/SensitiveData/components/DataExampleModal.vue b/frontend/src/components/SensitiveData/components/DataExampleModal.vueindex 03a05111f3..dca90f4c22 100644--- a/frontend/src/components/SensitiveData/components/DataExampleModal.vue+++ b/frontend/src/components/SensitiveData/components/DataExampleModal.vue@@ -8,12 +8,13 @@@close="$emit('dismiss')"><div class="my-4 rounded-sm p-4 bg-gray-100 relative">- <div- v-if="isSupported"- class="absolute top-2 right-2 p-2 rounded bg-gray-200 text-gray-500 hover:text-gray-700 hover:bg-gray-300 cursor-pointer"- @click="handleCopy"- >- <heroicons-outline:clipboard-document class="w-4 h-4" />+ <div class="absolute top-2 right-2 p-2">+ <CopyButton+ quaternary+ :text="false"+ :size="'medium'"+ :content="example"+ /></div><NConfigProvider :hljs="hljs"><NCode language="json" :code="example" />@@ -23,33 +24,16 @@</template><script lang="ts" setup>-import { useClipboard } from "@vueuse/core";import hljs from "highlight.js/lib/core";import { NCode, NConfigProvider } from "naive-ui";-import { useI18n } from "vue-i18n";import { BBModal } from "@/bbkit";-import { pushNotification } from "@/store";+import { CopyButton } from "@/components/v2";-const props = defineProps<{+defineProps<{example: string;}>();defineEmits<{(event: "dismiss"): void;}>();--const { copy: copyTextToClipboard, isSupported } = useClipboard({- legacy: true,-});-const { t } = useI18n();--const handleCopy = () => {- copyTextToClipboard(props.example).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("settings.sensitive-data.classification.copy-succeed"),- });- });-};</script>diff --git a/frontend/src/components/SyncDatabaseSchemaV1/DiffViewPanel.vue b/frontend/src/components/SyncDatabaseSchemaV1/DiffViewPanel.vueindex c477a6cf9c..9fc384d76e 100644--- a/frontend/src/components/SyncDatabaseSchemaV1/DiffViewPanel.vue+++ b/frontend/src/components/SyncDatabaseSchemaV1/DiffViewPanel.vue@@ -30,15 +30,9 @@<template v-if="tab === 'ddl'"><div class="w-full flex flex-col justify-start">- <div class="flex flex-row justify-start items-center">+ <div class="flex flex-row justify-start items-center space-x-2"><span>{{ $t("database.sync-schema.synchronize-statements") }}</span>- <button- type="button"- class="btn-icon ml-2"- @click.prevent="$emit('copy-statement')"- >- <heroicons-outline:clipboard class="h-5 w-5" />- </button>+ <CopyButton size="small" :content="statement" /></div><div class="textinfolabel">{{ $t("database.sync-schema.synchronize-statements-description") }}@@ -60,6 +54,7 @@import { NTabs, NTab } from "naive-ui";import { ref } from "vue";import { MonacoEditor } from "@/components/MonacoEditor";+import { CopyButton } from "@/components/v2";import { dialectOfEngineV1 } from "@/types";import type { Engine } from "@/types/proto/v1/common";import SchemaDiffViewer from "./SchemaDiffViewer.vue";@@ -75,7 +70,6 @@ defineProps<{defineEmits<{(event: "statement-change", statement: string): void;- (event: "copy-statement"): void;}>();const tab = ref<"diff" | "ddl">("diff");diff --git a/frontend/src/components/SyncDatabaseSchemaV1/SelectTargetDatabasesView.vue b/frontend/src/components/SyncDatabaseSchemaV1/SelectTargetDatabasesView.vueindex 8be24fe196..b5fc47be66 100644--- a/frontend/src/components/SyncDatabaseSchemaV1/SelectTargetDatabasesView.vue+++ b/frontend/src/components/SyncDatabaseSchemaV1/SelectTargetDatabasesView.vue@@ -125,7 +125,6 @@:should-show-diff="shouldShowDiff":preview-schema-change-message="previewSchemaChangeMessage"@statement-change="onStatementChange"- @copy-statement="onCopyStatement"/><divv-show="!selectedDatabase"@@ -164,18 +163,13 @@ import { useI18n } from "vue-i18n";import { useRoute } from "vue-router";import { BBSpin } from "@/bbkit";import { InstanceV1EngineIcon } from "@/components/v2";-import {- pushNotification,- useDatabaseV1Store,- useEnvironmentV1Store,-} from "@/store";+import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";import {isValidDatabaseName,type ComposedDatabase,type ComposedProject,} from "@/types";import { Engine } from "@/types/proto/v1/common";-import { toClipboard } from "@/utils";import DiffViewPanel from "./DiffViewPanel.vue";import SourceSchemaInfo from "./SourceSchemaInfo.vue";import TargetDatabasesSelectPanel from "./TargetDatabasesSelectPanel.vue";@@ -297,20 +291,6 @@ const handleUnselectDatabase = (database: ComposedDatabase) => {}};-const onCopyStatement = () => {- const editStatement = state.selectedDatabaseName- ? schemaDiffCache.value[state.selectedDatabaseName].edited- : "";-- toClipboard(editStatement).then(() => {- pushNotification({- module: "bytebase",- style: "INFO",- title: `Statement copied to clipboard.`,- });- });-};-const onStatementChange = (statement: string) => {if (state.selectedDatabaseName) {schemaDiffCache.value[state.selectedDatabaseName].edited = statement;diff --git a/frontend/src/components/TableSchemaViewer.vue b/frontend/src/components/TableSchemaViewer.vueindex 79172cca20..ed7d62e845 100644--- a/frontend/src/components/TableSchemaViewer.vue+++ b/frontend/src/components/TableSchemaViewer.vue@@ -8,19 +8,7 @@{{ resourceName }}</div><div class="flex flex-row justify-end items-center">- <NTooltip>- <template #trigger>- <NButton- quaternary- size="tiny"- class="!px-1"- @click="handleCopySchemaString"- >- <ClipboardIcon class="w-4 h-4" />- </NButton>- </template>- {{ $t("common.copy") }}- </NTooltip>+ <CopyButton :content="schemaString || ''" /></div></div><MonacoEditor@@ -32,15 +20,11 @@</template><script lang="ts" setup>-import { useClipboard } from "@vueuse/core";-import { ClipboardIcon } from "lucide-vue-next";-import { NButton, NTooltip } from "naive-ui";import { onMounted, ref, computed } from "vue";import { nextTick } from "vue";-import { useI18n } from "vue-i18n";import { MonacoEditor } from "@/components/MonacoEditor";+import { CopyButton } from "@/components/v2";import { databaseServiceClient } from "@/grpcweb";-import { pushNotification } from "@/store";import type { ComposedDatabase } from "@/types";import type { GetSchemaStringRequest_ObjectType } from "@/types/proto/v1/database_service";import { hasSchemaProperty } from "@/utils";@@ -52,11 +36,6 @@ const props = defineProps<{type?: GetSchemaStringRequest_ObjectType;}>();-const { t } = useI18n();--const { copy: copyTextToClipboard, isSupported } = useClipboard({- legacy: true,-});const schemaString = ref<string | null>(null);const engine = computed(() => {@@ -88,22 +67,4 @@ onMounted(async () => {schemaString.value = response.schemaString.trim();});});--const handleCopySchemaString = () => {- if (!isSupported.value) {- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: "Copy to clipboard is not enabled in your browser.",- });- return;- }-- copyTextToClipboard(schemaString.value || "");- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("sql-editor.copy-success"),- });-};</script>diff --git a/frontend/src/components/User/Settings/AADSyncDrawer.vue b/frontend/src/components/User/Settings/AADSyncDrawer.vueindex 343bf4cf84..72a9a0315d 100644--- a/frontend/src/components/User/Settings/AADSyncDrawer.vue+++ b/frontend/src/components/User/Settings/AADSyncDrawer.vue@@ -45,15 +45,16 @@class="w-full"readonly:value="scimUrl"- @click="handleCopyUrl(scimUrlFieldRef)"+ @click="handleSelect(scimUrlFieldRef)"/>- <NButton- v-if="isSupported"+ <CopyButton+ quaternary+ :text="false"+ :size="'medium'"+ :content="scimUrl":disabled="!scimUrl"- @click="handleCopyUrl(scimUrlFieldRef)"- >- <ClipboardIcon class="w-4 h-4" />- </NButton>+ @click="handleSelect(scimUrlFieldRef)"+ /></div></div>@@ -73,15 +74,16 @@readonlytype="password":value="scimToken"- @click="handleCopyUrl(scimTokenFieldRef)"+ @click="handleSelect(scimTokenFieldRef)"/>- <NButton- v-if="isSupported"+ <CopyButton+ quaternary+ :text="false"+ :size="'medium'"+ :content="scimToken":disabled="!scimToken"- @click="handleCopyUrl(scimTokenFieldRef)"- >- <ClipboardIcon class="w-4 h-4" />- </NButton>+ @click="handleSelect(scimTokenFieldRef)"+ /></div><NButtonv-if="hasPermission"@@ -110,8 +112,7 @@</template><script setup lang="ts">-import { useClipboard } from "@vueuse/core";-import { ClipboardIcon, ReplyIcon } from "lucide-vue-next";+import { ReplyIcon } from "lucide-vue-next";import { NButton, NInput, useDialog } from "naive-ui";import { computed, ref } from "vue";import { useI18n } from "vue-i18n";@@ -119,6 +120,7 @@ import { useRouter } from "vue-router";import { BBAttention } from "@/bbkit";import LearnMoreLink from "@/components/LearnMoreLink.vue";import { Drawer, DrawerContent } from "@/components/v2";+import { CopyButton } from "@/components/v2";import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/router/dashboard/workspaceSetting";import { pushNotification, useSettingV1Store } from "@/store";import { Setting_SettingName } from "@/types/proto/v1/setting_service";@@ -168,24 +170,8 @@ const scimToken = computed(() => {);});-const { copy: copyTextToClipboard, isSupported } = useClipboard({- legacy: true,-});--const handleCopyUrl = (component: HTMLInputElement | null) => {+const handleSelect = (component: HTMLInputElement | null) => {component?.select();- const value = component?.value;- if (!value) {- return;- }-- copyTextToClipboard(value).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.copied"),- });- });};const configureSetting = () => {@@ -221,8 +207,6 @@ const resetToken = () => {style: "SUCCESS",title: t("common.updated"),});-- handleCopyUrl(scimTokenFieldRef.value);});},});diff --git a/frontend/src/components/User/Settings/UserDataTable/cells/UserNameCell.vue b/frontend/src/components/User/Settings/UserDataTable/cells/UserNameCell.vueindex 4207494dc2..7f5915f43a 100644--- a/frontend/src/components/User/Settings/UserDataTable/cells/UserNameCell.vue+++ b/frontend/src/components/User/Settings/UserDataTable/cells/UserNameCell.vue@@ -48,19 +48,17 @@v-if="user.userType === UserType.SERVICE_ACCOUNT && allowEdit"class="ml-3 text-xs">- <NButton- v-if="user.serviceKey"- tertiary+ <CopyButton+ quaternarysize="small"- @click.prevent="() => copyServiceKey(user.serviceKey)"+ :text="false"+ :tertiary="true"+ :content="user.serviceKey">- <template #icon>- <ClipboardIcon class="w-4 h-4" />- </template>{{ $t("settings.members.copy-service-key") }}- </NButton>+ </CopyButton><NButton- v-else+ v-if="!user.serviceKey"tertiarysize="small"@click.prevent="$emit('reset-service-key', user)"@@ -76,22 +74,18 @@</template><script lang="ts" setup>-import { ClipboardIcon, ReplyIcon } from "lucide-vue-next";+import { ReplyIcon } from "lucide-vue-next";import { NButton, NTag } from "naive-ui";import { computed } from "vue";-import { useI18n } from "vue-i18n";import UserAvatar from "@/components/User/UserAvatar.vue";import ServiceAccountTag from "@/components/misc/ServiceAccountTag.vue";import SystemBotTag from "@/components/misc/SystemBotTag.vue";import YouTag from "@/components/misc/YouTag.vue";-import {- pushNotification,- useCurrentUserV1,- usePermissionStore,-} from "@/store";+import { CopyButton } from "@/components/v2";+import { useCurrentUserV1, usePermissionStore } from "@/store";import { SYSTEM_BOT_USER_NAME } from "@/types";import { UserType, type User } from "@/types/proto/v1/user_service";-import { hasWorkspacePermissionV2, toClipboard } from "@/utils";+import { hasWorkspacePermissionV2 } from "@/utils";defineProps<{user: User;@@ -102,21 +96,10 @@ defineEmits<{(event: "reset-service-key", user: User): void;}>();-const { t } = useI18n();const currentUserV1 = useCurrentUserV1();const permissionStore = usePermissionStore();const allowEdit = computed(() => {return hasWorkspacePermissionV2("bb.policies.update");});--const copyServiceKey = (serviceKey: string) => {- toClipboard(serviceKey).then(() => {- pushNotification({- module: "bytebase",- style: "INFO",- title: t("settings.members.service-key-copied"),- });- });-};</script>diff --git a/frontend/src/components/User/Settings/UserDataTable/index.vue b/frontend/src/components/User/Settings/UserDataTable/index.vueindex cfbbebe18d..4d23a1ae0d 100644--- a/frontend/src/components/User/Settings/UserDataTable/index.vue+++ b/frontend/src/components/User/Settings/UserDataTable/index.vue@@ -26,10 +26,10 @@ import { NDataTable } from "naive-ui";import { computed, reactive, h } from "vue";import { useI18n } from "vue-i18n";import { BBAlert } from "@/bbkit";-import { useUserStore, useWorkspaceV1Store } from "@/store";+import { useUserStore, useWorkspaceV1Store, pushNotification } from "@/store";import type { Group } from "@/types/proto/v1/group_service";import { type User } from "@/types/proto/v1/user_service";-import { copyServiceKeyToClipboardIfNeeded } from "../common";+import { toClipboard } from "@/utils";import GroupsCell from "./cells/GroupsCell.vue";import UserNameCell from "./cells/UserNameCell.vue";import UserOperationsCell from "./cells/UserOperationsCell.vue";@@ -143,7 +143,15 @@ const resetServiceKey = () => {regenerateTempMfaSecret: false,}).then((updatedUser) => {- copyServiceKeyToClipboardIfNeeded(updatedUser);+ if (updatedUser.serviceKey) {+ toClipboard(updatedUser.serviceKey).then(() => {+ pushNotification({+ module: "bytebase",+ style: "INFO",+ title: t("settings.members.service-key-copied"),+ });+ });+ }});};</script>diff --git a/frontend/src/components/User/Settings/common.ts b/frontend/src/components/User/Settings/common.tsdeleted file mode 100644index 4b6953b5d9..0000000000--- a/frontend/src/components/User/Settings/common.ts+++ /dev/null@@ -1,16 +0,0 @@-import { t } from "@/plugins/i18n";-import { pushNotification } from "@/store";-import { type User } from "@/types/proto/v1/user_service";-import { toClipboard } from "@/utils";--export const copyServiceKeyToClipboardIfNeeded = (user: User) => {- if (!user.serviceKey) return;-- toClipboard(user.serviceKey);-- pushNotification({- module: "bytebase",- style: "INFO",- title: t("settings.members.service-key-copied"),- });-};diff --git a/frontend/src/components/v2/Button/CopyButton.vue b/frontend/src/components/v2/Button/CopyButton.vuenew file mode 100644index 0000000000..e4e945f2dc--- /dev/null+++ b/frontend/src/components/v2/Button/CopyButton.vue@@ -0,0 +1,55 @@+<template>+ <NButton+ v-if="isSupported && content"+ v-bind="$attrs"+ :text="text"+ :size="size"+ :disabled="disabled"+ @click="handleCopy"+ >+ <template #icon>+ <CopyIcon />+ </template>+ <slot />+ </NButton>+</template>++<script lang="ts" setup>+import { useClipboard } from "@vueuse/core";+import { CopyIcon } from "lucide-vue-next";+import { NButton } from "naive-ui";+import { useI18n } from "vue-i18n";+import { pushNotification } from "@/store";++const props = withDefaults(+ defineProps<{+ content: string;+ text?: boolean;+ disabled?: boolean;+ size?: "tiny" | "small" | "medium" | "large";+ }>(),+ {+ text: true,+ disabled: false,+ size: "tiny",+ }+);++const { copy: copyTextToClipboard, isSupported } = useClipboard({+ legacy: true,+});+const { t } = useI18n();++const handleCopy = () => {+ if (!isSupported.value) {+ return;+ }+ copyTextToClipboard(props.content).then(() => {+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.copied"),+ });+ });+};+</script>diff --git a/frontend/src/components/v2/Button/index.ts b/frontend/src/components/v2/Button/index.tsindex 4e9cc2ac51..9e49680b7f 100644--- a/frontend/src/components/v2/Button/index.ts+++ b/frontend/src/components/v2/Button/index.ts@@ -1,4 +1,5 @@import ContextMenuButton from "./ContextMenuButton.vue";+import CopyButton from "./CopyButton.vue";import DeleteConfirmButton from "./DeleteConfirmButton.vue";import ErrorTipsButton from "./ErrorTipsButton.vue";import MiniActionButton from "./MiniActionButton.vue";@@ -10,5 +11,6 @@ export {ErrorTipsButton,MiniActionButton,DeleteConfirmButton,+ CopyButton,};export * from "./types";diff --git a/frontend/src/components/v2/Form/ResourceIdField.vue b/frontend/src/components/v2/Form/ResourceIdField.vueindex bedc7cc9c7..2403a8d0d6 100644--- a/frontend/src/components/v2/Form/ResourceIdField.vue+++ b/frontend/src/components/v2/Form/ResourceIdField.vue@@ -5,11 +5,7 @@{{ $t("resource-id.self", { resource: resourceName }) }}:<div v-if="state.resourceId" class="text-gray-600 font-medium mr-1 flex items-center gap-x-1">{{ state.resourceId }}- <NButton v-if="isSupported && readonly" text size="tiny" @click="handleCopy">- <template #icon>- <CopyIcon class="w-3 h-3" />- </template>- </NButton>+ <CopyButton v-if="readonly" :content="value"/></div><span v-else class="text-control-placeholder italic">{{ "<EMPTY>" }}@@ -63,16 +59,14 @@</template><script lang="ts" setup>-import { NInput, NButton, type InputProps } from "naive-ui";+import { NInput, type InputProps } from "naive-ui";import { Status } from "nice-grpc-common";import { computed, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import type { ResourceId, ValidatedMessage } from "@/types";import { randomString } from "@/utils";import { getErrorCode } from "@/utils/grpcweb";-import { CopyIcon } from "lucide-vue-next";-import { useClipboard } from "@vueuse/core";-import { pushNotification } from "@/store"+import { CopyButton } from "@/components/v2"// characters is the validated characters for resource id.const characters = "abcdefghijklmnopqrstuvwxyz1234567890-";@@ -297,24 +291,6 @@ watch(});-const { copy: copyTextToClipboard, isSupported } = useClipboard({- legacy: true,-});--const handleCopy = () => {- if (!isSupported.value) {- return;- }- copyTextToClipboard(props.value).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.copied"),- });- });-};--defineExpose({resourceId: computed(() => state.resourceId),isValidated: computed(() => {diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 7e9646de3c..7f9063521c 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -513,8 +513,7 @@"gitlab-template-description": "Sign in with GitLab accounts","microsoft-entra-template-description": "Sign in with Microsoft Entra ID","custom-template-description": "Configure custom OAuth 2.0 provider"- },- "copy-redirect-url": "Redirect URL copied to clipboard."+ }},"general": {"workspace": {@@ -741,7 +740,6 @@"classification": {"upload": "Upload classification","upload-label": "You can upload classification file with JSON format.",- "copy-succeed": "Copy example succeed","override-title": "Classification data override","override-desc": "Existed classification data will be overridden and affect all projects.","override-confirm": "Still upload"@@ -1309,7 +1307,6 @@"unable-to-connect": "Bytebase is unable to connect the instance. We recommend you to review the connection info again. But it's OK to ignore this warning for now. You can still fix the connection info from the instance detail page after creation.\n\nError detail: {0}","successfully-created-instance-createdinstance-name": "Successfully created instance '{0}'.","successfully-updated-instance-instance-name": "Successfully updated instance '{0}'.",- "copy-grant-statement": "CREATE USER and GRANT statements copied to clipboard. Paste to your {engine} client to apply.","successfully-connected-instance": "Successfully connected instance.","failed-to-connect-instance": "Failed to connect instance.","failed-to-connect-instance-localhost": "If you run Bytebase with Docker, please try \"host.docker.internal\" for the host address.",@@ -1871,10 +1868,6 @@}},"copy-url": "Copy URL",- "notify": {- "copy-code-succeed": "Copy code succeed",- "copy-share-link": "The share link was copied to Clipboard."- },"connect-to-a-database": "Connect to a database","link-access": "Link access","private": "Private",@@ -1940,7 +1933,6 @@"pending-query": "Pending query","executing-query": "Executing query","request-query": "Request query",- "copy-success": "Copy success","connect-in-new-tab": "Connect in new tab","copy-name": "Copy name","preview-table-data": "Preview table data",@@ -2416,7 +2408,6 @@"no-more": "no more"}},- "statement-copied": "Statement copied to clipboard","text2sql": "Text2SQL","actions": {"explain-code": "Explain code",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 40d2e7a23f..e72605cb34 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -513,8 +513,7 @@"gitlab-template-description": "Iniciar sesión con cuentas de GitLab","microsoft-entra-template-description": "Iniciar sesión con el ID de Microsoft Entra","custom-template-description": "Configurar un proveedor OAuth 2.0 personalizado"- },- "copy-redirect-url": "URL de redireccionamiento copiada al portapapeles."+ }},"general": {"workspace": {@@ -741,7 +740,6 @@"classification": {"upload": "Subir clasificación","upload-label": "Puede cargar un archivo de clasificación con formato JSON.",- "copy-succeed": "Copiar ejemplo correctamente","override-title": "Anulación de datos de clasificación","override-desc": "Los datos de clasificación existentes se anularán y afectarán a todos los proyectos.","override-confirm": "Aún subiendo"@@ -1309,7 +1307,6 @@"unable-to-connect": "Bytebase no puede conectar la instancia. Le recomendamos que revise la información de conexión nuevamente. Pero está bien ignorar esta advertencia por ahora. Aún puede solucionar la información de conexión desde la página de detalles de la instancia después de la creación.\n\nDetalle del error: {0}","successfully-created-instance-createdinstance-name": "Se ha creado correctamente la instancia '{0}'.","successfully-updated-instance-instance-name": "Se ha actualizado correctamente la instancia '{0}'.",- "copy-grant-statement": "Se ha copiado la declaración CREATE USER y GRANT al portapapeles. Pegue en su cliente de {engine} para aplicar.","successfully-connected-instance": "Instancia conectada correctamente.","failed-to-connect-instance": "Error al conectar la instancia.","failed-to-connect-instance-localhost": "Si ejecuta Bytebase con Docker, intente \"host.docker.internal\" para la dirección del host.",@@ -1871,10 +1868,6 @@}},"copy-url": "Copiar URL",- "notify": {- "copy-code-succeed": "Copia de código exitosa",- "copy-share-link": "El enlace compartido se copió al portapapeles."- },"connect-to-a-database": "Conectarse a una base de datos","link-access": "Acceso al enlace","private": "Privado",@@ -1940,7 +1933,6 @@"pending-query": "Consulta pendiente","executing-query": "Ejecutando consulta","request-query": "Solicitar consulta",- "copy-success": "Copiado al portapapeles","connect-in-new-tab": "Conéctate en una nueva pestaña","copy-name": "Copiar nombre","preview-table-data": "Vista previa de datos de la tabla",@@ -2416,7 +2408,6 @@"no-more": "No más"}},- "statement-copied": "Declaración copiada al portapapeles","text2sql": "Text2SQL","actions": {"explain-code": "Explicar el código",@@ -2802,4 +2793,4 @@"last-visit": "Última visita","changelog-for-version": "Registro de cambios para {version}"}-}\ No newline at end of file+}diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex e8a7f0acbf..60644a1fe7 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -513,8 +513,7 @@"gitlab-template-description": "GitLabアカウントでサインイン","microsoft-entra-template-description": "Microsoft Entra IDでサインイン","custom-template-description": "カスタムOAuth 2.0プロバイダーを構成する"- },- "copy-redirect-url": "リダイレクト URL がクリップボードにコピーされました。"+ }},"general": {"workspace": {@@ -741,7 +740,6 @@"classification": {"upload": "分類をアップロード","upload-label": "データを分類・分類したJSON形式ファイルをアップロードできます。",- "copy-succeed": "サンプルをコピーしました","override-title": "カバレッジの分類および等級付けされたデータ","override-desc": "既存の分類およびグレーディング データは上書きされ、関連するすべてのプロジェクトが影響を受けます。","override-confirm": "インポートを続行する"@@ -1309,7 +1307,6 @@"unable-to-connect": "Bytebase はインスタンスに接続できません。接続情報を再度確認することをお勧めします。ただし、今のところこの警告は無視してかまいません。作成後もインスタンスの詳細ページで接続情報を修正できます。\n\nエラーの詳細:{0}","successfully-created-instance-createdinstance-name": "インスタンス '{0}' が正常に作成されました。","successfully-updated-instance-instance-name": "インスタンス '{0}' が正常に更新されました。",- "copy-grant-statement": "CREATE USER および GRANT ステートメントがクリップボードにコピーされました。 {engine} クライアントに貼り付けます。","successfully-connected-instance": "インスタンスに正常に接続されました。","failed-to-connect-instance": "インスタンスへの接続に失敗しました。","failed-to-connect-instance-localhost": "Docker デプロイメントを使用している場合は、ホスト アドレスとして「host.docker.internal」を使用してみてください。",@@ -1871,10 +1868,6 @@}},"copy-url": "URLをコピー",- "notify": {- "copy-code-succeed": "コードが正常にコピーされました",- "copy-share-link": "共有リンクがクリップボードにコピーされました"- },"connect-to-a-database": "データベースに接続する","link-access": "リンクアクセス","private": "プライベート",@@ -1940,7 +1933,6 @@"pending-query": "保留中のクエリ","executing-query": "クエリの実行","request-query": "リクエストクエリ",- "copy-success": "正常にコピーされました","connect-in-new-tab": "新しいタブで接続する","copy-name": "名前をコピーする","preview-table-data": "テーブルデータのプレビュー",@@ -2416,7 +2408,6 @@"no-more": "何も残っていない"}},- "statement-copied": "ステートメントがクリップボードにコピーされました","text2sql": "Text2SQL","actions": {"explain-code": "コードの説明",@@ -2802,4 +2793,4 @@"last-visit": "最終訪問","changelog-for-version": "{version} の変更履歴"}-}\ No newline at end of file+}diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 3fe42df023..9dae0d1b5f 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -513,8 +513,7 @@"gitlab-template-description": "Đăng nhập bằng tài khoản GitLab","microsoft-entra-template-description": "Đăng nhập bằng ID Microsoft Entra","custom-template-description": "Cấu hình nhà cung cấp OAuth 2.0 tùy chỉnh"- },- "copy-redirect-url": "URL chuyển hướng đã được sao chép vào bộ nhớ tạm."+ }},"general": {"workspace": {@@ -741,7 +740,6 @@"classification": {"upload": "Tải lên phân loại","upload-label": "Bạn có thể tải lên tệp phân loại với định dạng JSON.",- "copy-succeed": "Sao chép ví dụ thành công","override-title": "Ghi đè dữ liệu phân loại","override-desc": "Dữ liệu phân loại hiện có sẽ bị ghi đè và ảnh hưởng đến tất cả các dự án.","override-confirm": "Vẫn tải lên"@@ -1309,7 +1307,6 @@"unable-to-connect": "Bytebase không thể kết nối với phiên bản. Chúng tôi khuyên bạn nên xem xét lại thông tin kết nối. Nhưng bạn có thể bỏ qua cảnh báo này ngay bây giờ. Bạn vẫn có thể sửa thông tin kết nối từ trang chi tiết phiên bản sau khi tạo.\n\nChi tiết lỗi: {0}","successfully-created-instance-createdinstance-name": "Đã tạo thành công phiên bản '{0}'.","successfully-updated-instance-instance-name": "Đã cập nhật thành công phiên bản '{0}'.",- "copy-grant-statement": "Các câu lệnh CREATE USER và GRANT đã được sao chép vào khay nhớ tạm. Dán vào ứng dụng khách {engine} của bạn để áp dụng.","successfully-connected-instance": "Đã kết nối thành công với phiên bản.","failed-to-connect-instance": "Không kết nối được với phiên bản.","failed-to-connect-instance-localhost": "Nếu bạn chạy Bytebase bằng Docker, vui lòng thử \"host.docker.internal\" cho địa chỉ máy chủ.",@@ -1871,10 +1868,6 @@}},"copy-url": "Sao chép URL",- "notify": {- "copy-code-succeed": "Sao chép mã thành công",- "copy-share-link": "Liên kết chia sẻ đã được sao chép vào khay nhớ tạm."- },"connect-to-a-database": "Kết nối với cơ sở dữ liệu","link-access": "Truy cập liên kết","private": "Riêng tư",@@ -1940,7 +1933,6 @@"pending-query": "Đang chờ truy vấn","executing-query": "Đang thực hiện truy vấn","request-query": "Yêu cầu truy vấn",- "copy-success": "Sao chép thành công","connect-in-new-tab": "Kết nối trong tab mới","copy-name": "Sao chép tên","preview-table-data": "Xem trước dữ liệu bảng",@@ -2416,7 +2408,6 @@"no-more": "không còn nữa"}},- "statement-copied": "Câu lệnh đã được sao chép vào khay nhớ tạm","text2sql": "Chuyển văn bản thành SQL","actions": {"explain-code": "Giải thích mã",@@ -2802,4 +2793,4 @@"last-visit": "Lần truy cập cuối","changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"}-}\ No newline at end of file+}diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 23e30b9e14..6c3a8c8d1f 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -513,8 +513,7 @@"gitlab-template-description": "使用 GitLab 帐户登录","microsoft-entra-template-description": "使用 Microsoft Entra ID 登录","custom-template-description": "配置自定义 OAuth 2.0 提供商"- },- "copy-redirect-url": "Redirect URL 已复制到剪切板。"+ }},"general": {"workspace": {@@ -741,7 +740,6 @@"classification": {"upload": "导入分类分级","upload-label": "您可以上传数据分类分级的 JSON 格式文件。",- "copy-succeed": "样例已复制","override-title": "覆盖分类分级数据","override-desc": "已有的分类分级数据将会被覆盖,涉及到的项目都会受到影响。","override-confirm": "继续导入"@@ -1309,7 +1307,6 @@"unable-to-connect": "Bytebase 无法连接到实例。我们推荐您再检查一遍连接信息。但也可以暂时忽略此警告。您在创建后仍能在实例详细页里修复连接信息。\n\n错误详情:{0}","successfully-created-instance-createdinstance-name": "成功创建实例'{0}'。","successfully-updated-instance-instance-name": "成功更新实例'{0}'。",- "copy-grant-statement": "CREATE USER and GRANT 语句已复制到剪贴板。 粘贴到您的 {engine} 客户端。","successfully-connected-instance": "成功连接到实例。","failed-to-connect-instance": "连接到实例失败。","failed-to-connect-instance-localhost": "如果您使用的 Docker 部署,请尝试使用 \"host.docker.internal\" 作为 Host 地址。",@@ -1871,10 +1868,6 @@}},"copy-url": "复制 URL",- "notify": {- "copy-code-succeed": "代码复制成功",- "copy-share-link": "分享链接已拷贝到剪贴板"- },"connect-to-a-database": "连接到数据库","link-access": "链接访问权限","private": "私有",@@ -1940,7 +1933,6 @@"pending-query": "待处理查询","executing-query": "执行查询","request-query": "请求查询",- "copy-success": "复制成功","connect-in-new-tab": "在新选项卡中连接","copy-name": "复制名称","preview-table-data": "预览表数据",@@ -2416,7 +2408,6 @@"no-more": "没有了"}},- "statement-copied": "语句已复制到剪贴板","text2sql": "Text2SQL","actions": {"explain-code": "解释代码",@@ -2802,4 +2793,4 @@"last-visit": "上次访问","changelog-for-version": "{version} 的更新日志"}-}\ No newline at end of file+}diff --git a/frontend/src/plugins/ai/components/ChatView/Markdown/CodeBlock.vue b/frontend/src/plugins/ai/components/ChatView/Markdown/CodeBlock.vueindex eff2bf585c..a5f9cc2f92 100644--- a/frontend/src/plugins/ai/components/ChatView/Markdown/CodeBlock.vue+++ b/frontend/src/plugins/ai/components/ChatView/Markdown/CodeBlock.vue@@ -36,12 +36,7 @@</NPopover><NPopover placement="bottom"><template #trigger>- <button- class="inline-flex items-center justify-center hover:text-accent cursor-pointer"- @click="handleCopy"- >- <ClipboardIcon class="w-3.5 h-3.5" />- </button>+ <CopyButton :content="code" /></template><div class="whitespace-nowrap">{{ $t("common.copy") }}@@ -80,14 +75,13 @@<script lang="ts" setup>import { useElementSize } from "@vueuse/core";-import { ClipboardIcon, PlayIcon } from "lucide-vue-next";+import { PlayIcon } from "lucide-vue-next";import { NPopover } from "naive-ui";import { computed, ref } from "vue";-import { useI18n } from "vue-i18n";import { MonacoEditor } from "@/components/MonacoEditor";+import { CopyButton } from "@/components/v2";import { useAIContext } from "@/plugins/ai/logic";-import { pushNotification } from "@/store";-import { findAncestor, toClipboard } from "@/utils";+import { findAncestor } from "@/utils";import { useSQLEditorContext } from "@/views/sql-editor/context";import InsertAtCaretIcon from "./InsertAtCaretIcon.vue";@@ -101,7 +95,6 @@ const props = defineProps<}>();-const { t } = useI18n();const { events, showHistoryDialog } = useAIContext();const { events: editorEvents } = useSQLEditorContext();const containerRef = ref<HTMLElement>();@@ -130,14 +123,4 @@ const handleInsertAtCaret = () => {});showHistoryDialog.value = false;};--const handleCopy = () => {- toClipboard(props.code).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("plugin.ai.statement-copied"),- });- });-};</script>diff --git a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail/DatabaseDetail.vueindex 01f8e24d43..ba7e38aff9 100644--- a/frontend/src/views/DatabaseDetail/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail/DatabaseDetail.vue@@ -27,18 +27,11 @@class="w-5 h-5"/></h1>- <div class="flex items-center">+ <div class="flex items-center space-x-1"><span class="textinfolabel">{{ database.name }}</span>- <NButton- v-if="isSupported"- quaternary- size="tiny"- @click="handleCopyDatabaseName(database.name)"- >- <ClipboardCopyIcon class="w-4 h-4" />- </NButton>+ <CopyButton :content="database.name" /></div></div></div>@@ -201,12 +194,10 @@<script lang="ts" setup>import { useTitle } from "@vueuse/core";-import { useClipboard } from "@vueuse/core";import dayjs from "dayjs";-import { ArrowRightLeftIcon, ClipboardCopyIcon } from "lucide-vue-next";+import { ArrowRightLeftIcon } from "lucide-vue-next";import { NButton, NTabPane, NTabs } from "naive-ui";import { computed, reactive, watch } from "vue";-import { useI18n } from "vue-i18n";import { useRouter, useRoute } from "vue-router";import { BBModal } from "@/bbkit";import SchemaEditorModal from "@/components/AlterSchemaPrepForm/SchemaEditorModal.vue";@@ -230,12 +221,12 @@ import {ProductionEnvironmentV1Icon,ProjectV1Name,} from "@/components/v2";+import { CopyButton } from "@/components/v2";import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";import {useAppFeature,useEnvironmentV1Store,useDatabaseV1ByName,- pushNotification,} from "@/store";import {databaseNamePrefix,@@ -277,7 +268,6 @@ const props = defineProps<{databaseName: string;}>();-const { t } = useI18n();const router = useRouter();const state = reactive<LocalState>({@@ -396,20 +386,4 @@ const environment = computed(() => {});useTitle(computed(() => database.value.databaseName));--const { copy: copyTextToClipboard, isSupported } = useClipboard({- legacy: true,-});-const handleCopyDatabaseName = (name: string) => {- if (!isSupported.value) {- return;- }- copyTextToClipboard(name).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.copied"),- });- });-};</script>diff --git a/frontend/src/views/ProjectDashboard.vue b/frontend/src/views/ProjectDashboard.vueindex 59be78f3cf..b10271d5f7 100644--- a/frontend/src/views/ProjectDashboard.vue+++ b/frontend/src/views/ProjectDashboard.vue@@ -1,13 +1,11 @@<template><div class="flex flex-col space-y-4">- <div class="flex items-center justify-between px-4">- <div class="flex items-center space-x-2">- <SearchBox- v-model:value="state.searchText"- style="max-width: 100%"- :placeholder="$t('common.filter-by-name')"- />- </div>+ <div class="flex items-center justify-between px-4 space-x-2">+ <AdvancedSearch+ v-model:params="state.params"+ :autofocus="false"+ :placeholder="$t('common.filter-by-name')"+ /><NButtonv-if="hasWorkspacePermissionV2('bb.projects.create')"type="primary"@@ -58,16 +56,17 @@ import { NButton } from "naive-ui";import { computed, onMounted, reactive, ref } from "vue";import type { ComponentExposed } from "vue-component-type-helpers";import { useRouter } from "vue-router";+import AdvancedSearch from "@/components/AdvancedSearch";import ProjectCreatePanel from "@/components/Project/ProjectCreatePanel.vue";-import { SearchBox, PagedProjectTable } from "@/components/v2";+import { PagedProjectTable } from "@/components/v2";import { Drawer } from "@/components/v2";import ProjectOperations from "@/components/v2/Model/Project/ProjectOperations.vue";import { useProjectV1Store, useUIStateStore } from "@/store";import type { ComposedProject } from "@/types";-import { hasWorkspacePermissionV2 } from "@/utils";+import { hasWorkspacePermissionV2, type SearchParams } from "@/utils";interface LocalState {- searchText: string;+ params: SearchParams;showCreateDrawer: boolean;selectedProjects: Set<string>;}@@ -77,7 +76,10 @@ const props = defineProps<{}>();const state = reactive<LocalState>({- searchText: "",+ params: {+ query: "",+ scopes: [],+ },showCreateDrawer: false,selectedProjects: new Set(),});@@ -88,7 +90,7 @@ const projectStore = useProjectV1Store();const pagedProjectTableRef = ref<ComponentExposed<typeof PagedProjectTable>>();const filter = computed(() => ({- query: state.searchText,+ query: state.params.query,excludeDefault: true,}));diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vueindex 328027b1c9..6c9425a0cc 100644--- a/frontend/src/views/SettingWorkspaceSubscription.vue+++ b/frontend/src/views/SettingWorkspaceSubscription.vue@@ -88,21 +88,20 @@<div class="mb-3 text-sm text-gray-400">{{ $t("settings.general.workspace.id-description") }}</div>- <div class="mb-4 flex space-x-2">+ <div class="mb-4 flex items-center space-x-2"><NInputref="workspaceIdField"- class="mb-4 w-full"+ class="w-full"readonly:value="workspaceId"@click="selectWorkspaceId"/>- <NButton- v-if="isSupported"- :disabled="!workspaceId"- @click="handleCopyId"- >- <ClipboardCopyIcon class="w-4 h-4" />- </NButton>+ <CopyButton+ quaternary+ :text="false"+ :size="'small'"+ :content="workspaceId"+ /></div></div><div@@ -155,10 +154,15 @@</template><script lang="ts" setup>+import { NButton, NDivider, NInput } from "naive-ui";+import { storeToRefs } from "pinia";+import { computed, reactive, ref } from "vue";+import { useI18n } from "vue-i18n";import LearnMoreLink from "@/components/LearnMoreLink.vue";import TrialModal from "@/components/TrialModal.vue";import WeChatQRModal from "@/components/WeChatQRModal.vue";import WorkspaceInstanceLicenseStats from "@/components/WorkspaceInstanceLicenseStats.vue";+import { CopyButton } from "@/components/v2";import { useLanguage } from "@/composables/useLanguage";import {pushNotification,@@ -170,12 +174,6 @@ import { ENTERPRISE_INQUIRE_LINK } from "@/types";import { Setting_SettingName } from "@/types/proto/v1/setting_service";import { PlanType } from "@/types/proto/v1/subscription_service";import { hasWorkspacePermissionV2 } from "@/utils";-import { useClipboard } from "@vueuse/core";-import { ClipboardCopyIcon } from "lucide-vue-next";-import { NButton, NDivider, NInput } from "naive-ui";-import { storeToRefs } from "pinia";-import { computed, reactive, ref } from "vue";-import { useI18n } from "vue-i18n";interface LocalState {loading: boolean;@@ -220,7 +218,8 @@ const workspaceIdField = ref<HTMLInputElement | null>(null);const workspaceId = computed(() => {return (- settingV1Store.getSettingByName(Setting_SettingName.WORKSPACE_ID)?.value?.stringValue ?? ""+ settingV1Store.getSettingByName(Setting_SettingName.WORKSPACE_ID)?.value+ ?.stringValue ?? "");});@@ -228,21 +227,6 @@ const selectWorkspaceId = () => {workspaceIdField.value?.select();};-const { copy: copyTextToClipboard, isSupported } = useClipboard({- legacy: true,-});--const handleCopyId = () => {- selectWorkspaceId();- copyTextToClipboard(workspaceId.value).then(() => {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.copied"),- });- });-};-const uploadLicense = async () => {if (disabled.value) return;state.loading = true;diff --git a/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue b/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vueindex 29ffc44d83..43e36d52cd 100644--- a/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue+++ b/frontend/src/views/sql-editor/AsidePanel/HistoryPane/HistoryPane.vue@@ -23,14 +23,12 @@{{ titleOfQueryHistory(history) }}</span></div>- <span- class="rounded text-gray-500 hover:text-gray-700 hover:bg-gray-200"- >- <heroicons-outline:clipboard-document- class="w-4 h-4"- @click.stop="handleCopy(history)"- />- </span>+ <CopyButton+ quaternary+ :text="false"+ :content="history.statement"+ @click.stop+ /></div><pclass="max-w-full text-xs break-words font-mono line-clamp-3"@@ -68,7 +66,6 @@<script lang="ts" setup>import { useDebounceFn } from "@vueuse/core";-import { useClipboard } from "@vueuse/core";import dayjs from "dayjs";import { escape } from "lodash-es";import { NButton, useDialog } from "naive-ui";@@ -76,8 +73,8 @@ import { computed, h, reactive, watch } from "vue";import { useI18n } from "vue-i18n";import MaskSpinner from "@/components/misc/MaskSpinner.vue";import { SearchBox } from "@/components/v2";+import { CopyButton } from "@/components/v2";import {- pushNotification,useSQLEditorQueryHistoryStore,useSQLEditorTabStore,useSQLEditorStore,@@ -148,10 +145,6 @@ watch(});-const { copy: copyTextToClipboard, isSupported } = useClipboard({- legacy: true,-});-const getFormattedStatement = (statement: string) => {return state.search? getHighlightHTMLByKeyWords(escape(statement), escape(state.search))@@ -164,28 +157,8 @@ const titleOfQueryHistory = (history: QueryHistory) => {);};-const handleCopy = (history: QueryHistory) => {- if (!isSupported.value) {- pushNotification({- module: "bytebase",- style: "CRITICAL",- title: "Copy to clipboard is not enabled in your browser.",- });- return;- }-- copyTextToClipboard(history.statement);- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("sql-editor.notify.copy-code-succeed"),- });-};--const confirmOverrideCurrentStatement = (): Promise<- "CANCEL" | "OVERRIDE" | "COPY"-> => {- const d = defer<"CANCEL" | "OVERRIDE" | "COPY">();+const confirmOverrideCurrentStatement = (): Promise<"CANCEL" | "OVERRIDE"> => {+ const d = defer<"CANCEL" | "OVERRIDE">();const dialog = $d.warning({title: t("common.warning"),content: t("sql-editor.current-editing-statement-is-not-empty"),@@ -210,15 +183,6 @@ const confirmOverrideCurrentStatement = (): Promise<},{ default: () => t("common.override") }),- h(- NButton,- {- size: "small",- type: "primary",- onClick: () => d.resolve("COPY"),- },- { default: () => t("common.copy") }- ),];return h("div",@@ -261,7 +225,6 @@ const handleQueryHistoryClick = async (queryHistory: QueryHistory) => {});return;}- handleCopy(queryHistory);};if (tab) {diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DetailPanel/DetailPanel.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DetailPanel/DetailPanel.vueindex be0b0103a1..c65fcc8e0a 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DetailPanel/DetailPanel.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DetailPanel/DetailPanel.vue@@ -92,12 +92,13 @@@click.stop/>- <NButton v-if="!disallowCopyingData" size="small" @click="handleCopy">- <template #icon>- <ClipboardIcon class="w-4 h-4" />- </template>- {{ $t("common.copy") }}- </NButton>+ <CopyButton+ v-if="!disallowCopyingData"+ quaternary+ size="small"+ :text="false"+ :content="copyContent"+ /></div></div><NScrollbar@@ -143,19 +144,17 @@</template><script setup lang="ts">-import { onKeyStroke, useClipboard, useLocalStorage } from "@vueuse/core";+import { onKeyStroke, useLocalStorage } from "@vueuse/core";import {ChevronDownIcon,ChevronUpIcon,- ClipboardIcon,BracesIcon,WrapTextIcon,} from "lucide-vue-next";import { NButton, NPopover, NScrollbar, NTooltip } from "naive-ui";import { computed } from "vue";-import { useI18n } from "vue-i18n";import { DrawerContent } from "@/components/v2";-import { pushNotification } from "@/store";+import { CopyButton } from "@/components/v2";import type { RowValue } from "@/types/proto/v1/sql_service";import { extractSQLRowValuePlain } from "@/utils";import {@@ -167,7 +166,6 @@ import BinaryFormatButton from "../DataTable/common/BinaryFormatButton.vue";import { useSQLResultViewContext } from "../context";import PrettyJSON from "./PrettyJSON.vue";-const { t } = useI18n();const { dark, detail, disallowCopyingData } = useSQLResultViewContext();const { getBinaryFormat, setBinaryFormat } = useBinaryFormatContext();@@ -270,44 +268,30 @@ const contentClass = computed(() => {return classes.join(" ");});-const { copy, copied } = useClipboard({- source: computed(() => {- const raw = content.value ?? "";+const copyContent = computed(() => {+ const raw = content.value ?? "";- // For JSON content- if (guessedIsJSON.value && format.value) {- try {- const obj = JSON.parse(raw);- return JSON.stringify(obj, null, " ");- } catch {- console.warn(- "[DetailPanel]",- "failed to parse and format (maybe) JSON value"- );- return raw;- }- }-- // For binary data, copy according to the selected format- if (isBinaryData.value) {+ // For JSON content+ if (guessedIsJSON.value && format.value) {+ try {+ const obj = JSON.parse(raw);+ return JSON.stringify(obj, null, " ");+ } catch {+ console.warn(+ "[DetailPanel]",+ "failed to parse and format (maybe) JSON value"+ );return raw;}+ }+ // For binary data, copy according to the selected format+ if (isBinaryData.value) {return raw;- }),- legacy: true,+ }++ return raw;});-const handleCopy = () => {- copy().then(() => {- if (copied.value) {- pushNotification({- module: "bytebase",- style: "INFO",- title: t("common.copied"),- });- }- });-};const move = (offset: number) => {if (!detail.value) {diff --git a/frontend/src/views/sql-editor/EditorCommon/SharePopover.vue b/frontend/src/views/sql-editor/EditorCommon/SharePopover.vueindex 12e9838a16..7d967261ea 100644--- a/frontend/src/views/sql-editor/EditorCommon/SharePopover.vue+++ b/frontend/src/views/sql-editor/EditorCommon/SharePopover.vue@@ -69,33 +69,27 @@<heroicons-solid:link class="w-5 h-auto" /></div></NInputGroupLabel>- <NInput v-model:value="sharedTabLink" disabled />- <NButton- class="w-20"- :type="copied ? 'success' : 'primary'"- :disabled="tabStore.currentTab?.status !== 'CLEAN'"- @click="handleCopy"- >- <heroicons-solid:check v-if="copied" class="h-4 w-4" />- {{ copied ? $t("common.copied") : $t("common.copy") }}- </NButton>+ <NInput :value="sharedTabLink" disabled />+ <div class="pl-2">+ <CopyButton+ quaternary+ :text="false"+ :size="'medium'"+ :content="sharedTabLink"+ :disabled="tabStore.currentTab?.status !== 'CLEAN'"+ />+ </div></NInputGroup></div></template><script lang="ts" setup>-import { useClipboard } from "@vueuse/core";import { LockKeyholeIcon, UsersIcon } from "lucide-vue-next";-import {- NButton,- NInput,- NInputGroup,- NInputGroupLabel,- NPopover,-} from "naive-ui";+import { NInput, NInputGroup, NInputGroupLabel, NPopover } from "naive-ui";import { ref, computed, onMounted, h } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";+import { CopyButton } from "@/components/v2";import { SQL_EDITOR_WORKSHEET_MODULE } from "@/router/sqlEditor";import {pushNotification,@@ -191,20 +185,6 @@ const sharedTabLink = computed(() => {).href;});-const { copy, copied } = useClipboard({- source: sharedTabLink.value,- legacy: true,-});--const handleCopy = async () => {- await copy();- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("sql-editor.notify.copy-share-link"),- });-};-onMounted(() => {if (sheet.value) {const { visibility } = sheet.value;