Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: ship missing project member list usages (#6130)
Liu Ji1691e3cfb469
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex aee90e5cf8..325d9a6336 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -231,7 +231,7 @@ import {} from "@/utils";import {hasFeature,- useCurrentUser,+ useCurrentUserV1,useDatabaseStore,useEnvironmentV1List,useProjectV1Store,@@ -273,7 +273,7 @@ const emit = defineEmits(["dismiss"]);const router = useRouter();-const currentUser = useCurrentUser();+const currentUserV1 = useCurrentUserV1();const projectV1Store = useProjectV1Store();const ghostDialog = ref<InstanceType<typeof GhostDialog>>();@@ -327,7 +327,7 @@ const databaseList = computed(() => {if (props.projectId) {list = databaseStore.getDatabaseListByProjectId(props.projectId);} else {- list = databaseStore.getDatabaseListByPrincipalId(currentUser.value.id);+ list = databaseStore.getDatabaseListByUser(currentUserV1.value);}list = list.filter((db) => db.syncStatus === "OK");diff --git a/frontend/src/components/DatabaseListSidePanel.vue b/frontend/src/components/DatabaseListSidePanel.vueindex 86f02d55ae..375dbac349 100644--- a/frontend/src/components/DatabaseListSidePanel.vue+++ b/frontend/src/components/DatabaseListSidePanel.vue@@ -20,6 +20,7 @@ import {useEnvironmentV1List,useCurrentUser,useDatabaseStore,+ useCurrentUserV1,} from "@/store";export default defineComponent({@@ -30,6 +31,7 @@ export default defineComponent({const router = useRouter();const currentUser = useCurrentUser();+ const currentUserV1 = useCurrentUserV1();const rawEnvironmentList = useEnvironmentV1List();@@ -50,7 +52,7 @@ export default defineComponent({// Use this to make the list reactive when project is transferred.const databaseList = computed((): Database[] => {return databaseStore- .getDatabaseListByPrincipalId(currentUser.value.id)+ .getDatabaseListByUser(currentUserV1.value).filter((db) => db.syncStatus === "OK");});diff --git a/frontend/src/components/DatabaseSelect.vue b/frontend/src/components/DatabaseSelect.vueindex 0b12348a10..439681b479 100644--- a/frontend/src/components/DatabaseSelect.vue+++ b/frontend/src/components/DatabaseSelect.vue@@ -22,7 +22,7 @@<script lang="ts">import { isNullOrUndefined } from "@/plugins/demo/utils";-import { useCurrentUser, useDatabaseStore } from "@/store";+import { useCurrentUserV1, useDatabaseStore } from "@/store";import {computed,reactive,@@ -95,7 +95,7 @@ export default defineComponent({selectedId: props.selectedId,});- const currentUser = useCurrentUser();+ const currentUserV1 = useCurrentUserV1();const prepareDatabaseList = () => {// TODO(tianzhou): Instead of fetching each time, we maybe able to let the outside context@@ -130,7 +130,7 @@ export default defineComponent({} else if (props.mode == "INSTANCE" && props.instanceId != UNKNOWN_ID) {list = databaseStore.getDatabaseListByInstanceId(props.instanceId);} else if (props.mode == "USER") {- list = databaseStore.getDatabaseListByPrincipalId(currentUser.value.id);+ list = databaseStore.getDatabaseListByUser(currentUserV1.value);}if (!isNullOrUndefined(props.engineTypeList)) {diff --git a/frontend/src/components/TransferDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm.vueindex 1b37d89bdc..2fdaeac6a2 100644--- a/frontend/src/components/TransferDatabaseForm.vue+++ b/frontend/src/components/TransferDatabaseForm.vue@@ -52,7 +52,7 @@ import {} from "../utils";import {pushNotification,- useCurrentUser,+ useCurrentUserV1,useDatabaseStore,useEnvironmentV1List,useProjectV1ByUID,@@ -78,7 +78,7 @@ const emit = defineEmits<{}>();const databaseStore = useDatabaseStore();-const currentUser = useCurrentUser();+const currentUserV1 = useCurrentUserV1();const state = reactive<LocalState>({transferSource:@@ -108,7 +108,7 @@ const rawDatabaseList = computed(() => {} else {const list = hasWorkspaceManageDatabasePermission.value? databaseStore.getDatabaseList()- : databaseStore.getDatabaseListByPrincipalId(currentUser.value.id);+ : databaseStore.getDatabaseListByUser(currentUserV1.value);return cloneDeep(list).filter((item: Database) =>String(item.project.id) !== props.projectId &&diff --git a/frontend/src/components/v2/Select/DatabaseSelect.vue b/frontend/src/components/v2/Select/DatabaseSelect.vueindex 70dc923b4e..8488cd7b25 100644--- a/frontend/src/components/v2/Select/DatabaseSelect.vue+++ b/frontend/src/components/v2/Select/DatabaseSelect.vue@@ -16,7 +16,7 @@ import { computed, watch, watchEffect } from "vue";import { NSelect, SelectOption } from "naive-ui";import { useI18n } from "vue-i18n";-import { useCurrentUser, useDatabaseStore } from "@/store";+import { useCurrentUserV1, useDatabaseStore } from "@/store";import {Database,DatabaseId,@@ -59,7 +59,7 @@ const emit = defineEmits<{}>();const { t } = useI18n();-const currentUser = useCurrentUser();+const currentUserV1 = useCurrentUserV1();const databaseStore = useDatabaseStore();const prepare = () => {@@ -68,7 +68,7 @@ const prepare = () => {watchEffect(prepare);const rawDatabaseList = computed(() => {- const list = databaseStore.getDatabaseListByPrincipalId(currentUser.value.id);+ const list = databaseStore.getDatabaseListByUser(currentUserV1.value);return list.filter((db) => {if (props.environment && props.environment !== String(UNKNOWN_ID)) {diff --git a/frontend/src/store/modules/database.ts b/frontend/src/store/modules/database.tsindex e1b6fca628..510c521229 100644--- a/frontend/src/store/modules/database.ts+++ b/frontend/src/store/modules/database.ts@@ -14,7 +14,6 @@ import {Instance,InstanceId,MaybeRef,- PrincipalId,Project,ResourceIdentifier,ResourceObject,@@ -24,7 +23,9 @@ import {import { useDataSourceStore } from "./dataSource";import { useInstanceStore } from "./instance";import { useLegacyProjectStore } from "./project";-import { isMemberOfProject } from "@/utils";+import { isMemberOfProjectV1 } from "@/utils";+import { useProjectV1Store } from "./v1";+import { User } from "@/types/proto/v1/auth_service";function convert(database: ResourceObject,@@ -170,11 +171,14 @@ export const useDatabaseStore = defineStore("database", {}return this.databaseListByInstanceId.get(instanceId) || [];},- getDatabaseListByPrincipalId(userId: PrincipalId): Database[] {+ getDatabaseListByUser(user: User): Database[] {const list: Database[] = [];for (const [_, databaseList] of this.databaseListByInstanceId) {databaseList.forEach((item: Database) => {- if (isMemberOfProject(item.project, userId)) {+ const projectV1 = useProjectV1Store().getProjectByUID(+ String(item.project.id)+ );+ if (isMemberOfProjectV1(projectV1.iamPolicy, user)) {list.push(item);}});diff --git a/frontend/src/views/AnomalyCenterDashboard.vue b/frontend/src/views/AnomalyCenterDashboard.vueindex 77aad19f7d..84ca88505a 100644--- a/frontend/src/views/AnomalyCenterDashboard.vue+++ b/frontend/src/views/AnomalyCenterDashboard.vue@@ -144,6 +144,7 @@ import {featureToRef,useAnomalyList,useCurrentUser,+ useCurrentUserV1,useDatabaseStore,useEnvironmentV1List,useInstanceList,@@ -172,6 +173,7 @@ export default defineComponent({const { t } = useI18n();const currentUser = useCurrentUser();+ const currentUserV1 = useCurrentUserV1();const state = reactive<LocalState>({selectedIndex: hasWorkspacePermission(@@ -195,7 +197,7 @@ export default defineComponent({watchEffect(prepareDatabaseList);const databaseList = computed(() => {- return databaseStore.getDatabaseListByPrincipalId(currentUser.value.id);+ return databaseStore.getDatabaseListByUser(currentUserV1.value);});const instanceList = useInstanceList();