Skip to content

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

refactor: use route name instead of the path (#10295)

ecmadao2191d7762e22
diff --git a/frontend/src/components/Branch/BranchCreateView.vue b/frontend/src/components/Branch/BranchCreateView.vue
index cc38172540..bdfaf2beae 100644
--- a/frontend/src/components/Branch/BranchCreateView.vue
+++ b/frontend/src/components/Branch/BranchCreateView.vue
@@ -89,7 +89,7 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import SchemaEditorLite from "@/components/SchemaEditorLite";
import { databaseServiceClient } from "@/grpcweb";
-import { PROJECT_V1_BRANCHE_DETAIL } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_BRANCH_DETAIL } from "@/router/dashboard/projectV1";
import {
pushNotification,
useDatabaseV1Store,
@@ -295,7 +295,7 @@ const handleConfirm = async () => {
// Go to branch detail page after created.
router.replace({
- name: PROJECT_V1_BRANCHE_DETAIL,
+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,
params: {
branchName: branchId.value,
},
diff --git a/frontend/src/components/Branch/BranchDataTable/cells/BranchNameCell.vue b/frontend/src/components/Branch/BranchDataTable/cells/BranchNameCell.vue
index d52ffbff72..b935610ec3 100644
--- a/frontend/src/components/Branch/BranchDataTable/cells/BranchNameCell.vue
+++ b/frontend/src/components/Branch/BranchDataTable/cells/BranchNameCell.vue
@@ -21,7 +21,7 @@ import { ShieldAlertIcon } from "lucide-vue-next";
import { NTooltip } from "naive-ui";
import { computed } from "vue";
import { useRouter } from "vue-router";
-import { PROJECT_V1_BRANCHE_DETAIL } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_BRANCH_DETAIL } from "@/router/dashboard/projectV1";
import { useProjectV1Store } from "@/store";
import {
getProjectAndBranchId,
@@ -60,7 +60,7 @@ const isProtected = computed(() => {
const handleBranchClick = async () => {
const [_, branchId] = getProjectAndBranchId(props.branch.name);
router.push({
- name: PROJECT_V1_BRANCHE_DETAIL,
+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,
params: {
branchName: `${branchId}`,
},
diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vue
index c7317d7df9..85fde8ca6d 100644
--- a/frontend/src/components/Branch/BranchDetailView.vue
+++ b/frontend/src/components/Branch/BranchDetailView.vue
@@ -132,11 +132,11 @@ import DatabaseInfo from "@/components/DatabaseInfo.vue";
import { validateDatabaseMetadata } from "@/components/SchemaEditorV1/utils";
import TargetDatabasesSelectPanel from "@/components/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue";
import {
- PROJECT_V1_BRANCHES,
- PROJECT_V1_BRANCHE_DETAIL,
- PROJECT_V1_BRANCHE_MERGE,
- PROJECT_V1_BRANCHE_ROLLOUT,
- PROJECT_V1_BRANCHE_REBASE,
+ PROJECT_V1_ROUTE_BRANCHES,
+ PROJECT_V1_ROUTE_BRANCH_DETAIL,
+ PROJECT_V1_ROUTE_BRANCH_MERGE,
+ PROJECT_V1_ROUTE_BRANCH_ROLLOUT,
+ PROJECT_V1_ROUTE_BRANCH_REBASE,
} from "@/router/dashboard/projectV1";
import { pushNotification, useDatabaseV1Store } from "@/store";
import { useBranchStore } from "@/store/modules/branch";
@@ -301,7 +301,7 @@ const handleParentBranchClick = async () => {
const [_, branchId] = getProjectAndBranchId(parentBranch.value.name);
router.push({
- name: PROJECT_V1_BRANCHE_DETAIL,
+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,
params: {
branchName: `${branchId}`,
},
@@ -396,7 +396,7 @@ const handleSaveBranch = async () => {
const handleGotoMergeBranch = () => {
router.push({
- name: PROJECT_V1_BRANCHE_MERGE,
+ name: PROJECT_V1_ROUTE_BRANCH_MERGE,
params: {
branchName: props.cleanBranch.branchId,
},
@@ -404,7 +404,7 @@ const handleGotoMergeBranch = () => {
};
const handleGotoRebaseBranch = () => {
router.push({
- name: PROJECT_V1_BRANCHE_REBASE,
+ name: PROJECT_V1_ROUTE_BRANCH_REBASE,
params: {
branchName: props.cleanBranch.branchId,
},
@@ -413,7 +413,7 @@ const handleGotoRebaseBranch = () => {
const handleApplyBranchToDatabase = () => {
router.push({
- name: PROJECT_V1_BRANCHE_ROLLOUT,
+ name: PROJECT_V1_ROUTE_BRANCH_ROLLOUT,
params: {
branchName: props.cleanBranch.branchId,
},
@@ -492,7 +492,7 @@ const deleteBranch = async () => {
const branch = props.dirtyBranch;
await branchStore.deleteBranch(branch.name);
router.replace({
- name: PROJECT_V1_BRANCHES,
+ name: PROJECT_V1_ROUTE_BRANCHES,
});
};
</script>
diff --git a/frontend/src/components/Branch/BranchMergeView/SelectBranchStep.vue b/frontend/src/components/Branch/BranchMergeView/SelectBranchStep.vue
index 0d571cd517..13c50632ab 100644
--- a/frontend/src/components/Branch/BranchMergeView/SelectBranchStep.vue
+++ b/frontend/src/components/Branch/BranchMergeView/SelectBranchStep.vue
@@ -122,7 +122,7 @@ import { ref, watch } from "vue";
import { DiffEditor } from "@/components/MonacoEditor";
import SchemaEditorLite from "@/components/SchemaEditorLite";
import MaskSpinner from "@/components/misc/MaskSpinner.vue";
-import { PROJECT_V1_BRANCHE_REBASE } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_BRANCH_REBASE } from "@/router/dashboard/projectV1";
import { useDatabaseV1Store } from "@/store";
import { ComposedProject } from "@/types";
import { Branch } from "@/types/proto/v1/branch_service";
@@ -170,7 +170,7 @@ const headBranchFilter = (branch: Branch) => {
const rebaseLink = (headBranch: Branch, targetBranch: Branch) => {
return {
- name: PROJECT_V1_BRANCHE_REBASE,
+ name: PROJECT_V1_ROUTE_BRANCH_REBASE,
params: {
branchName: headBranch.branchId,
},
diff --git a/frontend/src/components/Changelist/ChangelistDetail/ChangelistDetail.vue b/frontend/src/components/Changelist/ChangelistDetail/ChangelistDetail.vue
index 65a03ab5cd..a3b7f20ed0 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/ChangelistDetail.vue
+++ b/frontend/src/components/Changelist/ChangelistDetail/ChangelistDetail.vue
@@ -45,7 +45,7 @@ import { computed, reactive, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";
-import { PROJECT_V1_CHANGELIST_DETAIL } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_CHANGELIST_DETAIL } from "@/router/dashboard/projectV1";
import { pushNotification, useChangelistStore } from "@/store";
import {
Changelist_Change as Change,
@@ -125,7 +125,7 @@ const handleReorderMove = (row: number, delta: -1 | 1) => {
};
const documentTitle = computed(() => {
- if (route.name !== PROJECT_V1_CHANGELIST_DETAIL) {
+ if (route.name !== PROJECT_V1_ROUTE_CHANGELIST_DETAIL) {
return undefined;
}
return changelist.value.description;
diff --git a/frontend/src/components/Changelist/ChangelistDetail/DeleteChangelistButton.vue b/frontend/src/components/Changelist/ChangelistDetail/DeleteChangelistButton.vue
index 0b62cb1e8b..f7bcd89817 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/DeleteChangelistButton.vue
+++ b/frontend/src/components/Changelist/ChangelistDetail/DeleteChangelistButton.vue
@@ -37,7 +37,7 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import ErrorList from "@/components/misc/ErrorList.vue";
-import { PROJECT_V1_CHANGELISTS } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_CHANGELISTS } from "@/router/dashboard/projectV1";
import { pushNotification, useChangelistStore } from "@/store";
import { useChangelistDetailContext } from "./context";
@@ -61,7 +61,7 @@ const handleDelete = async () => {
try {
await useChangelistStore().deleteChangelist(changelist.value.name);
router.replace({
- name: PROJECT_V1_CHANGELISTS,
+ name: PROJECT_V1_ROUTE_CHANGELISTS,
});
pushNotification({
module: "bytebase",
diff --git a/frontend/src/components/CommonSidebar.vue b/frontend/src/components/CommonSidebar.vue
index c52c32a689..e251d05b07 100644
--- a/frontend/src/components/CommonSidebar.vue
+++ b/frontend/src/components/CommonSidebar.vue
@@ -14,13 +14,13 @@
<div
v-else-if="item.type === 'div'"
:class="[parentRouteClass, getItemClass(item.path)]"
- @click="onClick(i)"
+ @click="onClick(item, `${i}`, $event)"
>
<component :is="item.icon" class="mr-2 w-5 h-5 text-gray-500" />
{{ item.title }}
<div v-if="item.children.length > 0" class="ml-auto text-gray-500">
<ChevronRight
- v-if="!state.expandedSidebar.has(i)"
+ v-if="!state.expandedSidebar.has(`${i}`)"
class="w-4 h-4"
/>
<ChevronDown v-else class="w-4 h-4" />
@@ -30,7 +30,7 @@
v-if="item.type === 'link'"
:class="[parentRouteClass, getItemClass(item.path)]"
:href="item.path"
- @click="$emit('select', item.path)"
+ @click="$emit('select', item.path, $event)"
>
<component :is="item.icon" class="mr-2 w-5 h-5 text-gray-500" />
{{ item.title }}
@@ -40,7 +40,7 @@
class="border-t border-gray-300 my-2.5 mr-4 ml-2"
/>
<div
- v-if="item.children.length > 0 && state.expandedSidebar.has(i)"
+ v-if="item.children.length > 0 && state.expandedSidebar.has(`${i}`)"
class="space-y-1 mt-1"
>
<template v-for="(child, j) in item.children" :key="`${i}-${j}`">
@@ -48,17 +48,24 @@
v-if="child.type === 'link'"
:class="[childRouteClass, getItemClass(child.path)]"
:href="child.path"
- @click="$emit('select', child.path)"
+ @click="$emit('select', child.path, $event)"
>
{{ child.title }}
</a>
<router-link
- v-else-if="child.type === 'route'"
+ v-else-if="child.type === 'route' && child.path"
:to="child.path"
:class="[childRouteClass, getItemClass(child.path)]"
>
{{ child.title }}
</router-link>
+ <div
+ v-else-if="child.type === 'div'"
+ :class="[childRouteClass, getItemClass(child.path)]"
+ @click="onClick(child, `${i}-${j}`, $event)"
+ >
+ {{ child.title }}
+ </div>
</template>
</div>
</div>
@@ -76,16 +83,11 @@ export interface SidebarItem {
icon?: VNode;
hide?: boolean;
type: "route" | "div" | "divider" | "link";
- children?: {
- title: string;
- path: string;
- hide?: boolean;
- type: "route" | "link" | "divider";
- }[];
+ children?: SidebarItem[];
}
interface LocalState {
- expandedSidebar: Set<number>;
+ expandedSidebar: Set<string>;
}
const props = withDefaults(
@@ -101,7 +103,7 @@ const props = withDefaults(
);
const emit = defineEmits<{
- (event: "select", path: string | undefined): void;
+ (event: "select", path: string | undefined, e: MouseEvent): void;
}>();
const state = reactive<LocalState>({
@@ -134,20 +136,19 @@ onMounted(() => {
state.expandedSidebar.clear();
for (let i = 0; i < filteredSidebarList.value.length; i++) {
if (filteredSidebarList.value[i].children.length > 0) {
- state.expandedSidebar.add(i);
+ state.expandedSidebar.add(`${i}`);
}
}
});
-const onClick = (index: number) => {
- const sidebar = filteredSidebarList.value[index];
+const onClick = (sidebar: SidebarItem, key: string, e: MouseEvent) => {
if (sidebar.path) {
- return emit("select", sidebar.path);
+ return emit("select", sidebar.path, e);
}
- if (state.expandedSidebar.has(index)) {
- state.expandedSidebar.delete(index);
+ if (state.expandedSidebar.has(key)) {
+ state.expandedSidebar.delete(key);
} else {
- state.expandedSidebar.add(index);
+ state.expandedSidebar.add(key);
}
};
</script>
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
index 1821d402df..516df68939 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
@@ -48,9 +48,9 @@ import { useRouter } from "vue-router";
import { Drawer, DrawerContent } from "@/components/v2";
import { buildCELExpr } from "@/plugins/cel/logic";
import {
- PROJECT_V1_DATABASE_GROUPS,
- PROJECT_V1_DATABASE_GROUP_DETAIL,
- PROJECT_V1_DATABASE_GROUP_TABLE_GROUP_DETAIL,
+ PROJECT_V1_ROUTE_DATABASE_GROUPS,
+ PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
+ PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL,
} from "@/router/dashboard/projectV1";
import {
pushNotification,
@@ -169,10 +169,11 @@ const doDelete = () => {
const databaseGroup = props.databaseGroup as DatabaseGroup;
await dbGroupStore.deleteDatabaseGroup(databaseGroup.name);
if (
- router.currentRoute.value.name === PROJECT_V1_DATABASE_GROUP_DETAIL
+ router.currentRoute.value.name ===
+ PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL
) {
router.replace({
- name: PROJECT_V1_DATABASE_GROUPS,
+ name: PROJECT_V1_ROUTE_DATABASE_GROUPS,
});
}
} else if (props.resourceType === "SCHEMA_GROUP") {
@@ -181,7 +182,7 @@ const doDelete = () => {
await dbGroupStore.deleteSchemaGroup(schemaGroupName);
if (
router.currentRoute.value.name ===
- PROJECT_V1_DATABASE_GROUP_TABLE_GROUP_DETAIL
+ PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL
) {
const [_, databaseGroupName] =
getProjectNameAndDatabaseGroupNameAndSchemaGroupName(
diff --git a/frontend/src/components/IdentityProviderCreateForm.vue b/frontend/src/components/IdentityProviderCreateForm.vue
index 807f4ffa81..45cd8cecd3 100644
--- a/frontend/src/components/IdentityProviderCreateForm.vue
+++ b/frontend/src/components/IdentityProviderCreateForm.vue
@@ -814,6 +814,7 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";
import { identityProviderClient } from "@/grpcweb";
+import { SETTING_ROUTE_WORKSPACE_SSO } from "@/router/dashboard/workspaceSetting";
import { pushNotification, useActuatorV1Store } from "@/store";
import { useIdentityProviderStore } from "@/store/modules/idp";
import {
@@ -1206,7 +1207,7 @@ const handleDeleteButtonClick = async () => {
title: "Archive SSO succeed",
});
router.push({
- name: "setting.workspace.sso",
+ name: SETTING_ROUTE_WORKSPACE_SSO,
});
}
};
@@ -1226,7 +1227,7 @@ const handleRestoreButtonClick = async () => {
const handleCancelButtonClick = () => {
router.push({
- name: "setting.workspace.sso",
+ name: SETTING_ROUTE_WORKSPACE_SSO,
});
};
@@ -1287,7 +1288,7 @@ const handleCreateButtonClick = async () => {
title: "Create SSO succeed",
});
router.push({
- name: "setting.workspace.sso",
+ name: SETTING_ROUTE_WORKSPACE_SSO,
});
};
diff --git a/frontend/src/components/IdentityProviderTable.vue b/frontend/src/components/IdentityProviderTable.vue
index 6117ef7930..25a646274f 100644
--- a/frontend/src/components/IdentityProviderTable.vue
+++ b/frontend/src/components/IdentityProviderTable.vue
@@ -28,6 +28,7 @@
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
+import { SETTING_ROUTE_WORKSPACE_SSO_DETAIL } from "@/router/dashboard/workspaceSetting";
import { IdentityProvider } from "@/types/proto/v1/idp_service";
const props = defineProps<{
@@ -56,7 +57,7 @@ const columnList = computed(() => [
const clickIdentityProvider = function (section: number, row: number) {
const identityProvider = props.identityProviderList[row];
router.push({
- name: "setting.workspace.sso.detail",
+ name: SETTING_ROUTE_WORKSPACE_SSO_DETAIL,
params: {
ssoName: identityProvider.name,
},
diff --git a/frontend/src/components/Project/ProjectSidebarV1.vue b/frontend/src/components/Project/ProjectSidebarV1.vue
index d8efe34553..3d564dbd82 100644
--- a/frontend/src/components/Project/ProjectSidebarV1.vue
+++ b/frontend/src/components/Project/ProjectSidebarV1.vue
@@ -3,6 +3,7 @@
:key="'project'"
:item-list="projectSidebarItemList"
:get-item-class="getItemClass"
+ @select="onSelect"
/>
</template>
@@ -24,15 +25,29 @@ import { useI18n } from "vue-i18n";
import { useRouter, useRoute } from "vue-router";
import { SidebarItem } from "@/components/CommonSidebar.vue";
import {
- PROJECT_V1_WEBHOOK_CREATE,
- PROJECT_V1_WEBHOOK_DETAIL,
- PROJECT_V1_BRANCHE_DETAIL,
- PROJECT_V1_BRANCHE_ROLLOUT,
- PROJECT_V1_BRANCHE_MERGE,
- PROJECT_V1_BRANCHE_REBASE,
- PROJECT_V1_CHANGELIST_DETAIL,
- PROJECT_V1_DATABASE_GROUP_DETAIL,
- PROJECT_V1_DATABASE_GROUP_TABLE_GROUP_DETAIL,
+ PROJECT_V1_ROUTE_DATABASES,
+ PROJECT_V1_ROUTE_ISSUES,
+ PROJECT_V1_ROUTE_CHANGE_HISTORIES,
+ PROJECT_V1_ROUTE_SYNC_SCHEMA,
+ PROJECT_V1_ROUTE_SLOW_QUERIES,
+ PROJECT_V1_ROUTE_ANOMALIES,
+ PROJECT_V1_ROUTE_ACTIVITIES,
+ PROJECT_V1_ROUTE_GITOPS,
+ PROJECT_V1_ROUTE_MEMBERS,
+ PROJECT_V1_ROUTE_SETTINGS,
+ PROJECT_V1_ROUTE_WEBHOOKS,
+ PROJECT_V1_ROUTE_WEBHOOK_CREATE,
+ PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
+ PROJECT_V1_ROUTE_BRANCHES,
+ PROJECT_V1_ROUTE_BRANCH_DETAIL,
+ PROJECT_V1_ROUTE_BRANCH_ROLLOUT,
+ PROJECT_V1_ROUTE_BRANCH_MERGE,
+ PROJECT_V1_ROUTE_BRANCH_REBASE,
+ PROJECT_V1_ROUTE_CHANGELISTS,
+ PROJECT_V1_ROUTE_CHANGELIST_DETAIL,
+ PROJECT_V1_ROUTE_DATABASE_GROUPS,
+ PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
+ PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL,
} from "@/router/dashboard/projectV1";
import { useCurrentUserIamPolicy } from "@/store";
import { DEFAULT_PROJECT_V1_NAME } from "@/types";
@@ -42,12 +57,13 @@ import { useCurrentProject } from "./useCurrentProject";
interface ProjectSidebarItem extends SidebarItem {
title: string;
- type: "div" | "route";
+ type: "div";
+ path?: string;
children?: {
title: string;
path: string;
hide?: boolean;
- type: "route";
+ type: "div";
}[];
}
@@ -83,9 +99,7 @@ const isTenantProject = computed((): boolean => {
return project.value.tenantMode === TenantMode.TENANT_MODE_ENABLED;
});
-// TODO(ed): use route name instead of fullpath
const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
- const projectPath = `/${project.value.name}`;
return [
{
title: t("common.database"),
@@ -94,53 +108,53 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
children: [
{
title: t("common.databases"),
- path: `${projectPath}/databases`,
- type: "route",
+ path: PROJECT_V1_ROUTE_DATABASES,
+ type: "div",
},
{
title: t("common.groups"),
- path: `${projectPath}/database-groups`,
- type: "route",
+ path: PROJECT_V1_ROUTE_DATABASE_GROUPS,
+ type: "div",
hide:
!isTenantProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: t("common.change-history"),
- path: `${projectPath}/change-histories`,
- type: "route",
+ path: PROJECT_V1_ROUTE_CHANGE_HISTORIES,
+ type: "div",
hide:
isTenantProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: startCase(t("slow-query.slow-queries")),
- path: `${projectPath}/slow-queries`,
- type: "route",
+ path: PROJECT_V1_ROUTE_SLOW_QUERIES,
+ type: "div",
hide: !currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: t("common.anomalies"),
- path: `${projectPath}/anomalies`,
- type: "route",
+ path: PROJECT_V1_ROUTE_ANOMALIES,
+ type: "div",
hide: !currentUserIamPolicy.isMemberOfProject(project.value.name),
},
],
},
{
title: t("common.issues"),
- path: `${projectPath}/issues`,
+ path: PROJECT_V1_ROUTE_ISSUES,
icon: h(CircleDot),
- type: "route",
+ type: "div",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: t("common.branches"),
- path: `${projectPath}/branches`,
+ path: PROJECT_V1_ROUTE_BRANCHES,
icon: h(GitBranch),
- type: "route",
+ type: "div",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.allowToChangeDatabaseOfProject(
@@ -149,18 +163,18 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
},
{
title: t("changelist.changelists"),
- path: `${projectPath}/changelists`,
+ path: PROJECT_V1_ROUTE_CHANGELISTS,
icon: h(PencilRuler),
- type: "route",
+ type: "div",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: t("database.sync-schema.title"),
- path: `${projectPath}/sync-schema`,
+ path: PROJECT_V1_ROUTE_SYNC_SCHEMA,
icon: h(RefreshCcw),
- type: "route",
+ type: "div",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.allowToChangeDatabaseOfProject(
@@ -177,13 +191,13 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
children: [
{
title: t("common.gitops"),
- path: `${projectPath}/gitops`,
- type: "route",
+ path: PROJECT_V1_ROUTE_GITOPS,
+ type: "div",
},
{
title: t("common.webhooks"),
- path: `${projectPath}/webhooks`,
- type: "route",
+ path: PROJECT_V1_ROUTE_WEBHOOKS,
+ type: "div",
},
],
},
@@ -197,21 +211,21 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
children: [
{
title: t("common.members"),
- path: `${projectPath}/members`,
- type: "route",
+ path: PROJECT_V1_ROUTE_MEMBERS,
+ type: "div",
},
{
title: t("common.activities"),
- path: `${projectPath}/activities`,
- type: "route",
+ path: PROJECT_V1_ROUTE_ACTIVITIES,
+ type: "div",
},
],
},
{
title: t("common.setting"),
icon: h(Settings),
- path: `${projectPath}/settings`,
- type: "route",
+ path: PROJECT_V1_ROUTE_SETTINGS,
+ type: "div",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
@@ -220,47 +234,50 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
});
const getItemClass = (path: string | undefined) => {
- const projectPath = `/${project.value.name}`;
-
const list = ["outline-item"];
+ if (route.name === path) {
+ list.push("router-link-active", "bg-link-hover");
+ return list;
+ }
+
switch (route.name) {
- case PROJECT_V1_WEBHOOK_CREATE:
- case PROJECT_V1_WEBHOOK_DETAIL:
- if (path === `${projectPath}/webhooks`) {
+ case PROJECT_V1_ROUTE_WEBHOOK_CREATE:
+ case PROJECT_V1_ROUTE_WEBHOOK_DETAIL:
+ if (path === PROJECT_V1_ROUTE_WEBHOOKS) {
list.push("router-link-active", "bg-link-hover");
}
break;
- case PROJECT_V1_BRANCHE_DETAIL:
- case PROJECT_V1_BRANCHE_ROLLOUT:
- case PROJECT_V1_BRANCHE_MERGE:
- case PROJECT_V1_BRANCHE_REBASE:
- if (path === `${projectPath}/branches`) {
+ case PROJECT_V1_ROUTE_BRANCH_DETAIL:
+ case PROJECT_V1_ROUTE_BRANCH_ROLLOUT:
+ case PROJECT_V1_ROUTE_BRANCH_MERGE:
+ case PROJECT_V1_ROUTE_BRANCH_REBASE:
+ if (path === PROJECT_V1_ROUTE_BRANCHES) {
list.push("router-link-active", "bg-link-hover");
}
break;
- case PROJECT_V1_CHANGELIST_DETAIL:
- if (path === `${projectPath}/changelists`) {
+ case PROJECT_V1_ROUTE_CHANGELIST_DETAIL:
+ if (path === PROJECT_V1_ROUTE_CHANGELISTS) {
list.push("router-link-active", "bg-link-hover");
}
break;
- case PROJECT_V1_DATABASE_GROUP_DETAIL:
- case PROJECT_V1_DATABASE_GROUP_TABLE_GROUP_DETAIL:
- if (path === `${projectPath}/database-groups`) {
+ case PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL:
+ case PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL:
+ if (path === PROJECT_V1_ROUTE_DATABASE_GROUPS) {
list.push("router-link-active", "bg-link-hover");
}
break;
case "workspace.issue.detail":
- if (path === `${projectPath}/issues`) {
+ if (path === PROJECT_V1_ROUTE_ISSUES) {
list.push("router-link-active", "bg-link-hover");
}
break;
case "workspace.database.history.detail":
- if (path === `${projectPath}/change-histories`) {
+ if (path === PROJECT_V1_ROUTE_CHANGE_HISTORIES) {
list.push("router-link-active", "bg-link-hover");
}
break;
case "workspace.database.detail":
- if (path === `${projectPath}/databases`) {
+ if (path === PROJECT_V1_ROUTE_DATABASES) {
list.push("router-link-active", "bg-link-hover");
}
break;
@@ -268,13 +285,19 @@ const getItemClass = (path: string | undefined) => {
return list;
};
-const onSelect = (path: string) => {
+const onSelect = (path: string | undefined, e: MouseEvent | undefined) => {
if (!path) {
return;
}
- router.replace({
- path,
+ const route = router.resolve({
+ name: path,
});
+
+ if (e?.ctrlKey || e?.metaKey) {
+ window.open(route.fullPath, "_blank");
+ } else {
+ router.replace(route);
+ }
};
const flattenNavigationItems = computed(() => {
@@ -307,7 +330,7 @@ const navigationKbarActions = computed(() => {
name: item.title,
section: t("kbar.navigation"),
keywords: [item.title.toLowerCase(), item.path].join(" "),
- perform: () => onSelect(item.path),
+ perform: () => onSelect(item.path, undefined),
})
);
return actions;
diff --git a/frontend/src/components/Project/WebhookTypeIcon.vue b/frontend/src/components/Project/WebhookTypeIcon.vue
new file mode 100644
index 0000000000..4ca70730e3
--- /dev/null
+++ b/frontend/src/components/Project/WebhookTypeIcon.vue
@@ -0,0 +1,35 @@
+<template>
+ <div v-bind="$attrs">
+ <!-- This awkward code is author couldn't figure out proper way to use dynamic src under vite
+ https://github.com/vitejs/vite/issues/1265 -->
+ <template v-if="type === Webhook_Type.TYPE_SLACK">
+ <img src="../../assets/slack-logo.png" alt="" />
+ </template>
+ <template v-else-if="type === Webhook_Type.TYPE_DISCORD">
+ <img src="../../assets/discord-logo.svg" />
+ </template>
+ <template v-else-if="type === Webhook_Type.TYPE_TEAMS">
+ <img src="../../assets/teams-logo.svg" />
+ </template>
+ <template v-else-if="type === Webhook_Type.TYPE_DINGTALK">
+ <img src="../../assets/dingtalk-logo.png" />
+ </template>
+ <template v-else-if="type === Webhook_Type.TYPE_FEISHU">
+ <img src="../../assets/feishu-logo.webp" />
+ </template>
+ <template v-else-if="type === Webhook_Type.TYPE_WECOM">
+ <img src="../../assets/wecom-logo.png" />
+ </template>
+ <template v-else-if="type === Webhook_Type.TYPE_CUSTOM">
+ <heroicons-outline:puzzle v-bind="$attrs" />
+ </template>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { Webhook_Type } from "@/types/proto/v1/project_service";
+
+defineProps<{
+ type: Webhook_Type;
+}>();
+</script>
diff --git a/frontend/src/components/ProjectBranchesPanel.vue b/frontend/src/components/ProjectBranchesPanel.vue
index 6cf531d82e..89a2d726e3 100644
--- a/frontend/src/components/ProjectBranchesPanel.vue
+++ b/frontend/src/components/ProjectBranchesPanel.vue
@@ -41,7 +41,7 @@ import { NButton } from "naive-ui";
import { computed, reactive } from "vue";
import { useRouter } from "vue-router";
import BranchDataTable from "@/components/Branch/BranchDataTable/index.vue";
-import { PROJECT_V1_BRANCHE_DETAIL } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_BRANCH_DETAIL } from "@/router/dashboard/projectV1";
import { useCurrentUserV1 } from "@/store";
import { useBranchListByProject } from "@/store/modules/branch";
import { userNamePrefix } from "@/store/modules/v1/common";
@@ -104,7 +104,7 @@ const activeBranches = computed(() => {
const handleCreateBranch = () => {
router.push({
- name: PROJECT_V1_BRANCHE_DETAIL,
+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,
params: {
branchName: "new",
},
diff --git a/frontend/src/components/ProjectWebhookCard.vue b/frontend/src/components/ProjectWebhookCard.vue
index 34dd701854..6e3303a011 100644
--- a/frontend/src/components/ProjectWebhookCard.vue
+++ b/frontend/src/components/ProjectWebhookCard.vue
@@ -58,7 +58,7 @@
<script lang="ts" setup>
import { PropType, computed } from "vue";
import { useRouter } from "vue-router";
-import { PROJECT_V1_WEBHOOK_DETAIL } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_WEBHOOK_DETAIL } from "@/router/dashboard/projectV1";
import { projectWebhookV1ActivityItemList } from "@/types";
import {
Webhook,
@@ -77,7 +77,7 @@ const router = useRouter();
const viewProjectWebhook = () => {
router.push({
- name: PROJECT_V1_WEBHOOK_DETAIL,
+ name: PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
params: {
projectWebhookSlug: projectWebhookV1Slug(props.projectWebhook),
},
diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vue
index 5352c7c8ab..64bc0f4959 100644
--- a/frontend/src/components/ProjectWebhookForm.vue
+++ b/frontend/src/components/ProjectWebhookForm.vue
@@ -18,33 +18,7 @@
@click.capture="state.webhook.type = item.type"
>
<div class="flex flex-col items-center">
- <!-- This awkward code is author couldn't figure out proper way to use dynamic src under vite
- https://github.com/vitejs/vite/issues/1265 -->
- <template v-if="item.type === Webhook_Type.TYPE_SLACK">
- <img
- class="h-10 w-10"
- src="../assets/slack-logo.png"
- alt=""
- />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_DISCORD">
- <img class="h-10 w-10" src="../assets/discord-logo.svg" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_TEAMS">
- <img class="h-10 w-10" src="../assets/teams-logo.svg" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_DINGTALK">
- <img class="h-10 w-10" src="../assets/dingtalk-logo.png" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_FEISHU">
- <img class="h-10 w-10" src="../assets/feishu-logo.webp" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_WECOM">
- <img class="h-10 w-10" src="../assets/wecom-logo.png" />
- </template>
- <template v-else-if="item.type === Webhook_Type.TYPE_CUSTOM">
- <heroicons-outline:puzzle class="w-10 h-10" />
- </template>
+ <WebhookTypeIcon :type="item.type" class="h-10 w-10" />
<p class="mt-1 text-center textlabel">
{{ item.name }}
</p>
@@ -289,8 +263,8 @@ import { reactive, computed, PropType, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import {
- PROJECT_V1_WEBHOOKS,
- PROJECT_V1_WEBHOOK_DETAIL,
+ PROJECT_V1_ROUTE_WEBHOOKS,
+ PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
} from "@/router/dashboard/projectV1";
import {
pushNotification,
@@ -420,7 +394,7 @@ const toggleEvent = (type: Activity_Type, on: boolean) => {
const cancel = () => {
router.push({
- name: PROJECT_V1_WEBHOOKS,
+ name: PROJECT_V1_ROUTE_WEBHOOKS,
});
};
@@ -448,7 +422,7 @@ const createWebhook = () => {
});
if (createdWebhook) {
router.push({
- name: PROJECT_V1_WEBHOOK_DETAIL,
+ name: PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
params: {
projectWebhookSlug: projectWebhookV1Slug(createdWebhook),
},
diff --git a/frontend/src/components/ProjectWebhookPanel.vue b/frontend/src/components/ProjectWebhookPanel.vue
index 4de87fb955..99597a5532 100644
--- a/frontend/src/components/ProjectWebhookPanel.vue
+++ b/frontend/src/components/ProjectWebhookPanel.vue
@@ -34,7 +34,7 @@
<script lang="ts" setup>
import { computed, PropType } from "vue";
import { useRouter } from "vue-router";
-import { PROJECT_V1_WEBHOOK_CREATE } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_WEBHOOK_CREATE } from "@/router/dashboard/projectV1";
import { Project } from "@/types/proto/v1/project_service";
import ProjectWebhookCard from "./ProjectWebhookCard.vue";
@@ -56,7 +56,7 @@ const projectWebhookList = computed(() => {
const addProjectWebhook = () => {
router.push({
- name: PROJECT_V1_WEBHOOK_CREATE,
+ name: PROJECT_V1_ROUTE_WEBHOOK_CREATE,
});
};
</script>
diff --git a/frontend/src/components/RepositorySetupWizard.vue b/frontend/src/components/RepositorySetupWizard.vue
index 45ef7ab27f..db1a17512b 100644
--- a/frontend/src/components/RepositorySetupWizard.vue
+++ b/frontend/src/components/RepositorySetupWizard.vue
@@ -136,7 +136,7 @@ import { reactive, computed, PropType } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { StepTab } from "@/components/v2";
-import { PROJECT_V1_GITOPS } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_GITOPS } from "@/router/dashboard/projectV1";
import { useRepositoryV1Store, hasFeature, useProjectV1Store } from "@/store";
import { getVCSUid } from "@/store/modules/v1/common";
import {
@@ -373,7 +373,7 @@ const closeSetupSQLReviewModal = () => {
const cancel = () => {
emit("cancel");
router.push({
- name: PROJECT_V1_GITOPS,
+ name: PROJECT_V1_ROUTE_GITOPS,
});
};
diff --git a/frontend/src/components/RepositoryTable.vue b/frontend/src/components/RepositoryTable.vue
index d032ef0a52..3143819a27 100644
--- a/frontend/src/components/RepositoryTable.vue
+++ b/frontend/src/components/RepositoryTable.vue
@@ -22,6 +22,8 @@
import { computed, PropType } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
+import { PROJECT_V1_ROUTE_GITOPS } from "@/router/dashboard/projectV1";
+import { getProjectName } from "@/store/modules/v1/common";
import { ComposedRepository } from "@/types";
import { projectV1Name } from "../utils";
@@ -46,6 +48,11 @@ const columnList = computed(() => [
const clickRepository = function (_: number, row: number) {
const repository = props.repositoryList[row];
- router.push(`/${repository.project.name}/gitops`);
+ router.push({
+ name: PROJECT_V1_ROUTE_GITOPS,
+ params: {
+ projectId: getProjectName(repository.project.name),
+ },
+ });
};
</script>
diff --git a/frontend/src/components/SQLReview/SQLReviewCreation.vue b/frontend/src/components/SQLReview/SQLReviewCreation.vue
index a005cfb076..37cfdd8fad 100644
--- a/frontend/src/components/SQLReview/SQLReviewCreation.vue
+++ b/frontend/src/components/SQLReview/SQLReviewCreation.vue
@@ -41,6 +41,7 @@ import { reactive, computed, withDefaults } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { StepTab } from "@/components/v2";
+import { SETTING_ROUTE_WORKSPACE_SQL_REVIEW } from "@/router/dashboard/workspaceSetting";
import {
useCurrentUserV1,
pushNotification,
@@ -99,7 +100,6 @@ const subscriptionStore = useSubscriptionV1Store();
const BASIC_INFO_STEP = 0;
const CONFIGURE_RULE_STEP = 1;
const PREVIEW_STEP = 2;
-const ROUTE_NAME = "setting.workspace.sql-review";
const STEP_LIST = [
{ title: t("sql-review.create.basic-info.name") },
@@ -159,7 +159,7 @@ const onCancel = () => {
emit("cancel");
} else {
router.push({
- name: ROUTE_NAME,
+ name: SETTING_ROUTE_WORKSPACE_SQL_REVIEW,
});
}
};
diff --git a/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue b/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue
index 5ba921b573..aabbaffb50 100644
--- a/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue
+++ b/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue
@@ -136,6 +136,10 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBButtonConfirm, BBGrid, BBGridColumn } from "@/bbkit";
import { EnvironmentV1Name } from "@/components/v2";
+import {
+ SETTING_ROUTE_WORKSPACE_SQL_REVIEW_CREATE,
+ SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL,
+} from "@/router/dashboard/workspaceSetting";
import {
pushNotification,
useCurrentUserV1,
@@ -217,7 +221,7 @@ const toggleReviewEnabled = async (review: SQLReviewPolicy, on: boolean) => {
const handleClickCreate = (environment: Environment) => {
if (hasPermission.value) {
router.push({
- name: "setting.workspace.sql-review.create",
+ name: SETTING_ROUTE_WORKSPACE_SQL_REVIEW_CREATE,
query: {
environmentId: environment.uid,
},
@@ -233,7 +237,7 @@ const handleClickCreate = (environment: Environment) => {
const handleClickEdit = (review: SQLReviewPolicy) => {
router.push({
- name: "setting.workspace.sql-review.detail",
+ name: SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL,
params: {
sqlReviewPolicySlug: sqlReviewPolicySlug(review),
},
diff --git a/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue b/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue
index 1748074256..c29e2b2538 100644
--- a/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue
+++ b/frontend/src/components/SlowQuery/Panel/SlowQueryPanel.vue
@@ -54,6 +54,7 @@ import { NButton } from "naive-ui";
import { computed, shallowRef, watch, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
+import { SETTING_ROUTE_WORKSPACE_SLOW_QUERY } from "@/router/dashboard/workspaceSetting";
import {
pushNotification,
useCurrentUserV1,
@@ -232,7 +233,7 @@ const syncNow = async () => {
const goConfig = () => {
router.push({
- name: "setting.workspace.slow-query",
+ name: SETTING_ROUTE_WORKSPACE_SLOW_QUERY,
});
};
diff --git a/frontend/src/components/TrialModal.vue b/frontend/src/components/TrialModal.vue
index 49ae8958c6..cd7e63782a 100644
--- a/frontend/src/components/TrialModal.vue
+++ b/frontend/src/components/TrialModal.vue
@@ -55,6 +55,7 @@
import { reactive } from "vue";
import { useRouter } from "vue-router";
import { useLanguage } from "@/composables/useLanguage";
+import { SETTING_ROUTE_WORKSPACE_SUBSCRIPTION } from "@/router/dashboard/workspaceSetting";
import { useSubscriptionV1Store } from "@/store";
import { planTypeToString, ENTERPRISE_INQUIRE_LINK } from "@/types";
import { PlanType } from "@/types/proto/v1/subscription_service";
@@ -77,7 +78,7 @@ const { locale } = useLanguage();
const subscriptionStore = useSubscriptionV1Store();
const learnMore = () => {
- router.push({ name: "setting.workspace.subscription" });
+ router.push({ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION });
};
const trialSubscription = () => {
diff --git a/frontend/src/components/UpgradeSubscriptionButton.vue b/frontend/src/components/UpgradeSubscriptionButton.vue
index c25cb6a18b..66933e54b2 100644
--- a/frontend/src/components/UpgradeSubscriptionButton.vue
+++ b/frontend/src/components/UpgradeSubscriptionButton.vue
@@ -20,6 +20,7 @@ import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { useLanguage } from "@/composables/useLanguage";
+import { SETTING_ROUTE_WORKSPACE_SUBSCRIPTION } from "@/router/dashboard/workspaceSetting";
import { useSubscriptionV1Store } from "@/store";
import { ENTERPRISE_INQUIRE_LINK } from "@/types";
@@ -56,7 +57,7 @@ const onClick = () => {
window.open(ENTERPRISE_INQUIRE_LINK, "_blank");
}
} else {
- router.push({ name: "setting.workspace.subscription" });
+ router.push({ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION });
}
};
</script>
diff --git a/frontend/src/components/VCS/VCSCard.vue b/frontend/src/components/VCS/VCSCard.vue
index 23a39bf70f..01e80d0078 100644
--- a/frontend/src/components/VCS/VCSCard.vue
+++ b/frontend/src/components/VCS/VCSCard.vue
@@ -39,6 +39,7 @@
<script lang="ts" setup>
import { PropType } from "vue";
import { useRouter } from "vue-router";
+import { SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL } from "@/router/dashboard/workspaceSetting";
import { ExternalVersionControl } from "@/types/proto/v1/externalvs_service";
import { vcsSlugV1 } from "@/utils";
@@ -53,7 +54,7 @@ const router = useRouter();
const editVCS = () => {
router.push({
- name: "setting.workspace.gitops.detail",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL,
params: {
vcsSlug: vcsSlugV1(props.vcs),
},
diff --git a/frontend/src/components/VCS/VCSSetupWizard.vue b/frontend/src/components/VCS/VCSSetupWizard.vue
index 47a1eee116..f2a3483e8d 100644
--- a/frontend/src/components/VCS/VCSSetupWizard.vue
+++ b/frontend/src/components/VCS/VCSSetupWizard.vue
@@ -34,6 +34,7 @@ import { reactive, computed, onUnmounted, onMounted } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { StepTab } from "@/components/v2";
+import { SETTING_ROUTE_WORKSPACE_GITOPS } from "@/router/dashboard/workspaceSetting";
import { pushNotification, useVCSV1Store } from "@/store";
import {
isValidVCSApplicationIdOrSecret,
@@ -254,7 +255,7 @@ const tryFinishSetup = () => {
})
.then((vcs: ExternalVersionControl) => {
router.push({
- name: "setting.workspace.gitops",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS,
});
pushNotification({
module: "bytebase",
@@ -268,7 +269,7 @@ const tryFinishSetup = () => {
const cancelSetup = () => {
router.push({
- name: "setting.workspace.gitops",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS,
});
};
</script>
diff --git a/frontend/src/components/v2/Model/ProjectV1Table.vue b/frontend/src/components/v2/Model/ProjectV1Table.vue
index ba56cfd989..b09dca58d5 100644
--- a/frontend/src/components/v2/Model/ProjectV1Table.vue
+++ b/frontend/src/components/v2/Model/ProjectV1Table.vue
@@ -36,7 +36,7 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBGridColumn, BBGridRow, BBGrid } from "@/bbkit";
import {
- PROJECT_V1_DETAIL,
+ PROJECT_V1_ROUTE_DETAIL,
PROJECT_V1_ROUTE,
} from "@/router/dashboard/projectV1";
import { getProjectName } from "@/store/modules/v1/common";
@@ -81,7 +81,7 @@ const clickProject = function (
row: number,
e: MouseEvent
) {
- let routeName = PROJECT_V1_DETAIL;
+ let routeName = PROJECT_V1_ROUTE_DETAIL;
if (router.currentRoute.value.name?.toString().startsWith(PROJECT_V1_ROUTE)) {
routeName = router.currentRoute.value.name?.toString();
}
diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vue
index f67ff16c82..85b574cd99 100644
--- a/frontend/src/layouts/ProjectV1Layout.vue
+++ b/frontend/src/layouts/ProjectV1Layout.vue
@@ -32,8 +32,8 @@ import { useRoute } from "vue-router";
import ArchiveBanner from "@/components/ArchiveBanner.vue";
import HideInStandaloneMode from "@/components/misc/HideInStandaloneMode.vue";
import {
- PROJECT_V1_DATABASES,
- PROJECT_V1_DATABASE_GROUPS,
+ PROJECT_V1_ROUTE_DATABASES,
+ PROJECT_V1_ROUTE_DATABASE_GROUPS,
} from "@/router/dashboard/projectV1";
import {
useProjectV1Store,
@@ -232,8 +232,8 @@ const quickActionMapByRole = computed(() => {
const isDatabaseHash = computed(() => {
return (
- route.name === PROJECT_V1_DATABASES ||
- route.name === PROJECT_V1_DATABASE_GROUPS
+ route.name === PROJECT_V1_ROUTE_DATABASES ||
+ route.name === PROJECT_V1_ROUTE_DATABASE_GROUPS
);
});
@@ -241,7 +241,7 @@ const quickActionList = computed(() => {
if (!isDatabaseHash.value) {
return [];
}
- if (route.name === PROJECT_V1_DATABASE_GROUPS) {
+ if (route.name === PROJECT_V1_ROUTE_DATABASE_GROUPS) {
return quickActionForDatabaseGroup.value;
}
return getQuickActionList(quickActionMapByRole.value);
diff --git a/frontend/src/plugins/ai/components/MockInputPlaceholder.vue b/frontend/src/plugins/ai/components/MockInputPlaceholder.vue
index c9ca1aa700..240e8f0ab5 100644
--- a/frontend/src/plugins/ai/components/MockInputPlaceholder.vue
+++ b/frontend/src/plugins/ai/components/MockInputPlaceholder.vue
@@ -36,12 +36,16 @@
<script lang="ts" setup>
import { NInput, NInputGroup, NButton, NTooltip } from "naive-ui";
import { useRouter } from "vue-router";
+import { SETTING_ROUTE_WORKSPACE_GENERAL } from "@/router/dashboard/workspaceSetting";
import { DISMISS_PLACEHOLDER } from "./state";
const router = useRouter();
const handleClick = () => {
- router.push({ name: "setting.workspace.general", hash: "#ai-augmentation" });
+ router.push({
+ name: SETTING_ROUTE_WORKSPACE_GENERAL,
+ hash: "#ai-augmentation",
+ });
};
const handleDismiss = () => {
diff --git a/frontend/src/router/dashboard/database.ts b/frontend/src/router/dashboard/database.ts
index bbcebe8ca5..000e156dac 100644
--- a/frontend/src/router/dashboard/database.ts
+++ b/frontend/src/router/dashboard/database.ts
@@ -8,10 +8,13 @@ import { QuickActionType } from "@/types";
import { idFromSlug } from "@/utils";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
+export const DATABASE_ROUTE_DASHBOARD = "workspace.database";
+export const DATABASE_ROUTE_DETAIL = `${DATABASE_ROUTE_DASHBOARD}.detail`;
+
const databaseRoutes: RouteRecordRaw[] = [
{
path: "db",
- name: "workspace.database",
+ name: DATABASE_ROUTE_DASHBOARD,
meta: {
title: () => t("common.databases"),
quickActionListByRole: () => {
@@ -51,7 +54,7 @@ const databaseRoutes: RouteRecordRaw[] = [
children: [
{
path: "",
- name: "workspace.database.detail",
+ name: DATABASE_ROUTE_DETAIL,
meta: {
title: (route: RouteLocationNormalized) => {
const slug = route.params.databaseSlug as string;
diff --git a/frontend/src/router/dashboard/environment.ts b/frontend/src/router/dashboard/environment.ts
index 588e6d2beb..1bb0507622 100644
--- a/frontend/src/router/dashboard/environment.ts
+++ b/frontend/src/router/dashboard/environment.ts
@@ -5,10 +5,13 @@ import { QuickActionType } from "@/types";
import { idFromSlug } from "@/utils";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
+export const ENVIRONMENT_ROUTE_DASHBOARD = "workspace.environment";
+export const ENVIRONMENT_ROUTE_DETAIL = `${ENVIRONMENT_ROUTE_DASHBOARD}.detail`;
+
const environmentRoutes: RouteRecordRaw[] = [
{
path: "environment",
- name: "workspace.environment",
+ name: ENVIRONMENT_ROUTE_DASHBOARD,
meta: {
title: () => t("common.environments"),
quickActionListByRole: () => {
@@ -31,7 +34,7 @@ const environmentRoutes: RouteRecordRaw[] = [
},
{
path: "environment/:environmentSlug",
- name: "workspace.environment.detail",
+ name: ENVIRONMENT_ROUTE_DETAIL,
meta: {
title: (route: RouteLocationNormalized) => {
const slug = route.params.environmentSlug as string;
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index 5afbe5308c..16988d4ec1 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -4,30 +4,30 @@ import { t } from "@/plugins/i18n";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
export const PROJECT_V1_ROUTE = "workspace.projectV1";
-export const PROJECT_V1_DETAIL = `${PROJECT_V1_ROUTE}.detail`;
-export const PROJECT_V1_DATABASES = `${PROJECT_V1_ROUTE}.database.dashboard`;
-export const PROJECT_V1_DATABASE_GROUPS = `${PROJECT_V1_ROUTE}.database-group.dashboard`;
-export const PROJECT_V1_DATABASE_GROUP_DETAIL = `${PROJECT_V1_ROUTE}.database-group.detail`;
-export const PROJECT_V1_DATABASE_GROUP_TABLE_GROUP_DETAIL = `${PROJECT_V1_ROUTE}.database-group.table-group.detail`;
-export const PROJECT_V1_BRANCHES = `${PROJECT_V1_ROUTE}.branch.dashboard`;
-export const PROJECT_V1_BRANCHE_DETAIL = `${PROJECT_V1_ROUTE}.branch.detail`;
-export const PROJECT_V1_BRANCHE_ROLLOUT = `${PROJECT_V1_ROUTE}.branch.rollout`;
-export const PROJECT_V1_BRANCHE_MERGE = `${PROJECT_V1_ROUTE}.branch.merge`;
-export const PROJECT_V1_BRANCHE_REBASE = `${PROJECT_V1_ROUTE}.branch.rebase`;
-export const PROJECT_V1_ISSUES = `${PROJECT_V1_ROUTE}.issue.dashboard`;
-export const PROJECT_V1_CHANGE_HISTORIES = `${PROJECT_V1_ROUTE}.change-histories.dashboard`;
-export const PROJECT_V1_CHANGELISTS = `${PROJECT_V1_ROUTE}.changelist.dashboard`;
-export const PROJECT_V1_CHANGELIST_DETAIL = `${PROJECT_V1_ROUTE}.changelist.detail`;
-export const PROJECT_V1_SYNC_SCHEMA = `${PROJECT_V1_ROUTE}.sync-schema`;
-export const PROJECT_V1_SLOW_QUERIES = `${PROJECT_V1_ROUTE}.slow-queries`;
-export const PROJECT_V1_ANOMALIES = `${PROJECT_V1_ROUTE}.anomalies`;
-export const PROJECT_V1_ACTIVITIES = `${PROJECT_V1_ROUTE}.activities`;
-export const PROJECT_V1_GITOPS = `${PROJECT_V1_ROUTE}.gitops`;
-export const PROJECT_V1_WEBHOOKS = `${PROJECT_V1_ROUTE}.webhook.dashboard`;
-export const PROJECT_V1_WEBHOOK_CREATE = `${PROJECT_V1_ROUTE}.webhook.create`;
-export const PROJECT_V1_WEBHOOK_DETAIL = `${PROJECT_V1_ROUTE}.webhook.detail`;
-export const PROJECT_V1_MEMBERS = `${PROJECT_V1_ROUTE}.members`;
-export const PROJECT_V1_SETTINGS = `${PROJECT_V1_ROUTE}.settings`;
+export const PROJECT_V1_ROUTE_DETAIL = `${PROJECT_V1_ROUTE}.detail`;
+export const PROJECT_V1_ROUTE_DATABASES = `${PROJECT_V1_ROUTE}.database.dashboard`;
+export const PROJECT_V1_ROUTE_DATABASE_GROUPS = `${PROJECT_V1_ROUTE}.database-group.dashboard`;
+export const PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL = `${PROJECT_V1_ROUTE}.database-group.detail`;
+export const PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL = `${PROJECT_V1_ROUTE}.database-group.table-group.detail`;
+export const PROJECT_V1_ROUTE_BRANCHES = `${PROJECT_V1_ROUTE}.branch.dashboard`;
+export const PROJECT_V1_ROUTE_BRANCH_DETAIL = `${PROJECT_V1_ROUTE}.branch.detail`;
+export const PROJECT_V1_ROUTE_BRANCH_ROLLOUT = `${PROJECT_V1_ROUTE}.branch.rollout`;
+export const PROJECT_V1_ROUTE_BRANCH_MERGE = `${PROJECT_V1_ROUTE}.branch.merge`;
+export const PROJECT_V1_ROUTE_BRANCH_REBASE = `${PROJECT_V1_ROUTE}.branch.rebase`;
+export const PROJECT_V1_ROUTE_ISSUES = `${PROJECT_V1_ROUTE}.issue.dashboard`;
+export const PROJECT_V1_ROUTE_CHANGE_HISTORIES = `${PROJECT_V1_ROUTE}.change-histories.dashboard`;
+export const PROJECT_V1_ROUTE_CHANGELISTS = `${PROJECT_V1_ROUTE}.changelist.dashboard`;
+export const PROJECT_V1_ROUTE_CHANGELIST_DETAIL = `${PROJECT_V1_ROUTE}.changelist.detail`;
+export const PROJECT_V1_ROUTE_SYNC_SCHEMA = `${PROJECT_V1_ROUTE}.sync-schema`;
+export const PROJECT_V1_ROUTE_SLOW_QUERIES = `${PROJECT_V1_ROUTE}.slow-queries`;
+export const PROJECT_V1_ROUTE_ANOMALIES = `${PROJECT_V1_ROUTE}.anomalies`;
+export const PROJECT_V1_ROUTE_ACTIVITIES = `${PROJECT_V1_ROUTE}.activities`;
+export const PROJECT_V1_ROUTE_GITOPS = `${PROJECT_V1_ROUTE}.gitops`;
+export const PROJECT_V1_ROUTE_WEBHOOKS = `${PROJECT_V1_ROUTE}.webhook.dashboard`;
+export const PROJECT_V1_ROUTE_WEBHOOK_CREATE = `${PROJECT_V1_ROUTE}.webhook.create`;
+export const PROJECT_V1_ROUTE_WEBHOOK_DETAIL = `${PROJECT_V1_ROUTE}.webhook.detail`;
+export const PROJECT_V1_ROUTE_MEMBERS = `${PROJECT_V1_ROUTE}.members`;
+export const PROJECT_V1_ROUTE_SETTINGS = `${PROJECT_V1_ROUTE}.settings`;
const projectV1Routes: RouteRecordRaw[] = [
{
@@ -59,12 +59,12 @@ const projectV1Routes: RouteRecordRaw[] = [
children: [
{
path: "",
- name: PROJECT_V1_DETAIL,
- redirect: { name: PROJECT_V1_DATABASES },
+ name: PROJECT_V1_ROUTE_DETAIL,
+ redirect: { name: PROJECT_V1_ROUTE_DATABASES },
},
{
path: "databases",
- name: PROJECT_V1_DATABASES,
+ name: PROJECT_V1_ROUTE_DATABASES,
meta: {
overrideTitle: true,
},
@@ -80,7 +80,7 @@ const projectV1Routes: RouteRecordRaw[] = [
children: [
{
path: "",
- name: PROJECT_V1_DATABASE_GROUPS,
+ name: PROJECT_V1_ROUTE_DATABASE_GROUPS,
meta: {
overrideTitle: true,
},
@@ -90,13 +90,13 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: ":databaseGroupName",
- name: PROJECT_V1_DATABASE_GROUP_DETAIL,
+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
component: () => import("@/views/DatabaseGroupDetail.vue"),
props: true,
},
{
path: ":databaseGroupName/table-groups/:schemaGroupName",
- name: PROJECT_V1_DATABASE_GROUP_TABLE_GROUP_DETAIL,
+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_TABLE_GROUP_DETAIL,
component: () => import("@/views/SchemaGroupDetail.vue"),
props: true,
},
@@ -111,7 +111,7 @@ const projectV1Routes: RouteRecordRaw[] = [
children: [
{
path: "",
- name: PROJECT_V1_BRANCHES,
+ name: PROJECT_V1_ROUTE_BRANCHES,
meta: {
overrideTitle: true,
},
@@ -121,7 +121,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: ":branchName",
- name: PROJECT_V1_BRANCHE_DETAIL,
+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,
meta: {
overrideTitle: true,
},
@@ -130,7 +130,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: ":branchName/rollout",
- name: PROJECT_V1_BRANCHE_ROLLOUT,
+ name: PROJECT_V1_ROUTE_BRANCH_ROLLOUT,
meta: {
overrideTitle: true,
},
@@ -139,7 +139,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: ":branchName/merge",
- name: PROJECT_V1_BRANCHE_MERGE,
+ name: PROJECT_V1_ROUTE_BRANCH_MERGE,
meta: {
title: () => t("branch.merge-rebase.merge-branch"),
},
@@ -148,7 +148,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: ":branchName/rebase",
- name: PROJECT_V1_BRANCHE_REBASE,
+ name: PROJECT_V1_ROUTE_BRANCH_REBASE,
meta: {
title: () => t("branch.merge-rebase.rebase-branch"),
},
@@ -159,7 +159,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "issues",
- name: PROJECT_V1_ISSUES,
+ name: PROJECT_V1_ROUTE_ISSUES,
meta: {
overrideTitle: true,
},
@@ -168,7 +168,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "change-histories",
- name: PROJECT_V1_CHANGE_HISTORIES,
+ name: PROJECT_V1_ROUTE_CHANGE_HISTORIES,
meta: {
overrideTitle: true,
},
@@ -185,7 +185,7 @@ const projectV1Routes: RouteRecordRaw[] = [
children: [
{
path: "",
- name: PROJECT_V1_CHANGELISTS,
+ name: PROJECT_V1_ROUTE_CHANGELISTS,
meta: {
overrideTitle: true,
},
@@ -195,7 +195,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: ":changelistName",
- name: PROJECT_V1_CHANGELIST_DETAIL,
+ name: PROJECT_V1_ROUTE_CHANGELIST_DETAIL,
meta: {
overrideTitle: true,
},
@@ -207,7 +207,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "sync-schema",
- name: PROJECT_V1_SYNC_SCHEMA,
+ name: PROJECT_V1_ROUTE_SYNC_SCHEMA,
meta: {
overrideTitle: true,
},
@@ -216,7 +216,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "slow-queries",
- name: PROJECT_V1_SLOW_QUERIES,
+ name: PROJECT_V1_ROUTE_SLOW_QUERIES,
meta: {
overrideTitle: true,
},
@@ -226,7 +226,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "anomalies",
- name: PROJECT_V1_ANOMALIES,
+ name: PROJECT_V1_ROUTE_ANOMALIES,
meta: {
overrideTitle: true,
},
@@ -236,7 +236,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "activities",
- name: PROJECT_V1_ACTIVITIES,
+ name: PROJECT_V1_ROUTE_ACTIVITIES,
meta: {
overrideTitle: true,
},
@@ -245,7 +245,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "gitops",
- name: PROJECT_V1_GITOPS,
+ name: PROJECT_V1_ROUTE_GITOPS,
meta: {
overrideTitle: true,
},
@@ -262,7 +262,7 @@ const projectV1Routes: RouteRecordRaw[] = [
children: [
{
path: "",
- name: PROJECT_V1_WEBHOOKS,
+ name: PROJECT_V1_ROUTE_WEBHOOKS,
meta: {
overrideTitle: true,
},
@@ -272,7 +272,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "new",
- name: PROJECT_V1_WEBHOOK_CREATE,
+ name: PROJECT_V1_ROUTE_WEBHOOK_CREATE,
meta: {
title: () => t("project.webhook.create-webhook"),
},
@@ -281,7 +281,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: ":projectWebhookSlug",
- name: PROJECT_V1_WEBHOOK_DETAIL,
+ name: PROJECT_V1_ROUTE_WEBHOOK_DETAIL,
meta: {
overrideTitle: true,
},
@@ -292,7 +292,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "members",
- name: PROJECT_V1_MEMBERS,
+ name: PROJECT_V1_ROUTE_MEMBERS,
meta: {
overrideTitle: true,
},
@@ -301,7 +301,7 @@ const projectV1Routes: RouteRecordRaw[] = [
},
{
path: "settings",
- name: PROJECT_V1_SETTINGS,
+ name: PROJECT_V1_ROUTE_SETTINGS,
meta: {
overrideTitle: true,
},
diff --git a/frontend/src/router/dashboard/workspaceSetting.ts b/frontend/src/router/dashboard/workspaceSetting.ts
index 7cb2a3013c..e85f9a4fff 100644
--- a/frontend/src/router/dashboard/workspaceSetting.ts
+++ b/frontend/src/router/dashboard/workspaceSetting.ts
@@ -9,10 +9,38 @@ import {
import { idFromSlug } from "@/utils";
import SettingSidebar from "@/views/SettingSidebar.vue";
+export const SETTING_ROUTE = "setting";
+export const SETTING_ROUTE_WORKSPACE = `${SETTING_ROUTE}.workspace`;
+export const SETTING_ROUTE_PROFILE = `${SETTING_ROUTE}.profile`;
+export const SETTING_ROUTE_PROFILE_TWO_FACTOR = `${SETTING_ROUTE_PROFILE}.two-factor`;
+export const SETTING_ROUTE_WORKSPACE_GENERAL = `${SETTING_ROUTE_WORKSPACE}.general`;
+export const SETTING_ROUTE_WORKSPACE_AGENT = `${SETTING_ROUTE_WORKSPACE}.agent`;
+export const SETTING_ROUTE_WORKSPACE_MEMBER = `${SETTING_ROUTE_WORKSPACE}.member`;
+export const SETTING_ROUTE_WORKSPACE_ROLE = `${SETTING_ROUTE_WORKSPACE}.role`;
+export const SETTING_ROUTE_WORKSPACE_SSO = `${SETTING_ROUTE_WORKSPACE}.sso`;
+export const SETTING_ROUTE_WORKSPACE_SSO_CREATE = `${SETTING_ROUTE_WORKSPACE_SSO}.create`;
+export const SETTING_ROUTE_WORKSPACE_SSO_DETAIL = `${SETTING_ROUTE_WORKSPACE_SSO}.detail`;
+export const SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA = `${SETTING_ROUTE_WORKSPACE}.sensitive-data`;
+export const SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL = `${SETTING_ROUTE_WORKSPACE}.access-control`;
+export const SETTING_ROUTE_WORKSPACE_RISK_CENTER = `${SETTING_ROUTE_WORKSPACE}.risk-center`;
+export const SETTING_ROUTE_WORKSPACE_CUSTOM_APPROVAL = `${SETTING_ROUTE_WORKSPACE}.custom-approval`;
+export const SETTING_ROUTE_WORKSPACE_SLOW_QUERY = `${SETTING_ROUTE_WORKSPACE}.slow-query`;
+export const SETTING_ROUTE_WORKSPACE_SCHEMA_TEMPLATE = `${SETTING_ROUTE_WORKSPACE}.schema-template`;
+export const SETTING_ROUTE_WORKSPACE_GITOPS = `${SETTING_ROUTE_WORKSPACE}.gitops`;
+export const SETTING_ROUTE_WORKSPACE_GITOPS_CREATE = `${SETTING_ROUTE_WORKSPACE_GITOPS}.create`;
+export const SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL = `${SETTING_ROUTE_WORKSPACE_GITOPS}.detail`;
+export const SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY = `${SETTING_ROUTE_WORKSPACE}.mail-delivery`;
+export const SETTING_ROUTE_WORKSPACE_SUBSCRIPTION = `${SETTING_ROUTE_WORKSPACE}.subscription`;
+export const SETTING_ROUTE_WORKSPACE_SQL_REVIEW = `${SETTING_ROUTE_WORKSPACE}.sql-review`;
+export const SETTING_ROUTE_WORKSPACE_SQL_REVIEW_CREATE = `${SETTING_ROUTE_WORKSPACE_SQL_REVIEW}.create`;
+export const SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL = `${SETTING_ROUTE_WORKSPACE_SQL_REVIEW}.detail`;
+export const SETTING_ROUTE_WORKSPACE_AUDIT_LOG = `${SETTING_ROUTE_WORKSPACE}.audit-log`;
+export const SETTING_ROUTE_WORKSPACE_DEBUG_LOG = `${SETTING_ROUTE_WORKSPACE}.debug-log`;
+export const SETTING_ROUTE_WORKSPACE_ARCHIVE = `${SETTING_ROUTE_WORKSPACE}.archive`;
+
const workspaceSettingRoutes: RouteRecordRaw[] = [
{
path: "setting",
- name: "setting",
meta: { title: () => t("common.settings") },
components: {
content: () => import("@/layouts/SettingLayout.vue"),
@@ -25,7 +53,7 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
children: [
{
path: "",
- name: "setting.profile",
+ name: SETTING_ROUTE_PROFILE,
meta: { title: () => t("settings.sidebar.profile") },
component: () => import("@/views/ProfileDashboard.vue"),
alias: "profile",
@@ -33,7 +61,7 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "profile/two-factor",
- name: "setting.profile.two-factor",
+ name: SETTING_ROUTE_PROFILE_TWO_FACTOR,
meta: {
title: () => t("two-factor.self"),
},
@@ -42,47 +70,47 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "general",
- name: "setting.workspace.general",
+ name: SETTING_ROUTE_WORKSPACE_GENERAL,
meta: { title: () => t("settings.sidebar.general") },
component: () => import("@/views/SettingWorkspaceGeneral.vue"),
props: true,
},
{
path: "agent",
- name: "setting.workspace.agent",
+ name: SETTING_ROUTE_WORKSPACE_AGENT,
meta: { title: () => t("common.agents") },
component: () => import("@/views/SettingWorkspaceAgent.vue"),
props: true,
},
{
path: "member",
- name: "setting.workspace.member",
+ name: SETTING_ROUTE_WORKSPACE_MEMBER,
meta: { title: () => t("settings.sidebar.members") },
component: () => import("@/views/SettingWorkspaceMember.vue"),
props: true,
},
{
path: "role",
- name: "setting.workspace.role",
+ name: SETTING_ROUTE_WORKSPACE_ROLE,
meta: { title: () => t("settings.sidebar.custom-roles") },
component: () => import("@/views/SettingWorkspaceRole.vue"),
props: true,
},
{
path: "sso",
- name: "setting.workspace.sso",
+ name: SETTING_ROUTE_WORKSPACE_SSO,
meta: { title: () => t("settings.sidebar.sso") },
component: () => import("@/views/SettingWorkspaceSSO.vue"),
},
{
path: "sso/new",
- name: "setting.workspace.sso.create",
+ name: SETTING_ROUTE_WORKSPACE_SSO_CREATE,
meta: { title: () => t("settings.sidebar.sso") },
component: () => import("@/views/SettingWorkspaceSSODetail.vue"),
},
{
path: "sso/:ssoName",
- name: "setting.workspace.sso.detail",
+ name: SETTING_ROUTE_WORKSPACE_SSO_DETAIL,
meta: {
title: (route: RouteLocationNormalized) => {
const name = route.params.ssoName as string;
@@ -97,63 +125,63 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "sensitive-data",
- name: "setting.workspace.sensitive-data",
+ name: SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA,
meta: { title: () => t("settings.sidebar.sensitive-data") },
component: () => import("@/views/SettingWorkspaceSensitiveData.vue"),
props: true,
},
{
path: "access-control",
- name: "setting.workspace.access-control",
+ name: SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL,
meta: { title: () => t("settings.sidebar.access-control") },
component: () => import("@/views/SettingWorkspaceAccessControl.vue"),
props: true,
},
{
path: "risk-center",
- name: "setting.workspace.risk-center",
+ name: SETTING_ROUTE_WORKSPACE_RISK_CENTER,
meta: { title: () => t("custom-approval.risk.risk-center") },
component: () => import("@/views/SettingWorkspaceRiskCenter.vue"),
props: true,
},
{
path: "custom-approval",
- name: "setting.workspace.custom-approval",
+ name: SETTING_ROUTE_WORKSPACE_CUSTOM_APPROVAL,
meta: { title: () => t("custom-approval.self") },
component: () => import("@/views/SettingWorkspaceCustomApproval.vue"),
props: true,
},
{
path: "slow-query",
- name: "setting.workspace.slow-query",
+ name: SETTING_ROUTE_WORKSPACE_SLOW_QUERY,
meta: { title: () => startCase(t("slow-query.self")) },
component: () => import("@/views/SettingWorkspaceSlowQuery.vue"),
props: true,
},
{
path: "schema-template",
- name: "setting.workspace.schema-template",
+ name: SETTING_ROUTE_WORKSPACE_SCHEMA_TEMPLATE,
meta: { title: () => startCase(t("schema-template.self")) },
component: () => import("@/views/SettingWorkspaceSchemaTemplate.vue"),
props: true,
},
{
path: "gitops",
- name: "setting.workspace.gitops",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS,
meta: { title: () => t("settings.sidebar.gitops") },
component: () => import("@/views/SettingWorkspaceVCS.vue"),
props: true,
},
{
path: "gitops/new",
- name: "setting.workspace.gitops.create",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS_CREATE,
meta: { title: () => t("repository.add-git-provider") },
component: () => import("@/views/SettingWorkspaceVCSCreate.vue"),
props: true,
},
{
path: "gitops/:vcsSlug",
- name: "setting.workspace.gitops.detail",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL,
meta: {
title: (route: RouteLocationNormalized) => {
const slug = route.params.vcsSlug as string;
@@ -165,20 +193,20 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "mail-delivery",
- name: "setting.workspace.mail-delivery",
+ name: SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY,
meta: { title: () => t("settings.sidebar.mail-delivery") },
component: () => import("@/views/SettingWorkspaceMailDelivery.vue"),
},
{
path: "subscription",
- name: "setting.workspace.subscription",
+ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
meta: { title: () => t("settings.sidebar.subscription") },
component: () => import("@/views/SettingWorkspaceSubscription.vue"),
props: true,
},
{
path: "sql-review",
- name: "setting.workspace.sql-review",
+ name: SETTING_ROUTE_WORKSPACE_SQL_REVIEW,
meta: {
title: () => t("sql-review.title"),
},
@@ -187,7 +215,7 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "sql-review/new",
- name: "setting.workspace.sql-review.create",
+ name: SETTING_ROUTE_WORKSPACE_SQL_REVIEW_CREATE,
meta: {
title: () => t("sql-review.create.breadcrumb"),
},
@@ -196,7 +224,7 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "sql-review/:sqlReviewPolicySlug",
- name: "setting.workspace.sql-review.detail",
+ name: SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL,
meta: {
title: (route: RouteLocationNormalized) => {
const slug = route.params.sqlReviewPolicySlug as string;
@@ -212,7 +240,7 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "audit-log",
- name: "setting.workspace.audit-log",
+ name: SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
meta: {
title: () => t("settings.sidebar.audit-log"),
},
@@ -221,7 +249,7 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "debug-log",
- name: "setting.workspace.debug-log",
+ name: SETTING_ROUTE_WORKSPACE_DEBUG_LOG,
meta: {
title: () => t("settings.sidebar.debug-log"),
},
@@ -230,7 +258,7 @@ const workspaceSettingRoutes: RouteRecordRaw[] = [
},
{
path: "archive",
- name: "setting.workspace.archive",
+ name: SETTING_ROUTE_WORKSPACE_ARCHIVE,
meta: { title: () => t("common.archived") },
component: () => import("@/views/Archive.vue"),
props: true,
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 3a23f29c91..25abb9187d 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -42,6 +42,13 @@ import authRoutes, {
import dashboardRoutes from "./dashboard";
import { PROJECT_V1_ROUTE } from "./dashboard/projectV1";
import { WORKSPACE_HOME_MODULE } from "./dashboard/workspace";
+import {
+ SETTING_ROUTE_WORKSPACE,
+ SETTING_ROUTE,
+ SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL,
+ SETTING_ROUTE_WORKSPACE_SSO_DETAIL,
+ SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL,
+} from "./dashboard/workspaceSetting";
import sqlEditorRoutes, { SQL_EDITOR_HOME_MODULE } from "./sqlEditor";
export const router = createRouter({
@@ -193,7 +200,7 @@ router.beforeEach((to, from, next) => {
}
}
- if (to.name?.toString().startsWith("setting.workspace.")) {
+ if (to.name?.toString().startsWith(SETTING_ROUTE_WORKSPACE)) {
const hasPermission = hasSettingPagePermission(
to.name.toString(),
currentUserV1.value.userRole
@@ -238,10 +245,10 @@ router.beforeEach((to, from, next) => {
to.name === "workspace.issue" ||
to.name === "workspace.environment" ||
to.name === SQL_EDITOR_HOME_MODULE ||
- (to.name?.toString().startsWith("setting") &&
- to.name?.toString() != "setting.workspace.gitops.detail" &&
- to.name?.toString() != "setting.workspace.sql-review.detail" &&
- to.name?.toString() != "setting.workspace.sso.detail")
+ (to.name?.toString().startsWith(SETTING_ROUTE) &&
+ to.name?.toString() != SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL &&
+ to.name?.toString() != SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL &&
+ to.name?.toString() != SETTING_ROUTE_WORKSPACE_SSO_DETAIL)
) {
next();
return;
diff --git a/frontend/src/utils/role.ts b/frontend/src/utils/role.ts
index 71da88b2c1..ad55cbe446 100644
--- a/frontend/src/utils/role.ts
+++ b/frontend/src/utils/role.ts
@@ -1,6 +1,20 @@
import { kebabCase } from "lodash-es";
import { computed, unref } from "vue";
import { t } from "@/plugins/i18n";
+import {
+ SETTING_ROUTE_WORKSPACE_MEMBER,
+ SETTING_ROUTE_WORKSPACE_DEBUG_LOG,
+ SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA,
+ SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL,
+ SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
+ SETTING_ROUTE_WORKSPACE_GITOPS,
+ SETTING_ROUTE_WORKSPACE_GITOPS_CREATE,
+ SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL,
+ SETTING_ROUTE_WORKSPACE_SSO,
+ SETTING_ROUTE_WORKSPACE_SSO_CREATE,
+ SETTING_ROUTE_WORKSPACE_SSO_DETAIL,
+ SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY,
+} from "@/router/dashboard/workspaceSetting";
import { hasFeature, useCurrentUserV1, useRoleStore } from "@/store";
import { MaybeRef, RoleType, PresetRoleType } from "@/types";
import { UserRole } from "@/types/proto/v1/auth_service";
@@ -218,46 +232,46 @@ export const hasSettingPagePermission = (
role: UserRole
): boolean => {
switch (routeName) {
- case "setting.workspace.member":
+ case SETTING_ROUTE_WORKSPACE_MEMBER:
return hasWorkspacePermissionV1(
"bb.permission.workspace.manage-member",
role
);
- case "setting.workspace.sensitive-data":
+ case SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA:
return hasWorkspacePermissionV1(
"bb.permission.workspace.manage-sensitive-data",
role
);
- case "setting.workspace.access-control":
+ case SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL:
return hasWorkspacePermissionV1(
"bb.permission.workspace.manage-access-control",
role
);
- case "setting.workspace.sso":
- case "setting.workspace.sso.create":
- case "setting.workspace.sso.detail":
+ case SETTING_ROUTE_WORKSPACE_SSO:
+ case SETTING_ROUTE_WORKSPACE_SSO_CREATE:
+ case SETTING_ROUTE_WORKSPACE_SSO_DETAIL:
return hasWorkspacePermissionV1(
"bb.permission.workspace.manage-sso",
role
);
- case "setting.workspace.gitops":
- case "setting.workspace.gitops.create":
- case "setting.workspace.gitops.detail":
+ case SETTING_ROUTE_WORKSPACE_GITOPS:
+ case SETTING_ROUTE_WORKSPACE_GITOPS_CREATE:
+ case SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL:
return hasWorkspacePermissionV1(
"bb.permission.workspace.manage-vcs-provider",
role
);
- case "setting.workspace.debug-log":
+ case SETTING_ROUTE_WORKSPACE_DEBUG_LOG:
return hasWorkspacePermissionV1(
"bb.permission.workspace.debug-log",
role
);
- case "setting.workspace.audit-log":
+ case SETTING_ROUTE_WORKSPACE_AUDIT_LOG:
return hasWorkspacePermissionV1(
"bb.permission.workspace.audit-log",
role
);
- case "setting.workspace.mail-delivery":
+ case SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY:
return hasWorkspacePermissionV1(
"bb.permission.workspace.manage-mail-delivery",
role
diff --git a/frontend/src/views/BannerUpgradeSubscription.vue b/frontend/src/views/BannerUpgradeSubscription.vue
index e9c24ceacf..ab4ccbe03b 100644
--- a/frontend/src/views/BannerUpgradeSubscription.vue
+++ b/frontend/src/views/BannerUpgradeSubscription.vue
@@ -75,6 +75,7 @@ import { reactive } from "vue";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
+import { SETTING_ROUTE_WORKSPACE_SUBSCRIPTION } from "@/router/dashboard/workspaceSetting";
import { useSubscriptionV1Store, useActuatorV1Store } from "@/store";
import { FeatureType, planTypeToString } from "@/types";
import { PlanType } from "@/types/proto/v1/subscription_service";
@@ -125,7 +126,7 @@ const currentPlan = computed(() => {
const gotoSubscriptionPage = () => {
state.showModal = false;
- return router.push({ name: "setting.workspace.subscription" });
+ return router.push({ name: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION });
};
</script>
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index 543507ed09..93e54d468e 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -88,6 +88,7 @@ import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { useCurrentProject } from "@/components/Project/useCurrentProject";
+import { SETTING_ROUTE_WORKSPACE_MEMBER } from "@/router/dashboard/workspaceSetting";
import { useSubscriptionV1Store } from "@/store";
import { PlanType } from "@/types/proto/v1/subscription_service";
import BytebaseLogo from "../components/BytebaseLogo.vue";
@@ -138,7 +139,7 @@ const kbarActions = computed(() => {
name: "Settings",
section: t("kbar.navigation"),
keywords: "navigation",
- perform: () => router.push({ name: "setting.workspace.member" }),
+ perform: () => router.push({ name: SETTING_ROUTE_WORKSPACE_MEMBER }),
}),
];
});
diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vue
index a067301d1b..c8229509f2 100644
--- a/frontend/src/views/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail.vue
@@ -244,6 +244,7 @@ import {
ProductionEnvironmentV1Icon,
ProjectV1Name,
} from "@/components/v2";
+import { DATABASE_ROUTE_DETAIL } from "@/router/dashboard/database";
import {
pushNotification,
useAnomalyV1Store,
@@ -520,7 +521,7 @@ const createMigration = async (
};
router.push({
- name: "workspace.issue.detail",
+ name: DATABASE_ROUTE_DETAIL,
params: {
issueSlug: "new",
},
diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vue
index bbf400e8eb..7ed9339ae4 100644
--- a/frontend/src/views/EnvironmentDashboard.vue
+++ b/frontend/src/views/EnvironmentDashboard.vue
@@ -63,6 +63,7 @@ import { onMounted, computed, reactive, watch, h } from "vue";
import { useRouter } from "vue-router";
import { Drawer } from "@/components/v2";
import { EnvironmentV1Name, MiniActionButton } from "@/components/v2";
+import { ENVIRONMENT_ROUTE_DASHBOARD } from "@/router/dashboard/environment";
import {
useRegisterCommand,
useUIStateStore,
@@ -312,7 +313,7 @@ const selectEnvironment = (index: number) => {
const onTabChange = (uid: string) => {
state.selectedUid = uid;
router.replace({
- name: "workspace.environment",
+ name: ENVIRONMENT_ROUTE_DASHBOARD,
hash: "#" + uid,
});
};
diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vue
index b80450104b..0f37749abc 100644
--- a/frontend/src/views/EnvironmentDetail.vue
+++ b/frontend/src/views/EnvironmentDetail.vue
@@ -49,6 +49,10 @@ import { useRouter } from "vue-router";
import BBModal from "@/bbkit/BBModal.vue";
import ArchiveBanner from "@/components/ArchiveBanner.vue";
import EnvironmentForm from "@/components/EnvironmentForm.vue";
+import {
+ ENVIRONMENT_ROUTE_DASHBOARD,
+ ENVIRONMENT_ROUTE_DETAIL,
+} from "@/router/dashboard/environment";
import { hasFeature, pushNotification, useBackupV1Store } from "@/store";
import {
useEnvironmentV1Store,
@@ -186,7 +190,12 @@ const doArchive = (environment: Environment) => {
emit("archive", environment);
environment.state = State.DELETED;
assignEnvironment(environment);
- router.replace(`/environment/${environmentV1Slug(environment)}`);
+ router.replace({
+ name: ENVIRONMENT_ROUTE_DETAIL,
+ params: {
+ environmentSlug: environmentV1Slug(environment),
+ },
+ });
});
};
@@ -195,7 +204,10 @@ const doRestore = (environment: Environment) => {
.undeleteEnvironment(environment.name)
.then((environment) => {
assignEnvironment(environment);
- router.replace(`/environment#${environment.uid}`);
+ router.replace({
+ name: ENVIRONMENT_ROUTE_DASHBOARD,
+ hash: `#${environment.uid}`,
+ });
});
};
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index 3eb9ba818f..3e5ac85344 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -246,6 +246,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 { SETTING_ROUTE_PROFILE_TWO_FACTOR } from "@/router/dashboard/workspaceSetting";
import {
featureToRef,
pushNotification,
@@ -431,7 +432,7 @@ const enable2FA = () => {
state.showFeatureModal = true;
return;
}
- router.push({ name: "setting.profile.two-factor" });
+ router.push({ name: SETTING_ROUTE_PROFILE_TWO_FACTOR });
};
const disable2FA = () => {
diff --git a/frontend/src/views/SettingSidebar.vue b/frontend/src/views/SettingSidebar.vue
index 7b14d1ea7b..ed217fff6b 100644
--- a/frontend/src/views/SettingSidebar.vue
+++ b/frontend/src/views/SettingSidebar.vue
@@ -3,6 +3,7 @@
:key="'setting'"
:item-list="(settingSidebarItemList as SidebarItem[])"
:get-item-class="getItemClass"
+ @select="onSelect"
/>
</template>
@@ -16,39 +17,72 @@ import {
} from "lucide-vue-next";
import { computed, h } from "vue";
import { useI18n } from "vue-i18n";
-import { useRoute } from "vue-router";
+import { useRoute, useRouter } from "vue-router";
import { SidebarItem } from "@/components/CommonSidebar.vue";
+import {
+ SETTING_ROUTE_PROFILE,
+ SETTING_ROUTE_PROFILE_TWO_FACTOR,
+ SETTING_ROUTE_WORKSPACE_GENERAL,
+ SETTING_ROUTE_WORKSPACE_MEMBER,
+ SETTING_ROUTE_WORKSPACE_ROLE,
+ SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
+ SETTING_ROUTE_WORKSPACE_DEBUG_LOG,
+ SETTING_ROUTE_WORKSPACE_SQL_REVIEW,
+ SETTING_ROUTE_WORKSPACE_SQL_REVIEW_CREATE,
+ SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL,
+ SETTING_ROUTE_WORKSPACE_SLOW_QUERY,
+ SETTING_ROUTE_WORKSPACE_SCHEMA_TEMPLATE,
+ SETTING_ROUTE_WORKSPACE_RISK_CENTER,
+ SETTING_ROUTE_WORKSPACE_CUSTOM_APPROVAL,
+ SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA,
+ SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL,
+ SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
+ SETTING_ROUTE_WORKSPACE_GITOPS,
+ SETTING_ROUTE_WORKSPACE_GITOPS_CREATE,
+ SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL,
+ SETTING_ROUTE_WORKSPACE_SSO,
+ SETTING_ROUTE_WORKSPACE_SSO_CREATE,
+ SETTING_ROUTE_WORKSPACE_SSO_DETAIL,
+ SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY,
+ SETTING_ROUTE_WORKSPACE_ARCHIVE,
+} from "@/router/dashboard/workspaceSetting";
import { useCurrentUserV1 } from "@/store";
import { hasSettingPagePermission } from "../utils";
const { t } = useI18n();
const route = useRoute();
+const router = useRouter();
const currentUserV1 = useCurrentUserV1();
const getItemClass = (path: string | undefined) => {
const list = [];
+ if (route.name === path) {
+ list.push("router-link-active", "bg-link-hover");
+ return list;
+ }
+
switch (route.name) {
- case "setting.workspace.sso.detail":
- case "setting.workspace.sso.create":
- if (path === "/setting/sso") {
+ case SETTING_ROUTE_WORKSPACE_SSO_CREATE:
+ case SETTING_ROUTE_WORKSPACE_SSO_DETAIL:
+ if (path === SETTING_ROUTE_WORKSPACE_SSO) {
list.push("router-link-active", "bg-link-hover");
}
break;
- case "workspace.profile":
- if (path === "/setting/member") {
+ case SETTING_ROUTE_PROFILE:
+ case SETTING_ROUTE_PROFILE_TWO_FACTOR:
+ if (path === SETTING_ROUTE_WORKSPACE_MEMBER) {
list.push("router-link-active", "bg-link-hover");
}
break;
- case "setting.workspace.sql-review.create":
- case "setting.workspace.sql-review.detail":
- if (path === "/setting/sql-review") {
+ case SETTING_ROUTE_WORKSPACE_SQL_REVIEW_CREATE:
+ case SETTING_ROUTE_WORKSPACE_SQL_REVIEW_DETAIL:
+ if (path === SETTING_ROUTE_WORKSPACE_SQL_REVIEW) {
list.push("router-link-active", "bg-link-hover");
}
break;
- case "setting.workspace.gitop":
- case "setting.workspace.gitops.create":
- case "setting.workspace.gitops.detail":
- if (path === "/setting/gitops") {
+ case SETTING_ROUTE_WORKSPACE_GITOPS_CREATE:
+ case SETTING_ROUTE_WORKSPACE_GITOPS_DETAIL:
+ if (path === SETTING_ROUTE_WORKSPACE_GITOPS) {
list.push("router-link-active", "bg-link-hover");
}
break;
@@ -56,6 +90,21 @@ const getItemClass = (path: string | undefined) => {
return list;
};
+const onSelect = (path: string | undefined, e: MouseEvent | undefined) => {
+ if (!path) {
+ return;
+ }
+ const route = router.resolve({
+ name: path,
+ });
+
+ if (e?.ctrlKey || e?.metaKey) {
+ window.open(route.fullPath, "_blank");
+ } else {
+ router.replace(route);
+ }
+};
+
const settingSidebarItemList = computed((): SidebarItem[] => {
return [
{
@@ -65,8 +114,8 @@ const settingSidebarItemList = computed((): SidebarItem[] => {
children: [
{
title: t("settings.sidebar.profile"),
- path: "/setting/profile",
- type: "route",
+ path: SETTING_ROUTE_PROFILE,
+ type: "div",
},
],
},
@@ -77,36 +126,36 @@ const settingSidebarItemList = computed((): SidebarItem[] => {
children: [
{
title: t("settings.sidebar.general"),
- path: "/setting/general",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_GENERAL,
+ type: "div",
},
{
title: t("settings.sidebar.members"),
- path: "/setting/member",
+ path: SETTING_ROUTE_WORKSPACE_MEMBER,
hide: !hasSettingPagePermission(
- "setting.workspace.member",
+ SETTING_ROUTE_WORKSPACE_MEMBER,
currentUserV1.value.userRole
),
- type: "route",
+ type: "div",
},
{
title: t("settings.sidebar.custom-roles"),
- path: "/setting/role",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_ROLE,
+ type: "div",
},
{
title: t("settings.sidebar.subscription"),
- path: "/setting/subscription",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_SUBSCRIPTION,
+ type: "div",
},
{
title: t("settings.sidebar.debug-log"),
- path: "/setting/debug-log",
+ path: SETTING_ROUTE_WORKSPACE_DEBUG_LOG,
hide: !hasSettingPagePermission(
- "setting.workspace.debug-log",
+ SETTING_ROUTE_WORKSPACE_DEBUG_LOG,
currentUserV1.value.userRole
),
- type: "route",
+ type: "div",
},
],
},
@@ -117,55 +166,55 @@ const settingSidebarItemList = computed((): SidebarItem[] => {
children: [
{
title: t("sql-review.title"),
- path: "/setting/sql-review",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_SQL_REVIEW,
+ type: "div",
},
{
title: t("slow-query.self"),
- path: "/setting/slow-query",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_SLOW_QUERY,
+ type: "div",
},
{
title: t("schema-template.self"),
- path: "/setting/schema-template",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_SCHEMA_TEMPLATE,
+ type: "div",
},
{
title: t("custom-approval.risk.risk-center"),
- path: "/setting/risk-center",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_RISK_CENTER,
+ type: "div",
},
{
title: t("custom-approval.self"),
- path: "/setting/custom-approval",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_CUSTOM_APPROVAL,
+ type: "div",
},
{
title: t("settings.sidebar.sensitive-data"),
- path: "/setting/sensitive-data",
+ path: SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA,
hide: !hasSettingPagePermission(
- "setting.workspace.sensitive-data",
+ SETTING_ROUTE_WORKSPACE_SENSITIVE_DATA,
currentUserV1.value.userRole
),
- type: "route",
+ type: "div",
},
{
title: t("settings.sidebar.access-control"),
- path: "/setting/access-control",
+ path: SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL,
hide: !hasSettingPagePermission(
- "setting.workspace.access-control",
+ SETTING_ROUTE_WORKSPACE_ACCESS_CONTROL,
currentUserV1.value.userRole
),
- type: "route",
+ type: "div",
},
{
title: t("settings.sidebar.audit-log"),
- path: "/setting/audit-log",
+ path: SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
hide: !hasSettingPagePermission(
- "setting.workspace.audit-log",
+ SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
currentUserV1.value.userRole
),
- type: "route",
+ type: "div",
},
],
},
@@ -176,38 +225,38 @@ const settingSidebarItemList = computed((): SidebarItem[] => {
children: [
{
title: t("settings.sidebar.gitops"),
- path: "/setting/gitops",
+ path: SETTING_ROUTE_WORKSPACE_GITOPS,
hide: !hasSettingPagePermission(
- "setting.workspace.gitops",
+ SETTING_ROUTE_WORKSPACE_GITOPS,
currentUserV1.value.userRole
),
- type: "route",
+ type: "div",
},
{
title: t("settings.sidebar.sso"),
- path: "/setting/sso",
+ path: SETTING_ROUTE_WORKSPACE_SSO,
hide: !hasSettingPagePermission(
- "setting.workspace.sso",
+ SETTING_ROUTE_WORKSPACE_SSO,
currentUserV1.value.userRole
),
- type: "route",
+ type: "div",
},
{
title: t("settings.sidebar.mail-delivery"),
- path: "/setting/mail-delivery",
+ path: SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY,
hide: !hasSettingPagePermission(
- "setting.workspace.mail-delivery",
+ SETTING_ROUTE_WORKSPACE_MAIL_DELIVERY,
currentUserV1.value.userRole
),
- type: "route",
+ type: "div",
},
],
},
{
title: t("common.archived"),
icon: h(Archive),
- path: "/setting/archive",
- type: "route",
+ path: SETTING_ROUTE_WORKSPACE_ARCHIVE,
+ type: "div",
},
];
});
diff --git a/frontend/src/views/SettingWorkspaceAuditLog.vue b/frontend/src/views/SettingWorkspaceAuditLog.vue
index c6f63c3b27..2d68922d5f 100644
--- a/frontend/src/views/SettingWorkspaceAuditLog.vue
+++ b/frontend/src/views/SettingWorkspaceAuditLog.vue
@@ -95,6 +95,7 @@ import { useI18n } from "vue-i18n";
import { useRoute, useRouter } from "vue-router";
import { BBDialog } from "@/bbkit";
import { ExportOption } from "@/components/DataExportButton.vue";
+import { SETTING_ROUTE_WORKSPACE_AUDIT_LOG } from "@/router/dashboard/workspaceSetting";
import { featureToRef, useUserStore, useActivityV1Store } from "@/store";
import {
AuditActivityTypeList,
@@ -137,7 +138,7 @@ watch(
() => state.userUid,
(uid) => {
router.replace({
- name: "setting.workspace.audit-log",
+ name: SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
query: {
...route.query,
user: parseInt(uid, 10) > 0 ? uid : undefined,
@@ -150,7 +151,7 @@ watch(
() => state.selectedAuditTypeList,
(list) => {
router.replace({
- name: "setting.workspace.audit-log",
+ name: SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
query: {
...route.query,
type: list.join(","),
@@ -212,7 +213,7 @@ const handleViewDetail = (log: LogEntity) => {
const confirmDatePicker = (value: [number, number]) => {
router.replace({
- name: "setting.workspace.audit-log",
+ name: SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
query: {
...route.query,
createdTsAfter: value[0],
@@ -223,7 +224,7 @@ const confirmDatePicker = (value: [number, number]) => {
const clearDatePicker = () => {
router.replace({
- name: "setting.workspace.audit-log",
+ name: SETTING_ROUTE_WORKSPACE_AUDIT_LOG,
query: {
...route.query,
createdTsAfter: 0,
diff --git a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
index b62de2350c..f9819d0c10 100644
--- a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
@@ -136,8 +136,15 @@ import { computed, reactive, toRef, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBTextField } from "@/bbkit";
+import {
+ payloadValueListToComponentList,
+ SQLRuleFilter,
+ useSQLRuleFilter,
+ SQLRuleTable,
+} from "@/components/SQLReview/components";
import { PayloadForEngine } from "@/components/SQLReview/components/RuleConfigComponents";
import { EnvironmentV1Name } from "@/components/v2";
+import { SETTING_ROUTE_WORKSPACE_SQL_REVIEW } from "@/router/dashboard/workspaceSetting";
import {
pushNotification,
useCurrentUserV1,
@@ -158,12 +165,6 @@ import {
import { Engine } from "@/types/proto/v1/common";
import { SQLReviewRuleLevel } from "@/types/proto/v1/org_policy_service";
import { idFromSlug, hasWorkspacePermissionV1 } from "@/utils";
-import {
- payloadValueListToComponentList,
- SQLRuleFilter,
- useSQLRuleFilter,
- SQLRuleTable,
-} from "../components/SQLReview/components";
const props = defineProps({
sqlReviewPolicySlug: {
@@ -188,7 +189,6 @@ const { t } = useI18n();
const store = useSQLReviewStore();
const router = useRouter();
const currentUserV1 = useCurrentUserV1();
-const ROUTE_NAME = "setting.workspace.sql-review";
const subscriptionStore = useSubscriptionV1Store();
const state = reactive<LocalState>({
@@ -384,7 +384,7 @@ const onRemove = () => {
});
});
router.replace({
- name: ROUTE_NAME,
+ name: SETTING_ROUTE_WORKSPACE_SQL_REVIEW,
});
};
</script>
diff --git a/frontend/src/views/SettingWorkspaceSSO.vue b/frontend/src/views/SettingWorkspaceSSO.vue
index c0365e76c3..81cac3f794 100644
--- a/frontend/src/views/SettingWorkspaceSSO.vue
+++ b/frontend/src/views/SettingWorkspaceSSO.vue
@@ -82,6 +82,10 @@
<script lang="ts" setup>
import { computed, onMounted, reactive } from "vue";
import { useRouter } from "vue-router";
+import {
+ SETTING_ROUTE_WORKSPACE_SSO_CREATE,
+ SETTING_ROUTE_WORKSPACE_SSO_DETAIL,
+} from "@/router/dashboard/workspaceSetting";
import { featureToRef } from "@/store";
import { useIdentityProviderStore } from "@/store/modules/idp";
import { IdentityProvider } from "@/types/proto/v1/idp_service";
@@ -116,7 +120,7 @@ const handleCreateSSO = () => {
return;
}
router.push({
- name: "setting.workspace.sso.create",
+ name: SETTING_ROUTE_WORKSPACE_SSO_CREATE,
});
};
@@ -126,7 +130,7 @@ const handleViewSSO = (identityProvider: IdentityProvider) => {
return;
}
router.push({
- name: "setting.workspace.sso.detail",
+ name: SETTING_ROUTE_WORKSPACE_SSO_DETAIL,
params: {
ssoName: identityProvider.name,
},
diff --git a/frontend/src/views/SettingWorkspaceVCS.vue b/frontend/src/views/SettingWorkspaceVCS.vue
index 13dae02456..2e5bb1b0ab 100644
--- a/frontend/src/views/SettingWorkspaceVCS.vue
+++ b/frontend/src/views/SettingWorkspaceVCS.vue
@@ -30,6 +30,7 @@ import { computed, watchEffect } from "vue";
import { useRouter } from "vue-router";
import VCSCard from "@/components/VCS/VCSCard.vue";
import VCSSetupWizard from "@/components/VCS/VCSSetupWizard.vue";
+import { SETTING_ROUTE_WORKSPACE_GITOPS_CREATE } from "@/router/dashboard/workspaceSetting";
import { useVCSV1Store } from "@/store";
const vcsV1Store = useVCSV1Store();
@@ -47,7 +48,7 @@ const vcsList = computed(() => {
const addVCSProvider = () => {
router.push({
- name: "setting.workspace.gitops.create",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS_CREATE,
});
};
</script>
diff --git a/frontend/src/views/SettingWorkspaceVCSDetail.vue b/frontend/src/views/SettingWorkspaceVCSDetail.vue
index 7b92c21788..a9136bdf2b 100644
--- a/frontend/src/views/SettingWorkspaceVCSDetail.vue
+++ b/frontend/src/views/SettingWorkspaceVCSDetail.vue
@@ -155,6 +155,7 @@ import isEmpty from "lodash-es/isEmpty";
import { reactive, computed, watchEffect, onMounted, onUnmounted } from "vue";
import { useRouter } from "vue-router";
import { vcsListByUIType } from "@/components/VCS/utils";
+import { SETTING_ROUTE_WORKSPACE_GITOPS } from "@/router/dashboard/workspaceSetting";
import { pushNotification, useRepositoryV1Store, useVCSV1Store } from "@/store";
import {
OAuthToken,
@@ -373,7 +374,7 @@ const doUpdate = () => {
const cancel = () => {
router.push({
- name: "setting.workspace.gitops",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS,
});
};
@@ -389,7 +390,7 @@ const deleteVCS = () => {
title: `Successfully deleted '${title}'`,
});
router.push({
- name: "setting.workspace.gitops",
+ name: SETTING_ROUTE_WORKSPACE_GITOPS,
});
});
};
diff --git a/frontend/src/views/TwoFactorSetup.vue b/frontend/src/views/TwoFactorSetup.vue
index 4bcd37392a..4a0146823b 100644
--- a/frontend/src/views/TwoFactorSetup.vue
+++ b/frontend/src/views/TwoFactorSetup.vue
@@ -89,6 +89,7 @@ import RecoveryCodesView from "@/components/RecoveryCodesView.vue";
import TwoFactorSecretModal from "@/components/TwoFactorSecretModal.vue";
import { StepTab } from "@/components/v2";
import { AUTH_2FA_SETUP_MODULE } from "@/router/auth";
+import { SETTING_ROUTE_PROFILE } from "@/router/dashboard/workspaceSetting";
import { pushNotification, useAuthStore, useUserStore } from "@/store";
import { UpdateUserRequest } from "@/types/proto/v1/auth_service";
@@ -182,7 +183,7 @@ const cancelSetup = () => {
props.cancelAction();
} else {
router.replace({
- name: "setting.profile",
+ name: SETTING_ROUTE_PROFILE,
});
}
};
@@ -222,7 +223,7 @@ const tryFinishSetup = async () => {
});
} else {
router.replace({
- name: "setting.profile",
+ name: SETTING_ROUTE_PROFILE,
});
}
};
diff --git a/frontend/src/views/branch/BranchDetail.vue b/frontend/src/views/branch/BranchDetail.vue
index 8e5150e509..29751a66ed 100644
--- a/frontend/src/views/branch/BranchDetail.vue
+++ b/frontend/src/views/branch/BranchDetail.vue
@@ -29,7 +29,7 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import BranchCreateView from "@/components/Branch/BranchCreateView.vue";
import BranchDetailView from "@/components/Branch/BranchDetailView.vue";
-import { PROJECT_V1_BRANCHE_DETAIL } from "@/router/dashboard/projectV1";
+import { PROJECT_V1_ROUTE_BRANCH_DETAIL } from "@/router/dashboard/projectV1";
import { extractUserEmail, useCurrentUserV1, useProjectV1Store } from "@/store";
import { useBranchStore } from "@/store/modules/branch";
import { projectNamePrefix } from "@/store/modules/v1/common";
@@ -74,7 +74,7 @@ const handleUpdateBranchId = (id: string) => {
branch.value.clean.branchId = id;
branch.value.dirty.branchId = id;
router.replace({
- name: PROJECT_V1_BRANCHE_DETAIL,
+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,
params: {
branchName: id,
},
diff --git a/frontend/src/views/branch/BranchMerge.vue b/frontend/src/views/branch/BranchMerge.vue
index 410f42eb55..69dd8557fc 100644
--- a/frontend/src/views/branch/BranchMerge.vue
+++ b/frontend/src/views/branch/BranchMerge.vue
@@ -16,8 +16,8 @@ import { computed } from "vue";
import { useRouter } from "vue-router";
import BranchMergeView from "@/components/Branch/BranchMergeView";
import {
- PROJECT_V1_BRANCHE_MERGE,
- PROJECT_V1_BRANCHE_DETAIL,
+ PROJECT_V1_ROUTE_BRANCH_MERGE,
+ PROJECT_V1_ROUTE_BRANCH_DETAIL,
} from "@/router/dashboard/projectV1";
import { useProjectV1Store } from "@/store";
import { getProjectAndBranchId } from "@/store/modules/v1/common";
@@ -49,7 +49,7 @@ const branchFullName = computed(() => {
const handleUpdateHeadBranchName = (branchName: string | null) => {
const branchId = branchName ? getProjectAndBranchId(branchName)[1] : "-";
router.replace({
- name: PROJECT_V1_BRANCHE_MERGE,
+ name: PROJECT_V1_ROUTE_BRANCH_MERGE,
params: {
branchName: branchId,
},
@@ -64,7 +64,7 @@ const handleMerged = (
headBranch: Branch | undefined
) => {
router.replace({
- name: PROJECT_V1_BRANCHE_DETAIL,
+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,
params: {
branchName: mergedBranch.branchId,
},
diff --git a/frontend/src/views/branch/BranchRebase.vue b/frontend/src/views/branch/BranchRebase.vue
index aa96bace08..5823305f97 100644
--- a/frontend/src/views/branch/BranchRebase.vue
+++ b/frontend/src/views/branch/BranchRebase.vue
@@ -16,8 +16,8 @@ import { computed } from "vue";
import { useRouter } from "vue-router";
import BranchRebaseView from "@/components/Branch/BranchRebaseView";
import {
- PROJECT_V1_BRANCHE_REBASE,
- PROJECT_V1_BRANCHE_DETAIL,
+ PROJECT_V1_ROUTE_BRANCH_REBASE,
+ PROJECT_V1_ROUTE_BRANCH_DETAIL,
} from "@/router/dashboard/projectV1";
import { useProjectV1Store } from "@/store";
import { getProjectAndBranchId } from "@/store/modules/v1/common";
@@ -49,7 +49,7 @@ const branchFullName = computed(() => {
const handleUpdateHeadBranchName = (branchName: string | null) => {
const branchId = branchName ? getProjectAndBranchId(branchName)[1] : "-";
router.replace({
- name: PROJECT_V1_BRANCHE_REBASE,
+ name: PROJECT_V1_ROUTE_BRANCH_REBASE,
params: {
branchName: branchId,
},
@@ -60,7 +60,7 @@ const handleUpdateHeadBranchName = (branchName: string | null) => {
const handleRebased = (rebasedBranch: Branch) => {
router.replace({
- name: PROJECT_V1_BRANCHE_DETAIL,
+ name: PROJECT_V1_ROUTE_BRANCH_DETAIL,
params: {
branchName: rebasedBranch.branchId,
},
diff --git a/frontend/src/views/project/ProjectWebhookDetail.vue b/frontend/src/views/project/ProjectWebhookDetail.vue
index 65ed2a244c..1dd6b83989 100644
--- a/frontend/src/views/project/ProjectWebhookDetail.vue
+++ b/frontend/src/views/project/ProjectWebhookDetail.vue
@@ -2,32 +2,7 @@
<div class="space-y-4 divide-y divide-block-border">
<div class="flex justify-between">
<div class="flex flex-row space-x-2 items-center">
- <!-- This awkward code is author couldn't figure out proper way to use dynamic src under vite
- https://github.com/vitejs/vite/issues/1265 -->
- <!-- TODO(ed): extract the code -->
- <template v-if="projectWebhook.type === Webhook_Type.TYPE_SLACK">
- <img class="h-6 w-6" src="../../assets/slack-logo.png" alt="" />
- </template>
- <template v-else-if="projectWebhook.type === Webhook_Type.TYPE_DISCORD">
- <img class="h-6 w-6" src="../../assets/discord-logo.svg" />
- </template>
- <template v-else-if="projectWebhook.type === Webhook_Type.TYPE_TEAMS">
- <img class="h-6 w-6" src="../../assets/teams-logo.svg" />
- </template>
- <template
- v-else-if="projectWebhook.type === Webhook_Type.TYPE_DINGTALK"
- >
- <img class="h-6 w-6" src="../../assets/dingtalk-logo.png" />
- </template>
- <template v-else-if="projectWebhook.type === Webhook_Type.TYPE_FEISHU">
- <img class="h-6 w-6" src="../../assets/feishu-logo.webp" />
- </template>
- <template v-else-if="projectWebhook.type === Webhook_Type.TYPE_WECOM">
- <img class="h-6 w-6" src="../../assets/wecom-logo.png" />
- </template>
- <template v-else-if="projectWebhook.type === Webhook_Type.TYPE_CUSTOM">
- <heroicons-outline:puzzle class="w-6 h-6" />
- </template>
+ <WebhookTypeIcon :type="projectWebhook.type" class="h-6 w-6" />
<h3 class="text-xl leading-6 font-medium text-main">
{{ projectWebhook.title }}
</h3>
@@ -49,7 +24,6 @@ import ProjectWebhookForm from "@/components/ProjectWebhookForm.vue";
import { useProjectV1Store, useProjectWebhookV1Store } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import { emptyProjectWebhook } from "@/types";
-import { Webhook_Type } from "@/types/proto/v1/project_service";
import { idFromSlug } from "@/utils";
const props = defineProps<{