Skip to content

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

chore: several ui and code updates (#9989)

ecmadao807e96997948
diff --git a/frontend/src/components/Changelist/ChangelistDetail/ApplyToDatabasePanel/ApplyToDatabasePanel.vue b/frontend/src/components/Changelist/ChangelistDetail/ApplyToDatabasePanel/ApplyToDatabasePanel.vue
index 0ad726fc16..d004c8558c 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/ApplyToDatabasePanel/ApplyToDatabasePanel.vue
+++ b/frontend/src/components/Changelist/ChangelistDetail/ApplyToDatabasePanel/ApplyToDatabasePanel.vue
@@ -7,11 +7,13 @@
>
<div v-if="ready" class="flex flex-col gap-y-4">
<ProjectStandardView
- :state="state"
:project="project"
:database-list="schemaDatabaseList"
:environment-list="environmentList"
- @select-database="handleSelectDatabase"
+ @select-databases="
+ (...dbUidList) =>
+ (state.selectedDatabaseUidList = new Set(dbUidList))
+ "
>
<template #header>
<div class="flex items-center justify-end mx-2">
@@ -83,9 +85,7 @@ import { zindexable as vZindexable } from "vdirs";
import { computed, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
-import ProjectStandardView, {
- ProjectStandardViewState,
-} from "@/components/AlterSchemaPrepForm/ProjectStandardView.vue";
+import ProjectStandardView from "@/components/AlterSchemaPrepForm/ProjectStandardView.vue";
import { ErrorTipsButton, SearchBox } from "@/components/v2";
import {
useDatabaseV1Store,
@@ -103,9 +103,10 @@ import {
import { generateIssueName } from "../common";
import { useChangelistDetailContext } from "../context";
-type LocalState = ProjectStandardViewState & {
+type LocalState = {
keyword: string;
isGenerating: boolean;
+ selectedDatabaseUidList: Set<string>;
};
const { t } = useI18n();
@@ -118,8 +119,7 @@ const {
} = useChangelistDetailContext();
const state = reactive<LocalState>({
- selectedDatabaseUidListForEnvironment: new Map(),
- alterType: "MULTI_DB",
+ selectedDatabaseUidList: new Set<string>(),
keyword: "",
isGenerating: false,
});
@@ -183,11 +183,7 @@ const schemalessDatabaseList = computed(() => {
});
const flattenSelectedDatabaseUidList = computed(() => {
- const flattenDatabaseIdList: string[] = [];
- for (const databaseIdList of state.selectedDatabaseUidListForEnvironment.values()) {
- flattenDatabaseIdList.push(...databaseIdList);
- }
- return flattenDatabaseIdList;
+ return [...state.selectedDatabaseUidList];
});
const nextButtonErrors = computed(() => {
@@ -199,10 +195,6 @@ const nextButtonErrors = computed(() => {
return errors;
});
-const handleSelectDatabase = (db: ComposedDatabase) => {
- console.log("handleSelectDatabase", db);
-};
-
const handleClickNext = async () => {
state.isGenerating = true;
try {
@@ -238,7 +230,7 @@ const handleClickNext = async () => {
};
const reset = () => {
- state.selectedDatabaseUidListForEnvironment = new Map();
+ state.selectedDatabaseUidList = new Set();
state.keyword = "";
};
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index 9804be5e85..499cfe0471 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -10,7 +10,9 @@
<template #icon>
<component :is="quickAction.icon" class="h-4 w-4" />
</template>
- {{ quickAction.title }}
+ <NEllipsis :line-clamp="1">
+ {{ quickAction.title }}
+ </NEllipsis>
</NButton>
</template>
</div>
@@ -102,6 +104,7 @@ import {
FileSearchIcon,
FileDownIcon,
} from "lucide-vue-next";
+import { NEllipsis } from "naive-ui";
import { reactive, PropType, computed, watch, VNode, h } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
diff --git a/frontend/src/components/SQLReview/SQLReviewCreation.vue b/frontend/src/components/SQLReview/SQLReviewCreation.vue
index 2b7ac5277b..ea7017f815 100644
--- a/frontend/src/components/SQLReview/SQLReviewCreation.vue
+++ b/frontend/src/components/SQLReview/SQLReviewCreation.vue
@@ -79,7 +79,6 @@ interface LocalState {
selectedRuleList: RuleTemplate[];
selectedTemplate: SQLReviewPolicyTemplate | undefined;
ruleUpdated: boolean;
- showAlertModal: boolean;
pendingApplyTemplate: SQLReviewPolicyTemplate | undefined;
}
@@ -124,7 +123,6 @@ const state = reactive<LocalState>({
? rulesToTemplate(props.policy, false /* withDisabled=false */)
: undefined,
ruleUpdated: false,
- showAlertModal: false,
pendingApplyTemplate: undefined,
});
diff --git a/frontend/src/views/ExportCenter/index.vue b/frontend/src/views/ExportCenter/index.vue
index d4d7539571..3d4116df88 100644
--- a/frontend/src/views/ExportCenter/index.vue
+++ b/frontend/src/views/ExportCenter/index.vue
@@ -1,29 +1,15 @@
<template>
<div class="w-full px-4 py-6">
<div
- class="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-y-2"
+ class="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-2"
>
- <div class="flex max-w-full items-center gap-x-4">
- <NInputGroup>
- <ProjectSelect
- :project="state.filterParams.project?.uid ?? String(UNKNOWN_ID)"
- :include-all="true"
- @update:project="changeProjectId"
- />
- <InstanceSelect
- class="!w-48"
- :instance="state.filterParams.instance?.uid ?? String(UNKNOWN_ID)"
- :include-all="true"
- @update:instance="changeInstanceId"
- />
- <DatabaseSelect
- :database="state.filterParams.database?.uid ?? String(UNKNOWN_ID)"
- :instance="state.filterParams.instance?.uid"
- :project="state.filterParams.project?.uid"
- :include-all="true"
- @update:database="changeDatabaseId"
- />
- </NInputGroup>
+ <div class="flex flex-1 max-w-full items-center gap-x-2">
+ <AdvancedSearchBox
+ v-model:params="state.params"
+ :autofocus="false"
+ :placeholder="''"
+ :support-option-id-list="supportOptionIdList"
+ />
<NButton
v-if="filterIssueId !== String(UNKNOWN_ID)"
@click="clearFilterIssueId"
@@ -47,8 +33,8 @@
<RequestExportPanel
v-if="state.showRequestExportPanel"
- :project-id="state.filterParams.project?.uid"
- :database-id="state.filterParams.database?.uid"
+ :project-id="selectedProject?.uid"
+ :database-id="selectedDatabase?.uid"
:redirect-to-issue-page="true"
:statement-only="true"
@close="state.showRequestExportPanel = false"
@@ -62,12 +48,11 @@
</template>
<script lang="ts" setup>
-import { NButton, NInputGroup } from "naive-ui";
+import { NButton } from "naive-ui";
import { computed, reactive, watchEffect } from "vue";
import { useRoute, useRouter } from "vue-router";
import RequestExportPanel from "@/components/Issue/panel/RequestExportPanel/index.vue";
import { getExpiredDateTime } from "@/components/ProjectMember/ProjectRoleTable/utils";
-import { ProjectSelect, InstanceSelect, DatabaseSelect } from "@/components/v2";
import {
featureToRef,
useCurrentUserV1,
@@ -78,15 +63,16 @@ import {
useProjectV1Store,
} from "@/store";
import { UNKNOWN_ID } from "@/types";
+import { SearchParams, SearchScopeId } from "@/utils";
import { convertFromExpr } from "@/utils/issue/cel";
import ExportRecordTable from "./ExportRecordTable.vue";
-import { FilterParams, ExportRecord } from "./types";
+import { ExportRecord } from "./types";
interface LocalState {
- filterParams: FilterParams;
exportRecords: ExportRecord[];
showRequestExportPanel: boolean;
showFeatureModal: boolean;
+ params: SearchParams;
}
const issueDescriptionRegexp = /^#(\d+)$/;
@@ -96,19 +82,51 @@ const router = useRouter();
const currentUser = useCurrentUserV1();
const projectIamPolicyStore = useProjectIamPolicyStore();
const databaseStore = useDatabaseV1Store();
+const projectStore = useProjectV1Store();
+const instanceStore = useInstanceV1Store();
const { projectList } = useProjectV1ListByCurrentUser();
const state = reactive<LocalState>({
- filterParams: {
- project: undefined,
- instance: undefined,
- database: undefined,
- },
exportRecords: [],
showRequestExportPanel: false,
showFeatureModal: false,
+ params: {
+ query: "",
+ scopes: [],
+ },
});
const hasDataAccessControlFeature = featureToRef("bb.feature.access-control");
+const selectedProject = computed(() => {
+ const project = state.params.scopes.find(
+ (scope) => scope.id === "project"
+ )?.value;
+ if (!project) {
+ return;
+ }
+ return projectStore.getProjectByName(`projects/${project}`);
+});
+
+const selectedInstance = computed(() => {
+ const instance = state.params.scopes.find(
+ (scope) => scope.id === "instance"
+ )?.value;
+ if (!instance) {
+ return;
+ }
+ return instanceStore.getInstanceByName(`instances/${instance}`);
+});
+
+const selectedDatabase = computed(() => {
+ const database = state.params.scopes.find(
+ (scope) => scope.id === "database"
+ )?.value;
+ if (!database) {
+ return;
+ }
+ const uid = database.split("-").slice(-1)[0];
+ return databaseStore.getDatabaseByUID(uid);
+});
+
const filterIssueId = computed(() => {
const hash = route.hash.replace(/^#+/g, "");
const maybeIssueId = parseInt(hash, 10);
@@ -126,18 +144,18 @@ const filterExportRecords = computed(() => {
}
}
- if (state.filterParams.project) {
- if (record.database.project !== state.filterParams.project.name) {
+ if (selectedProject.value) {
+ if (record.database.project !== selectedProject.value.name) {
return false;
}
}
- if (state.filterParams.instance) {
- if (record.database.instance !== state.filterParams.instance.name) {
+ if (selectedInstance.value) {
+ if (record.database.instance !== selectedInstance.value.name) {
return false;
}
}
- if (state.filterParams.database) {
- if (record.database.name !== state.filterParams.database.name) {
+ if (selectedDatabase.value) {
+ if (record.database.name !== selectedDatabase.value.name) {
return false;
}
}
@@ -224,37 +242,16 @@ const handleRequestExportClick = () => {
state.showRequestExportPanel = true;
};
-const changeProjectId = (id: string | undefined) => {
- if (id && id !== String(UNKNOWN_ID)) {
- const project = useProjectV1Store().getProjectByUID(id);
- state.filterParams.project = project;
- } else {
- state.filterParams.project = undefined;
- }
-};
-
-const changeInstanceId = (uid: string | undefined) => {
- if (uid && uid !== String(UNKNOWN_ID)) {
- const instance = useInstanceV1Store().getInstanceByUID(uid);
- state.filterParams.instance = instance;
- } else {
- state.filterParams.instance = undefined;
- }
-};
-
-const changeDatabaseId = (uid: string | undefined) => {
- if (uid && uid !== String(UNKNOWN_ID)) {
- const database = useDatabaseV1Store().getDatabaseByUID(uid);
- state.filterParams.database = database;
- } else {
- state.filterParams.database = undefined;
- }
-};
-
const clearFilterIssueId = () => {
router.replace({
...route,
hash: "",
});
};
+
+const supportOptionIdList = computed((): SearchScopeId[] => [
+ "project",
+ "instance",
+ "database",
+]);
</script>
diff --git a/frontend/src/views/ExportCenter/types.ts b/frontend/src/views/ExportCenter/types.ts
index e5de9742f8..db11067ad9 100644
--- a/frontend/src/views/ExportCenter/types.ts
+++ b/frontend/src/views/ExportCenter/types.ts
@@ -1,13 +1,4 @@
import { ComposedDatabase, DatabaseResource } from "@/types";
-import { Database } from "@/types/proto/v1/database_service";
-import { Instance } from "@/types/proto/v1/instance_service";
-import { Project } from "@/types/proto/v1/project_service";
-
-export interface FilterParams {
- project: Project | undefined; // undefined to "All"
- instance: Instance | undefined; // undefined to "All"
- database: Database | undefined; // undefined to "All"
-}
export interface ExportRecord {
databaseResource: DatabaseResource;
diff --git a/frontend/src/views/ProjectDashboard.vue b/frontend/src/views/ProjectDashboard.vue
index 21619eeff2..c92d18b5d9 100644
--- a/frontend/src/views/ProjectDashboard.vue
+++ b/frontend/src/views/ProjectDashboard.vue
@@ -1,8 +1,9 @@
<template>
<div class="flex flex-col space-y-4">
- <div class="px-4 flex justify-end items-center">
+ <div class="px-4 flex justify-end">
<SearchBox
v-model:value="state.searchText"
+ class="!max-w-full md:!max-w-[18rem]"
:placeholder="$t('common.filter-by-name')"
:autofocus="true"
/>