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: add statement only props to request export form for SQL Editor (#7994)
boojack957e802222ed
diff --git a/frontend/src/components/Issue/panel/RequestExportPanel/ExportResourceForm/index.vue b/frontend/src/components/Issue/panel/RequestExportPanel/ExportResourceForm/index.vueindex 221789be95..4f0cc69b95 100644--- a/frontend/src/components/Issue/panel/RequestExportPanel/ExportResourceForm/index.vue+++ b/frontend/src/components/Issue/panel/RequestExportPanel/ExportResourceForm/index.vue@@ -1,6 +1,7 @@<template><div class="w-full mb-2"><NRadioGroup+ v-if="!props.statementOnly"v-model:value="state.exportMethod"class="w-full !flex flex-row justify-start items-center gap-4">@@ -30,17 +31,19 @@@change="handleStatementChange"/></div>- <div- v-if="state.exportMethod === 'DATABASE'"- class="w-full flex flex-row justify-start items-center"- >- <DatabaseResourceSelector- :project-id="project!.uid"- :database-id="(props.databaseId as string)"- :database-resources="state.databaseResources"- @update="handleTableResourceUpdate"- />- </div>+ <template v-if="!props.statementOnly">+ <div+ v-if="state.exportMethod === 'DATABASE'"+ class="w-full flex flex-row justify-start items-center"+ >+ <DatabaseResourceSelector+ :project-id="project!.uid"+ :database-id="(props.databaseId as string)"+ :database-resources="state.databaseResources"+ @update="handleTableResourceUpdate"+ />+ </div>+ </template></template><script lang="ts" setup>@@ -63,6 +66,7 @@ const props = defineProps<{projectId?: string;databaseId?: string;statement?: string;+ statementOnly?: boolean;databaseResources?: DatabaseResource[];}>();diff --git a/frontend/src/components/Issue/panel/RequestExportPanel/index.vue b/frontend/src/components/Issue/panel/RequestExportPanel/index.vueindex 3bc1bd0223..cca0256bb4 100644--- a/frontend/src/components/Issue/panel/RequestExportPanel/index.vue+++ b/frontend/src/components/Issue/panel/RequestExportPanel/index.vue@@ -60,13 +60,18 @@</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-method") }}+ {{+ props.statementOnly+ ? "SQL"+ : $t("issue.grant-request.export-method")+ }}<RequiredStar /></span><ExportResourceForm:project-id="state.projectId":database-id="state.databaseId":statement="statement"+ :statement-only="props.statementOnly"@update:condition="state.databaseResourceCondition = $event"@update:database-resources="state.databaseResources = $event"/>@@ -173,6 +178,7 @@ interface LocalState {const props = defineProps<{databaseId?: string;statement?: string;+ statementOnly?: boolean;redirectToIssuePage?: boolean;}>();diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vueindex 77968c7e81..234bc89aaa 100644--- a/frontend/src/views/ExportCenter/index.vue+++ b/frontend/src/views/ExportCenter/index.vue@@ -62,6 +62,7 @@ import { NButton, NInputGroup } from "naive-ui";import { computed, reactive, watchEffect } from "vue";import { useRoute, useRouter } from "vue-router";import RequestExportPanel from "@/components/Issue/panel/RequestExportPanel/index.vue";+import { getExpiredDateTime } from "@/components/ProjectMember/ProjectRoleTable/utils";import { ProjectSelect, InstanceSelect, DatabaseSelect } from "@/components/v2";import {featureToRef,@@ -158,40 +159,53 @@ watchEffect(async () => {if (!binding.parsedExpr?.expr) {continue;}-+ // Skip the expired export record.+ const expiredDateTime = getExpiredDateTime(binding);+ if (+ expiredDateTime &&+ new Date().getTime() >= expiredDateTime.getTime()+ ) {+ continue;+ }const conditionExpr = convertFromExpr(binding.parsedExpr.expr);- if (!conditionExpr.databaseResources) {+ // Only show the export record with statement condition in export center.+ if (!conditionExpr.statement || conditionExpr.statement === "") {+ continue;+ }+ if (+ !conditionExpr.databaseResources ||+ conditionExpr.databaseResources.length !== 1+ ) {continue;}- for (const databaseResource of conditionExpr.databaseResources) {- const description = binding.condition?.description || "";- const issueId = description.match(issueDescriptionRegexp)?.[1];- 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(".")};`;+ const databaseResource = conditionExpr.databaseResources[0];+ const description = binding.condition?.description || "";+ const issueId = description.match(issueDescriptionRegexp)?.[1];+ 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);}-- tempExportRecords.push({- databaseResource,- database,- statement,- expiration: conditionExpr.expiredTime || "",- maxRowCount: conditionExpr.rowLimit || 0,- exportFormat: (conditionExpr.exportFormat as any) || "JSON",- issueId: issueId || String(UNKNOWN_ID),- });+ names.push(databaseResource.table);+ statement = `SELECT * FROM ${names.join(".")};`;}++ tempExportRecords.push({+ databaseResource,+ database,+ statement,+ expiration: conditionExpr.expiredTime || "",+ maxRowCount: conditionExpr.rowLimit || 0,+ exportFormat: (conditionExpr.exportFormat as any) || "JSON",+ issueId: issueId || String(UNKNOWN_ID),+ });}}state.exportRecords = tempExportRecords;diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vueindex d547cefddd..9e41631d3e 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue@@ -120,6 +120,7 @@v-if="state.showRequestExportPanel":database-id="currentTab.connection.databaseId":statement="result.statement"+ :statement-only="true":redirect-to-issue-page="sqlEditorStore.mode === 'BUNDLED'"@close="state.showRequestExportPanel = false"/>