Skip to content

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

fix(SQL editor): copy sheet share link (#1501)

STEVEN93082c7ec914
diff --git a/frontend/package.json b/frontend/package.json
index ebe87e1ab5..a2937d3c6b 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -14,7 +14,7 @@
"dependencies": {
"@bytebase/vue-kbar": "^0.1.6",
"@soerenmartius/vue3-clipboard": "^0.1.2",
- "@vueuse/core": "^7.6.0",
+ "@vueuse/core": "^8.6.0",
"axios": "^0.26.0",
"dayjs": "^1.10.7",
"escape-string-regexp": "^5.0.0",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index 8e2fa2c173..3bc3330380 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -21,7 +21,7 @@ specifiers:
'@vitejs/plugin-vue': ^1.1.4
'@vue/compiler-sfc': ^3.2.4
'@vue/eslint-config-typescript': ^9.1.0
- '@vueuse/core': ^7.6.0
+ '@vueuse/core': ^8.6.0
autoprefixer: ^10.4.4
axios: ^0.26.0
dayjs: ^1.10.7
@@ -61,7 +61,7 @@ specifiers:
dependencies:
'@bytebase/vue-kbar': [email protected]
'@soerenmartius/vue3-clipboard': 0.1.2
- '@vueuse/core': [email protected]
+ '@vueuse/core': [email protected]
axios: 0.26.1
dayjs: 1.10.8
escape-string-regexp: 5.0.0
@@ -102,7 +102,7 @@ devDependencies:
'@typescript-eslint/parser': 5.14.0_ynv3edxl3ah44xwgrna2g2yine
'@vitejs/plugin-vue': [email protected]
'@vue/compiler-sfc': 3.2.31
- '@vue/eslint-config-typescript': 9.1.0_ferhj2dr4dws36ciqwbscuzvcm
+ '@vue/eslint-config-typescript': 9.1.0_adhk4s5f3scaw5ovrjdremp7ca
autoprefixer: [email protected]
eslint: 8.11.0
eslint-config-prettier: [email protected]
@@ -153,7 +153,6 @@ packages:
/@babel/helper-validator-identifier/7.16.7:
resolution: {integrity: sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==}
engines: {node: '>=6.9.0'}
- dev: true
/@babel/highlight/7.16.10:
resolution: {integrity: sha512-5FnTQLSLswEj6IkgVw5KusNUUFY9ZGqe/TRFnP/BKYHYgfh7tc+C7mwiy95/yNP7Dh9x580Vv8r7u7ZfTBFxdw==}
@@ -168,6 +167,8 @@ packages:
resolution: {integrity: sha512-7yJPvPV+ESz2IUTPbOL+YkIGyCqOyNIzdguKQuJGnH7bg1WTIifuM21YqokFt/THWh1AkCRn9IgoykTRCBVpzA==}
engines: {node: '>=6.0.0'}
hasBin: true
+ dependencies:
+ '@babel/types': 7.18.4
/@babel/runtime/7.17.2:
resolution: {integrity: sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==}
@@ -176,6 +177,13 @@ packages:
regenerator-runtime: 0.13.9
dev: false
+ /@babel/types/7.18.4:
+ resolution: {integrity: sha512-ThN1mBcMq5pG/Vm2IcBmPPfyPXbd8S02rS+OBIDENdufvqC7Z/jHPCv9IcP01277aKtDI8g/2XysBN4hA8niiw==}
+ engines: {node: '>=6.9.0'}
+ dependencies:
+ '@babel/helper-validator-identifier': 7.16.7
+ to-fast-properties: 2.0.0
+
/@bytebase/vue-kbar/[email protected]:
resolution: {integrity: sha512-bRtp7UBiFuQ1EffF+F6keUG3bNk2OC1q1FLvUFkZ92kI0owiKDolaj4cBObGLSaDc8yk4L/KtuK9wlGFTJwkkw==}
peerDependencies:
@@ -298,14 +306,12 @@ packages:
'@intlify/message-compiler': 9.2.0-beta.32
'@intlify/shared': 9.2.0-beta.32
'@intlify/vue-devtools': 9.2.0-beta.32
- dev: false
/@intlify/devtools-if/9.2.0-beta.32:
resolution: {integrity: sha512-MvcxHrP7urM17wcna2vyqt8D8Pc5lyD3ps2BcmAr60UYifNKBQU7LmHfjTG7BZO4t0LyUWrWFJmm7fRVlju40g==}
engines: {node: '>= 12'}
dependencies:
'@intlify/shared': 9.2.0-beta.32
- dev: false
/@intlify/message-compiler/9.2.0-beta.32:
resolution: {integrity: sha512-7OOHIhOmOM4nqe3KfEuE65xLwawwBGg/pCFByzayf0jARoHkeaA7v/eKsUJVJMEakeF2pNstx06AvfecijgPzg==}
@@ -313,7 +319,6 @@ packages:
dependencies:
'@intlify/shared': 9.2.0-beta.32
source-map: 0.6.1
- dev: false
/@intlify/message-compiler/9.2.0-beta.36:
resolution: {integrity: sha512-u4EwW/U9Mc50G7vM1p24UQ3aPrrkm0eM60xKRLVib1XKpH+TK8taLeetSVPI/8mNOBkLNpXmysMfhD3HlsXHIA==}
@@ -326,7 +331,6 @@ packages:
/@intlify/shared/9.2.0-beta.32:
resolution: {integrity: sha512-lVaHnKFNg16eWlfDLzDFLapurrf0WK7xLWEkz8DMYNIXJshRQOZCkH7sQaqtONPoOT0LqjyPo1+sV0Wq85/HRQ==}
engines: {node: '>= 12'}
- dev: false
/@intlify/shared/9.2.0-beta.36:
resolution: {integrity: sha512-+IXLiQ0V+9muzEf7RT9t9wEh6hNIK+kq+34Lce8W+DYny/jaFxPWIU4REYja3xC16kV7q+fz4I3vFz03gh7ysA==}
@@ -364,7 +368,6 @@ packages:
dependencies:
'@intlify/core-base': 9.2.0-beta.32
'@intlify/shared': 9.2.0-beta.32
- dev: false
/@juggle/resize-observer/3.3.1:
resolution: {integrity: sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw==}
@@ -711,9 +714,8 @@ packages:
/@vue/devtools-api/6.1.0:
resolution: {integrity: sha512-1FtbxEEHN70WGJl1b/h8nLmyN+tOHONNsNLvgVEXF/L/vBrRqQZ0kF+dev1YAz3OtxsQ1sV/vPLKwRlq1axrgg==}
- dev: false
- /@vue/eslint-config-typescript/9.1.0_ferhj2dr4dws36ciqwbscuzvcm:
+ /@vue/eslint-config-typescript/9.1.0_adhk4s5f3scaw5ovrjdremp7ca:
resolution: {integrity: sha512-j/852/ZYQ5wDvCD3HE2q4uqJwJAceer2FwoEch1nFo+zTOsPrbzbE3cuWIs3kvu5hdFsGTMYwRwjI6fqZKDMxQ==}
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
peerDependencies:
@@ -721,11 +723,16 @@ packages:
'@typescript-eslint/parser': ^5.0.0
eslint: ^6.2.0 || ^7.0.0 || ^8.0.0
eslint-plugin-vue: ^8.0.1
+ typescript: '*'
+ peerDependenciesMeta:
+ typescript:
+ optional: true
dependencies:
'@typescript-eslint/eslint-plugin': 5.14.0_vttptz3sfoat4ipk6lojso6ecm
'@typescript-eslint/parser': 5.14.0_ynv3edxl3ah44xwgrna2g2yine
eslint: 8.11.0
eslint-plugin-vue: [email protected]
+ typescript: 4.6.2
vue-eslint-parser: [email protected]
transitivePeerDependencies:
- supports-color
@@ -750,7 +757,6 @@ packages:
dependencies:
'@vue/reactivity': 3.2.31
'@vue/shared': 3.2.31
- dev: false
/@vue/runtime-dom/3.2.31:
resolution: {integrity: sha512-N+o0sICVLScUjfLG7u9u5XCjvmsexAiPt17GNnaWHJUfsKed5e85/A3SWgKxzlxx2SW/Hw7RQxzxbXez9PtY3g==}
@@ -758,7 +764,6 @@ packages:
'@vue/runtime-core': 3.2.31
'@vue/shared': 3.2.31
csstype: 2.6.20
- dev: false
/@vue/server-renderer/[email protected]:
resolution: {integrity: sha512-8CN3Zj2HyR2LQQBHZ61HexF5NReqngLT3oahyiVRfSSvak+oAvVmu8iNLSu6XR77Ili2AOpnAt1y8ywjjqtmkg==}
@@ -768,7 +773,6 @@ packages:
'@vue/compiler-ssr': 3.2.31
'@vue/shared': 3.2.31
vue: 3.2.31
- dev: false
/@vue/shared/3.2.31:
resolution: {integrity: sha512-ymN2pj6zEjiKJZbrf98UM2pfDd6F2H7ksKw7NDt/ZZ1fh5Ei39X5tABugtT03ZRlWd9imccoK0hE8hpjpU7irQ==}
@@ -789,6 +793,27 @@ packages:
dev: false
+ /@vueuse/core/[email protected]:
+ resolution: {integrity: sha512-VirzExCm/N+QdrEWT7J4uSrvJ5hquKIAU9alQ37kUvIJk9XxCLxmfRnmekYc1kz2+6BnoyuKYXVmrMV351CB4w==}
+ peerDependencies:
+ '@vue/composition-api': ^1.1.0
+ vue: ^2.6.0 || ^3.2.0
+ peerDependenciesMeta:
+ '@vue/composition-api':
+ optional: true
+ vue:
+ optional: true
+ dependencies:
+ '@vueuse/metadata': 8.6.0
+ '@vueuse/shared': [email protected]
+ vue: 3.2.31
+ vue-demi: [email protected]
+ dev: false
+
+ /@vueuse/metadata/8.6.0:
+ resolution: {integrity: sha512-F+CKPvaExsm7QgRr8y+ZNJFwXasn89rs5wth/HeX9lJ1q8XEt+HJ16Q5Sxh4rfG5YSKXrStveVge8TKvPjMjFA==}
+ dev: false
+
/@vueuse/shared/[email protected]:
resolution: {integrity: sha512-rN2qd22AUl7VdBxihagWyhUNHCyVk9IpvBTTfHoLH9G7rGE552X1f+zeCfehuno0zXif13jPw+icW/wn2a0rnQ==}
peerDependencies:
@@ -801,7 +826,22 @@ packages:
optional: true
dependencies:
vue: 3.2.31
- vue-demi: [email protected]
+ vue-demi: [email protected]
+ dev: false
+
+ /@vueuse/shared/[email protected]:
+ resolution: {integrity: sha512-Y/IVywZo7IfEoSSEtCYpkVEmPV7pU35mEIxV7PbD/D3ly18B3mEsBaPbtDkNM/QP3zAZ5mn4nEkOfddX4uwuIA==}
+ peerDependencies:
+ '@vue/composition-api': ^1.1.0
+ vue: ^2.6.0 || ^3.2.0
+ peerDependenciesMeta:
+ '@vue/composition-api':
+ optional: true
+ vue:
+ optional: true
+ dependencies:
+ vue: 3.2.31
+ vue-demi: [email protected]
dev: false
/abbrev/1.1.1:
@@ -1109,7 +1149,6 @@ packages:
/csstype/2.6.20:
resolution: {integrity: sha512-/WwNkdXfckNgw6S5R125rrW8ez139lBHWouiBvX8dfMFtcn6V81REDqnH7+CRpRipfYlyU1CmOnOxrmGcFOjeA==}
- dev: false
/csstype/3.0.11:
resolution: {integrity: sha512-sa6P2wJ+CAbgyy4KFssIb/JNMLxFvKF1pCYCSXS8ZMuqZnMsrxqI2E5sPyoTpxoPU/gVZMzr2zjOfg8GIZOMsw==}
@@ -2630,6 +2669,10 @@ packages:
engines: {node: '>=14.0.0'}
dev: true
+ /to-fast-properties/2.0.0:
+ resolution: {integrity: sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=}
+ engines: {node: '>=4'}
+
/to-regex-range/5.0.1:
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
engines: {node: '>=8.0'}
@@ -2676,7 +2719,6 @@ packages:
resolution: {integrity: sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==}
engines: {node: '>=4.2.0'}
hasBin: true
- dev: true
/unplugin-icons/0.13.4_lw5qzsdy6ovzzkql26ywt3pnim:
resolution: {integrity: sha512-gyp5H4WADnXEE1uk8+NW6gnnALOlSpU8M5GwzNCYbUgjM4QudjcFbacHKuuqETk4VeSJyzM9Z2ufbuZFMuxvuQ==}
@@ -2978,7 +3020,6 @@ packages:
'@intlify/vue-devtools': 9.2.0-beta.32
'@vue/devtools-api': 6.1.0
vue: 3.2.31
- dev: false
/vue-router/[email protected]:
resolution: {integrity: sha512-wAO6zF9zxA3u+7AkMPqw9LjoUCjSxfFvINQj3E/DceTt6uEz1XZLraDhdg2EYmvVwTBSGlLYsUw8bDmx0754Mw==}
@@ -3011,7 +3052,6 @@ packages:
'@vue/runtime-dom': 3.2.31
'@vue/server-renderer': [email protected]
'@vue/shared': 3.2.31
- dev: false
resolution: {integrity: sha512-wkIM6F1VT9cuzC2YOIzktPcTJ3eI8FoQ39KazAKwcdPv3GcXZGO1vBZc3TspBwap0AIn9eF8dxvQAW80yxhbHg==}
diff --git a/frontend/src/views/sql-editor/EditorPanel/EditorAction.vue b/frontend/src/views/sql-editor/EditorPanel/EditorAction.vue
index 84a56fc05e..c068280c27 100644
--- a/frontend/src/views/sql-editor/EditorPanel/EditorAction.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/EditorAction.vue
@@ -96,13 +96,7 @@
>
<carbon:save class="h-5 w-5" /> &nbsp; {{ $t("common.save") }} (⌘+S)
</NButton>
- <NPopover
- trigger="click"
- placement="bottom-end"
- :show-arrow="false"
- :show="isShowSharePopover"
- :on-clickoutside="handleClickoutside"
- >
+ <NPopover trigger="click" placement="bottom-end" :show-arrow="false">
<template #trigger>
<NButton
:disabled="
@@ -110,26 +104,26 @@
sqlEditorStore.isDisconnected ||
!tabStore.currentTab.isSaved
"
- @click.stop.prevent="toggleSharePopover"
>
<carbon:share class="h-5 w-5" /> &nbsp; {{ $t("common.share") }}
</NButton>
</template>
- <SharePopover @close="isShowSharePopover = false" />
+ <template #default>
+ <SharePopover />
+ </template>
</NPopover>
</div>
</div>
</template>
<script lang="ts" setup>
-import { computed, ref, defineEmits } from "vue";
-
+import { computed, defineEmits } from "vue";
+import { useRouter } from "vue-router";
+import { useExecuteSQL } from "@/composables/useExecuteSQL";
import { useInstanceStore, useTabStore, useSQLEditorStore } from "@/store";
import { UNKNOWN_ID, Instance } from "@/types";
-import { useExecuteSQL } from "@/composables/useExecuteSQL";
+import { instanceSlug } from "@/utils/slug";
import SharePopover from "./SharePopover.vue";
-import { useRouter } from "vue-router";
-import { instanceSlug } from "../../../utils/slug";
const emit = defineEmits<{
(e: "save-sheet", content?: string): void;
@@ -142,8 +136,6 @@ const sqlEditorStore = useSQLEditorStore();
const connectionContext = computed(() => sqlEditorStore.connectionContext);
-const isShowSharePopover = ref(false);
-
const isEmptyStatement = computed(
() => !tabStore.currentTab || tabStore.currentTab.statement === ""
);
@@ -183,14 +175,6 @@ const gotoInstanceDetailPage = () => {
});
};
-const handleClickoutside = (e: any) => {
- isShowSharePopover.value = false;
-};
-
-const toggleSharePopover = () => {
- isShowSharePopover.value = !isShowSharePopover.value;
-};
-
const handleFormatSQL = () => {
sqlEditorStore.setShouldFormatContent(true);
};
diff --git a/frontend/src/views/sql-editor/EditorPanel/SharePopover.vue b/frontend/src/views/sql-editor/EditorPanel/SharePopover.vue
index 73ea7da58e..305f68d873 100644
--- a/frontend/src/views/sql-editor/EditorPanel/SharePopover.vue
+++ b/frontend/src/views/sql-editor/EditorPanel/SharePopover.vue
@@ -1,6 +1,6 @@
<template>
- <div class="share-popover w-112 p-2 space-y-4">
- <section class="flex justify-between">
+ <div class="share-popover w-96 p-2 space-y-4">
+ <section class="w-full flex flex-row justify-between items-center">
<div class="pr-4">
<h2 class="text-lg font-semibold">{{ $t("common.share") }}</h2>
</div>
@@ -11,8 +11,12 @@
@click="isShowAccessPopover = !isShowAccessPopover"
>
<span class="pr-2">{{ $t("sql-editor.link-access") }}:</span>
- <strong>{{ currentAccess.label }}</strong>
- <heroicons-solid:chevron-down />
+ <div
+ class="border flex flex-row justify-start items-center px-2 py-1 rounded hover:border-accent"
+ >
+ <strong>{{ currentAccess.label }}</strong>
+ <heroicons-solid:chevron-down />
+ </div>
</div>
</template>
<div class="access-content space-y-2 w-80">
@@ -58,8 +62,12 @@
</NPopover>
</section>
<NInputGroup class="flex items-center justify-center">
- <n-input-group-label class="flex items-center">
- <heroicons-solid:link class="h-4 w-4" />
+ <n-input-group-label>
+ <div
+ class="w-full h-full flex flex-row items-center justify-center m-auto"
+ >
+ <heroicons-solid:link class="w-5 h-auto" />
+ </div>
</n-input-group-label>
<n-input v-model:value="sharedTabLink" disabled />
<NButton
@@ -80,7 +88,6 @@ import { ref, computed, onMounted } from "vue";
import { useClipboard } from "@vueuse/core";
import { useI18n } from "vue-i18n";
import slug from "slug";
-
import {
pushNotification,
useTabStore,
@@ -89,10 +96,6 @@ import {
} from "@/store";
import { AccessOption } from "@/types";
-const emit = defineEmits<{
- (e: "close"): void;
-}>();
-
const { t } = useI18n();
const tabStore = useTabStore();
const sqlEditorStore = useSQLEditorStore();
@@ -119,11 +122,9 @@ const accessOptions = computed<AccessOption[]>(() => {
});
const ctx = computed(() => sqlEditorStore.connectionContext);
-
const sheet = computed(() => sheetStore.currentSheet);
const creator = computed(() => sheetStore.isCreator);
-const host = window.location.host;
const connectionSlug = [
slug(ctx.value.instanceName as string),
ctx.value.instanceId,
@@ -164,7 +165,9 @@ const handleChangeAccess = (option: AccessOption) => {
const sheetSlug = `${slug(tabStore.currentTab.name)}_${
tabStore.currentTab.sheetId
}`;
-const sharedTabLink = ref(`${host}/sql-editor/${connectionSlug}/${sheetSlug}`);
+const sharedTabLink = ref(
+ `${window.location.origin}/sql-editor/${connectionSlug}/${sheetSlug}`
+);
const { copy, copied } = useClipboard({
source: sharedTabLink.value,
@@ -177,7 +180,6 @@ const handleCopy = async () => {
style: "SUCCESS",
title: t("sql-editor.notify.copy-share-link"),
});
- emit("close");
};
onMounted(() => {