Skip to content

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

chore: update user profile page (#10413)

boojack055dccb4f71a
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
index 86cc58b860..8244c945d5 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
@@ -134,29 +134,21 @@ import type { ColumnDef } from "@tanstack/vue-table";
import { sortBy } from "lodash-es";
import cloneDeep from "lodash-es/cloneDeep";
import { NPagination } from "naive-ui";
-import {
- computed,
- nextTick,
- PropType,
- reactive,
- ref,
- watch,
- watchEffect,
-} from "vue";
+import { computed, nextTick, PropType, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBGridColumn } from "@/bbkit/types";
import { PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL } from "@/router/dashboard/projectV1";
-import { usePolicyV1Store, usePageMode, useCurrentUserV1 } from "@/store";
+import { usePageMode, useCurrentUserV1 } from "@/store";
import { getProjectNameAndDatabaseGroupName } from "@/store/modules/v1/common";
import { ComposedDatabase, ComposedDatabaseGroup } from "@/types";
import {
- Policy,
- PolicyType,
- PolicyResourceType,
-} from "@/types/proto/v1/org_policy_service";
-import { databaseV1Url, getScrollParent } from "@/utils";
-import { isDatabaseV1Queryable, isPITRDatabaseV1, VueClass } from "@/utils";
+ databaseV1Url,
+ getScrollParent,
+ isDatabaseV1Queryable,
+ isPITRDatabaseV1,
+ VueClass,
+} from "@/utils";
import DatabaseGroupTableRow from "./DatabaseGroupTableRow.vue";
import DatabaseTableRow from "./DatabaseTableRow.vue";
import { isDatabase, Mode } from "./utils";
@@ -240,7 +232,6 @@ const props = defineProps({
const emit = defineEmits(["select-database"]);
const router = useRouter();
-const policyStore = usePolicyV1Store();
const currentUserV1 = useCurrentUserV1();
const { t } = useI18n();
const state = reactive<LocalState>({
@@ -279,19 +270,6 @@ const mixedDataList = computed(() => {
});
});
-const policyList = ref<Policy[]>([]);
-
-const preparePolicyList = () => {
- if (showSQLEditorLink.value) {
- policyStore
- .fetchPolicies({
- policyType: PolicyType.WORKSPACE_IAM,
- resourceType: PolicyResourceType.WORKSPACE,
- })
- .then((list) => (policyList.value = list));
- }
-};
-
const columnListMap = computed(() => {
const NAME = {
title: t("common.name"),
@@ -429,17 +407,6 @@ const showReservedDatabaseList = () => {
});
};
-const showSQLEditorLink = computed(() => {
- if (
- props.mode === "ALL_SHORT" ||
- props.mode === "ALL_TINY" ||
- props.mode === "PROJECT_SHORT"
- ) {
- return false;
- }
- return true;
-});
-
const allowQuery = (database: ComposedDatabase) => {
return isDatabaseV1Queryable(database, currentUserV1.value);
};
@@ -496,6 +463,4 @@ const clickDatabase = (
}
}
};
-
-watchEffect(preparePolicyList);
</script>
diff --git a/frontend/src/router/dashboard/database.ts b/frontend/src/router/dashboard/database.ts
index 003ea061a0..42f1380ed4 100644
--- a/frontend/src/router/dashboard/database.ts
+++ b/frontend/src/router/dashboard/database.ts
@@ -15,6 +15,8 @@ const databaseRoutes: RouteRecordRaw[] = [
getQuickActionList: () => {
return ["quickaction.bb.database.create"];
},
+ // Workspace-level database list is accessible to all users.
+ requiredProjectPermissionList: () => [],
},
components: {
content: () => import("@/views/DatabaseDashboard.vue"),
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index 24bf7dfb83..8051bedb14 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -1,8 +1,6 @@
import { startCase } from "lodash-es";
-import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
+import { RouteRecordRaw } from "vue-router";
import { t } from "@/plugins/i18n";
-import { useUserStore } from "@/store";
-import { unknownUser } from "@/types";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
import Home from "@/views/Home.vue";
import SettingSidebar from "@/views/SettingSidebar.vue";
@@ -11,6 +9,7 @@ import {
WORKSPACE_ROUTE_SLOW_QUERY,
WORKSPACE_ROUTE_EXPORT_CENTER,
WORKSPACE_ROUTE_ANOMALY_CENTER,
+ WORKSPACE_ROUTE_USER_PROFILE,
} from "./workspaceRoutes";
const workspaceRoutes: RouteRecordRaw[] = [
@@ -38,30 +37,6 @@ const workspaceRoutes: RouteRecordRaw[] = [
leftSidebar: true,
},
},
- {
- path: "403",
- name: "error.403",
- components: {
- content: () => import("@/views/Page403.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
- {
- path: "404",
- name: "error.404",
- components: {
- content: () => import("@/views/Page404.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: {
- content: true,
- leftSidebar: true,
- },
- },
{
path: "slow-query",
name: WORKSPACE_ROUTE_SLOW_QUERY,
@@ -109,20 +84,36 @@ const workspaceRoutes: RouteRecordRaw[] = [
// accessed endpoint, and maybe in the future, we will further provide a
// shortlink such as users/<<email>>
path: "users/:principalEmail",
- name: "workspace.profile",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const principalEmail = route.params.principalEmail as string;
- const user =
- useUserStore().getUserByEmail(principalEmail) ?? unknownUser();
- return user.title;
- },
- },
+ name: WORKSPACE_ROUTE_USER_PROFILE,
components: {
content: () => import("@/views/ProfileDashboard.vue"),
leftSidebar: SettingSidebar,
},
- props: { content: true },
+ props: true,
+ },
+ {
+ path: "403",
+ name: "error.403",
+ components: {
+ content: () => import("@/views/Page403.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
+ {
+ path: "404",
+ name: "error.404",
+ components: {
+ content: () => import("@/views/Page404.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
},
];
diff --git a/frontend/src/router/dashboard/workspaceRoutes.ts b/frontend/src/router/dashboard/workspaceRoutes.ts
index bfc73070b4..d89a525a3c 100644
--- a/frontend/src/router/dashboard/workspaceRoutes.ts
+++ b/frontend/src/router/dashboard/workspaceRoutes.ts
@@ -2,6 +2,7 @@ export const WORKSPACE_HOME_MODULE = "workspace.home";
export const WORKSPACE_ROUTE_SLOW_QUERY = "workspace.slow-query";
export const WORKSPACE_ROUTE_EXPORT_CENTER = "workspace.export-center";
export const WORKSPACE_ROUTE_ANOMALY_CENTER = "workspace.anomaly-center";
+export const WORKSPACE_ROUTE_USER_PROFILE = "workspace.user-profile";
export const DATABASE_ROUTE_DASHBOARD = "workspace.database";
export const INSTANCE_ROUTE_DASHBOARD = "workspace.instance";
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index b256e4a5bf..2ed5cd09bc 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -9,7 +9,6 @@ import {
useRouterStore,
useOnboardingStateStore,
useTabStore,
- useUserStore,
useCurrentUserV1,
usePageMode,
} from "@/store";
@@ -35,6 +34,7 @@ import {
WORKSPACE_ROUTE_SLOW_QUERY,
WORKSPACE_ROUTE_EXPORT_CENTER,
WORKSPACE_ROUTE_ANOMALY_CENTER,
+ WORKSPACE_ROUTE_USER_PROFILE,
} from "./dashboard/workspaceRoutes";
import { SETTING_ROUTE } from "./dashboard/workspaceSetting";
import sqlEditorRoutes, {
@@ -196,6 +196,7 @@ router.beforeEach((to, from, next) => {
to.name === WORKSPACE_ROUTE_SLOW_QUERY ||
to.name === WORKSPACE_ROUTE_EXPORT_CENTER ||
to.name === WORKSPACE_ROUTE_ANOMALY_CENTER ||
+ to.name === WORKSPACE_ROUTE_USER_PROFILE ||
to.name?.toString().startsWith(ENVIRONMENT_V1_ROUTE_DASHBOARD) ||
to.name?.toString().startsWith(INSTANCE_ROUTE_DASHBOARD) ||
to.name?.toString().startsWith(PROJECT_V1_ROUTE_DASHBOARD) ||
@@ -217,27 +218,10 @@ router.beforeEach((to, from, next) => {
}
const routerSlug = routerStore.routeSlug(to);
- const principalEmail = routerSlug.principalEmail;
const issueSlug = routerSlug.issueSlug;
const connectionSlug = routerSlug.connectionSlug;
const sheetSlug = routerSlug.sheetSlug;
- if (principalEmail) {
- useUserStore()
- .getOrFetchUserById(principalEmail)
- .then(() => {
- next();
- })
- .catch((error) => {
- next({
- name: "error.404",
- replace: false,
- });
- throw error;
- });
- return;
- }
-
if (issueSlug) {
// We've moved the preparation data fetch jobs into IssueDetail page
// so just next() here.
diff --git a/frontend/src/store/modules/router.ts b/frontend/src/store/modules/router.ts
index 98cc4f6b24..1818054b8d 100644
--- a/frontend/src/store/modules/router.ts
+++ b/frontend/src/store/modules/router.ts
@@ -17,19 +17,6 @@ export const useRouterStore = defineStore("router", {
return backPath;
},
routeSlug(currentRoute: RouteLocationNormalized): RouterSlug {
- {
- // /users/:email
- // Total 2 elements, 2nd element is the principal id
- const profileComponents = currentRoute.path.match(
- /\/users\/(\S+@\S+\.\S+)/
- ) || ["/", undefined];
- if (profileComponents[1]) {
- return {
- principalEmail: profileComponents[1],
- };
- }
- }
-
{
// /issue/:issueSlug
// Total 2 elements, 2nd element is the issue slug
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index eb8814f0bf..48d098f07b 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -44,7 +44,6 @@ export type RowStatus = "NORMAL" | "ARCHIVED";
// Router
export type RouterSlug = {
- principalEmail?: string;
issueSlug?: string;
connectionSlug?: string;
sheetSlug?: string;
diff --git a/frontend/src/views/ChangeHistoryDetail.vue b/frontend/src/views/ChangeHistoryDetail.vue
index 719f263ec1..5fb038c300 100644
--- a/frontend/src/views/ChangeHistoryDetail.vue
+++ b/frontend/src/views/ChangeHistoryDetail.vue
@@ -145,7 +145,7 @@
</button>
</a>
<highlight-code-block
- class="border p-2 whitespace-pre-wrap w-full"
+ class="border p-2 whitespace-pre-wrap w-full text-sm"
:code="changeHistoryStatement"
/>
<div
@@ -241,7 +241,7 @@
<DiffEditor
v-if="state.showDiff"
- class="h-[64rem] max-h-full border rounded-md overflow-clip"
+ class="h-[64rem] max-h-full border rounded-md text-sm overflow-clip"
:original="changeHistory.prevSchema"
:modified="changeHistory.schema"
:readonly="true"
@@ -249,7 +249,7 @@
<template v-else>
<div v-if="changeHistory.schema" class="space-y-2">
<highlight-code-block
- class="border p-2 whitespace-pre-wrap w-full"
+ class="border p-2 whitespace-pre-wrap w-full text-sm"
:code="changeHistorySchema"
data-label="bb-change-history-code-block"
/>
@@ -453,9 +453,6 @@ watch(
skipCache: false,
view: DatabaseMetadataView.DATABASE_METADATA_VIEW_BASIC,
}),
- changeHistoryStore.fetchChangeHistoryList({
- parent: changeHistoryParent.value,
- }),
changeHistoryStore.fetchChangeHistory({
name: changeHistoryName.value,
}),
diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vue
index e828567e72..00261aae96 100644
--- a/frontend/src/views/DatabaseDashboard.vue
+++ b/frontend/src/views/DatabaseDashboard.vue
@@ -61,7 +61,7 @@
<script lang="ts" setup>
import { NCheckbox } from "naive-ui";
-import { computed, watchEffect, onMounted, reactive, ref } from "vue";
+import { computed, watchEffect, onMounted, reactive } from "vue";
import { DatabaseV1Table } from "@/components/v2";
import { isDatabase } from "@/components/v2/Model/DatabaseV1Table/utils";
import {
@@ -69,7 +69,6 @@ import {
useDBGroupStore,
useDatabaseV1Store,
usePageMode,
- usePolicyV1Store,
useProjectV1ListByCurrentUser,
useUIStateStore,
} from "@/store";
@@ -80,11 +79,6 @@ import {
ComposedDatabaseGroup,
DEFAULT_PROJECT_V1_NAME,
} from "@/types";
-import {
- Policy,
- PolicyResourceType,
- PolicyType,
-} from "@/types/proto/v1/org_policy_service";
import {
SearchScopeId,
SearchParams,
@@ -120,21 +114,8 @@ const state = reactive<LocalState>({
});
const currentUserV1 = useCurrentUserV1();
-const policyStore = usePolicyV1Store();
const databaseV1Store = useDatabaseV1Store();
const dbGroupStore = useDBGroupStore();
-const policyList = ref<Policy[]>([]);
-
-const preparePolicyList = () => {
- policyStore
- .fetchPolicies({
- policyType: PolicyType.WORKSPACE_IAM,
- resourceType: PolicyResourceType.WORKSPACE,
- })
- .then((list) => (policyList.value = list));
-};
-
-watchEffect(preparePolicyList);
const isStandaloneMode = computed(() => pageMode.value === "STANDALONE");
@@ -175,17 +156,6 @@ onMounted(() => {
}
});
-const prepareDatabaseList = async () => {
- // It will also be called when user logout
- if (currentUserV1.value.name !== UNKNOWN_USER_NAME) {
- state.loading = true;
- await databaseV1Store.fetchDatabaseList({
- parent: "instances/-",
- });
- state.loading = false;
- }
-};
-
const databaseV1List = computed(() => {
return sortDatabaseV1List(databaseV1Store.databaseList).filter((db) =>
projectList.value.map((project) => project.name).includes(db.project)
@@ -206,7 +176,6 @@ const prepareDatabaseGroupList = async () => {
watchEffect(async () => {
state.loading = true;
- await prepareDatabaseList();
await prepareDatabaseGroupList();
state.loading = false;
});
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index cabda70e47..9087f6d0c4 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -241,6 +241,7 @@
</template>
<script lang="ts" setup>
+import { useTitle } from "@vueuse/core";
import { cloneDeep, isEmpty, isEqual } from "lodash-es";
import { NButton, NInput, NDropdown, DropdownOption } from "naive-ui";
import { nextTick, computed, onMounted, onUnmounted, reactive, ref } from "vue";
@@ -250,6 +251,7 @@ import LearnMoreLink from "@/components/LearnMoreLink.vue";
import RegenerateRecoveryCodesView from "@/components/RegenerateRecoveryCodesView.vue";
import UserAvatar from "@/components/User/UserAvatar.vue";
import PhoneNumberInput from "@/components/v2/Form/PhoneNumberInput.vue";
+import { WORKSPACE_ROUTE_USER_PROFILE } from "@/router/dashboard/workspaceRoutes";
import { SETTING_ROUTE_PROFILE_TWO_FACTOR } from "@/router/dashboard/workspaceSetting";
import {
featureToRef,
@@ -368,6 +370,12 @@ const allowSaveEdit = computed(() => {
);
});
+onMounted(async () => {
+ if (props.principalEmail) {
+ await useUserStore().getOrFetchUserById(props.principalEmail);
+ }
+});
+
const updateUser = <K extends keyof User>(field: K, value: User[K]) => {
if (!state.editingUser) return;
@@ -423,6 +431,16 @@ const saveEdit = async () => {
state.editingUser = undefined;
state.editing = false;
+
+ // If we update email, we need to redirect to the new email.
+ if (updateMask.includes("email") && props.principalEmail) {
+ router.replace({
+ name: WORKSPACE_ROUTE_USER_PROFILE,
+ params: {
+ principalEmail: userPatch.email,
+ },
+ });
+ }
};
const enable2FA = () => {
@@ -478,4 +496,6 @@ const dropDownOptions = computed((): DropdownOption[] => [
},
},
]);
+
+useTitle(user.value.title);
</script>