Skip to content

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

chore: optimize (#13424)

ecmadao9800bd0fef52
diff --git a/frontend/src/components/SensitiveData/SensitiveColumnView.vue b/frontend/src/components/SensitiveData/SensitiveColumnView.vue
index 1039f059ee..5c475fa16a 100644
--- a/frontend/src/components/SensitiveData/SensitiveColumnView.vue
+++ b/frontend/src/components/SensitiveData/SensitiveColumnView.vue
@@ -218,7 +218,7 @@ const updateList = async () => {
state.isLoading = true;
const distinctDatabaseNameList = uniq(
policyList.value.map((policy) => {
- const [databaseName] = getPolicyResourceNameAndType(policy.name);
+ const [databaseName, _] = getPolicyResourceNameAndType(policy.name);
return databaseName;
})
);
@@ -236,7 +236,10 @@ const updateList = async () => {
continue;
}
- const [databaseName] = getPolicyResourceNameAndType(policy.name);
+ const [databaseName, _] = getPolicyResourceNameAndType(policy.name);
+ if (!databaseName) {
+ continue;
+ }
const database = await databaseStore.getOrFetchDatabaseByName(databaseName);
for (const maskData of policy.maskingPolicy.maskData) {
diff --git a/frontend/src/grpcweb/middlewares/authInterceptorMiddleware.ts b/frontend/src/grpcweb/middlewares/authInterceptorMiddleware.ts
index 941c2d8bd8..b1fdbe82a0 100644
--- a/frontend/src/grpcweb/middlewares/authInterceptorMiddleware.ts
+++ b/frontend/src/grpcweb/middlewares/authInterceptorMiddleware.ts
@@ -41,7 +41,9 @@ export const authInterceptorMiddleware: ClientMiddleware<IgnoreErrorsOptions> =
try {
await useAuthStore().logout();
} finally {
- router.push({ name: AUTH_SIGNIN_MODULE });
+ router.push({ name: AUTH_SIGNIN_MODULE }).then(() => {
+ window.location.reload();
+ });
}
} else if (code === Status.PERMISSION_DENIED) {
// Jump to 403 page
diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vue
index 0af8b56694..ad3e9906ec 100644
--- a/frontend/src/layouts/ProjectV1Layout.vue
+++ b/frontend/src/layouts/ProjectV1Layout.vue
@@ -43,10 +43,12 @@ import { useRecentProjects } from "@/components/Project/useRecentProjects";
import QuickActionPanel from "@/components/QuickActionPanel.vue";
import NoPermissionPlaceholder from "@/components/misc/NoPermissionPlaceholder.vue";
import {
+ PROJECT_V1_ROUTE_DETAIL,
PROJECT_V1_ROUTE_DATABASES,
PROJECT_V1_ROUTE_DATABASE_GROUPS,
} from "@/router/dashboard/projectV1";
import { WORKSPACE_ROUTE_MY_ISSUES } from "@/router/dashboard/workspaceRoutes";
+import { useRecentVisit } from "@/router/useRecentVisit";
import { useAppFeature, useProjectV1Store, pushNotification } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import { useDatabaseV1List } from "@/store/modules/v1/databaseList";
@@ -67,6 +69,7 @@ const route = useRoute();
const router = useRouter();
const recentProjects = useRecentProjects();
const projectStore = useProjectV1Store();
+const { remove: removeVisit } = useRecentVisit();
const hideQuickAction = useAppFeature("bb.feature.console.hide-quick-action");
const hideDefaultProject = useAppFeature("bb.feature.project.hide-default");
@@ -88,6 +91,14 @@ watchEffect(async () => {
title: `Failed to fetch project ${props.projectId}`,
description: (err as ClientError).details,
});
+
+ const projectRoute = router.resolve({
+ name: PROJECT_V1_ROUTE_DETAIL,
+ params: {
+ projectId: props.projectId,
+ },
+ });
+ removeVisit(projectRoute.fullPath);
router.replace({
name: WORKSPACE_ROUTE_MY_ISSUES,
});
diff --git a/frontend/src/router/useRecentVisit.ts b/frontend/src/router/useRecentVisit.ts
index e21cb5d7eb..8e5ba67810 100644
--- a/frontend/src/router/useRecentVisit.ts
+++ b/frontend/src/router/useRecentVisit.ts
@@ -20,9 +20,8 @@ export function useRecentVisit() {
return recentVisit.value[0];
});
- const record = (path: string) => {
- const list = recentVisit.value;
- const index = list.findIndex((item) => {
+ const remove = (path: string) => {
+ const index = recentVisit.value.findIndex((item) => {
// We treat the two URLs "the same" when their urls'
// `path` are the same (means ignoring querystring and hash).
// e.g. "/db?environment=5003" & "/db?environment=5005"
@@ -31,23 +30,26 @@ export function useRecentVisit() {
return getPath(item) === getPath(path);
});
if (index >= 0) {
- // current page exists in the history already
- // pull it out before next step
- list.splice(index, 1);
+ recentVisit.value.splice(index, 1);
}
- // then prepend the latest item to the queue
- list.unshift(path);
+ };
+
+ const record = (path: string) => {
+ // current page exists in the history already
+ // pull it out before next step
+ remove(path);
// ensure the queue's length
// should be no more than (MAX_HISTORY + 1)
// because current page will always be the first one in the list
// but it will be not shown in kbar
- while (list.length > MAX_HISTORY + 1) {
- list.pop();
+ while (recentVisit.value.length > MAX_HISTORY + 1) {
+ recentVisit.value.pop();
}
};
return {
+ remove,
record,
lastVisit,
};
diff --git a/frontend/src/store/modules/auth.ts b/frontend/src/store/modules/auth.ts
index d6c6628b8e..be791730b0 100644
--- a/frontend/src/store/modules/auth.ts
+++ b/frontend/src/store/modules/auth.ts
@@ -62,10 +62,11 @@ export const useAuthStore = defineStore("auth_v1", () => {
const logout = async () => {
try {
await axios.post("/v1/auth/logout");
- currentUserId.value = undefined;
- restartAppRoot();
} catch {
// nothing
+ } finally {
+ currentUserId.value = undefined;
+ restartAppRoot();
}
};