Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update export center (#6649)
boojacked00a6662d5b
diff --git a/frontend/src/components/Issue/form/GrantRequestExporterForm.vue b/frontend/src/components/Issue/form/GrantRequestExporterForm.vueindex 5b1451ee2f..c8c41da4b7 100644--- a/frontend/src/components/Issue/form/GrantRequestExporterForm.vue+++ b/frontend/src/components/Issue/form/GrantRequestExporterForm.vue@@ -2,47 +2,33 @@<divclass="w-full mx-auto flex flex-col justify-start items-start mb-4 space-y-4">- <template v-if="exportMethod === 'SQL'">- <div class="w-full flex flex-col justify-start items-start">- <span class="flex items-center textlabel mb-2">- {{ $t("common.database") }}- </span>- <div class="flex flex-row justify-start items-center">- <InstanceV1EngineIcon- :instance="selectedDatabase.instanceEntity"- :link="false"- class="mr-1"- />- {{ selectedDatabase.databaseName }}- </div>- </div>- <div class="w-full flex flex-col justify-start items-start">- <span class="flex items-center textlabel mb-2">SQL</span>- <div class="w-full border rounded">- <MonacoEditor- class="w-full h-[300px] py-2"- readonly- :value="state.statement"- :auto-focus="false"- :language="'sql'"- :dialect="dialect"- />- </div>- </div>- </template>- <template v-else>- <div class="w-full flex flex-col justify-start items-start">- <span class="flex items-center textlabel mb-2">- {{ $t("common.database") }}- </span>- <DatabaseResourceTable- class="w-full"- :database-resource-list="- selectedDatabaseResource ? [selectedDatabaseResource] : []- "+ <div class="w-full flex flex-col justify-start items-start">+ <span class="flex items-center textlabel mb-2">+ {{ $t("common.database") }}+ </span>+ <DatabaseResourceTable+ class="w-full"+ :database-resource-list="+ selectedDatabaseResource ? [selectedDatabaseResource] : []+ "+ />+ </div>+ <div+ v-if="exportMethod === 'SQL'"+ class="w-full flex flex-col justify-start items-start"+ >+ <span class="flex items-center textlabel mb-2">SQL</span>+ <div class="w-full border rounded">+ <MonacoEditor+ class="w-full h-[300px] py-2"+ readonly+ :value="state.statement"+ :auto-focus="false"+ :language="'sql'"+ :dialect="dialect"/></div>- </template>+ </div><div class="w-full flex flex-col justify-start items-start"><span class="flex items-center textlabel mb-2">{{ $t("issue.grant-request.export-rows") }}@@ -89,7 +75,6 @@ import {import { useDatabaseV1Store } from "@/store";import MonacoEditor from "@/components/MonacoEditor";import { convertFromCELString } from "@/utils/issue/cel";-import { InstanceV1EngineIcon } from "@/components/v2";import { Engine } from "@/types/proto/v1/common";import dayjs from "dayjs";import DatabaseResourceTable from "../table/DatabaseResourceTable.vue";@@ -114,7 +99,9 @@ const state = reactive<LocalState>({const selectedDatabaseResource = ref<DatabaseResource | undefined>(undefined);const selectedDatabase = computed(() => {- return databaseStore.getDatabaseByUID(state.databaseId ?? String(UNKNOWN_ID));+ return databaseStore.getDatabaseByName(+ selectedDatabaseResource.value?.databaseName ?? String(UNKNOWN_ID)+ );});const exportMethod = computed(() => {diff --git a/frontend/src/components/Issue/form/GrantRequestQuerierForm.vue b/frontend/src/components/Issue/form/GrantRequestQuerierForm.vueindex 84c462f5f0..4063d52357 100644--- a/frontend/src/components/Issue/form/GrantRequestQuerierForm.vue+++ b/frontend/src/components/Issue/form/GrantRequestQuerierForm.vue@@ -1,25 +1,25 @@<template><div- class="w-full mx-auto flex flex-col justify-start items-start space-y-4 my-8 gap-4"+ class="w-full mx-auto flex flex-col justify-start items-start space-y-4 gap-4 mb-4">- <div v-if="create" class="w-full flex flex-row justify-start items-start">- <span class="flex w-40 items-center textlabel !leading-6 mt-2">+ <div v-if="create" class="w-full flex flex-col justify-start items-start">+ <span class="flex w-full items-center textlabel mb-2">{{ $t("common.project") }}<RequiredStar /></span><ProjectSelect- class="!w-60 shrink-0"+ class="!w-60":only-userself="false":selected-id="projectId"@select-project-id="handleProjectSelect"/></div>- <div class="w-full flex flex-row justify-start items-start">- <span class="flex w-40 items-center textlabel shrink-0 !leading-6">+ <div class="w-full flex flex-col justify-start items-start">+ <span class="flex w-full items-center textlabel mb-2">{{ $t("common.databases") }}<RequiredStar /></span>- <div v-if="create">+ <div v-if="create" class="w-full"><NRadioGroupv-model:value="state.allDatabases"class="w-full !flex flex-row justify-start items-start gap-4"@@ -41,49 +41,45 @@:value="false":disabled="!state.projectId":label="$t('issue.grant-request.manually-select')"- @click="handleManuallySelectClick"/><button- v-if="state.projectId"+ v-if="state.projectId && state.allDatabases === false"class="ml-2 normal-link h-6 disabled:cursor-not-allowed"@click="state.showSelectDatabasePanel = true">{{ $t("common.select") }}</button>- <div- v-if="state.selectedDatabaseResourceList.length > 0"- class="ml-6 flex flex-row justify-start items-start flex-wrap gap-2 gap-x-4"- >- <div- v-for="databaseResource in state.selectedDatabaseResourceList"- :key="`${databaseResource.databaseName}`"- class="flex flex-row justify-start items-center"- >- <DatabaseResourceView :database-resource="databaseResource" />- </div>- </div></div></NRadioGroup>+ <div+ v-if="+ state.selectedDatabaseResourceList.length > 0 &&+ state.allDatabases === false+ "+ class="w-full max-w-3xl mt-2"+ >+ <DatabaseResourceTable+ class="w-full"+ :database-resource-list="state.selectedDatabaseResourceList"+ />+ </div></div><divv-else- class="flex flex-row justify-start items-start flex-wrap gap-2 gap-x-4"+ class="w-full flex flex-row justify-start items-start flex-wrap gap-2 gap-x-4"><span v-if="state.selectedDatabaseResourceList.length === 0">{{$t("issue.grant-request.all-databases")}}</span>- <div- v-for="databaseResource in state.selectedDatabaseResourceList"+ <DatabaseResourceTablev-else- :key="`${databaseResource.databaseName}`"- class="flex flex-row justify-start items-center"- >- <DatabaseResourceView :database-resource="databaseResource" />- </div>+ class="w-full"+ :database-resource-list="state.selectedDatabaseResourceList"+ /></div></div>- <div class="w-full flex flex-row justify-start items-start">- <span class="flex w-40 items-start textlabel !leading-6">+ <div class="w-full flex flex-col justify-start items-start">+ <span class="flex w-full items-center textlabel mb-4">{{create? $t("issue.grant-request.expire-days")@@ -94,7 +90,7 @@<div v-if="create"><NRadioGroupv-model:value="state.expireDays"- class="!grid grid-cols-4 gap-x-4 gap-y-4"+ class="!grid grid-cols-4 gap-4"name="radiogroup"><div@@ -141,6 +137,7 @@</template><script lang="ts" setup>+import dayjs from "dayjs";import { head } from "lodash-es";import { NRadioGroup, NRadio, NInputNumber, NTooltip } from "naive-ui";import { computed, onMounted, reactive, watch } from "vue";@@ -160,7 +157,7 @@ import { convertFromCELString } from "@/utils/issue/cel";import { DatabaseResource } from "./SelectDatabaseResourceForm/common";import RequiredStar from "@/components/RequiredStar.vue";import SelectDatabaseResourceForm from "./SelectDatabaseResourceForm/index.vue";-import DatabaseResourceView from "./DatabaseResourceView.vue";+import DatabaseResourceTable from "../table/DatabaseResourceTable.vue";interface LocalState {showSelectDatabasePanel: boolean;@@ -253,12 +250,6 @@ const handleProjectSelect = async (projectId: string) => {});};-const handleManuallySelectClick = () => {- if (state.selectedDatabaseResourceList.length === 0) {- state.showSelectDatabasePanel = true;- }-};-const handleSelectedDatabaseResourceChanged = (databaseResourceList: DatabaseResource[]) => {@@ -302,9 +293,9 @@ watch(payload.condition.expression);if (conditionExpression.expiredTime !== undefined) {- state.expiredAt = new Date(- conditionExpression.expiredTime- ).toLocaleString();+ state.expiredAt = dayjs(+ new Date(conditionExpression.expiredTime)+ ).format("LLL");}if (conditionExpression.databaseResources !== undefined &&diff --git a/frontend/src/components/Issue/panel/RequestExportPanel/index.vue b/frontend/src/components/Issue/panel/RequestExportPanel/index.vueindex 1dbdb44bde..dc7fd8762a 100644--- a/frontend/src/components/Issue/panel/RequestExportPanel/index.vue+++ b/frontend/src/components/Issue/panel/RequestExportPanel/index.vue@@ -135,7 +135,7 @@><NRadio :value="'CSV'" label="CSV" /><NRadio :value="'JSON'" label="JSON" />- <NRadio :value="'SQL'" label="SQL" />+ <NRadio v-if="isDev" :value="'SQL'" label="SQL" /></NRadioGroup></div></div>diff --git a/frontend/src/components/Issue/table/DatabaseResourceTable.vue b/frontend/src/components/Issue/table/DatabaseResourceTable.vueindex 3db992051c..00d92489ed 100644--- a/frontend/src/components/Issue/table/DatabaseResourceTable.vue+++ b/frontend/src/components/Issue/table/DatabaseResourceTable.vue@@ -65,7 +65,7 @@ const extractTableName = (databaseResource: DatabaseResource) => {if (databaseResource.table) {nameList.push(databaseResource.table);}- return nameList.join(".") ?? "*";+ return nameList.join(".") || "*";};const extractComposedDatabase = (databaseResource: DatabaseResource) => {diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vueindex 170583a717..f4e740f095 100644--- a/frontend/src/components/QuickActionPanel.vue+++ b/frontend/src/components/QuickActionPanel.vue@@ -397,7 +397,7 @@ const createRequestQueryIssue = () => {query: {template: "bb.issue.grant.request",role: "QUERIER",- name: "New grant querier request",+ name: "Request data query permission",},};const routeSlug = routerStore.routeSlug(route);diff --git a/frontend/src/views/DashboardSidebar.vue b/frontend/src/views/DashboardSidebar.vueindex d3fb825691..a8511017e1 100644--- a/frontend/src/views/DashboardSidebar.vue+++ b/frontend/src/views/DashboardSidebar.vue@@ -48,7 +48,6 @@{{ $t("database.sync-schema.title") }}</router-link><router-link- v-if="isDev"to="/export-center"class="outline-item group flex items-center px-2 py-2 capitalize">diff --git a/frontend/src/views/ExportCenter/ExportRecordTable.vue b/frontend/src/views/ExportCenter/ExportRecordTable.vueindex fdf4780f16..ea50a23dbc 100644--- a/frontend/src/views/ExportCenter/ExportRecordTable.vue+++ b/frontend/src/views/ExportCenter/ExportRecordTable.vue@@ -27,16 +27,23 @@{{ item.database.databaseName }}</div><div class="bb-grid-cell">- {{ item.database.instanceEntity.environmentEntity.title }}+ <EnvironmentV1Name+ :environment="item.database.instanceEntity.environmentEntity"+ />+ </div>+ <div class="bb-grid-cell">+ <InstanceV1Name :instance="item.database.instanceEntity" /></div><div class="bb-grid-cell">- {{ item.database.instanceEntity.title }}+ <ProjectV1Name :project="item.database.projectEntity" /></div><div class="bb-grid-cell">- {{ item.database.projectEntity.title }}+ {{ item.maxRowCount }}</div><div class="bb-grid-cell">- {{ item.expiration ? humanizeDate(new Date(item.expiration)) : "*" }}+ {{+ item.expiration ? dayjs(new Date(item.expiration)).format("LLL") : "*"+ }}</div><div class="bb-grid-cell"><ExportDataButton :export-record="item" />@@ -54,6 +61,7 @@</template><script lang="ts" setup>+import dayjs from "dayjs";import { computed, shallowRef } from "vue";import { useI18n } from "vue-i18n";import { ExportRecord } from "./types";@@ -95,6 +103,10 @@ const COLUMN_LIST = computed(() => {title: t("common.project"),width: "1fr",},+ {+ title: t("issue.grant-request.export-rows"),+ width: "1fr",+ },{title: t("common.expiration"),width: "1fr",diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vueindex 0a92ec4aae..3c429589b5 100644--- a/frontend/src/views/ExportCenter/index.vue+++ b/frontend/src/views/ExportCenter/index.vue@@ -128,10 +128,23 @@ watchEffect(async () => {const database = await databaseStore.getOrFetchDatabaseByName(databaseResource.databaseName);+ let statement = conditionExpr.statement || "";+ // NOTE: concat schema and table name to statement for table level export.+ // Maybe we need to move this into backend later.+ if (statement === "" && databaseResource.table) {+ const names = [];+ if (databaseResource.schema) {+ names.push(databaseResource.schema);+ }+ names.push(databaseResource.table);+ statement = `SELECT * FROM ${names.join(".")};`;+ }+tempExportRecords.push({+ databaseResource,database,+ statement,expiration: conditionExpr.expiredTime || "",- statement: conditionExpr.statement || "",maxRowCount: conditionExpr.rowLimit || 0,exportFormat: (conditionExpr.exportFormat as any) || "JSON",issueId: issueId || String(UNKNOWN_ID),diff --git a/frontend/src/views/ExportCenter/types.ts b/frontend/src/views/ExportCenter/types.tsindex 2a30fea6ed..60e20c4181 100644--- a/frontend/src/views/ExportCenter/types.ts+++ b/frontend/src/views/ExportCenter/types.ts@@ -1,3 +1,4 @@+import { DatabaseResource } from "@/components/Issue/panel/RequestExportPanel/SelectTableForm/common";import { ComposedDatabase } from "@/types";import { Database } from "@/types/proto/v1/database_service";import { Instance } from "@/types/proto/v1/instance_service";@@ -10,6 +11,7 @@ export interface FilterParams {}export interface ExportRecord {+ databaseResource: DatabaseResource;database: ComposedDatabase;expiration: string;statement: string;