Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): "Default Project" improvement part.1 (#2195)
Liu Jiac4e098736d4
diff --git a/frontend/src/components/Breadcrumb.vue b/frontend/src/components/Breadcrumb.vueindex 90271fe474..60e41115db 100644--- a/frontend/src/components/Breadcrumb.vue+++ b/frontend/src/components/Breadcrumb.vue@@ -192,9 +192,14 @@ export default defineComponent({});}- if (currentRoute.value.meta.title) {+ const { title, overrideBreadcrumb } = currentRoute.value.meta;+ if (title) {+ const route = currentRoute.value;+ if (overrideBreadcrumb && overrideBreadcrumb(route)) {+ list.length = 0; // empty the array+ }list.push({- name: currentRoute.value.meta.title(currentRoute.value),+ name: title(route),// Set empty path for the current route to make the link not clickable.// We do this because clicking the current route path won't trigger reload and would// confuse user since UI won't change while we may have cleared all query parameters.diff --git a/frontend/src/layouts/ProjectLayout.vue b/frontend/src/layouts/ProjectLayout.vueindex cb477998e5..99b613874a 100644--- a/frontend/src/layouts/ProjectLayout.vue+++ b/frontend/src/layouts/ProjectLayout.vue@@ -3,7 +3,12 @@<ArchiveBanner v-if="project.rowStatus == 'ARCHIVED'" /></div><h1 class="px-6 pb-4 text-xl font-bold leading-6 text-main truncate">- {{ project.name }}+ <template v-if="project.id === DEFAULT_PROJECT_ID">+ {{ $t("database.unassigned-databases") }}+ </template>+ <template v-else>+ {{ project.name }}+ </template><spanv-if="project.tenantMode === 'TENANT'"class="text-sm font-normal px-2 ml-2 rounded whitespace-nowrap inline-flex items-center bg-gray-200"diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 1dc70cc230..0325c8ba40 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -533,7 +533,7 @@"from-default-project": "From Default project","from-other-projects": "From other projects","transfer-in-db-title": "Transfer in database from other projects",- "default-db-hint": "Bytebase periodically syncs the instance schema. Newly synced databases are first placed in this default project.",+ "default-db-hint": "Bytebase periodically syncs the instance schema. Newly synced databases are first placed in the default project.","transfer-in-db-alert": "Are you sure to transfer \"{ dbName }\" into our project?"},"create-db": {@@ -857,7 +857,9 @@},"backup-policy-violation": "Backup policy violation","synced-at": "Synced at {time}",- "not-found-last-successful-sync-was": "Not found, last successful sync was {time}"+ "not-found-last-successful-sync-was": "Not found, last successful sync was {time}",+ "view-unassigned-databases": "View unassigned databases",+ "unassigned-databases": "Unassigned databases"},"repository": {"branch-observe-file-change": "The branch where Bytebase observes the file change.",@@ -960,7 +962,7 @@"recent-activity": "Recent @.lower:{'common.activities'}","in-progress": "In progress","recently-closed": "Recently Closed",- "info-slot-content": "Bytebase periodically syncs the instance schema. Newly synced databases are first placed in this default project. User should transfer them to the proper application project.",+ "info-slot-content": "Bytebase periodically syncs the instance schema. Newly synced databases are first placed here. User should transfer them to the proper application project.","no-db-prompt": "No database belongs to this project. You can add database by clicking {newDb} or {transferInDb} from the top action bar."},"webhook": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 72c1c29c9a..cd3942e1ee 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -858,7 +858,9 @@},"backup-policy-violation": "违反了备份策略","synced-at": "同步于 {time}",- "not-found-last-successful-sync-was": "未找到,上次成功同步于 {time}"+ "not-found-last-successful-sync-was": "未找到,上次成功同步于 {time}",+ "view-unassigned-databases": "查看未分配的数据库",+ "unassigned-databases": "未分配的数据库"},"repository": {"branch-observe-file-change": "Bytebase 跟踪文件变更的分支。",@@ -961,7 +963,7 @@"recent-activity": "近期@.lower:{'common.activities'}","in-progress": "进行中","recently-closed": "近期结束",- "info-slot-content": "Bytebase 会定时同步实例的 schema,新同步的数据库会首先被置于默认项目中,之后您可以再将他们转移到适当的项目中。",+ "info-slot-content": "Bytebase 会定时同步实例的 schema,新同步的数据库会首先被置于这里,之后您可以再将他们转移到适当的项目中。","no-db-prompt": "没有数据库属于当前项目。您可以通过点击位于上方菜单栏中的 {newDb} 或者 {transferInDb} 来添加数据库。"},"webhook": {diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex 3037cd9b1a..3227da11dd 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -25,6 +25,7 @@ import {} from "../store";import {Database,+ DEFAULT_PROJECT_ID,PlanType,QuickActionType,Sheet,@@ -584,10 +585,21 @@ const routes: Array<RouteRecordRaw> = [path: "",name: "workspace.project.detail",meta: {+ overrideBreadcrumb: (route: RouteLocationNormalized) => {+ const slug = route.params.projectSlug as string;+ const projectId = idFromSlug(slug);+ if (projectId === DEFAULT_PROJECT_ID) {+ return true;+ }+ return false;+ },title: (route: RouteLocationNormalized) => {const slug = route.params.projectSlug as string;- return useProjectStore().getProjectById(idFromSlug(slug))- .name;+ const projectId = idFromSlug(slug);+ if (projectId === DEFAULT_PROJECT_ID) {+ return t("database.unassigned-databases");+ }+ return useProjectStore().getProjectById(projectId).name;},allowBookmark: true,},diff --git a/frontend/src/shims-vue-router.d.ts b/frontend/src/shims-vue-router.d.tsindex 8a187b0621..47e02493d3 100644--- a/frontend/src/shims-vue-router.d.ts+++ b/frontend/src/shims-vue-router.d.ts@@ -8,5 +8,6 @@ declare module "vue-router" {quickActionListByRole?: (route: RouteLocationNormalized) => Map<RoleType, QuickActionType[]>;+ overrideBreadcrumb?: (route: RouteLocationNormalized) => boolean;}}diff --git a/frontend/src/views/DatabaseDashboard.vue b/frontend/src/views/DatabaseDashboard.vueindex dbaebdc2ea..b0fb3a57e2 100644--- a/frontend/src/views/DatabaseDashboard.vue+++ b/frontend/src/views/DatabaseDashboard.vue@@ -1,18 +1,47 @@<template>- <div class="flex flex-col">+ <div class="flex flex-col relative"><div class="px-5 py-2 flex justify-between items-center">- <!-- eslint-disable vue/attribute-hyphenation --><EnvironmentTabFilter- :selectedId="state.selectedEnvironment?.id"+ :selected-id="state.selectedEnvironment?.id"@select-environment="selectEnvironment"/>- <BBTableSearch- ref="searchField"- :placeholder="$t('database.search-database-name')"- @change-text="(text) => changeSearchText(text)"- />++ <div class="flex items-center space-x-4">+ <NTooltip>+ <template #trigger>+ <router-link+ :to="{+ name: 'workspace.project.detail',+ params: {+ projectSlug: DEFAULT_PROJECT_ID,+ },+ }"+ class="normal-link text-sm"+ >+ {{ $t("database.view-unassigned-databases") }}+ </router-link>+ </template>++ <div class="whitespace-pre-wrap">+ {{ $t("quick-action.default-db-hint") }}+ </div>+ </NTooltip>+ <BBTableSearch+ ref="searchField"+ :placeholder="$t('database.search-database-name')"+ @change-text="(text) => changeSearchText(text)"+ />+ </div></div>+<DatabaseTable :bordered="false" :database-list="filteredList" />++ <div+ v-if="state.loading"+ class="absolute inset-0 bg-white/50 flex justify-center items-center"+ >+ <BBSpin />+ </div></div></template>@@ -26,9 +55,15 @@ import {defineComponent,} from "vue";import { useRouter } from "vue-router";+import { NTooltip } from "naive-ui";import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";import DatabaseTable from "../components/DatabaseTable.vue";-import { Environment, Database, UNKNOWN_ID } from "../types";+import {+ Environment,+ Database,+ UNKNOWN_ID,+ DEFAULT_PROJECT_ID,+} from "../types";import { sortDatabaseList } from "../utils";import { cloneDeep } from "lodash-es";import {@@ -43,11 +78,13 @@ interface LocalState {searchText: string;databaseList: Database[];selectedEnvironment?: Environment;+ loading: boolean;}export default defineComponent({- name: "InstanceDashboard",+ name: "DatabaseDashboard",components: {+ NTooltip,EnvironmentTabFilter,DatabaseTable,},@@ -65,6 +102,7 @@ export default defineComponent({parseInt(router.currentRoute.value.query.environment as string, 10)): undefined,+ loading: false,});const currentUser = useCurrentUser();@@ -86,6 +124,7 @@ export default defineComponent({const prepareDatabaseList = () => {// It will also be called when user logoutif (currentUser.value.id != UNKNOWN_ID) {+ state.loading = true;useDatabaseStore().fetchDatabaseList().then((list) => {@@ -93,6 +132,9 @@ export default defineComponent({cloneDeep(list),environmentList.value);+ })+ .finally(() => {+ state.loading = false;});}};@@ -133,6 +175,7 @@ export default defineComponent({});return {+ DEFAULT_PROJECT_ID,searchField,state,filteredList,