Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add project databases and issues routes (#9747)
boojack60639efa224c
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue b/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vueindex e0052ce450..e8684ef671 100644--- a/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue+++ b/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue@@ -1,5 +1,5 @@<template>- <div ref="containerRef" class="bb-advanced-issue-search-box relative">+ <div ref="containerRef" class="bb-advanced-issue-search-box w-full relative"><NInputref="inputRef"v-model:value="inputText"diff --git a/frontend/src/components/Project/ProjectSidebar.vue b/frontend/src/components/Project/ProjectSidebar.vueindex 0b092b1d9c..adbe4f6ffc 100644--- a/frontend/src/components/Project/ProjectSidebar.vue+++ b/frontend/src/components/Project/ProjectSidebar.vue@@ -62,6 +62,7 @@ interface ProjectSidebarItem extends SidebarItem {const props = defineProps<{projectSlug?: string;+ projectId?: string;issueSlug?: string;databaseSlug?: string;changeHistorySlug?: string;@@ -83,6 +84,7 @@ const state = reactive<LocalState>({const params = computed(() => {return {projectSlug: props.projectSlug,+ projectId: props.projectId,issueSlug: props.issueSlug,databaseSlug: props.databaseSlug,changeHistorySlug: props.changeHistorySlug,diff --git a/frontend/src/components/Project/useCurrentProject.ts b/frontend/src/components/Project/useCurrentProject.tsindex 15aaf74b2f..b922d08554 100644--- a/frontend/src/components/Project/useCurrentProject.ts+++ b/frontend/src/components/Project/useCurrentProject.ts@@ -6,12 +6,14 @@ import {useDatabaseV1Store,experimentalFetchIssueByUID,} from "@/store";+import { projectNamePrefix } from "@/store/modules/v1/common";import { unknownProject, unknownDatabase, UNKNOWN_ID, EMPTY_ID } from "@/types";import { idFromSlug } from "@/utils";export const useCurrentProject = (params: ComputedRef<{projectSlug?: string;+ projectId?: string;issueSlug?: string;databaseSlug?: string;changeHistorySlug?: string;@@ -54,6 +56,10 @@ export const useCurrentProject = (return useProjectV1Store().getProjectByUID(String(idFromSlug(unref(params).projectSlug!)));+ } else if (unref(params).projectId) {+ return useProjectV1Store().getProjectByName(+ `${projectNamePrefix}${unref(params).projectId}`+ );} else if (unref(params).databaseSlug || unref(params).changeHistorySlug) {return database.value.projectEntity;}diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vueindex a6b7beefec..bbed63bd29 100644--- a/frontend/src/components/ProjectDatabasesPanel.vue+++ b/frontend/src/components/ProjectDatabasesPanel.vue@@ -1,7 +1,7 @@<template><div class="space-y-4"><div- class="text-lg space-x-2 font-medium leading-7 text-main flex flex-col lg:flex-row items-start lg:items-end justify-between space-y-2"+ class="w-full text-lg font-medium leading-7 text-main flex flex-col sm:flex-row items-start sm:items-end justify-between gap-2"><AdvancedSearchBoxv-model:params="state.params"@@ -17,7 +17,7 @@</div><DatabaseOperations- v-if="selectedDatabases.length > 0"+ v-if="showDatabaseOperations":databases="selectedDatabases"@dismiss="state.selectedDatabaseIds.clear()"/>@@ -59,7 +59,11 @@</DatabaseV1Table></template><div v-else class="text-center textinfolabel">- <i18n-t keypath="project.overview.no-db-prompt" tag="p">+ <i18n-t+ v-if="showEmptyActions"+ keypath="project.overview.no-db-prompt"+ tag="p"+ ><template #newDb><span class="text-main">{{ $t("quick-action.new-db") }}</span></template>@@ -73,7 +77,7 @@<script lang="ts" setup>import { reactive, PropType, computed, ref, watchEffect } from "vue";-import { useCurrentUserV1, usePolicyV1Store } from "@/store";+import { useCurrentUserV1, usePageMode, usePolicyV1Store } from "@/store";import { ComposedDatabase, UNKNOWN_ID } from "@/types";import {Policy,@@ -104,6 +108,7 @@ const props = defineProps({});const currentUserV1 = useCurrentUserV1();+const pageMode = usePageMode();const state = reactive<LocalState>({selectedDatabaseIds: new Set(),@@ -177,6 +182,18 @@ const filteredDatabaseList = computed(() => {return list;});+const showDatabaseOperations = computed(() => {+ if (pageMode.value === "STANDALONE") {+ return true;+ }++ return selectedDatabases.value.length > 0;+});++const showEmptyActions = computed(() => {+ return pageMode.value === "BUNDLED";+});+const getAllSelectionState = (databaseList: ComposedDatabase[]): { checked: boolean; indeterminate: boolean } => {diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vueindex 97d577f538..343c30f29a 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue@@ -1,7 +1,7 @@<template><divv-bind="$attrs"- class="flex flex-col lg:flex-row items-start lg:items-center bg-blue-100 py-3 px-2 text-main gap-y-2"+ class="flex flex-col sm:flex-row items-start sm:items-center bg-blue-100 py-3 px-2 text-main gap-y-2 gap-x-4"><div class="flex items-center"><button@@ -17,7 +17,7 @@})}}</div>- <div class="flex items-center gap-x-4 text-sm ml-5 text-accent">+ <div class="flex items-center gap-x-4 text-sm text-accent"><template v-for="action in actions" :key="action.text"><NTooltip :disabled="!action.disabled"><template #trigger>diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vuenew file mode 100644index 0000000000..ea56970dd8--- /dev/null+++ b/frontend/src/layouts/ProjectV1Layout.vue@@ -0,0 +1,82 @@+<template>+ <ArchiveBanner v-if="project.state === State.DELETED" class="py-2" />+ <div class="p-6 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"+ :style="'INFO'"+ :title="$t('project.overview.info-slot-content')"+ />+ </HideInStandaloneMode>+ <router-view :project-id="projectId" :allow-edit="allowEdit" />+ </div>+</template>++<script lang="ts" setup>+import { computed, onMounted } from "vue";+import ArchiveBanner from "@/components/ArchiveBanner.vue";+import HideInStandaloneMode from "@/components/misc/HideInStandaloneMode.vue";+import { useCurrentUserV1, useProjectV1Store } from "@/store";+import { projectNamePrefix } from "@/store/modules/v1/common";+import { DEFAULT_PROJECT_V1_NAME } from "@/types";+import { State } from "@/types/proto/v1/common";+import { hasWorkspacePermissionV1, hasPermissionInProjectV1 } from "@/utils";++const props = defineProps({+ projectId: {+ required: true,+ type: String,+ },+});++const currentUserV1 = useCurrentUserV1();+const projectV1Store = useProjectV1Store();++const project = computed(() => {+ return projectV1Store.getProjectByName(+ `${projectNamePrefix}${props.projectId}`+ );+});++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;+});++onMounted(async () => {+ await projectV1Store.getOrFetchProjectByName(+ `${projectNamePrefix}${props.projectId}`+ );+});+</script>diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex 4f417534af..9617a81a2b 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -730,6 +730,36 @@ const routes: Array<RouteRecordRaw> = [},],},+ {+ path: "projects/:projectId",+ components: {+ content: () => import("../layouts/ProjectV1Layout.vue"),+ leftSidebar: ProjectSidebar,+ },+ props: { content: true, leftSidebar: true },+ children: [+ {+ path: "databases",+ name: "workspace.project.database.dashboard",+ meta: {+ overrideTitle: true,+ },+ component: () =>+ import("../views/project/ProjectDatabaseDashboard.vue"),+ props: true,+ },+ {+ path: "issues",+ name: "workspace.project.issue.dashboard",+ meta: {+ overrideTitle: true,+ },+ component: () =>+ import("../views/project/ProjectIssueDashboard.vue"),+ props: true,+ },+ ],+ },{path: "instance",name: "workspace.instance",@@ -1106,7 +1136,6 @@ router.beforeEach((to, from, next) => {to.name === "workspace.issue" ||to.name === "workspace.environment" ||to.name === "sql-editor.home" ||- to.name?.toString().startsWith("sheets") ||(to.name?.toString().startsWith("setting") &&to.name?.toString() != "setting.workspace.gitops.detail" &&to.name?.toString() != "setting.workspace.sql-review.detail" &&@@ -1116,6 +1145,15 @@ router.beforeEach((to, from, next) => {return;}+ if (+ to.name === "workspace.project.detailV1" ||+ to.name === "workspace.project.database.dashboard" ||+ to.name === "workspace.project.issue.dashboard"+ ) {+ next();+ return;+ }+// We may just change the anchor (e.g. in Issue Detail view), thus we don't need// to fetch the data to verify its existence since we have already verified before.if (to.path == from.path) {diff --git a/frontend/src/views/project/ProjectDatabaseDashboard.vue b/frontend/src/views/project/ProjectDatabaseDashboard.vuenew file mode 100644index 0000000000..1ecade6550--- /dev/null+++ b/frontend/src/views/project/ProjectDatabaseDashboard.vue@@ -0,0 +1,126 @@+<template>+ <div v-if="showQuickActionPanel" class="flex-1 pb-4">+ <QuickActionPanel :quick-action-list="quickActionList" />+ </div>+ <ProjectDatabasesPanel :database-list="databaseV1List" />+</template>++<script lang="ts" setup>+import { pull } from "lodash-es";+import { computed } from "vue";+import ProjectDatabasesPanel from "@/components/ProjectDatabasesPanel.vue";+import {+ useSearchDatabaseV1List,+ 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,+} from "@/utils";++const props = defineProps({+ projectId: {+ required: true,+ type: String,+ },+});++const projectV1Store = useProjectV1Store();+const pageMode = usePageMode();++const project = computed(() => {+ return projectV1Store.getProjectByName(+ `${projectNamePrefix}${props.projectId}`+ );+});++useSearchDatabaseV1List(+ computed(() => ({+ parent: "instances/-",+ filter: `project == "${project.value.name}"`,+ }))+);++const databaseV1List = computed(() => {+ const list = useDatabaseV1Store().databaseListByProject(project.value.name);+ return sortDatabaseV1List(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",+ "quickaction.bb.project.database.transfer-out",+ ];+ 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",+ "quickaction.bb.project.database.transfer-out"+ );+ }+ 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/ProjectIssueDashboard.vue b/frontend/src/views/project/ProjectIssueDashboard.vuenew file mode 100644index 0000000000..3c65468c97--- /dev/null+++ b/frontend/src/views/project/ProjectIssueDashboard.vue@@ -0,0 +1,24 @@+<template>+ <ProjectIssuesPanel :project="project" />+</template>++<script lang="ts" setup>+import { computed } from "vue";+import { useProjectV1Store } from "@/store";+import { projectNamePrefix } from "@/store/modules/v1/common";++const props = defineProps({+ projectId: {+ required: true,+ type: String,+ },+});++const projectV1Store = useProjectV1Store();++const project = computed(() => {+ return projectV1Store.getProjectByName(+ `${projectNamePrefix}${props.projectId}`+ );+});+</script>