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: download sheet (#6890)
Liu Jiad8b1b510cb4
diff --git a/frontend/naive-ui.config.ts b/frontend/naive-ui.config.tsindex 1b23b96d5b..17a458d07f 100644--- a/frontend/naive-ui.config.ts+++ b/frontend/naive-ui.config.ts@@ -37,6 +37,12 @@ export const themeOverrides = computed((): GlobalThemeOverrides => {errorColorHover: callVar("--color-error-hover"),errorColorPressed: callVar("--color-error"),},+ Button: {+ color: "white",+ colorHover: "white",+ colorFocus: "white",+ colorPressed: "white",+ },};});diff --git a/frontend/src/bbkit/BBAttention.vue b/frontend/src/bbkit/BBAttention.vueindex 7cffbe1d90..69b9d3a20d 100644--- a/frontend/src/bbkit/BBAttention.vue+++ b/frontend/src/bbkit/BBAttention.vue@@ -37,18 +37,20 @@</slot></div></div>- <div- v-if="actionText != ''"- class="flex items-center justify-end mt-2 md:mt-0 md:ml-2"- >- <button- type="button"- class="btn-primary whitespace-nowrap"- @click.prevent="$emit('click-action')"+ <slot name="action">+ <div+ v-if="actionText != ''"+ class="flex items-center justify-end mt-2 md:mt-0 md:ml-2">- {{ $t(actionText) }}- </button>- </div>+ <button+ type="button"+ class="btn-primary whitespace-nowrap"+ @click.prevent="$emit('click-action')"+ >+ {{ $t(actionText) }}+ </button>+ </div>+ </slot></div></template>diff --git a/frontend/src/components/Issue/IssueTaskStatementPanel.vue b/frontend/src/components/Issue/IssueTaskStatementPanel.vueindex 6960f094d6..76b0d01b86 100644--- a/frontend/src/components/Issue/IssueTaskStatementPanel.vue+++ b/frontend/src/components/Issue/IssueTaskStatementPanel.vue@@ -98,7 +98,11 @@:class="'my-2'":style="`WARN`":title="$t('issue.statement-from-sheet-warning')"- />+ >+ <template v-if="state.taskSheetName" #action>+ <DownloadSheetButton :sheet="state.taskSheetName" size="small" />+ </template>+ </BBAttention><divclass="whitespace-pre-wrap mt-2 w-full overflow-hidden":class="state.editing ? 'border-t border-x' : 'border-t border-x'"@@ -157,6 +161,7 @@ import { TableMetadata } from "@/types/proto/store/database";import MonacoEditor from "../MonacoEditor/MonacoEditor.vue";import { useSQLAdviceMarkers } from "./logic/useSQLAdviceMarkers";import UploadProgressButton from "../misc/UploadProgressButton.vue";+import DownloadSheetButton from "../Sheet/DownloadSheetButton.vue";import {Sheet_Visibility,Sheet_Source,diff --git a/frontend/src/components/Sheet/DownloadSheetButton.vue b/frontend/src/components/Sheet/DownloadSheetButton.vuenew file mode 100644index 0000000000..9edc80245b--- /dev/null+++ b/frontend/src/components/Sheet/DownloadSheetButton.vue@@ -0,0 +1,42 @@+<template>+ <NButton :loading="downloading" @click="downloadSheet">+ {{ $t("common.download") }}+ </NButton>+</template>++<script lang="ts" setup>+import { ref } from "vue";+import { NButton } from "naive-ui";++import { sheetServiceClient } from "@/grpcweb";++const props = defineProps<{+ sheet: string;+}>();++const downloading = ref(false);++const downloadSheet = async () => {+ try {+ downloading.value = true;++ const response = await sheetServiceClient.getSheet({+ name: props.sheet,+ raw: true,+ });++ const filename = `${response.title}.sql`;+ const content = new TextDecoder().decode(response.content);++ const blob = new Blob([content], { type: "text/plain" });+ const downloadLink = document.createElement("a");+ downloadLink.href = URL.createObjectURL(blob);+ downloadLink.download = filename;+ document.body.appendChild(downloadLink);+ downloadLink.click();+ URL.revokeObjectURL(downloadLink.href);+ } finally {+ downloading.value = false;+ }+};+</script>diff --git a/frontend/src/views/sql-editor/EditorPanel/SheetForIssueTipsBar.vue b/frontend/src/views/sql-editor/EditorPanel/SheetForIssueTipsBar.vueindex 65a00f66b0..ee7c0742e8 100644--- a/frontend/src/views/sql-editor/EditorPanel/SheetForIssueTipsBar.vue+++ b/frontend/src/views/sql-editor/EditorPanel/SheetForIssueTipsBar.vue@@ -1,9 +1,12 @@<template>- <div v-if="payload || isSheetOversize" class="w-full p-4 flex bg-yellow-50">+ <div+ v-if="payload || isSheetOversize"+ class="w-full p-4 flex items-center bg-yellow-50 gap-x-3"+ ><div class="flex-shrink-0"><heroicons-solid:information-circle class="h-5 w-5 text-yellow-400" /></div>- <div class="ml-3 text-sm font-medium text-yellow-800">+ <div class="flex-1 text-sm font-medium text-yellow-800"><i18n-t v-if="payload" tag="h3" keypath="sheet.from-issue-warning"><template #issue><NTooltip :disabled="loading || !issue">@@ -31,16 +34,22 @@{{ $t("sheet.content-oversize-warning") }}</div></div>+ <DownloadSheetButton+ v-if="tab.sheetName"+ :sheet="tab.sheetName"+ size="small"+ /></div></template><script lang="ts" setup>+import { shallowRef, computed, ref, watch } from "vue";+import { NTooltip } from "naive-ui";+import { useIssueStore, useSheetV1Store, useTabStore } from "@/store";import { Issue } from "@/types";import { getSheetIssueBacktracePayloadV1 } from "@/utils";-import { NTooltip } from "naive-ui";-import { shallowRef } from "vue";-import { computed, ref, watch } from "vue";+import DownloadSheetButton from "@/components/Sheet/DownloadSheetButton.vue";const tabStore = useTabStore();const sheetV1Store = useSheetV1Store();