Skip to content

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

refactor: project routing (#10289)

ecmadaof3c0ad76a7fb
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index a8c0d210aa..bbb213344e 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -17,7 +17,7 @@
>
<template #deployment_config>
<router-link
- :to="`/project/${projectV1Slug(selectedProject!)}#setting`"
+ :to="`/${selectedProject!.name}/settings`"
class="underline hover:bg-link-hover"
active-class=""
exact-active-class=""
@@ -336,7 +336,6 @@ import {
instanceV1HasAlterSchema,
filterDatabaseV1ByKeyword,
sortDatabaseV1List,
- projectV1Slug,
generateIssueName,
SearchScopeId,
SearchParams,
diff --git a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
index 0be1f53bb2..e4f40da2ff 100644
--- a/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/ProjectTenantView.vue
@@ -11,8 +11,7 @@
<template #go>
<router-link
:to="{
- path: `/project/${projectV1Slug(project)}`,
- hash: '#deployment-config',
+ path: `/${project.name}/settings`,
}"
active-class=""
exact-active-class=""
@@ -57,7 +56,6 @@ import { useDeploymentConfigV1ByProject } from "@/store";
import type { ComposedDatabase } from "@/types";
import { Environment } from "@/types/proto/v1/environment_service";
import { Project } from "@/types/proto/v1/project_service";
-import { projectV1Slug } from "@/utils";
import { DeployDatabaseTable } from "../TenantDatabaseTable";
const props = defineProps<{
diff --git a/frontend/src/components/Branch/BranchCreateView.vue b/frontend/src/components/Branch/BranchCreateView.vue
index 67f0bc3f9c..cc38172540 100644
--- a/frontend/src/components/Branch/BranchCreateView.vue
+++ b/frontend/src/components/Branch/BranchCreateView.vue
@@ -89,6 +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 {
pushNotification,
useDatabaseV1Store,
@@ -98,7 +99,6 @@ import { useBranchStore } from "@/store/modules/branch";
import { UNKNOWN_ID } from "@/types";
import { Branch } from "@/types/proto/v1/branch_service";
import { DatabaseMetadataView } from "@/types/proto/v1/database_service";
-import { projectV1Slug } from "@/utils";
import BaselineSchemaSelector from "./BaselineSchemaSelector.vue";
import BranchSelector from "./BranchSelector.vue";
import { validateBranchName } from "./utils";
@@ -164,7 +164,6 @@ const prepareBranchFromParentBranch = async (parent: string) => {
};
const prepareBranchFromDatabaseHead = async (uid: string) => {
const tag = `prepareBranchFromDatabaseHead(${uid})`;
- console.log(tag);
console.time(tag);
console.time("--fetch metadata");
@@ -296,9 +295,8 @@ const handleConfirm = async () => {
// Go to branch detail page after created.
router.replace({
- name: "workspace.project.branch.detail",
+ name: PROJECT_V1_BRANCHE_DETAIL,
params: {
- projectSlug: projectV1Slug(project.value),
branchName: branchId.value,
},
});
diff --git a/frontend/src/components/Branch/BranchDataTable/cells/BranchNameCell.vue b/frontend/src/components/Branch/BranchDataTable/cells/BranchNameCell.vue
index 8eb5e2f536..d52ffbff72 100644
--- a/frontend/src/components/Branch/BranchDataTable/cells/BranchNameCell.vue
+++ b/frontend/src/components/Branch/BranchDataTable/cells/BranchNameCell.vue
@@ -21,6 +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 { useProjectV1Store } from "@/store";
import {
getProjectAndBranchId,
@@ -28,7 +29,6 @@ import {
} from "@/store/modules/v1/common";
import { useProjectBranchProtectionRules } from "@/store/modules/v1/projectProtectionRoles";
import { Branch } from "@/types/proto/v1/branch_service";
-import { projectV1Slug } from "@/utils";
import { wildcardToRegex } from "../../utils";
const props = defineProps<{
@@ -60,9 +60,8 @@ const isProtected = computed(() => {
const handleBranchClick = async () => {
const [_, branchId] = getProjectAndBranchId(props.branch.name);
router.push({
- name: "workspace.project.branch.detail",
+ name: PROJECT_V1_BRANCHE_DETAIL,
params: {
- projectSlug: projectV1Slug(project.value),
branchName: `${branchId}`,
},
});
diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vue
index 91d94e95b6..c7317d7df9 100644
--- a/frontend/src/components/Branch/BranchDetailView.vue
+++ b/frontend/src/components/Branch/BranchDetailView.vue
@@ -131,13 +131,19 @@ import { useRouter } from "vue-router";
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,
+} from "@/router/dashboard/projectV1";
import { pushNotification, useDatabaseV1Store } from "@/store";
import { useBranchStore } from "@/store/modules/branch";
import { getProjectAndBranchId } from "@/store/modules/v1/common";
import { ComposedProject } from "@/types";
import { Branch } from "@/types/proto/v1/branch_service";
import { DatabaseMetadata } from "@/types/proto/v1/database_service";
-import { projectV1Slug } from "@/utils";
import { provideSQLCheckContext } from "../SQLCheck";
import { generateDiffDDL } from "../SchemaEditorLite";
import MaskSpinner from "../misc/MaskSpinner.vue";
@@ -295,9 +301,8 @@ const handleParentBranchClick = async () => {
const [_, branchId] = getProjectAndBranchId(parentBranch.value.name);
router.push({
- name: "workspace.project.branch.detail",
+ name: PROJECT_V1_BRANCHE_DETAIL,
params: {
- projectSlug: projectV1Slug(props.project),
branchName: `${branchId}`,
},
});
@@ -391,18 +396,16 @@ const handleSaveBranch = async () => {
const handleGotoMergeBranch = () => {
router.push({
- name: "workspace.project.branch.merge",
+ name: PROJECT_V1_BRANCHE_MERGE,
params: {
- projectSlug: projectV1Slug(props.project),
branchName: props.cleanBranch.branchId,
},
});
};
const handleGotoRebaseBranch = () => {
router.push({
- name: "workspace.project.branch.rebase",
+ name: PROJECT_V1_BRANCHE_REBASE,
params: {
- projectSlug: projectV1Slug(props.project),
branchName: props.cleanBranch.branchId,
},
});
@@ -410,9 +413,8 @@ const handleGotoRebaseBranch = () => {
const handleApplyBranchToDatabase = () => {
router.push({
- name: "workspace.project.branch.rollout",
+ name: PROJECT_V1_BRANCHE_ROLLOUT,
params: {
- projectSlug: projectV1Slug(props.project),
branchName: props.cleanBranch.branchId,
},
});
@@ -490,11 +492,7 @@ const deleteBranch = async () => {
const branch = props.dirtyBranch;
await branchStore.deleteBranch(branch.name);
router.replace({
- name: "workspace.project.detail",
- hash: "#branches",
- params: {
- projectSlug: projectV1Slug(props.project),
- },
+ name: PROJECT_V1_BRANCHES,
});
};
</script>
diff --git a/frontend/src/components/Branch/BranchMergeView/SelectBranchStep.vue b/frontend/src/components/Branch/BranchMergeView/SelectBranchStep.vue
index cfe8215350..0d571cd517 100644
--- a/frontend/src/components/Branch/BranchMergeView/SelectBranchStep.vue
+++ b/frontend/src/components/Branch/BranchMergeView/SelectBranchStep.vue
@@ -122,11 +122,11 @@ 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 { useDatabaseV1Store } from "@/store";
import { ComposedProject } from "@/types";
import { Branch } from "@/types/proto/v1/branch_service";
import { DatabaseMetadata } from "@/types/proto/v1/database_service";
-import { projectSlugV1 } from "@/utils";
import { MergeBranchValidationState } from "./types";
type TabValue = "schema-editor" | "raw-schema-text";
@@ -170,9 +170,8 @@ const headBranchFilter = (branch: Branch) => {
const rebaseLink = (headBranch: Branch, targetBranch: Branch) => {
return {
- name: "workspace.project.branch.rebase",
+ name: PROJECT_V1_BRANCHE_REBASE,
params: {
- projectSlug: projectSlugV1(props.project),
branchName: headBranch.branchId,
},
query: {
diff --git a/frontend/src/components/Changelist/ChangelistDashboard/ChangelistTable.vue b/frontend/src/components/Changelist/ChangelistDashboard/ChangelistTable.vue
index d8045592bb..a6f7062db9 100644
--- a/frontend/src/components/Changelist/ChangelistDashboard/ChangelistTable.vue
+++ b/frontend/src/components/Changelist/ChangelistDashboard/ChangelistTable.vue
@@ -44,7 +44,6 @@ import { Changelist } from "@/types/proto/v1/changelist_service";
import {
extractUserResourceName,
getHighlightHTMLByRegExp,
- projectV1Slug,
extractChangelistResourceName,
} from "@/utils";
import { projectForChangelist } from "../ChangelistDetail/common";
@@ -79,11 +78,8 @@ const handleClickRow = (
row: number,
e: MouseEvent
) => {
- const project = projectForChangelist(item);
const url = router.resolve({
- path: `/project/${projectV1Slug(
- project
- )}/changelists/${extractChangelistResourceName(item.name)}`,
+ path: `changelists/${extractChangelistResourceName(item.name)}`,
}).fullPath;
if (e.ctrlKey || e.metaKey) {
window.open(url, "_blank");
diff --git a/frontend/src/components/Changelist/ChangelistDashboard/CreateChangelistPanel.vue b/frontend/src/components/Changelist/ChangelistDashboard/CreateChangelistPanel.vue
index e15efcaf0b..8f57e6064e 100644
--- a/frontend/src/components/Changelist/ChangelistDashboard/CreateChangelistPanel.vue
+++ b/frontend/src/components/Changelist/ChangelistDashboard/CreateChangelistPanel.vue
@@ -103,7 +103,7 @@ import {
import { ResourceId, UNKNOWN_ID, ValidatedMessage } from "@/types";
import { ComposedProject } from "@/types";
import { Changelist } from "@/types/proto/v1/changelist_service";
-import { projectV1Slug, extractChangelistResourceName } from "@/utils";
+import { extractChangelistResourceName } from "@/utils";
import { getErrorCode } from "@/utils/grpcweb";
import { useChangelistDashboardContext } from "./context";
@@ -195,9 +195,9 @@ const doCreate = async () => {
});
router.push(
- `/project/${projectV1Slug(
- project
- )}/changelists/${extractChangelistResourceName(created.name)}`
+ `/${project.name}/changelists/${extractChangelistResourceName(
+ created.name
+ )}`
);
events.emit("refresh");
} finally {
diff --git a/frontend/src/components/Changelist/ChangelistDetail/AddChangePanel/form/ChangeHistoryTable/ChangeHistoryTable.vue b/frontend/src/components/Changelist/ChangelistDetail/AddChangePanel/form/ChangeHistoryTable/ChangeHistoryTable.vue
index 34552156a2..8ba5ba7ee9 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/AddChangePanel/form/ChangeHistoryTable/ChangeHistoryTable.vue
+++ b/frontend/src/components/Changelist/ChangelistDetail/AddChangePanel/form/ChangeHistoryTable/ChangeHistoryTable.vue
@@ -166,7 +166,6 @@ const handleClickRow = (item: ChangeHistory) => {
};
const tryClickCheckbox = (e: MouseEvent) => {
- console.log(e);
const div = e.target as HTMLElement;
const checkbox = div.querySelector(".n-checkbox");
if (!checkbox) return;
diff --git a/frontend/src/components/Changelist/ChangelistDetail/ChangelistDetail.vue b/frontend/src/components/Changelist/ChangelistDetail/ChangelistDetail.vue
index 7bbfa3eadd..65a03ab5cd 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/ChangelistDetail.vue
+++ b/frontend/src/components/Changelist/ChangelistDetail/ChangelistDetail.vue
@@ -45,6 +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 { pushNotification, useChangelistStore } from "@/store";
import {
Changelist_Change as Change,
@@ -124,7 +125,7 @@ const handleReorderMove = (row: number, delta: -1 | 1) => {
};
const documentTitle = computed(() => {
- if (route.name !== "workspace.project.changelist.detail") {
+ if (route.name !== PROJECT_V1_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 31a6dae63c..0b62cb1e8b 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/DeleteChangelistButton.vue
+++ b/frontend/src/components/Changelist/ChangelistDetail/DeleteChangelistButton.vue
@@ -37,9 +37,8 @@ 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 { pushNotification, useChangelistStore } from "@/store";
-import { projectV1Slug } from "@/utils";
-import { projectForChangelist } from "./common";
import { useChangelistDetailContext } from "./context";
const router = useRouter();
@@ -59,15 +58,10 @@ const errors = computed(() => {
const handleDelete = async () => {
isUpdating.value = true;
- const project = projectForChangelist(changelist.value);
try {
await useChangelistStore().deleteChangelist(changelist.value.name);
router.replace({
- name: "workspace.project.detail",
- hash: "#changelists",
- params: {
- projectSlug: projectV1Slug(project),
- },
+ name: PROJECT_V1_CHANGELISTS,
});
pushNotification({
module: "bytebase",
diff --git a/frontend/src/components/Changelist/ChangelistDetail/context.ts b/frontend/src/components/Changelist/ChangelistDetail/context.ts
index c504a9cab1..03629472a7 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/context.ts
+++ b/frontend/src/components/Changelist/ChangelistDetail/context.ts
@@ -1,18 +1,26 @@
import Emittery from "emittery";
-import { InjectionKey, Ref, computed, inject, provide, ref } from "vue";
+import {
+ InjectionKey,
+ Ref,
+ computed,
+ inject,
+ provide,
+ ref,
+ watchEffect,
+} from "vue";
import { useRoute } from "vue-router";
import {
useChangelistStore,
useCurrentUserV1,
useProjectV1Store,
} from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { ComposedProject, unknownChangelist, unknownProject } from "@/types";
import {
Changelist,
Changelist_Change as Change,
} from "@/types/proto/v1/changelist_service";
import {
- idFromSlug,
extractUserResourceName,
hasWorkspacePermissionV1,
isOwnerOfProjectV1,
@@ -50,19 +58,22 @@ export const provideChangelistDetailContext = () => {
const projectV1Store = useProjectV1Store();
const project = computed(() => {
- const projectSlug = route.params.projectSlug as string;
- if (!projectSlug) {
+ const projectId = route.params.projectId as string;
+ if (!projectId) {
return unknownProject();
}
- const proj = projectV1Store.getProjectByUID(
- String(idFromSlug(projectSlug))
- );
- return proj;
+
+ return projectV1Store.getProjectByName(`${projectNamePrefix}${projectId}`);
});
const name = computed(() => {
return `${project.value.name}/changelists/${route.params.changelistName}`;
});
+
+ watchEffect(async () => {
+ await useChangelistStore().fetchChangelistByName(name.value);
+ });
+
const changelist = computed(() => {
return (
useChangelistStore().getChangelistByName(name.value) ??
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
index 0796c08ee3..1821d402df 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
@@ -47,6 +47,11 @@ import { useI18n } from "vue-i18n";
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,
+} from "@/router/dashboard/projectV1";
import {
pushNotification,
useDBGroupStore,
@@ -61,7 +66,7 @@ import {
import { ParsedExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
import { Expr } from "@/types/proto/google/type/expr";
import { DatabaseGroup, SchemaGroup } from "@/types/proto/v1/project_service";
-import { batchConvertParsedExprToCELString, projectV1Slug } from "@/utils";
+import { batchConvertParsedExprToCELString } from "@/utils";
import { buildDatabaseGroupExpr } from "@/utils/databaseGroup/cel";
import DatabaseGroupForm from "./DatabaseGroupForm.vue";
import { ResourceType } from "./common/ExprEditor/context";
@@ -164,15 +169,10 @@ const doDelete = () => {
const databaseGroup = props.databaseGroup as DatabaseGroup;
await dbGroupStore.deleteDatabaseGroup(databaseGroup.name);
if (
- router.currentRoute.value.name ===
- "workspace.project.database-group.detail"
+ router.currentRoute.value.name === PROJECT_V1_DATABASE_GROUP_DETAIL
) {
router.replace({
- name: "workspace.project.detail",
- params: {
- projectSlug: projectV1Slug(props.project),
- },
- hash: "#database-groups",
+ name: PROJECT_V1_DATABASE_GROUPS,
});
}
} else if (props.resourceType === "SCHEMA_GROUP") {
@@ -181,16 +181,14 @@ const doDelete = () => {
await dbGroupStore.deleteSchemaGroup(schemaGroupName);
if (
router.currentRoute.value.name ===
- "workspace.project.database-group.table-group.detail"
+ PROJECT_V1_DATABASE_GROUP_TABLE_GROUP_DETAIL
) {
const [_, databaseGroupName] =
getProjectNameAndDatabaseGroupNameAndSchemaGroupName(
schemaGroupName
);
// TODO(steven): prevent `Cannot use 'in' operator to search for 'path' in undefined` error in vue-router.
- window.location.href = `/project/${projectV1Slug(
- props.project
- )}/database-groups/${databaseGroupName}`;
+ window.location.href = `/${props.project.name}/database-groups/${databaseGroupName}`;
}
}
emit("close");
@@ -287,9 +285,7 @@ const doConfirm = async () => {
);
if (dbGroup) {
router.push(
- `/project/${projectV1Slug(dbGroup.project)}/database-groups/${
- dbGroup.databaseGroupName
- }`
+ `/${dbGroup.project.name}/database-groups/${dbGroup.databaseGroupName}`
);
}
} else {
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
index 3f775eef20..60562f0461 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupTable.vue
@@ -29,7 +29,6 @@ import { useRouter } from "vue-router";
import { BBGridColumn } from "@/bbkit";
import { ComposedDatabaseGroup } from "@/types";
import { DatabaseGroup } from "@/types/proto/v1/project_service";
-import { projectV1Slug } from "@/utils";
const props = defineProps<{
databaseGroupList: ComposedDatabaseGroup[];
@@ -68,9 +67,7 @@ const clickDatabaseGroup = (databaseGroup: ComposedDatabaseGroup) => {
}
router.push(
- `/project/${projectV1Slug(databaseGroup.project)}/database-groups/${
- databaseGroup.databaseGroupName
- }`
+ `/${databaseGroup.project.name}/database-groups/${databaseGroup.databaseGroupName}`
);
};
</script>
diff --git a/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue b/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue
index 7cb0eeee34..d1b0e48154 100644
--- a/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue
+++ b/frontend/src/components/DatabaseGroup/SchemaGroupTable.vue
@@ -28,7 +28,6 @@ import { BBGridColumn } from "@/bbkit";
import { getProjectNameAndDatabaseGroupNameAndSchemaGroupName } from "@/store/modules/v1/common";
import { ComposedSchemaGroup } from "@/types";
import { SchemaGroup } from "@/types/proto/v1/project_service";
-import { projectV1Slug } from "@/utils";
defineProps<{
schemaGroupList: SchemaGroup[];
@@ -57,9 +56,7 @@ const clickSchemaGroup = (schemaGroup: ComposedSchemaGroup) => {
const [_, databaseGroupName, schemaGroupName] =
getProjectNameAndDatabaseGroupNameAndSchemaGroupName(schemaGroup.name);
router.push(
- `/project/${projectV1Slug(
- schemaGroup.databaseGroup.project
- )}/database-groups/${databaseGroupName}/table-groups/${schemaGroupName}`
+ `/${schemaGroup.databaseGroup.project.name}/database-groups/${databaseGroupName}/table-groups/${schemaGroupName}`
);
};
</script>
diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vue
index edbc1eed93..c2e60d6cd4 100644
--- a/frontend/src/components/InstanceForm/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm/InstanceForm.vue
@@ -652,7 +652,6 @@ const changeMaximumConnections = (maximumConnections: number) => {
if (!basicInfo.value.options) {
basicInfo.value.options = InstanceOptions.fromPartial({});
}
- console.log(maximumConnections);
basicInfo.value.options.maximumConnections = maximumConnections;
};
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue b/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue
index 5fdc824904..3531331ba8 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue
+++ b/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue
@@ -58,7 +58,6 @@
v-show="showMenu"
v-zindexable="{ enabled: true }"
class="absolute top-[36px] w-full bg-gray-100 shadow-xl origin-top-left rounded-[3px] overflow-clip"
- @wheel="console.log('wheel', $event)"
>
<ScopeMenu
:show="menuView === 'scope'"
diff --git a/frontend/src/components/KBar/useProjectActions.ts b/frontend/src/components/KBar/useProjectActions.ts
index d1e197d5a7..f58b5487e6 100644
--- a/frontend/src/components/KBar/useProjectActions.ts
+++ b/frontend/src/components/KBar/useProjectActions.ts
@@ -4,7 +4,7 @@ import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { useCurrentUserV1, useProjectV1ListByCurrentUser } from "@/store";
import { DEFAULT_PROJECT_ID } from "@/types";
-import { isMemberOfProjectV1, projectV1Slug } from "@/utils";
+import { isMemberOfProjectV1 } from "@/utils";
export const useProjectActions = () => {
const { t } = useI18n();
@@ -39,7 +39,7 @@ export const useProjectActions = () => {
tags: [project.key],
},
perform: () => {
- router.push({ path: `/project/${projectV1Slug(project)}#overview` });
+ router.push({ path: `/${project.name}` });
},
})
);
diff --git a/frontend/src/components/Project/ProjectCreatePanel.vue b/frontend/src/components/Project/ProjectCreatePanel.vue
index 7c97e16984..81cca32e80 100644
--- a/frontend/src/components/Project/ProjectCreatePanel.vue
+++ b/frontend/src/components/Project/ProjectCreatePanel.vue
@@ -103,7 +103,7 @@ import { projectNamePrefix } from "@/store/modules/v1/common";
import { useProjectV1Store } from "@/store/modules/v1/project";
import { ResourceId, ValidatedMessage, emptyProject } from "@/types";
import { Project, TenantMode } from "@/types/proto/v1/project_service";
-import { projectV1Slug, randomString } from "@/utils";
+import { randomString } from "@/utils";
import { getErrorCode } from "@/utils/grpcweb";
interface LocalState {
@@ -200,8 +200,7 @@ const create = async () => {
}),
});
const url = {
- path: `/project/${projectV1Slug(createdProject)}`,
- hash: "",
+ path: `/${createdProject.name}`,
};
router.push(url);
emit("dismiss");
diff --git a/frontend/src/components/Project/ProjectSidebar.vue b/frontend/src/components/Project/ProjectSidebarV1.vue
similarity index 58%
rename from frontend/src/components/Project/ProjectSidebar.vue
rename to frontend/src/components/Project/ProjectSidebarV1.vue
index e435941028..d8efe34553 100644
--- a/frontend/src/components/Project/ProjectSidebar.vue
+++ b/frontend/src/components/Project/ProjectSidebarV1.vue
@@ -19,49 +19,39 @@ import {
RefreshCcw,
PencilRuler,
} from "lucide-vue-next";
-import { computed, h, reactive, watch, nextTick } from "vue";
+import { computed, h } from "vue";
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,
+} from "@/router/dashboard/projectV1";
import { useCurrentUserIamPolicy } from "@/store";
import { DEFAULT_PROJECT_V1_NAME } from "@/types";
import { TenantMode } from "@/types/proto/v1/project_service";
-import { projectSlugV1 } from "@/utils";
import { useProjectDatabaseActions } from "../KBar/useDatabaseActions";
import { useCurrentProject } from "./useCurrentProject";
-const projectHashList = [
- "databases",
- "database-groups",
- "change-history",
- "slow-query",
- "anomalies",
- "issues",
- "branches",
- "changelists",
- "sync-schema",
- "gitops",
- "webhook",
- "members",
- "activities",
- "setting",
-] as const;
-export type ProjectHash = typeof projectHashList[number];
-const isProjectHash = (x: any): x is ProjectHash => projectHashList.includes(x);
-
interface ProjectSidebarItem extends SidebarItem {
title: string;
- type: "div" | "link";
+ type: "div" | "route";
children?: {
title: string;
path: string;
hide?: boolean;
- type: "link";
+ type: "route";
}[];
}
const props = defineProps<{
- projectSlug?: string;
projectId?: string;
issueSlug?: string;
databaseSlug?: string;
@@ -69,21 +59,11 @@ const props = defineProps<{
}>();
const route = useRoute();
-
-interface LocalState {
- selectedHash: ProjectHash;
-}
-
const { t } = useI18n();
const router = useRouter();
-const state = reactive<LocalState>({
- selectedHash: "databases",
-});
-
const params = computed(() => {
return {
- projectSlug: props.projectSlug,
projectId: props.projectId,
issueSlug: props.issueSlug,
databaseSlug: props.databaseSlug,
@@ -93,10 +73,6 @@ const params = computed(() => {
const { project } = useCurrentProject(params);
-const defaultHash = computed((): ProjectHash => {
- return "databases";
-});
-
const currentUserIamPolicy = useCurrentUserIamPolicy();
const isDefaultProject = computed((): boolean => {
@@ -107,8 +83,9 @@ 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/${projectSlugV1(project.value)}`;
+ const projectPath = `/${project.value.name}`;
return [
{
title: t("common.database"),
@@ -117,53 +94,53 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
children: [
{
title: t("common.databases"),
- path: `${projectPath}#databases`,
- type: "link",
+ path: `${projectPath}/databases`,
+ type: "route",
},
{
title: t("common.groups"),
- path: `${projectPath}#database-groups`,
- type: "link",
+ path: `${projectPath}/database-groups`,
+ type: "route",
hide:
!isTenantProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: t("common.change-history"),
- path: `${projectPath}#change-history`,
- type: "link",
+ path: `${projectPath}/change-histories`,
+ type: "route",
hide:
isTenantProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: startCase(t("slow-query.slow-queries")),
- path: `${projectPath}#slow-query`,
- type: "link",
+ path: `${projectPath}/slow-queries`,
+ type: "route",
hide: !currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: t("common.anomalies"),
- path: `${projectPath}#anomalies`,
- type: "link",
+ path: `${projectPath}/anomalies`,
+ type: "route",
hide: !currentUserIamPolicy.isMemberOfProject(project.value.name),
},
],
},
{
title: t("common.issues"),
- path: `${projectPath}#issues`,
+ path: `${projectPath}/issues`,
icon: h(CircleDot),
- type: "link",
+ type: "route",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: t("common.branches"),
- path: `${projectPath}#branches`,
+ path: `${projectPath}/branches`,
icon: h(GitBranch),
- type: "link",
+ type: "route",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.allowToChangeDatabaseOfProject(
@@ -172,18 +149,18 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
},
{
title: t("changelist.changelists"),
- path: `${projectPath}#changelists`,
+ path: `${projectPath}/changelists`,
icon: h(PencilRuler),
- type: "link",
+ type: "route",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
},
{
title: t("database.sync-schema.title"),
- path: `${projectPath}#sync-schema`,
+ path: `${projectPath}/sync-schema`,
icon: h(RefreshCcw),
- type: "link",
+ type: "route",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.allowToChangeDatabaseOfProject(
@@ -200,13 +177,13 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
children: [
{
title: t("common.gitops"),
- path: `${projectPath}#gitops`,
- type: "link",
+ path: `${projectPath}/gitops`,
+ type: "route",
},
{
title: t("common.webhooks"),
- path: `${projectPath}#webhook`,
- type: "link",
+ path: `${projectPath}/webhooks`,
+ type: "route",
},
],
},
@@ -220,21 +197,21 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
children: [
{
title: t("common.members"),
- path: `${projectPath}#members`,
- type: "link",
+ path: `${projectPath}/members`,
+ type: "route",
},
{
title: t("common.activities"),
- path: `${projectPath}#activities`,
- type: "link",
+ path: `${projectPath}/activities`,
+ type: "route",
},
],
},
{
title: t("common.setting"),
icon: h(Settings),
- path: `${projectPath}#setting`,
- type: "link",
+ path: `${projectPath}/settings`,
+ type: "route",
hide:
isDefaultProject.value ||
!currentUserIamPolicy.isMemberOfProject(project.value.name),
@@ -242,112 +219,80 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
];
});
-const getHashByFullPath = (fullpath: string | undefined): ProjectHash => {
- if (!fullpath) {
- return "" as ProjectHash;
- }
- return fullpath.split("#").splice(-1)[0] as ProjectHash;
-};
+const getItemClass = (path: string | undefined) => {
+ const projectPath = `/${project.value.name}`;
-const getItemClass = (fullpath: string | undefined) => {
- const hash = getHashByFullPath(fullpath);
const list = ["outline-item"];
- if (!isProjectHash(hash)) {
- return list;
- }
- const projectHash = hash as ProjectHash;
- if (state.selectedHash === projectHash) {
- list.push("bg-link-hover");
+ switch (route.name) {
+ case PROJECT_V1_WEBHOOK_CREATE:
+ case PROJECT_V1_WEBHOOK_DETAIL:
+ if (path === `${projectPath}/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`) {
+ list.push("router-link-active", "bg-link-hover");
+ }
+ break;
+ case PROJECT_V1_CHANGELIST_DETAIL:
+ if (path === `${projectPath}/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`) {
+ list.push("router-link-active", "bg-link-hover");
+ }
+ break;
+ case "workspace.issue.detail":
+ if (path === `${projectPath}/issues`) {
+ list.push("router-link-active", "bg-link-hover");
+ }
+ break;
+ case "workspace.database.history.detail":
+ if (path === `${projectPath}/change-histories`) {
+ list.push("router-link-active", "bg-link-hover");
+ }
+ break;
+ case "workspace.database.detail":
+ if (path === `${projectPath}/databases`) {
+ list.push("router-link-active", "bg-link-hover");
+ }
+ break;
}
return list;
};
-const onSelect = (hash: ProjectHash | undefined) => {
- if (!hash || !isProjectHash(hash)) {
+const onSelect = (path: string) => {
+ if (!path) {
return;
}
- let validHash = hash || defaultHash.value;
- const tab = flattenNavigationItems.value.find((item) => item.path === hash);
- if (!tab || tab.hide) {
- validHash = defaultHash.value;
- }
- state.selectedHash = validHash;
router.replace({
- name: "workspace.project.detail",
- hash: `#${validHash}`,
- query: route.query,
- params: {
- projectSlug: props.projectSlug || projectSlugV1(project.value),
- },
+ path,
});
};
-const selectProjectTabOnHash = () => {
- const { name, hash } = router.currentRoute.value;
-
- switch (name) {
- case "workspace.project.detail": {
- let targetHash = hash.replace(/^#?/g, "");
- if (!isProjectHash(targetHash)) {
- targetHash = defaultHash.value;
- }
- onSelect(targetHash as ProjectHash);
- return;
- }
- case "workspace.project.hook.create":
- case "workspace.project.hook.detail":
- state.selectedHash = "webhook";
- return;
- case "workspace.project.changelist.detail":
- state.selectedHash = "changelists";
- return;
- case "workspace.project.branch.detail":
- state.selectedHash = "branches";
- return;
- case "workspace.project.database-group.detail":
- case "workspace.project.database-group.table-group.detail":
- state.selectedHash = "database-groups";
- return;
- case "workspace.issue.detail":
- state.selectedHash = "issues";
- return;
- case "workspace.database.detail":
- state.selectedHash = "databases";
- return;
- case "workspace.database.history.detail":
- state.selectedHash = "change-history";
- return;
- }
-};
-
-watch(
- () => [router.currentRoute.value.hash],
- () => {
- nextTick(() => {
- selectProjectTabOnHash();
- });
- },
- {
- immediate: true,
- }
-);
-
const flattenNavigationItems = computed(() => {
return projectSidebarItemList.value.flatMap<{
- path: ProjectHash;
+ path: string;
title: string;
hide?: boolean;
}>((item) => {
if (item.children && item.children.length > 0) {
return item.children.map((child) => ({
- path: getHashByFullPath(child.path),
+ path: child.path,
title: child.title,
hide: child.hide,
}));
}
return [
{
- path: getHashByFullPath(item.path),
+ path: item.path ?? "",
title: item.title,
hide: item.hide,
},
diff --git a/frontend/src/components/Project/useCurrentProject.ts b/frontend/src/components/Project/useCurrentProject.ts
index b922d08554..865d59b813 100644
--- a/frontend/src/components/Project/useCurrentProject.ts
+++ b/frontend/src/components/Project/useCurrentProject.ts
@@ -12,7 +12,6 @@ import { idFromSlug } from "@/utils";
export const useCurrentProject = (
params: ComputedRef<{
- projectSlug?: string;
projectId?: string;
issueSlug?: string;
databaseSlug?: string;
@@ -52,10 +51,6 @@ export const useCurrentProject = (
const existedIssue = await experimentalFetchIssueByUID(issueUID.value);
return existedIssue.projectEntity;
- } else if (unref(params).projectSlug) {
- return useProjectV1Store().getProjectByUID(
- String(idFromSlug(unref(params).projectSlug!))
- );
} else if (unref(params).projectId) {
return useProjectV1Store().getProjectByName(
`${projectNamePrefix}${unref(params).projectId}`
diff --git a/frontend/src/components/ProjectBranchesPanel.vue b/frontend/src/components/ProjectBranchesPanel.vue
index 6e071d4ee0..6cf531d82e 100644
--- a/frontend/src/components/ProjectBranchesPanel.vue
+++ b/frontend/src/components/ProjectBranchesPanel.vue
@@ -41,11 +41,11 @@ 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 { useCurrentUserV1 } from "@/store";
import { useBranchListByProject } from "@/store/modules/branch";
import { userNamePrefix } from "@/store/modules/v1/common";
import { ComposedProject } from "@/types";
-import { projectV1Slug } from "@/utils";
const props = defineProps<{
project: ComposedProject;
@@ -104,9 +104,8 @@ const activeBranches = computed(() => {
const handleCreateBranch = () => {
router.push({
- name: "workspace.project.branch.detail",
+ name: PROJECT_V1_BRANCHE_DETAIL,
params: {
- projectSlug: projectV1Slug(props.project),
branchName: "new",
},
});
diff --git a/frontend/src/components/ProjectWebhookCard.vue b/frontend/src/components/ProjectWebhookCard.vue
index 58567adb28..34dd701854 100644
--- a/frontend/src/components/ProjectWebhookCard.vue
+++ b/frontend/src/components/ProjectWebhookCard.vue
@@ -58,6 +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 { projectWebhookV1ActivityItemList } from "@/types";
import {
Webhook,
@@ -76,7 +77,7 @@ const router = useRouter();
const viewProjectWebhook = () => {
router.push({
- name: "workspace.project.hook.detail",
+ name: PROJECT_V1_WEBHOOK_DETAIL,
params: {
projectWebhookSlug: projectWebhookV1Slug(props.projectWebhook),
},
diff --git a/frontend/src/components/ProjectWebhookForm.vue b/frontend/src/components/ProjectWebhookForm.vue
index 4839309396..5352c7c8ab 100644
--- a/frontend/src/components/ProjectWebhookForm.vue
+++ b/frontend/src/components/ProjectWebhookForm.vue
@@ -288,6 +288,10 @@ import { NCheckbox, NRadio, NRadioGroup } from "naive-ui";
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,
+} from "@/router/dashboard/projectV1";
import {
pushNotification,
useProjectWebhookV1Store,
@@ -303,7 +307,7 @@ import {
Webhook,
Webhook_Type,
} from "@/types/proto/v1/project_service";
-import { projectV1Slug, projectWebhookV1Slug } from "../utils";
+import { projectWebhookV1Slug } from "../utils";
interface LocalState {
webhook: Webhook;
@@ -416,11 +420,7 @@ const toggleEvent = (type: Activity_Type, on: boolean) => {
const cancel = () => {
router.push({
- name: "workspace.project.detail",
- params: {
- projectSlug: projectV1Slug(props.project),
- },
- hash: "#webhook",
+ name: PROJECT_V1_WEBHOOKS,
});
};
@@ -448,7 +448,7 @@ const createWebhook = () => {
});
if (createdWebhook) {
router.push({
- name: "workspace.project.hook.detail",
+ name: PROJECT_V1_WEBHOOK_DETAIL,
params: {
projectWebhookSlug: projectWebhookV1Slug(createdWebhook),
},
diff --git a/frontend/src/components/ProjectWebhookPanel.vue b/frontend/src/components/ProjectWebhookPanel.vue
index fbcfc2d671..4de87fb955 100644
--- a/frontend/src/components/ProjectWebhookPanel.vue
+++ b/frontend/src/components/ProjectWebhookPanel.vue
@@ -34,6 +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 } from "@/types/proto/v1/project_service";
import ProjectWebhookCard from "./ProjectWebhookCard.vue";
@@ -55,7 +56,7 @@ const projectWebhookList = computed(() => {
const addProjectWebhook = () => {
router.push({
- name: "workspace.project.hook.create",
+ name: PROJECT_V1_WEBHOOK_CREATE,
});
};
</script>
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index d22d6af85f..37013e7904 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -35,27 +35,27 @@
/>
<CreateDatabasePrepPanel
v-if="state.quickActionType === 'quickaction.bb.database.create'"
- :project-id="projectId"
+ :project-id="project?.uid"
@dismiss="state.quickActionType = undefined"
/>
<AlterSchemaPrepForm
v-if="state.quickActionType === 'quickaction.bb.database.schema.update'"
- :project-id="projectId"
+ :project-id="project?.uid"
:type="'bb.issue.database.schema.update'"
@dismiss="state.quickActionType = undefined"
/>
<AlterSchemaPrepForm
v-if="state.quickActionType === 'quickaction.bb.database.data.update'"
- :project-id="projectId"
+ :project-id="project?.uid"
:type="'bb.issue.database.data.update'"
@dismiss="state.quickActionType = undefined"
/>
<TransferDatabaseForm
v-if="
- projectId &&
+ project &&
state.quickActionType === 'quickaction.bb.project.database.transfer'
"
- :project-id="projectId"
+ :project-id="project.uid"
@dismiss="state.quickActionType = undefined"
/>
</Drawer>
@@ -111,7 +111,7 @@ import {
import { NButton, NEllipsis } from "naive-ui";
import { reactive, PropType, computed, watch, VNode, h } from "vue";
import { useI18n } from "vue-i18n";
-import { useRoute, useRouter } from "vue-router";
+import { useRoute } from "vue-router";
import AlterSchemaPrepForm from "@/components/AlterSchemaPrepForm/";
import { CreateDatabasePrepPanel } from "@/components/CreateDatabasePrepForm";
import InstanceForm from "@/components/InstanceForm/";
@@ -120,6 +120,7 @@ import RequestQueryPanel from "@/components/Issue/panel/RequestQueryPanel/index.
import ProjectCreatePanel from "@/components/Project/ProjectCreatePanel.vue";
import TransferDatabaseForm from "@/components/TransferDatabaseForm.vue";
import { Drawer } from "@/components/v2";
+import { PROJECT_V1_ROUTE } from "@/router/dashboard/projectV1";
import {
useInstanceV1Store,
useCommandStore,
@@ -128,12 +129,12 @@ import {
useSubscriptionV1Store,
useProjectV1Store,
} from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import {
QuickActionType,
DatabaseGroupQuickActionType,
FeatureType,
} from "@/types";
-import { idFromSlug } from "@/utils";
interface LocalState {
feature?: FeatureType;
@@ -158,7 +159,6 @@ const props = defineProps({
});
const { t } = useI18n();
-const router = useRouter();
const route = useRoute();
const commandStore = useCommandStore();
const subscriptionStore = useSubscriptionV1Store();
@@ -175,9 +175,8 @@ const state = reactive<LocalState>({
});
const projectId = computed((): string | undefined => {
- if (router.currentRoute.value.name == "workspace.project.detail") {
- const parts = router.currentRoute.value.path.split("/");
- return String(idFromSlug(parts[parts.length - 1]));
+ if (route.name?.toString().startsWith(PROJECT_V1_ROUTE)) {
+ return route.params.projectId as string;
}
return undefined;
});
@@ -186,7 +185,9 @@ const project = computed(() => {
if (!projectId.value) {
return;
}
- return projectStore.getProjectByUID(projectId.value);
+ return projectStore.getProjectByName(
+ `${projectNamePrefix}${projectId.value}`
+ );
});
// Only show alter schema and change data if the user has permission to alter schema of at least one project.
diff --git a/frontend/src/components/RepositorySetupWizard.vue b/frontend/src/components/RepositorySetupWizard.vue
index f6af466ac2..45ef7ab27f 100644
--- a/frontend/src/components/RepositorySetupWizard.vue
+++ b/frontend/src/components/RepositorySetupWizard.vue
@@ -136,6 +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 { useRepositoryV1Store, hasFeature, useProjectV1Store } from "@/store";
import { getVCSUid } from "@/store/modules/v1/common";
import {
@@ -150,7 +151,6 @@ import {
SchemaChange,
} from "@/types/proto/v1/project_service";
import { ExternalRepositoryInfo, ProjectRepositoryConfig } from "../types";
-import { projectSlugV1 } from "../utils";
// Default file path template is to organize migration files from different environments under separate directories.
const DEFAULT_FILE_PATH_TEMPLATE =
@@ -373,11 +373,7 @@ const closeSetupSQLReviewModal = () => {
const cancel = () => {
emit("cancel");
router.push({
- name: "workspace.project.detail",
- params: {
- projectSlug: projectSlugV1(props.project),
- },
- hash: "#gitops",
+ name: PROJECT_V1_GITOPS,
});
};
diff --git a/frontend/src/components/RepositoryTable.vue b/frontend/src/components/RepositoryTable.vue
index 9c089a4002..d032ef0a52 100644
--- a/frontend/src/components/RepositoryTable.vue
+++ b/frontend/src/components/RepositoryTable.vue
@@ -23,7 +23,7 @@ import { computed, PropType } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { ComposedRepository } from "@/types";
-import { projectSlugV1, projectV1Name } from "../utils";
+import { projectV1Name } from "../utils";
const props = defineProps({
repositoryList: {
@@ -46,6 +46,6 @@ const columnList = computed(() => [
const clickRepository = function (_: number, row: number) {
const repository = props.repositoryList[row];
- router.push(`/project/${projectSlugV1(repository.project)}#gitops`);
+ router.push(`/${repository.project.name}/gitops`);
};
</script>
diff --git a/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue b/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue
index 94cbc85321..36be0e6b42 100644
--- a/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue
+++ b/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vue
@@ -14,7 +14,7 @@
<span>{{ $t("common.project") }} - </span>
<a
class="normal-link inline-flex items-center"
- :href="`/project/${projectV1Slug(project)}`"
+ :href="`/${project.name}`"
>{{ project.title }}</a
>
</div>
@@ -56,7 +56,7 @@
<span>{{ $t("common.project") }} - </span>
<a
class="normal-link inline-flex items-center"
- :href="`/project/${projectV1Slug(project)}`"
+ :href="`/${project.name}`"
>{{ project.title }}</a
>
</div>
@@ -243,12 +243,7 @@ import {
import { ComposedDatabase, UNKNOWN_ID } from "@/types";
import { Engine } from "@/types/proto/v1/common";
import { ChangeHistory } from "@/types/proto/v1/database_service";
-import {
- changeHistoryLink,
- databaseV1Slug,
- projectV1Slug,
- toClipboard,
-} from "@/utils";
+import { changeHistoryLink, databaseV1Slug, toClipboard } from "@/utils";
import DiffViewPanel from "./DiffViewPanel.vue";
import RawSQLEditorPanel from "./RawSQLEditorPanel.vue";
import TargetDatabasesSelectPanel from "./TargetDatabasesSelectPanel.vue";
diff --git a/frontend/src/components/v2/Model/DatabaseGroupName.vue b/frontend/src/components/v2/Model/DatabaseGroupName.vue
index 37c610809c..9db68a311c 100644
--- a/frontend/src/components/v2/Model/DatabaseGroupName.vue
+++ b/frontend/src/components/v2/Model/DatabaseGroupName.vue
@@ -12,7 +12,6 @@
<script lang="ts" setup>
import { computed } from "vue";
import type { ComposedDatabaseGroup } from "@/types";
-import { projectV1Slug } from "@/utils";
const props = withDefaults(
defineProps<{
@@ -33,9 +32,7 @@ const bindings = computed(() => {
return {};
}
- const route = `/project/${projectV1Slug(
- props.databaseGroup.project
- )}/database-groups/${props.databaseGroup.databaseGroupName}`;
+ const route = `/${props.databaseGroup.project.name}/database-groups/${props.databaseGroup.databaseGroupName}`;
if (props.link) {
return {
to: route,
diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
index 7fb7d977ff..4c10cc73f6 100644
--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue
@@ -157,7 +157,6 @@ import {
import { getScrollParent } from "@/utils";
import {
databaseV1Slug,
- projectV1Slug,
isDatabaseV1Queryable,
isPITRDatabaseV1,
VueClass,
@@ -492,9 +491,9 @@ const clickDatabase = (
database.name
);
router.push(
- `/project/${projectV1Slug(
- (database as ComposedDatabaseGroup).project
- )}/database-groups/${databaseGroupName}`
+ `/${
+ (database as ComposedDatabaseGroup).project.name
+ }/database-groups/${databaseGroupName}`
);
}
}
diff --git a/frontend/src/components/v2/Model/ProjectName.vue b/frontend/src/components/v2/Model/ProjectName.vue
index affeb2b5b3..6a89fc68c8 100644
--- a/frontend/src/components/v2/Model/ProjectName.vue
+++ b/frontend/src/components/v2/Model/ProjectName.vue
@@ -12,7 +12,7 @@
<script lang="ts" setup>
import { computed } from "vue";
import type { Project } from "@/types";
-import { projectName, projectSlug } from "@/utils";
+import { projectName } from "@/utils";
const props = withDefaults(
defineProps<{
@@ -29,7 +29,7 @@ const props = withDefaults(
const bindings = computed(() => {
if (props.link) {
return {
- to: `/project/${projectSlug(props.project)}`,
+ to: `/${props.project.name}`,
activeClass: "",
exactActiveClass: "",
onClick: (e: MouseEvent) => {
diff --git a/frontend/src/components/v2/Model/ProjectV1Name.vue b/frontend/src/components/v2/Model/ProjectV1Name.vue
index 219d8826fa..58e7bb8b4b 100644
--- a/frontend/src/components/v2/Model/ProjectV1Name.vue
+++ b/frontend/src/components/v2/Model/ProjectV1Name.vue
@@ -15,7 +15,7 @@
import { NPerformantEllipsis } from "naive-ui";
import { computed } from "vue";
import type { Project } from "@/types/proto/v1/project_service";
-import { projectV1Name, projectV1Slug } from "@/utils";
+import { projectV1Name } from "@/utils";
const props = withDefaults(
defineProps<{
@@ -36,7 +36,7 @@ const props = withDefaults(
const bindings = computed(() => {
if (props.link) {
return {
- to: `/project/${projectV1Slug(props.project)}${props.hash}`,
+ to: `/${props.project.name}`,
activeClass: "",
exactActiveClass: "",
onClick: (e: MouseEvent) => {
diff --git a/frontend/src/components/v2/Model/ProjectV1Table.vue b/frontend/src/components/v2/Model/ProjectV1Table.vue
index 6bd8c08111..ba56cfd989 100644
--- a/frontend/src/components/v2/Model/ProjectV1Table.vue
+++ b/frontend/src/components/v2/Model/ProjectV1Table.vue
@@ -35,8 +35,12 @@ import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBGridColumn, BBGridRow, BBGrid } from "@/bbkit";
+import {
+ PROJECT_V1_DETAIL,
+ PROJECT_V1_ROUTE,
+} from "@/router/dashboard/projectV1";
+import { getProjectName } from "@/store/modules/v1/common";
import { Project } from "@/types/proto/v1/project_service";
-import { projectV1Slug } from "@/utils";
export type ProjectGridRow = BBGridRow<Project>;
@@ -77,13 +81,22 @@ const clickProject = function (
row: number,
e: MouseEvent
) {
- const url = `/project/${projectV1Slug(project)}${
- router.currentRoute.value.hash
- }`;
+ let routeName = PROJECT_V1_DETAIL;
+ if (router.currentRoute.value.name?.toString().startsWith(PROJECT_V1_ROUTE)) {
+ routeName = router.currentRoute.value.name?.toString();
+ }
+
+ const route = router.resolve({
+ name: routeName,
+ params: {
+ projectId: getProjectName(project.name),
+ },
+ });
+
if (e.ctrlKey || e.metaKey) {
- window.open(url, "_blank");
+ window.open(route.fullPath, "_blank");
} else {
- window.location.href = url;
+ window.location.href = route.fullPath;
}
emit("click");
};
diff --git a/frontend/src/layouts/ProjectLayout.vue b/frontend/src/layouts/ProjectLayout.vue
deleted file mode 100644
index de14795ec6..0000000000
--- a/frontend/src/layouts/ProjectLayout.vue
+++ /dev/null
@@ -1,95 +0,0 @@
-<template>
- <ArchiveBanner v-if="project.state === State.DELETED" class="py-2" />
- <div class="px-4 pb-4 h-full overflow-auto">
- <HideInStandaloneMode>
- <template v-if="isDefaultProject">
- <h1 class="mb-4 text-xl font-bold leading-6 text-main truncate">
- {{ $t("database.unassigned-databases") }}
- </h1>
- </template>
- <BBAttention
- v-if="isDefaultProject"
- class="mb-4"
- type="info"
- :title="$t('project.overview.info-slot-content')"
- />
- </HideInStandaloneMode>
- <router-view
- :project-slug="projectSlug"
- :project-webhook-slug="projectWebhookSlug"
- :allow-edit="allowEdit"
- />
- </div>
-</template>
-
-<script lang="ts" setup>
-import { computed, watchEffect } from "vue";
-import ArchiveBanner from "@/components/ArchiveBanner.vue";
-import { useRecentProjects } from "@/components/Project/useRecentProjects";
-import HideInStandaloneMode from "@/components/misc/HideInStandaloneMode.vue";
-import { useCurrentUserV1, useProjectV1Store } from "@/store";
-import { DEFAULT_PROJECT_V1_NAME } from "@/types";
-import { State } from "@/types/proto/v1/common";
-import {
- idFromSlug,
- hasWorkspacePermissionV1,
- hasPermissionInProjectV1,
-} from "@/utils";
-
-const props = defineProps({
- projectSlug: {
- required: true,
- type: String,
- },
- projectWebhookSlug: {
- type: String,
- default: undefined,
- },
- branchName: {
- type: String,
- default: undefined,
- },
-});
-
-const currentUserV1 = useCurrentUserV1();
-const projectV1Store = useProjectV1Store();
-const recentProjects = useRecentProjects();
-
-const project = computed(() => {
- return projectV1Store.getProjectByUID(String(idFromSlug(props.projectSlug)));
-});
-
-watchEffect(() => {
- recentProjects.setRecentProject(project.value.name);
-});
-
-const isDefaultProject = computed((): boolean => {
- return project.value.name === DEFAULT_PROJECT_V1_NAME;
-});
-
-const allowEdit = computed(() => {
- if (project.value.state === State.DELETED) {
- return false;
- }
-
- if (
- hasWorkspacePermissionV1(
- "bb.permission.workspace.manage-project",
- currentUserV1.value.userRole
- )
- ) {
- return true;
- }
-
- if (
- hasPermissionInProjectV1(
- project.value.iamPolicy,
- currentUserV1.value,
- "bb.permission.project.manage-general"
- )
- ) {
- return true;
- }
- return false;
-});
-</script>
diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vue
index a1d47da981..f67ff16c82 100644
--- a/frontend/src/layouts/ProjectV1Layout.vue
+++ b/frontend/src/layouts/ProjectV1Layout.vue
@@ -1,6 +1,6 @@
<template>
<ArchiveBanner v-if="project.state === State.DELETED" class="py-2" />
- <div class="p-4 h-full overflow-auto">
+ <div class="px-4 pb-4 h-full overflow-auto">
<HideInStandaloneMode>
<template v-if="isDefaultProject">
<h1 class="mb-4 text-xl font-bold leading-6 text-main truncate">
@@ -14,19 +14,51 @@
:title="$t('project.overview.info-slot-content')"
/>
</HideInStandaloneMode>
+ <QuickActionPanel
+ v-if="showQuickActionPanel"
+ :quick-action-list="quickActionList"
+ class="mb-4"
+ />
<router-view :project-id="projectId" :allow-edit="allowEdit" />
</div>
</template>
<script lang="ts" setup>
+import { useLocalStorage } from "@vueuse/core";
+import { pull } from "lodash-es";
import { computed, onMounted } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRoute } from "vue-router";
import ArchiveBanner from "@/components/ArchiveBanner.vue";
import HideInStandaloneMode from "@/components/misc/HideInStandaloneMode.vue";
-import { useCurrentUserV1, useProjectV1Store } from "@/store";
+import {
+ PROJECT_V1_DATABASES,
+ PROJECT_V1_DATABASE_GROUPS,
+} from "@/router/dashboard/projectV1";
+import {
+ useProjectV1Store,
+ useCurrentUserV1,
+ useActivityV1Store,
+ hasFeature,
+ usePageMode,
+ pushNotification,
+} from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
-import { DEFAULT_PROJECT_V1_NAME } from "@/types";
+import {
+ DEFAULT_PROJECT_V1_NAME,
+ QuickActionType,
+ RoleType,
+ activityName,
+} from "@/types";
import { State } from "@/types/proto/v1/common";
-import { hasWorkspacePermissionV1, hasPermissionInProjectV1 } from "@/utils";
+import { LogEntity_Action } from "@/types/proto/v1/logging_service";
+import { TenantMode } from "@/types/proto/v1/project_service";
+import {
+ isOwnerOfProjectV1,
+ hasPermissionInProjectV1,
+ hasWorkspacePermissionV1,
+ getQuickActionList,
+} from "@/utils";
const props = defineProps({
projectId: {
@@ -35,8 +67,12 @@ const props = defineProps({
},
});
+const route = useRoute();
const currentUserV1 = useCurrentUserV1();
const projectV1Store = useProjectV1Store();
+const activityV1Store = useActivityV1Store();
+const pageMode = usePageMode();
+const { t } = useI18n();
const project = computed(() => {
return projectV1Store.getProjectByName(
@@ -74,9 +110,144 @@ const allowEdit = computed(() => {
return false;
});
+const cachedNotifiedActivities = useLocalStorage<string[]>(
+ `bb.project.${props.projectId}.activities`,
+ []
+);
+
+const maximumCachedActivities = 5;
+
onMounted(async () => {
await projectV1Store.getOrFetchProjectByName(
`${projectNamePrefix}${props.projectId}`
);
+
+ if (
+ !hasWorkspacePermissionV1(
+ "bb.permission.workspace.manage-issue",
+ currentUserV1.value.userRole
+ ) &&
+ !hasPermissionInProjectV1(
+ project.value.iamPolicy,
+ currentUserV1.value,
+ "bb.permission.project.change-database"
+ )
+ ) {
+ return;
+ }
+ activityV1Store
+ .fetchActivityList({
+ pageSize: 1,
+ order: "desc",
+ action: [LogEntity_Action.ACTION_PROJECT_REPOSITORY_PUSH],
+ resource: project.value.name,
+ })
+ .then((resp) => {
+ for (const activity of resp.logEntities) {
+ if (cachedNotifiedActivities.value.includes(activity.name)) {
+ continue;
+ }
+ cachedNotifiedActivities.value.push(activity.name);
+ if (cachedNotifiedActivities.value.length > maximumCachedActivities) {
+ cachedNotifiedActivities.value.shift();
+ }
+
+ pushNotification({
+ module: "bytebase",
+ style: "INFO",
+ title: activityName(activity.action),
+ manualHide: true,
+ link: `/${project.value.name}/activities`,
+ linkTitle: t("common.view"),
+ });
+ break;
+ }
+ });
+});
+
+const quickActionForDatabaseGroup = computed((): QuickActionType[] => {
+ if (project.value.tenantMode !== TenantMode.TENANT_MODE_ENABLED) {
+ return [];
+ }
+ return [
+ "quickaction.bb.database.schema.update",
+ "quickaction.bb.database.data.update",
+ "quickaction.bb.group.database-group.create",
+ "quickaction.bb.group.table-group.create",
+ ];
+});
+
+const quickActionMapByRole = computed(() => {
+ if (project.value.state === State.ACTIVE) {
+ const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
+ "quickaction.bb.database.create",
+ "quickaction.bb.project.database.transfer",
+ ];
+ const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [];
+
+ const currentUserV1 = useCurrentUserV1();
+ if (
+ project.value.name !== DEFAULT_PROJECT_V1_NAME &&
+ hasPermissionInProjectV1(
+ project.value.iamPolicy,
+ currentUserV1.value,
+ "bb.permission.project.change-database"
+ )
+ ) {
+ // Default project (Unassigned databases) are not allowed
+ // to be changed.
+ DEVELOPER_QUICK_ACTION_LIST.push("quickaction.bb.database.create");
+ }
+ if (
+ hasPermissionInProjectV1(
+ project.value.iamPolicy,
+ currentUserV1.value,
+ "bb.permission.project.transfer-database"
+ )
+ ) {
+ DEVELOPER_QUICK_ACTION_LIST.push(
+ "quickaction.bb.project.database.transfer"
+ );
+ }
+ if (!isOwnerOfProjectV1(project.value.iamPolicy, currentUserV1.value)) {
+ DEVELOPER_QUICK_ACTION_LIST.push(
+ "quickaction.bb.issue.grant.request.querier",
+ "quickaction.bb.issue.grant.request.exporter"
+ );
+ }
+
+ if (hasFeature("bb.feature.dba-workflow")) {
+ pull(DEVELOPER_QUICK_ACTION_LIST, "quickaction.bb.database.create");
+ }
+
+ return new Map([
+ ["OWNER", [...DBA_AND_OWNER_QUICK_ACTION_LIST]],
+ ["DBA", [...DBA_AND_OWNER_QUICK_ACTION_LIST]],
+ ["DEVELOPER", DEVELOPER_QUICK_ACTION_LIST],
+ ]) as Map<RoleType, QuickActionType[]>;
+ }
+
+ return new Map<RoleType, QuickActionType[]>();
+});
+
+const isDatabaseHash = computed(() => {
+ return (
+ route.name === PROJECT_V1_DATABASES ||
+ route.name === PROJECT_V1_DATABASE_GROUPS
+ );
+});
+
+const quickActionList = computed(() => {
+ if (!isDatabaseHash.value) {
+ return [];
+ }
+ if (route.name === PROJECT_V1_DATABASE_GROUPS) {
+ return quickActionForDatabaseGroup.value;
+ }
+ return getQuickActionList(quickActionMapByRole.value);
+});
+
+const showQuickActionPanel = computed(() => {
+ return pageMode.value === "BUNDLED" && quickActionList.value.length > 0;
});
</script>
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 3763070d8f..dfcaa758fc 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -38,7 +38,6 @@ import {
isDev,
isRelease,
projectName,
- projectSlug,
sizeToFit,
urlfy,
} from "./utils";
@@ -151,7 +150,6 @@ app.config.globalProperties.isEmpty = isEmpty;
app.config.globalProperties.environmentName = environmentName;
app.config.globalProperties.environmentSlug = environmentSlug;
app.config.globalProperties.projectName = projectName;
-app.config.globalProperties.projectSlug = projectSlug;
app.config.globalProperties.instanceName = instanceName;
app.config.globalProperties.instanceSlug = instanceSlug;
app.config.globalProperties.databaseSlug = databaseSlug;
diff --git a/frontend/src/router/dashboard/database.ts b/frontend/src/router/dashboard/database.ts
index 89679a1b2f..bbcebe8ca5 100644
--- a/frontend/src/router/dashboard/database.ts
+++ b/frontend/src/router/dashboard/database.ts
@@ -1,6 +1,6 @@
import { pull } from "lodash-es";
import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
-import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+import ProjectSidebarV1 from "@/components/Project/ProjectSidebarV1.vue";
import DatabaseLayout from "@/layouts/DatabaseLayout.vue";
import { t } from "@/plugins/i18n";
import { hasFeature, useDatabaseV1Store } from "@/store";
@@ -45,7 +45,7 @@ const databaseRoutes: RouteRecordRaw[] = [
path: "db/:databaseSlug",
components: {
content: DatabaseLayout,
- leftSidebar: ProjectSidebar,
+ leftSidebar: ProjectSidebarV1,
},
props: { content: true, leftSidebar: true },
children: [
diff --git a/frontend/src/router/dashboard/index.ts b/frontend/src/router/dashboard/index.ts
index 52f750980a..58eac65702 100644
--- a/frontend/src/router/dashboard/index.ts
+++ b/frontend/src/router/dashboard/index.ts
@@ -5,7 +5,6 @@ import databaseRoutes from "./database";
import environmentRoutes from "./environment";
import instanceRoutes from "./instance";
import issueRoutes from "./issue";
-import projectRoutes from "./project";
import projectV1Routes from "./projectV1";
import workspaceRoutes from "./workspace";
import workspaceSettingRoutes from "./workspaceSetting";
@@ -23,7 +22,6 @@ const dashboardRoutes: RouteRecordRaw[] = [
...workspaceSettingRoutes,
...environmentRoutes,
...instanceRoutes,
- ...projectRoutes,
...projectV1Routes,
...issueRoutes,
...databaseRoutes,
diff --git a/frontend/src/router/dashboard/instance.ts b/frontend/src/router/dashboard/instance.ts
index 942701c5b8..2c62a67d64 100644
--- a/frontend/src/router/dashboard/instance.ts
+++ b/frontend/src/router/dashboard/instance.ts
@@ -1,5 +1,5 @@
import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
-import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+import ProjectSidebarV1 from "@/components/Project/ProjectSidebarV1.vue";
import InstanceLayout from "@/layouts/InstanceLayout.vue";
import { t } from "@/plugins/i18n";
import { useChangeHistoryStore, useInstanceV1Store } from "@/store";
@@ -67,7 +67,7 @@ const instanceRoutes: RouteRecordRaw[] = [
},
components: {
content: () => import("@/views/ChangeHistoryDetail.vue"),
- leftSidebar: ProjectSidebar,
+ leftSidebar: ProjectSidebarV1,
},
props: { content: true, leftSidebar: true },
},
diff --git a/frontend/src/router/dashboard/issue.ts b/frontend/src/router/dashboard/issue.ts
index bf61a88f97..5dbb392c64 100644
--- a/frontend/src/router/dashboard/issue.ts
+++ b/frontend/src/router/dashboard/issue.ts
@@ -1,5 +1,5 @@
import { RouteRecordRaw } from "vue-router";
-import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+import ProjectSidebarV1 from "@/components/Project/ProjectSidebarV1.vue";
import { t } from "@/plugins/i18n";
import DashboardSidebar from "@/views/DashboardSidebar.vue";
@@ -24,7 +24,7 @@ const issueRoutes: RouteRecordRaw[] = [
},
components: {
content: () => import("@/views/IssueDetailV1.vue"),
- leftSidebar: ProjectSidebar,
+ leftSidebar: ProjectSidebarV1,
},
props: { content: true, leftSidebar: true },
},
diff --git a/frontend/src/router/dashboard/project.ts b/frontend/src/router/dashboard/project.ts
deleted file mode 100644
index 543cf0972c..0000000000
--- a/frontend/src/router/dashboard/project.ts
+++ /dev/null
@@ -1,149 +0,0 @@
-import { RouteLocationNormalized, RouteRecordRaw } from "vue-router";
-import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
-import { t } from "@/plugins/i18n";
-import { useProjectV1Store, useProjectWebhookV1Store } from "@/store";
-import { DEFAULT_PROJECT_ID } from "@/types";
-import { idFromSlug } from "@/utils";
-import DashboardSidebar from "@/views/DashboardSidebar.vue";
-
-const projectRoutes: RouteRecordRaw[] = [
- {
- path: "project",
- name: "workspace.project",
- meta: {
- title: () => t("common.projects"),
- quickActionListByRole: () => {
- return new Map([
- ["OWNER", ["quickaction.bb.project.create"]],
- ["DBA", ["quickaction.bb.project.create"]],
- ["DEVELOPER", ["quickaction.bb.project.create"]],
- ]);
- },
- },
- components: {
- content: () => import("@/views/ProjectDashboard.vue"),
- leftSidebar: DashboardSidebar,
- },
- props: { content: true, leftSidebar: true },
- },
- {
- path: "project/:projectSlug",
- components: {
- content: () => import("@/layouts/ProjectLayout.vue"),
- leftSidebar: ProjectSidebar,
- },
- props: { content: true, leftSidebar: true },
- children: [
- {
- path: "",
- name: "workspace.project.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const slug = route.params.projectSlug as string;
- const projectId = idFromSlug(slug);
- if (projectId === DEFAULT_PROJECT_ID) {
- return t("database.unassigned-databases");
- }
- const projectV1 = useProjectV1Store().getProjectByUID(
- String(projectId)
- );
- return projectV1.title;
- },
- },
- component: () => import("@/views/ProjectDetail.vue"),
- props: true,
- },
- {
- path: "webhook/new",
- name: "workspace.project.hook.create",
- meta: {
- title: () => t("project.webhook.create-webhook"),
- },
- component: () => import("@/views/ProjectWebhookCreate.vue"),
- props: true,
- },
- {
- path: "webhook/:projectWebhookSlug",
- name: "workspace.project.hook.detail",
- meta: {
- title: (route: RouteLocationNormalized) => {
- const projectSlug = route.params.projectSlug as string;
- const projectWebhookSlug = route.params
- .projectWebhookSlug as string;
- const project = useProjectV1Store().getProjectByUID(
- String(idFromSlug(projectSlug))
- );
- const webhook =
- useProjectWebhookV1Store().getProjectWebhookFromProjectById(
- project,
- idFromSlug(projectWebhookSlug)
- );
-
- return `${t("common.webhook")} - ${webhook?.title ?? "unknown"}`;
- },
- },
- component: () => import("@/views/ProjectWebhookDetail.vue"),
- props: true,
- },
- {
- path: "branches/:branchName",
- name: "workspace.project.branch.detail",
- meta: {
- overrideTitle: true,
- },
- component: () => import("@/views/branch/BranchDetail.vue"),
- props: true,
- },
- {
- path: "branches/:branchName/rollout",
- name: "workspace.project.branch.rollout",
- meta: {
- overrideTitle: true,
- },
- component: () => import("@/views/branch/BranchRollout.vue"),
- props: true,
- },
- {
- path: "branches/:branchName/merge",
- name: "workspace.project.branch.merge",
- meta: {
- title: () => t("branch.merge-rebase.merge-branch"),
- },
- component: () => import("@/views/branch/BranchMerge.vue"),
- props: true,
- },
- {
- path: "branches/:branchName/rebase",
- name: "workspace.project.branch.rebase",
- meta: {
- title: () => t("branch.merge-rebase.rebase-branch"),
- },
- component: () => import("@/views/branch/BranchRebase.vue"),
- props: true,
- },
- {
- path: "changelists/:changelistName",
- name: "workspace.project.changelist.detail",
- meta: {
- overrideTitle: true,
- },
- component: () => import("@/components/Changelist/ChangelistDetail/"),
- props: true,
- },
- {
- path: "database-groups/:databaseGroupName",
- name: "workspace.project.database-group.detail",
- component: () => import("@/views/DatabaseGroupDetail.vue"),
- props: true,
- },
- {
- path: "database-groups/:databaseGroupName/table-groups/:schemaGroupName",
- name: "workspace.project.database-group.table-group.detail",
- component: () => import("@/views/SchemaGroupDetail.vue"),
- props: true,
- },
- ],
- },
-];
-
-export default projectRoutes;
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index a03f545604..5afbe5308c 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -1,33 +1,313 @@
import { RouteRecordRaw } from "vue-router";
-import ProjectSidebar from "@/components/Project/ProjectSidebar.vue";
+import ProjectSidebarV1 from "@/components/Project/ProjectSidebarV1.vue";
+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`;
const projectV1Routes: RouteRecordRaw[] = [
+ {
+ path: "project",
+ name: "workspace.project",
+ meta: {
+ title: () => t("common.projects"),
+ quickActionListByRole: () => {
+ return new Map([
+ ["OWNER", ["quickaction.bb.project.create"]],
+ ["DBA", ["quickaction.bb.project.create"]],
+ ["DEVELOPER", ["quickaction.bb.project.create"]],
+ ]);
+ },
+ },
+ components: {
+ content: () => import("@/views/ProjectDashboard.vue"),
+ leftSidebar: DashboardSidebar,
+ },
+ props: { content: true, leftSidebar: true },
+ },
{
path: "projects/:projectId",
components: {
content: () => import("@/layouts/ProjectV1Layout.vue"),
- leftSidebar: ProjectSidebar,
+ leftSidebar: ProjectSidebarV1,
},
props: { content: true, leftSidebar: true },
children: [
+ {
+ path: "",
+ name: PROJECT_V1_DETAIL,
+ redirect: { name: PROJECT_V1_DATABASES },
+ },
{
path: "databases",
- name: "workspace.project.database.dashboard",
+ name: PROJECT_V1_DATABASES,
meta: {
overrideTitle: true,
},
component: () => import("@/views/project/ProjectDatabaseDashboard.vue"),
props: true,
},
+ {
+ path: "database-groups",
+ meta: {
+ overrideTitle: true,
+ },
+ props: true,
+ children: [
+ {
+ path: "",
+ name: PROJECT_V1_DATABASE_GROUPS,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/views/project/ProjectDatabaseGroupDashboard.vue"),
+ props: true,
+ },
+ {
+ path: ":databaseGroupName",
+ name: PROJECT_V1_DATABASE_GROUP_DETAIL,
+ component: () => import("@/views/DatabaseGroupDetail.vue"),
+ props: true,
+ },
+ {
+ path: ":databaseGroupName/table-groups/:schemaGroupName",
+ name: PROJECT_V1_DATABASE_GROUP_TABLE_GROUP_DETAIL,
+ component: () => import("@/views/SchemaGroupDetail.vue"),
+ props: true,
+ },
+ ],
+ },
+ {
+ path: "branches",
+ meta: {
+ overrideTitle: true,
+ },
+ props: true,
+ children: [
+ {
+ path: "",
+ name: PROJECT_V1_BRANCHES,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/views/project/ProjectBrancheDashboard.vue"),
+ props: true,
+ },
+ {
+ path: ":branchName",
+ name: PROJECT_V1_BRANCHE_DETAIL,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/branch/BranchDetail.vue"),
+ props: true,
+ },
+ {
+ path: ":branchName/rollout",
+ name: PROJECT_V1_BRANCHE_ROLLOUT,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/branch/BranchRollout.vue"),
+ props: true,
+ },
+ {
+ path: ":branchName/merge",
+ name: PROJECT_V1_BRANCHE_MERGE,
+ meta: {
+ title: () => t("branch.merge-rebase.merge-branch"),
+ },
+ component: () => import("@/views/branch/BranchMerge.vue"),
+ props: true,
+ },
+ {
+ path: ":branchName/rebase",
+ name: PROJECT_V1_BRANCHE_REBASE,
+ meta: {
+ title: () => t("branch.merge-rebase.rebase-branch"),
+ },
+ component: () => import("@/views/branch/BranchRebase.vue"),
+ props: true,
+ },
+ ],
+ },
{
path: "issues",
- name: "workspace.project.issue.dashboard",
+ name: PROJECT_V1_ISSUES,
meta: {
overrideTitle: true,
},
component: () => import("@/views/project/ProjectIssueDashboard.vue"),
props: true,
},
+ {
+ path: "change-histories",
+ name: PROJECT_V1_CHANGE_HISTORIES,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/views/project/ProjectChangeHistoryDashboard.vue"),
+ props: true,
+ },
+ {
+ path: "changelists",
+ meta: {
+ overrideTitle: true,
+ },
+ props: true,
+ children: [
+ {
+ path: "",
+ name: PROJECT_V1_CHANGELISTS,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/views/project/ProjectChangelistDashboard.vue"),
+ props: true,
+ },
+ {
+ path: ":changelistName",
+ name: PROJECT_V1_CHANGELIST_DETAIL,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/components/Changelist/ChangelistDetail/"),
+ props: true,
+ },
+ ],
+ },
+ {
+ path: "sync-schema",
+ name: PROJECT_V1_SYNC_SCHEMA,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/project/ProjectSyncDatabasePanel.vue"),
+ props: true,
+ },
+ {
+ path: "slow-queries",
+ name: PROJECT_V1_SLOW_QUERIES,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/views/project/ProjectSlowQueryDashboard.vue"),
+ props: true,
+ },
+ {
+ path: "anomalies",
+ name: PROJECT_V1_ANOMALIES,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/views/project/ProjectAnomalyCenterDashboard.vue"),
+ props: true,
+ },
+ {
+ path: "activities",
+ name: PROJECT_V1_ACTIVITIES,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/project/ProjectActivityDashboard.vue"),
+ props: true,
+ },
+ {
+ path: "gitops",
+ name: PROJECT_V1_GITOPS,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/views/project/ProjectVersionControlPanel.vue"),
+ props: true,
+ },
+ {
+ path: "webhooks",
+ meta: {
+ overrideTitle: true,
+ },
+ props: true,
+ children: [
+ {
+ path: "",
+ name: PROJECT_V1_WEBHOOKS,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () =>
+ import("@/views/project/ProjectWebhookDashboard.vue"),
+ props: true,
+ },
+ {
+ path: "new",
+ name: PROJECT_V1_WEBHOOK_CREATE,
+ meta: {
+ title: () => t("project.webhook.create-webhook"),
+ },
+ component: () => import("@/views/project/ProjectWebhookCreate.vue"),
+ props: true,
+ },
+ {
+ path: ":projectWebhookSlug",
+ name: PROJECT_V1_WEBHOOK_DETAIL,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/project/ProjectWebhookDetail.vue"),
+ props: true,
+ },
+ ],
+ },
+ {
+ path: "members",
+ name: PROJECT_V1_MEMBERS,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/project/ProjectMemberDashboard.vue"),
+ props: true,
+ },
+ {
+ path: "settings",
+ name: PROJECT_V1_SETTINGS,
+ meta: {
+ overrideTitle: true,
+ },
+ component: () => import("@/views/project/ProjectSettingPanel.vue"),
+ props: true,
+ },
],
},
];
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 114e221d35..47bd872399 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -14,14 +14,11 @@ import {
useTabStore,
useIdentityProviderStore,
useUserStore,
- useProjectV1Store,
- useProjectWebhookV1Store,
useEnvironmentV1Store,
useCurrentUserV1,
useInstanceV1Store,
useDatabaseV1Store,
useChangeHistoryStore,
- useChangelistStore,
usePageMode,
} from "@/store";
import { UNKNOWN_ID } from "@/types";
@@ -41,6 +38,7 @@ import authRoutes, {
AUTH_SIGNUP_MODULE,
} from "./auth";
import dashboardRoutes from "./dashboard";
+import { PROJECT_V1_ROUTE } from "./dashboard/projectV1";
import { WORKSPACE_HOME_MODULE } from "./dashboard/workspace";
import sqlEditorRoutes, { SQL_EDITOR_HOME_MODULE } from "./sqlEditor";
@@ -84,8 +82,6 @@ router.beforeEach((to, from, next) => {
const authStore = useAuthStore();
const dbSchemaStore = useDBSchemaV1Store();
const routerStore = useRouterStore();
- const projectV1Store = useProjectV1Store();
- const projectWebhookV1Store = useProjectWebhookV1Store();
const isLoggedIn = authStore.isLoggedIn();
@@ -246,11 +242,7 @@ router.beforeEach((to, from, next) => {
return;
}
- if (
- to.name === "workspace.project.detailV1" ||
- to.name === "workspace.project.database.dashboard" ||
- to.name === "workspace.project.issue.dashboard"
- ) {
+ if (to.name?.toString().startsWith(PROJECT_V1_ROUTE)) {
next();
return;
}
@@ -287,8 +279,6 @@ router.beforeEach((to, from, next) => {
const routerSlug = routerStore.routeSlug(to);
const principalEmail = routerSlug.principalEmail;
const environmentSlug = routerSlug.environmentSlug;
- const projectSlug = routerSlug.projectSlug;
- const projectWebhookSlug = routerSlug.projectWebhookSlug;
const issueSlug = routerSlug.issueSlug;
const instanceSlug = routerSlug.instanceSlug;
const databaseSlug = routerSlug.databaseSlug;
@@ -336,87 +326,6 @@ router.beforeEach((to, from, next) => {
return;
}
- if (projectSlug && projectSlug !== "-") {
- projectV1Store
- .fetchProjectByUID(String(idFromSlug(projectSlug)))
- .then((project) => {
- if (projectWebhookSlug) {
- const webhook =
- projectWebhookV1Store.getProjectWebhookFromProjectById(
- project,
- idFromSlug(projectWebhookSlug)
- );
- if (webhook) {
- next();
- } else {
- next({
- name: "error.404",
- replace: false,
- });
- throw new Error("not found");
- }
- } else if (to.name === "workspace.project.changelist.detail") {
- const name = `${project.name}/changelists/${to.params.changelistName}`;
- useChangelistStore()
- .fetchChangelistByName(name)
- .then((changelist) => {
- if (changelist) {
- next();
- } else {
- next({
- name: "error.404",
- replace: false,
- });
- return;
- }
- })
- .catch((error) => {
- next({
- name: "error.404",
- replace: false,
- });
- throw error;
- });
- } else if (
- to.name === "workspace.project.branch.detail" &&
- to.params.branchName !== "new"
- ) {
- next();
- // const name = `${project.name}/branches/${to.params.branchName}`;
- // useBranchStore()
- // .fetchBranchByName(name, false /* !useCache */)
- // .then((branch) => {
- // if (branch) {
- // next();
- // } else {
- // next({
- // name: "error.404",
- // replace: false,
- // });
- // throw new Error("not found");
- // }
- // })
- // .catch((error) => {
- // next({
- // name: "error.404",
- // replace: false,
- // });
- // throw error;
- // });
- } else {
- next();
- }
- })
- .catch((error) => {
- next({
- name: "error.404",
- replace: false,
- });
- throw error;
- });
- return;
- }
-
if (issueSlug) {
// We've moved the preparation data fetch jobs into IssueDetail page
// so just next() here.
@@ -424,13 +333,6 @@ router.beforeEach((to, from, next) => {
return;
}
- if (to.name === "workspace.project.branch.detail") {
- if (to.params.branchName === "new") {
- next();
- return;
- }
- }
-
if (databaseSlug) {
if (databaseSlug.toLowerCase() == "grant") {
next();
diff --git a/frontend/src/shims-vue-globals.d.ts b/frontend/src/shims-vue-globals.d.ts
index 3614e8fc8d..6798d25860 100644
--- a/frontend/src/shims-vue-globals.d.ts
+++ b/frontend/src/shims-vue-globals.d.ts
@@ -11,7 +11,6 @@ import type {
instanceName,
instanceSlug,
projectName,
- projectSlug,
sizeToFit,
urlfy,
} from "./utils";
@@ -33,7 +32,6 @@ declare module "vue" {
environmentName: typeof environmentName;
environmentSlug: typeof environmentSlug;
projectName: typeof projectName;
- projectSlug: typeof projectSlug;
instanceName: typeof instanceName;
instanceSlug: typeof instanceSlug;
databaseSlug: typeof databaseSlug;
diff --git a/frontend/src/store/modules/router.ts b/frontend/src/store/modules/router.ts
index 4912b1035d..7488ac2476 100644
--- a/frontend/src/store/modules/router.ts
+++ b/frontend/src/store/modules/router.ts
@@ -44,14 +44,14 @@ export const useRouterStore = defineStore("router", {
}
{
- // /project/:projectSlug/webhook/:hookSlug
+ // /projects/:projectId/webhook/:hookSlug
// Total 3 elements, 2nd element is the project slug, 3rd element is the project webhook slug
const projectComponents = currentRoute.path.match(
- "/project/([0-9a-zA-Z_-]+)/webhook/([0-9a-zA-Z_-]+)"
+ "/projects/([0-9a-zA-Z_-]+)/webhook/([0-9a-zA-Z_-]+)"
) || ["/", undefined, undefined];
if (projectComponents[1] && projectComponents[2]) {
return {
- projectSlug: projectComponents[1],
+ projectId: projectComponents[1],
projectWebhookSlug:
projectComponents[2].toLowerCase() == "new"
? undefined
@@ -61,28 +61,28 @@ export const useRouterStore = defineStore("router", {
}
{
- // /project/:projectSlug/changelists/:changelistName
+ // /projects/:projectId/changelists/:changelistName
// Total 3 elements, 2nd element is the project slug, 3rd element is the project changelist name.
const projectComponents = currentRoute.path.match(
- "/project/([0-9a-zA-Z_-]+)/changelists/([0-9a-zA-Z_-]+)"
+ "/projects/([0-9a-zA-Z_-]+)/changelists/([0-9a-zA-Z_-]+)"
) || ["/", undefined];
if (projectComponents.length === 3) {
return {
- projectSlug: projectComponents[1],
+ projectId: projectComponents[1],
changelistName: projectComponents[2],
};
}
}
{
- // /project/:projectSlug/branches/:branchName
+ // /projects/:projectId/branches/:branchName
// Total 3 elements, 2nd element is the project slug, 3rd element is the project changelist name.
const projectComponents = currentRoute.path.match(
- "/project/([0-9a-zA-Z_-]+)/branches/([0-9a-zA-Z_-]+)"
+ "/projects/([0-9a-zA-Z_-]+)/branches/([0-9a-zA-Z_-]+)"
) || ["/", undefined];
if (projectComponents.length === 3) {
return {
- projectSlug: projectComponents[1],
+ projectId: projectComponents[1],
branchName: projectComponents[2],
};
}
@@ -209,14 +209,14 @@ export const useRouterStore = defineStore("router", {
}
{
- // /project/proj-nt-iq3z/database-groups/test/table-groups/asd123
+ // /projects/proj-nt-iq3z/database-groups/test/table-groups/asd123
const schemaGroupDetailComponents = currentRoute.path.match(
- "/project/([0-9a-zA-Z_-]+)/database-groups/([0-9a-zA-Z_-]+)/table-groups/([0-9a-zA-Z_-]+)"
+ "/projects/([0-9a-zA-Z_-]+)/database-groups/([0-9a-zA-Z_-]+)/table-groups/([0-9a-zA-Z_-]+)"
) || ["/", undefined];
if (schemaGroupDetailComponents.length === 4) {
return {
- projectSlug: schemaGroupDetailComponents[1],
+ projectId: schemaGroupDetailComponents[1],
databaseGroupName: schemaGroupDetailComponents[2],
schemaGroupName: schemaGroupDetailComponents[3],
};
@@ -224,28 +224,28 @@ export const useRouterStore = defineStore("router", {
}
{
- // /project/proj-nt-iq3z/database-groups/test
+ // /projects/proj-nt-iq3z/database-groups/test
const schemaGroupDetailComponents = currentRoute.path.match(
- "/project/([0-9a-zA-Z_-]+)/database-groups/([0-9a-zA-Z_-]+)"
+ "/projects/([0-9a-zA-Z_-]+)/database-groups/([0-9a-zA-Z_-]+)"
) || ["/", undefined];
if (schemaGroupDetailComponents.length === 3) {
return {
- projectSlug: schemaGroupDetailComponents[1],
+ projectId: schemaGroupDetailComponents[1],
databaseGroupName: schemaGroupDetailComponents[2],
};
}
}
{
- // /project/:projectSlug
+ // /projects/:projectId
// Total 2 elements, 2nd element is the project slug
const projectComponents = currentRoute.path.match(
- "/project/([0-9a-zA-Z_-]+)"
+ "/projects/([0-9a-zA-Z_-]+)"
) || ["/", undefined];
if (projectComponents[1]) {
return {
- projectSlug: projectComponents[1],
+ projectId: projectComponents[1],
};
}
}
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index 3500ff9987..a5b35a2ad5 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -45,7 +45,6 @@ export type RowStatus = "NORMAL" | "ARCHIVED";
export type RouterSlug = {
principalEmail?: string;
environmentSlug?: string;
- projectSlug?: string;
projectWebhookSlug?: string;
issueSlug?: string;
instanceSlug?: string;
@@ -58,6 +57,7 @@ export type RouterSlug = {
ssoName?: string;
// Resource names.
+ projectId?: string;
databaseGroupName?: string;
schemaGroupName?: string;
changelistName?: string;
diff --git a/frontend/src/utils/slug.ts b/frontend/src/utils/slug.ts
index d260c89830..bb17fb503d 100644
--- a/frontend/src/utils/slug.ts
+++ b/frontend/src/utils/slug.ts
@@ -6,14 +6,12 @@ import {
getVCSUid,
} from "@/store/modules/v1/common";
import { ExternalVersionControl as VCSV1 } from "@/types/proto/v1/externalvs_service";
-import { Project as ProjectV1 } from "@/types/proto/v1/project_service";
import { Sheet as SheetV1 } from "@/types/proto/v1/sheet_service";
import {
Database,
Environment,
Instance,
IssueId,
- Project,
SQLReviewPolicy,
UNKNOWN_ID,
} from "../types";
@@ -59,14 +57,6 @@ export function environmentSlug(environment: Environment): string {
return [slug(environment.name), environment.id].join("-");
}
-export function projectSlug(project: Project): string {
- return [slug(project.name), project.id].join("-");
-}
-
-export function projectSlugV1(project: ProjectV1): string {
- return [slug(project.title), project.uid].join("-");
-}
-
export function instanceSlug(instance: Instance): string {
return [
slug(instance.environment.name),
diff --git a/frontend/src/utils/v1/project.ts b/frontend/src/utils/v1/project.ts
index 9b4915946a..99ec04b461 100644
--- a/frontend/src/utils/v1/project.ts
+++ b/frontend/src/utils/v1/project.ts
@@ -1,5 +1,4 @@
import { orderBy, uniq } from "lodash-es";
-import slug from "slug";
import { extractUserEmail, useUserStore } from "@/store";
import {
ALL_USERS_USER_EMAIL,
@@ -17,10 +16,6 @@ import {
ProjectPermissionType,
} from "../role";
-export function projectV1Slug(project: Project): string {
- return [slug(project.title), project.uid].join("-");
-}
-
export const extractProjectResourceName = (name: string) => {
const pattern = /(?:^|\/)projects\/([^/]+)(?:$|\/)/;
const matches = name.match(pattern);
diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vue
index a23d7abd6b..543507ed09 100644
--- a/frontend/src/views/DashboardHeader.vue
+++ b/frontend/src/views/DashboardHeader.vue
@@ -114,7 +114,7 @@ const state = reactive<LocalState>({
const params = computed(() => {
const route = router.currentRoute.value;
return {
- projectSlug: route.params.projectSlug as string,
+ projectId: route.params.projectId as string,
issueSlug: route.params.issueSlug as string,
databaseSlug: route.params.databaseSlug as string,
changeHistorySlug: route.params.changeHistorySlug as string,
diff --git a/frontend/src/views/DatabaseGroupDetail.vue b/frontend/src/views/DatabaseGroupDetail.vue
index a60980c685..123ca2324a 100644
--- a/frontend/src/views/DatabaseGroupDetail.vue
+++ b/frontend/src/views/DatabaseGroupDetail.vue
@@ -145,9 +145,9 @@ import {
useSubscriptionV1Store,
} from "@/store";
import { databaseGroupNamePrefix } from "@/store/modules/v1/common";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { ComposedDatabase, ComposedDatabaseGroup } from "@/types";
import { DatabaseGroup, SchemaGroup } from "@/types/proto/v1/project_service";
-import { idFromSlug } from "@/utils";
interface LocalState {
isLoaded: boolean;
@@ -161,16 +161,10 @@ interface EditDatabaseGroupState {
parentDatabaseGroup?: ComposedDatabaseGroup;
}
-const props = defineProps({
- projectSlug: {
- required: true,
- type: String,
- },
- databaseGroupName: {
- required: true,
- type: String,
- },
-});
+const props = defineProps<{
+ projectId: string;
+ databaseGroupName: string;
+}>();
const projectStore = useProjectV1Store();
const dbGroupStore = useDBGroupStore();
@@ -189,7 +183,9 @@ const issueType = ref<
| undefined
>();
const project = computed(() => {
- return projectStore.getProjectByUID(String(idFromSlug(props.projectSlug)));
+ return projectStore.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
});
const databaseGroupResourceName = computed(() => {
return `${project.value.name}/${databaseGroupNamePrefix}${props.databaseGroupName}`;
diff --git a/frontend/src/views/ProjectDetail.vue b/frontend/src/views/ProjectDetail.vue
deleted file mode 100644
index 194de82c0b..0000000000
--- a/frontend/src/views/ProjectDetail.vue
+++ /dev/null
@@ -1,288 +0,0 @@
-<template>
- <QuickActionPanel :quick-action-list="quickActionList" class="mb-4" />
- <template v-if="hash === 'issues'">
- <ProjectIssuesPanel id="issues" :project="project" />
- </template>
- <template v-if="hash === 'branches'">
- <ProjectBranchesPanel id="branches" :project="project" />
- </template>
- <template v-if="hash === 'databases'">
- <ProjectDatabasesPanel :project="project" :database-list="databaseV1List" />
- </template>
- <template v-if="hash === 'database-groups'">
- <ProjectDatabaseGroupPanel :project="project" />
- </template>
- <template v-if="hash === 'change-history'">
- <ProjectChangeHistoryPanel
- id="change-history"
- :database-list="databaseV1List"
- />
- </template>
- <template v-if="hash === 'changelists'">
- <ChangelistDashboard :project="project" />
- </template>
- <template v-if="hash === 'sync-schema'">
- <SyncDatabaseSchema :key="project.name" :project="project" />
- </template>
- <template v-if="hash === 'slow-query'">
- <ProjectSlowQueryPanel :project="project" />
- </template>
- <template v-if="hash === 'anomalies'">
- <AnomalyCenterDashboard :project="project" :selected-tab="'database'" />
- </template>
- <template v-if="hash === 'activities'">
- <ProjectActivityPanel id="activity" :project="project" />
- </template>
- <template v-if="!isDefaultProject && hash === 'gitops'">
- <ProjectVersionControlPanel
- id="gitops"
- :project="project"
- :allow-edit="allowEdit"
- />
- </template>
- <template v-if="!isDefaultProject && hash === 'webhook'">
- <ProjectWebhookPanel
- id="webhook"
- :project="project"
- :allow-edit="allowEdit"
- />
- </template>
- <template v-if="!isDefaultProject && hash === 'members'">
- <ProjectMemberPanel
- id="setting"
- :project="project"
- :allow-edit="allowEdit"
- />
- </template>
- <template v-if="!isDefaultProject && hash === 'setting'">
- <ProjectSettingPanel
- id="setting"
- :project="project"
- :allow-edit="allowEdit"
- />
- </template>
-</template>
-
-<script lang="ts" setup>
-import { useLocalStorage } from "@vueuse/core";
-import { pull } from "lodash-es";
-import { computed, onMounted } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRoute } from "vue-router";
-import AnomalyCenterDashboard from "@/components/AnomalyCenter/AnomalyCenterDashboard.vue";
-import ChangelistDashboard from "@/components/Changelist/ChangelistDashboard";
-import ProjectDatabaseGroupPanel from "@/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue";
-import ProjectIssuesPanel from "@/components/Project/ProjectIssuesPanel.vue";
-import { ProjectHash } from "@/components/Project/ProjectSidebar.vue";
-import ProjectActivityPanel from "@/components/ProjectActivityPanel.vue";
-import ProjectBranchesPanel from "@/components/ProjectBranchesPanel.vue";
-import ProjectChangeHistoryPanel from "@/components/ProjectChangeHistoryPanel.vue";
-import ProjectDatabasesPanel from "@/components/ProjectDatabasesPanel.vue";
-import ProjectMemberPanel from "@/components/ProjectMember/ProjectMemberPanel.vue";
-import ProjectSettingPanel from "@/components/ProjectSettingPanel.vue";
-import ProjectSlowQueryPanel from "@/components/ProjectSlowQueryPanel.vue";
-import ProjectVersionControlPanel from "@/components/ProjectVersionControlPanel.vue";
-import ProjectWebhookPanel from "@/components/ProjectWebhookPanel.vue";
-import SyncDatabaseSchema from "@/components/SyncDatabaseSchema/index.vue";
-import {
- useSearchDatabaseV1List,
- useDatabaseV1Store,
- useProjectV1Store,
- useCurrentUserV1,
- useActivityV1Store,
- hasFeature,
- pushNotification,
-} from "@/store";
-import {
- QuickActionType,
- DEFAULT_PROJECT_V1_NAME,
- RoleType,
- activityName,
-} from "@/types";
-import { State } from "@/types/proto/v1/common";
-import { LogEntity_Action } from "@/types/proto/v1/logging_service";
-import { TenantMode } from "@/types/proto/v1/project_service";
-import {
- idFromSlug,
- projectV1Slug,
- sortDatabaseV1List,
- isOwnerOfProjectV1,
- hasPermissionInProjectV1,
- hasWorkspacePermissionV1,
- getQuickActionList,
-} from "@/utils";
-
-const props = defineProps({
- projectWebhookSlug: {
- default: undefined,
- type: String,
- },
- projectSlug: {
- required: true,
- type: String,
- },
- allowEdit: {
- required: true,
- type: Boolean,
- },
-});
-
-const route = useRoute();
-const projectV1Store = useProjectV1Store();
-const activityV1Store = useActivityV1Store();
-const { t } = useI18n();
-
-const hash = computed(() => route.hash.replace(/^#?/, "") as ProjectHash);
-
-const project = computed(() => {
- return projectV1Store.getProjectByUID(String(idFromSlug(props.projectSlug)));
-});
-
-const isDefaultProject = computed((): boolean => {
- return project.value.name === DEFAULT_PROJECT_V1_NAME;
-});
-
-useSearchDatabaseV1List(
- computed(() => ({
- parent: "instances/-",
- filter: `project == "${project.value.name}"`,
- }))
-);
-
-const databaseV1List = computed(() => {
- const list = useDatabaseV1Store().databaseListByProject(project.value.name);
- return sortDatabaseV1List(list);
-});
-
-const cachedNotifiedActivities = useLocalStorage<string[]>(
- `bb.project.${props.projectSlug}.activities`,
- []
-);
-
-const maximumCachedActivities = 5;
-
-onMounted(() => {
- const currentUserV1 = useCurrentUserV1();
-
- if (
- !hasWorkspacePermissionV1(
- "bb.permission.workspace.manage-issue",
- currentUserV1.value.userRole
- ) &&
- !hasPermissionInProjectV1(
- project.value.iamPolicy,
- currentUserV1.value,
- "bb.permission.project.change-database"
- )
- ) {
- return;
- }
- activityV1Store
- .fetchActivityList({
- pageSize: 1,
- order: "desc",
- action: [LogEntity_Action.ACTION_PROJECT_REPOSITORY_PUSH],
- resource: project.value.name,
- })
- .then((resp) => {
- for (const activity of resp.logEntities) {
- if (cachedNotifiedActivities.value.includes(activity.name)) {
- continue;
- }
- cachedNotifiedActivities.value.push(activity.name);
- if (cachedNotifiedActivities.value.length > maximumCachedActivities) {
- cachedNotifiedActivities.value.shift();
- }
-
- pushNotification({
- module: "bytebase",
- style: "INFO",
- title: activityName(activity.action),
- manualHide: true,
- link: `/project/${projectV1Slug(project.value)}#activities`,
- linkTitle: t("common.view"),
- });
- break;
- }
- });
-});
-
-const quickActionForDatabaseGroup = computed((): QuickActionType[] => {
- if (project.value.tenantMode !== TenantMode.TENANT_MODE_ENABLED) {
- return [];
- }
- return [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
- "quickaction.bb.group.database-group.create",
- "quickaction.bb.group.table-group.create",
- ];
-});
-
-const quickActionMapByRole = computed(() => {
- if (project.value.state === State.ACTIVE) {
- const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.create",
- "quickaction.bb.project.database.transfer",
- ];
- const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [];
-
- const currentUserV1 = useCurrentUserV1();
- if (
- project.value.name !== DEFAULT_PROJECT_V1_NAME &&
- hasPermissionInProjectV1(
- project.value.iamPolicy,
- currentUserV1.value,
- "bb.permission.project.change-database"
- )
- ) {
- // Default project (Unassigned databases) are not allowed
- // to be changed.
- DEVELOPER_QUICK_ACTION_LIST.push("quickaction.bb.database.create");
- }
- if (
- hasPermissionInProjectV1(
- project.value.iamPolicy,
- currentUserV1.value,
- "bb.permission.project.transfer-database"
- )
- ) {
- DEVELOPER_QUICK_ACTION_LIST.push(
- "quickaction.bb.project.database.transfer"
- );
- }
- if (!isOwnerOfProjectV1(project.value.iamPolicy, currentUserV1.value)) {
- DEVELOPER_QUICK_ACTION_LIST.push(
- "quickaction.bb.issue.grant.request.querier",
- "quickaction.bb.issue.grant.request.exporter"
- );
- }
-
- if (hasFeature("bb.feature.dba-workflow")) {
- pull(DEVELOPER_QUICK_ACTION_LIST, "quickaction.bb.database.create");
- }
-
- return new Map([
- ["OWNER", [...DBA_AND_OWNER_QUICK_ACTION_LIST]],
- ["DBA", [...DBA_AND_OWNER_QUICK_ACTION_LIST]],
- ["DEVELOPER", DEVELOPER_QUICK_ACTION_LIST],
- ]) as Map<RoleType, QuickActionType[]>;
- }
-
- return new Map<RoleType, QuickActionType[]>();
-});
-
-const isDatabaseHash = computed(() => {
- return hash.value === "databases" || hash.value === "database-groups";
-});
-
-const quickActionList = computed(() => {
- if (!isDatabaseHash.value) {
- return [];
- }
- if (hash.value === "database-groups") {
- return quickActionForDatabaseGroup.value;
- }
- return getQuickActionList(quickActionMapByRole.value);
-});
-</script>
diff --git a/frontend/src/views/ProjectWebhookCreate.vue b/frontend/src/views/ProjectWebhookCreate.vue
deleted file mode 100644
index f3fcae56f3..0000000000
--- a/frontend/src/views/ProjectWebhookCreate.vue
+++ /dev/null
@@ -1,48 +0,0 @@
-<template>
- <div class="space-y-4 divide-y divide-block-border">
- <div class="text-xl leading-6 font-medium text-main">
- {{ $t("project.webhook.creation.title") }}
- </div>
- <ProjectWebhookForm
- class="pt-4"
- :create="true"
- :project="project"
- :webhook="defaultNewWebhook"
- />
- </div>
-</template>
-
-<script lang="ts">
-import { computed, defineComponent } from "vue";
-import { useProjectV1Store } from "@/store";
-import { emptyProjectWebhook } from "@/types";
-import ProjectWebhookForm from "../components/ProjectWebhookForm.vue";
-import { idFromSlug } from "../utils";
-
-export default defineComponent({
- name: "ProjectWebhookCreate",
- components: { ProjectWebhookForm },
- props: {
- projectSlug: {
- required: true,
- type: String,
- },
- },
- setup(props) {
- const projectV1Store = useProjectV1Store();
-
- const project = computed(() => {
- return projectV1Store.getProjectByUID(
- String(idFromSlug(props.projectSlug))
- );
- });
-
- const defaultNewWebhook = emptyProjectWebhook();
-
- return {
- defaultNewWebhook,
- project,
- };
- },
-});
-</script>
diff --git a/frontend/src/views/SchemaGroupDetail.vue b/frontend/src/views/SchemaGroupDetail.vue
index 3212bd9264..04d93184ef 100644
--- a/frontend/src/views/SchemaGroupDetail.vue
+++ b/frontend/src/views/SchemaGroupDetail.vue
@@ -111,8 +111,8 @@ import {
databaseGroupNamePrefix,
schemaGroupNamePrefix,
} from "@/store/modules/v1/common";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { ComposedSchemaGroupTable } from "@/types";
-import { idFromSlug } from "@/utils";
import { convertCELStringToExpr } from "@/utils/databaseGroup/cel";
interface LocalState {
@@ -121,20 +121,11 @@ interface LocalState {
expr?: ConditionGroupExpr;
}
-const props = defineProps({
- projectSlug: {
- required: true,
- type: String,
- },
- databaseGroupName: {
- required: true,
- type: String,
- },
- schemaGroupName: {
- required: true,
- type: String,
- },
-});
+const props = defineProps<{
+ projectId: string;
+ databaseGroupName: string;
+ schemaGroupName: string;
+}>();
const projectStore = useProjectV1Store();
const dbGroupStore = useDBGroupStore();
@@ -145,7 +136,9 @@ const state = reactive<LocalState>({
showConfigurePanel: false,
});
const project = computed(() => {
- return projectStore.getProjectByUID(String(idFromSlug(props.projectSlug)));
+ return projectStore.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
});
const schemaGroup = computed(() => {
return dbGroupStore.getSchemaGroupByName(
diff --git a/frontend/src/views/auth/PasswordReset.vue b/frontend/src/views/auth/PasswordReset.vue
index 535f482347..020923830c 100644
--- a/frontend/src/views/auth/PasswordReset.vue
+++ b/frontend/src/views/auth/PasswordReset.vue
@@ -76,9 +76,7 @@ export default {
return isValidEmail(state.email);
});
- const tryReset = () => {
- console.log("Reset Email", state.email);
- };
+ const tryReset = () => {};
return { state, allowReset, tryReset };
},
diff --git a/frontend/src/views/branch/BranchDetail.vue b/frontend/src/views/branch/BranchDetail.vue
index 889c83b071..8e5150e509 100644
--- a/frontend/src/views/branch/BranchDetail.vue
+++ b/frontend/src/views/branch/BranchDetail.vue
@@ -29,13 +29,15 @@ 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 { extractUserEmail, useCurrentUserV1, useProjectV1Store } from "@/store";
import { useBranchStore } from "@/store/modules/branch";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { Branch } from "@/types/proto/v1/branch_service";
-import { idFromSlug, isOwnerOfProjectV1 } from "@/utils";
+import { isOwnerOfProjectV1 } from "@/utils";
const props = defineProps<{
- projectSlug: string;
+ projectId: string;
branchName: string;
}>();
@@ -51,11 +53,11 @@ const detailViewKey = ref(uniqueId());
const isCreating = computed(() => props.branchName === "new");
const branch = ref<{ clean: Branch; dirty: Branch }>();
const project = computed(() => {
- if (props.projectSlug === "-") {
+ if (props.projectId === "-") {
return;
}
- return projectStore.getProjectByUID(
- String(idFromSlug(props.projectSlug as string))
+ return projectStore.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
);
});
const allowEdit = computed(() => {
@@ -72,15 +74,15 @@ const handleUpdateBranchId = (id: string) => {
branch.value.clean.branchId = id;
branch.value.dirty.branchId = id;
router.replace({
+ name: PROJECT_V1_BRANCHE_DETAIL,
params: {
- projectSlug: props.projectSlug,
branchName: id,
},
});
};
watch(
- [() => props.projectSlug, () => props.branchName],
+ [() => props.projectId, () => props.branchName],
async () => {
if (isCreating.value) {
return;
diff --git a/frontend/src/views/branch/BranchMerge.vue b/frontend/src/views/branch/BranchMerge.vue
index a8389e0164..410f42eb55 100644
--- a/frontend/src/views/branch/BranchMerge.vue
+++ b/frontend/src/views/branch/BranchMerge.vue
@@ -15,24 +15,28 @@
import { computed } from "vue";
import { useRouter } from "vue-router";
import BranchMergeView from "@/components/Branch/BranchMergeView";
+import {
+ PROJECT_V1_BRANCHE_MERGE,
+ PROJECT_V1_BRANCHE_DETAIL,
+} from "@/router/dashboard/projectV1";
import { useProjectV1Store } from "@/store";
import { getProjectAndBranchId } from "@/store/modules/v1/common";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { Branch } from "@/types/proto/v1/branch_service";
-import { idFromSlug } from "@/utils";
const props = defineProps<{
- projectSlug: string;
+ projectId: string;
branchName: string;
}>();
const router = useRouter();
const project = computed(() => {
- if (props.projectSlug === "-") {
+ if (props.projectId === "-") {
return;
}
- return useProjectV1Store().getProjectByUID(
- String(idFromSlug(props.projectSlug as string))
+ return useProjectV1Store().getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
);
});
@@ -45,9 +49,8 @@ const branchFullName = computed(() => {
const handleUpdateHeadBranchName = (branchName: string | null) => {
const branchId = branchName ? getProjectAndBranchId(branchName)[1] : "-";
router.replace({
- name: "workspace.project.branch.merge",
+ name: PROJECT_V1_BRANCHE_MERGE,
params: {
- projectSlug: props.projectSlug,
branchName: branchId,
},
query: router.currentRoute.value.query,
@@ -61,9 +64,8 @@ const handleMerged = (
headBranch: Branch | undefined
) => {
router.replace({
- name: "workspace.project.branch.detail",
+ name: PROJECT_V1_BRANCHE_DETAIL,
params: {
- projectSlug: props.projectSlug,
branchName: mergedBranch.branchId,
},
});
diff --git a/frontend/src/views/branch/BranchRebase.vue b/frontend/src/views/branch/BranchRebase.vue
index 11746bca19..aa96bace08 100644
--- a/frontend/src/views/branch/BranchRebase.vue
+++ b/frontend/src/views/branch/BranchRebase.vue
@@ -15,24 +15,28 @@
import { computed } from "vue";
import { useRouter } from "vue-router";
import BranchRebaseView from "@/components/Branch/BranchRebaseView";
+import {
+ PROJECT_V1_BRANCHE_REBASE,
+ PROJECT_V1_BRANCHE_DETAIL,
+} from "@/router/dashboard/projectV1";
import { useProjectV1Store } from "@/store";
import { getProjectAndBranchId } from "@/store/modules/v1/common";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { Branch } from "@/types/proto/v1/branch_service";
-import { idFromSlug } from "@/utils";
const props = defineProps<{
- projectSlug: string;
+ projectId: string;
branchName: string;
}>();
const router = useRouter();
const project = computed(() => {
- if (props.projectSlug === "-") {
+ if (props.projectId === "-") {
return;
}
- return useProjectV1Store().getProjectByUID(
- String(idFromSlug(props.projectSlug as string))
+ return useProjectV1Store().getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
);
});
@@ -45,9 +49,8 @@ const branchFullName = computed(() => {
const handleUpdateHeadBranchName = (branchName: string | null) => {
const branchId = branchName ? getProjectAndBranchId(branchName)[1] : "-";
router.replace({
- name: "workspace.project.branch.rebase",
+ name: PROJECT_V1_BRANCHE_REBASE,
params: {
- projectSlug: props.projectSlug,
branchName: branchId,
},
query: router.currentRoute.value.query,
@@ -55,15 +58,10 @@ const handleUpdateHeadBranchName = (branchName: string | null) => {
});
};
-const handleRebased = (
- rebasedBranch: Branch,
- headBranchName: string,
- headBranch: Branch | undefined
-) => {
+const handleRebased = (rebasedBranch: Branch) => {
router.replace({
- name: "workspace.project.branch.detail",
+ name: PROJECT_V1_BRANCHE_DETAIL,
params: {
- projectSlug: props.projectSlug,
branchName: rebasedBranch.branchId,
},
});
diff --git a/frontend/src/views/branch/BranchRollout.vue b/frontend/src/views/branch/BranchRollout.vue
index 9cd0a23139..511c0573e8 100644
--- a/frontend/src/views/branch/BranchRollout.vue
+++ b/frontend/src/views/branch/BranchRollout.vue
@@ -18,11 +18,11 @@ import { useRouter } from "vue-router";
import BranchRolloutView from "@/components/Branch/BranchRolloutView";
import { useProjectV1Store } from "@/store";
import { useBranchStore } from "@/store/modules/branch";
+import { projectNamePrefix } from "@/store/modules/v1/common";
import { Branch } from "@/types/proto/v1/branch_service";
-import { idFromSlug } from "@/utils";
const props = defineProps<{
- projectSlug: string;
+ projectId: string;
branchName: string;
}>();
@@ -34,17 +34,17 @@ const branchFullName = ref<string>("");
const ready = ref<boolean>(false);
const project = computed(() => {
- if (props.projectSlug === "-") {
+ if (props.projectId === "-") {
return;
}
- return projectStore.getProjectByUID(
- String(idFromSlug(props.projectSlug as string))
+ return projectStore.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
);
});
const branch = ref<Branch>();
watch(
- [() => props.projectSlug, () => props.branchName],
+ [() => props.projectId, () => props.branchName],
async () => {
// Prepare branch name from route params.
const branchId = props.branchName;
diff --git a/frontend/src/views/project/ProjectActivityDashboard.vue b/frontend/src/views/project/ProjectActivityDashboard.vue
new file mode 100644
index 0000000000..3dc05cc7d7
--- /dev/null
+++ b/frontend/src/views/project/ProjectActivityDashboard.vue
@@ -0,0 +1,21 @@
+<template>
+ <ProjectActivityPanel :project="project" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectAnomalyCenterDashboard.vue b/frontend/src/views/project/ProjectAnomalyCenterDashboard.vue
new file mode 100644
index 0000000000..09f13b448c
--- /dev/null
+++ b/frontend/src/views/project/ProjectAnomalyCenterDashboard.vue
@@ -0,0 +1,23 @@
+<template>
+ <AnomalyCenterDashboard :project="project" :selected-tab="'database'" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import AnomalyCenterDashboard from "@/components/AnomalyCenter/AnomalyCenterDashboard.vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+ allowEdit: boolean;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectBrancheDashboard.vue b/frontend/src/views/project/ProjectBrancheDashboard.vue
new file mode 100644
index 0000000000..9da5c448fa
--- /dev/null
+++ b/frontend/src/views/project/ProjectBrancheDashboard.vue
@@ -0,0 +1,22 @@
+<template>
+ <ProjectBranchesPanel :project="project" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import ProjectBranchesPanel from "@/components/ProjectBranchesPanel.vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectChangeHistoryDashboard.vue b/frontend/src/views/project/ProjectChangeHistoryDashboard.vue
new file mode 100644
index 0000000000..b285b20861
--- /dev/null
+++ b/frontend/src/views/project/ProjectChangeHistoryDashboard.vue
@@ -0,0 +1,28 @@
+<template>
+ <ProjectChangeHistoryPanel :database-list="databaseV1List" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import ProjectChangeHistoryPanel from "@/components/ProjectChangeHistoryPanel.vue";
+import { useProjectV1Store, useDatabaseV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import { sortDatabaseV1List } from "@/utils";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+
+const databaseV1List = computed(() => {
+ const list = useDatabaseV1Store().databaseListByProject(project.value.name);
+ return sortDatabaseV1List(list);
+});
+</script>
diff --git a/frontend/src/views/project/ProjectChangelistDashboard.vue b/frontend/src/views/project/ProjectChangelistDashboard.vue
new file mode 100644
index 0000000000..a287cd0f41
--- /dev/null
+++ b/frontend/src/views/project/ProjectChangelistDashboard.vue
@@ -0,0 +1,22 @@
+<template>
+ <ChangelistDashboard :project="project" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import ChangelistDashboard from "@/components/Changelist/ChangelistDashboard";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectDatabaseDashboard.vue b/frontend/src/views/project/ProjectDatabaseDashboard.vue
index 3113c82542..7f6ea3400f 100644
--- a/frontend/src/views/project/ProjectDatabaseDashboard.vue
+++ b/frontend/src/views/project/ProjectDatabaseDashboard.vue
@@ -1,14 +1,8 @@
<template>
- <QuickActionPanel
- v-if="showQuickActionPanel"
- :quick-action-list="quickActionList"
- class="mb-4"
- />
<ProjectDatabasesPanel :project="project" :database-list="databaseV1List" />
</template>
<script lang="ts" setup>
-import { pull } from "lodash-es";
import { computed } from "vue";
import ProjectDatabasesPanel from "@/components/ProjectDatabasesPanel.vue";
import {
@@ -16,26 +10,14 @@ import {
useDatabaseV1Store,
useProjectV1Store,
useCurrentUserV1,
- hasFeature,
usePageMode,
} from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
-import { QuickActionType, DEFAULT_PROJECT_V1_NAME, RoleType } from "@/types";
-import { State } from "@/types/proto/v1/common";
-import {
- sortDatabaseV1List,
- isOwnerOfProjectV1,
- hasPermissionInProjectV1,
- getQuickActionList,
- isDatabaseV1Alterable,
-} from "@/utils";
+import { sortDatabaseV1List, isDatabaseV1Alterable } from "@/utils";
-const props = defineProps({
- projectId: {
- required: true,
- type: String,
- },
-});
+const props = defineProps<{
+ projectId: string;
+}>();
const currentUser = useCurrentUserV1();
const projectV1Store = useProjectV1Store();
@@ -63,71 +45,4 @@ const databaseV1List = computed(() => {
}
return list;
});
-
-const quickActionMapByRole = computed(() => {
- if (project.value.state === State.ACTIVE) {
- const DBA_AND_OWNER_QUICK_ACTION_LIST: QuickActionType[] = [
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
- "quickaction.bb.database.create",
- "quickaction.bb.project.database.transfer",
- ];
- const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [];
-
- const currentUserV1 = useCurrentUserV1();
- if (
- project.value.name !== DEFAULT_PROJECT_V1_NAME &&
- hasPermissionInProjectV1(
- project.value.iamPolicy,
- currentUserV1.value,
- "bb.permission.project.change-database"
- )
- ) {
- // Default project (Unassigned databases) are not allowed
- // to be changed.
- DEVELOPER_QUICK_ACTION_LIST.push(
- "quickaction.bb.database.schema.update",
- "quickaction.bb.database.data.update",
- "quickaction.bb.database.create"
- );
- }
- if (
- hasPermissionInProjectV1(
- project.value.iamPolicy,
- currentUserV1.value,
- "bb.permission.project.transfer-database"
- )
- ) {
- DEVELOPER_QUICK_ACTION_LIST.push(
- "quickaction.bb.project.database.transfer"
- );
- }
- if (!isOwnerOfProjectV1(project.value.iamPolicy, currentUserV1.value)) {
- DEVELOPER_QUICK_ACTION_LIST.push(
- "quickaction.bb.issue.grant.request.querier",
- "quickaction.bb.issue.grant.request.exporter"
- );
- }
-
- if (hasFeature("bb.feature.dba-workflow")) {
- pull(DEVELOPER_QUICK_ACTION_LIST, "quickaction.bb.database.create");
- }
-
- return new Map([
- ["OWNER", DBA_AND_OWNER_QUICK_ACTION_LIST],
- ["DBA", DBA_AND_OWNER_QUICK_ACTION_LIST],
- ["DEVELOPER", DEVELOPER_QUICK_ACTION_LIST],
- ]) as Map<RoleType, QuickActionType[]>;
- }
-
- return new Map<RoleType, QuickActionType[]>();
-});
-
-const quickActionList = computed(() => {
- return getQuickActionList(quickActionMapByRole.value);
-});
-
-const showQuickActionPanel = computed(() => {
- return pageMode.value === "BUNDLED" && quickActionList.value.length > 0;
-});
</script>
diff --git a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
new file mode 100644
index 0000000000..d532818669
--- /dev/null
+++ b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
@@ -0,0 +1,22 @@
+<template>
+ <ProjectDatabaseGroupPanel :project="project" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import ProjectDatabaseGroupPanel from "@/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectIssueDashboard.vue b/frontend/src/views/project/ProjectIssueDashboard.vue
index 3c65468c97..98e9e03f73 100644
--- a/frontend/src/views/project/ProjectIssueDashboard.vue
+++ b/frontend/src/views/project/ProjectIssueDashboard.vue
@@ -7,12 +7,9 @@ import { computed } from "vue";
import { useProjectV1Store } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
-const props = defineProps({
- projectId: {
- required: true,
- type: String,
- },
-});
+const props = defineProps<{
+ projectId: string;
+}>();
const projectV1Store = useProjectV1Store();
diff --git a/frontend/src/views/project/ProjectMemberDashboard.vue b/frontend/src/views/project/ProjectMemberDashboard.vue
new file mode 100644
index 0000000000..bec91b7e7d
--- /dev/null
+++ b/frontend/src/views/project/ProjectMemberDashboard.vue
@@ -0,0 +1,22 @@
+<template>
+ <ProjectMemberPanel :project="project" :allow-edit="allowEdit" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+ allowEdit: boolean;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectSettingPanel.vue b/frontend/src/views/project/ProjectSettingPanel.vue
new file mode 100644
index 0000000000..d791777e95
--- /dev/null
+++ b/frontend/src/views/project/ProjectSettingPanel.vue
@@ -0,0 +1,23 @@
+<template>
+ <ProjectSettingPanel :project="project" :allow-edit="allowEdit" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import ProjectSettingPanel from "@/components/ProjectSettingPanel.vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+ allowEdit: boolean;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectSlowQueryDashboard.vue b/frontend/src/views/project/ProjectSlowQueryDashboard.vue
new file mode 100644
index 0000000000..bcb550dab9
--- /dev/null
+++ b/frontend/src/views/project/ProjectSlowQueryDashboard.vue
@@ -0,0 +1,22 @@
+<template>
+ <ProjectSlowQueryPanel :project="project" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import ProjectSlowQueryPanel from "@/components/ProjectSlowQueryPanel.vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectSyncDatabasePanel.vue b/frontend/src/views/project/ProjectSyncDatabasePanel.vue
new file mode 100644
index 0000000000..3df91bbba8
--- /dev/null
+++ b/frontend/src/views/project/ProjectSyncDatabasePanel.vue
@@ -0,0 +1,22 @@
+<template>
+ <SyncDatabaseSchema :key="project.name" :project="project" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import SyncDatabaseSchema from "@/components/SyncDatabaseSchema/index.vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectVersionControlPanel.vue b/frontend/src/views/project/ProjectVersionControlPanel.vue
new file mode 100644
index 0000000000..24497fcbb1
--- /dev/null
+++ b/frontend/src/views/project/ProjectVersionControlPanel.vue
@@ -0,0 +1,23 @@
+<template>
+ <ProjectVersionControlPanel :project="project" :allow-edit="allowEdit" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import ProjectVersionControlPanel from "@/components/ProjectVersionControlPanel.vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+ allowEdit: boolean;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectWebhookCreate.vue b/frontend/src/views/project/ProjectWebhookCreate.vue
new file mode 100644
index 0000000000..450e1f127a
--- /dev/null
+++ b/frontend/src/views/project/ProjectWebhookCreate.vue
@@ -0,0 +1,35 @@
+<template>
+ <div class="space-y-4 divide-y divide-block-border">
+ <div class="text-xl leading-6 font-medium text-main">
+ {{ $t("project.webhook.creation.title") }}
+ </div>
+ <ProjectWebhookForm
+ class="pt-4"
+ :create="true"
+ :project="project"
+ :webhook="defaultNewWebhook"
+ />
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+import ProjectWebhookForm from "@/components/ProjectWebhookForm.vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import { emptyProjectWebhook } from "@/types";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+
+const defaultNewWebhook = emptyProjectWebhook();
+</script>
diff --git a/frontend/src/views/project/ProjectWebhookDashboard.vue b/frontend/src/views/project/ProjectWebhookDashboard.vue
new file mode 100644
index 0000000000..abb4531ba7
--- /dev/null
+++ b/frontend/src/views/project/ProjectWebhookDashboard.vue
@@ -0,0 +1,22 @@
+<template>
+ <ProjectWebhookPanel :project="project" :allow-edit="allowEdit" />
+</template>
+
+<script setup lang="ts">
+import { computed } from "vue";
+import { useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+ allowEdit: boolean;
+}>();
+
+const projectV1Store = useProjectV1Store();
+
+const project = computed(() => {
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
+});
+</script>
diff --git a/frontend/src/views/ProjectWebhookDetail.vue b/frontend/src/views/project/ProjectWebhookDetail.vue
similarity index 70%
rename from frontend/src/views/ProjectWebhookDetail.vue
rename to frontend/src/views/project/ProjectWebhookDetail.vue
index d9c96db525..65ed2a244c 100644
--- a/frontend/src/views/ProjectWebhookDetail.vue
+++ b/frontend/src/views/project/ProjectWebhookDetail.vue
@@ -4,25 +4,26 @@
<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="" />
+ <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" />
+ <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" />
+ <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" />
+ <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" />
+ <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" />
+ <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" />
@@ -44,32 +45,26 @@
<script lang="ts" setup>
import { computed } from "vue";
+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 ProjectWebhookForm from "../components/ProjectWebhookForm.vue";
-import { idFromSlug } from "../utils";
+import { idFromSlug } from "@/utils";
-const props = defineProps({
- projectSlug: {
- required: true,
- type: String,
- },
- projectWebhookSlug: {
- required: true,
- type: String,
- },
- allowEdit: {
- required: true,
- type: Boolean,
- },
-});
+const props = defineProps<{
+ projectId: string;
+ projectWebhookSlug: string;
+ allowEdit: boolean;
+}>();
const projectV1Store = useProjectV1Store();
const projectWebhookV1Store = useProjectWebhookV1Store();
const project = computed(() => {
- return projectV1Store.getProjectByUID(String(idFromSlug(props.projectSlug)));
+ return projectV1Store.getProjectByName(
+ `${projectNamePrefix}${props.projectId}`
+ );
});
const projectWebhook = computed(() => {