Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(export): move data export creation to issue-scoped flow (#19843)
boojack27cfb8f62289
diff --git a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepPanel.vue b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepPanel.vueindex 0ac9d18875..93dec376be 100644--- a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepPanel.vue+++ b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepPanel.vue@@ -396,6 +396,7 @@ const create = async () => {creator: currentUserV1.value.name,});const issueCreate = createProto(IssueSchema, {+ title,type: Issue_Type.DATABASE_CHANGE,creator: `users/${currentUserV1.value.email}`,labels: state.labels,diff --git a/frontend/src/components/DataExportPrepForm/DataExportPrepDrawer.vue b/frontend/src/components/DataExportPrepForm/DataExportPrepDrawer.vuenew file mode 100644index 0000000000..c2a0dc5a08--- /dev/null+++ b/frontend/src/components/DataExportPrepForm/DataExportPrepDrawer.vue@@ -0,0 +1,26 @@+<template>+ <Drawer :show="show" :auto-focus="true" @close="$emit('dismiss')">+ <DataExportPrepForm+ :show="show"+ :project-name="projectName"+ :seed="seed"+ @dismiss="$emit('dismiss')"+ />+ </Drawer>+</template>++<script lang="ts" setup>+import { Drawer } from "@/components/v2";+import DataExportPrepForm from "./DataExportPrepForm.vue";+import type { DataExportPrepSeed } from "./types";++defineProps<{+ show: boolean;+ projectName: string;+ seed?: DataExportPrepSeed;+}>();++defineEmits<{+ (event: "dismiss"): void;+}>();+</script>diff --git a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vueindex 8665be4267..62a3077d17 100644--- a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue+++ b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue@@ -1,109 +1,424 @@<template><DrawerContent class="max-w-[100vw]"><template #header>- <div class="flex flex-col gap-y-1">+ <div class="flex flex-col gap-y-3"><span>{{ $t("custom-approval.risk-rule.risk.namespace.data_export") }}</span>+ <NSteps :current="state.step" size="small">+ <NStep :title="$t('plan.targets.title')" />+ <NStep :title="$t('common.configure')" />+ </NSteps></div></template><divclass="flex flex-col gap-y-4 h-full w-[calc(100vw-8rem)] lg:w-240 max-w-[calc(100vw-8rem)] overflow-x-auto">- <DatabaseAndGroupSelector- :project="project"- v-model:value="state.targetSelectState"- />+ <template v-if="state.step === 1">+ <DatabaseAndGroupSelector+ :project="project"+ v-model:value="state.targetSelectState"+ />+ </template>++ <template v-else>+ <div class="flex flex-col gap-y-4 pb-2">+ <div class="flex flex-col gap-y-2">+ <h3 class="text-base font-medium">+ {{ $t("plan.targets.title") }}+ </h3>+ <div class="flex flex-wrap gap-2">+ <div+ v-for="target in targets"+ :key="target"+ class="inline-flex items-center gap-2 px-2 py-1.5 border rounded-sm min-w-0"+ >+ <template v-if="isValidDatabaseName(target)">+ <DatabaseDisplay+ :database="target"+ :show-environment="true"+ size="medium"+ class="flex-1 min-w-0"+ />+ </template>+ <template v-else-if="isValidDatabaseGroupName(target)">+ <DatabaseGroupTargetDisplay :target="target" class="px-1 py-1" />+ </template>+ </div>+ </div>+ </div>++ <div class="flex flex-col gap-y-2">+ <label class="textlabel">+ {{ $t("common.title") }}+ <RequiredStar v-if="project.enforceIssueTitle" />+ </label>+ <NInput+ v-model:value="state.title"+ :placeholder="$t('common.title')"+ @update:value="state.titleEdited = true"+ />+ </div>++ <div class="flex flex-col gap-y-2">+ <label class="textlabel">+ {{ $t("common.description") }}+ </label>+ <MarkdownEditor+ mode="editor"+ :content="state.description"+ :project="project"+ :compact="true"+ @change="state.description = $event"+ />+ </div>++ <div class="flex flex-col gap-y-2">+ <label class="textlabel">+ {{ $t("issue.labels") }}+ <RequiredStar v-if="project.forceIssueLabels" />+ </label>+ <IssueLabelSelector+ :disabled="state.creating"+ :selected="state.labels"+ :project="project"+ size="medium"+ :render-menu-inside-parent="true"+ @update:selected="state.labels = $event"+ />+ </div>++ <div class="flex flex-col gap-y-2">+ <label class="textlabel">+ {{ $t("common.sql") }}+ <RequiredStar />+ </label>+ <div class="h-96 overflow-hidden border rounded-sm">+ <MonacoEditor+ class="w-full h-full"+ :content="state.statement"+ language="sql"+ @update:content="state.statement = $event"+ />+ </div>+ </div>++ <div class="flex flex-col gap-y-2">+ <h3 class="text-base">+ {{ $t("issue.data-export.options") }}+ </h3>+ <div class="p-3 border rounded-sm flex flex-col gap-y-3">+ <div class="flex items-center gap-4">+ <span class="text-sm">+ {{ $t("issue.data-export.format") }}+ </span>+ <ExportFormatSelector+ v-model:format="state.format"+ :editable="true"+ />+ </div>++ <ExportPasswordInputer+ v-model:password="state.password"+ :editable="true"+ />+ </div>+ </div>++ <LimitsSection />+ </div>+ </template></div><template #footer>- <div class="flex-1 flex items-center justify-between">- <div></div>-- <div class="flex items-center justify-end gap-x-3">- <NButton @click.prevent="cancel">- {{ $t("common.cancel") }}- </NButton>- <NButton- type="primary"- :disabled="!validSelectState"- @click="navigateToIssuePage"- >- {{ $t("common.next") }}- </NButton>- </div>+ <div class="flex items-center justify-end gap-x-3">+ <NButton @click.prevent="handleCancel">+ {{+ state.step === 1 ? $t("common.cancel") : $t("common.back")+ }}+ </NButton>+ <NButton+ v-if="state.step === 1"+ type="primary"+ :disabled="!validSelectState"+ @click="state.step = 2"+ >+ {{ $t("common.next") }}+ </NButton>+ <NButton+ v-else+ type="primary"+ :disabled="!canCreate"+ :loading="state.creating"+ @click="handleCreate"+ >+ {{ $t("common.create") }}+ </NButton></div></template></DrawerContent></template><script lang="ts" setup>-import { NButton } from "naive-ui";-import { computed, reactive } from "vue";-import { type LocationQueryRaw, useRouter } from "vue-router";-import DatabaseAndGroupSelector, {- type DatabaseSelectState,-} from "@/components/DatabaseAndGroupSelector/";-import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";-import { useProjectByName } from "@/store";-import { extractProjectResourceName, generatePlanTitle } from "@/utils";-import { DrawerContent } from "../v2";+import { create } from "@bufbuild/protobuf";+import { NButton, NInput, NStep, NSteps } from "naive-ui";+import { v4 as uuidv4 } from "uuid";+import { computed, reactive, watch, watchEffect } from "vue";+import { useI18n } from "vue-i18n";+import { useRouter } from "vue-router";+import DatabaseAndGroupSelector from "@/components/DatabaseAndGroupSelector/";+import IssueLabelSelector from "@/components/IssueV1/components/IssueLabelSelector.vue";+import MarkdownEditor from "@/components/MarkdownEditor";+import { MonacoEditor } from "@/components/MonacoEditor";+import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";+import ExportFormatSelector from "@/components/Plan/components/ExportOption/ExportFormatSelector.vue";+import ExportPasswordInputer from "@/components/Plan/components/ExportOption/ExportPasswordInputer.vue";+import LimitsSection from "@/components/Plan/components/IssueReviewView/DatabaseExportView/LimitsSection.vue";+import DatabaseGroupTargetDisplay from "@/components/Plan/components/SpecDetailView/DatabaseGroupTargetDisplay.vue";+import { createEmptyLocalSheet } from "@/components/Plan/logic";+import RequiredStar from "@/components/RequiredStar.vue";+import { DrawerContent } from "@/components/v2";+import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";+import {+ experimentalCreateIssueByPlan,+ pushNotification,+ useCurrentUserV1,+ useDatabaseV1Store,+ useDBGroupStore,+ useProjectByName,+ useSheetV1Store,+} from "@/store";+import { isValidDatabaseGroupName, isValidDatabaseName } from "@/types";+import { ExportFormat } from "@/types/proto-es/v1/common_pb";+import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";+import { Issue_Type, IssueSchema } from "@/types/proto-es/v1/issue_service_pb";+import {+ Plan_ExportDataConfigSchema,+ Plan_SpecSchema,+ PlanSchema,+} from "@/types/proto-es/v1/plan_service_pb";+import {+ extractDatabaseGroupName,+ extractDatabaseResourceName,+ extractIssueUID,+ extractProjectResourceName,+ generatePlanTitle,+ setSheetStatement,+} from "@/utils";+import { type DataExportPrepSeed, normalizeDataExportPrepSeed } from "./types";type LocalState = {- targetSelectState?: DatabaseSelectState;+ step: 1 | 2;+ creating: boolean;+ targetSelectState?: DataExportPrepSeed["targetSelectState"];+ title: string;+ titleEdited: boolean;+ description: string;+ labels: string[];+ statement: string;+ format: ExportFormat;+ password: string;};const props = defineProps<{projectName: string;+ show?: boolean;+ seed?: DataExportPrepSeed;+}>();++const emit = defineEmits<{+ (event: "dismiss"): void;}>();+const { t } = useI18n();+const router = useRouter();+const currentUser = useCurrentUserV1();+const sheetStore = useSheetV1Store();+const dbStore = useDatabaseV1Store();+const dbGroupStore = useDBGroupStore();const { project } = useProjectByName(computed(() => props.projectName));-const emit = defineEmits(["dismiss"]);+const buildInitialState = (): LocalState => {+ const seed = normalizeDataExportPrepSeed(props.seed);+ return {+ step: seed.step,+ creating: false,+ targetSelectState: seed.targetSelectState,+ title: "",+ titleEdited: false,+ description: "",+ labels: [],+ statement: "",+ format: ExportFormat.JSON,+ password: "",+ };+};-const router = useRouter();-const state = reactive<LocalState>({});+const state = reactive<LocalState>(buildInitialState());-const validSelectState = computed(() => {- if (!state.targetSelectState) {- return false;- }+const resetState = () => {+ Object.assign(state, buildInitialState());+};++const targets = computed(() => {+ if (!state.targetSelectState) return [];if (state.targetSelectState.changeSource === "DATABASE") {- return state.targetSelectState.selectedDatabaseNameList.length > 0;+ return state.targetSelectState.selectedDatabaseNameList;}- return !!state.targetSelectState.selectedDatabaseGroup;+ return state.targetSelectState.selectedDatabaseGroup+ ? [state.targetSelectState.selectedDatabaseGroup]+ : [];});-const navigateToIssuePage = async () => {- if (!state.targetSelectState) {- return;- }+const validSelectState = computed(() => targets.value.length > 0);- const template = "bb.plan.export-data";- const query: LocationQueryRaw = {- template,- name: generatePlanTitle(template),- };+const targetTitleNames = computed(() => {+ return targets.value.map((target) => {+ if (isValidDatabaseName(target)) {+ return extractDatabaseResourceName(target).databaseName;+ }+ if (isValidDatabaseGroupName(target)) {+ return extractDatabaseGroupName(target);+ }+ return target;+ });+});- if (state.targetSelectState.changeSource === "DATABASE") {- query["databaseList"] =- state.targetSelectState.selectedDatabaseNameList.join(",");- } else {- query["databaseGroupName"] = state.targetSelectState.selectedDatabaseGroup;+const canCreate = computed(() => {+ if (!validSelectState.value) return false;+ if (project.value.enforceIssueTitle && !state.title.trim()) return false;+ if (project.value.forceIssueLabels && state.labels.length === 0) return false;+ if (!state.statement.trim()) return false;+ return true;+});++const effectiveTitle = computed(() => {+ const title = state.title.trim();+ if (title) {+ return title;}+ return generatePlanTitle("bb.plan.export-data", targetTitleNames.value);+});- router.push({- name: PROJECT_V1_ROUTE_PLAN_DETAIL,- params: {- projectId: extractProjectResourceName(project.value.name),- planId: "create",- },- query,- });+const syncGeneratedTitle = () => {+ if (project.value.enforceIssueTitle) return;+ if (targetTitleNames.value.length === 0) return;+ if (state.titleEdited && state.title.trim()) return;+ state.title = generatePlanTitle(+ "bb.plan.export-data",+ targetTitleNames.value+ );};-const cancel = () => {+watch(+ () => targetTitleNames.value.join(","),+ () => {+ syncGeneratedTitle();+ },+ { immediate: true }+);++watch(+ () => props.show,+ (show) => {+ if (show) {+ resetState();+ syncGeneratedTitle();+ }+ },+ { immediate: true }+);++watchEffect(() => {+ for (const target of targets.value) {+ if (isValidDatabaseName(target)) {+ dbStore.getOrFetchDatabaseByName(target);+ } else if (isValidDatabaseGroupName(target)) {+ dbGroupStore.getOrFetchDBGroupByName(target, {+ view: DatabaseGroupView.FULL,+ });+ }+ }+});++const handleCancel = () => {+ if (state.step === 2) {+ state.step = 1;+ return;+ }+ resetState();emit("dismiss");};++const handleCreate = async () => {+ if (state.creating || !canCreate.value) {+ return;+ }++ state.creating = true;++ try {+ const sheet = createEmptyLocalSheet();+ setSheetStatement(sheet, state.statement);+ const createdSheet = await sheetStore.createSheet(+ project.value.name,+ sheet+ );++ const spec = create(Plan_SpecSchema, {+ id: uuidv4(),+ config: {+ case: "exportDataConfig",+ value: create(Plan_ExportDataConfigSchema, {+ targets: targets.value,+ sheet: createdSheet.name,+ format: state.format,+ password: state.password,+ }),+ },+ });++ const planCreate = create(PlanSchema, {+ title: effectiveTitle.value,+ description: state.description,+ specs: [spec],+ creator: currentUser.value.name,+ });++ const issueCreate = create(IssueSchema, {+ title: effectiveTitle.value,+ description: state.description,+ creator: `users/${currentUser.value.email}`,+ labels: state.labels,+ type: Issue_Type.DATABASE_EXPORT,+ });++ const { createdIssue } = await experimentalCreateIssueByPlan(+ project.value,+ issueCreate,+ planCreate,+ { skipRollout: true }+ );++ resetState();+ emit("dismiss");+ router.push({+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL,+ params: {+ projectId: extractProjectResourceName(createdIssue.name),+ issueId: extractIssueUID(createdIssue.name),+ },+ });+ } catch (error) {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("common.failed"),+ description: String(error),+ });+ } finally {+ state.creating = false;+ }+};</script>diff --git a/frontend/src/components/DataExportPrepForm/index.ts b/frontend/src/components/DataExportPrepForm/index.tsindex a9bcbec805..9a60f7fd57 100644--- a/frontend/src/components/DataExportPrepForm/index.ts+++ b/frontend/src/components/DataExportPrepForm/index.ts@@ -1,3 +1,5 @@import DataExportPrepForm from "./DataExportPrepForm.vue";+export { default as DataExportPrepDrawer } from "./DataExportPrepDrawer.vue";+export * from "./types";export default DataExportPrepForm;diff --git a/frontend/src/components/DataExportPrepForm/types.ts b/frontend/src/components/DataExportPrepForm/types.tsnew file mode 100644index 0000000000..f1ae5577f6--- /dev/null+++ b/frontend/src/components/DataExportPrepForm/types.ts@@ -0,0 +1,30 @@+import type { DatabaseSelectState } from "@/components/DatabaseAndGroupSelector";++export type DataExportPrepStep = 1 | 2;++export interface DataExportPrepSeed {+ targetSelectState?: DatabaseSelectState;+ step?: DataExportPrepStep;+}++export const normalizeDataExportPrepSeed = (+ seed?: DataExportPrepSeed+): {+ targetSelectState?: DatabaseSelectState;+ step: DataExportPrepStep;+} => {+ const targetSelectState = seed?.targetSelectState+ ? {+ changeSource: seed.targetSelectState.changeSource,+ selectedDatabaseNameList: [+ ...seed.targetSelectState.selectedDatabaseNameList,+ ],+ selectedDatabaseGroup: seed.targetSelectState.selectedDatabaseGroup,+ }+ : undefined;++ return {+ targetSelectState,+ step: seed?.step ?? 1,+ };+};diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vueindex 694f2d9459..8828da325e 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue@@ -80,23 +80,19 @@ import {} from "@/components/Plan/components/common";import { getLocalSheetByName, usePlanContext } from "@/components/Plan/logic";import RequiredStar from "@/components/RequiredStar.vue";-import { issueServiceClientConnect, planServiceClientConnect } from "@/connect";+import { planServiceClientConnect } from "@/connect";import {PROJECT_V1_ROUTE_ISSUE_DETAIL,PROJECT_V1_ROUTE_PLAN_DETAIL,} from "@/router/dashboard/projectV1";import {+ experimentalCreateIssueByPlan,pushNotification,useCurrentProjectV1,useCurrentUserV1,useSheetV1Store,} from "@/store";-import {- CreateIssueRequestSchema,- Issue_Type,- IssueSchema,- IssueStatus,-} from "@/types/proto-es/v1/issue_service_pb";+import { Issue_Type, IssueSchema } from "@/types/proto-es/v1/issue_service_pb";import {CreatePlanRequestSchema,type Plan_ChangeDatabaseConfig,@@ -133,10 +129,10 @@ const handleCancel = () => {// Use the validation hook for all specsconst { isSpecEmpty } = useSpecsValidation(computed(() => plan.value.specs));-// Check if this is a data export planconst isDataExportPlan = computed(() => {- return plan.value.specs.every(- (spec) => spec.config.case === "exportDataConfig"+ return (+ plan.value.specs.length > 0 &&+ plan.value.specs.every((spec) => spec.config?.case === "exportDataConfig"));});@@ -231,30 +227,19 @@ const doCreateDataExportIssue = async () => {// Create sheets firstawait createSheets();- // Create the plan- const planRequest = create(CreatePlanRequestSchema, {- parent: project.value.name,- plan: plan.value,+ const issueCreate = create(IssueSchema, {+ title: plan.value.title,+ description: plan.value.description,+ creator: `users/${currentUser.value.email}`,+ labels: selectedLabels.value,+ type: Issue_Type.DATABASE_EXPORT,});- const createdPlan = await planServiceClientConnect.createPlan(planRequest);- if (!createdPlan) {- loading.value = false;- return;- }-- // Create the issue with selected labels- const issueRequest = create(CreateIssueRequestSchema, {- parent: project.value.name,- issue: create(IssueSchema, {- creator: `users/${currentUser.value.email}`,- labels: selectedLabels.value,- plan: createdPlan.name,- status: IssueStatus.OPEN,- type: Issue_Type.DATABASE_EXPORT,- }),- });- const createdIssue =- await issueServiceClientConnect.createIssue(issueRequest);+ const { createdIssue } = await experimentalCreateIssueByPlan(+ project.value,+ issueCreate,+ plan.value,+ { skipRollout: true }+ );resetDraft();@@ -263,7 +248,7 @@ const doCreateDataExportIssue = async () => {router.replace({name: PROJECT_V1_ROUTE_ISSUE_DETAIL,params: {- projectId: extractProjectResourceName(createdPlan.name),+ projectId: extractProjectResourceName(createdIssue.name),issueId: extractIssueUID(createdIssue.name),},});diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vueindex 89aafd5465..9031025705 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateIssueButton.vue@@ -227,6 +227,19 @@ const getIssueTypeFromPlan = (planValue: Plan): Issue_Type => {return Issue_Type.DATABASE_CHANGE;};+const shouldStayOnPlanDetailPage = (planValue: Plan) => {+ if (planValue.specs.length === 0) {+ return true;+ }++ return !planValue.specs.every((spec: Plan_Spec) => {+ return (+ spec.config?.case === "createDatabaseConfig" ||+ spec.config?.case === "exportDataConfig"+ );+ });+};+const doCreateIssue = async () => {if (loading.value) return;if (confirmErrors.value.length > 0) return;@@ -253,13 +266,13 @@ const doCreateIssue = async () => {resetDraft();showPopover.value = false;- // On Plan Detail Page, stay in-place — the Review section will auto-expand.- // On other pages, navigate to the issue (backward compat).+ // Only plan-scoped flows should remain on the dedicated Plan Detail page.+ // Issue-scoped flows must continue on the issue page.const currentRoute = router.currentRoute.value;const isPlanDetailPage =typeof currentRoute.name === "string" &¤tRoute.name.startsWith(PROJECT_V1_ROUTE_PLAN_DETAIL);- if (!isPlanDetailPage) {+ if (!(isPlanDetailPage && shouldStayOnPlanDetailPage(plan.value))) {nextTick(() => {router.push({name: PROJECT_V1_ROUTE_ISSUE_DETAIL,diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/DatabaseChangeView.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/DatabaseChangeView.vueindex 328ca08946..a86d68dba1 100644--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/DatabaseChangeView.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseChangeView/DatabaseChangeView.vue@@ -5,7 +5,7 @@<div v-if="selectedSpec" class="flex flex-col gap-2"><TargetListSection /><div class="h-72 flex flex-col">- <StatementSection />+ <StatementSection header-variant="section" /></div><OptionsSection /></div>diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vueindex bda1679c0a..e33e689d9e 100644--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue@@ -11,7 +11,7 @@<OptionsSection /><div class="h-72 flex flex-col">- <StatementSection />+ <StatementSection header-variant="section" /></div></div></template>diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/LimitsSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/LimitsSection.vueindex f591a5eb7c..6cce3101c1 100644--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/LimitsSection.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/LimitsSection.vue@@ -1,12 +1,14 @@<template><div class="w-full flex flex-col gap-y-2">- <span class="text-base">{{ $t("issue.data-export.limits") }}</span>+ <h3 class="text-base font-medium">+ {{ $t("issue.data-export.limits") }}+ </h3><div class="flex items-center gap-x-2"><span class="text-sm">{{ $t("settings.general.workspace.maximum-sql-result.size.self") }}</span>- <span class=" font-medium">+ <span class="font-medium">{{ maximumResultSize }} MB</span></div>@@ -27,4 +29,4 @@ const maximumResultSize = computed(() => {return Number(size) / 1024 / 1024;});-</script>\ No newline at end of file+</script>diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/OptionsSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/OptionsSection.vueindex 7d97a8e7f1..1ff12fa329 100644--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/OptionsSection.vue+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/OptionsSection.vue@@ -1,7 +1,7 @@<template><div class="flex flex-col gap-y-2"><div class="flex items-center justify-between">- <h3 class="text-base">+ <h3 class="text-base font-medium">{{ $t("issue.data-export.options") }}</h3><divdiff --git a/frontend/src/components/Plan/components/PlanDetailPage/PlanDetailLayout.vue b/frontend/src/components/Plan/components/PlanDetailPage/PlanDetailLayout.vueindex 049e3f3b07..185bfe198a 100644--- a/frontend/src/components/Plan/components/PlanDetailPage/PlanDetailLayout.vue+++ b/frontend/src/components/Plan/components/PlanDetailPage/PlanDetailLayout.vue@@ -36,7 +36,7 @@import { NSpin } from "naive-ui";import { computed, ref, toRef, watch } from "vue";import { useI18n } from "vue-i18n";-import { onBeforeRouteLeave, onBeforeRouteUpdate } from "vue-router";+import { onBeforeRouteLeave, onBeforeRouteUpdate, useRouter } from "vue-router";import {providePlanContext,useBasePlanContext,@@ -47,7 +47,7 @@ import { useNavigationGuard } from "@/components/Plan/logic/useNavigationGuard";import PollerProvider from "@/components/Plan/PollerProvider.vue";import { useProjectByName } from "@/store";import { projectNamePrefix } from "@/store/modules/v1/common";-import { setDocumentTitle } from "@/utils";+import { getIssueRoute, setDocumentTitle } from "@/utils";import PlanDetailHeader from "./PlanDetailHeader.vue";import PlanDetailPage from "./PlanDetailPage.vue";import {@@ -62,6 +62,7 @@ const props = defineProps<{}>();const { t } = useI18n();+const router = useRouter();const {isCreating,plan,@@ -98,6 +99,21 @@ provideSidebarContext(containerRef);const projectName = computed(() => `${projectNamePrefix}${props.projectId}`);const { project } = useProjectByName(projectName);+const shouldRedirectToIssueDetail = computed(() => {+ if (!issue.value?.name) {+ return false;+ }+ if (plan.value.specs.length === 0) {+ return false;+ }+ return plan.value.specs.every((spec) => {+ return (+ spec.config?.case === "createDatabaseConfig" ||+ spec.config?.case === "exportDataConfig"+ );+ });+});+watch([isCreating, ready, () => plan.value?.title, () => project.value.title],() => {@@ -110,6 +126,18 @@ watch({ immediate: true });+watch(+ [ready, shouldRedirectToIssueDetail, () => issue.value?.name],+ ([isReady, shouldRedirect, issueName]) => {+ if (!isReady) return;++ if (issueName && shouldRedirect) {+ void router.replace(getIssueRoute({ name: issueName }));+ }+ },+ { immediate: true }+);+const handleRouteNavigation = async (_to: unknown,_from: unknown,diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vueindex ee9133e775..5d36db2b08 100644--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue@@ -71,7 +71,7 @@ import { computed, h, inject, nextTick, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";import { planServiceClientConnect } from "@/connect";-import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";+import { buildSpecDetailRouteForCurrentPage } from "@/router/dashboard/projectV1RouteHelpers";import {pushNotification,useCurrentProjectV1,@@ -180,14 +180,7 @@ const handleSpecCreated = async (spec: Plan_Spec) => {const gotoSpec = (specId: string, enableEditing = false) => {const currentRoute = router.currentRoute.value;- const nextRoute = {- name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,- params: {- ...(currentRoute.params || {}),- specId,- },- query: currentRoute.query || {},- };+ const nextRoute = buildSpecDetailRouteForCurrentPage(currentRoute, specId);// When spec selection is managed via injection (PlanDetailPage),// keep the local selection responsive while still syncing the URL.diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vueindex 06f3d2f168..ef55ae0e0a 100644--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue@@ -3,8 +3,7 @@<div class="flex items-center justify-between"><div class="flex items-center gap-x-1"><span- class="textlabel uppercase"- :class="isEmpty(state.statement) ? 'text-red-600!' : ''"+ :class="titleClass">{{ statementTitle }}</span>@@ -13,7 +12,7 @@<div class="flex items-center justify-end gap-x-2"><template v-if="isCreating"><SQLUploadButton- size="tiny"+ :size="actionButtonSize":loading="state.isUploadingFile"@update:sql="handleUpdateStatement">@@ -21,7 +20,7 @@</SQLUploadButton><NButtonv-if="shouldShowSchemaEditorButton && targetDatabaseNames.length > 0"- size="tiny"+ :size="actionButtonSize"@click="handleOpenSchemaEditor"><template #icon>@@ -39,7 +38,7 @@<template #trigger><NButtonv-if="!isSheetOversize"- size="tiny"+ :size="actionButtonSize"tag="div":disabled="denyEditStatementReasons.length > 0"@click.prevent="beginEdit"@@ -49,7 +48,7 @@<!-- for oversized sheets, only allow to upload and overwrite the sheet --><SQLUploadButtonv-else- size="tiny"+ :size="actionButtonSize":loading="state.isUploadingFile"@update:sql="handleUpdateStatementAndOverwrite">@@ -64,7 +63,7 @@</template><template v-else><SQLUploadButton- size="tiny"+ :size="actionButtonSize":loading="state.isUploadingFile"@update:sql="handleUpdateStatement">@@ -72,7 +71,7 @@</SQLUploadButton><NButtonv-if="shouldShowSchemaEditorButton"- size="tiny"+ :size="actionButtonSize"@click="handleOpenSchemaEditor"><template #icon>@@ -82,7 +81,7 @@</NButton><NButtonv-if="editorState.isEditing.value"- size="tiny"+ :size="actionButtonSize":disabled="!allowSaveSQL"@click.prevent="saveEdit">@@ -90,7 +89,7 @@</NButton><NButtonv-if="editorState.isEditing.value"- size="tiny"+ :size="actionButtonSize"quaternary@click.prevent="cancelEdit">@@ -244,6 +243,15 @@ type LocalState = {showSchemaEditorDrawer: boolean;};+const props = withDefaults(+ defineProps<{+ headerVariant?: "editor" | "section";+ }>(),+ {+ headerVariant: "editor",+ }+);+const { t } = useI18n();const dialog = useDialog();const { project } = useCurrentProjectV1();@@ -277,6 +285,21 @@ const dialect = computed((): SQLDialect => {const statementTitle = computed(() => {return language.value === "sql" ? t("common.sql") : t("common.statement");});+const titleClass = computed(() => {+ if (props.headerVariant === "section") {+ return [+ "text-base font-medium",+ isEmpty(state.statement) ? "text-red-600!" : "",+ ];+ }+ return [+ "textlabel uppercase",+ isEmpty(state.statement) ? "text-red-600!" : "",+ ];+});+const actionButtonSize = computed(() => {+ return props.headerVariant === "section" ? "small" : "tiny";+});const planCheckRunsForSelectedSpec = computed(() =>planCheckRunListForSpec(planCheckRuns.value, selectedSpec.value));diff --git a/frontend/src/components/Plan/components/StatementSection/StatementSection.vue b/frontend/src/components/Plan/components/StatementSection/StatementSection.vueindex 698bbb4db1..1163d7e1d2 100644--- a/frontend/src/components/Plan/components/StatementSection/StatementSection.vue+++ b/frontend/src/components/Plan/components/StatementSection/StatementSection.vue@@ -1,6 +1,6 @@<template><div v-if="viewMode === 'EDITOR'" class="flex-1">- <EditorView :key="editorViewKey" />+ <EditorView :key="editorViewKey" :header-variant="headerVariant" /></div><ReleaseView v-else-if="viewMode === 'RELEASE'" /></template>@@ -12,6 +12,15 @@ import { useSelectedSpec } from "../SpecDetailView/context";import EditorView from "./EditorView";import ReleaseView from "./ReleaseView";+withDefaults(+ defineProps<{+ headerVariant?: "editor" | "section";+ }>(),+ {+ headerVariant: "editor",+ }+);+const { selectedSpec } = useSelectedSpec();const viewMode = computed((): "NONE" | "EDITOR" | "RELEASE" => {diff --git a/frontend/src/components/Plan/logic/initialize/create.ts b/frontend/src/components/Plan/logic/initialize/create.tsindex e2134cec51..5717e1d7b6 100644--- a/frontend/src/components/Plan/logic/initialize/create.ts+++ b/frontend/src/components/Plan/logic/initialize/create.ts@@ -4,11 +4,9 @@ import { v4 as uuidv4 } from "uuid";import { useRoute } from "vue-router";import { useProjectV1Store } from "@/store";import { projectNamePrefix } from "@/store/modules/v1/common";-import { ExportFormat } from "@/types/proto-es/v1/common_pb";import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";import {Plan_ChangeDatabaseConfigSchema,- Plan_ExportDataConfigSchema,Plan_SpecSchema,PlanSchema,} from "@/types/proto-es/v1/plan_service_pb";@@ -18,7 +16,7 @@ import { sheetNameForSpec, targetsForSpec } from "../plan";import { getLocalSheetByName, getNextLocalSheetUID } from "../sheet";import { extractInitialSQLFromQuery } from "./util";-type PlanTemplate = "bb.plan.change-database" | "bb.plan.export-data";+type PlanTemplate = "bb.plan.change-database";export type InitialSQL = {sqlMap?: Record<string, string>;@@ -48,9 +46,9 @@ export const createPlanSkeleton = async (`${projectNamePrefix}${projectName}`);const template = query.template as PlanTemplate | undefined;- if (!template) {+ if (!template || template !== "bb.plan.change-database") {throw new Error(- "Template is required to create a plan skeleton. Please provide a valid template."+ "Only change-database plan creation is supported from the plan detail route.");}const params: CreatePlanParams = {@@ -115,17 +113,6 @@ const buildSpecForTargetsV1 = async (};break;}- case "bb.plan.export-data": {- spec.config = {- case: "exportDataConfig",- value: createProto(Plan_ExportDataConfigSchema, {- targets,- sheet,- format: ExportFormat.JSON, // default to JSON- }),- };- break;- }}return spec;};diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vueindex ab21ac6458..bdd547957e 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue@@ -62,6 +62,19 @@@update="onEnvironmentUpdate($event)"/>+ <DataExportPrepDrawer+ :show="state.showRequestExportPanel"+ :project-name="selectedProjectName"+ :seed="{+ step: 2,+ targetSelectState: {+ changeSource: 'DATABASE',+ selectedDatabaseNameList: selectedDatabaseNameList,+ },+ }"+ @dismiss="state.showRequestExportPanel = false"+ />+<Drawer:show="!!state.transferOutDatabaseType":auto-focus="true"@@ -116,9 +129,8 @@ import { NButton, NScrollbar, NTooltip } from "naive-ui";import type { VNode } from "vue";import { computed, h, reactive } from "vue";import { useI18n } from "vue-i18n";-import type { LocationQueryRaw } from "vue-router";-import { useRouter } from "vue-router";import { BBAlert } from "@/bbkit";+import DataExportPrepDrawer from "@/components/DataExportPrepForm/DataExportPrepDrawer.vue";import EditEnvironmentDrawer from "@/components/EditEnvironmentDrawer.vue";import LabelEditorDrawer from "@/components/LabelEditorDrawer.vue";import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";@@ -126,10 +138,6 @@ import { preCreateIssue } from "@/components/Plan/logic/issue";import { TransferDatabaseForm } from "@/components/TransferDatabaseForm";import TransferOutDatabaseForm from "@/components/TransferOutDatabaseForm";import { Drawer } from "@/components/v2";-import {- PROJECT_V1_ROUTE_PLAN_DETAIL,- PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,-} from "@/router/dashboard/projectV1";import {pushNotification,useActuatorV1Store,@@ -147,9 +155,6 @@ import {UpdateDatabaseRequestSchema,} from "@/types/proto-es/v1/database_service_pb";import {- extractDatabaseResourceName,- extractProjectResourceName,- generatePlanTitle,PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE,PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE,@@ -165,6 +170,7 @@ interface DatabaseAction {interface LocalState {loading: boolean;+ showRequestExportPanel: boolean;showUnassignAlert: boolean;showLabelEditorDrawer: boolean;showEditEnvironmentDrawer: boolean;@@ -183,6 +189,7 @@ const props = withDefaults(const state = reactive<LocalState>({loading: false,+ showRequestExportPanel: false,showUnassignAlert: false,showLabelEditorDrawer: false,showEditEnvironmentDrawer: false,@@ -195,7 +202,6 @@ const emit = defineEmits<{}>();const { t } = useI18n();-const router = useRouter();const actuatorStore = useActuatorV1Store();const databaseStore = useDatabaseV1Store();const projectStore = useProjectV1Store();@@ -261,42 +267,6 @@ const operations = computed(() => {];});-const generateMultiDb = async (- type: "bb.plan.change-database" | "bb.plan.export-data"-) => {- // Fetch project to check enforce_issue_title setting- const project = await projectStore.getOrFetchProjectByName(- selectedProjectName.value- );-- const query: LocationQueryRaw = {- template: type,- databaseList: props.databases.map((db) => db.name).join(","),- };- // Only set title from generated if enforceIssueTitle is false.- if (!project.enforceIssueTitle) {- query.name = generatePlanTitle(- type,- props.databases.map(- (db) => extractDatabaseResourceName(db.name).databaseName- )- );- }-- const isDataExport = type === "bb.plan.export-data";- router.push({- name: isDataExport- ? PROJECT_V1_ROUTE_PLAN_DETAIL- : PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,- params: {- projectId: extractProjectResourceName(selectedProjectName.value),- planId: "create",- ...(isDataExport ? {} : { specId: "placeholder" }),- },- query,- });-};-const syncSchema = async () => {if (state.loading) {return;@@ -416,7 +386,7 @@ const actions = computed((): DatabaseAction[] => {!selectedProjectName.value ||props.databases.length < 1 ||hasDefaultProjectSelected.value,- click: () => generateMultiDb("bb.plan.export-data"),+ click: () => (state.showRequestExportPanel = true),requiredPermissions: [...PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE],});}diff --git a/frontend/src/router/dashboard/projectV1RouteHelpers.ts b/frontend/src/router/dashboard/projectV1RouteHelpers.tsindex e7fd47f3a5..d3ed3fdb28 100644--- a/frontend/src/router/dashboard/projectV1RouteHelpers.ts+++ b/frontend/src/router/dashboard/projectV1RouteHelpers.ts@@ -1,4 +1,8 @@-import type { LocationQueryValue, RouteLocationRaw } from "vue-router";+import type {+ LocationQueryValue,+ RouteLocationNormalizedLoaded,+ RouteLocationRaw,+} from "vue-router";import {extractPlanUID,extractPlanUIDFromRolloutName,@@ -7,7 +11,10 @@ import {extractStageUID,extractTaskUID,} from "@/utils";-import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "./projectV1";+import {+ PROJECT_V1_ROUTE_PLAN_DETAIL,+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,+} from "./projectV1";export const PLAN_DETAIL_PHASE_DEPLOY = "deploy";@@ -47,6 +54,20 @@ export const buildPlanDeployRoute = ({};};+export const buildSpecDetailRouteForCurrentPage = (+ currentRoute: Pick<RouteLocationNormalizedLoaded, "params" | "query">,+ specId: string+): RouteLocationRaw => {+ return {+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,+ params: {+ ...(currentRoute.params || {}),+ specId,+ },+ query: currentRoute.query || {},+ };+};+export const buildPlanDeployRouteFromPlanName = (planName: string,options?: Omit<BuildPlanDeployRouteParams, "projectId" | "planId">diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vueindex 0c75366bb6..c1becfdf02 100644--- a/frontend/src/views/ExportCenter/index.vue+++ b/frontend/src/views/ExportCenter/index.vue@@ -51,16 +51,11 @@</PagedTable></div>- <Drawer- :auto-focus="true"+ <DataExportPrepDrawer:show="state.showRequestExportPanel"- @close="state.showRequestExportPanel = false"- >- <DataExportPrepForm- :project-name="specificProject.name"- @dismiss="state.showRequestExportPanel = false"- />- </Drawer>+ :project-name="specificProject.name"+ @dismiss="state.showRequestExportPanel = false"+ /></template><script lang="ts" setup>@@ -68,11 +63,10 @@ import { DownloadIcon } from "lucide-vue-next";import { NButton } from "naive-ui";import { computed, reactive, ref, watch } from "vue";import type { ComponentExposed } from "vue-component-type-helpers";-import DataExportPrepForm from "@/components/DataExportPrepForm";+import DataExportPrepDrawer from "@/components/DataExportPrepForm/DataExportPrepDrawer.vue";import IssueListV1 from "@/components/IssueV1/components/IssueListV1.vue";import IssueSearch from "@/components/IssueV1/components/IssueSearch/IssueSearch.vue";import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";-import { Drawer } from "@/components/v2";import PagedTable from "@/components/v2/Model/PagedTable.vue";import {useIssueV1Store,