Skip to content

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

refactor: database export issue (#17458)

boojackb23a4ad53825
diff --git a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
index 2496afdaaf..a997401571 100644
--- a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
+++ b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
@@ -45,7 +45,7 @@ import { useRouter, type LocationQueryRaw } from "vue-router";
import DatabaseAndGroupSelector, {
type DatabaseSelectState,
} from "@/components/DatabaseAndGroupSelector/";
-import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
import { useProjectByName } from "@/store";
import { generateIssueTitle, extractProjectResourceName } from "@/utils";
import { DrawerContent } from "../v2";
@@ -94,10 +94,10 @@ const navigateToIssuePage = async () => {
}
router.push({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
- issueSlug: "create",
+ planId: "create",
},
query,
});
diff --git a/frontend/src/components/IssueV1/DataExportIssueDetailPage.vue b/frontend/src/components/IssueV1/DataExportIssueDetailPage.vue
deleted file mode 100644
index c92166cdd5..0000000000
--- a/frontend/src/components/IssueV1/DataExportIssueDetailPage.vue
+++ /dev/null
@@ -1,148 +0,0 @@
-<template>
- <div ref="containerRef" class="h-full flex flex-col">
- <div class="border-b">
- <BannerSection v-if="!isCreating" />
- <FeatureAttention :feature="PlanFeature.FEATURE_APPROVAL_WORKFLOW" />
- <HeaderSection />
- </div>
- <div class="flex-1 flex flex-row">
- <div
- class="flex-1 flex flex-col hide-scrollbar divide-y overflow-x-hidden"
- >
- <DataExportSection />
- <TaskRunSection v-if="!isCreating" />
- <SQLCheckSection v-if="isCreating" />
- <StatementSection />
- <DescriptionSection v-if="isCreating" />
- <IssueCommentSection v-if="!isCreating" />
- </div>
-
- <div
- v-if="sidebarMode == 'DESKTOP'"
- class="hide-scrollbar border-l"
- :style="{
- width: `${desktopSidebarWidth}px`,
- }"
- >
- <Sidebar />
- </div>
- </div>
- </div>
-
- <template v-if="sidebarMode === 'MOBILE'">
- <!-- mobile sidebar -->
- <Drawer :show="mobileSidebarOpen" @close="mobileSidebarOpen = false">
- <div
- style="
- min-width: 240px;
- width: 80vw;
- max-width: 320px;
- padding: 0.5rem 0;
- "
- >
- <Sidebar v-if="sidebarMode === 'MOBILE'" />
- </div>
- </Drawer>
- </template>
-
- <IssueReviewActionPanel
- :action="ongoingIssueReviewAction?.action"
- @close="ongoingIssueReviewAction = undefined"
- />
- <IssueStatusActionPanel
- :action="ongoingIssueStatusAction?.action"
- @close="ongoingIssueStatusAction = undefined"
- />
- <TaskRolloutActionPanel
- :action="ongoingTaskRolloutAction?.action"
- :task-list="ongoingTaskRolloutAction?.taskList ?? []"
- @close="ongoingTaskRolloutAction = undefined"
- />
-</template>
-
-<script setup lang="ts">
-import { computed, ref } from "vue";
-import { FeatureAttention } from "@/components/FeatureGuard";
-import { useCurrentProjectV1 } from "@/store";
-import type { Plan, Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
-import type { Task } from "@/types/proto-es/v1/rollout_service_pb";
-import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
-import { SQLCheckSection } from "../Plan/components";
-import { providePlanSQLCheckContext } from "../Plan/components/SQLCheckSection";
-import { provideSidebarContext } from "../Plan/logic";
-import { Drawer } from "../v2";
-import {
- BannerSection,
- HeaderSection,
- StatementSection,
- DescriptionSection,
- IssueCommentSection,
- Sidebar,
- IssueReviewActionPanel,
- IssueStatusActionPanel,
- TaskRolloutActionPanel,
- DataExportSection,
- TaskRunSection,
-} from "./components";
-import type {
- IssueReviewAction,
- IssueStatusAction,
- TaskRolloutAction,
-} from "./logic";
-import { specForTask, useIssueContext, usePollIssue } from "./logic";
-
-const containerRef = ref<HTMLElement>();
-const { isCreating, issue, selectedTask, events } = useIssueContext();
-const { project } = useCurrentProjectV1();
-
-const ongoingIssueReviewAction = ref<{
- action: IssueReviewAction;
-}>();
-const ongoingIssueStatusAction = ref<{
- action: IssueStatusAction;
-}>();
-const ongoingTaskRolloutAction = ref<{
- action: TaskRolloutAction;
- taskList: Task[];
-}>();
-
-usePollIssue();
-
-events.on("perform-issue-review-action", ({ action }) => {
- ongoingIssueReviewAction.value = {
- action,
- };
-});
-
-events.on("perform-issue-status-action", ({ action }) => {
- ongoingIssueStatusAction.value = {
- action,
- };
-});
-
-events.on("perform-task-rollout-action", async ({ action, tasks }) => {
- ongoingTaskRolloutAction.value = {
- action,
- taskList: tasks,
- };
-});
-
-providePlanSQLCheckContext({
- project,
- plan: computed(() => issue.value.planEntity as Plan),
- selectedSpec: computed(
- () =>
- specForTask(
- issue.value.planEntity as Plan,
- selectedTask.value
- ) as Plan_Spec
- ),
- selectedTask: selectedTask,
-});
-
-const {
- mode: sidebarMode,
- desktopSidebarWidth,
- mobileSidebarOpen,
-} = provideSidebarContext(containerRef);
-</script>
diff --git a/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue b/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue
deleted file mode 100644
index f3db8c7019..0000000000
--- a/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue
+++ /dev/null
@@ -1,61 +0,0 @@
-<template>
- <div class="w-full flex flex-col divide-y">
- <template v-if="stageList.length > 0">
- <StageSection />
- <TaskListSection />
- <div class="w-full py-2 px-2 sm:px-4">
- <BBAttention
- v-if="policyStore.maximumResultRows !== Number.MAX_VALUE"
- class="w-full mb-2"
- :type="'warning'"
- >
- {{
- $t(
- "settings.general.workspace.maximum-sql-result.rows.limit-warning",
- { count: policyStore.maximumResultRows }
- )
- }}
- </BBAttention>
- <ExportOptionSection />
- </div>
- </template>
- <template v-else>
- <NoPermissionPlaceholder
- v-if="placeholder === 'PERMISSION_DENIED'"
- class="py-6"
- />
- <NEmpty v-else class="py-6" />
- </template>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { NEmpty } from "naive-ui";
-import { computed } from "vue";
-import { BBAttention } from "@/bbkit";
-import { useIssueContext } from "@/components/IssueV1/logic";
-import NoPermissionPlaceholder from "@/components/misc/NoPermissionPlaceholder.vue";
-import { useCurrentProjectV1, usePolicyV1Store } from "@/store";
-import { hasProjectPermissionV2 } from "@/utils";
-import { StageSection, TaskListSection } from "../../components";
-import ExportOptionSection from "./ExportOptionSection";
-
-const { isCreating, issue } = useIssueContext();
-const { project } = useCurrentProjectV1();
-const policyStore = usePolicyV1Store();
-
-// For database data export issue, the stageList should always be only 1 stage.
-const stageList = computed(() => {
- return issue.value.rolloutEntity?.stages || [];
-});
-
-const placeholder = computed(() => {
- if (
- isCreating.value &&
- !hasProjectPermissionV2(project.value, "bb.rollouts.preview")
- ) {
- return "PERMISSION_DENIED";
- }
- return "NO_DATA";
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/ExportOptionSection.vue b/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/ExportOptionSection.vue
deleted file mode 100644
index f215696085..0000000000
--- a/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/ExportOptionSection.vue
+++ /dev/null
@@ -1,204 +0,0 @@
-<template>
- <div class="w-full flex flex-col">
- <div class="w-full flex flex-row justify-between items-center mb-1">
- <span class="textlabel mr-4">{{ $t("issue.data-export.options") }}</span>
- <div
- v-if="showEditButtons"
- class="flex flex-row justify-end items-center gap-2"
- >
- <NTooltip
- v-if="!state.isEditing"
- :disabled="denyEditTaskReasons.length === 0"
- >
- <template #trigger>
- <NButton
- size="tiny"
- tag="div"
- :disabled="denyEditTaskReasons.length > 0"
- @click="state.isEditing = true"
- >
- {{ $t("common.edit") }}
- </NButton>
- </template>
- <template #default>
- <ErrorList :errors="denyEditTaskReasons" />
- </template>
- </NTooltip>
- <template v-else>
- <NButton size="tiny" @click="handleSaveEdit">
- {{ $t("common.save") }}
- </NButton>
- <NButton size="tiny" quaternary @click.prevent="handleCancelEdit">
- {{ $t("common.cancel") }}
- </NButton>
- </template>
- </div>
- </div>
- <div class="w-full h-8 flex flex-row justify-start items-center">
- <span class="textinfolabel inline-block mr-2 !min-w-[64px]">{{
- $t("issue.data-export.format")
- }}</span>
- <ExportFormatSelector
- :key="refreshKey"
- v-model:format="convertedFormat"
- :editable="optionsEditable"
- />
- </div>
- <div class="w-full h-8 flex flex-row justify-start items-center">
- <span class="textinfolabel inline-block mr-2 !min-w-[64px]">{{
- $t("issue.data-export.encrypt")
- }}</span>
- <ExportPasswordInputer
- :key="refreshKey"
- v-model:password="state.config.password"
- :editable="optionsEditable"
- />
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { create } from "@bufbuild/protobuf";
-import { cloneDeep, head } from "lodash-es";
-import { NButton, NTooltip } from "naive-ui";
-import { computed, watch, reactive, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import {
- allowUserToEditStatementForTask,
- useIssueContext,
-} from "@/components/IssueV1/logic";
-import ErrorList from "@/components/misc/ErrorList.vue";
-import { planServiceClientConnect } from "@/grpcweb";
-import { pushNotification } from "@/store";
-import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
-import { type Plan_ExportDataConfig } from "@/types/proto-es/v1/plan_service_pb";
-import {
- UpdatePlanRequestSchema,
- Plan_SpecSchema,
- Plan_ExportDataConfigSchema,
-} from "@/types/proto-es/v1/plan_service_pb";
-import ExportFormatSelector from "./ExportFormatSelector.vue";
-import ExportPasswordInputer from "./ExportPasswordInputer.vue";
-
-interface LocalState {
- config: Plan_ExportDataConfig;
- isEditing: boolean;
-}
-
-const { t } = useI18n();
-const context = useIssueContext();
-const { issue, isCreating, selectedTask, events } = context;
-const refreshKey = ref(0);
-
-const spec = computed(
- () => head(issue.value.planEntity?.specs) || create(Plan_SpecSchema, {})
-);
-
-const state = reactive<LocalState>({
- config: create(
- Plan_ExportDataConfigSchema,
- spec.value.config?.case === "exportDataConfig"
- ? {
- targets: spec.value.config.value.targets,
- sheet: spec.value.config.value.sheet,
- format: spec.value.config.value.format,
- password: spec.value.config.value.password,
- }
- : {}
- ),
- isEditing: false,
-});
-
-const showEditButtons = computed(() => {
- return !isCreating.value && issue.value.status === IssueStatus.OPEN;
-});
-
-const optionsEditable = computed(() => {
- return isCreating.value || (showEditButtons.value && state.isEditing);
-});
-
-const denyEditTaskReasons = computed(() =>
- allowUserToEditStatementForTask(issue.value, selectedTask.value)
-);
-
-// Convert between old and new ExportFormat types
-const convertedFormat = computed({
- get() {
- return state.config.format;
- },
- set(value) {
- state.config.format = value;
- },
-});
-
-const handleCancelEdit = () => {
- state.isEditing = false;
- state.config = create(
- Plan_ExportDataConfigSchema,
- spec.value.config?.case === "exportDataConfig"
- ? {
- targets: spec.value.config.value.targets,
- sheet: spec.value.config.value.sheet,
- format: spec.value.config.value.format,
- password: spec.value.config.value.password,
- }
- : {}
- );
- // Trigger a re-render of the child components.
- refreshKey.value++;
-};
-
-const handleSaveEdit = async () => {
- const planPatch = cloneDeep(issue.value.planEntity);
- if (!planPatch) {
- // Should not reach here.
- throw new Error("Plan is not defined. Cannot update export options.");
- }
-
- const distinctSpecIds = new Set([spec.value.id]);
- const specsToPatch = (planPatch.specs || []).filter((spec) =>
- distinctSpecIds.has(spec.id)
- );
- for (let i = 0; i < specsToPatch.length; i++) {
- const spec = specsToPatch[i];
- if (spec.config?.case === "exportDataConfig") {
- spec.config.value.format = state.config.format;
- spec.config.value.password = state.config.password || undefined;
- }
- }
-
- const request = create(UpdatePlanRequestSchema, {
- plan: planPatch,
- updateMask: { paths: ["specs"] },
- });
- const response = await planServiceClientConnect.updatePlan(request);
- issue.value.planEntity = response;
-
- events.emit("status-changed", { eager: true });
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
- handleCancelEdit();
-};
-
-watch(
- () => state.config,
- () => {
- if (!isCreating.value) {
- return;
- }
- for (const spec of issue.value.planEntity?.specs ?? []) {
- if (spec.config?.case === "exportDataConfig") {
- spec.config.value = create(Plan_ExportDataConfigSchema, {
- ...spec.config.value,
- format: state.config.format,
- password: state.config.password,
- });
- }
- }
- },
- { deep: true }
-);
-</script>
diff --git a/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/index.ts b/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/index.ts
deleted file mode 100644
index 8df7a2ff74..0000000000
--- a/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import ExportOptionSection from "./ExportOptionSection.vue";
-
-export default ExportOptionSection;
diff --git a/frontend/src/components/IssueV1/components/DataExportSection/index.ts b/frontend/src/components/IssueV1/components/DataExportSection/index.ts
deleted file mode 100644
index d3df01c753..0000000000
--- a/frontend/src/components/IssueV1/components/DataExportSection/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import DataExportSection from "./DataExportSection.vue";
-
-export default DataExportSection;
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueExtraActionButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueExtraActionButtonGroup.vue
deleted file mode 100644
index ec8791dc48..0000000000
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueExtraActionButtonGroup.vue
+++ /dev/null
@@ -1,45 +0,0 @@
-<template>
- <div v-if="show" class="flex items-center gap-x-2">
- <ExportArchiveDownloadButton v-if="shouldShowExportArchiveDownloadButton" />
- </div>
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import {
- PrimaryTaskRolloutActionList,
- getApplicableTaskRolloutActionList,
- useIssueContext,
-} from "@/components/IssueV1/logic";
-import { useCurrentUserV1 } from "@/store";
-import { userNamePrefix } from "@/store/modules/v1/common";
-import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
-import { isDatabaseDataExportIssue } from "@/utils";
-import { ExportArchiveDownloadButton } from "../request";
-
-const currentUser = useCurrentUserV1();
-const { issue, selectedTask } = useIssueContext();
-
-const taskRolloutActionList = computed(() => {
- return getApplicableTaskRolloutActionList(issue.value, selectedTask.value);
-});
-
-const primaryTaskRolloutActionList = computed(() => {
- return taskRolloutActionList.value.filter((action) =>
- PrimaryTaskRolloutActionList.includes(action)
- );
-});
-
-const shouldShowExportArchiveDownloadButton = computed(() => {
- return (
- [IssueStatus.OPEN, IssueStatus.DONE].includes(issue.value.status) &&
- primaryTaskRolloutActionList.value.length == 0 &&
- issue.value.creator === `${userNamePrefix}${currentUser.value.email}` &&
- isDatabaseDataExportIssue(issue.value)
- );
-});
-
-const show = computed(() => {
- return shouldShowExportArchiveDownloadButton.value;
-});
-</script>
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/index.ts b/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/index.ts
index 260d03e16d..0f556f0e6a 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/index.ts
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/index.ts
@@ -1,5 +1,4 @@
-import IssueExtraActionButtonGroup from "./IssueExtraActionButtonGroup.vue";
import IssueStatusActionButtonGroup from "./IssueStatusActionButtonGroup";
export * from "./types";
-export { IssueExtraActionButtonGroup, IssueStatusActionButtonGroup };
+export { IssueStatusActionButtonGroup };
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportArchiveDownloadButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportArchiveDownloadButton.vue
deleted file mode 100644
index 8cb40ad289..0000000000
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportArchiveDownloadButton.vue
+++ /dev/null
@@ -1,142 +0,0 @@
-<template>
- <NTooltip
- v-if="taskRun?.exportArchiveStatus === TaskRun_ExportArchiveStatus.READY"
- >
- <template #trigger>
- <NButton
- type="primary"
- :loading="state.isExporting"
- @click="downloadExportArchive"
- >
- <template #icon>
- <DownloadIcon class="w-5 h-5" />
- </template>
- {{ $t("common.download") }}
- </NButton>
- </template>
- <span class="text-sm">
- {{ $t("issue.data-export.download-tooltip") }}
- </span>
- </NTooltip>
- <div
- v-else-if="
- taskRun?.exportArchiveStatus === TaskRun_ExportArchiveStatus.EXPORTED
- "
- class="flex flex-row items-center gap-2 text-sm textlabel !leading-8"
- >
- <CircleCheckBigIcon class="w-5 h-auto" />
- {{ $t("issue.data-export.file-downloaded") }}
- </div>
-</template>
-
-<script setup lang="ts">
-import { create } from "@bufbuild/protobuf";
-import dayjs from "dayjs";
-import { head, last } from "lodash-es";
-import { DownloadIcon, CircleCheckBigIcon } from "lucide-vue-next";
-import { NButton, NTooltip } from "naive-ui";
-import { computed, reactive } from "vue";
-import { watchEffect } from "vue";
-import { useIssueContext } from "@/components/IssueV1";
-import { issueServiceClientConnect } from "@/grpcweb";
-import { useSQLStore } from "@/store";
-import { ExportFormat } from "@/types/proto-es/v1/common_pb";
-import {
- BatchUpdateIssuesStatusRequestSchema,
- IssueStatus as NewIssueStatus,
-} from "@/types/proto-es/v1/issue_service_pb";
-import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
-import {
- Plan_ExportDataConfigSchema,
- Plan_SpecSchema,
- type Plan_ExportDataConfig,
-} from "@/types/proto-es/v1/plan_service_pb";
-import {
- TaskRun_ExportArchiveStatus,
- Task_Status,
-} from "@/types/proto-es/v1/rollout_service_pb";
-import { ExportRequestSchema } from "@/types/proto-es/v1/sql_service_pb";
-import { flattenTaskV1List } from "@/utils";
-
-interface LocalState {
- isExporting: boolean;
-}
-
-const { issue, events, selectedStage } = useIssueContext();
-const state = reactive<LocalState>({
- isExporting: false,
-});
-
-const taskRun = computed(() => {
- return last(issue.value.rolloutTaskRunList);
-});
-
-const exportDataConfig = computed(() => {
- const spec =
- head(issue.value.planEntity?.specs) || create(Plan_SpecSchema, {});
- return (
- (spec.config?.value as Plan_ExportDataConfig) ||
- create(Plan_ExportDataConfigSchema, {})
- );
-});
-
-watchEffect(async () => {
- if (issue.value.status === IssueStatus.OPEN) {
- if (
- flattenTaskV1List(issue.value.rolloutEntity).every((task) => {
- return [Task_Status.DONE, Task_Status.SKIPPED].includes(task.status);
- })
- ) {
- const request = create(BatchUpdateIssuesStatusRequestSchema, {
- parent: issue.value.project,
- issues: [issue.value.name],
- status: NewIssueStatus.DONE,
- });
- await issueServiceClientConnect.batchUpdateIssuesStatus(request);
- }
- }
-});
-
-const downloadExportArchive = async () => {
- state.isExporting = true;
- const content = await useSQLStore().exportData(
- create(ExportRequestSchema, {
- name: selectedStage.value.name,
- })
- );
- const fileType = getExportFileType(exportDataConfig.value);
- const buffer = content.buffer.slice(
- content.byteOffset,
- content.byteOffset + content.byteLength
- ) as ArrayBuffer;
- const blob = new Blob([buffer], {
- type: fileType,
- });
- const url = window.URL.createObjectURL(blob);
-
- const formattedDateString = dayjs(new Date()).format("YYYY-MM-DDTHH-mm-ss");
- const filename = `export-data-${formattedDateString}`;
- const link = document.createElement("a");
- link.download = `${filename}.zip`;
- link.href = url;
- link.click();
- events.emit("status-changed", { eager: true });
- state.isExporting = false;
-};
-
-const getExportFileType = (exportDataConfig: Plan_ExportDataConfig) => {
- if (exportDataConfig.password) {
- return "application/zip";
- }
- switch (exportDataConfig.format) {
- case ExportFormat.CSV:
- return "text/csv";
- case ExportFormat.JSON:
- return "application/json";
- case ExportFormat.SQL:
- return "application/sql";
- case ExportFormat.XLSX:
- return "application/vnd.ms-excel";
- }
-};
-</script>
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportCenterButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportCenterButton.vue
deleted file mode 100644
index 8804b6f4c5..0000000000
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/ExportCenterButton.vue
+++ /dev/null
@@ -1,27 +0,0 @@
-<template>
- <NButton type="primary" size="large" @click="toExportCenter">
- <template #icon>
- <heroicons-outline:download class="w-5 h-5" />
- </template>
-
- {{ $t("export-center.self") }}
- </NButton>
-</template>
-
-<script setup lang="ts">
-import { NButton } from "naive-ui";
-import { useRouter } from "vue-router";
-import { useIssueContext } from "@/components/IssueV1";
-import { WORKSPACE_ROUTE_EXPORT_CENTER } from "@/router/dashboard/workspaceRoutes";
-import { extractIssueUID } from "@/utils";
-
-const router = useRouter();
-const { issue } = useIssueContext();
-
-const toExportCenter = () => {
- router.push({
- name: WORKSPACE_ROUTE_EXPORT_CENTER,
- hash: `#${extractIssueUID(issue.value.name)}`,
- });
-};
-</script>
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/index.ts b/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/index.ts
index 45d839284e..ce433ca37e 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/index.ts
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/request/index.ts
@@ -1,5 +1,3 @@
-import ExportArchiveDownloadButton from "./ExportArchiveDownloadButton.vue";
-import ExportCenterButton from "./ExportCenterButton.vue";
import TinySQLEditorButton from "./TinySQLEditorButton.vue";
-export { TinySQLEditorButton, ExportCenterButton, ExportArchiveDownloadButton };
+export { TinySQLEditorButton };
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
index c1bee5eb8a..39276550e8 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
@@ -1,7 +1,5 @@
<template>
<div class="flex gap-x-3">
- <IssueExtraActionButtonGroup v-if="shouldShowExtraActionButtonGroup" />
-
<RolloutActionButtonGroup
v-if="primaryTaskRolloutActionList.length > 0"
:task-rollout-action-list="primaryTaskRolloutActionList"
@@ -33,12 +31,8 @@ import {
useIssueContext,
} from "@/components/IssueV1/logic";
import type { Task } from "@/types/proto-es/v1/rollout_service_pb";
-import { isDatabaseDataExportIssue } from "@/utils";
import type { ExtraActionOption } from "../common";
-import {
- IssueStatusActionButtonGroup,
- IssueExtraActionButtonGroup,
-} from "../common";
+import { IssueStatusActionButtonGroup } from "../common";
import RolloutActionButtonGroup from "./RolloutActionButtonGroup.vue";
import type { RolloutAction } from "./common";
@@ -107,15 +101,8 @@ const extraActionList = computed(() => {
return list;
});
-const shouldShowExtraActionButtonGroup = computed(() => {
- return isDatabaseDataExportIssue(issue.value);
-});
-
const issueStatusButtonsDisplayMode = computed(() => {
- return shouldShowExtraActionButtonGroup.value ||
- primaryTaskRolloutActionList.value.length > 0
- ? "DROPDOWN"
- : "BUTTON";
+ return primaryTaskRolloutActionList.value.length > 0 ? "DROPDOWN" : "BUTTON";
});
const performRolloutAction = async (params: RolloutAction) => {
diff --git a/frontend/src/components/IssueV1/components/index.ts b/frontend/src/components/IssueV1/components/index.ts
index 229cfe7f4d..2d99090324 100644
--- a/frontend/src/components/IssueV1/components/index.ts
+++ b/frontend/src/components/IssueV1/components/index.ts
@@ -1,5 +1,4 @@
import BannerSection from "./BannerSection.vue";
-import DataExportSection from "./DataExportSection";
import DescriptionSection from "./DescriptionSection";
import HeaderSection from "./HeaderSection";
import IssueCommentSection from "./IssueCommentSection";
@@ -24,6 +23,5 @@ export {
DescriptionSection,
IssueSearch,
Sidebar,
- DataExportSection,
IssueCommentSection,
};
diff --git a/frontend/src/components/IssueV1/index.ts b/frontend/src/components/IssueV1/index.ts
index bb7d726538..5607abf290 100644
--- a/frontend/src/components/IssueV1/index.ts
+++ b/frontend/src/components/IssueV1/index.ts
@@ -1,11 +1,6 @@
-import DataExportIssueDetailPage from "./DataExportIssueDetailPage.vue";
import GrantRequestIssueDetailPage from "./GrantRequestIssueDetailPage.vue";
import IssueDetailPage from "./IssueDetailPage.vue";
export * from "./logic";
-export {
- DataExportIssueDetailPage,
- IssueDetailPage,
- GrantRequestIssueDetailPage,
-};
+export { IssueDetailPage, GrantRequestIssueDetailPage };
diff --git a/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/ExportFormatSelector.vue b/frontend/src/components/Plan/components/ExportOption/ExportFormatSelector.vue
similarity index 91%
rename from frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/ExportFormatSelector.vue
rename to frontend/src/components/Plan/components/ExportOption/ExportFormatSelector.vue
index 124561d3b6..3ae99a1594 100644
--- a/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/ExportFormatSelector.vue
+++ b/frontend/src/components/Plan/components/ExportOption/ExportFormatSelector.vue
@@ -8,7 +8,9 @@
/>
</NRadioGroup>
<template v-else>
- <span class="text-base">{{ exportFormatToString(format) }}</span>
+ <span class="text-sm font-medium leading-6">{{
+ exportFormatToString(format)
+ }}</span>
</template>
</template>
diff --git a/frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/ExportPasswordInputer.vue b/frontend/src/components/Plan/components/ExportOption/ExportPasswordInputer.vue
similarity index 100%
rename from frontend/src/components/IssueV1/components/DataExportSection/ExportOptionSection/ExportPasswordInputer.vue
rename to frontend/src/components/Plan/components/ExportOption/ExportPasswordInputer.vue
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
index 34719ee7f0..a6fa2eff07 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue
@@ -119,7 +119,6 @@ const {
hasRunning: hasRunningPlanChecks,
} = usePlanCheckStatus(plan);
-// Provide issue review context when an issue exists
const reviewContext = useIssueReviewContext();
// Policy for restricting issue creation when plan checks fail
@@ -143,13 +142,17 @@ const pendingReviewAction = ref<IssueReviewAction | undefined>(undefined);
const pendingStatusAction = ref<IssueStatusAction | undefined>(undefined);
const pendingRolloutAction = ref<RolloutAction | undefined>(undefined);
-// Get the stage that contains database creation tasks
+// Get the stage that contains database creation or export tasks
const rolloutStage = computed(() => {
if (!rollout.value) return undefined;
- // Find the first stage with database creation tasks
+ // Find the first stage with database creation or export tasks
return rollout.value.stages.find((stage) =>
- stage.tasks.some((task) => task.type === Task_Type.DATABASE_CREATE)
+ stage.tasks.some(
+ (task) =>
+ task.type === Task_Type.DATABASE_CREATE ||
+ task.type === Task_Type.DATABASE_EXPORT
+ )
);
});
@@ -334,11 +337,15 @@ const availableActions = computed(() => {
hasProjectPermissionV2(project.value, "bb.taskRuns.create") &&
issueValue.approvalFindingDone
) {
- const hasDatabaseCreateTasks = rollout.value.stages.some((stage) =>
- stage.tasks.some((task) => task.type === Task_Type.DATABASE_CREATE)
+ const hasDatabaseCreateOrExportTasks = rollout.value.stages.some((stage) =>
+ stage.tasks.some(
+ (task) =>
+ task.type === Task_Type.DATABASE_CREATE ||
+ task.type === Task_Type.DATABASE_EXPORT
+ )
);
- if (hasDatabaseCreateTasks) {
+ if (hasDatabaseCreateOrExportTasks) {
// Show ROLLOUT_START if there are actionable database creation tasks
// This includes both normal rollout and force rollout scenarios
const hasStartableTasks = rollout.value.stages
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
index 2c2beddc68..0afe0932cd 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue
@@ -34,16 +34,39 @@ import {
getLocalSheetByName,
} from "@/components/Plan/logic";
import { usePlanContext } from "@/components/Plan/logic";
-import { planServiceClientConnect } from "@/grpcweb";
-import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
-import { useCurrentProjectV1, useSheetV1Store } from "@/store";
+import {
+ planServiceClientConnect,
+ issueServiceClientConnect,
+ rolloutServiceClientConnect,
+} from "@/grpcweb";
+import {
+ PROJECT_V1_ROUTE_PLAN_DETAIL,
+ PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+} from "@/router/dashboard/projectV1";
+import {
+ useCurrentProjectV1,
+ useSheetV1Store,
+ useCurrentUserV1,
+ pushNotification,
+} from "@/store";
+import {
+ CreateIssueRequestSchema,
+ IssueSchema,
+ IssueStatus,
+ Issue_Type,
+} from "@/types/proto-es/v1/issue_service_pb";
import { CreatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
-import { type Plan_ChangeDatabaseConfig } from "@/types/proto-es/v1/plan_service_pb";
+import {
+ type Plan_ChangeDatabaseConfig,
+ type Plan_ExportDataConfig,
+} from "@/types/proto-es/v1/plan_service_pb";
+import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";
import type { Sheet } from "@/types/proto-es/v1/sheet_service_pb";
import {
extractPlanUID,
extractProjectResourceName,
extractSheetUID,
+ extractIssueUID,
hasProjectPermissionV2,
} from "@/utils";
@@ -52,11 +75,19 @@ const router = useRouter();
const { project } = useCurrentProjectV1();
const { plan } = usePlanContext();
const sheetStore = useSheetV1Store();
+const currentUser = useCurrentUserV1();
const loading = ref(false);
// Use the validation hook for all specs
const { isSpecEmpty } = useSpecsValidation(computed(() => plan.value.specs));
+// Check if this is a data export plan
+const isDataExportPlan = computed(() => {
+ return plan.value.specs.every(
+ (spec) => spec.config.case === "exportDataConfig"
+ );
+});
+
const planCreateErrorList = computed(() => {
const errorList: string[] = [];
if (!hasProjectPermissionV2(project.value, "bb.plans.create")) {
@@ -75,39 +106,107 @@ const doCreatePlan = async () => {
loading.value = true;
try {
- await createSheets();
- const request = create(CreatePlanRequestSchema, {
- parent: project.value.name,
- plan: plan.value,
- });
- const createdPlan = await planServiceClientConnect.createPlan(request);
- if (!createdPlan) return;
-
- nextTick(() => {
- router.replace({
- name: PROJECT_V1_ROUTE_PLAN_DETAIL,
- params: {
- projectId: extractProjectResourceName(createdPlan.name),
- planId: extractPlanUID(createdPlan.name),
- },
+ // For data export plans, create plan + issue + rollout and redirect to issue
+ if (isDataExportPlan.value) {
+ await doCreateDataExportIssue();
+ } else {
+ // For regular plans, just create the plan
+ await createSheets();
+ const request = create(CreatePlanRequestSchema, {
+ parent: project.value.name,
+ plan: plan.value,
});
- });
+ const createdPlan = await planServiceClientConnect.createPlan(request);
+ if (!createdPlan) return;
- return createdPlan;
- } catch {
+ nextTick(() => {
+ router.replace({
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(createdPlan.name),
+ planId: extractPlanUID(createdPlan.name),
+ },
+ });
+ });
+ }
+ } catch (error) {
+ console.error("Failed to create plan:", error);
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: "Failed to create",
+ description: String(error),
+ });
loading.value = false;
}
};
+// Create data export issue (plan + issue + rollout)
+const doCreateDataExportIssue = async () => {
+ // Create sheets first
+ await createSheets();
+
+ // Create the plan
+ const planRequest = create(CreatePlanRequestSchema, {
+ parent: project.value.name,
+ plan: plan.value,
+ });
+ const createdPlan = await planServiceClientConnect.createPlan(planRequest);
+ if (!createdPlan) return;
+
+ // Create the issue
+ const issueRequest = create(CreateIssueRequestSchema, {
+ parent: project.value.name,
+ issue: create(IssueSchema, {
+ creator: `users/${currentUser.value.email}`,
+ labels: [],
+ plan: createdPlan.name,
+ status: IssueStatus.OPEN,
+ type: Issue_Type.DATABASE_EXPORT,
+ rollout: "",
+ }),
+ });
+ const createdIssue =
+ await issueServiceClientConnect.createIssue(issueRequest);
+
+ // Create the rollout
+ const rolloutRequest = create(CreateRolloutRequestSchema, {
+ parent: project.value.name,
+ rollout: {
+ plan: createdPlan.name,
+ },
+ });
+ await rolloutServiceClientConnect.createRollout(rolloutRequest);
+
+ // Redirect to issue detail page
+ nextTick(() => {
+ router.replace({
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+ params: {
+ projectId: extractProjectResourceName(createdPlan.name),
+ issueId: extractIssueUID(createdIssue.name),
+ },
+ });
+ });
+};
+
// Create sheets for spec configs and update their resource names.
const createSheets = async () => {
const specs = plan.value.specs || [];
- const configWithSheetList: Plan_ChangeDatabaseConfig[] = [];
+ const configWithSheetList: (
+ | Plan_ChangeDatabaseConfig
+ | Plan_ExportDataConfig
+ )[] = [];
const pendingCreateSheetMap = new Map<string, Sheet>();
for (const spec of specs) {
- const config =
- spec.config?.case === "changeDatabaseConfig" ? spec.config.value : null;
+ let config = null;
+ if (spec.config?.case === "changeDatabaseConfig") {
+ config = spec.config.value;
+ } else if (spec.config?.case === "exportDataConfig") {
+ config = spec.config.value;
+ }
+
if (!config) continue;
configWithSheetList.push(config);
if (pendingCreateSheetMap.has(config.sheet)) continue;
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/export/ExportArchiveDownloadAction.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/export/ExportArchiveDownloadAction.vue
new file mode 100644
index 0000000000..8b55233409
--- /dev/null
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/export/ExportArchiveDownloadAction.vue
@@ -0,0 +1,136 @@
+<template>
+ <NTooltip
+ v-if="taskRun?.exportArchiveStatus === TaskRun_ExportArchiveStatus.READY"
+ >
+ <template #trigger>
+ <NButton
+ type="primary"
+ :loading="state.isExporting"
+ @click="downloadExportArchive"
+ >
+ <template #icon>
+ <DownloadIcon class="w-5 h-5" />
+ </template>
+ {{ $t("common.download") }}
+ </NButton>
+ </template>
+ <span class="text-sm">
+ {{ $t("issue.data-export.download-tooltip") }}
+ </span>
+ </NTooltip>
+ <div
+ v-else-if="
+ taskRun?.exportArchiveStatus === TaskRun_ExportArchiveStatus.EXPORTED
+ "
+ class="flex flex-row items-center gap-2 text-sm textlabel !leading-8"
+ >
+ <CircleCheckBigIcon class="w-5 h-auto" />
+ {{ $t("issue.data-export.file-downloaded") }}
+ </div>
+</template>
+
+<script setup lang="ts">
+import { create } from "@bufbuild/protobuf";
+import dayjs from "dayjs";
+import { last } from "lodash-es";
+import { DownloadIcon, CircleCheckBigIcon } from "lucide-vue-next";
+import { NButton, NTooltip } from "naive-ui";
+import { computed, reactive } from "vue";
+import { usePlanContext } from "@/components/Plan/logic";
+import { useSQLStore } from "@/store";
+import { ExportFormat } from "@/types/proto-es/v1/common_pb";
+import type { Plan_ExportDataConfig } from "@/types/proto-es/v1/plan_service_pb";
+import { TaskRun_ExportArchiveStatus } from "@/types/proto-es/v1/rollout_service_pb";
+import { ExportRequestSchema } from "@/types/proto-es/v1/sql_service_pb";
+
+interface LocalState {
+ isExporting: boolean;
+}
+
+const { plan, rollout, taskRuns, events } = usePlanContext();
+const state = reactive<LocalState>({
+ isExporting: false,
+});
+
+const taskRun = computed(() => {
+ if (!rollout.value || !taskRuns.value.length) return undefined;
+
+ // Find export tasks first
+ const exportTasks = rollout.value.stages
+ .flatMap((stage) => stage.tasks)
+ .filter((task) => {
+ // Find tasks that belong to export data specs
+ const exportSpec = plan.value.specs.find(
+ (spec) =>
+ spec.config?.case === "exportDataConfig" && spec.id === task.specId
+ );
+ return !!exportSpec;
+ });
+
+ // Get task runs for export tasks
+ const exportTaskRuns = taskRuns.value.filter((taskRun) =>
+ exportTasks.some((task) => taskRun.name.startsWith(task.name + "/"))
+ );
+
+ return last(exportTaskRuns);
+});
+
+const exportDataConfig = computed((): Plan_ExportDataConfig | undefined => {
+ const spec = plan.value.specs.find(
+ (spec) => spec.config?.case === "exportDataConfig"
+ );
+ return spec?.config?.value as Plan_ExportDataConfig;
+});
+
+const downloadExportArchive = async () => {
+ if (!rollout.value) return;
+
+ state.isExporting = true;
+ try {
+ const content = await useSQLStore().exportData(
+ create(ExportRequestSchema, {
+ name: rollout.value.name,
+ })
+ );
+ const fileType = getExportFileType(exportDataConfig.value);
+ const buffer = content.buffer.slice(
+ content.byteOffset,
+ content.byteOffset + content.byteLength
+ ) as ArrayBuffer;
+ const blob = new Blob([buffer], {
+ type: fileType,
+ });
+ const url = window.URL.createObjectURL(blob);
+
+ const formattedDateString = dayjs(new Date()).format("YYYY-MM-DDTHH-mm-ss");
+ const filename = `export-data-${formattedDateString}`;
+ const link = document.createElement("a");
+ link.download = `${filename}.zip`;
+ link.href = url;
+ link.click();
+ events.emit("status-changed", { eager: true });
+ } finally {
+ state.isExporting = false;
+ }
+};
+
+const getExportFileType = (exportDataConfig?: Plan_ExportDataConfig) => {
+ if (!exportDataConfig) return "application/zip";
+
+ if (exportDataConfig.password) {
+ return "application/zip";
+ }
+ switch (exportDataConfig.format) {
+ case ExportFormat.CSV:
+ return "text/csv";
+ case ExportFormat.JSON:
+ return "application/json";
+ case ExportFormat.SQL:
+ return "application/sql";
+ case ExportFormat.XLSX:
+ return "application/vnd.ms-excel";
+ default:
+ return "application/zip";
+ }
+};
+</script>
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/export/index.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/export/index.ts
new file mode 100644
index 0000000000..6baab9ee63
--- /dev/null
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/export/index.ts
@@ -0,0 +1 @@
+export { default as ExportArchiveDownloadAction } from "./ExportArchiveDownloadAction.vue";
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue
index 2adca2fb3a..4a21979363 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue
@@ -8,6 +8,9 @@
:disabled="disabled"
@click="$emit('perform-action', action)"
>
+ <template v-if="action === 'EXPORT_DOWNLOAD'" #icon>
+ <DownloadIcon class="w-5 h-5" />
+ </template>
{{ actionDisplayName(action) }}
</NButton>
</template>
@@ -18,8 +21,11 @@
</template>
<script setup lang="ts">
+import { DownloadIcon } from "lucide-vue-next";
import { NButton, NTooltip } from "naive-ui";
+import { computed } from "vue";
import { useI18n } from "vue-i18n";
+import { usePlanContext } from "../../../../logic";
import type { UnifiedAction } from "./types";
defineProps<{
@@ -33,6 +39,14 @@ defineEmits<{
}>();
const { t } = useI18n();
+const { plan } = usePlanContext();
+
+// Check if this is a database export plan
+const isExportPlan = computed(() => {
+ return plan.value.specs.some(
+ (spec) => spec.config?.case === "exportDataConfig"
+ );
+});
const actionDisplayName = (action: UnifiedAction): string => {
switch (action) {
@@ -55,9 +69,11 @@ const actionDisplayName = (action: UnifiedAction): string => {
case "PLAN_REOPEN":
return t("common.reopen");
case "ROLLOUT_START":
- return t("common.rollout");
+ return isExportPlan.value ? t("common.export") : t("common.rollout");
case "ROLLOUT_CANCEL":
return t("common.cancel");
+ case "EXPORT_DOWNLOAD":
+ return t("common.download");
}
};
@@ -66,6 +82,7 @@ const actionButtonProps = (action: UnifiedAction) => {
case "ISSUE_REVIEW_APPROVE":
case "ISSUE_CREATE":
case "ROLLOUT_START":
+ case "EXPORT_DOWNLOAD":
return {
type: "primary" as const,
};
@@ -79,6 +96,7 @@ const actionButtonProps = (action: UnifiedAction) => {
case "ISSUE_STATUS_CLOSE":
case "PLAN_CLOSE":
case "PLAN_REOPEN":
+ case "ROLLOUT_CANCEL":
return {
type: "default" as const,
};
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
index d521ba5046..3c7892aa55 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionGroup.vue
@@ -1,8 +1,11 @@
<template>
<div class="flex items-center gap-x-2">
- <!-- Primary action button -->
+ <!-- Export Archive Download Action for export data issues (replaces primary action) -->
+ <ExportArchiveDownloadAction v-if="shouldShowExportDownload" />
+
+ <!-- Primary action button (hidden when export download is shown) -->
<UnifiedActionButton
- v-if="primaryAction"
+ v-else-if="primaryAction && primaryAction.action !== 'EXPORT_DOWNLOAD'"
:action="primaryAction.action"
:disabled="disabled || primaryAction.disabled"
:disabled-tooltip="disabled ? disabledTooltip : primaryAction.description"
@@ -33,12 +36,21 @@
</template>
<script setup lang="ts">
+import { last } from "lodash-es";
import { EllipsisVerticalIcon } from "lucide-vue-next";
import { NButton, NDropdown, type DropdownOption } from "naive-ui";
import { computed, h } from "vue";
import type { VNode } from "vue";
import { useI18n } from "vue-i18n";
import { DropdownItemWithErrorList } from "@/components/IssueV1/components/common";
+import { useCurrentUserV1, extractUserId } from "@/store";
+import { IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
+import {
+ TaskRun_ExportArchiveStatus,
+ Task_Type,
+} from "@/types/proto-es/v1/rollout_service_pb";
+import { usePlanContext } from "../../../../logic";
+import { ExportArchiveDownloadAction } from "../export";
import UnifiedActionButton from "./UnifiedActionButton.vue";
import type { ActionConfig, UnifiedAction } from "./types";
@@ -54,6 +66,74 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
+const { plan, issue, rollout, taskRuns } = usePlanContext();
+const currentUser = useCurrentUserV1();
+
+// Check if this is a database export plan
+const isExportPlan = computed(() => {
+ return plan.value.specs.every(
+ (spec) => spec.config.case === "exportDataConfig"
+ );
+});
+
+// Export download logic
+const hasExportDataTask = computed(() => {
+ return (
+ rollout.value?.stages.some((stage) =>
+ stage.tasks.some((task) => task.type === Task_Type.DATABASE_EXPORT)
+ ) || false
+ );
+});
+
+const taskRun = computed(() => {
+ if (!rollout.value || !taskRuns.value.length) return undefined;
+
+ // Find export tasks first
+ const exportTasks = rollout.value.stages
+ .flatMap((stage) => stage.tasks)
+ .filter((task) => {
+ // Find tasks that belong to export data specs
+ const exportSpec = plan.value.specs.find(
+ (spec) =>
+ spec.config?.case === "exportDataConfig" && spec.id === task.specId
+ );
+ return !!exportSpec;
+ });
+
+ // Get task runs for export tasks
+ const exportTaskRuns = taskRuns.value.filter((taskRun) =>
+ exportTasks.some((task) => taskRun.name.startsWith(task.name + "/"))
+ );
+
+ return last(exportTaskRuns);
+});
+
+const shouldShowExportDownload = computed(() => {
+ // Must have export data tasks
+ if (!hasExportDataTask.value) return false;
+
+ // Must have an issue
+ if (!issue?.value) return false;
+
+ // Issue status must be OPEN or DONE
+ if (![IssueStatus.OPEN, IssueStatus.DONE].includes(issue.value.status)) {
+ return false;
+ }
+
+ // Current user must be the issue creator
+ const currentUserEmail = currentUser.value.email;
+ const issueCreator = extractUserId(issue.value.creator);
+ if (currentUserEmail !== issueCreator) return false;
+
+ // Check if export archive is ready
+ if (
+ taskRun.value?.exportArchiveStatus !== TaskRun_ExportArchiveStatus.READY
+ ) {
+ return false;
+ }
+
+ return true;
+});
const actionDisplayName = (action: UnifiedAction): string => {
switch (action) {
@@ -76,9 +156,11 @@ const actionDisplayName = (action: UnifiedAction): string => {
case "PLAN_REOPEN":
return t("common.reopen");
case "ROLLOUT_START":
- return t("common.rollout");
+ return isExportPlan.value ? t("common.export") : t("common.rollout");
case "ROLLOUT_CANCEL":
return t("common.cancel");
+ case "EXPORT_DOWNLOAD":
+ return t("common.download");
}
};
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts
index eeccd6a968..d8f4ee1673 100644
--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts
+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/types.ts
@@ -17,8 +17,14 @@ export type PlanAction = "PLAN_CLOSE" | "PLAN_REOPEN";
export type RolloutAction = "ROLLOUT_START" | "ROLLOUT_CANCEL";
+export type ExportAction = "EXPORT_DOWNLOAD";
+
// All unified actions
-export type UnifiedAction = IssueAction | PlanAction | RolloutAction;
+export type UnifiedAction =
+ | IssueAction
+ | PlanAction
+ | RolloutAction
+ | ExportAction;
export interface ActionConfig {
action: UnifiedAction;
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue
index 91e2daa503..287b8c6219 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView.vue
@@ -1,16 +1,44 @@
<template>
- <!-- TODO: Add database export specific overview content -->
- <div class="bg-green-50 border border-green-200 rounded-lg p-4">
- <div class="text-lg font-medium text-green-900 mb-2">
- Database Export Overview
- </div>
- <div class="text-sm text-green-700">
- Export Data plan overview - Coming Soon
- </div>
+ <div class="w-full space-y-4">
+ <!-- Tasks Section -->
+ <TasksSection />
+
+ <!-- Export Options Section -->
+ <OptionsSection />
+
+ <!-- SQL Statement Section -->
+ <StatementSection />
</div>
</template>
<script lang="ts" setup>
-// TODO: Add database export specific logic
-// This component will handle the review interface for export data plans
+import { computed, watchEffect } from "vue";
+import { useDatabaseV1Store, useSheetV1Store } from "@/store";
+import type { Plan_ExportDataConfig } from "@/types/proto-es/v1/plan_service_pb";
+import { useSelectedSpec } from "../SpecDetailView/context";
+import StatementSection from "../StatementSection";
+import { TasksSection, OptionsSection } from "./DatabaseExportView";
+
+const databaseStore = useDatabaseV1Store();
+const sheetStore = useSheetV1Store();
+
+const selectedSpec = useSelectedSpec();
+
+const exportDataConfig = computed(() => {
+ return selectedSpec.value.config.value as Plan_ExportDataConfig;
+});
+
+// Fetch target databases
+watchEffect(() => {
+ exportDataConfig.value?.targets?.forEach((target) => {
+ databaseStore.getOrFetchDatabaseByName(target);
+ });
+});
+
+// Fetch sheet for statement display
+watchEffect(() => {
+ if (exportDataConfig.value?.sheet) {
+ sheetStore.getOrFetchSheetByName(exportDataConfig.value.sheet);
+ }
+});
</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/OptionsSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/OptionsSection.vue
new file mode 100644
index 0000000000..978c10ecfe
--- /dev/null
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/OptionsSection.vue
@@ -0,0 +1,227 @@
+<template>
+ <div class="space-y-2">
+ <div class="flex items-center justify-between">
+ <h3 class="text-base">
+ {{ $t("issue.data-export.options") }}
+ </h3>
+ <div
+ v-if="shouldShowEditButton || isEditing"
+ class="flex flex-row justify-end items-center gap-2"
+ >
+ <template v-if="!isEditing">
+ <NButton size="small" @click="handleEdit">
+ {{ $t("common.edit") }}
+ </NButton>
+ </template>
+ <template v-else>
+ <NButton size="small" :disabled="!hasChanges" @click="handleSave">
+ {{ $t("common.save") }}
+ </NButton>
+ <NButton size="small" quaternary @click="handleCancel">
+ {{ $t("common.cancel") }}
+ </NButton>
+ </template>
+ </div>
+ </div>
+
+ <div class="p-3 border rounded space-y-3">
+ <!-- Format Display/Edit -->
+ <div class="flex items-center gap-4">
+ <span class="text-sm">
+ {{ $t("issue.data-export.format") }}
+ </span>
+ <ExportFormatSelector
+ v-model:format="editableConfig.format"
+ :editable="optionsEditable"
+ />
+ </div>
+
+ <!-- Password Protection Display/Edit -->
+ <div class="flex items-center gap-4 min-h-7">
+ <span class="text-sm">
+ {{ $t("export-data.password-optional") }}
+ </span>
+ <ExportPasswordInputer
+ v-model:password="editableConfig.password"
+ :editable="optionsEditable"
+ />
+ </div>
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { create } from "@bufbuild/protobuf";
+import { cloneDeep, includes } from "lodash-es";
+import { NButton } from "naive-ui";
+import { computed, reactive, watchEffect } from "vue";
+import { useI18n } from "vue-i18n";
+import { planServiceClientConnect } from "@/grpcweb";
+import { pushNotification } from "@/store";
+import type { Plan_ExportDataConfig } from "@/types/proto-es/v1/plan_service_pb";
+import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";
+import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
+import { usePlanContext } from "../../../logic";
+import ExportFormatSelector from "../../ExportOption/ExportFormatSelector.vue";
+import ExportPasswordInputer from "../../ExportOption/ExportPasswordInputer.vue";
+
+const { t } = useI18n();
+const { plan, rollout, readonly, isCreating } = usePlanContext();
+
+// Get export config from plan context
+const exportDataConfig = computed(() => {
+ const exportDataSpec = plan.value.specs.find(
+ (spec) => spec.config?.case === "exportDataConfig"
+ );
+ if (exportDataSpec?.config.case === "exportDataConfig") {
+ return exportDataSpec.config.value;
+ }
+ return null;
+});
+
+// Local editing state
+const state = reactive({
+ isEditing: false,
+ editableConfig: {} as Plan_ExportDataConfig,
+});
+
+// Initialize editableConfig when exportDataConfig becomes available
+watchEffect(() => {
+ if (
+ exportDataConfig.value &&
+ Object.keys(state.editableConfig).length === 0
+ ) {
+ state.editableConfig = { ...exportDataConfig.value };
+ }
+});
+
+const isEditing = computed(() => state.isEditing);
+
+// Check if we should show edit button (similar to statement section logic)
+const shouldShowEditButton = computed(() => {
+ // Not allowed to edit if readonly
+ if (readonly.value) {
+ return false;
+ }
+ // Need not to show "Edit" while the plan is still pending create
+ if (isCreating.value) {
+ return false;
+ }
+ // Will show another button group as [Save][Cancel] while editing
+ if (state.isEditing) {
+ return false;
+ }
+
+ // Check if any export tasks are running or completed
+ if (plan.value.rollout && rollout?.value) {
+ const exportDataSpec = plan.value.specs.find(
+ (spec) => spec.config?.case === "exportDataConfig"
+ );
+
+ if (exportDataSpec) {
+ const tasks = rollout.value.stages
+ .flatMap((stage) => stage.tasks)
+ .filter((task) => task.specId === exportDataSpec.id);
+
+ if (
+ tasks.some((task) =>
+ includes(
+ [
+ Task_Status.RUNNING,
+ Task_Status.PENDING,
+ Task_Status.DONE,
+ Task_Status.SKIPPED,
+ ],
+ task.status
+ )
+ )
+ ) {
+ return false;
+ }
+ }
+ }
+ return true;
+});
+
+const optionsEditable = computed(() => {
+ return isCreating.value || state.isEditing;
+});
+
+const editableConfig = computed(() => state.editableConfig);
+
+// Check if the editable config has changes compared to the original
+const hasChanges = computed(() => {
+ if (!state.isEditing || !exportDataConfig.value) {
+ return false;
+ }
+
+ // Compare the current editable config with the original config
+ return (
+ state.editableConfig.format !== exportDataConfig.value.format ||
+ state.editableConfig.password !== exportDataConfig.value.password
+ );
+});
+
+// Event handlers
+const handleEdit = () => {
+ if (!exportDataConfig.value) return;
+
+ state.isEditing = true;
+ state.editableConfig = { ...exportDataConfig.value };
+};
+
+const handleSave = async () => {
+ try {
+ const exportDataSpec = plan.value.specs.find(
+ (spec) => spec.config?.case === "exportDataConfig"
+ );
+
+ if (!exportDataSpec) {
+ throw new Error("Cannot find export data spec to update");
+ }
+
+ const planPatch = cloneDeep(plan.value);
+ const specToPatch = planPatch.specs.find(
+ (spec) => spec.id === exportDataSpec.id
+ );
+
+ if (!specToPatch || specToPatch.config.case !== "exportDataConfig") {
+ throw new Error("Cannot find export data spec to update");
+ }
+
+ // Update the export config
+ specToPatch.config.value = { ...state.editableConfig };
+
+ const request = create(UpdatePlanRequestSchema, {
+ plan: planPatch,
+ updateMask: { paths: ["specs"] },
+ });
+
+ const response = await planServiceClientConnect.updatePlan(request);
+ Object.assign(plan.value, response);
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("common.error"),
+ description: `Failed to update export options: ${error}`,
+ });
+ return; // Don't exit editing mode if save failed
+ }
+
+ state.isEditing = false;
+};
+
+const handleCancel = () => {
+ state.isEditing = false;
+ if (exportDataConfig.value) {
+ state.editableConfig = { ...exportDataConfig.value };
+ }
+};
+</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue
new file mode 100644
index 0000000000..dca78b57e6
--- /dev/null
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/TasksSection.vue
@@ -0,0 +1,169 @@
+<template>
+ <div class="space-y-2">
+ <!-- Tasks Display -->
+ <div class="space-y-3">
+ <!-- Task status summary with title -->
+ <div
+ v-if="exportTasks.length > 0"
+ class="flex items-center justify-between"
+ >
+ <div class="flex items-center gap-2">
+ <h3 class="text-base font-medium">
+ {{ $t("common.task", exportTasks.length) }}
+ </h3>
+ </div>
+ </div>
+
+ <!-- Flattened task list -->
+ <div v-if="exportTasks.length > 0" class="flex flex-wrap gap-2">
+ <div
+ v-for="task in exportTasks"
+ :key="task.name"
+ class="inline-flex items-center gap-2 px-2 py-1.5 border rounded transition-colors min-w-0 cursor-pointer"
+ :class="{
+ 'bg-blue-50 border-blue-300': selectedTask?.name === task.name,
+ 'hover:bg-gray-50': selectedTask?.name !== task.name,
+ }"
+ @click="handleTaskClick(task)"
+ >
+ <!-- Task Status -->
+ <div class="flex-shrink-0">
+ <TaskStatus :status="task.status" size="tiny" />
+ </div>
+
+ <!-- Database Display -->
+ <div class="flex-1 min-w-0">
+ <DatabaseDisplay
+ :database="task.target"
+ :show-environment="true"
+ size="medium"
+ />
+ </div>
+ </div>
+ </div>
+
+ <!-- Task Runs for Selected Task -->
+ <div
+ v-if="selectedTask && selectedTaskRuns.length > 0"
+ class="mt-4 space-y-2"
+ >
+ <div class="text-sm font-medium text-control">
+ {{ $t("task-run.history") }}
+ </div>
+ <TaskRunTable :task="selectedTask" :task-runs="selectedTaskRuns" />
+ </div>
+
+ <!-- No tasks message -->
+ <div
+ v-else-if="exportTasks.length === 0"
+ class="text-center text-control-light py-8"
+ >
+ {{ $t("common.no-data") }}
+ </div>
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { computed, ref, watchEffect } from "vue";
+import TaskRunTable from "@/components/Plan/components/RolloutView/TaskRunTable.vue";
+import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
+import TaskStatus from "@/components/Rollout/kits/TaskStatus.vue";
+import {
+ Task_Status,
+ type Task,
+ type TaskRun,
+} from "@/types/proto-es/v1/rollout_service_pb";
+import { extractTaskUID } from "@/utils";
+import { usePlanContext } from "../../../logic";
+import { usePlanContextWithRollout } from "../../../logic";
+
+const { plan, rollout } = usePlanContext();
+const { taskRuns } = usePlanContextWithRollout();
+
+// Track selected task for showing task runs
+const selectedTask = ref<Task | null>(null);
+
+// Get task runs for the selected task
+const selectedTaskRuns = computed((): TaskRun[] => {
+ if (!selectedTask.value) return [];
+
+ const taskUID = extractTaskUID(selectedTask.value.name);
+ return taskRuns.value.filter(
+ (taskRun) => extractTaskUID(taskRun.name) === taskUID
+ );
+});
+
+// Get the export data spec
+const exportDataSpec = computed(() => {
+ return plan.value.specs.find(
+ (spec) => spec.config?.case === "exportDataConfig"
+ );
+});
+
+// Find export tasks related to this spec
+const exportTasks = computed(() => {
+ if (!rollout.value || !exportDataSpec.value) return [];
+
+ const tasks = [];
+ for (const stage of rollout.value.stages) {
+ for (const task of stage.tasks) {
+ if (task.specId === exportDataSpec.value.id) {
+ tasks.push(task);
+ }
+ }
+ }
+ return tasks;
+});
+
+// Auto-select the most relevant task
+const autoSelectTask = () => {
+ if (exportTasks.value.length === 0) {
+ selectedTask.value = null;
+ return;
+ }
+
+ // Priority order: Failed > Not started (Pending) > First task
+ const failedTasks = exportTasks.value.filter(
+ (task) => task.status === Task_Status.FAILED
+ );
+ const pendingTasks = exportTasks.value.filter(
+ (task) =>
+ task.status === Task_Status.PENDING ||
+ task.status === Task_Status.NOT_STARTED ||
+ task.status === Task_Status.RUNNING
+ );
+
+ let taskToSelect: Task | null = null;
+
+ if (failedTasks.length > 0) {
+ // Select first failed task
+ taskToSelect = failedTasks[0];
+ } else if (pendingTasks.length > 0) {
+ // Select first not started (pending) task
+ taskToSelect = pendingTasks[0];
+ } else {
+ // Fallback to first task
+ taskToSelect = exportTasks.value[0];
+ }
+
+ selectedTask.value = taskToSelect;
+};
+
+// Handle task selection
+const handleTaskClick = (task: Task) => {
+ if (selectedTask.value?.name === task.name) {
+ selectedTask.value = null; // Deselect if clicking the same task
+ } else {
+ selectedTask.value = task; // Select the new task
+ }
+};
+
+// Auto-select task when tasks change
+watchEffect(() => {
+ // Only auto-select if no task is currently selected
+ if (!selectedTask.value && exportTasks.value.length > 0) {
+ autoSelectTask();
+ }
+});
+</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/index.ts b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/index.ts
new file mode 100644
index 0000000000..dc879e1e00
--- /dev/null
+++ b/frontend/src/components/Plan/components/IssueReviewView/DatabaseExportView/index.ts
@@ -0,0 +1,2 @@
+export { default as TasksSection } from "./TasksSection.vue";
+export { default as OptionsSection } from "./OptionsSection.vue";
diff --git a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
index 4f1ffaa092..88b590690b 100644
--- a/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/Plan/components/RolloutView/TaskRolloutActionPanel.vue
@@ -33,92 +33,96 @@
<PlanCheckStatusCount :plan="plan" />
</div>
- <!-- Stage/Task information - hidden for database creation tasks -->
- <template v-if="shouldShowStageTaskInfo">
- <div
- class="flex flex-row gap-x-2 shrink-0 overflow-y-hidden justify-start items-center"
- >
- <label class="font-medium text-control">
- {{ $t("common.stage") }}
+ <!-- Stage information -->
+ <div
+ v-if="shouldShowStageInfo"
+ class="flex flex-row gap-x-2 shrink-0 overflow-y-hidden justify-start items-center"
+ >
+ <label class="font-medium text-control">
+ {{ $t("common.stage") }}
+ </label>
+ <EnvironmentV1Name
+ :environment="
+ environmentStore.getEnvironmentByName(targetStage.environment)
+ "
+ :link="false"
+ />
+ </div>
+
+ <!-- Task information -->
+ <div
+ v-if="shouldShowTaskInfo"
+ class="flex flex-col gap-y-1 shrink overflow-y-hidden justify-start"
+ >
+ <div class="flex items-center justify-between">
+ <label class="text-control">
+ <span class="font-medium">{{
+ $t("common.task", eligibleTasks.length)
+ }}</span>
+ <span
+ class="opacity-80"
+ v-if="eligibleTasks.length > 1 && shouldShowStageInfo"
+ >
+ ({{
+ eligibleTasks.length === target.stage.tasks.length
+ ? eligibleTasks.length
+ : `${eligibleTasks.length} / ${target.stage.tasks.length}`
+ }})
+ </span>
</label>
- <EnvironmentV1Name
- :environment="
- environmentStore.getEnvironmentByName(targetStage.environment)
- "
- :link="false"
- />
</div>
-
- <div
- class="flex flex-col gap-y-1 shrink overflow-y-hidden justify-start"
- >
- <div class="flex items-center justify-between">
- <label class="text-control">
- <span class="font-medium">{{
- $t("common.task", eligibleTasks.length)
- }}</span>
- <span class="opacity-80" v-if="eligibleTasks.length > 1">
- ({{
- eligibleTasks.length === target.stage.tasks.length
- ? eligibleTasks.length
- : `${eligibleTasks.length} / ${target.stage.tasks.length}`
- }})
- </span>
- </label>
- </div>
- <div class="flex-1 overflow-y-auto">
- <template v-if="useVirtualScroll">
- <NVirtualList
- :items="eligibleTasks"
- :item-size="itemHeight"
- class="max-h-64"
- item-resizable
- >
- <template #default="{ item: task }">
- <div
- :key="task.name"
- class="flex items-center text-sm"
- :style="{ height: `${itemHeight}px` }"
+ <div class="flex-1 overflow-y-auto">
+ <template v-if="useVirtualScroll">
+ <NVirtualList
+ :items="eligibleTasks"
+ :item-size="itemHeight"
+ class="max-h-64"
+ item-resizable
+ >
+ <template #default="{ item: task }">
+ <div
+ :key="task.name"
+ class="flex items-center text-sm"
+ :style="{ height: `${itemHeight}px` }"
+ >
+ <NTag
+ v-if="semanticTaskType(task.type)"
+ class="mr-2"
+ size="small"
>
- <NTag
- v-if="semanticTaskType(task.type)"
- class="mr-2"
- size="small"
- >
- <span class="inline-block text-center">
- {{ semanticTaskType(task.type) }}
- </span>
- </NTag>
- <TaskDatabaseName :task="task" />
- </div>
- </template>
- </NVirtualList>
- </template>
- <template v-else>
- <NScrollbar class="max-h-64">
- <ul class="text-sm space-y-2">
- <li
- v-for="task in eligibleTasks"
- :key="task.name"
- class="flex items-center"
+ <span class="inline-block text-center">
+ {{ semanticTaskType(task.type) }}
+ </span>
+ </NTag>
+ <TaskDatabaseName :task="task" />
+ </div>
+ </template>
+ </NVirtualList>
+ </template>
+ <template v-else>
+ <NScrollbar class="max-h-64">
+ <ul class="text-sm space-y-2">
+ <li
+ v-for="task in eligibleTasks"
+ :key="task.name"
+ class="flex items-center"
+ >
+ <NTag
+ v-if="semanticTaskType(task.type)"
+ class="mr-2"
+ size="small"
>
- <NTag
- v-if="semanticTaskType(task.type)"
- class="mr-2"
- size="small"
- >
- <span class="inline-block text-center">
- {{ semanticTaskType(task.type) }}
- </span>
- </NTag>
- <TaskDatabaseName :task="task" />
- </li>
- </ul>
- </NScrollbar>
- </template>
- </div>
+ <span class="inline-block text-center">
+ {{ semanticTaskType(task.type) }}
+ </span>
+ </NTag>
+ <TaskDatabaseName :task="task" />
+ </li>
+ </ul>
+ </NScrollbar>
+ </template>
</div>
- </template>
+ </div>
<div v-if="showScheduledTimePicker" class="flex flex-col">
<h3 class="font-medium text-control mb-1">
@@ -235,7 +239,7 @@
import { create } from "@bufbuild/protobuf";
import { TimestampSchema } from "@bufbuild/protobuf/wkt";
import dayjs from "dayjs";
-import { head } from "lodash-es";
+import { flatten, head } from "lodash-es";
import {
NAlert,
NButton,
@@ -409,13 +413,13 @@ const validationMessages = computed(() => {
const messages: string[] = [];
// Basic validation errors
- if (runnableTasks.value.length === 0) {
+ if (eligibleTasks.value.length === 0) {
messages.push(t("common.no-data"));
}
if (
!canPerformTaskAction(
- runnableTasks.value,
+ eligibleTasks.value,
rollout.value,
project.value,
issue?.value
@@ -463,7 +467,7 @@ const validationMessages = computed(() => {
if (
props.action === "CANCEL" &&
- runnableTasks.value.some(
+ eligibleTasks.value.some(
(task) =>
task.status !== Task_Status.PENDING &&
task.status !== Task_Status.RUNNING
@@ -537,6 +541,34 @@ const title = computed(() => {
// Get eligible tasks based on action type and target
const eligibleTasks = computed(() => {
+ // For database create/export tasks, get all relevant tasks from all stages
+ if (isDatabaseCreationOrExportTask.value) {
+ const allTasks = flatten(rollout.value.stages.map((stage) => stage.tasks));
+ // Apply action-based filtering
+ if (props.action === "RUN") {
+ return allTasks.filter(
+ (task) =>
+ task.status === Task_Status.NOT_STARTED ||
+ task.status === Task_Status.CANCELED ||
+ task.status === Task_Status.FAILED
+ );
+ } else if (props.action === "SKIP") {
+ return allTasks.filter(
+ (task) =>
+ task.status === Task_Status.NOT_STARTED ||
+ task.status === Task_Status.FAILED ||
+ task.status === Task_Status.CANCELED
+ );
+ } else if (props.action === "CANCEL") {
+ return allTasks.filter(
+ (task) =>
+ task.status === Task_Status.PENDING ||
+ task.status === Task_Status.RUNNING
+ );
+ }
+ return allTasks;
+ }
+
// If specific tasks are provided, use them
if (
props.target.type === "tasks" &&
@@ -574,11 +606,6 @@ const eligibleTasks = computed(() => {
return [];
});
-// Get the tasks that will actually be run
-const runnableTasks = computed(() => {
- return eligibleTasks.value;
-});
-
// Virtual scroll configuration
const useVirtualScroll = computed(() => eligibleTasks.value.length > 50);
const itemHeight = computed(() => 32); // Height of each task item in pixels
@@ -589,12 +616,26 @@ const showScheduledTimePicker = computed(() => {
// Check if any of the eligible tasks are database creation tasks
const isDatabaseCreationTask = computed(() => {
- return eligibleTasks.value.every(
- (task) => task.type === Task_Type.DATABASE_CREATE
- );
+ const allTasks = flatten(rollout.value.stages.map((stage) => stage.tasks));
+ return allTasks.every((task) => task.type === Task_Type.DATABASE_CREATE);
});
-const shouldShowStageTaskInfo = computed(() => !isDatabaseCreationTask.value);
+// Check if any of the eligible tasks are database export tasks
+const isDatabaseExportTask = computed(() => {
+ const allTasks = flatten(rollout.value.stages.map((stage) => stage.tasks));
+ return allTasks.every((task) => task.type === Task_Type.DATABASE_EXPORT);
+});
+
+// Check if any of the eligible tasks are database creation or export tasks
+const isDatabaseCreationOrExportTask = computed(() => {
+ return isDatabaseCreationTask.value || isDatabaseExportTask.value;
+});
+
+const shouldShowStageInfo = computed(
+ () => !isDatabaseCreationOrExportTask.value
+);
+
+const shouldShowTaskInfo = computed(() => !isDatabaseCreationTask.value);
// Handle execution mode change (immediate vs scheduled)
const handleExecutionModeChange = (value: string) => {
@@ -605,39 +646,97 @@ const handleExecutionModeChange = (value: string) => {
}
};
+// Helper function to group tasks by their stage (environment) for export tasks
+const groupTasksByStage = (tasks: Task[]) => {
+ const tasksByStage = new Map<string, Task[]>();
+ for (const task of tasks) {
+ // Extract stage from task name: projects/{project}/rollouts/{rollout}/stages/{stage}/tasks/{task}
+ const pathParts = task.name.split("/");
+ const stageIndex = pathParts.findIndex((part) => part === "stages");
+ if (stageIndex !== -1 && stageIndex + 1 < pathParts.length) {
+ const stageId = pathParts[stageIndex + 1];
+ if (!tasksByStage.has(stageId)) {
+ tasksByStage.set(stageId, []);
+ }
+ tasksByStage.get(stageId)!.push(task);
+ }
+ }
+ return tasksByStage;
+};
+
+// Helper function to add run time to a request if specified
+const addRunTimeToRequest = (request: any) => {
+ if (runTimeInMS.value !== undefined) {
+ // Convert timestamp to protobuf Timestamp format
+ const runTimeSeconds = Math.floor(runTimeInMS.value / 1000);
+ const runTimeNanos = (runTimeInMS.value % 1000) * 1000000;
+ request.runTime = create(TimestampSchema, {
+ seconds: BigInt(runTimeSeconds),
+ nanos: runTimeNanos,
+ });
+ }
+};
+
const handleConfirm = async () => {
state.loading = true;
+
+ const parent = isDatabaseCreationOrExportTask.value
+ ? rollout.value.name
+ : targetStage.value.name;
try {
if (props.action === "RUN") {
- // Prepare the request parameters
- const request = create(BatchRunTasksRequestSchema, {
- parent: targetStage.value.name,
- tasks: runnableTasks.value.map((task) => task.name),
- reason: comment.value,
- });
-
- if (runTimeInMS.value !== undefined) {
- // Convert timestamp to protobuf Timestamp format
- const runTimeSeconds = Math.floor(runTimeInMS.value / 1000);
- const runTimeNanos = (runTimeInMS.value % 1000) * 1000000;
- request.runTime = create(TimestampSchema, {
- seconds: BigInt(runTimeSeconds),
- nanos: runTimeNanos,
+ // For export tasks, group by stage/environment and make separate batch calls
+ if (isDatabaseExportTask.value) {
+ const tasksByStage = groupTasksByStage(eligibleTasks.value);
+
+ // Make batch run calls for each stage/environment
+ for (const [_stageId, stageTasks] of tasksByStage) {
+ const request = create(BatchRunTasksRequestSchema, {
+ parent,
+ tasks: stageTasks.map((task) => task.name),
+ reason: comment.value,
+ });
+ addRunTimeToRequest(request);
+ await rolloutServiceClientConnect.batchRunTasks(request);
+ }
+ } else {
+ // For non-export tasks, use the original logic
+ const request = create(BatchRunTasksRequestSchema, {
+ parent,
+ tasks: eligibleTasks.value.map((task) => task.name),
+ reason: comment.value,
});
+ addRunTimeToRequest(request);
+ await rolloutServiceClientConnect.batchRunTasks(request);
}
- await rolloutServiceClientConnect.batchRunTasks(request);
} else if (props.action === "SKIP") {
- const request = create(BatchSkipTasksRequestSchema, {
- parent: targetStage.value.name,
- tasks: runnableTasks.value.map((task) => task.name),
- reason: comment.value,
- });
- await rolloutServiceClientConnect.batchSkipTasks(request);
+ // For export tasks, group by stage/environment and make separate batch calls
+ if (isDatabaseExportTask.value) {
+ const tasksByStage = groupTasksByStage(eligibleTasks.value);
+
+ // Make batch skip calls for each stage/environment
+ for (const [_stageId, stageTasks] of tasksByStage) {
+ const request = create(BatchSkipTasksRequestSchema, {
+ parent,
+ tasks: stageTasks.map((task) => task.name),
+ reason: comment.value,
+ });
+ await rolloutServiceClientConnect.batchSkipTasks(request);
+ }
+ } else {
+ // For non-export tasks, use the original logic
+ const request = create(BatchSkipTasksRequestSchema, {
+ parent,
+ tasks: eligibleTasks.value.map((task) => task.name),
+ reason: comment.value,
+ });
+ await rolloutServiceClientConnect.batchSkipTasks(request);
+ }
} else if (props.action === "CANCEL") {
// Fetch task runs for the tasks to be canceled.
const taskRuns = (
await Promise.all(
- runnableTasks.value.map(async (task) => {
+ eligibleTasks.value.map(async (task) => {
const request = create(ListTaskRunsRequestSchema, {
parent: task.name,
pageSize: 10,
@@ -653,12 +752,46 @@ const handleConfirm = async () => {
taskRun.status === TaskRun_Status.PENDING ||
taskRun.status === TaskRun_Status.RUNNING
);
- const request = create(BatchCancelTaskRunsRequestSchema, {
- parent: `${targetStage.value.name}/tasks/-`,
- taskRuns: cancelableTaskRuns.map((taskRun) => taskRun.name),
- reason: comment.value,
- });
- await rolloutServiceClientConnect.batchCancelTaskRuns(request);
+
+ if (isDatabaseCreationOrExportTask.value) {
+ // For database creation/export tasks, group task runs by stage and cancel them per stage
+ const taskRunsByStage = new Map<string, typeof cancelableTaskRuns>();
+
+ for (const taskRun of cancelableTaskRuns) {
+ // Extract stage name from task run path: projects/.../rollouts/.../stages/{stage}/tasks/.../taskRuns/...
+ const pathParts = taskRun.name.split("/");
+ const stageIndex = pathParts.findIndex((part) => part === "stages");
+ if (stageIndex >= 0 && stageIndex + 1 < pathParts.length) {
+ const stageName = pathParts.slice(0, stageIndex + 2).join("/"); // projects/.../rollouts/.../stages/{stage}
+ if (!taskRunsByStage.has(stageName)) {
+ taskRunsByStage.set(stageName, []);
+ }
+ taskRunsByStage.get(stageName)!.push(taskRun);
+ }
+ }
+
+ // Cancel task runs for each stage separately
+ await Promise.all(
+ Array.from(taskRunsByStage.entries()).map(
+ ([stageName, stageTaskRuns]) => {
+ const request = create(BatchCancelTaskRunsRequestSchema, {
+ parent: `${stageName}/tasks/-`,
+ taskRuns: stageTaskRuns.map((taskRun) => taskRun.name),
+ reason: comment.value,
+ });
+ return rolloutServiceClientConnect.batchCancelTaskRuns(request);
+ }
+ )
+ );
+ } else {
+ // For regular stage-level tasks
+ const request = create(BatchCancelTaskRunsRequestSchema, {
+ parent: `${targetStage.value.name}/tasks/-`,
+ taskRuns: cancelableTaskRuns.map((taskRun) => taskRun.name),
+ reason: comment.value,
+ });
+ await rolloutServiceClientConnect.batchCancelTaskRuns(request);
+ }
}
emit("confirm");
diff --git a/frontend/src/components/Plan/components/SpecDetailView/DataExportOptionsSection.vue b/frontend/src/components/Plan/components/SpecDetailView/DataExportOptionsSection.vue
new file mode 100644
index 0000000000..b8a812f2ba
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecDetailView/DataExportOptionsSection.vue
@@ -0,0 +1,71 @@
+<template>
+ <div class="w-full py-3">
+ <div class="flex items-center justify-between mb-3">
+ <span class="text-base">{{ $t("issue.data-export.options") }}</span>
+ </div>
+
+ <div class="space-y-3">
+ <!-- Export Format -->
+ <div class="flex items-center gap-4">
+ <span class="text-sm min-w-[100px]">{{
+ $t("export-data.export-format")
+ }}</span>
+ <ExportFormatSelector
+ v-model:format="exportFormat"
+ :editable="isCreating"
+ />
+ </div>
+
+ <!-- Password Protection -->
+ <div class="flex items-center gap-4 min-h-7">
+ <span class="text-sm min-w-[100px]">{{
+ $t("export-data.password-optional")
+ }}</span>
+ <ExportPasswordInputer
+ v-model:password="exportPassword"
+ :editable="isCreating"
+ />
+ </div>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import { ExportFormat } from "@/types/proto-es/v1/common_pb";
+import { usePlanContext } from "../../logic/context";
+import ExportFormatSelector from "../ExportOption/ExportFormatSelector.vue";
+import ExportPasswordInputer from "../ExportOption/ExportPasswordInputer.vue";
+import { useSelectedSpec } from "./context";
+
+const { isCreating } = usePlanContext();
+const selectedSpec = useSelectedSpec();
+
+const exportFormat = computed({
+ get() {
+ if (selectedSpec.value.config.case === "exportDataConfig") {
+ return selectedSpec.value.config.value.format || ExportFormat.JSON;
+ }
+ return ExportFormat.JSON;
+ },
+ set(value) {
+ if (selectedSpec.value.config.case === "exportDataConfig") {
+ selectedSpec.value.config.value.format = value;
+ }
+ },
+});
+
+const exportPassword = computed({
+ get() {
+ if (selectedSpec.value.config.case === "exportDataConfig") {
+ return selectedSpec.value.config.value.password || "";
+ }
+ return "";
+ },
+ set(value) {
+ if (selectedSpec.value.config.case === "exportDataConfig") {
+ selectedSpec.value.config.value.password = value || undefined;
+ }
+ },
+});
+</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
index b2e54d6bb3..4de4b6a09d 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecDetailView.vue
@@ -5,6 +5,7 @@
class="w-full flex-1 flex flex-col gap-3 px-4 divide-y overflow-x-auto"
>
<TargetListSection />
+ <DataExportOptionsSection v-if="isDataExportPlan" />
<FailedTaskRunsSection v-if="!isCreating && rollout" />
<template v-if="!specHasRelease">
<SQLCheckV1Section v-if="isCreating" />
@@ -29,6 +30,7 @@ import PlanCheckSection from "../PlanCheckSection";
import { providePlanSQLCheckContext } from "../SQLCheckSection";
import SQLCheckV1Section from "../SQLCheckV1Section";
import StatementSection from "../StatementSection";
+import DataExportOptionsSection from "./DataExportOptionsSection.vue";
import FailedTaskRunsSection from "./FailedTaskRunsSection.vue";
import SpecListSection from "./SpecListSection.vue";
import TargetListSection from "./TargetListSection.vue";
@@ -52,9 +54,18 @@ const specHasRelease = computed(() => {
);
});
+const isDataExportPlan = computed(() => {
+ return plan.value.specs.every(
+ (spec) => spec.config.case === "exportDataConfig"
+ );
+});
+
const shouldShowSpecList = computed(() => {
return (
- isCreating.value || plan.value.specs.length > 1 || plan.value.rollout === ""
+ (isCreating.value ||
+ plan.value.specs.length > 1 ||
+ plan.value.rollout === "") &&
+ !isDataExportPlan.value
);
});
</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/context.ts b/frontend/src/components/Plan/components/SpecDetailView/context.ts
index a4a809e862..7d2bd195f2 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/context.ts
+++ b/frontend/src/components/Plan/components/SpecDetailView/context.ts
@@ -11,10 +11,22 @@ export const useSelectedSpec = () => {
if (plan.value.specs.length === 0) {
throw new Error("No specs found in the plan.");
}
+
const specId = route.params.specId as string | undefined;
+
+ // If no specId in route, check if this is a database export plan
if (!specId) {
+ const isExportPlan = plan.value.specs.every(
+ (spec) => spec.config.case === "exportDataConfig"
+ );
+ if (isExportPlan) {
+ // For export plans, return the first (and typically only) spec
+ return plan.value.specs[0];
+ }
+
throw new Error("Spec ID is required in the route parameters.");
}
+
const foundSpec =
plan.value.specs.find((spec) => spec.id === specId) ||
head(plan.value.specs);
diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
index c07206975d..26b5880ac5 100644
--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue
@@ -96,7 +96,7 @@
<div class="relative flex-1">
<MonacoEditor
ref="monacoEditorRef"
- class="w-full h-full min-h-[200px] border rounded-[3px]"
+ class="w-full h-full min-h-[200px] border rounded overflow-hidden"
:filename="filename"
:content="state.statement"
:language="language"
@@ -426,7 +426,10 @@ const updateStatement = async (statement: string) => {
)}`
);
}
- if (specToPatch.config.case !== "changeDatabaseConfig") {
+ if (
+ specToPatch.config.case !== "changeDatabaseConfig" &&
+ specToPatch.config.case !== "exportDataConfig"
+ ) {
throw new Error(
`Unsupported spec type for plan update ${JSON.stringify(specToPatch)}`
);
diff --git a/frontend/src/components/Plan/logic/initialize/create.ts b/frontend/src/components/Plan/logic/initialize/create.ts
index 2dc32e2c34..63ff1bb226 100644
--- a/frontend/src/components/Plan/logic/initialize/create.ts
+++ b/frontend/src/components/Plan/logic/initialize/create.ts
@@ -9,6 +9,7 @@ import {
} from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import type { IssueType } from "@/types";
+import { ExportFormat } from "@/types/proto-es/v1/common_pb";
import type { Plan_Spec } from "@/types/proto-es/v1/plan_service_pb";
import {
PlanSchema,
@@ -177,6 +178,7 @@ const buildSpecForTargetsV1 = async (
value: createProto(Plan_ExportDataConfigSchema, {
targets,
sheet,
+ format: ExportFormat.JSON, // default to JSON
}),
};
break;
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
index 8c1f38d459..90154a3c20 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
@@ -127,7 +127,10 @@ import LabelEditorDrawer from "@/components/LabelEditorDrawer.vue";
import { TransferDatabaseForm } from "@/components/TransferDatabaseForm";
import TransferOutDatabaseForm from "@/components/TransferOutDatabaseForm";
import { Drawer } from "@/components/v2";
-import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
+import {
+ PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ PROJECT_V1_ROUTE_PLAN_DETAIL,
+} from "@/router/dashboard/projectV1";
import {
pushNotification,
useDatabaseV1Store,
@@ -351,11 +354,15 @@ const generateMultiDb = async (
),
databaseList: props.databases.map((db) => db.name).join(","),
};
+ // Use CI/CD UI for data export issues, legacy UI for others
+ const isDataExport = type === "bb.issue.database.data.export";
router.push({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ name: isDataExport
+ ? PROJECT_V1_ROUTE_PLAN_DETAIL
+ : PROJECT_V1_ROUTE_ISSUE_DETAIL,
params: {
projectId: extractProjectResourceName(selectedProjectName.value),
- issueSlug: "create",
+ [isDataExport ? "planId" : "issueSlug"]: "create",
},
query,
});
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 34e06fa541..06d34bbabb 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -621,8 +621,7 @@
"self": "Maximum SQL result rows",
"rows": "Rows",
"description": "Limit the output rows in SQL query result.",
- "limit": "No limit when the value <= 0",
- "limit-warning": "Maximum export {count} rows due to the query restriction"
+ "limit": "No limit when the value <= 0"
}
},
"query-data-policy": {
@@ -1033,7 +1032,6 @@
"data-export": {
"options": "Options",
"format": "Format",
- "encrypt": "Encrypt",
"file-downloaded": "File Downloaded",
"download-tooltip": "Available for 24 hours"
},
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 8b24fa003f..494e47be36 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -621,8 +621,7 @@
"self": "Máximo de filas de resultados de SQL",
"rows": "Filas",
"description": "Limite las filas de salida en el resultado de la consulta SQL, el valor <= 0 significa que no hay límite.",
- "limit": "No hay límite cuando el valor <= 0",
- "limit-warning": "Exportación máxima de {count} filas debido a la restricción de la consulta"
+ "limit": "No hay límite cuando el valor <= 0"
}
},
"query-data-policy": {
@@ -1033,7 +1032,6 @@
"data-export": {
"options": "Opciones de exportación",
"format": "Formato",
- "encrypt": "Cifrar",
"file-downloaded": "Archivo Descargado",
"download-tooltip": "Disponible por 24 horas"
},
@@ -2925,4 +2923,4 @@
"last-visit": "Última visita",
"changelog-for-version": "Registro de cambios para {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index c287e2f47a..7c02775cad 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -621,8 +621,7 @@
"self": "最大SQL結果行数",
"rows": "行",
"description": "SQL クエリ結果の出力行を制限します。値 <= 0 は制限がないことを意味します。",
- "limit": "値が0以下の場合、制限なし",
- "limit-warning": "クエリ制限により、最大エクスポート行数は {count} 行です"
+ "limit": "値が0以下の場合、制限なし"
}
},
"query-data-policy": {
@@ -1033,7 +1032,6 @@
"data-export": {
"options": "設定項目",
"format": "エクスポート形式",
- "encrypt": "暗号化",
"file-downloaded": "ダウンロードされたファイル",
"download-tooltip": "24 時間利用可能"
},
@@ -2925,4 +2923,4 @@
"last-visit": "最終訪問",
"changelog-for-version": "{version} の変更履歴"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 58d5bafac5..badd240708 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -621,8 +621,7 @@
"self": "Số lượng hàng kết quả SQL tối đa",
"rows": "Hàng",
"description": "Giới hạn số hàng đầu ra trong kết quả truy vấn SQL, giá trị <= 0 nghĩa là không giới hạn.",
- "limit": "Không giới hạn khi giá trị <= 0",
- "limit-warning": "Xuất tối đa {count} hàng do hạn chế truy vấn"
+ "limit": "Không giới hạn khi giá trị <= 0"
}
},
"query-data-policy": {
@@ -1033,7 +1032,6 @@
"data-export": {
"options": "Tùy chọn",
"format": "Định dạng",
- "encrypt": "Mã hóa",
"file-downloaded": "Tệp đã tải xuống",
"download-tooltip": "Có sẵn trong 24 giờ"
},
@@ -2925,4 +2923,4 @@
"last-visit": "Lần truy cập cuối",
"changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 31af68c507..ea2f7d7ae9 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -621,8 +621,7 @@
"self": "SQL结果行数上限",
"rows": "行",
"description": "限制SQL查询结果的输出行数,值 <=0 表示不限制。",
- "limit": "当值 <= 0 时无限制",
- "limit-warning": "由于查询限制,最多可导出 {count} 行"
+ "limit": "当值 <= 0 时无限制"
}
},
"query-data-policy": {
@@ -1033,7 +1032,6 @@
"data-export": {
"options": "配置项",
"format": "导出格式",
- "encrypt": "加密",
"file-downloaded": "文件已下载",
"download-tooltip": "24 小时可用"
},
@@ -2925,4 +2923,4 @@
"last-visit": "上次访问",
"changelog-for-version": "{version} 的更新日志"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/views/project/CICDLayout.vue b/frontend/src/views/project/CICDLayout.vue
index 132402def8..c8437fcbb8 100644
--- a/frontend/src/views/project/CICDLayout.vue
+++ b/frontend/src/views/project/CICDLayout.vue
@@ -185,7 +185,8 @@ watch(
plan.value.specs.some(
(spec) =>
spec.config.case !== "changeDatabaseConfig" &&
- spec.config.case !== "createDatabaseConfig"
+ spec.config.case !== "createDatabaseConfig" &&
+ spec.config.case !== "exportDataConfig"
)
) {
router.replace({
diff --git a/frontend/src/views/project/ProjectIssueDetail.vue b/frontend/src/views/project/ProjectIssueDetail.vue
index 8166f09d01..3a355f5be6 100644
--- a/frontend/src/views/project/ProjectIssueDetail.vue
+++ b/frontend/src/views/project/ProjectIssueDetail.vue
@@ -2,7 +2,6 @@
<div class="relative overflow-x-hidden h-full">
<template v-if="ready">
<GrantRequestIssueDetailPage v-if="isGrantRequestIssue(issue)" />
- <DataExportIssueDetailPage v-else-if="isDatabaseDataExportIssue(issue)" />
<IssueDetailPage v-else />
</template>
<div v-else class="w-full h-full flex flex-col items-center justify-center">
@@ -15,10 +14,10 @@
import { useTitle } from "@vueuse/core";
import Emittery from "emittery";
import { NSpin } from "naive-ui";
-import { computed, onMounted, toRef } from "vue";
+import { computed, onMounted, toRef, watch } from "vue";
import { useI18n } from "vue-i18n";
+import { useRoute, useRouter } from "vue-router";
import {
- DataExportIssueDetailPage,
GrantRequestIssueDetailPage,
provideIssueContext,
useBaseIssueContext,
@@ -30,8 +29,14 @@ import {
type PlanCheckRunEvents,
} from "@/components/PlanCheckRun/context";
import { useBodyLayoutContext } from "@/layouts/common";
+import {
+ PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+} from "@/router/dashboard/projectV1";
import { projectNamePrefix, useProjectByName, useUIStateStore } from "@/store";
import {
+ extractIssueUID,
+ extractProjectResourceName,
isDatabaseDataExportIssue,
isGrantRequestIssue,
isValidIssueName,
@@ -47,6 +52,8 @@ const props = defineProps<{
}>();
const { t } = useI18n();
+const router = useRouter();
+const route = useRoute();
const { project, ready: projectReady } = useProjectByName(
computed(() => `${projectNamePrefix}${props.projectId}`)
@@ -104,6 +111,40 @@ onMounted(() => {
}
});
+// Watch for when the issue data is ready and handle redirects
+watch(
+ ready,
+ (isReady) => {
+ if (!isReady) return;
+
+ // Redirect all data export issues to new layout
+ if (isDatabaseDataExportIssue(issue.value)) {
+ if (isCreating.value) {
+ // Redirect creation to plan creation page
+ router.replace({
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPECS,
+ params: {
+ projectId: extractProjectResourceName(project.value.name),
+ planId: "create",
+ },
+ query: route.query,
+ });
+ } else {
+ // Redirect existing issues to new issue detail layout
+ router.replace({
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,
+ params: {
+ projectId: extractProjectResourceName(project.value.name),
+ issueId: extractIssueUID(issue.value.name),
+ },
+ query: route.query,
+ });
+ }
+ }
+ },
+ { immediate: true }
+);
+
const documentTitle = computed(() => {
if (isCreating.value) {
return t("issue.new-issue");
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
index 904cde8ce5..ebbf88becc 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
@@ -222,7 +222,7 @@ import DataExportButton from "@/components/DataExportButton.vue";
import DatabaseInfo from "@/components/DatabaseInfo.vue";
import { RichDatabaseName } from "@/components/v2";
import { DISMISS_PLACEHOLDER } from "@/plugins/ai/components/state";
-import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
import {
useConnectionOfCurrentSQLEditorTab,
usePolicyByParentAndType,
@@ -543,10 +543,10 @@ const handleRequestExport = async () => {
sqlStorageKey,
};
const route = router.resolve({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL,
params: {
projectId: extractProjectResourceName(project.name),
- issueSlug: "create",
+ planId: "create",
},
query,
});