Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: fetch issue related databases per page (#15751)
ecmadaoc03acceb5c72
diff --git a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vueindex a95b420a1b..fab4929aaf 100644--- a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue+++ b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue@@ -132,7 +132,7 @@ const loadMore = async (i: number) => {state.databaseMatchLists[i].loading = true;try {const previous = state.databaseMatchLists[i].index;- const next = previous + 10;+ const next = previous + 20;await Promise.all(state.databaseMatchLists[i].databaseNameListdiff --git a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vueindex 67824783a3..f7e53a625a 100644--- a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue+++ b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue@@ -21,7 +21,9 @@ const props = defineProps<{}>();const router = useRouter();-const { dbGroupList, ready } = useDBGroupListByProject(props.project.name);+const { dbGroupList, ready } = useDBGroupListByProject(+ computed(() => props.project.name)+);const filteredDbGroupList = computed(() => {const filter = props.filter.trim().toLowerCase();diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vueindex 75ff2409f2..9a18b700e1 100644--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue@@ -231,10 +231,7 @@ const createSheets = async () => {if (uid.startsWith("-")) {// The sheet is pending createconst sheet = getLocalSheetByName(config.sheet);- const engine = await databaseEngineForSpec(- issue.value.projectEntity,- spec- );+ const engine = await databaseEngineForSpec(spec);sheet.engine = engine;pendingCreateSheetMap.set(sheet.name, sheet);diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vueindex 00fc6c648a..dbb578ee83 100644--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue@@ -260,7 +260,6 @@ const route = useRoute();const context = useIssueContext();const { events, isCreating, issue, selectedTask, getPlanCheckRunsForTask } =context;-const project = computed(() => issue.value.projectEntity);const dialog = useDialog();const editorContainerElRef = ref<HTMLElement>();const monacoEditorRef = ref<InstanceType<typeof MonacoEditor>>();@@ -639,7 +638,7 @@ const updateStatement = async (statement: string) => {const sheet = Sheet.fromPartial({...createEmptyLocalSheet(),title: issue.value.title,- engine: await databaseEngineForSpec(project.value, head(specsToPatch)),+ engine: await databaseEngineForSpec(head(specsToPatch)),});setSheetStatement(sheet, statement);const createdSheet = await useSheetV1Store().createSheet(diff --git a/frontend/src/components/IssueV1/components/TaskListSection/TaskListSection.vue b/frontend/src/components/IssueV1/components/TaskListSection/TaskListSection.vueindex 3655799e38..6b3d3db4fd 100644--- a/frontend/src/components/IssueV1/components/TaskListSection/TaskListSection.vue+++ b/frontend/src/components/IssueV1/components/TaskListSection/TaskListSection.vue@@ -11,25 +11,77 @@'max-height': `${MAX_LIST_HEIGHT}px`,}">- <TaskCard v-for="(task, i) in taskList" :key="i" :task="task" />+ <TaskCard+ v-for="(task, i) in taskList.slice(0, state.index)"+ :key="i"+ :task="task"+ />+ <div v-if="taskList.length > state.index" class="col-span-full">+ <NButton+ size="small"+ quaternary+ :loading="state.loading"+ @click="() => loadMore()"+ >+ {{ $t("common.load-more") }}+ </NButton>+ </div></div></div></template><script lang="ts" setup>-import { computed, ref } from "vue";+import { useDebounceFn } from "@vueuse/core";+import { NButton } from "naive-ui";+import { computed, ref, reactive, watch } from "vue";import { useVerticalScrollState } from "@/composables/useScrollState";-import { useIssueContext } from "../../logic";+import { batchGetOrFetchDatabases } from "@/store";+import { useIssueContext, databaseForTask } from "../../logic";import TaskCard from "./TaskCard.vue";// 3 * lines of cards + 2 * top and bottom padding + 2 * horizontal gaps + jitterconst MAX_LIST_HEIGHT = 207;-const { selectedStage } = useIssueContext();+const state = reactive<{ loading: boolean; index: number }>({+ loading: false,+ index: 0,+});++const { selectedStage, issue } = useIssueContext();const taskBar = ref<HTMLDivElement>();const taskBarScrollState = useVerticalScrollState(taskBar, MAX_LIST_HEIGHT);const taskList = computed(() => selectedStage.value.tasks);++const loadMore = useDebounceFn(async () => {+ if (state.index >= taskList.value.length) {+ return;+ }+ state.loading = true;+ try {+ const previous = state.index;+ const next = previous + 20;++ const databaseNames = taskList.value+ .slice(previous, next)+ .map((task) => databaseForTask(issue.value, task).name);+ await batchGetOrFetchDatabases(databaseNames);++ state.index = next;+ } finally {+ state.loading = false;+ }+}, 500);++watch(+ () => taskList.value.length,+ (length) => {+ if (length > 0) {+ loadMore();+ }+ },+ { immediate: true }+);</script><style scoped lang="postcss">diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.tsindex 351c29d02e..1c41fc6798 100644--- a/frontend/src/components/IssueV1/logic/initialize/create.ts+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts@@ -8,7 +8,6 @@ import {useChangelistStore,useCurrentUserV1,useDatabaseV1Store,- useDBGroupStore,useEnvironmentV1Store,useProjectV1Store,useSheetV1Store,@@ -25,7 +24,6 @@ import {isValidDatabaseName,TaskTypeListWithStatement,} from "@/types";-import { DatabaseGroupView } from "@/types/proto/v1/database_group_service";import { IssueStatus, Issue_Type } from "@/types/proto/v1/issue_service";import {Plan,@@ -121,22 +119,7 @@ const buildIssue = async (params: CreateIssueParams) => {export const buildPlan = async (params: CreateIssueParams) => {const { project, query } = params;- let databaseNameList = (query.databaseList ?? "").split(",");- const databaseGroupName = query.databaseGroupName;- // Prepare database list if databaseGroupName and changelist are specified.- if (databaseGroupName) {- const dbGroup = await useDBGroupStore().getOrFetchDBGroupByName(- databaseGroupName,- {- view: DatabaseGroupView.DATABASE_GROUP_VIEW_FULL,- }- );- if (dbGroup) {- databaseNameList = dbGroup.matchedDatabases.map((db) => db.name);- }- }- // TODO(ed): the database group may match too many databases.- await batchGetOrFetchDatabases(databaseNameList);+ const databaseNameList = (query.databaseList ?? "").split(",");const plan = Plan.fromPartial({name: `${project.name}/plans/${nextUID()}`,});@@ -215,7 +198,7 @@ export const buildStepsForDatabaseGroup = async (const sheetUID = nextUID();const sheetName = `${params.project.name}/sheets/${sheetUID}`;const sheet = getLocalSheetByName(sheetName);- sheet.engine = await databaseEngineForSpec(params.project, databaseGroupName);+ sheet.engine = await databaseEngineForSpec(databaseGroupName);setSheetStatement(sheet, sql);const spec = await buildSpecForTarget(diff --git a/frontend/src/components/IssueV1/logic/plan.ts b/frontend/src/components/IssueV1/logic/plan.tsindex 3b602f91f1..30b79ddcc2 100644--- a/frontend/src/components/IssueV1/logic/plan.ts+++ b/frontend/src/components/IssueV1/logic/plan.ts@@ -7,7 +7,6 @@ import {useInstanceResourceByName,} from "@/store";import {- type ComposedProject,UNKNOWN_ID,type ComposedIssue,unknownDatabase,@@ -82,7 +81,6 @@ export const sheetNameForSpec = (spec: Plan_Spec): string => {};export const databaseEngineForSpec = async (- project: ComposedProject,specOrTarget?: Plan_Spec | string) => {if (!specOrTarget) return Engine.ENGINE_UNSPECIFIED;diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vueindex fb1bc4a715..207ff1f141 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue@@ -136,10 +136,7 @@ const createSheets = async () => {if (uid.startsWith("-")) {// The sheet is pending createconst sheet = getLocalSheetByName(config.sheet);- const engine = await databaseEngineForSpec(- plan.value.projectEntity,- spec- );+ const engine = await databaseEngineForSpec(spec);sheet.engine = engine;pendingCreateSheetMap.set(sheet.name, sheet);diff --git a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vueindex 2d2130f454..7a343e4558 100644--- a/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue+++ b/frontend/src/components/Plan/components/StatementSection/EditorView/EditorView.vue@@ -246,7 +246,6 @@ const { t } = useI18n();const context = usePlanContext();const { isCreating, plan, selectedSpec, formatOnSave, events } =usePlanContext();-const project = computed(() => plan.value.projectEntity);const dialog = useDialog();const editorContainerElRef = ref<HTMLElement>();const monacoEditorRef = ref<InstanceType<typeof MonacoEditor>>();@@ -522,7 +521,7 @@ const updateStatement = async (statement: string) => {const sheet = Sheet.fromPartial({...createEmptyLocalSheet(),title: plan.value.title,- engine: await databaseEngineForSpec(project.value, head(specsToPatch)),+ engine: await databaseEngineForSpec(head(specsToPatch)),});setSheetStatement(sheet, statement);const createdSheet = await useSheetV1Store().createSheet(diff --git a/frontend/src/components/Plan/logic/initialize/create.ts b/frontend/src/components/Plan/logic/initialize/create.tsindex cd2cf1f697..06ab40bb1d 100644--- a/frontend/src/components/Plan/logic/initialize/create.ts+++ b/frontend/src/components/Plan/logic/initialize/create.ts@@ -157,7 +157,7 @@ export const buildStepsForDatabaseGroup = async (const sql = params.initialSQL.sql ?? "";const sheetCreate = Sheet.fromPartial({...createEmptyLocalSheet(),- engine: await databaseEngineForSpec(params.project, databaseGroupName),+ engine: await databaseEngineForSpec(databaseGroupName),});setSheetStatement(sheetCreate, sql);const sheet = await useSheetV1Store().createSheet(diff --git a/frontend/src/components/Plan/logic/plan.ts b/frontend/src/components/Plan/logic/plan.tsindex 224829255c..ead2da832c 100644--- a/frontend/src/components/Plan/logic/plan.ts+++ b/frontend/src/components/Plan/logic/plan.ts@@ -4,7 +4,6 @@ import {useEnvironmentV1Store,} from "@/store";import {- type ComposedProject,isValidDatabaseName,unknownDatabase,unknownEnvironment,@@ -52,7 +51,6 @@ export const sheetNameForSpec = (spec: Plan_Spec): string => {};export const databaseEngineForSpec = async (- project: ComposedProject,specOrTarget?: Plan_Spec | string) => {if (!specOrTarget) return Engine.ENGINE_UNSPECIFIED;diff --git a/frontend/src/store/modules/v1/experimental-issue.ts b/frontend/src/store/modules/v1/experimental-issue.tsindex 2d1b56e842..286e699c3d 100644--- a/frontend/src/store/modules/v1/experimental-issue.ts+++ b/frontend/src/store/modules/v1/experimental-issue.ts@@ -5,12 +5,7 @@ import {planServiceClient,rolloutServiceClient,} from "@/grpcweb";-import {- useProjectV1Store,- useUserStore,- batchGetOrFetchUsers,- batchGetOrFetchDatabases,-} from "@/store";+import { useProjectV1Store, useUserStore, batchGetOrFetchUsers } from "@/store";import type { ComposedIssue, ComposedProject, ComposedTaskRun } from "@/types";import {emptyIssue,@@ -78,12 +73,6 @@ export const composeIssue = async (issue.rolloutEntity = await rolloutServiceClient.getRollout({name: issue.rollout,});- await batchGetOrFetchDatabases(- issue.rolloutEntity.stages.reduce((databaseList, stage) => {- databaseList.push(...stage.tasks.map((task) => task.target));- return databaseList;- }, [] as string[])- );}if (hasProjectPermissionV2(projectEntity, "bb.taskRuns.list")) {const { taskRuns } = await rolloutServiceClient.listTaskRuns({diff --git a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue b/frontend/src/views/project/ProjectDatabaseGroupDetail.vueindex 1ace588e6d..4e9063a7a8 100644--- a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue+++ b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue@@ -11,7 +11,7 @@<FeatureAttentionForInstanceLicensecustom-class="mb-4"- type="warning"+ type="info"feature="bb.feature.database-grouping"/>