Skip to content

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

refactor(frontend): migrate export center and data export drawer to React (#19873)

Danny Xu558c57c19148
diff --git a/frontend/src/components/DataExportPrepForm/DataExportPrepDrawer.vue b/frontend/src/components/DataExportPrepForm/DataExportPrepDrawer.vue
deleted file mode 100644
index c2a0dc5a08..0000000000
--- a/frontend/src/components/DataExportPrepForm/DataExportPrepDrawer.vue
+++ /dev/null
@@ -1,26 +0,0 @@
-<template>
- <Drawer :show="show" :auto-focus="true" @close="$emit('dismiss')">
- <DataExportPrepForm
- :show="show"
- :project-name="projectName"
- :seed="seed"
- @dismiss="$emit('dismiss')"
- />
- </Drawer>
-</template>
-
-<script lang="ts" setup>
-import { Drawer } from "@/components/v2";
-import DataExportPrepForm from "./DataExportPrepForm.vue";
-import type { DataExportPrepSeed } from "./types";
-
-defineProps<{
- show: boolean;
- projectName: string;
- seed?: DataExportPrepSeed;
-}>();
-
-defineEmits<{
- (event: "dismiss"): void;
-}>();
-</script>
diff --git a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue b/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
deleted file mode 100644
index 62a3077d17..0000000000
--- a/frontend/src/components/DataExportPrepForm/DataExportPrepForm.vue
+++ /dev/null
@@ -1,424 +0,0 @@
-<template>
- <DrawerContent class="max-w-[100vw]">
- <template #header>
- <div class="flex flex-col gap-y-3">
- <span>
- {{ $t("custom-approval.risk-rule.risk.namespace.data_export") }}
- </span>
- <NSteps :current="state.step" size="small">
- <NStep :title="$t('plan.targets.title')" />
- <NStep :title="$t('common.configure')" />
- </NSteps>
- </div>
- </template>
-
- <div
- class="flex flex-col gap-y-4 h-full w-[calc(100vw-8rem)] lg:w-240 max-w-[calc(100vw-8rem)] overflow-x-auto"
- >
- <template v-if="state.step === 1">
- <DatabaseAndGroupSelector
- :project="project"
- v-model:value="state.targetSelectState"
- />
- </template>
-
- <template v-else>
- <div class="flex flex-col gap-y-4 pb-2">
- <div class="flex flex-col gap-y-2">
- <h3 class="text-base font-medium">
- {{ $t("plan.targets.title") }}
- </h3>
- <div class="flex flex-wrap gap-2">
- <div
- v-for="target in targets"
- :key="target"
- class="inline-flex items-center gap-2 px-2 py-1.5 border rounded-sm min-w-0"
- >
- <template v-if="isValidDatabaseName(target)">
- <DatabaseDisplay
- :database="target"
- :show-environment="true"
- size="medium"
- class="flex-1 min-w-0"
- />
- </template>
- <template v-else-if="isValidDatabaseGroupName(target)">
- <DatabaseGroupTargetDisplay :target="target" class="px-1 py-1" />
- </template>
- </div>
- </div>
- </div>
-
- <div class="flex flex-col gap-y-2">
- <label class="textlabel">
- {{ $t("common.title") }}
- <RequiredStar v-if="project.enforceIssueTitle" />
- </label>
- <NInput
- v-model:value="state.title"
- :placeholder="$t('common.title')"
- @update:value="state.titleEdited = true"
- />
- </div>
-
- <div class="flex flex-col gap-y-2">
- <label class="textlabel">
- {{ $t("common.description") }}
- </label>
- <MarkdownEditor
- mode="editor"
- :content="state.description"
- :project="project"
- :compact="true"
- @change="state.description = $event"
- />
- </div>
-
- <div class="flex flex-col gap-y-2">
- <label class="textlabel">
- {{ $t("issue.labels") }}
- <RequiredStar v-if="project.forceIssueLabels" />
- </label>
- <IssueLabelSelector
- :disabled="state.creating"
- :selected="state.labels"
- :project="project"
- size="medium"
- :render-menu-inside-parent="true"
- @update:selected="state.labels = $event"
- />
- </div>
-
- <div class="flex flex-col gap-y-2">
- <label class="textlabel">
- {{ $t("common.sql") }}
- <RequiredStar />
- </label>
- <div class="h-96 overflow-hidden border rounded-sm">
- <MonacoEditor
- class="w-full h-full"
- :content="state.statement"
- language="sql"
- @update:content="state.statement = $event"
- />
- </div>
- </div>
-
- <div class="flex flex-col gap-y-2">
- <h3 class="text-base">
- {{ $t("issue.data-export.options") }}
- </h3>
- <div class="p-3 border rounded-sm flex flex-col gap-y-3">
- <div class="flex items-center gap-4">
- <span class="text-sm">
- {{ $t("issue.data-export.format") }}
- </span>
- <ExportFormatSelector
- v-model:format="state.format"
- :editable="true"
- />
- </div>
-
- <ExportPasswordInputer
- v-model:password="state.password"
- :editable="true"
- />
- </div>
- </div>
-
- <LimitsSection />
- </div>
- </template>
- </div>
-
- <template #footer>
- <div class="flex items-center justify-end gap-x-3">
- <NButton @click.prevent="handleCancel">
- {{
- state.step === 1 ? $t("common.cancel") : $t("common.back")
- }}
- </NButton>
- <NButton
- v-if="state.step === 1"
- type="primary"
- :disabled="!validSelectState"
- @click="state.step = 2"
- >
- {{ $t("common.next") }}
- </NButton>
- <NButton
- v-else
- type="primary"
- :disabled="!canCreate"
- :loading="state.creating"
- @click="handleCreate"
- >
- {{ $t("common.create") }}
- </NButton>
- </div>
- </template>
- </DrawerContent>
-</template>
-
-<script lang="ts" setup>
-import { create } from "@bufbuild/protobuf";
-import { NButton, NInput, NStep, NSteps } from "naive-ui";
-import { v4 as uuidv4 } from "uuid";
-import { computed, reactive, watch, watchEffect } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
-import DatabaseAndGroupSelector from "@/components/DatabaseAndGroupSelector/";
-import IssueLabelSelector from "@/components/IssueV1/components/IssueLabelSelector.vue";
-import MarkdownEditor from "@/components/MarkdownEditor";
-import { MonacoEditor } from "@/components/MonacoEditor";
-import DatabaseDisplay from "@/components/Plan/components/common/DatabaseDisplay.vue";
-import ExportFormatSelector from "@/components/Plan/components/ExportOption/ExportFormatSelector.vue";
-import ExportPasswordInputer from "@/components/Plan/components/ExportOption/ExportPasswordInputer.vue";
-import LimitsSection from "@/components/Plan/components/IssueReviewView/DatabaseExportView/LimitsSection.vue";
-import DatabaseGroupTargetDisplay from "@/components/Plan/components/SpecDetailView/DatabaseGroupTargetDisplay.vue";
-import { createEmptyLocalSheet } from "@/components/Plan/logic";
-import RequiredStar from "@/components/RequiredStar.vue";
-import { DrawerContent } from "@/components/v2";
-import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
-import {
- experimentalCreateIssueByPlan,
- pushNotification,
- useCurrentUserV1,
- useDatabaseV1Store,
- useDBGroupStore,
- useProjectByName,
- useSheetV1Store,
-} from "@/store";
-import { isValidDatabaseGroupName, isValidDatabaseName } from "@/types";
-import { ExportFormat } from "@/types/proto-es/v1/common_pb";
-import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";
-import { Issue_Type, IssueSchema } from "@/types/proto-es/v1/issue_service_pb";
-import {
- Plan_ExportDataConfigSchema,
- Plan_SpecSchema,
- PlanSchema,
-} from "@/types/proto-es/v1/plan_service_pb";
-import {
- extractDatabaseGroupName,
- extractDatabaseResourceName,
- extractIssueUID,
- extractProjectResourceName,
- generatePlanTitle,
- setSheetStatement,
-} from "@/utils";
-import { type DataExportPrepSeed, normalizeDataExportPrepSeed } from "./types";
-
-type LocalState = {
- step: 1 | 2;
- creating: boolean;
- targetSelectState?: DataExportPrepSeed["targetSelectState"];
- title: string;
- titleEdited: boolean;
- description: string;
- labels: string[];
- statement: string;
- format: ExportFormat;
- password: string;
-};
-
-const props = defineProps<{
- projectName: string;
- show?: boolean;
- seed?: DataExportPrepSeed;
-}>();
-
-const emit = defineEmits<{
- (event: "dismiss"): void;
-}>();
-
-const { t } = useI18n();
-const router = useRouter();
-const currentUser = useCurrentUserV1();
-const sheetStore = useSheetV1Store();
-const dbStore = useDatabaseV1Store();
-const dbGroupStore = useDBGroupStore();
-const { project } = useProjectByName(computed(() => props.projectName));
-
-const buildInitialState = (): LocalState => {
- const seed = normalizeDataExportPrepSeed(props.seed);
- return {
- step: seed.step,
- creating: false,
- targetSelectState: seed.targetSelectState,
- title: "",
- titleEdited: false,
- description: "",
- labels: [],
- statement: "",
- format: ExportFormat.JSON,
- password: "",
- };
-};
-
-const state = reactive<LocalState>(buildInitialState());
-
-const resetState = () => {
- Object.assign(state, buildInitialState());
-};
-
-const targets = computed(() => {
- if (!state.targetSelectState) return [];
- if (state.targetSelectState.changeSource === "DATABASE") {
- return state.targetSelectState.selectedDatabaseNameList;
- }
- return state.targetSelectState.selectedDatabaseGroup
- ? [state.targetSelectState.selectedDatabaseGroup]
- : [];
-});
-
-const validSelectState = computed(() => targets.value.length > 0);
-
-const targetTitleNames = computed(() => {
- return targets.value.map((target) => {
- if (isValidDatabaseName(target)) {
- return extractDatabaseResourceName(target).databaseName;
- }
- if (isValidDatabaseGroupName(target)) {
- return extractDatabaseGroupName(target);
- }
- return target;
- });
-});
-
-const canCreate = computed(() => {
- if (!validSelectState.value) return false;
- if (project.value.enforceIssueTitle && !state.title.trim()) return false;
- if (project.value.forceIssueLabels && state.labels.length === 0) return false;
- if (!state.statement.trim()) return false;
- return true;
-});
-
-const effectiveTitle = computed(() => {
- const title = state.title.trim();
- if (title) {
- return title;
- }
- return generatePlanTitle("bb.plan.export-data", targetTitleNames.value);
-});
-
-const syncGeneratedTitle = () => {
- if (project.value.enforceIssueTitle) return;
- if (targetTitleNames.value.length === 0) return;
- if (state.titleEdited && state.title.trim()) return;
- state.title = generatePlanTitle(
- "bb.plan.export-data",
- targetTitleNames.value
- );
-};
-
-watch(
- () => targetTitleNames.value.join(","),
- () => {
- syncGeneratedTitle();
- },
- { immediate: true }
-);
-
-watch(
- () => props.show,
- (show) => {
- if (show) {
- resetState();
- syncGeneratedTitle();
- }
- },
- { immediate: true }
-);
-
-watchEffect(() => {
- for (const target of targets.value) {
- if (isValidDatabaseName(target)) {
- dbStore.getOrFetchDatabaseByName(target);
- } else if (isValidDatabaseGroupName(target)) {
- dbGroupStore.getOrFetchDBGroupByName(target, {
- view: DatabaseGroupView.FULL,
- });
- }
- }
-});
-
-const handleCancel = () => {
- if (state.step === 2) {
- state.step = 1;
- return;
- }
- resetState();
- emit("dismiss");
-};
-
-const handleCreate = async () => {
- if (state.creating || !canCreate.value) {
- return;
- }
-
- state.creating = true;
-
- try {
- const sheet = createEmptyLocalSheet();
- setSheetStatement(sheet, state.statement);
- const createdSheet = await sheetStore.createSheet(
- project.value.name,
- sheet
- );
-
- const spec = create(Plan_SpecSchema, {
- id: uuidv4(),
- config: {
- case: "exportDataConfig",
- value: create(Plan_ExportDataConfigSchema, {
- targets: targets.value,
- sheet: createdSheet.name,
- format: state.format,
- password: state.password,
- }),
- },
- });
-
- const planCreate = create(PlanSchema, {
- title: effectiveTitle.value,
- description: state.description,
- specs: [spec],
- creator: currentUser.value.name,
- });
-
- const issueCreate = create(IssueSchema, {
- title: effectiveTitle.value,
- description: state.description,
- creator: `users/${currentUser.value.email}`,
- labels: state.labels,
- type: Issue_Type.DATABASE_EXPORT,
- });
-
- const { createdIssue } = await experimentalCreateIssueByPlan(
- project.value,
- issueCreate,
- planCreate,
- { skipRollout: true }
- );
-
- resetState();
- emit("dismiss");
- router.push({
- name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
- params: {
- projectId: extractProjectResourceName(createdIssue.name),
- issueId: extractIssueUID(createdIssue.name),
- },
- });
- } catch (error) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("common.failed"),
- description: String(error),
- });
- } finally {
- state.creating = false;
- }
-};
-</script>
diff --git a/frontend/src/components/DataExportPrepForm/index.ts b/frontend/src/components/DataExportPrepForm/index.ts
deleted file mode 100644
index 9a60f7fd57..0000000000
--- a/frontend/src/components/DataExportPrepForm/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import DataExportPrepForm from "./DataExportPrepForm.vue";
-
-export { default as DataExportPrepDrawer } from "./DataExportPrepDrawer.vue";
-export * from "./types";
-export default DataExportPrepForm;
diff --git a/frontend/src/components/DataExportPrepForm/types.ts b/frontend/src/components/DataExportPrepForm/types.ts
deleted file mode 100644
index f1ae5577f6..0000000000
--- a/frontend/src/components/DataExportPrepForm/types.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import type { DatabaseSelectState } from "@/components/DatabaseAndGroupSelector";
-
-export type DataExportPrepStep = 1 | 2;
-
-export interface DataExportPrepSeed {
- targetSelectState?: DatabaseSelectState;
- step?: DataExportPrepStep;
-}
-
-export const normalizeDataExportPrepSeed = (
- seed?: DataExportPrepSeed
-): {
- targetSelectState?: DatabaseSelectState;
- step: DataExportPrepStep;
-} => {
- const targetSelectState = seed?.targetSelectState
- ? {
- changeSource: seed.targetSelectState.changeSource,
- selectedDatabaseNameList: [
- ...seed.targetSelectState.selectedDatabaseNameList,
- ],
- selectedDatabaseGroup: seed.targetSelectState.selectedDatabaseGroup,
- }
- : undefined;
-
- return {
- targetSelectState,
- step: seed?.step ?? 1,
- };
-};
diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vue
deleted file mode 100644
index 991072f45b..0000000000
--- a/frontend/src/components/ProjectDatabasesPanel.vue
+++ /dev/null
@@ -1,174 +0,0 @@
-<template>
- <div class="py-4 flex flex-col">
- <div class="px-4 flex flex-col gap-y-2 pb-2">
- <div
- class="w-full flex flex-col sm:flex-row items-start sm:items-end justify-between gap-2"
- >
- <AdvancedSearch
- v-model:params="state.params"
- class="flex-1"
- :autofocus="false"
- :placeholder="$t('database.filter-database')"
- :scope-options="scopeOptions"
- />
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.instances.list',
- ...PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
- ]"
- >
- <NButton
- type="primary"
- :disabled="slotProps.disabled"
- @click="state.showCreateDrawer = true"
- >
- <template #icon>
- <PlusIcon class="h-4 w-4" />
- </template>
- {{ $t("quick-action.new-db") }}
- </NButton>
- </PermissionGuardWrapper>
- </div>
- </div>
- <DatabaseOperations
- :project-name="project.name"
- :databases="selectedDatabases"
- @refresh="() => pagedDatabaseTableRef?.refresh()"
- @update="(databases) => pagedDatabaseTableRef?.updateCache(databases)"
- />
- <PagedDatabaseTable
- ref="pagedDatabaseTableRef"
- mode="PROJECT"
- :bordered="false"
- :show-selection="true"
- :filter="filter"
- :footer-class="'mx-4'"
- :parent="project.name"
- v-model:selected-database-names="state.selectedDatabaseNames"
- />
- </div>
- <Drawer
- :auto-focus="true"
- :close-on-esc="true"
- :show="state.showCreateDrawer"
- @close="state.showCreateDrawer = false"
- >
- <CreateDatabasePrepPanel @dismiss="state.showCreateDrawer = false" />
- </Drawer>
-</template>
-
-<script lang="ts" setup>
-import { PlusIcon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
-import { computed, reactive, ref, watch } from "vue";
-import { CreateDatabasePrepPanel } from "@/components/CreateDatabasePrepForm";
-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import { Drawer } from "@/components/v2";
-import { PagedDatabaseTable } from "@/components/v2/Model/DatabaseV1Table";
-import { useDatabaseV1Store } from "@/store";
-import {
- environmentNamePrefix,
- instanceNamePrefix,
-} from "@/store/modules/v1/common";
-import { isValidDatabaseName } from "@/types";
-import { Engine } from "@/types/proto-es/v1/common_pb";
-import type { Database } from "@/types/proto-es/v1/database_service_pb";
-import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import type { SearchParams, SearchScope } from "@/utils";
-import {
- CommonFilterScopeIdList,
- extractProjectResourceName,
- getValueFromSearchParams,
- getValuesFromSearchParams,
- PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
-} from "@/utils";
-import AdvancedSearch from "./AdvancedSearch";
-import { useCommonSearchScopeOptions } from "./AdvancedSearch/useCommonSearchScopeOptions";
-import { DatabaseOperations } from "./v2";
-
-interface LocalState {
- selectedDatabaseNames: string[];
- params: SearchParams;
- showCreateDrawer: boolean;
-}
-
-const props = defineProps<{
- project: Project;
-}>();
-
-const readonlyScopes = computed((): SearchScope[] => [
- {
- id: "project",
- value: extractProjectResourceName(props.project.name),
- readonly: true,
- },
-]);
-
-const databaseStore = useDatabaseV1Store();
-
-const state = reactive<LocalState>({
- selectedDatabaseNames: [],
- params: {
- query: "",
- scopes: [...readonlyScopes.value],
- },
- showCreateDrawer: false,
-});
-
-watch(
- () => props.project.name,
- () => {
- state.params = {
- query: "",
- scopes: [...readonlyScopes.value],
- };
- state.selectedDatabaseNames = [];
- }
-);
-
-const pagedDatabaseTableRef = ref<InstanceType<typeof PagedDatabaseTable>>();
-
-const scopeOptions = useCommonSearchScopeOptions([
- ...CommonFilterScopeIdList,
- "label",
- "engine",
-]);
-
-const selectedInstance = computed(() => {
- return getValueFromSearchParams(state.params, "instance", instanceNamePrefix);
-});
-
-const selectedEnvironment = computed(() => {
- return getValueFromSearchParams(
- state.params,
- "environment",
- environmentNamePrefix
- );
-});
-
-const selectedLabels = computed(() => {
- return getValuesFromSearchParams(state.params, "label");
-});
-
-const selectedEngines = computed(() => {
- return getValuesFromSearchParams(state.params, "engine").map(
- (engine) => Engine[engine as keyof typeof Engine]
- );
-});
-
-const filter = computed(() => ({
- instance: selectedInstance.value,
- environment: selectedEnvironment.value,
- query: state.params.query,
- labels: selectedLabels.value,
- engines: selectedEngines.value,
-}));
-
-const selectedDatabases = computed((): Database[] => {
- return state.selectedDatabaseNames
- .map((databaseName) => databaseStore.getDatabaseByName(databaseName))
- .filter((database) => isValidDatabaseName(database.name));
-});
-</script>
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
deleted file mode 100644
index bdd547957e..0000000000
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue
+++ /dev/null
@@ -1,517 +0,0 @@
-<template>
- <NScrollbar x-scrollable>
- <div
- v-bind="$attrs"
- class="text-sm flex flex-col lg:flex-row items-start lg:items-center bg-blue-100 py-3 px-4 text-main gap-y-2 gap-x-4"
- >
- <span class="whitespace-nowrap">{{
- $t("database.selected-n-databases", {
- n: databases.length,
- })
- }}</span>
- <div class="flex items-center">
- <template v-for="action in actions" :key="action.text">
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="selectedProject"
- :permissions="action.requiredPermissions"
- >
- <NTooltip
- :disabled="slotProps.disabled || !action.disabled || !getDisabledTooltip(action.text)"
- >
- <template #trigger>
- <NButton
- quaternary
- size="small"
- type="primary"
- :disabled="slotProps.disabled || action.disabled"
- @click="action.click"
- >
- <template #icon>
- <component :is="action.icon" class="h-4 w-4" />
- </template>
- <span class="text-sm">{{ action.text }}</span>
- </NButton>
- </template>
- <span class="w-56 text-sm">
- {{ getDisabledTooltip(action.text) }}
- </span>
- </NTooltip>
- </PermissionGuardWrapper>
- </template>
- </div>
- </div>
- </NScrollbar>
-
- <LabelEditorDrawer
- :show="state.showLabelEditorDrawer"
- :readonly="false"
- :title="
- $t('db.labels-for-resource', {
- resource: $t('database.n-databases', { n: databases.length }),
- })
- "
- :labels="databases.map((db) => db.labels)"
- @dismiss="state.showLabelEditorDrawer = false"
- @apply="onLabelsApply($event)"
- />
-
- <EditEnvironmentDrawer
- :show="state.showEditEnvironmentDrawer"
- @dismiss="state.showEditEnvironmentDrawer = false"
- @update="onEnvironmentUpdate($event)"
- />
-
- <DataExportPrepDrawer
- :show="state.showRequestExportPanel"
- :project-name="selectedProjectName"
- :seed="{
- step: 2,
- targetSelectState: {
- changeSource: 'DATABASE',
- selectedDatabaseNameList: selectedDatabaseNameList,
- },
- }"
- @dismiss="state.showRequestExportPanel = false"
- />
-
- <Drawer
- :show="!!state.transferOutDatabaseType"
- :auto-focus="true"
- @close="state.transferOutDatabaseType = undefined"
- >
- <TransferOutDatabaseForm
- v-if="state.transferOutDatabaseType === 'TRANSFER-OUT'"
- :database-list="props.databases"
- :selected-database-names="selectedDatabaseNameList"
- :on-success="() => $emit('refresh')"
- @dismiss="state.transferOutDatabaseType = undefined"
- />
- <TransferDatabaseForm
- v-else
- :project-name="projectName"
- :on-success="() => $emit('refresh')"
- @dismiss="state.transferOutDatabaseType = undefined"
- />
- </Drawer>
-
- <BBAlert
- v-model:show="state.showUnassignAlert"
- type="warning"
- :ok-text="$t('common.confirm')"
- :title="$t('database.unassign-alert-title')"
- :description="$t('database.unassign-alert-description')"
- @ok="
- () => {
- state.showUnassignAlert = false;
- unAssignDatabases();
- }
- "
- @cancel="state.showUnassignAlert = false"
- />
-</template>
-
-<script lang="ts" setup>
-import { create } from "@bufbuild/protobuf";
-import { FieldMaskSchema as FieldMaskProtoEsSchema } from "@bufbuild/protobuf/wkt";
-import {
- ArrowRightLeftIcon,
- ChevronsDownIcon,
- DownloadIcon,
- PencilIcon,
- PlusIcon,
- RefreshCcwIcon,
- SquareStackIcon,
- TagIcon,
- UnlinkIcon,
-} from "lucide-vue-next";
-import { NButton, NScrollbar, NTooltip } from "naive-ui";
-import type { VNode } from "vue";
-import { computed, h, reactive } from "vue";
-import { useI18n } from "vue-i18n";
-import { BBAlert } from "@/bbkit";
-import DataExportPrepDrawer from "@/components/DataExportPrepForm/DataExportPrepDrawer.vue";
-import EditEnvironmentDrawer from "@/components/EditEnvironmentDrawer.vue";
-import LabelEditorDrawer from "@/components/LabelEditorDrawer.vue";
-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import { preCreateIssue } from "@/components/Plan/logic/issue";
-import { TransferDatabaseForm } from "@/components/TransferDatabaseForm";
-import TransferOutDatabaseForm from "@/components/TransferOutDatabaseForm";
-import { Drawer } from "@/components/v2";
-import {
- pushNotification,
- useActuatorV1Store,
- useDatabaseV1Store,
- useDBSchemaV1Store,
- useGracefulRequest,
- useProjectV1Store,
-} from "@/store";
-import type { Permission } from "@/types";
-import { isDefaultProject, isValidProjectName } from "@/types";
-import type { Database } from "@/types/proto-es/v1/database_service_pb";
-import {
- BatchUpdateDatabasesRequestSchema,
- DatabaseSchema$,
- UpdateDatabaseRequestSchema,
-} from "@/types/proto-es/v1/database_service_pb";
-import {
- PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE,
- PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
- PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE,
-} from "@/utils";
-
-interface DatabaseAction {
- icon: VNode;
- text: string;
- disabled: boolean;
- click: () => void;
- requiredPermissions: Permission[];
-}
-
-interface LocalState {
- loading: boolean;
- showRequestExportPanel: boolean;
- showUnassignAlert: boolean;
- showLabelEditorDrawer: boolean;
- showEditEnvironmentDrawer: boolean;
- transferOutDatabaseType?: "TRANSFER-IN" | "TRANSFER-OUT";
-}
-
-const props = withDefaults(
- defineProps<{
- databases: Database[];
- projectName?: string;
- instanceName?: string;
- onCreateDatabase?: () => void;
- }>(),
- { projectName: "", instanceName: "", onCreateDatabase: undefined }
-);
-
-const state = reactive<LocalState>({
- loading: false,
- showRequestExportPanel: false,
- showUnassignAlert: false,
- showLabelEditorDrawer: false,
- showEditEnvironmentDrawer: false,
- transferOutDatabaseType: undefined,
-});
-
-const emit = defineEmits<{
- (event: "refresh"): void;
- (event: "update", databases: Database[]): void;
-}>();
-
-const { t } = useI18n();
-const actuatorStore = useActuatorV1Store();
-const databaseStore = useDatabaseV1Store();
-const projectStore = useProjectV1Store();
-const dbSchemaStore = useDBSchemaV1Store();
-
-const selectedProjectNames = computed(() => {
- return new Set(props.databases.map((db) => db.project));
-});
-
-const hasDefaultProjectSelected = computed(() => {
- return [...selectedProjectNames.value].some((name) => isDefaultProject(name));
-});
-
-const assignedDatabases = computed(() => {
- return props.databases.filter((db) => !isDefaultProject(db.project));
-});
-
-const getDisabledTooltip = (action: string) => {
- if (selectedProjectNames.value.size > 1) {
- return t("database.batch-action-disabled", {
- action: action.toLowerCase(),
- });
- }
- if (hasDefaultProjectSelected.value) {
- return t("database.batch-action-disabled-for-unassigned", {
- action: action.toLowerCase(),
- });
- }
- return "";
-};
-
-const selectedProjectName = computed(() => {
- if (props.projectName) {
- return props.projectName;
- }
- if (selectedProjectNames.value.size !== 1) {
- return "";
- }
- return [...selectedProjectNames.value][0];
-});
-
-const selectedProject = computed(() => {
- if (!isValidProjectName(selectedProjectName.value)) {
- return;
- }
- return projectStore.getProjectByName(selectedProjectName.value);
-});
-
-const selectedDatabaseNameList = computed(() => {
- return props.databases.map((db) => db.name);
-});
-
-const operations = computed(() => {
- return [
- "CREATE-DATABASE",
- "CHANGE-DATABASE",
- "EXPORT-DATA",
- "SYNC-SCHEMA",
- "EDIT-LABELS",
- "EDIT-ENVIRONMENT",
- "TRANSFER-OUT",
- "TRANSFER-IN",
- ];
-});
-
-const syncSchema = async () => {
- if (state.loading) {
- return;
- }
- pushNotification({
- module: "bytebase",
- style: "INFO",
- title: t("db.start-to-sync-schema"),
- });
- try {
- state.loading = true;
- await useGracefulRequest(async () => {
- await databaseStore.batchSyncDatabases(
- props.databases.map((db) => db.name)
- );
- for (const db of props.databases) {
- dbSchemaStore.removeCache(db.name);
- }
- });
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("db.successfully-synced-schema"),
- });
- } catch {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("db.failed-to-sync-schema"),
- });
- } finally {
- state.loading = false;
- }
-};
-
-const unAssignDatabases = async () => {
- if (state.loading) {
- return;
- }
- try {
- state.loading = true;
- await databaseStore.batchUpdateDatabases(
- create(BatchUpdateDatabasesRequestSchema, {
- parent: "-",
- requests: assignedDatabases.value.map((database) => {
- return create(UpdateDatabaseRequestSchema, {
- database: create(DatabaseSchema$, {
- name: database.name,
- project: actuatorStore.serverInfo?.defaultProject ?? "",
- }),
- updateMask: create(FieldMaskProtoEsSchema, { paths: ["project"] }),
- });
- }),
- })
- );
- emit("refresh");
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("database.successfully-transferred-databases"),
- });
- } catch {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("db.failed-to-sync-schema"),
- });
- } finally {
- state.loading = false;
- }
-};
-
-const operationsInProjectDetail = computed(() => !!props.projectName);
-
-const isInDefaultProject = computed(() => isDefaultProject(props.projectName));
-
-const actions = computed((): DatabaseAction[] => {
- const resp: DatabaseAction[] = [];
- for (const operation of operations.value) {
- switch (operation) {
- case "CREATE-DATABASE":
- if (props.instanceName && props.onCreateDatabase) {
- resp.push({
- icon: h(PlusIcon),
- text: t("instance.new-database"),
- disabled: false,
- click: props.onCreateDatabase,
- requiredPermissions: [...PERMISSIONS_FOR_DATABASE_CREATE_ISSUE],
- });
- }
- break;
- case "CHANGE-DATABASE":
- if (operationsInProjectDetail.value && !isInDefaultProject.value) {
- resp.push({
- icon: h(PencilIcon),
- text: t("database.change-database"),
- disabled:
- !selectedProjectName.value ||
- selectedDatabaseNameList.value.length < 1 ||
- hasDefaultProjectSelected.value,
- click: () => {
- preCreateIssue(
- selectedProjectName.value,
- selectedDatabaseNameList.value
- );
- },
- requiredPermissions: [...PERMISSIONS_FOR_DATABASE_CHANGE_ISSUE],
- });
- }
- break;
- case "EXPORT-DATA":
- if (operationsInProjectDetail.value && !isInDefaultProject.value) {
- resp.push({
- icon: h(DownloadIcon),
- text: t("custom-approval.risk-rule.risk.namespace.data_export"),
- disabled:
- !selectedProjectName.value ||
- props.databases.length < 1 ||
- hasDefaultProjectSelected.value,
- click: () => (state.showRequestExportPanel = true),
- requiredPermissions: [...PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE],
- });
- }
- break;
- case "SYNC-SCHEMA":
- resp.push({
- icon: h(RefreshCcwIcon),
- text: t("database.sync-schema-button"),
- disabled: props.databases.length < 1,
- click: syncSchema,
- requiredPermissions: ["bb.databases.sync"],
- });
- break;
- case "EDIT-LABELS":
- resp.push({
- icon: h(TagIcon),
- text: t("database.edit-labels"),
- disabled: props.databases.length < 1,
- click: () => (state.showLabelEditorDrawer = true),
- requiredPermissions: ["bb.databases.update"],
- });
- break;
- case "EDIT-ENVIRONMENT":
- resp.push({
- icon: h(SquareStackIcon),
- text: t("database.edit-environment"),
- disabled: props.databases.length < 1,
- click: () => (state.showEditEnvironmentDrawer = true),
- requiredPermissions: [
- "bb.databases.update",
- "bb.settings.getEnvironment",
- ],
- });
- break;
- case "TRANSFER-IN": {
- if (operationsInProjectDetail.value && !isInDefaultProject.value) {
- resp.push({
- icon: h(ChevronsDownIcon),
- text: t("quick-action.transfer-in-db"),
- disabled: false,
- click: () => (state.transferOutDatabaseType = "TRANSFER-IN"),
- requiredPermissions: ["bb.projects.update"],
- });
- }
- break;
- }
- case "TRANSFER-OUT":
- if (!operationsInProjectDetail.value) {
- resp.push({
- icon: h(ArrowRightLeftIcon),
- text: t("database.transfer-project"),
- disabled: props.databases.length < 1,
- click: () => (state.transferOutDatabaseType = "TRANSFER-OUT"),
- requiredPermissions: ["bb.databases.update"],
- });
- } else if (!isInDefaultProject.value) {
- resp.push({
- icon: h(UnlinkIcon),
- text: t("database.unassign"),
- disabled: props.databases.length < 1,
- click: () => (state.showUnassignAlert = true),
- requiredPermissions: ["bb.databases.update"],
- });
- }
- break;
- }
- }
-
- return resp;
-});
-
-const onLabelsApply = async (labelsList: { [key: string]: string }[]) => {
- if (labelsList.length !== props.databases.length) {
- // This should never happen.
- return;
- }
-
- const updatedDatabases = await databaseStore.batchUpdateDatabases(
- create(BatchUpdateDatabasesRequestSchema, {
- parent: "-",
- requests: props.databases.map((database, i) => {
- const label = labelsList[i];
- const patch = create(DatabaseSchema$, {
- ...database,
- labels: label,
- });
- return create(UpdateDatabaseRequestSchema, {
- database: patch,
- updateMask: create(FieldMaskProtoEsSchema, { paths: ["labels"] }),
- });
- }),
- })
- );
- emit("update", updatedDatabases);
-
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
-};
-
-const onEnvironmentUpdate = async (environment: string) => {
- const updatedDatabases = await databaseStore.batchUpdateDatabases(
- create(BatchUpdateDatabasesRequestSchema, {
- parent: "-",
- requests: props.databases.map((database) => {
- return create(UpdateDatabaseRequestSchema, {
- database: create(DatabaseSchema$, {
- name: database.name,
- environment: environment,
- }),
- updateMask: create(FieldMaskProtoEsSchema, {
- paths: ["environment"],
- }),
- });
- }),
- })
- );
- emit("update", updatedDatabases);
-
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
-};
-</script>
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/index.ts b/frontend/src/components/v2/Model/DatabaseV1Table/index.ts
index d5ab219877..7aa81e9c77 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/index.ts
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/index.ts
@@ -1,5 +1,4 @@
-import DatabaseOperations from "./DatabaseOperations.vue";
import DatabaseV1Table from "./DatabaseV1Table.vue";
import PagedDatabaseTable from "./PagedDatabaseTable.vue";
-export { DatabaseOperations, PagedDatabaseTable, DatabaseV1Table };
+export { PagedDatabaseTable, DatabaseV1Table };
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f13f99321e..91b44e5ccb 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1335,7 +1335,6 @@
"add-instance": "@:common.add @:common.instance",
"new-project": "@:common.new @:common.project",
"create-project": "@:common.create @:common.project",
- "transfer-in-db": "Transfer In",
"from-unassigned-databases": "Unassigned databases",
"from-projects": "From other projects",
"transfer-in-db-title": "Transfer in database",
@@ -1398,7 +1397,6 @@
},
"instance": {
"select-database-user": "Select database user",
- "new-database": "New Database",
"syncing": "Syncing ...",
"sync": {
"self": "Sync instance",
@@ -1723,8 +1721,6 @@
"mixed-values-for-label": "This selected label have mixed values",
"mixed-label-values-warning": "Some of the selected resources have mixed values for the same key. Only edit these key-value pairs if you intend to change them.",
"table-detail": "Table detail",
- "batch-action-disabled": "Can not {action} for the databases from different projects",
- "batch-action-disabled-for-unassigned": "Can not {action} for unassigned database",
"successfully-transferred-databases": "Successfully transferred databases",
"nullable": "Nullable",
"expression": "Expression",
@@ -1743,7 +1739,6 @@
"go-to-transfer": "Go to transfer",
"unassigned-databases": "Unassigned databases",
"selected-n-databases": "{n} database selected | {n} databases selected",
- "n-databases": "{n} database | {n} databases",
"sync-schema": {
"title": "Sync Schema",
"description": "Bytebase supports synchronizing a schema to one or multiple target databases. (MySQL, PostgreSQL, Oracle, MSSQL, TiDB only)",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 0b0a03076c..0f9a846c1a 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1335,7 +1335,6 @@
"add-instance": "@:common.add @:common.instance",
"new-project": "@:common.new @:common.project",
"create-project": "@:common.create @:common.project",
- "transfer-in-db": "Transferir",
"from-unassigned-databases": "Bases de datos no asignadas",
"from-projects": "De otro proyecto",
"transfer-in-db-title": "Transferir base de datos",
@@ -1398,7 +1397,6 @@
},
"instance": {
"select-database-user": "Seleccionar usuario de base de datos",
- "new-database": "Nueva base de datos",
"syncing": "Sincronizando...",
"sync": {
"self": "Instancia de sincronización",
@@ -1723,8 +1721,6 @@
"mixed-values-for-label": "Esta etiqueta seleccionada tiene valores mixtos.",
"mixed-label-values-warning": "Algunos de los recursos seleccionados tienen valores mixtos para la misma clave. Solo edite estos pares clave-valor si tiene la intención de cambiarlos.",
"table-detail": "Detalle de la tabla",
- "batch-action-disabled": "No se puede {action} para las bases de datos de diferentes proyectos",
- "batch-action-disabled-for-unassigned": "No se puede {action} para una base de datos no asignada",
"successfully-transferred-databases": "Bases de datos transferidas exitosamente",
"nullable": "Anulable",
"expression": "Expresión",
@@ -1743,7 +1739,6 @@
"go-to-transfer": "Ir a transferir",
"unassigned-databases": "Bases de datos no asignadas",
"selected-n-databases": "{n} base de datos seleccionada | {n} bases de datos seleccionadas",
- "n-databases": "{n} base de datos | {n} bases de datos",
"sync-schema": {
"title": "Sincronizar esquema",
"description": "Bytebase admite la sincronización de un esquema con una o varias bases de datos de destino. (Solo MySQL, PostgreSQL, Oracle, MSSQL, TiDB)",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 00f66e5e61..506774eccc 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1335,7 +1335,6 @@
"add-instance": "@:common.instance@:common.add",
"new-project": "@:common.new@:common.project",
"create-project": "@:common.create@:common.project",
- "transfer-in-db": "転入",
"from-unassigned-databases": "割り当てられていないデータベース",
"from-projects": "他のプロジェクトから",
"transfer-in-db-title": "データベースへの転送",
@@ -1398,7 +1397,6 @@
},
"instance": {
"select-database-user": "データベースユーザーの選択",
- "new-database": "@:common.new@:common.database",
"syncing": "同期中 ...",
"sync": {
"self": "インスタンスの同期",
@@ -1723,8 +1721,6 @@
"mixed-values-for-label": "タグの値が異なります",
"mixed-label-values-warning": "選択されたリソースの一部は、同じキーに対して異なる値を持っています。これらのキーと値のペアを変更する場合にのみ編集してください。",
"table-detail": "テーブルの詳細",
- "batch-action-disabled": "異なるプロジェクトのデータベース {action} を比較できません",
- "batch-action-disabled-for-unassigned": "未割り当てのデータベース {action} にアクセスできません",
"successfully-transferred-databases": "データベースの移行が完了しました",
"nullable": "null も可能",
"expression": "式",
@@ -1743,7 +1739,6 @@
"go-to-transfer": "転送に行く",
"unassigned-databases": "未割り当てのデータベース",
"selected-n-databases": "{n} 個のデータベースが選択されました",
- "n-databases": "{n} データベース",
"sync-schema": {
"title": "データベーステーブルの同期",
"description": "Bytebase は、スキーマを 1 つまたは複数のターゲット データベースに同期することをサポートします。(MySQL, PostgreSQL, Oracle, MSSQL, TiDB のみ)",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 321639acd5..12351247d8 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1335,7 +1335,6 @@
"add-instance": "@:common.add @:common.instance",
"new-project": "@:common.new @:common.project",
"create-project": "@:common.create @:common.project",
- "transfer-in-db": "Chuyển vào",
"from-unassigned-databases": "Cơ sở dữ liệu chưa được gán",
"from-projects": "Từ các dự án khác",
"transfer-in-db-title": "Chuyển vào cơ sở dữ liệu",
@@ -1398,7 +1397,6 @@
},
"instance": {
"select-database-user": "Chọn người dùng cơ sở dữ liệu",
- "new-database": "Cơ sở dữ liệu mới",
"syncing": "Đang đồng bộ hóa ...",
"sync": {
"self": "Đồng bộ phiên bản",
@@ -1723,8 +1721,6 @@
"mixed-values-for-label": "Nhãn đã chọn này có các giá trị hỗn hợp",
"mixed-label-values-warning": "Một số tài nguyên đã chọn có các giá trị khác nhau cho cùng một khóa. Chỉ chỉnh sửa các cặp khóa-giá trị này nếu bạn muốn thay đổi chúng.",
"table-detail": "Chi tiết bảng",
- "batch-action-disabled": "Không thể {action} đối với các cơ sở dữ liệu từ các dự án khác nhau",
- "batch-action-disabled-for-unassigned": "Không thể {action} đối với cơ sở dữ liệu chưa được gán",
"successfully-transferred-databases": "Đã chuyển thành công cơ sở dữ liệu",
"nullable": "Có thể null",
"expression": "Biểu thức",
@@ -1743,7 +1739,6 @@
"go-to-transfer": "Đi tới chuyển",
"unassigned-databases": "Cơ sở dữ liệu chưa được gán",
"selected-n-databases": "Đã chọn {n} cơ sở dữ liệu | Đã chọn {n} cơ sở dữ liệu",
- "n-databases": "{n} cơ sở dữ liệu | {n} cơ sở dữ liệu",
"sync-schema": {
"title": "Đồng bộ lược đồ",
"description": "Bytebase hỗ trợ đồng bộ hóa một lược đồ với một hoặc nhiều cơ sở dữ liệu đích. (Chỉ MySQL, PostgreSQL, Oracle, MSSQL, TiDB)",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 93f4505a1f..3e89caf68d 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1335,7 +1335,6 @@
"add-instance": "@:common.add@:common.instance",
"new-project": "@:common.new@:common.project",
"create-project": "@:common.create@:common.project",
- "transfer-in-db": "转入",
"from-unassigned-databases": "未分配的数据库",
"from-projects": "从其他项目",
"transfer-in-db-title": "转进数据库",
@@ -1398,7 +1397,6 @@
},
"instance": {
"select-database-user": "选择数据库用户",
- "new-database": "@:common.new@:common.database",
"syncing": "同步中 ...",
"sync": {
"self": "同步实例",
@@ -1723,8 +1721,6 @@
"mixed-values-for-label": "该标签拥有不同的值",
"mixed-label-values-warning": "部分标签拥有不同的值,编辑标签将会批量应用。仅在您打算更改时再编辑这些键值对。",
"table-detail": "表详情",
- "batch-action-disabled": "无法对来自不同项目的数据库{action}",
- "batch-action-disabled-for-unassigned": "无法对未分配的数据库{action}",
"successfully-transferred-databases": "数据库转移完成",
"nullable": "可为空",
"expression": "表达式",
@@ -1743,7 +1739,6 @@
"go-to-transfer": "前去转移",
"unassigned-databases": "未分配的数据库",
"selected-n-databases": "已选择 {n} 个数据库",
- "n-databases": "{n} 个数据库",
"sync-schema": {
"title": "库表同步",
"description": "Bytebase 支持将一个指定的 Schema 同步到一个或多个目标数据库。(支持 MySQL, PostgreSQL, Oracle, MSSQL 以及 TiDB)",
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 9531623b0f..70e1bbf63c 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -211,6 +211,11 @@
"view-details": "View Details",
"warning": "Warning",
"webhooks": "Webhooks",
+ "approved": "Approved",
+ "closed": "Closed",
+ "rejected": "Rejected",
+ "sql": "SQL",
+ "untitled": "Untitled",
"you": "you"
},
"create-db": {
@@ -283,6 +288,9 @@
"rule": {
"first-match-wins": "Rules are evaluated in order. First matching rule applies."
},
+ "issue-review": {
+ "generating-approval-flow": "Generating approval flow"
+ },
"self": "Custom Approval"
},
"database": {
@@ -446,13 +454,29 @@
"advanced-search": {
"filter": "Filter"
},
+ "data-export": {
+ "format": "Format",
+ "limits": "Limits",
+ "options": "Options"
+ },
"labels": "Issue Labels",
+ "risk-level": {
+ "high": "High",
+ "moderate": "Moderate",
+ "self": "Risk level"
+ },
"role-grant": {
"all-databases": "All",
"all-databases-tip": "All current and future databases in this project.",
"manually-select": "Manually select",
"use-cel": "Use CEL Expression"
},
+ "table": {
+ "approval-progress": "{{approved}}/{{total}} Approvals",
+ "approved": "Approved",
+ "open": "Open",
+ "waiting-role": "Waiting: {{role}}"
+ },
"upload-sql": "Upload SQL"
},
"label": {
@@ -473,7 +497,10 @@
}
},
"plan": {
- "plans": "Plans"
+ "plans": "Plans",
+ "targets": {
+ "title": "Targets"
+ }
},
"policy": {
"environment-tier": {
@@ -647,7 +674,8 @@
"create-db": "Create database",
"create-project": "Create Project",
"new-db": "New DB",
- "new-project": "New Project"
+ "new-project": "New Project",
+ "request-export-data": "Request Export"
},
"release": {
"releases": "Releases"
@@ -1403,5 +1431,8 @@
"description": "Copy the code and enter it in your TOTP app manually.",
"self": "Your two-factor secret"
}
+ },
+ "export-data": {
+ "password-optional": "Encrypt with password (Optional)"
}
}
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index 19af27d312..dad7453c39 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -72,6 +72,7 @@
"added": "Agregado",
"address": "Dirección",
"all": "Todos",
+ "approved": "Aprobado",
"archive": "Archivo",
"archive-description": "Mark \"{{name}}\" as archived and read-only.",
"archive-resource": "Archive {{type}}",
@@ -83,6 +84,7 @@
"classification-level": "Nivel de clasificación",
"clear": "Limpiar",
"close": "Cerrar",
+ "closed": "Cerrado",
"columns": "Columnas",
"configure": "Configurar",
"configure-now": "Configurar ahora",
@@ -167,6 +169,7 @@
"projects": "Proyectos",
"reason": "Reason",
"regenerate": "Regenerar",
+ "rejected": "Rechazado",
"release": "Versión",
"reorder": "Reordenar",
"required-permission": "Permisos necesarios",
@@ -190,6 +193,7 @@
"sensitive-placeholder": "Sensible - solo escritura",
"setting": "Configuración",
"settings": "Configuraciones",
+ "sql": "SQL",
"state": "Estado",
"statement": "Declaración",
"status": "Estado",
@@ -202,6 +206,7 @@
"type": "Tipo",
"unassigned": "No asignado",
"unlimited": "Ilimitado",
+ "untitled": "Sin título",
"update": "Actualizar",
"updated": "Actualizado",
"upload": "Subir",
@@ -251,6 +256,9 @@
"presets-title": "Plantillas"
}
},
+ "issue-review": {
+ "generating-approval-flow": "Generando flujo de aprobación"
+ },
"risk": {
"description": "La evaluación de riesgos evalúa automáticamente los cambios en la base de datos y asigna niveles de riesgo según el tipo de operación que se realiza.",
"how-it-works": "Cómo funciona",
@@ -363,6 +371,9 @@
"export-center": {
"data-export": "Exportación de datos"
},
+ "export-data": {
+ "password-optional": "Cifrar con contraseña (opcional)"
+ },
"gitops": {
"checklist": {
"database-group-recommendation": "Para bases de datos con el mismo esquema, un grupo de bases de datos permite migrarlas juntas en un solo cambio. Defina el grupo una vez y reutilícelo en las migraciones sin tener que seleccionar bases de datos individuales cada vez.",
@@ -446,13 +457,29 @@
"advanced-search": {
"filter": "Filtrar"
},
+ "data-export": {
+ "format": "Formato",
+ "limits": "Límites",
+ "options": "Opciones de exportación"
+ },
"labels": "Etiquetas de problema",
+ "risk-level": {
+ "high": "Alto",
+ "moderate": "Moderado",
+ "self": "Nivel de riesgo"
+ },
"role-grant": {
"all-databases": "todas las bases de datos",
"all-databases-tip": "Todas las bases de datos actuales y futuras de este proyecto.",
"manually-select": "selección manual",
"use-cel": "Usar expresión CEL"
},
+ "table": {
+ "approval-progress": "{{approved}}/{{total}} Approvals",
+ "approved": "Approved",
+ "open": "Abierto",
+ "waiting-role": "Waiting: {{role}}"
+ },
"upload-sql": "Upload SQL"
},
"label": {
@@ -473,7 +500,10 @@
}
},
"plan": {
- "plans": "Planes"
+ "plans": "Planes",
+ "targets": {
+ "title": "Objetivos"
+ }
},
"policy": {
"environment-tier": {
@@ -647,7 +677,8 @@
"create-db": "Crear base de datos",
"create-project": "Crear Proyecto",
"new-db": "Nueva BD",
- "new-project": "Nuevo Proyecto"
+ "new-project": "Nuevo Proyecto",
+ "request-export-data": "Solicitar exportación"
},
"release": {
"releases": "Lanzamientos"
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index 2efffdf6a2..9ea17048c3 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -72,6 +72,7 @@
"added": "作成した",
"address": "接続先",
"all": "全て",
+ "approved": "承認済み",
"archive": "アーカイブ",
"archive-description": "Mark \"{{name}}\" as archived and read-only.",
"archive-resource": "Archive {{type}}",
@@ -83,6 +84,7 @@
"classification-level": "分類レベル",
"clear": "クリア",
"close": "閉じる",
+ "closed": "閉まっている",
"columns": "カラム",
"configure": "設定",
"configure-now": "今すぐ設定する",
@@ -167,6 +169,7 @@
"projects": "プロジェクト",
"reason": "Reason",
"regenerate": "再生する",
+ "rejected": "却下",
"release": "リリース",
"reorder": "並び替え",
"required-permission": "必要な権限",
@@ -190,6 +193,7 @@
"sensitive-placeholder": "機密データ - 書き込みのみ",
"setting": "設定",
"settings": "設定",
+ "sql": "SQL",
"state": "ステート",
"statement": "ステートメント",
"status": "ステータス",
@@ -202,6 +206,7 @@
"type": "タイプ",
"unassigned": "割り当てられていない",
"unlimited": "無制限",
+ "untitled": "名前のない",
"update": "更新する",
"updated": "更新しました",
"upload": "アップロード",
@@ -251,6 +256,9 @@
"presets-title": "プリセット"
}
},
+ "issue-review": {
+ "generating-approval-flow": "承認フローが生成されています"
+ },
"risk": {
"description": "リスク評価は、データベースの変更を自動的に評価し、実行される操作の種類に基づいてリスクレベルを割り当てます。",
"how-it-works": "仕組み",
@@ -363,6 +371,9 @@
"export-center": {
"data-export": "データエクスポート"
},
+ "export-data": {
+ "password-optional": "パスワード暗号化の設定 (オプション)"
+ },
"gitops": {
"checklist": {
"database-group-recommendation": "同じスキーマを持つデータベースには、データベースグループを使用すると一度の変更でまとめてマイグレーションできます。グループを一度定義すれば、毎回個別にデータベースを選択することなく、マイグレーション全体で再利用できます。",
@@ -446,13 +457,29 @@
"advanced-search": {
"filter": "フィルター"
},
+ "data-export": {
+ "format": "エクスポート形式",
+ "limits": "制限",
+ "options": "設定項目"
+ },
"labels": "イシューラベル",
+ "risk-level": {
+ "high": "高い",
+ "moderate": "適度",
+ "self": "リスクレベル"
+ },
"role-grant": {
"all-databases": "すべてのデータベース",
"all-databases-tip": "このプロジェクトに属する現在および将来のすべてのデータベース。",
"manually-select": "手動選択",
"use-cel": "CEL式を使用"
},
+ "table": {
+ "approval-progress": "{{approved}}/{{total}} Approvals",
+ "approved": "Approved",
+ "open": "オープン",
+ "waiting-role": "Waiting: {{role}}"
+ },
"upload-sql": "Upload SQL"
},
"label": {
@@ -473,7 +500,10 @@
}
},
"plan": {
- "plans": "プラン"
+ "plans": "プラン",
+ "targets": {
+ "title": "ターゲット"
+ }
},
"policy": {
"environment-tier": {
@@ -647,7 +677,8 @@
"create-db": "データベースの作成",
"create-project": "作成するプロジェクト",
"new-db": "データベースの作成",
- "new-project": "作成するプロジェクト"
+ "new-project": "作成するプロジェクト",
+ "request-export-data": "データ出力を申請する"
},
"release": {
"releases": "リリース"
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index ac1769105a..9e2d3885a2 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -72,6 +72,7 @@
"added": "Đã thêm",
"address": "Địa chỉ",
"all": "Tất cả",
+ "approved": "Đã phê duyệt",
"archive": "Lưu trữ",
"archive-description": "Mark \"{{name}}\" as archived and read-only.",
"archive-resource": "Archive {{type}}",
@@ -83,6 +84,7 @@
"classification-level": "Cấp phân loại",
"clear": "Xóa",
"close": "Đóng",
+ "closed": "Đã đóng",
"columns": "Cột",
"configure": "Cấu hình",
"configure-now": "Cấu hình ngay",
@@ -167,6 +169,7 @@
"projects": "Dự án",
"reason": "Reason",
"regenerate": "Tạo lại",
+ "rejected": "Đã từ chối",
"release": "Phiên bản",
"reorder": "Sắp xếp lại",
"required-permission": "Quyền hạn cần thiết",
@@ -190,6 +193,7 @@
"sensitive-placeholder": "Nhạy cảm - Chỉ ghi",
"setting": "Cài đặt",
"settings": "Cài đặt",
+ "sql": "SQL",
"state": "Trạng thái",
"statement": "Câu lệnh",
"status": "Trạng thái",
@@ -202,6 +206,7 @@
"type": "Loại",
"unassigned": "Chưa gán",
"unlimited": "Không giới hạn",
+ "untitled": "Không tiêu đề",
"update": "Cập nhật",
"updated": "Đã cập nhật",
"upload": "Tải lên",
@@ -251,6 +256,9 @@
"presets-title": "Mẫu có sẵn"
}
},
+ "issue-review": {
+ "generating-approval-flow": "Đang tạo quy trình phê duyệt"
+ },
"risk": {
"description": "Đánh giá rủi ro tự động đánh giá các thay đổi cơ sở dữ liệu và phân loại mức độ rủi ro dựa trên loại thao tác được thực hiện.",
"how-it-works": "Cách hoạt động",
@@ -363,6 +371,9 @@
"export-center": {
"data-export": "Xuất dữ liệu"
},
+ "export-data": {
+ "password-optional": "Mã hóa bằng mật khẩu (Tùy chọn)"
+ },
"gitops": {
"checklist": {
"database-group-recommendation": "Đối với các cơ sở dữ liệu có cùng schema, nhóm cơ sở dữ liệu cho phép bạn migration tất cả cùng lúc trong một thay đổi. Chỉ cần định nghĩa nhóm một lần và tái sử dụng trong các lần migration mà không cần chọn từng cơ sở dữ liệu mỗi lần.",
@@ -446,13 +457,29 @@
"advanced-search": {
"filter": "Bộ lọc"
},
+ "data-export": {
+ "format": "Định dạng",
+ "limits": "Giới hạn",
+ "options": "Tùy chọn"
+ },
"labels": "Nhãn vấn đề",
+ "risk-level": {
+ "high": "Cao",
+ "moderate": "Trung bình",
+ "self": "Mức độ rủi ro"
+ },
"role-grant": {
"all-databases": "Tất cả",
"all-databases-tip": "Tất cả cơ sở dữ liệu hiện tại và tương lai trong dự án này.",
"manually-select": "Chọn thủ công",
"use-cel": "Sử dụng biểu thức CEL"
},
+ "table": {
+ "approval-progress": "{{approved}}/{{total}} Approvals",
+ "approved": "Approved",
+ "open": "Mở",
+ "waiting-role": "Waiting: {{role}}"
+ },
"upload-sql": "Upload SQL"
},
"label": {
@@ -473,7 +500,10 @@
}
},
"plan": {
- "plans": "Kế hoạch"
+ "plans": "Kế hoạch",
+ "targets": {
+ "title": "Mục tiêu"
+ }
},
"policy": {
"environment-tier": {
@@ -647,7 +677,8 @@
"create-db": "Tạo cơ sở dữ liệu",
"create-project": "Tạo Dự án",
"new-db": "Cơ sở dữ liệu mới",
- "new-project": "Mới Dự án"
+ "new-project": "Mới Dự án",
+ "request-export-data": "Yêu cầu Xuất"
},
"release": {
"releases": "Bản phát hành"
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index 41c6d7f9fa..08e091debf 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -72,6 +72,7 @@
"added": "已创建",
"address": "地址",
"all": "全部",
+ "approved": "已批准",
"archive": "归档",
"archive-description": "将「{{name}}」标记为已归档且只读。",
"archive-resource": "归档{{type}}",
@@ -83,6 +84,7 @@
"classification-level": "分类等级",
"clear": "清除",
"close": "关闭",
+ "closed": "已关闭",
"columns": "列",
"configure": "配置",
"configure-now": "现在配置",
@@ -167,6 +169,7 @@
"projects": "项目",
"reason": "Reason",
"regenerate": "重新生成",
+ "rejected": "已拒绝",
"release": "版本",
"reorder": "排序",
"required-permission": "所需权限",
@@ -190,6 +193,7 @@
"sensitive-placeholder": "敏感数据 - 仅写入",
"setting": "设置",
"settings": "设置",
+ "sql": "SQL",
"state": "状态",
"statement": "语句",
"status": "状态",
@@ -202,6 +206,7 @@
"type": "类型",
"unassigned": "未分配",
"unlimited": "无限制",
+ "untitled": "未命名",
"update": "更新",
"updated": "已更新",
"upload": "上传",
@@ -251,6 +256,9 @@
"presets-title": "预设模板"
}
},
+ "issue-review": {
+ "generating-approval-flow": "正在生成审批流"
+ },
"risk": {
"description": "风险评估会自动评估数据库变更,并根据操作类型分配风险等级。",
"how-it-works": "工作原理",
@@ -363,6 +371,9 @@
"export-center": {
"data-export": "数据导出"
},
+ "export-data": {
+ "password-optional": "设置密码加密(可选)"
+ },
"gitops": {
"checklist": {
"database-group-recommendation": "对于具有相同 Schema 的数据库,数据库分组可以让您在一次变更中同时迁移它们。只需定义一次分组,即可在多次迁移中复用,无需每次都逐个选择数据库。",
@@ -446,13 +457,29 @@
"advanced-search": {
"filter": "过滤"
},
+ "data-export": {
+ "format": "导出格式",
+ "limits": "限制",
+ "options": "配置项"
+ },
"labels": "工单标签",
+ "risk-level": {
+ "high": "高风险",
+ "moderate": "中风险",
+ "self": "风险等级"
+ },
"role-grant": {
"all-databases": "所有数据库",
"all-databases-tip": "所有当前和未来属于这个项目的数据库。",
"manually-select": "手动选择",
"use-cel": "使用 CEL 表达式"
},
+ "table": {
+ "approval-progress": "{{approved}}/{{total}} 已审批",
+ "approved": "已审批",
+ "open": "开启中",
+ "waiting-role": "等待: {{role}}"
+ },
"upload-sql": "上传 SQL"
},
"label": {
@@ -473,7 +500,10 @@
}
},
"plan": {
- "plans": "变更计划"
+ "plans": "变更计划",
+ "targets": {
+ "title": "目标库"
+ }
},
"policy": {
"environment-tier": {
@@ -647,7 +677,8 @@
"create-db": "创建数据库",
"create-project": "创建项目",
"new-db": "创建数据库",
- "new-project": "创建项目"
+ "new-project": "创建项目",
+ "request-export-data": "申请导出数据"
},
"release": {
"releases": "发布包"
diff --git a/frontend/src/react/pages/project/ProjectDatabasesPage.tsx b/frontend/src/react/pages/project/ProjectDatabasesPage.tsx
index 6c94125b24..acdc32f3d8 100644
--- a/frontend/src/react/pages/project/ProjectDatabasesPage.tsx
+++ b/frontend/src/react/pages/project/ProjectDatabasesPage.tsx
@@ -19,8 +19,6 @@ import {
import { EditEnvironmentDrawer } from "@/react/components/EditEnvironmentDrawer";
import { Button } from "@/react/components/ui/button";
import { useVueState } from "@/react/hooks/useVueState";
-import { router } from "@/router";
-import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
import {
pushNotification,
useActuatorV1Store,
@@ -50,12 +48,11 @@ import {
} from "@/types/proto-es/v1/database_service_pb";
import {
engineNameV1,
- extractDatabaseResourceName,
- generatePlanTitle,
hasProjectPermissionV2,
PERMISSIONS_FOR_DATABASE_CREATE_ISSUE,
supportedEngineV1List,
} from "@/utils";
+import { DataExportPrepDrawer } from "./export-center/DataExportPrepDrawer";
export function ProjectDatabasesPage({ projectId }: { projectId: string }) {
const { t } = useTranslation();
@@ -342,29 +339,11 @@ export function ProjectDatabasesPage({ projectId }: { projectId: string }) {
);
}, [projectName, selectedDatabases]);
- const handleExportData = useCallback(async () => {
- const project = await projectStore.getOrFetchProjectByName(projectName);
- const query: Record<string, string> = {
- template: "bb.plan.export-data",
- databaseList: selectedDatabases.map((db) => db.name).join(","),
- };
- if (!project.enforceIssueTitle) {
- query.name = generatePlanTitle(
- "bb.plan.export-data",
- selectedDatabases.map(
- (db) => extractDatabaseResourceName(db.name).databaseName
- )
- );
- }
- router.push({
- name: PROJECT_V1_ROUTE_PLAN_DETAIL,
- params: {
- projectId,
- planId: "create",
- },
- query,
- });
- }, [projectName, projectId, selectedDatabases, projectStore]);
+ const [showExportDrawer, setShowExportDrawer] = useState(false);
+
+ const handleExportData = useCallback(() => {
+ setShowExportDrawer(true);
+ }, []);
return (
<div className="py-4 flex flex-col">
@@ -431,6 +410,16 @@ export function ProjectDatabasesPage({ projectId }: { projectId: string }) {
projectName={projectName}
/>
+ <DataExportPrepDrawer
+ open={showExportDrawer}
+ onClose={() => setShowExportDrawer(false)}
+ projectName={projectName}
+ seed={{
+ selectedDatabaseNames: selectedDatabases.map((db) => db.name),
+ step: 2,
+ }}
+ />
+
{/* Unassign confirmation dialog */}
{showUnassignConfirm && (
<div className="fixed inset-0 z-50 flex items-center justify-center">
diff --git a/frontend/src/react/pages/project/ProjectExportCenterPage.tsx b/frontend/src/react/pages/project/ProjectExportCenterPage.tsx
new file mode 100644
index 0000000000..d86af693d0
--- /dev/null
+++ b/frontend/src/react/pages/project/ProjectExportCenterPage.tsx
@@ -0,0 +1,568 @@
+import { Download, Loader2 } from "lucide-react";
+import { useCallback, useEffect, useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+import {
+ AdvancedSearch,
+ type ScopeOption,
+ type SearchParams,
+ type SearchScope,
+} from "@/react/components/AdvancedSearch";
+import { Button } from "@/react/components/ui/button";
+import { Tooltip } from "@/react/components/ui/tooltip";
+import { useVueState } from "@/react/hooks/useVueState";
+import {
+ PagedTableFooter,
+ usePagedData,
+} from "@/react/pages/settings/shared/usePagedData";
+import { router } from "@/router";
+import { WORKSPACE_ROUTE_USER_PROFILE } from "@/router/dashboard/workspaceRoutes";
+import { useIssueV1Store, useProjectV1Store, useUserStore } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import { getTimeForPbTimestampProtoEs, unknownUser } from "@/types";
+import { RiskLevel } from "@/types/proto-es/v1/common_pb";
+import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
+import {
+ Issue_ApprovalStatus,
+ Issue_Type,
+ IssueStatus,
+} from "@/types/proto-es/v1/issue_service_pb";
+import {
+ buildIssueFilterBySearchParams,
+ displayRoleTitle,
+ extractIssueUID,
+ extractProjectResourceName,
+ formatAbsoluteDateTime,
+ getHighlightHTMLByRegExp,
+ getIssueRoute,
+ hasProjectPermissionV2,
+ humanizeTs,
+ PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE,
+ type SearchParams as VueSearchParams,
+} from "@/utils";
+import { DataExportPrepDrawer } from "./export-center/DataExportPrepDrawer";
+
+export function ProjectExportCenterPage({ projectId }: { projectId: string }) {
+ const { t } = useTranslation();
+ const issueStore = useIssueV1Store();
+ const projectStore = useProjectV1Store();
+
+ const projectName = `${projectNamePrefix}${projectId}`;
+ const project = useVueState(() => projectStore.getProjectByName(projectName));
+
+ const [showDrawer, setShowDrawer] = useState(false);
+
+ // Read-only scopes (always present, not removable)
+ const readonlyScopes: SearchScope[] = useMemo(
+ () => [
+ { id: "project", value: projectId, readonly: true },
+ {
+ id: "issue-type",
+ value: Issue_Type[Issue_Type.DATABASE_EXPORT],
+ readonly: true,
+ },
+ ],
+ [projectId]
+ );
+
+ const defaultSearchParams = useCallback(
+ (): SearchParams => ({
+ query: "",
+ scopes: [
+ ...readonlyScopes,
+ { id: "status", value: IssueStatus[IssueStatus.OPEN] },
+ ],
+ }),
+ [readonlyScopes]
+ );
+
+ const [searchParams, setSearchParams] =
+ useState<SearchParams>(defaultSearchParams);
+
+ // Reset search params when projectId changes (e.g. navigating between projects)
+ useEffect(() => {
+ setSearchParams(defaultSearchParams());
+ }, [projectId]);
+
+ // Scope options for the search bar
+ const scopeOptions: ScopeOption[] = useMemo(
+ () => [
+ {
+ id: "status",
+ title: t("common.status"),
+ options: [
+ {
+ value: IssueStatus[IssueStatus.OPEN],
+ keywords: ["open"],
+ render: () => <span>{t("issue.table.open")}</span>,
+ },
+ {
+ value: IssueStatus[IssueStatus.DONE],
+ keywords: ["done", "approved"],
+ render: () => <span>{t("common.approved")}</span>,
+ },
+ {
+ value: IssueStatus[IssueStatus.CANCELED],
+ keywords: ["canceled", "closed"],
+ render: () => <span>{t("common.closed")}</span>,
+ },
+ ],
+ },
+ {
+ id: "instance",
+ title: t("common.instance"),
+ },
+ {
+ id: "database",
+ title: t("common.database"),
+ },
+ {
+ id: "issue-label",
+ title: t("issue.labels"),
+ },
+ ],
+ [t]
+ );
+
+ // Permission check for creating export issues
+ const canCreate = useMemo(() => {
+ if (!project) return false;
+ return PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE.every((p) =>
+ hasProjectPermissionV2(project, p)
+ );
+ }, [project]);
+
+ // Build issue filter from search params
+ const issueFilter = useMemo(() => {
+ // Merge the readonly scopes into the search params for the filter builder
+ const merged: VueSearchParams = {
+ query: searchParams.query,
+ scopes: searchParams.scopes.map((s) => ({
+ id: s.id,
+ value: s.value,
+ })),
+ };
+ return buildIssueFilterBySearchParams(merged);
+ }, [searchParams]);
+
+ const fetchIssueList = useCallback(
+ async (params: { pageSize: number; pageToken: string }) => {
+ const { nextPageToken, issues } = await issueStore.listIssues({
+ find: issueFilter,
+ pageSize: params.pageSize,
+ pageToken: params.pageToken,
+ });
+ return { list: issues, nextPageToken };
+ },
+ [issueStore, issueFilter]
+ );
+
+ const paged = usePagedData<Issue>({
+ sessionKey: "export-center",
+ fetchList: fetchIssueList,
+ });
+
+ return (
+ <div className="py-4 w-full flex flex-col">
+ <div className="px-4">
+ <div className="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-2">
+ <div className="flex flex-1 max-w-full items-center gap-x-2">
+ <AdvancedSearch
+ params={searchParams}
+ onParamsChange={setSearchParams}
+ scopeOptions={scopeOptions}
+ placeholder={t("issue.advanced-search.filter")}
+ />
+ <Tooltip
+ content={
+ !canCreate
+ ? t("common.missing-required-permission", {
+ permissions:
+ PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE.join(", "),
+ })
+ : undefined
+ }
+ >
+ <Button disabled={!canCreate} onClick={() => setShowDrawer(true)}>
+ <Download className="h-4 w-4 mr-1" />
+ {t("quick-action.request-export-data")}
+ </Button>
+ </Tooltip>
+ </div>
+ </div>
+ </div>
+
+ {/* Issue list */}
+ <div className="mt-2">
+ {paged.isLoading ? (
+ <div className="flex justify-center py-8 text-control-light">
+ <Loader2 className="w-5 h-5 animate-spin" />
+ </div>
+ ) : paged.dataList.length === 0 ? (
+ <div className="flex justify-center py-8 text-control-light">
+ {t("common.no-data")}
+ </div>
+ ) : (
+ <>
+ {paged.dataList.map((issue) => (
+ <IssueListItem
+ key={issue.name}
+ issue={issue}
+ highlightText={searchParams.query}
+ />
+ ))}
+ </>
+ )}
+
+ {paged.dataList.length > 0 && (
+ <div className="mx-4 mt-3">
+ <PagedTableFooter
+ pageSize={paged.pageSize}
+ pageSizeOptions={paged.pageSizeOptions}
+ onPageSizeChange={paged.onPageSizeChange}
+ hasMore={paged.hasMore}
+ isFetchingMore={paged.isFetchingMore}
+ onLoadMore={paged.loadMore}
+ />
+ </div>
+ )}
+ </div>
+
+ <DataExportPrepDrawer
+ open={showDrawer}
+ onClose={() => setShowDrawer(false)}
+ projectName={project?.name ?? projectName}
+ />
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// IssueStatusIcon
+// ---------------------------------------------------------------------------
+
+function IssueStatusIcon({ status }: { status: IssueStatus }) {
+ switch (status) {
+ case IssueStatus.OPEN:
+ return (
+ <span className="flex items-center justify-center rounded-full w-5 h-5 bg-white border-2 border-info text-info shrink-0">
+ <span className="h-1.5 w-1.5 bg-info rounded-full" />
+ </span>
+ );
+ case IssueStatus.DONE:
+ return (
+ <span className="flex items-center justify-center rounded-full w-5 h-5 bg-success text-white shrink-0">
+ <svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
+ <path
+ fillRule="evenodd"
+ d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
+ clipRule="evenodd"
+ />
+ </svg>
+ </span>
+ );
+ case IssueStatus.CANCELED:
+ return (
+ <span className="flex items-center justify-center rounded-full w-5 h-5 bg-white border-2 text-gray-400 border-gray-400 shrink-0">
+ <svg className="w-5 h-5" fill="currentColor" viewBox="0 0 20 20">
+ <path
+ fillRule="evenodd"
+ d="M3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"
+ clipRule="evenodd"
+ />
+ </svg>
+ </span>
+ );
+ default:
+ return null;
+ }
+}
+
+// ---------------------------------------------------------------------------
+// RiskLevelIcon
+// ---------------------------------------------------------------------------
+
+function RiskLevelIcon({ riskLevel }: { riskLevel: RiskLevel }) {
+ const { t } = useTranslation();
+ if (
+ riskLevel === RiskLevel.RISK_LEVEL_UNSPECIFIED ||
+ riskLevel === RiskLevel.LOW
+ ) {
+ return null;
+ }
+ const color =
+ riskLevel === RiskLevel.MODERATE ? "text-warning" : "text-error";
+ const label =
+ riskLevel === RiskLevel.MODERATE
+ ? t("issue.risk-level.moderate")
+ : t("issue.risk-level.high");
+ return (
+ <Tooltip content={`${label} (${t("issue.risk-level.self")})`}>
+ <svg
+ className={`w-4 h-4 shrink-0 ${color}`}
+ fill="none"
+ viewBox="0 0 24 24"
+ stroke="currentColor"
+ strokeWidth={2}
+ >
+ <path
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4.5c-.77-.833-2.694-.833-3.464 0L3.34 16.5c-.77.833.192 2.5 1.732 2.5z"
+ />
+ </svg>
+ </Tooltip>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// IssueApprovalStatusTag
+// ---------------------------------------------------------------------------
+
+function IssueApprovalStatusTag({ issue }: { issue: Issue }) {
+ const { t } = useTranslation();
+ const approvalSteps = issue.approvalTemplate?.flow?.roles ?? [];
+
+ if (issue.approvalStatus === Issue_ApprovalStatus.CHECKING) {
+ return (
+ <span className="shrink-0 mt-1 inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600">
+ {t("custom-approval.issue-review.generating-approval-flow")}
+ </span>
+ );
+ }
+
+ const progressText = t("issue.table.approval-progress", {
+ approved: issue.approvers.length,
+ total: approvalSteps.length,
+ });
+
+ if (approvalSteps.length > 0) {
+ const status = issue.approvalStatus;
+ if (status === Issue_ApprovalStatus.APPROVED) {
+ return (
+ <div className="shrink-0 flex flex-row sm:flex-col items-center sm:items-end gap-x-1.5 sm:gap-x-0 mt-1">
+ <span className="inline-flex items-center rounded-full bg-success/10 text-success px-2 py-0.5 text-xs">
+ {t("issue.table.approved")}
+ </span>
+ <span className="text-xs text-control-light whitespace-nowrap sm:mt-1">
+ {progressText}
+ </span>
+ </div>
+ );
+ }
+ if (status === Issue_ApprovalStatus.REJECTED) {
+ return (
+ <div className="shrink-0 flex flex-row sm:flex-col items-center sm:items-end gap-x-1.5 sm:gap-x-0 mt-1">
+ <span className="inline-flex items-center rounded-full bg-warning/10 text-warning px-2 py-0.5 text-xs">
+ {t("common.rejected")}
+ </span>
+ <span className="text-xs text-control-light whitespace-nowrap sm:mt-1">
+ {progressText}
+ </span>
+ </div>
+ );
+ }
+ if (status === Issue_ApprovalStatus.PENDING) {
+ const currentRoleIndex = issue.approvers.length;
+ const role = approvalSteps[currentRoleIndex];
+ const roleName = role ? displayRoleTitle(role) : "";
+ return (
+ <div className="shrink-0 flex flex-row sm:flex-col items-center sm:items-end gap-x-1.5 sm:gap-x-0 mt-1">
+ <span className="inline-flex items-center rounded-full bg-gray-100 px-2 py-0.5 text-xs text-gray-600">
+ {progressText}
+ </span>
+ {roleName && (
+ <span className="text-xs text-control-light whitespace-nowrap sm:mt-1">
+ {t("issue.table.waiting-role", { role: roleName })}
+ </span>
+ )}
+ </div>
+ );
+ }
+ }
+
+ // No approval required
+ return (
+ <span className="shrink-0 mt-1 inline-flex items-center rounded-full bg-gray-50 px-2 py-0.5 text-xs text-gray-500">
+ {t("custom-approval.approval-flow.skip")}
+ </span>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// IssueListItem
+// ---------------------------------------------------------------------------
+
+function IssueListItem({
+ issue,
+ highlightText = "",
+}: {
+ issue: Issue;
+ highlightText?: string;
+}) {
+ const { t } = useTranslation();
+ const userStore = useUserStore();
+ const projectStore = useProjectV1Store();
+
+ const creator =
+ userStore.getUserByIdentifier(issue.creator) || unknownUser(issue.creator);
+
+ const issueProject = useVueState(() =>
+ projectStore.getProjectByName(
+ `${projectNamePrefix}${extractProjectResourceName(issue.name)}`
+ )
+ );
+
+ const createTimeTs = Math.floor(
+ getTimeForPbTimestampProtoEs(issue.createTime, 0) / 1000
+ );
+
+ const issueUrl = useMemo(() => {
+ const issueRoute = getIssueRoute(issue);
+ return router.resolve({
+ name: issueRoute.name,
+ params: issueRoute.params,
+ }).fullPath;
+ }, [issue.name]);
+
+ const onRowClick = useCallback(
+ (e: React.MouseEvent) => {
+ if (e.ctrlKey || e.metaKey) {
+ window.open(issueUrl, "_blank");
+ } else {
+ router.push(issueUrl);
+ }
+ },
+ [issueUrl]
+ );
+
+ // Labels
+ const validLabels = useMemo(() => {
+ if (!issueProject?.issueLabels) return [];
+ const pool = new Set(
+ issueProject.issueLabels.map((l: { value: string }) => l.value)
+ );
+ const validValues = issue.labels.filter((l) => pool.has(l));
+ return issueProject.issueLabels.filter((l: { value: string }) =>
+ validValues.includes(l.value)
+ );
+ }, [issue.labels, issueProject]);
+
+ // Highlight
+ const highlightWords = useMemo(
+ () => (highlightText ? highlightText.toLowerCase().split(" ") : []),
+ [highlightText]
+ );
+
+ const highlightedTitle = useMemo(
+ () =>
+ getHighlightHTMLByRegExp(
+ issue.title,
+ highlightWords,
+ false,
+ "bg-yellow-100"
+ ),
+ [issue.title, highlightWords]
+ );
+
+ const highlightedDescription = useMemo(
+ () =>
+ getHighlightHTMLByRegExp(
+ issue.description,
+ highlightWords,
+ false,
+ "bg-yellow-100"
+ ),
+ [issue.description, highlightWords]
+ );
+
+ const expanded =
+ highlightText &&
+ issue.description &&
+ highlightWords.some((word) =>
+ issue.description.toLowerCase().includes(word)
+ );
+
+ return (
+ <div
+ className="flex items-start gap-x-2 px-3 sm:px-4 py-3 cursor-pointer border-b border-gray-100 hover:bg-gray-50"
+ onClick={onRowClick}
+ >
+ {/* Left: issue content */}
+ <div className="flex-1 min-w-0 flex flex-col sm:flex-row sm:items-start sm:gap-x-2">
+ <div className="flex-1 min-w-0">
+ {/* Line 1: status icon + title + labels */}
+ <div className="flex items-center gap-x-1.5">
+ <div className="h-6 flex justify-center items-center">
+ <IssueStatusIcon status={issue.status} />
+ </div>
+ {issue.title ? (
+ <a
+ href={issueUrl}
+ className="font-medium text-main text-base truncate hover:underline"
+ onClick={(e) => e.stopPropagation()}
+ dangerouslySetInnerHTML={{ __html: highlightedTitle }}
+ />
+ ) : (
+ <a
+ href={issueUrl}
+ className="font-medium text-base truncate hover:underline italic text-gray-400"
+ onClick={(e) => e.stopPropagation()}
+ >
+ {t("common.untitled")}
+ </a>
+ )}
+ <RiskLevelIcon riskLevel={issue.riskLevel} />
+ {validLabels.map((label: { value: string; color: string }) => (
+ <span
+ key={label.value}
+ className="inline-flex items-center gap-x-1 px-1.5 py-0.5 rounded text-xs whitespace-nowrap border shrink-0"
+ >
+ <span
+ className="w-2.5 h-2.5 rounded-sm shrink-0"
+ style={{ backgroundColor: label.color }}
+ />
+ {label.value}
+ </span>
+ ))}
+ </div>
+ {/* Line 2: metadata */}
+ <div className="flex items-center flex-wrap gap-x-1 text-xs text-control-light mt-1">
+ <span className="opacity-80">#{extractIssueUID(issue.name)}</span>
+ <span>&middot;</span>
+ {t("common.created")}
+ <Tooltip content={formatAbsoluteDateTime(createTimeTs * 1000)}>
+ <span>{humanizeTs(createTimeTs)}</span>
+ </Tooltip>
+ <span>&middot;</span>
+ <a
+ className="hover:underline"
+ href="#"
+ onClick={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ router.push({
+ name: WORKSPACE_ROUTE_USER_PROFILE,
+ params: { principalEmail: creator.email },
+ });
+ }}
+ >
+ {creator.title}
+ </a>
+ </div>
+ {/* Expanded description for search highlights */}
+ {expanded && (
+ <div
+ className="mt-2 max-h-80 overflow-auto whitespace-pre-wrap break-all text-sm text-control-light"
+ dangerouslySetInnerHTML={{
+ __html: highlightedDescription,
+ }}
+ />
+ )}
+ </div>
+
+ {/* Right: approval status tag */}
+ <IssueApprovalStatusTag issue={issue} />
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/react/pages/project/export-center/DataExportPrepDrawer.tsx b/frontend/src/react/pages/project/export-center/DataExportPrepDrawer.tsx
new file mode 100644
index 0000000000..1b540f23c6
--- /dev/null
+++ b/frontend/src/react/pages/project/export-center/DataExportPrepDrawer.tsx
@@ -0,0 +1,1095 @@
+import { create } from "@bufbuild/protobuf";
+import {
+ ChevronDown,
+ Database as DatabaseIcon,
+ FolderTree,
+ Loader2,
+ X,
+} from "lucide-react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { v4 as uuidv4 } from "uuid";
+import { EngineIconPath } from "@/components/InstanceForm/constants";
+import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";
+import { Button } from "@/react/components/ui/button";
+import { Switch } from "@/react/components/ui/switch";
+import { useClickOutside } from "@/react/hooks/useClickOutside";
+import { useEscapeKey } from "@/react/hooks/useEscapeKey";
+import { useSessionPageSize } from "@/react/hooks/useSessionPageSize";
+import { useVueState } from "@/react/hooks/useVueState";
+import { cn } from "@/react/lib/utils";
+import { router } from "@/router";
+import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
+import {
+ DEFAULT_MAX_RESULT_SIZE_IN_MB,
+ experimentalCreateIssueByPlan,
+ pushNotification,
+ useCurrentUserV1,
+ useDatabaseV1Store,
+ useDBGroupStore,
+ useProjectV1Store,
+ useSettingV1Store,
+ useSheetV1Store,
+} from "@/store";
+import { isValidDatabaseGroupName, isValidDatabaseName } from "@/types";
+import { ExportFormat } from "@/types/proto-es/v1/common_pb";
+import type { DatabaseGroup } from "@/types/proto-es/v1/database_group_service_pb";
+import { DatabaseGroupView } from "@/types/proto-es/v1/database_group_service_pb";
+import type { Database } from "@/types/proto-es/v1/database_service_pb";
+import { Issue_Type, IssueSchema } from "@/types/proto-es/v1/issue_service_pb";
+import {
+ Plan_ExportDataConfigSchema,
+ Plan_SpecSchema,
+ PlanSchema,
+} from "@/types/proto-es/v1/plan_service_pb";
+import { SheetSchema } from "@/types/proto-es/v1/sheet_service_pb";
+import {
+ extractDatabaseGroupName,
+ extractDatabaseResourceName,
+ extractIssueUID,
+ extractProjectResourceName,
+ generatePlanTitle,
+ getDatabaseEnvironment,
+ getInstanceResource,
+ setSheetStatement,
+} from "@/utils";
+
+// ---------------------------------------------------------------------------
+// Main Drawer
+// ---------------------------------------------------------------------------
+
+export interface DataExportPrepSeed {
+ /** Pre-selected database resource names. */
+ selectedDatabaseNames?: string[];
+ /** Start directly at step 2 (Configure). */
+ step?: 1 | 2;
+}
+
+export interface DataExportPrepDrawerProps {
+ open: boolean;
+ onClose: () => void;
+ projectName: string;
+ seed?: DataExportPrepSeed;
+}
+
+type Step = 1 | 2;
+
+const EXPORT_FORMATS = [
+ { value: ExportFormat.CSV, label: "CSV" },
+ { value: ExportFormat.JSON, label: "JSON" },
+ { value: ExportFormat.SQL, label: "SQL" },
+ { value: ExportFormat.XLSX, label: "XLSX" },
+] as const;
+
+export function DataExportPrepDrawer({
+ open,
+ onClose,
+ projectName,
+ seed,
+}: DataExportPrepDrawerProps) {
+ const { t } = useTranslation();
+ const currentUser = useCurrentUserV1();
+ const sheetStore = useSheetV1Store();
+ const dbStore = useDatabaseV1Store();
+ const dbGroupStore = useDBGroupStore();
+ const projectStore = useProjectV1Store();
+ const settingStore = useSettingV1Store();
+
+ const project = useVueState(() => projectStore.getProjectByName(projectName));
+
+ const [step, setStep] = useState<Step>(1);
+ const [creating, setCreating] = useState(false);
+
+ // Step 1: target selection
+ const [changeSource, setChangeSource] = useState<"DATABASE" | "GROUP">(
+ "DATABASE"
+ );
+ const [selectedDatabaseNames, setSelectedDatabaseNames] = useState<
+ Set<string>
+ >(new Set());
+ const [selectedDatabaseGroup, setSelectedDatabaseGroup] = useState<
+ string | undefined
+ >();
+
+ // Step 2: form fields
+ const [title, setTitle] = useState("");
+ const [titleEdited, setTitleEdited] = useState(false);
+ const [description, setDescription] = useState("");
+ const [labels, setLabels] = useState<string[]>([]);
+ const [statement, setStatement] = useState("");
+ const [format, setFormat] = useState(ExportFormat.JSON);
+ const [password, setPassword] = useState("");
+ const [passwordEnabled, setPasswordEnabled] = useState(false);
+
+ const targets = useMemo(() => {
+ if (changeSource === "DATABASE") {
+ return [...selectedDatabaseNames];
+ }
+ return selectedDatabaseGroup ? [selectedDatabaseGroup] : [];
+ }, [changeSource, selectedDatabaseNames, selectedDatabaseGroup]);
+
+ const validSelectState = targets.length > 0;
+
+ const targetTitleNames = useMemo(
+ () =>
+ targets.map((target) => {
+ if (isValidDatabaseName(target)) {
+ return extractDatabaseResourceName(target).databaseName;
+ }
+ if (isValidDatabaseGroupName(target)) {
+ return extractDatabaseGroupName(target);
+ }
+ return target;
+ }),
+ [targets]
+ );
+
+ const canCreate = useMemo(() => {
+ if (!validSelectState) return false;
+ if (project?.enforceIssueTitle && !title.trim()) return false;
+ if (project?.forceIssueLabels && labels.length === 0) return false;
+ if (!statement.trim()) return false;
+ return true;
+ }, [validSelectState, project, title, labels, statement]);
+
+ const effectiveTitle = useMemo(() => {
+ const trimmed = title.trim();
+ if (trimmed) return trimmed;
+ return generatePlanTitle("bb.plan.export-data", targetTitleNames);
+ }, [title, targetTitleNames]);
+
+ // Auto-generate title when targets change
+ const targetKey = targetTitleNames.join(",");
+ useEffect(() => {
+ if (project?.enforceIssueTitle) return;
+ if (targetTitleNames.length === 0) return;
+ if (titleEdited && title.trim()) return;
+ setTitle(generatePlanTitle("bb.plan.export-data", targetTitleNames));
+ }, [targetKey]);
+
+ // Fetch database/group metadata for display
+ useEffect(() => {
+ for (const target of targets) {
+ if (isValidDatabaseName(target)) {
+ dbStore.getOrFetchDatabaseByName(target);
+ } else if (isValidDatabaseGroupName(target)) {
+ dbGroupStore.getOrFetchDBGroupByName(target, {
+ view: DatabaseGroupView.FULL,
+ });
+ }
+ }
+ }, [targets, dbStore, dbGroupStore]);
+
+ // Reset on open or when seed changes while open
+ const seedKey = seed?.selectedDatabaseNames?.join(",") ?? "";
+ const seedStep = seed?.step ?? 1;
+ useEffect(() => {
+ if (open) {
+ setStep(seedStep);
+ setCreating(false);
+ setChangeSource("DATABASE");
+ setSelectedDatabaseNames(new Set(seed?.selectedDatabaseNames ?? []));
+ setSelectedDatabaseGroup(undefined);
+ setTitle("");
+ setTitleEdited(false);
+ setDescription("");
+ setLabels([]);
+ setStatement("");
+ setFormat(ExportFormat.JSON);
+ setPassword("");
+ setPasswordEnabled(false);
+ }
+ }, [open, seedKey, seedStep]);
+
+ // Close the drawer if the project context changes while open
+ useEffect(() => {
+ if (open) {
+ onClose();
+ }
+ }, [projectName]);
+
+ useEscapeKey(open, onClose);
+
+ // Limits
+ const maximumResultSize = useVueState(() => {
+ let size = settingStore.workspaceProfile.sqlResultSize;
+ if (size <= 0) {
+ size = BigInt(DEFAULT_MAX_RESULT_SIZE_IN_MB * 1024 * 1024);
+ }
+ return Number(size) / 1024 / 1024;
+ });
+
+ const handleCancel = () => {
+ if (step === 2 && !seed?.step) {
+ // Only go back to step 1 if the user navigated here naturally.
+ // When seeded at step 2 (e.g. from database list), close instead.
+ setStep(1);
+ return;
+ }
+ onClose();
+ };
+
+ const handleCreate = async () => {
+ if (creating || !canCreate || !project) return;
+ setCreating(true);
+
+ try {
+ const sheet = create(SheetSchema, {});
+ setSheetStatement(sheet, statement);
+ const createdSheet = await sheetStore.createSheet(project.name, sheet);
+
+ const spec = create(Plan_SpecSchema, {
+ id: uuidv4(),
+ config: {
+ case: "exportDataConfig",
+ value: create(Plan_ExportDataConfigSchema, {
+ targets,
+ sheet: createdSheet.name,
+ format,
+ password: passwordEnabled ? password : "",
+ }),
+ },
+ });
+
+ const planCreate = create(PlanSchema, {
+ title: effectiveTitle,
+ description,
+ specs: [spec],
+ creator: currentUser.value.name,
+ });
+
+ const issueCreate = create(IssueSchema, {
+ title: effectiveTitle,
+ description,
+ creator: `users/${currentUser.value.email}`,
+ labels,
+ type: Issue_Type.DATABASE_EXPORT,
+ });
+
+ const { createdIssue } = await experimentalCreateIssueByPlan(
+ project,
+ issueCreate,
+ planCreate,
+ { skipRollout: true }
+ );
+
+ onClose();
+ router.push({
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(createdIssue.name),
+ issueId: extractIssueUID(createdIssue.name),
+ },
+ });
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("common.failed"),
+ description: String(error),
+ });
+ } finally {
+ setCreating(false);
+ }
+ };
+
+ if (!open) return null;
+
+ return (
+ <div className="fixed inset-0 z-50 flex">
+ <div className="fixed inset-0 bg-black/50" onClick={onClose} />
+ <div className="ml-auto relative bg-white w-[calc(100vw-8rem)] lg:w-240 max-w-[calc(100vw-8rem)] h-full shadow-lg flex flex-col">
+ {/* Header */}
+ <div className="px-6 py-4 border-b border-control-border">
+ <div className="flex flex-col gap-y-3">
+ <div className="flex items-center justify-between">
+ <span className="text-lg font-semibold">
+ {t("custom-approval.risk-rule.risk.namespace.data_export")}
+ </span>
+ <button
+ className="p-1 hover:bg-control-bg rounded"
+ onClick={onClose}
+ >
+ <X className="w-4 h-4" />
+ </button>
+ </div>
+ {/* Steps indicator */}
+ <div className="flex items-center gap-x-4 text-sm">
+ <StepIndicator
+ number={1}
+ label={t("plan.targets.title")}
+ active={step === 1}
+ completed={step > 1}
+ />
+ <div className="h-px w-8 bg-gray-300" />
+ <StepIndicator
+ number={2}
+ label={t("common.configure")}
+ active={step === 2}
+ completed={false}
+ />
+ </div>
+ </div>
+ </div>
+
+ {/* Content */}
+ <div className="flex-1 overflow-y-auto p-6">
+ {step === 1 ? (
+ <DatabaseAndGroupSelector
+ projectName={projectName}
+ changeSource={changeSource}
+ onChangeSourceChange={setChangeSource}
+ selectedDatabaseNames={selectedDatabaseNames}
+ onSelectedDatabaseNamesChange={setSelectedDatabaseNames}
+ selectedDatabaseGroup={selectedDatabaseGroup}
+ onSelectedDatabaseGroupChange={setSelectedDatabaseGroup}
+ />
+ ) : (
+ <div className="flex flex-col gap-y-4 pb-2">
+ {/* Targets display */}
+ <div className="flex flex-col gap-y-2">
+ <h3 className="text-base font-medium">
+ {t("plan.targets.title")}
+ </h3>
+ <div className="flex flex-wrap gap-2">
+ {targets.map((target) => (
+ <TargetBadge key={target} target={target} />
+ ))}
+ </div>
+ </div>
+
+ {/* Title */}
+ <div className="flex flex-col gap-y-2">
+ <label className="text-sm font-medium text-control">
+ {t("common.title")}
+ {project?.enforceIssueTitle && (
+ <span className="text-error"> *</span>
+ )}
+ </label>
+ <input
+ className="w-full border border-control-border rounded-sm px-3 py-2 text-sm focus:outline-none focus:border-accent"
+ value={title}
+ placeholder={t("common.title")}
+ onChange={(e) => {
+ setTitle(e.target.value);
+ setTitleEdited(true);
+ }}
+ />
+ </div>
+
+ {/* Description */}
+ <div className="flex flex-col gap-y-2">
+ <label className="text-sm font-medium text-control">
+ {t("common.description")}
+ </label>
+ <textarea
+ className="w-full border border-control-border rounded-sm px-3 py-2 text-sm focus:outline-none focus:border-accent min-h-[6rem] resize-y"
+ value={description}
+ placeholder={t("common.description")}
+ onChange={(e) => setDescription(e.target.value)}
+ />
+ </div>
+
+ {/* Labels */}
+ {project &&
+ (project.issueLabels.length > 0 ||
+ project.forceIssueLabels) && (
+ <IssueLabelSelect
+ labels={project.issueLabels}
+ selected={labels}
+ required={project.forceIssueLabels}
+ onChange={setLabels}
+ />
+ )}
+
+ {/* SQL */}
+ <div className="flex flex-col gap-y-2">
+ <label className="text-sm font-medium text-control">
+ {t("common.sql")}
+ <span className="text-error"> *</span>
+ </label>
+ <textarea
+ className="w-full h-96 border border-control-border rounded-sm px-3 py-2 text-sm font-mono focus:outline-none focus:border-accent resize-y"
+ value={statement}
+ placeholder="SELECT ..."
+ onChange={(e) => setStatement(e.target.value)}
+ />
+ </div>
+
+ {/* Export options */}
+ <div className="flex flex-col gap-y-2">
+ <h3 className="text-base">{t("issue.data-export.options")}</h3>
+ <div className="p-3 border rounded-sm flex flex-col gap-y-3">
+ {/* Format */}
+ <div className="flex items-center gap-4">
+ <span className="text-sm">
+ {t("issue.data-export.format")}
+ </span>
+ <div className="flex items-center gap-x-3">
+ {EXPORT_FORMATS.map((f) => (
+ <label
+ key={f.value}
+ className="inline-flex items-center gap-x-1.5 text-sm cursor-pointer"
+ >
+ <input
+ type="radio"
+ name="export-format"
+ checked={format === f.value}
+ onChange={() => setFormat(f.value)}
+ className="accent-accent"
+ />
+ {f.label}
+ </label>
+ ))}
+ </div>
+ </div>
+
+ {/* Password */}
+ <div className="flex flex-col gap-y-2">
+ <div className="flex items-center gap-x-2">
+ <Switch
+ checked={passwordEnabled}
+ onCheckedChange={(checked) => {
+ setPasswordEnabled(checked);
+ if (!checked) setPassword("");
+ }}
+ />
+ <span className="text-sm">
+ {t("export-data.password-optional")}
+ </span>
+ </div>
+ {passwordEnabled && (
+ <input
+ type="password"
+ className="w-full border border-control-border rounded-sm px-3 py-2 text-sm focus:outline-none focus:border-accent"
+ value={password}
+ placeholder={t("export-data.password-optional")}
+ onChange={(e) => setPassword(e.target.value)}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+
+ {/* Limits */}
+ <div className="w-full flex flex-col gap-y-2">
+ <h3 className="text-base font-medium">
+ {t("issue.data-export.limits")}
+ </h3>
+ <div className="flex items-center gap-x-2">
+ <span className="text-sm">
+ {t(
+ "settings.general.workspace.maximum-sql-result.size.self"
+ )}
+ </span>
+ <span className="font-medium">{maximumResultSize} MB</span>
+ </div>
+ </div>
+ </div>
+ )}
+ </div>
+
+ {/* Footer */}
+ <div className="px-6 py-4 border-t border-control-border flex items-center justify-end gap-x-2">
+ <Button variant="outline" onClick={handleCancel}>
+ {step === 1 ? t("common.cancel") : t("common.back")}
+ </Button>
+ {step === 1 ? (
+ <Button disabled={!validSelectState} onClick={() => setStep(2)}>
+ {t("common.next")}
+ </Button>
+ ) : (
+ <Button disabled={!canCreate || creating} onClick={handleCreate}>
+ {creating && <Loader2 className="w-4 h-4 mr-1 animate-spin" />}
+ {t("common.create")}
+ </Button>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// StepIndicator
+// ---------------------------------------------------------------------------
+
+function StepIndicator({
+ number,
+ label,
+ active,
+ completed,
+}: {
+ number: number;
+ label: string;
+ active: boolean;
+ completed: boolean;
+}) {
+ return (
+ <div className="flex items-center gap-x-2">
+ <span
+ className={cn(
+ "w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium",
+ active
+ ? "bg-accent text-white"
+ : completed
+ ? "bg-success text-white"
+ : "bg-gray-200 text-gray-500"
+ )}
+ >
+ {completed ? (
+ <svg className="w-3.5 h-3.5" fill="currentColor" viewBox="0 0 20 20">
+ <path
+ fillRule="evenodd"
+ d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
+ clipRule="evenodd"
+ />
+ </svg>
+ ) : (
+ number
+ )}
+ </span>
+ <span
+ className={cn(
+ "text-sm",
+ active ? "text-main font-medium" : "text-control-light"
+ )}
+ >
+ {label}
+ </span>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// TargetBadge (database or group display in step 2)
+// ---------------------------------------------------------------------------
+
+function TargetBadge({ target }: { target: string }) {
+ const dbStore = useDatabaseV1Store();
+ const isDatabaseTarget = isValidDatabaseName(target);
+ const isGroupTarget = isValidDatabaseGroupName(target);
+
+ // Always call useVueState unconditionally (rules of hooks)
+ const db = useVueState(() =>
+ isDatabaseTarget ? dbStore.getDatabaseByName(target) : undefined
+ );
+
+ if (isDatabaseTarget && db) {
+ const inst = getInstanceResource(db);
+ const env = getDatabaseEnvironment(db);
+ const { databaseName } = extractDatabaseResourceName(target);
+ return (
+ <div className="inline-flex items-center gap-2 px-2 py-1.5 border rounded-sm min-w-0">
+ {inst && EngineIconPath[inst.engine] && (
+ <img
+ className="h-4 w-4 shrink-0"
+ src={EngineIconPath[inst.engine]}
+ alt=""
+ />
+ )}
+ {env && <EnvironmentLabel environmentName={env.name} />}
+ <span className="text-sm truncate">{databaseName}</span>
+ </div>
+ );
+ }
+
+ if (isGroupTarget) {
+ const groupName = extractDatabaseGroupName(target);
+ return (
+ <div className="inline-flex items-center gap-2 px-2 py-1.5 border rounded-sm min-w-0">
+ <FolderTree className="w-4 h-4 shrink-0 text-control-light" />
+ <span className="text-sm truncate">{groupName}</span>
+ </div>
+ );
+ }
+
+ return (
+ <div className="inline-flex items-center gap-2 px-2 py-1.5 border rounded-sm min-w-0">
+ <span className="text-sm truncate">{target}</span>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// IssueLabelSelect (reusable for export form)
+// ---------------------------------------------------------------------------
+
+function IssueLabelSelect({
+ labels,
+ selected,
+ required,
+ onChange,
+}: {
+ labels: { value: string; color: string }[];
+ selected: string[];
+ required: boolean;
+ onChange: (labels: string[]) => void;
+}) {
+ const { t } = useTranslation();
+ const [open, setOpen] = useState(false);
+ const containerRef = useRef<HTMLDivElement>(null);
+ const closeDropdown = useCallback(() => setOpen(false), []);
+ useClickOutside(containerRef, open, closeDropdown);
+
+ const toggleLabel = (value: string) => {
+ onChange(
+ selected.includes(value)
+ ? selected.filter((l) => l !== value)
+ : [...selected, value]
+ );
+ };
+
+ return (
+ <div className="flex flex-col gap-y-2">
+ <label className="text-sm font-medium text-control">
+ {t("issue.labels")}
+ {required && <span className="text-error"> *</span>}
+ </label>
+ <div ref={containerRef} className="relative">
+ <button
+ type="button"
+ className={cn(
+ "w-full flex items-center justify-between gap-2 border border-control-border rounded-sm h-9 px-3 text-sm bg-white text-left transition-colors",
+ "hover:border-gray-400",
+ open && "border-accent shadow-[0_0_0_1px_var(--color-accent)]"
+ )}
+ onClick={() => setOpen(!open)}
+ >
+ {selected.length > 0 ? (
+ <div className="flex items-center gap-1.5 truncate">
+ {selected.map((val) => {
+ const label = labels.find((l) => l.value === val);
+ return (
+ <span
+ key={val}
+ className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-gray-100 text-xs"
+ >
+ <span
+ className="w-2.5 h-2.5 rounded-sm shrink-0"
+ style={{ backgroundColor: label?.color }}
+ />
+ {val}
+ <X
+ className="w-3 h-3 text-gray-400 hover:text-gray-600"
+ onClick={(e) => {
+ e.stopPropagation();
+ toggleLabel(val);
+ }}
+ />
+ </span>
+ );
+ })}
+ </div>
+ ) : (
+ <span className="text-gray-400">{t("common.select")}</span>
+ )}
+ <ChevronDown
+ className={cn(
+ "w-4 h-4 text-gray-400 shrink-0 transition-transform",
+ open && "rotate-180"
+ )}
+ />
+ </button>
+ {open && (
+ <div className="absolute z-50 mt-1 w-full bg-white border border-gray-200 rounded-sm shadow-lg overflow-hidden">
+ <div className="max-h-60 overflow-y-auto">
+ {labels.length === 0 ? (
+ <div className="px-3 py-6 text-sm text-gray-400 text-center">
+ {t("common.no-data")}
+ </div>
+ ) : (
+ labels.map((label) => {
+ const isSelected = selected.includes(label.value);
+ return (
+ <button
+ key={label.value}
+ type="button"
+ className="w-full text-left px-3 py-2 text-sm flex items-center gap-2 hover:bg-gray-50 transition-colors"
+ onClick={() => toggleLabel(label.value)}
+ >
+ <input
+ type="checkbox"
+ checked={isSelected}
+ readOnly
+ className="rounded border-gray-300 accent-accent"
+ />
+ <span
+ className="w-4 h-4 rounded-sm shrink-0"
+ style={{ backgroundColor: label.color }}
+ />
+ <span>{label.value}</span>
+ </button>
+ );
+ })
+ )}
+ </div>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// DatabaseAndGroupSelector (step 1)
+// ---------------------------------------------------------------------------
+
+function DatabaseAndGroupSelector({
+ projectName,
+ changeSource,
+ onChangeSourceChange,
+ selectedDatabaseNames,
+ onSelectedDatabaseNamesChange,
+ selectedDatabaseGroup,
+ onSelectedDatabaseGroupChange,
+}: {
+ projectName: string;
+ changeSource: "DATABASE" | "GROUP";
+ onChangeSourceChange: (source: "DATABASE" | "GROUP") => void;
+ selectedDatabaseNames: Set<string>;
+ onSelectedDatabaseNamesChange: (names: Set<string>) => void;
+ selectedDatabaseGroup: string | undefined;
+ onSelectedDatabaseGroupChange: (name: string | undefined) => void;
+}) {
+ const { t } = useTranslation();
+
+ return (
+ <div className="flex flex-col gap-y-3">
+ {/* Tab bar */}
+ <div className="flex border-b border-control-border">
+ <button
+ type="button"
+ className={cn(
+ "px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",
+ changeSource === "DATABASE"
+ ? "border-accent text-accent"
+ : "border-transparent text-control-light hover:text-control"
+ )}
+ onClick={() => onChangeSourceChange("DATABASE")}
+ >
+ <span className="inline-flex items-center gap-x-1.5">
+ <DatabaseIcon className="w-4 h-4" />
+ {t("common.databases")}
+ </span>
+ </button>
+ <button
+ type="button"
+ className={cn(
+ "px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors",
+ changeSource === "GROUP"
+ ? "border-accent text-accent"
+ : "border-transparent text-control-light hover:text-control"
+ )}
+ onClick={() => onChangeSourceChange("GROUP")}
+ >
+ <span className="inline-flex items-center gap-x-1.5">
+ <FolderTree className="w-4 h-4" />
+ {t("common.database-group")}
+ </span>
+ </button>
+ </div>
+
+ {changeSource === "DATABASE" ? (
+ <DatabaseSelector
+ projectName={projectName}
+ selectedNames={selectedDatabaseNames}
+ onSelectedNamesChange={onSelectedDatabaseNamesChange}
+ />
+ ) : (
+ <DatabaseGroupSelector
+ projectName={projectName}
+ selectedGroup={selectedDatabaseGroup}
+ onSelectedGroupChange={onSelectedDatabaseGroupChange}
+ />
+ )}
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// DatabaseSelector (table with checkboxes)
+// ---------------------------------------------------------------------------
+
+function DatabaseSelector({
+ projectName,
+ selectedNames,
+ onSelectedNamesChange,
+}: {
+ projectName: string;
+ selectedNames: Set<string>;
+ onSelectedNamesChange: (names: Set<string>) => void;
+}) {
+ const { t } = useTranslation();
+ const databaseStore = useDatabaseV1Store();
+
+ const [databases, setDatabases] = useState<Database[]>([]);
+ const [loading, setLoading] = useState(true);
+ const [hasMore, setHasMore] = useState(false);
+ const [isFetchingMore, setIsFetchingMore] = useState(false);
+ const [query, setQuery] = useState("");
+ const [pageSize] = useSessionPageSize("bb.export-db-selector");
+ const nextPageTokenRef = useRef("");
+ const fetchIdRef = useRef(0);
+
+ const doFetch = useCallback(
+ async (isRefresh: boolean) => {
+ const currentFetchId = ++fetchIdRef.current;
+ if (isRefresh) {
+ setLoading(true);
+ } else {
+ setIsFetchingMore(true);
+ }
+ try {
+ const token = isRefresh ? "" : nextPageTokenRef.current;
+ const filter = { query };
+ const result = await databaseStore.fetchDatabases({
+ parent: projectName,
+ pageSize,
+ pageToken: token || undefined,
+ filter,
+ });
+ if (currentFetchId !== fetchIdRef.current) return;
+ setDatabases((prev) =>
+ isRefresh ? result.databases : [...prev, ...result.databases]
+ );
+ nextPageTokenRef.current = result.nextPageToken;
+ setHasMore(Boolean(result.nextPageToken));
+ } finally {
+ if (currentFetchId === fetchIdRef.current) {
+ setLoading(false);
+ setIsFetchingMore(false);
+ }
+ }
+ },
+ [databaseStore, projectName, pageSize, query]
+ );
+
+ const isFirstLoad = useRef(true);
+ useEffect(() => {
+ if (isFirstLoad.current) {
+ isFirstLoad.current = false;
+ doFetch(true);
+ return;
+ }
+ const timer = setTimeout(() => doFetch(true), 300);
+ return () => clearTimeout(timer);
+ }, [doFetch]);
+
+ const toggleDatabase = (name: string) => {
+ const next = new Set(selectedNames);
+ if (next.has(name)) {
+ next.delete(name);
+ } else {
+ next.add(name);
+ }
+ onSelectedNamesChange(next);
+ };
+
+ const toggleAll = () => {
+ const allSelected = databases.every((db) => selectedNames.has(db.name));
+ if (allSelected) {
+ onSelectedNamesChange(new Set());
+ } else {
+ onSelectedNamesChange(new Set(databases.map((db) => db.name)));
+ }
+ };
+
+ const allSelected =
+ databases.length > 0 && databases.every((db) => selectedNames.has(db.name));
+ const someSelected =
+ databases.some((db) => selectedNames.has(db.name)) && !allSelected;
+
+ return (
+ <div className="flex flex-col gap-y-2">
+ <input
+ type="text"
+ className="w-full border border-control-border rounded-sm px-3 py-2 text-sm focus:outline-none focus:border-accent"
+ placeholder={t("database.filter-database")}
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ />
+
+ {loading ? (
+ <div className="flex justify-center py-8 text-control-light">
+ <Loader2 className="w-5 h-5 animate-spin" />
+ </div>
+ ) : databases.length === 0 ? (
+ <div className="flex justify-center py-8 text-control-light">
+ {t("common.no-data")}
+ </div>
+ ) : (
+ <>
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b text-left text-control-light">
+ <th className="py-2 pr-2 w-8">
+ <input
+ type="checkbox"
+ checked={allSelected}
+ ref={(el) => {
+ if (el) el.indeterminate = someSelected;
+ }}
+ onChange={toggleAll}
+ className="accent-accent"
+ />
+ </th>
+ <th className="py-2 pr-4 font-medium">
+ {t("common.database")}
+ </th>
+ <th className="py-2 pr-4 font-medium">
+ {t("common.environment")}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {databases.map((db) => {
+ const { databaseName } = extractDatabaseResourceName(db.name);
+ const inst = getInstanceResource(db);
+ const env = getDatabaseEnvironment(db);
+ const isSelected = selectedNames.has(db.name);
+ return (
+ <tr
+ key={db.name}
+ className={cn(
+ "border-b cursor-pointer hover:bg-gray-50",
+ isSelected && "bg-accent/5"
+ )}
+ onClick={() => toggleDatabase(db.name)}
+ >
+ <td className="py-2 pr-2">
+ <input
+ type="checkbox"
+ checked={isSelected}
+ readOnly
+ className="accent-accent"
+ />
+ </td>
+ <td className="py-2 pr-4">
+ <div className="flex items-center gap-x-1.5">
+ {inst && EngineIconPath[inst.engine] && (
+ <img
+ className="h-4 w-4 shrink-0"
+ src={EngineIconPath[inst.engine]}
+ alt=""
+ />
+ )}
+ <span>{databaseName}</span>
+ </div>
+ </td>
+ <td className="py-2 pr-4">
+ {env && <EnvironmentLabel environmentName={env.name} />}
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+
+ {hasMore && (
+ <div className="flex justify-center">
+ <Button
+ variant="ghost"
+ size="sm"
+ disabled={isFetchingMore}
+ onClick={() => doFetch(false)}
+ >
+ {isFetchingMore ? t("common.loading") : t("common.load-more")}
+ </Button>
+ </div>
+ )}
+ </>
+ )}
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// DatabaseGroupSelector
+// ---------------------------------------------------------------------------
+
+function DatabaseGroupSelector({
+ projectName,
+ selectedGroup,
+ onSelectedGroupChange,
+}: {
+ projectName: string;
+ selectedGroup: string | undefined;
+ onSelectedGroupChange: (name: string | undefined) => void;
+}) {
+ const { t } = useTranslation();
+ const dbGroupStore = useDBGroupStore();
+ const [groups, setGroups] = useState<DatabaseGroup[]>([]);
+ const [loading, setLoading] = useState(true);
+
+ useEffect(() => {
+ setLoading(true);
+ dbGroupStore
+ .fetchDBGroupListByProjectName(projectName, DatabaseGroupView.BASIC)
+ .then((result) => {
+ setGroups(result);
+ })
+ .finally(() => setLoading(false));
+ }, [projectName, dbGroupStore]);
+
+ if (loading) {
+ return (
+ <div className="flex justify-center py-8 text-control-light">
+ <Loader2 className="w-5 h-5 animate-spin" />
+ </div>
+ );
+ }
+
+ if (groups.length === 0) {
+ return (
+ <div className="flex justify-center py-8 text-control-light">
+ {t("common.no-data")}
+ </div>
+ );
+ }
+
+ return (
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b text-left text-control-light">
+ <th className="py-2 pr-2 w-8" />
+ <th className="py-2 pr-4 font-medium">
+ {t("common.database-group")}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {groups.map((group) => {
+ const isSelected = selectedGroup === group.name;
+ return (
+ <tr
+ key={group.name}
+ className={cn(
+ "border-b cursor-pointer hover:bg-gray-50",
+ isSelected && "bg-accent/5"
+ )}
+ onClick={() =>
+ onSelectedGroupChange(isSelected ? undefined : group.name)
+ }
+ >
+ <td className="py-2 pr-2">
+ <input
+ type="radio"
+ checked={isSelected}
+ readOnly
+ className="accent-accent"
+ />
+ </td>
+ <td className="py-2 pr-4">
+ <div className="flex items-center gap-x-1.5">
+ <FolderTree className="w-4 h-4 text-control-light shrink-0" />
+ <span>{extractDatabaseGroupName(group.name)}</span>
+ </div>
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ );
+}
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index 07f033ff8d..bce2206424 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -465,8 +465,11 @@ const projectV1Routes: RouteRecordRaw[] = [
title: () => t("export-center.self"),
requiredPermissionList: () => ["bb.issues.list", "bb.databases.list"],
},
- component: () => import("@/views/ExportCenter/index.vue"),
- props: true,
+ component: () => import("@/react/ReactPageMount.vue"),
+ props: (route) => ({
+ page: "ProjectExportCenterPage",
+ ...route.params,
+ }),
},
{
path: "releases",
diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vue
deleted file mode 100644
index c1becfdf02..0000000000
--- a/frontend/src/views/ExportCenter/index.vue
+++ /dev/null
@@ -1,195 +0,0 @@
-<template>
- <div class="py-4 w-full flex flex-col">
- <div class="px-4">
- <div
- class="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-2"
- >
- <div class="flex flex-1 max-w-full items-center gap-x-2">
- <IssueSearch
- v-model:params="state.params"
- class="flex-1"
- :override-scope-id-list="overrideSearchScopeIdList"
- >
- <template #searchbox-suffix>
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="specificProject"
- :permissions="[
- ...PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE
- ]"
- >
- <NButton
- type="primary"
- :disabled="slotProps.disabled"
- @click="state.showRequestExportPanel = true"
- >
- <template #icon>
- <DownloadIcon class="h-4 w-4" />
- </template>
- {{ $t("quick-action.request-export-data") }}
- </NButton>
- </PermissionGuardWrapper>
- </template>
- </IssueSearch>
- </div>
- </div>
- </div>
- <PagedTable
- ref="issuePagedTable"
- :session-key="'export-center'"
- :footer-class="'mx-4'"
- :fetch-list="fetchIssueList"
- >
- <template #table="{ list, loading }">
- <IssueListV1
- class="border-x-0"
- :loading="loading"
- :issue-list="list"
- :highlight-text="state.params.query"
- />
- </template>
- </PagedTable>
- </div>
-
- <DataExportPrepDrawer
- :show="state.showRequestExportPanel"
- :project-name="specificProject.name"
- @dismiss="state.showRequestExportPanel = false"
- />
-</template>
-
-<script lang="ts" setup>
-import { DownloadIcon } from "lucide-vue-next";
-import { NButton } from "naive-ui";
-import { computed, reactive, ref, watch } from "vue";
-import type { ComponentExposed } from "vue-component-type-helpers";
-import DataExportPrepDrawer from "@/components/DataExportPrepForm/DataExportPrepDrawer.vue";
-import IssueListV1 from "@/components/IssueV1/components/IssueListV1.vue";
-import IssueSearch from "@/components/IssueV1/components/IssueSearch/IssueSearch.vue";
-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import PagedTable from "@/components/v2/Model/PagedTable.vue";
-import {
- useIssueV1Store,
- useProjectByName,
- useRefreshIssueList,
-} from "@/store";
-import { projectNamePrefix } from "@/store/modules/v1/common";
-import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
-import { Issue_Type, IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
-import {
- buildIssueFilterBySearchParams,
- extractProjectResourceName,
- PERMISSIONS_FOR_DATABASE_EXPORT_ISSUE,
- type SearchParams,
- type SearchScope,
- type SearchScopeId,
-} from "@/utils";
-
-const props = defineProps<{
- projectId: string;
-}>();
-
-interface LocalState {
- showRequestExportPanel: boolean;
- params: SearchParams;
-}
-
-const { project: specificProject } = useProjectByName(
- computed(() => `${projectNamePrefix}${props.projectId}`)
-);
-
-const readonlyScopes = computed((): SearchScope[] => {
- return [
- {
- id: "project",
- value: extractProjectResourceName(specificProject.value.name),
- readonly: true,
- },
- {
- id: "issue-type",
- value: Issue_Type[Issue_Type.DATABASE_EXPORT],
- readonly: true,
- },
- ];
-});
-
-const defaultSearchParams = () => {
- const params: SearchParams = {
- query: "",
- scopes: [
- ...readonlyScopes.value,
- { id: "status", value: IssueStatus[IssueStatus.OPEN] },
- ],
- };
- return params;
-};
-
-const state = reactive<LocalState>({
- showRequestExportPanel: false,
- params: defaultSearchParams(),
-});
-
-watch(
- () => props.projectId,
- () => {
- state.params = defaultSearchParams();
- }
-);
-
-const issueStore = useIssueV1Store();
-const issuePagedTable = ref<ComponentExposed<typeof PagedTable<Issue>>>();
-
-const dataExportIssueSearchParams = computed(() => {
- // Default scopes with type.
- const defaultScopes = [];
- // If specific project is provided, add project scope.
- if (specificProject.value) {
- defaultScopes.push({
- id: "project",
- value: extractProjectResourceName(specificProject.value.name),
- });
- }
- return {
- query: state.params.query,
- scopes: [...state.params.scopes, ...defaultScopes],
- } as SearchParams;
-});
-
-const overrideSearchScopeIdList = computed(() => {
- const defaultScopeIdList: SearchScopeId[] = [
- "status",
- "instance",
- "database",
- "issue-label",
- ];
- return defaultScopeIdList;
-});
-
-const mergedIssueFilter = computed(() => {
- return buildIssueFilterBySearchParams(dataExportIssueSearchParams.value);
-});
-
-const fetchIssueList = async ({
- pageToken,
- pageSize,
-}: {
- pageToken: string;
- pageSize: number;
-}) => {
- const { nextPageToken, issues } = await issueStore.listIssues({
- find: mergedIssueFilter.value,
- pageSize,
- pageToken,
- });
- return {
- nextPageToken,
- list: issues,
- };
-};
-
-watch(
- () => JSON.stringify(mergedIssueFilter.value),
- () => issuePagedTable.value?.refresh()
-);
-useRefreshIssueList(() => issuePagedTable.value?.refresh());
-</script>
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index c835eb3f09..9f77a40185 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -40,23 +40,13 @@
:placeholder="$t('database.filter-database')"
:scope-options="scopeOptions"
/>
- <DatabaseOperations
- :databases="selectedDatabases"
- :instance-name="instance.name"
- :on-create-database="allowCreateDatabase && instance.state === State.ACTIVE ? createDatabase : undefined"
- @refresh="() => pagedDatabaseTableRef?.refresh()"
- @update="
- (databases) => pagedDatabaseTableRef?.updateCache(databases)
- "
- />
<PagedDatabaseTable
ref="pagedDatabaseTableRef"
mode="INSTANCE"
:footer-class="'pb-4'"
- :show-selection="true"
+ :show-selection="false"
:filter="filter"
:parent="instance.name"
- v-model:selected-database-names="state.selectedDatabaseNameList"
/>
</div>
</NTabPane>
@@ -66,16 +56,6 @@
</NTabs>
</div>
- <Drawer
- v-model:show="state.showCreateDatabaseModal"
- :title="$t('quick-action.create-db')"
- >
- <CreateDatabasePrepPanel
- :environment-name="formatEnvironmentName(environment.id)"
- :instance-name="instance.name"
- @dismiss="state.showCreateDatabaseModal = false"
- />
- </Drawer>
</template>
<script lang="tsx" setup>
@@ -88,7 +68,6 @@ import { BBAttention } from "@/bbkit";
import AdvancedSearch from "@/components/AdvancedSearch";
import { useCommonSearchScopeOptions } from "@/components/AdvancedSearch/useCommonSearchScopeOptions";
import ArchiveBanner from "@/components/ArchiveBanner.vue";
-import { CreateDatabasePrepPanel } from "@/components/CreateDatabasePrepForm";
import { EngineIcon } from "@/components/Icon";
import InstanceActionDropdown from "@/components/Instance/InstanceActionDropdown.vue";
import InstanceSyncButton from "@/components/Instance/InstanceSyncButton.vue";
@@ -97,31 +76,21 @@ import {
Form as InstanceFormBody,
Buttons as InstanceFormButtons,
} from "@/components/InstanceForm/";
-import { Drawer, InstanceRoleTable } from "@/components/v2";
-import {
- DatabaseOperations,
- PagedDatabaseTable,
-} from "@/components/v2/Model/DatabaseV1Table";
+import { InstanceRoleTable } from "@/components/v2";
+import { PagedDatabaseTable } from "@/components/v2/Model/DatabaseV1Table";
import { useRouteChangeGuard } from "@/composables/useRouteChangeGuard";
-import {
- useDatabaseV1Store,
- useEnvironmentV1Store,
- useInstanceV1Store,
-} from "@/store";
+import { useDatabaseV1Store, useInstanceV1Store } from "@/store";
import {
environmentNamePrefix,
instanceNamePrefix,
projectNamePrefix,
} from "@/store/modules/v1/common";
-import { formatEnvironmentName, isValidDatabaseName } from "@/types";
import { State } from "@/types/proto-es/v1/common_pb";
-import type { Database } from "@/types/proto-es/v1/database_service_pb";
import type { SearchParams, SearchScope } from "@/utils";
import {
CommonFilterScopeIdList,
getValueFromSearchParams,
getValuesFromSearchParams,
- instanceV1HasCreateDatabase,
instanceV1Name,
setDocumentTitle,
} from "@/utils";
@@ -132,9 +101,7 @@ const isInstanceHash = (x: unknown): x is InstanceHash =>
instanceHashList.includes(x as InstanceHash);
interface LocalState {
- showCreateDatabaseModal: boolean;
syncingSchema: boolean;
- selectedDatabaseNameList: string[];
params: SearchParams;
selectedTab: InstanceHash;
}
@@ -170,9 +137,7 @@ const readonlyScopes = computed((): SearchScope[] => [
]);
const state = reactive<LocalState>({
- showCreateDatabaseModal: false,
syncingSchema: false,
- selectedDatabaseNameList: [],
params: {
query: "",
scopes: [...readonlyScopes.value],
@@ -218,12 +183,6 @@ const instance = computed(() => {
);
});
-const environment = computed(() => {
- return useEnvironmentV1Store().getEnvironmentByName(
- instance.value.environment ?? ""
- );
-});
-
const selectedEnvironment = computed(() => {
return getValueFromSearchParams(
state.params,
@@ -251,10 +210,6 @@ const instanceRoleList = computed(() => {
return instance.value.roles;
});
-const allowCreateDatabase = computed(() => {
- return instanceV1HasCreateDatabase(instance.value);
-});
-
const syncSchema = async (enableFullSync: boolean) => {
await instanceV1Store.syncInstance(instance.value.name, enableFullSync);
// Remove the database list cache for the instance.
@@ -263,10 +218,6 @@ const syncSchema = async (enableFullSync: boolean) => {
// which shows an honest "syncing" message and checks for errors after 30 seconds
};
-const createDatabase = () => {
- state.showCreateDatabaseModal = true;
-};
-
watch(
() => instance.value.title,
(title) => {
@@ -274,10 +225,4 @@ watch(
},
{ immediate: true }
);
-
-const selectedDatabases = computed((): Database[] => {
- return state.selectedDatabaseNameList
- .map((databaseName) => databaseStore.getDatabaseByName(databaseName))
- .filter((database) => isValidDatabaseName(database.name));
-});
</script>
diff --git a/frontend/src/views/project/ProjectDatabaseDashboard.vue b/frontend/src/views/project/ProjectDatabaseDashboard.vue
deleted file mode 100644
index a62a9e842e..0000000000
--- a/frontend/src/views/project/ProjectDatabaseDashboard.vue
+++ /dev/null
@@ -1,18 +0,0 @@
-<template>
- <ProjectDatabasesPanel class="py-4" :project="project" />
-</template>
-
-<script lang="ts" setup>
-import { computed } from "vue";
-import ProjectDatabasesPanel from "@/components/ProjectDatabasesPanel.vue";
-import { useProjectByName } from "@/store";
-import { projectNamePrefix } from "@/store/modules/v1/common";
-
-const props = defineProps<{
- projectId: string;
-}>();
-
-const { project } = useProjectByName(
- computed(() => `${projectNamePrefix}${props.projectId}`)
-);
-</script>