Skip to content

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

chore: support pagination in switch project modal (#16620)

ecmadao237062dcffec
diff --git a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
index 71db6cf19f..4e28a6e976 100644
--- a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
+++ b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
@@ -24,6 +24,7 @@ import {
extractProjectResourceName,
supportedEngineV1List,
getDefaultPagination,
+ hasWorkspacePermissionV2,
} from "@/utils";
import type { ScopeOption, ValueOption } from "./types";
@@ -192,12 +193,19 @@ export const useCommonSearchScopeOptions = (
} as Record<SearchScopeId, () => ScopeOption>;
const scopes: ScopeOption[] = [];
- unref(supportOptionIdList).forEach((id) => {
+ for (const id of unref(supportOptionIdList)) {
+ // TODO(ed): optimize it.
+ if (id === "instance") {
+ if (!hasWorkspacePermissionV2("bb.instances.list")) {
+ continue;
+ }
+ }
const create = scopeCreators[id];
if (create) {
scopes.push(create());
}
- });
+ }
+
return scopes;
});
diff --git a/frontend/src/components/AuditLog/AuditLogDataTable.vue b/frontend/src/components/AuditLog/AuditLogDataTable.vue
index 0f61469d7c..ff5f839466 100644
--- a/frontend/src/components/AuditLog/AuditLogDataTable.vue
+++ b/frontend/src/components/AuditLog/AuditLogDataTable.vue
@@ -148,20 +148,29 @@ const columnList = computed((): AuditDataTableColumn[] => {
minWidth: 256,
width: 256,
title: t("audit-log.table.service-data"),
- render: (auditLog) =>
- auditLog.serviceData && auditLog.serviceData.typeUrl ? (
+ render: (auditLog) => {
+ return auditLog.serviceData && auditLog.serviceData.typeUrl ? (
<JSONStringView
- jsonString={JSON.stringify({
- "@type": auditLog.serviceData.typeUrl,
- ...getServiceDataValue(
- auditLog.serviceData.typeUrl,
- auditLog.serviceData.value
- ),
- })}
+ jsonString={JSON.stringify(
+ {
+ "@type": auditLog.serviceData.typeUrl,
+ ...getServiceDataValue(
+ auditLog.serviceData.typeUrl,
+ auditLog.serviceData.value
+ ),
+ },
+ (_, value) => {
+ if (typeof value === "bigint") {
+ return value.toString(); // Convert to string
+ }
+ return value;
+ }
+ )}
/>
) : (
"-"
- ),
+ );
+ },
},
] as AuditDataTableColumn[]
).filter((column) => !column.hide);
diff --git a/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue
index 33b1e96dab..6b149ba562 100644
--- a/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue
+++ b/frontend/src/components/Project/ProjectSwitch/ProjectSwitchContent.vue
@@ -1,5 +1,5 @@
<template>
- <div class="w-full">
+ <div class="w-full max-h-[calc(100vh-10rem)]">
<div v-if="isValidProjectName(project.name)">
<NButton size="small" text @click="gotoWorkspace">
<template #icon>
@@ -46,43 +46,48 @@
"
>
<ProjectV1Table
+ v-if="tab.id === 'recent'"
:project-list="tab.list"
:current-project="
isValidProjectName(project.name) ? project : undefined
"
- :loading="tab.id === 'all' && state.loading"
:keyword="state.searchText"
@row-click="onProjectSelect"
/>
+ <PagedProjectTable
+ v-else
+ class="mb-2"
+ session-key="bb.project-table"
+ :filter="{
+ query: state.searchText,
+ excludeDefault: true,
+ }"
+ :loading="state.loading"
+ @row-click="onProjectSelect"
+ />
</NTabPane>
</NTabs>
</div>
</template>
<script lang="ts" setup>
-import { useDebounceFn } from "@vueuse/core";
import { ChevronLeftIcon, PlusIcon } from "lucide-vue-next";
import { NButton, NTabPane, NTabs, NTooltip } from "naive-ui";
import { computed, reactive, onMounted, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { useRecentProjects } from "@/components/Project/useRecentProjects";
-import { SearchBox, ProjectV1Table } from "@/components/v2";
+import { SearchBox, ProjectV1Table, PagedProjectTable } from "@/components/v2";
import { PROJECT_V1_ROUTE_DETAIL } from "@/router/dashboard/projectV1";
import { WORKSPACE_ROUTE_LANDING } from "@/router/dashboard/workspaceRoutes";
import { useRecentVisit } from "@/router/useRecentVisit";
-import { useCurrentProjectV1, useProjectV1Store } from "@/store";
+import { useCurrentProjectV1 } from "@/store";
import { getProjectName } from "@/store/modules/v1/common";
import type { ComposedProject } from "@/types";
-import {
- isValidProjectName,
- DEFAULT_PROJECT_NAME,
- DEBOUNCE_SEARCH_DELAY,
-} from "@/types";
+import { isValidProjectName, DEFAULT_PROJECT_NAME } from "@/types";
import {
filterProjectV1ListByKeyword,
hasWorkspacePermissionV2,
- getDefaultPagination,
} from "@/utils";
type LocalTabType = "recent" | "all";
@@ -92,7 +97,6 @@ interface LocalState {
searchText: string;
loading: boolean;
selectedTab: LocalTabType;
- allProjects: ComposedProject[];
}
defineEmits<{
@@ -105,9 +109,8 @@ const state = reactive<LocalState>({
searchText: "",
selectedTab: "all",
loading: true,
- allProjects: [],
});
-const projectStore = useProjectV1Store();
+
const { recentViewProjects } = useRecentProjects();
const router = useRouter();
const { record } = useRecentVisit();
@@ -135,25 +138,6 @@ const allowToCreateProject = computed(() =>
hasWorkspacePermissionV2("bb.projects.create")
);
-watch(
- () => state.searchText,
- useDebounceFn(async () => {
- state.loading = true;
- try {
- const { projects } = await projectStore.fetchProjectList({
- filter: {
- query: state.searchText,
- },
- pageSize: getDefaultPagination(),
- });
- state.allProjects = [...projects];
- } finally {
- state.loading = false;
- }
- }, DEBOUNCE_SEARCH_DELAY),
- { immediate: true }
-);
-
const tabList = computed(
(): { title: string; id: LocalTabType; list: ComposedProject[] }[] => [
{
@@ -164,9 +148,7 @@ const tabList = computed(
{
title: t("common.all"),
id: "all",
- list: state.allProjects.filter(
- (project) => project.name !== DEFAULT_PROJECT_NAME
- ),
+ list: [],
},
]
);
diff --git a/frontend/src/components/v2/Model/PagedProjectTable.vue b/frontend/src/components/v2/Model/PagedProjectTable.vue
index db7e0ff870..5902028854 100644
--- a/frontend/src/components/v2/Model/PagedProjectTable.vue
+++ b/frontend/src/components/v2/Model/PagedProjectTable.vue
@@ -11,6 +11,7 @@
:project-list="list"
:selected-project-names="selectedProjectNames"
:show-selection="showSelection"
+ :keyword="filter.query"
@update:selected-project-names="updateSelectedProjectNames"
/>
</template>