Skip to content

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

chore: tweak plan pages (#16512)

boojack7c9b6ac7bd28
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
index 28764432e1..e97c0ef113 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
@@ -135,7 +135,7 @@ import { ActionConfirmModal } from "@/components/SchemaEditorLite";
import SQLUploadButton from "@/components/misc/SQLUploadButton.vue";
import {
PROJECT_V1_ROUTE_ISSUE_DETAIL,
- PROJECT_V1_ROUTE_PLAN_DETAIL,
+ PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
} from "@/router/dashboard/projectV1";
import {
pushNotification,
@@ -501,12 +501,13 @@ const handlePreviewIssue = async () => {
const routeInfo = {
name: state.planOnly
- ? PROJECT_V1_ROUTE_PLAN_DETAIL
+ ? PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL
: PROJECT_V1_ROUTE_ISSUE_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
issueSlug: "create",
planId: "create",
+ specId: "placeholder", // This will be replaced with the actual spec ID later.
},
query,
};
diff --git a/frontend/src/components/Plan/PlanDetailPage.vue b/frontend/src/components/Plan/PlanDetailPage.vue
index d27e0ad017..20a70e0e9e 100644
--- a/frontend/src/components/Plan/PlanDetailPage.vue
+++ b/frontend/src/components/Plan/PlanDetailPage.vue
@@ -105,7 +105,7 @@ const tabRender = (tab: TabKey) => {
<div>
{t("plan.navigator.checks")}
{planCheckRunList.value.length > 0 && (
- <span>({planCheckRunList.value.length})</span>
+ <span class="text-gray-500">({planCheckRunList.value.length})</span>
)}
</div>
);
diff --git a/frontend/src/components/Plan/components/AddSpecDrawer.vue b/frontend/src/components/Plan/components/AddSpecDrawer.vue
index 12aff4925a..7eb1a48d26 100644
--- a/frontend/src/components/Plan/components/AddSpecDrawer.vue
+++ b/frontend/src/components/Plan/components/AddSpecDrawer.vue
@@ -8,58 +8,91 @@
>
<DrawerContent :title="title ?? $t('plan.add-spec')" closable>
<div class="flex flex-col gap-y-4">
- <!-- Step 1: Select Change Type -->
- <div class="flex flex-row items-center gap-x-4">
- <label class="text-sm font-medium text-main block">
- {{ $t("plan.change-type") }}
- </label>
- <NRadioGroup v-model:value="changeType" class="space-y-2">
- <NRadio value="MIGRATE">
- <div class="flex items-center gap-2">
- <FileDiffIcon class="w-4 h-4" />
- <span>{{ $t("plan.schema-migration") }}</span>
- </div>
- <div class="text-sm text-control-light ml-6">
- {{ $t("plan.schema-migration-description") }}
- </div>
- </NRadio>
- <NRadio value="DATA">
- <div class="flex items-center gap-2">
- <EditIcon class="w-4 h-4" />
- <span>{{ $t("plan.data-change") }}</span>
- </div>
- <div class="text-sm text-control-light ml-6">
- {{ $t("plan.data-change-description") }}
- </div>
- </NRadio>
- </NRadioGroup>
- </div>
-
- <!-- Step 2: Select Targets -->
- <div>
- <label class="text-sm font-medium text-main mb-2 block">
- {{ $t("plan.select-targets") }}
- </label>
- <DatabaseAndGroupSelector
- :project="project"
- :value="databaseSelectState"
- @update:value="handleUpdateSelection"
+ <!-- Steps indicator -->
+ <NSteps :current="currentStep" size="small">
+ <NStep
+ :title="
+ currentStep === 1
+ ? $t('plan.change-type')
+ : changeType === 'DATA'
+ ? $t('plan.data-change')
+ : $t('plan.schema-migration')
+ "
/>
+ <NStep :title="$t('plan.select-targets')" />
+ </NSteps>
+
+ <!-- Step content -->
+ <div class="flex-1">
+ <!-- Step 1: Select Change Type -->
+ <template v-if="currentStep === 1">
+ <NRadioGroup
+ v-model:value="changeType"
+ size="large"
+ class="space-x-3"
+ >
+ <NRadio value="MIGRATE">
+ <div class="flex items-center gap-2">
+ <FileDiffIcon class="w-5 h-5" />
+ <span>{{ $t("plan.schema-migration") }}</span>
+ </div>
+ <div class="text-sm text-control-light ml-7">
+ {{ $t("plan.schema-migration-description") }}
+ </div>
+ </NRadio>
+ <NRadio value="DATA">
+ <div class="flex items-center gap-2">
+ <EditIcon class="w-5 h-5" />
+ <span>{{ $t("plan.data-change") }}</span>
+ </div>
+ <div class="text-sm text-control-light ml-7">
+ {{ $t("plan.data-change-description") }}
+ </div>
+ </NRadio>
+ </NRadioGroup>
+ </template>
+
+ <!-- Step 2: Select Targets -->
+ <template v-else-if="currentStep === 2">
+ <DatabaseAndGroupSelector
+ :project="project"
+ :value="databaseSelectState"
+ @update:value="handleUpdateSelection"
+ />
+ </template>
</div>
</div>
<template #footer>
- <div class="flex items-center justify-end gap-x-3">
- <NButton @click="handleCancel">
- {{ $t("common.cancel") }}
- </NButton>
- <NButton
- type="primary"
- :disabled="!canSubmit"
- :loading="isCreating"
- @click="handleConfirm"
- >
- {{ $t("common.confirm") }}
- </NButton>
+ <div class="flex items-center justify-between">
+ <div class="flex items-center gap-x-3">
+ <NButton v-if="currentStep === 1" @click="handleCancel">
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ v-if="currentStep === 2"
+ quaternary
+ @click="handlePrevStep"
+ >
+ {{ $t("common.back") }}
+ </NButton>
+ <NButton
+ v-if="currentStep === 1"
+ type="primary"
+ :disabled="!changeType"
+ @click="handleNextStep"
+ >
+ {{ $t("common.next") }}
+ </NButton>
+ <NButton
+ v-else-if="currentStep === 2"
+ type="primary"
+ :disabled="!canSubmit"
+ :loading="isCreating"
+ @click="handleConfirm"
+ >
+ {{ $t("common.confirm") }}
+ </NButton>
+ </div>
</div>
</template>
</DrawerContent>
@@ -68,7 +101,7 @@
<script setup lang="ts">
import { FileDiffIcon, EditIcon } from "lucide-vue-next";
-import { NButton, NRadio, NRadioGroup } from "naive-ui";
+import { NButton, NRadio, NRadioGroup, NSteps, NStep } from "naive-ui";
import { v4 as uuidv4 } from "uuid";
import { computed, reactive, ref, watch } from "vue";
import DatabaseAndGroupSelector from "@/components/DatabaseAndGroupSelector";
@@ -96,6 +129,7 @@ const show = defineModel<boolean>("show", { default: false });
const changeType = ref<"MIGRATE" | "DATA">("MIGRATE");
const isCreating = ref(false);
+const currentStep = ref(1);
const databaseSelectState = reactive<DatabaseSelectState>({
changeSource: "DATABASE",
@@ -117,6 +151,7 @@ const canSubmit = computed(() => {
// Reset state when drawer opens
watch(show, (newVal) => {
if (newVal) {
+ currentStep.value = 1;
changeType.value = "MIGRATE";
databaseSelectState.changeSource = "DATABASE";
databaseSelectState.selectedDatabaseNameList = [];
@@ -133,6 +168,18 @@ const handleCancel = () => {
show.value = false;
};
+const handleNextStep = () => {
+ if (currentStep.value === 1 && changeType.value) {
+ currentStep.value = 2;
+ }
+};
+
+const handlePrevStep = () => {
+ if (currentStep.value === 2) {
+ currentStep.value = 1;
+ }
+};
+
const handleConfirm = async () => {
if (!canSubmit.value) return;
diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
index b5174dee2f..f93f10a1f2 100644
--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue
@@ -50,19 +50,13 @@
</div>
<div class="flex-1 overflow-y-auto">
- <!-- Loading State -->
- <div v-if="isLoading" class="flex items-center justify-center py-8">
- <BBSpin />
- </div>
-
<!-- Check Results -->
- <div v-else-if="checkRunsForSpec.length > 0" class="flex flex-wrap gap-4">
+ <div v-if="checkRunsForSpec.length > 0" class="flex flex-wrap gap-4">
<!-- Group by Check Type -->
<div
v-for="(typeGroup, checkType) in groupedByType"
:key="checkType"
class="inline-flex items-center gap-1"
- @click="selectedCheckType = checkType"
>
<component
:is="getCheckTypeIcon(checkType)"
@@ -226,7 +220,6 @@ import {
import { NButton } from "naive-ui";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
-import { BBSpin } from "@/bbkit";
import Drawer from "@/components/v2/Container/Drawer.vue";
import DrawerContent from "@/components/v2/Container/DrawerContent.vue";
import { planServiceClient } from "@/grpcweb";
@@ -251,21 +244,15 @@ const { project } = useCurrentProjectV1();
const { plan, planCheckRunList } = usePlanContext();
const { selectedSpec } = usePlanSpecContext();
-const isLoading = ref(false);
const isRunningChecks = ref(false);
const drawerVisible = ref(false);
const selectedStatus = ref<"ERROR" | "WARNING" | "SUCCESS">("ERROR");
-const selectedCheckType = ref<string>("");
const show = computed(() => {
- if (!selectedSpec.value) {
- return false;
- }
return planSpecHasPlanChecks(selectedSpec.value);
});
const checkRunsForSpec = computed(() => {
- if (!selectedSpec.value) return [];
return planCheckRunListForSpec(planCheckRunList.value, selectedSpec.value);
});
diff --git a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
index 50e583d0ef..9da375c4a0 100644
--- a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
+++ b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
@@ -1,5 +1,7 @@
<template>
<NDataTable
+ key="plan-table"
+ size="small"
:columns="columnList"
:data="planList"
:striped="true"
@@ -17,8 +19,6 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBAvatar } from "@/bbkit";
-import { projectOfPlan } from "@/components/Plan/logic";
-import { ProjectNameCell } from "@/components/v2/Model/DatabaseV1Table/cells";
import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
import { useUserStore } from "@/store";
import { getTimeForPbTimestamp, unknownUser } from "@/types";
@@ -30,16 +30,12 @@ import {
} from "@/utils";
import PlanCheckRunStatusIcon from "../PlanCheckRunStatusIcon.vue";
-const props = withDefaults(
+withDefaults(
defineProps<{
planList: Plan[];
loading?: boolean;
- showProject: boolean;
}>(),
- {
- loading: true,
- showProject: true,
- }
+ {}
);
const { t } = useI18n();
@@ -78,16 +74,6 @@ const columnList = computed((): DataTableColumn<Plan>[] => {
);
},
},
- {
- key: "project",
- title: t("common.project"),
- width: 144,
- resizable: true,
- hide: !props.showProject,
- render: (plan) => (
- <ProjectNameCell project={projectOfPlan(plan)} mode={"ALL_SHORT"} />
- ),
- },
{
key: "updateTime",
title: t("issue.table.updated"),
diff --git a/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue b/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue
new file mode 100644
index 0000000000..78dec6dd98
--- /dev/null
+++ b/frontend/src/components/Plan/components/SpecDetailView/AllTargetsDrawer.vue
@@ -0,0 +1,296 @@
+<template>
+ <Drawer :show="show" width="auto" @update:show="$emit('update:show', $event)">
+ <DrawerContent
+ :title="`${$t('plan.targets.title')} (${targets.length})`"
+ :closable="true"
+ class="w-[50rem] max-w-[100vw] relative"
+ >
+ <template #default>
+ <div class="w-full h-full flex flex-col gap-y-4">
+ <!-- Search bar -->
+ <div class="px-4">
+ <SearchBox
+ v-model:value="state.searchText"
+ :placeholder="$t('common.search')"
+ />
+ </div>
+
+ <!-- Targets list -->
+ <div class="flex-1 px-4 pb-4 overflow-hidden">
+ <div
+ v-if="state.isLoading"
+ class="flex items-center justify-center h-full"
+ >
+ <BBSpin />
+ </div>
+ <div
+ v-else-if="filteredTargets.length > 0"
+ class="h-full overflow-y-auto"
+ >
+ <div class="flex flex-wrap gap-2">
+ <div
+ v-for="item in filteredTargets"
+ :key="item.target"
+ class="inline-flex items-center gap-x-1.5 px-3 py-1.5 border rounded-lg transition-all cursor-default max-w-[20rem]"
+ >
+ <EngineIcon
+ v-if="item.type === 'database' && item.engine"
+ :engine="item.engine"
+ custom-class="w-4 h-4 text-control-light flex-shrink-0"
+ />
+ <component
+ v-else
+ :is="item.icon"
+ class="w-4 h-4 text-control-light flex-shrink-0"
+ />
+ <span class="text-sm text-gray-500" v-if="item.environment">
+ ({{ item.environment }})
+ </span>
+ <div class="flex items-center gap-x-1 min-w-0 text-sm">
+ <NEllipsis :line-clamp="1">
+ <span class="font-medium">{{ item.name }}</span>
+ </NEllipsis>
+ </div>
+ <div
+ class="text-xs px-2 py-0.5 rounded-md bg-control-bg text-control-light flex-shrink-0"
+ >
+ {{ getTypeLabel(item.type) }}
+ </div>
+ </div>
+ </div>
+ </div>
+ <div
+ v-else
+ class="flex items-center justify-center h-full text-control-light"
+ >
+ {{ $t("common.no-data") }}
+ </div>
+ </div>
+ </div>
+ </template>
+ </DrawerContent>
+ </Drawer>
+</template>
+
+<script setup lang="ts">
+import { ServerIcon, DatabaseIcon, FolderIcon } from "lucide-vue-next";
+import { NEllipsis } from "naive-ui";
+import { reactive, computed, watch } from "vue";
+import { useI18n } from "vue-i18n";
+import { BBSpin } from "@/bbkit";
+import EngineIcon from "@/components/Icon/EngineIcon.vue";
+import { Drawer, DrawerContent, SearchBox } from "@/components/v2";
+import {
+ useInstanceV1Store,
+ useDatabaseV1Store,
+ useDBGroupStore,
+ batchGetOrFetchDatabases,
+} from "@/store";
+import {
+ isValidDatabaseGroupName,
+ isValidDatabaseName,
+ isValidInstanceName,
+} from "@/types";
+import type { Engine } from "@/types/proto/v1/common";
+import {
+ extractInstanceResourceName,
+ instanceV1Name,
+ extractDatabaseResourceName,
+ extractDatabaseGroupName,
+} from "@/utils";
+
+interface Props {
+ show: boolean;
+ targets: string[];
+}
+
+interface TargetRow {
+ target: string;
+ type: "instance" | "database" | "databaseGroup";
+ icon: any;
+ name: string;
+ instance?: string;
+ environment?: string;
+ description?: string;
+ engine?: Engine;
+}
+
+interface LocalState {
+ searchText: string;
+ isLoading: boolean;
+ targetRows: TargetRow[];
+}
+
+const props = defineProps<Props>();
+defineEmits<{
+ "update:show": [show: boolean];
+}>();
+
+const { t } = useI18n();
+const instanceStore = useInstanceV1Store();
+const databaseStore = useDatabaseV1Store();
+const dbGroupStore = useDBGroupStore();
+
+const state = reactive<LocalState>({
+ searchText: "",
+ isLoading: false,
+ targetRows: [],
+});
+
+const filteredTargets = computed(() => {
+ if (!state.searchText) {
+ return state.targetRows;
+ }
+ const searchText = state.searchText.toLowerCase();
+ return state.targetRows.filter((row) => {
+ return (
+ row.name.toLowerCase().includes(searchText) ||
+ row.instance?.toLowerCase().includes(searchText) ||
+ row.environment?.toLowerCase().includes(searchText)
+ );
+ });
+});
+
+const getTypeLabel = (type: TargetRow["type"]) => {
+ const typeLabels = {
+ instance: t("plan.targets.type.instance"),
+ database: t("plan.targets.type.database"),
+ databaseGroup: t("plan.targets.type.database-group"),
+ };
+ return typeLabels[type];
+};
+
+const loadAllTargets = async () => {
+ if (props.targets.length === 0) {
+ state.targetRows = [];
+ return;
+ }
+
+ state.isLoading = true;
+
+ try {
+ // Separate different types of targets for optimized fetching
+ const databaseTargets: string[] = [];
+ const instanceTargets: string[] = [];
+ const dbGroupTargets: string[] = [];
+
+ for (const target of props.targets) {
+ if (isValidDatabaseGroupName(target)) {
+ // If target is a valid database group name
+ dbGroupTargets.push(target);
+ } else if (isValidDatabaseName(target)) {
+ databaseTargets.push(target);
+ } else if (isValidInstanceName(target)) {
+ instanceTargets.push(target);
+ }
+ }
+
+ // Batch fetch all targets
+ const fetchPromises: Promise<any>[] = [];
+
+ if (databaseTargets.length > 0) {
+ fetchPromises.push(batchGetOrFetchDatabases(databaseTargets));
+ }
+
+ const instancePromises = instanceTargets.map((target) => {
+ const instanceResourceName = extractInstanceResourceName(target);
+ return instanceStore.getOrFetchInstanceByName(instanceResourceName);
+ });
+ fetchPromises.push(...instancePromises);
+
+ const dbGroupPromises = dbGroupTargets.map((target) =>
+ dbGroupStore.getOrFetchDBGroupByName(target)
+ );
+ fetchPromises.push(...dbGroupPromises);
+
+ await Promise.allSettled(fetchPromises);
+
+ // Build target rows
+ const rows: TargetRow[] = props.targets.map((target): TargetRow => {
+ if (!isValidDatabaseName(target) && isValidInstanceName(target)) {
+ const instanceResourceName = extractInstanceResourceName(target);
+ const instance = instanceStore.getInstanceByName(instanceResourceName);
+ return {
+ target,
+ type: "instance",
+ icon: ServerIcon,
+ name: instance ? instanceV1Name(instance) : instanceResourceName,
+ environment: instance?.environmentEntity?.title || "Unknown",
+ description: instance?.title || "",
+ };
+ }
+
+ // For database group targets
+ if (isValidDatabaseGroupName(target)) {
+ const groupName = extractDatabaseGroupName(target);
+ const dbGroup = dbGroupStore.getDBGroupByName(target);
+
+ return {
+ target,
+ type: "databaseGroup",
+ icon: FolderIcon,
+ name: dbGroup?.title || groupName,
+ };
+ }
+
+ // For regular database targets
+ const database = databaseStore.getDatabaseByName(target);
+
+ if (!database) {
+ // Fallback when database is not found
+ const { instance: instanceId, databaseName } =
+ extractDatabaseResourceName(target);
+ if (instanceId && databaseName) {
+ return {
+ target,
+ type: "database",
+ icon: DatabaseIcon,
+ name: databaseName,
+ instance: instanceId,
+ description: t("plan.targets.database-not-found"),
+ };
+ }
+ }
+
+ const instance = database?.instanceResource;
+
+ return {
+ target,
+ type: "database",
+ icon: DatabaseIcon,
+ name: database?.databaseName || target,
+ instance: instance ? instanceV1Name(instance) : "",
+ environment: database?.effectiveEnvironmentEntity?.title || "",
+ engine: instance?.engine,
+ };
+ });
+
+ state.targetRows = rows;
+ } catch (error) {
+ console.error("Failed to load targets:", error);
+ } finally {
+ state.isLoading = false;
+ }
+};
+
+// Load all targets when drawer opens
+watch(
+ () => props.show,
+ async (show) => {
+ if (show) {
+ state.searchText = "";
+ await loadAllTargets();
+ }
+ }
+);
+
+// Reload if targets change while drawer is open
+watch(
+ () => props.targets,
+ async () => {
+ if (props.show) {
+ await loadAllTargets();
+ }
+ }
+);
+</script>
diff --git a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
index 14cf69266b..ddb3421e4e 100644
--- a/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
+++ b/frontend/src/components/Plan/components/SpecDetailView/TargetListSection.vue
@@ -5,32 +5,42 @@
<h3 class="text-base font-medium">{{ $t("plan.targets.title") }}</h3>
<span class="text-control-light">({{ targets.length }})</span>
</div>
- <NButton
- v-if="allowEdit"
- size="small"
- @click="showTargetsSelector = true"
- >
- <template #icon>
- <EditIcon class="w-4 h-4" />
- </template>
- {{ $t("common.edit") }}
- </NButton>
+ <div class="flex items-center gap-1">
+ <NButton
+ v-if="targets.length > DEFAULT_VISIBLE_TARGETS"
+ size="small"
+ quaternary
+ @click="showAllTargetsDrawer = true"
+ >
+ {{
+ $t("plan.targets.view-all", {
+ count: targets.length,
+ })
+ }}
+ </NButton>
+ <NButton
+ v-if="allowEdit"
+ size="small"
+ @click="showTargetsSelector = true"
+ >
+ <template #icon>
+ <EditIcon class="w-4 h-4" />
+ </template>
+ {{ $t("common.edit") }}
+ </NButton>
+ </div>
</div>
<div class="relative flex-1">
<div
- v-if="!paginationState.initialized && paginationState.isRequesting"
+ v-if="isLoadingTargets"
class="flex items-center justify-center py-8"
>
<BBSpin />
</div>
<div
v-else-if="targets.length > 0"
- ref="targetContainer"
class="flex flex-wrap gap-2 overflow-y-auto"
- :style="{
- 'max-height': `${MAX_LIST_HEIGHT}px`,
- }"
>
<div
v-for="item in tableData"
@@ -61,21 +71,6 @@
{{ getTypeLabel(item.type) }}
</div>
</div>
-
- <!-- Load More Button -->
- <div
- v-if="targets.length > paginationState.index"
- class="w-full flex items-center justify-end"
- >
- <NButton
- size="small"
- quaternary
- :loading="paginationState.isRequesting"
- @click="loadNextPage"
- >
- {{ $t("common.load-more") }}
- </NButton>
- </div>
</div>
<div v-else class="text-center text-control-light py-8">
{{ $t("plan.targets.no-targets-found") }}
@@ -88,11 +83,12 @@
:current-targets="targets"
@confirm="handleUpdateTargets"
/>
+
+ <AllTargetsDrawer v-model:show="showAllTargetsDrawer" :targets="targets" />
</div>
</template>
<script setup lang="ts">
-import { useDebounceFn } from "@vueuse/core";
import {
ServerIcon,
DatabaseIcon,
@@ -100,7 +96,7 @@ import {
EditIcon,
} from "lucide-vue-next";
import { NEllipsis, NButton } from "naive-ui";
-import { computed, ref, reactive, watch } from "vue";
+import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { BBSpin } from "@/bbkit";
import EngineIcon from "@/components/Icon/EngineIcon.vue";
@@ -113,7 +109,6 @@ import {
pushNotification,
batchGetOrFetchDatabases,
} from "@/store";
-import { DEBOUNCE_SEARCH_DELAY } from "@/types";
import type { Engine } from "@/types/proto/v1/common";
import {
extractInstanceResourceName,
@@ -124,6 +119,7 @@ import {
} from "@/utils";
import { usePlanContext } from "../../logic/context";
import { targetsForSpec } from "../../logic/plan";
+import AllTargetsDrawer from "./AllTargetsDrawer.vue";
import TargetsSelectorDrawer from "./TargetsSelectorDrawer.vue";
import { usePlanSpecContext } from "./context";
@@ -138,19 +134,7 @@ interface TargetRow {
engine?: Engine;
}
-interface PaginationState {
- // Index is the current number of targets to show.
- index: number;
- initialized: boolean;
- isRequesting: boolean;
-}
-
-interface LocalState {
- pageStatePerSpec: Map<string, PaginationState>;
-}
-
-const MAX_LIST_HEIGHT = 256;
-const TARGETS_PER_PAGE = 16;
+const DEFAULT_VISIBLE_TARGETS = 20;
const { t } = useI18n();
const { plan, isCreating, events } = usePlanContext();
@@ -160,12 +144,9 @@ const databaseStore = useDatabaseV1Store();
const dbGroupStore = useDBGroupStore();
const projectStore = useProjectV1Store();
-const state = reactive<LocalState>({
- pageStatePerSpec: new Map<string, PaginationState>(),
-});
-
+const isLoadingTargets = ref(false);
const showTargetsSelector = ref(false);
-const targetContainer = ref<HTMLDivElement>();
+const showAllTargetsDrawer = ref(false);
const targets = computed(() => {
if (!selectedSpec.value) return [];
@@ -176,34 +157,6 @@ const isCreateDatabaseSpec = computed(() => {
return !!selectedSpec.value?.createDatabaseConfig;
});
-// Create a unique key for the spec based on its properties
-const specKey = computed(() => {
- if (!selectedSpec.value) return "";
- return JSON.stringify({
- createDb: !!selectedSpec.value.createDatabaseConfig,
- changeDb: !!selectedSpec.value.changeDatabaseConfig,
- exportData: !!selectedSpec.value.exportDataConfig,
- id: selectedSpec.value.id,
- });
-});
-
-const paginationState = computed(
- () =>
- state.pageStatePerSpec.get(specKey.value) ?? {
- index: 0,
- initialized: false,
- isRequesting: false,
- }
-);
-
-const updatePaginationState = (patch: Partial<PaginationState>) => {
- if (!selectedSpec.value) return;
- state.pageStatePerSpec.set(specKey.value, {
- ...paginationState.value,
- ...patch,
- });
-};
-
const project = computed(() => {
if (!plan.value?.name) return undefined;
const projectName = `projects/${extractProjectResourceName(plan.value.name)}`;
@@ -217,86 +170,14 @@ const allowEdit = computed(() => {
return (isCreating.value || plan.value.rollout === "") && selectedSpec.value;
});
-const loadMore = useDebounceFn(async () => {
- const fromIndex = paginationState.value.index;
- const toIndex = fromIndex + TARGETS_PER_PAGE;
- const targetList = targets.value.slice(fromIndex, toIndex);
-
- if (targetList.length === 0) {
- updatePaginationState({
- index: toIndex,
- initialized: true,
- });
- return;
- }
-
- // Separate different types of targets for optimized fetching
- const databaseTargets: string[] = [];
- const instanceTargets: string[] = [];
- const dbGroupTargets: string[] = [];
-
- for (const target of targetList) {
- if (isCreateDatabaseSpec.value) {
- instanceTargets.push(target);
- } else if (target.includes("/databaseGroups/")) {
- dbGroupTargets.push(target);
- } else {
- databaseTargets.push(target);
- }
- }
-
- try {
- // Use BatchGetDatabases for database targets
- if (databaseTargets.length > 0) {
- await batchGetOrFetchDatabases(databaseTargets);
- }
-
- // Fetch instances for create database specs
- const instancePromises = instanceTargets.map((target) => {
- const instanceResourceName = extractInstanceResourceName(target);
- return instanceStore.getOrFetchInstanceByName(instanceResourceName);
- });
-
- // Fetch database groups
- const dbGroupPromises = dbGroupTargets.map((target) =>
- dbGroupStore.getOrFetchDBGroupByName(target)
- );
-
- // Wait for all remaining promises
- await Promise.allSettled([...instancePromises, ...dbGroupPromises]);
- } catch {
- // Ignore errors - some targets might not be found
- } finally {
- updatePaginationState({
- index: toIndex,
- initialized: true,
- });
- }
-}, DEBOUNCE_SEARCH_DELAY);
-
-const loadNextPage = async () => {
- if (paginationState.value.isRequesting) {
- return;
- }
- updatePaginationState({
- isRequesting: true,
- });
- try {
- await loadMore();
- } catch {
- // Ignore errors
- } finally {
- updatePaginationState({
- isRequesting: false,
- });
- }
-};
-
const tableData = computed((): TargetRow[] => {
if (!selectedSpec.value) return [];
- // Only show targets up to the current pagination index
- const visibleTargets = targets.value.slice(0, paginationState.value.index);
+ // Show only the first DEFAULT_VISIBLE_TARGETS targets
+ const visibleTargets = targets.value.slice(
+ 0,
+ Math.min(DEFAULT_VISIBLE_TARGETS, targets.value.length)
+ );
return visibleTargets.map((target): TargetRow => {
// For create database spec, target is instance
@@ -396,13 +277,57 @@ const handleUpdateTargets = async (targets: string[]) => {
}
};
-// Initialize pagination when spec changes
-watch(
- specKey,
- async () => {
- if (!paginationState.value.initialized && targets.value.length > 0) {
- await loadNextPage();
+// Load target data when targets change
+const loadTargetData = async () => {
+ if (targets.value.length === 0) {
+ return;
+ }
+
+ isLoadingTargets.value = true;
+
+ try {
+ // Fetch data for visible targets only
+ const visibleTargets = targets.value.slice(0, DEFAULT_VISIBLE_TARGETS);
+ const databaseTargets: string[] = [];
+ const instanceTargets: string[] = [];
+ const dbGroupTargets: string[] = [];
+
+ for (const target of visibleTargets) {
+ if (isCreateDatabaseSpec.value) {
+ instanceTargets.push(target);
+ } else if (target.includes("/databaseGroups/")) {
+ dbGroupTargets.push(target);
+ } else {
+ databaseTargets.push(target);
+ }
+ }
+
+ if (databaseTargets.length > 0) {
+ await batchGetOrFetchDatabases(databaseTargets);
}
+
+ const instancePromises = instanceTargets.map((target) => {
+ const instanceResourceName = extractInstanceResourceName(target);
+ return instanceStore.getOrFetchInstanceByName(instanceResourceName);
+ });
+
+ const dbGroupPromises = dbGroupTargets.map((target) =>
+ dbGroupStore.getOrFetchDBGroupByName(target)
+ );
+
+ await Promise.allSettled([...instancePromises, ...dbGroupPromises]);
+ } catch {
+ // Ignore errors
+ } finally {
+ isLoadingTargets.value = false;
+ }
+};
+
+// Watch for target changes and load data
+watch(
+ targets,
+ () => {
+ loadTargetData();
},
{ immediate: true }
);
diff --git a/frontend/src/components/Plan/logic/initialize/index.ts b/frontend/src/components/Plan/logic/initialize/index.ts
index 537058c0ba..e7755e9478 100644
--- a/frontend/src/components/Plan/logic/initialize/index.ts
+++ b/frontend/src/components/Plan/logic/initialize/index.ts
@@ -1,6 +1,6 @@
import { computed, ref, unref, watch, type MaybeRef } from "vue";
import { useRoute, useRouter, type LocationQuery } from "vue-router";
-import { usePlanStore } from "@/store";
+import { projectNamePrefix, usePlanStore } from "@/store";
import { EMPTY_ID, UNKNOWN_ID } from "@/types";
import type { Plan, PlanCheckRun } from "@/types/proto/v1/plan_service";
import { emptyPlan } from "@/types/v1/issue/plan";
@@ -12,7 +12,7 @@ export * from "./util";
export function useInitializePlan(
planId: MaybeRef<string>,
- project: MaybeRef<string> = "-",
+ projectId: MaybeRef<string>,
redirectNotFound: boolean = true
) {
const isCreating = computed(() => {
@@ -33,14 +33,16 @@ export function useInitializePlan(
const plan = ref<Plan>(emptyPlan());
const planCheckRunList = ref<PlanCheckRun[]>([]);
- const runner = async (uid: string, project: string, url: string) => {
+ const runner = async (uid: string, projectId: string, url: string) => {
const plan =
uid === String(EMPTY_ID)
? await createPlanSkeleton(
route,
convertRouterQuery(router.resolve(url).query)
)
- : await planStore.fetchPlanByUID(uid, project);
+ : await planStore.fetchPlanByName(
+ `${projectNamePrefix}${projectId}/plans/${uid}`
+ );
return {
plan,
url,
@@ -48,15 +50,15 @@ export function useInitializePlan(
};
watch(
- [uid, () => unref(project)],
- ([uid, project]) => {
+ [uid, () => unref(projectId)],
+ ([uid, projectId]) => {
if (uid === String(UNKNOWN_ID) && redirectNotFound) {
router.push({ name: "error.404" });
return;
}
const url = route.fullPath;
isInitializing.value = true;
- runner(uid, project, url).then(async (result) => {
+ runner(uid, projectId, url).then(async (result) => {
if (result.url !== route.fullPath) {
// the url changed, drop the outdated result
return;
diff --git a/frontend/src/components/Plan/logic/plan-check.ts b/frontend/src/components/Plan/logic/plan-check.ts
index 06b583da42..2719a2af88 100644
--- a/frontend/src/components/Plan/logic/plan-check.ts
+++ b/frontend/src/components/Plan/logic/plan-check.ts
@@ -13,7 +13,7 @@ export const planCheckRunListForSpec = (
spec: Plan_Spec
) => {
const targets = targetsForSpec(spec);
- const sheet = spec ? sheetNameForSpec(spec) : "";
+ const sheet = sheetNameForSpec(spec);
return planCheckRunList.filter((check) => {
if (!targets.includes(check.target)) {
return false;
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 05a71edcb3..b8e42ef386 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1027,7 +1027,8 @@
"instance": "Instance",
"database": "Database",
"database-group": "Database Group"
- }
+ },
+ "view-all": "View all ({count})"
},
"options": {
"self": "Options",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index d329b0f298..22cf00e4fd 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -895,8 +895,8 @@
"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",
- "custom-date-placeholder": "Seleccione la fecha y hora de vencimiento",
- "custom-date": "Fecha personalizada"
+ "custom-date": "Fecha personalizada",
+ "custom-date-placeholder": "Seleccione la fecha y hora de vencimiento"
},
"review-sent-back": "Revisión devuelta",
"update-statement": {
@@ -1027,7 +1027,8 @@
"instance": "Instancia",
"database": "Base de datos",
"database-group": "Grupo de bases de datos"
- }
+ },
+ "view-all": "Ver todo ({count})"
},
"options": {
"self": "Opciones",
@@ -2735,4 +2736,4 @@
"last-visit": "Última visita",
"changelog-for-version": "Registro de cambios para {version}"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index dc92114abb..bec3584326 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -895,8 +895,8 @@
"all-databases": "すべてのデータベース",
"all-databases-tip": "このプロジェクトに属する現在および将来のすべてのデータベース。",
"manually-select": "手動選択",
- "custom-date-placeholder": "有効期限と時刻を選択します",
- "custom-date": "カスタム日付"
+ "custom-date": "カスタム日付",
+ "custom-date-placeholder": "有効期限と時刻を選択します"
},
"review-sent-back": "レビューが返されました",
"update-statement": {
@@ -1027,7 +1027,8 @@
"instance": "実例",
"database": "データベース",
"database-group": "データベースグループ"
- }
+ },
+ "view-all": "すべて表示 ({count})"
},
"options": {
"self": "オプション",
@@ -2735,4 +2736,4 @@
"last-visit": "最終訪問",
"changelog-for-version": "{version} の変更履歴"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 9e02474530..5ca2e2b691 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -895,8 +895,8 @@
"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",
- "custom-date-placeholder": "Chọn ngày và giờ hết hạn",
- "custom-date": "Ngày tùy chỉnh"
+ "custom-date": "Ngày tùy chỉnh",
+ "custom-date-placeholder": "Chọn ngày và giờ hết hạn"
},
"review-sent-back": "Đánh giá đã gửi lại",
"update-statement": {
@@ -1027,7 +1027,8 @@
"instance": "Ví dụ",
"database": "Cơ sở dữ liệu",
"database-group": "Nhóm cơ sở dữ liệu"
- }
+ },
+ "view-all": "Xem tất cả ({count})"
},
"options": {
"self": "Tùy chọn",
@@ -2735,4 +2736,4 @@
"last-visit": "Lần truy cập cuối",
"changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 5c67a3f3df..c6163f87f5 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -895,8 +895,8 @@
"all-databases": "所有数据库",
"all-databases-tip": "所有当前和未来属于这个项目的数据库。",
"manually-select": "手动选择",
- "custom-date-placeholder": "选择到期日期和时间",
- "custom-date": "自定义日期"
+ "custom-date": "自定义日期",
+ "custom-date-placeholder": "选择到期日期和时间"
},
"review-sent-back": "审核被退回",
"update-statement": {
@@ -1027,7 +1027,8 @@
"instance": "实例",
"database": "数据库",
"database-group": "数据库组"
- }
+ },
+ "view-all": "查看全部 ({count})"
},
"options": {
"self": "配置项",
@@ -2735,4 +2736,4 @@
"last-visit": "上次访问",
"changelog-for-version": "{version} 的更新日志"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/store/modules/v1/experimental-issue.ts b/frontend/src/store/modules/v1/experimental-issue.ts
index 97c94c2a9b..4821a252ee 100644
--- a/frontend/src/store/modules/v1/experimental-issue.ts
+++ b/frontend/src/store/modules/v1/experimental-issue.ts
@@ -1,5 +1,4 @@
import { orderBy } from "lodash-es";
-import { ref, watch, type WatchCallback } from "vue";
import {
issueServiceClient,
planServiceClient,
@@ -149,11 +148,3 @@ export const experimentalCreateIssueByPlan = async (
return { createdPlan, createdIssue, createdRollout };
};
-
-const REFRESH_PLAN_LIST = ref(Math.random());
-export const refreshPlanList = () => {
- REFRESH_PLAN_LIST.value = Math.random();
-};
-export const useRefreshPlanList = (callback: WatchCallback) => {
- watch(REFRESH_PLAN_LIST, callback);
-};
diff --git a/frontend/src/store/modules/v1/plan.ts b/frontend/src/store/modules/v1/plan.ts
index 34bf373076..c0a9233c75 100644
--- a/frontend/src/store/modules/v1/plan.ts
+++ b/frontend/src/store/modules/v1/plan.ts
@@ -2,9 +2,7 @@ import dayjs from "dayjs";
import { uniq } from "lodash-es";
import { defineStore } from "pinia";
import { planServiceClient } from "@/grpcweb";
-import { EMPTY_ID, UNKNOWN_ID } from "@/types";
import type { Plan } from "@/types/proto/v1/plan_service";
-import { emptyPlan, unknownPlan } from "@/types/v1/issue/plan";
import {
getTsRangeFromSearchParams,
getValueFromSearchParams,
@@ -94,21 +92,8 @@ export const usePlanStore = defineStore("plan", () => {
return plan;
};
- const fetchPlanByUID = async (uid: string, project = "-"): Promise<Plan> => {
- if (uid === "undefined") {
- console.warn("undefined plan uid");
- return emptyPlan();
- }
-
- if (uid === String(EMPTY_ID)) return emptyPlan();
- if (uid === String(UNKNOWN_ID)) return unknownPlan();
-
- return fetchPlanByName(`projects/${project}/plans/${uid}`);
- };
-
return {
searchPlans,
fetchPlanByName,
- fetchPlanByUID,
};
});
diff --git a/frontend/src/store/modules/v1/project.ts b/frontend/src/store/modules/v1/project.ts
index 88d8f5767f..ab5ad286b9 100644
--- a/frontend/src/store/modules/v1/project.ts
+++ b/frontend/src/store/modules/v1/project.ts
@@ -1,4 +1,3 @@
-import { computedAsync } from "@vueuse/core";
import { orderBy, uniq } from "lodash-es";
import { defineStore } from "pinia";
import { computed, reactive, ref, unref, watchEffect } from "vue";
@@ -200,24 +199,10 @@ export const useProjectByName = (name: MaybeRef<string>) => {
export const useCurrentProjectV1 = () => {
const route = useRoute();
-
- const project = computedAsync(async () => {
- if (route.params.projectId) {
- return await useProjectV1Store().getOrFetchProjectByName(
- `${projectNamePrefix}${route.params.projectId}`
- );
- }
- return unknownProject();
- }, unknownProject());
-
- const isValid = computed(() => {
- return isValidProjectName(project.value.name);
- });
-
- return {
- project,
- isValid,
- };
+ const projectName = computed(
+ () => `${projectNamePrefix}${route.params.projectId}`
+ );
+ return useProjectByName(projectName);
};
const batchComposeProjectIamPolicy = async (projectList: Project[]) => {
diff --git a/frontend/src/views/ReviewCenter/index.vue b/frontend/src/views/ReviewCenter/index.vue
index f936ecbdf4..5559fe44bf 100644
--- a/frontend/src/views/ReviewCenter/index.vue
+++ b/frontend/src/views/ReviewCenter/index.vue
@@ -1,5 +1,5 @@
<template>
- <div :class="['w-full']">
+ <div v-if="ready" class="w-full">
<div
class="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-2"
>
@@ -25,15 +25,11 @@
<div class="relative w-full mt-4 min-h-[20rem]">
<PagedTable
ref="planPagedTable"
- :session-key="'review-center'"
+ :session-key="`bb.${project.name}.plan-table`"
:fetch-list="fetchPlanList"
>
<template #table="{ list, loading }">
- <PlanDataTable
- :loading="loading"
- :plan-list="list"
- :show-project="false"
- />
+ <PlanDataTable :loading="loading" :plan-list="list" />
</template>
</PagedTable>
</div>
@@ -59,12 +55,8 @@ import { targetsForSpec } from "@/components/Plan";
import AddSpecDrawer from "@/components/Plan/components/AddSpecDrawer.vue";
import PlanDataTable from "@/components/Plan/components/PlanDataTable";
import PagedTable from "@/components/v2/Model/PagedTable.vue";
-import { PROJECT_V1_ROUTE_PLAN_DETAIL } from "@/router/dashboard/projectV1";
-import {
- useCurrentProjectV1,
- useCurrentUserV1,
- useRefreshPlanList,
-} from "@/store";
+import { PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL } from "@/router/dashboard/projectV1";
+import { useCurrentProjectV1, useCurrentUserV1 } from "@/store";
import { usePlanStore } from "@/store/modules/v1/plan";
import { buildPlanFindBySearchParams } from "@/store/modules/v1/plan";
import { isValidDatabaseGroupName } from "@/types";
@@ -91,17 +83,11 @@ interface LocalState {
| "bb.issue.database.data.update";
}
-const { project } = useCurrentProjectV1();
+const { project, ready } = useCurrentProjectV1();
const showAddSpecDrawer = ref(false);
const readonlyScopes = computed((): SearchScope[] => {
- return [
- {
- id: "project",
- value: extractProjectResourceName(project.value.name),
- readonly: true,
- },
- ];
+ return [];
});
const defaultSearchParams = () => {
@@ -141,14 +127,11 @@ const planSearchParams = computed(() => {
id: "creator",
value: currentUser.value.email,
},
- ];
- // If specific project is provided, add project scope.
- if (project.value) {
- defaultScopes.push({
+ {
id: "project",
value: extractProjectResourceName(project.value.name),
- });
- }
+ },
+ ];
return {
scopes: [...state.params.scopes, ...defaultScopes],
} as SearchParams;
@@ -183,7 +166,6 @@ watch(
() => JSON.stringify(mergedPlanFind.value),
() => planPagedTable.value?.refresh()
);
-useRefreshPlanList(() => planPagedTable.value?.refresh());
const allowToCreatePlan = computed(() => {
// Check if user has permission to create plan in specific project.
@@ -222,11 +204,13 @@ const handleSpecCreated = async (spec: Plan_Spec) => {
);
}
+ // Navigate to the spec detail page with the created spec.
router.push({
- name: PROJECT_V1_ROUTE_PLAN_DETAIL,
+ name: PROJECT_V1_ROUTE_PLAN_DETAIL_SPEC_DETAIL,
params: {
projectId: extractProjectResourceName(project.value.name),
planId: "create",
+ specId: "placeholder", // This will be replaced with the actual spec ID later.
},
query,
});
diff --git a/frontend/src/views/SettingWorkspaceSSO.vue b/frontend/src/views/SettingWorkspaceSSO.vue
index 1a566feb1f..8a2e5f0e1a 100644
--- a/frontend/src/views/SettingWorkspaceSSO.vue
+++ b/frontend/src/views/SettingWorkspaceSSO.vue
@@ -29,6 +29,7 @@
</div>
<NDataTable
key="sso-table"
+ size="small"
:data="identityProviderList"
:row-key="(sso: IdentityProvider) => sso.name"
:columns="columnList"
@@ -102,8 +103,8 @@ const allowGetSSO = computed(() => {
return hasWorkspacePermissionV2("bb.identityProviders.get");
});
-onMounted(() => {
- identityProviderStore.fetchIdentityProviderList();
+onMounted(async () => {
+ await identityProviderStore.fetchIdentityProviderList();
state.isLoading = false;
});