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): hide NOT_FOUND databases if not needed (#3973)
Liu Ji605a869f075f
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex 181c990639..10c6332654 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -275,6 +275,8 @@ const databaseList = computed(() => {list = databaseStore.getDatabaseListByPrincipalId(currentUser.value.id);}+ list = list.filter((db) => db.syncStatus === "OK");+const keyword = state.searchText.trim();list = list.filter((db) =>filterDatabaseByKeyword(db, keyword, [diff --git a/frontend/src/components/DatabaseTable.vue b/frontend/src/components/DatabaseTable.vueindex 4cf9a17e2c..33cbb61c2c 100644--- a/frontend/src/components/DatabaseTable.vue+++ b/frontend/src/components/DatabaseTable.vue@@ -316,6 +316,14 @@ const props = defineProps({type: Number,default: 20,},+ scrollOnPageChange: {+ type: Boolean,+ default: true,+ },+ showMissingDatabases: {+ type: Boolean,+ default: false,+ },});const emit = defineEmits(["select-database"]);@@ -330,16 +338,21 @@ const state = reactive<State>({const wrapper = ref<HTMLElement>();const sortedDatabaseList = computed(() => {- const list = [...props.databaseList];- list.sort((a, b) => {- if (a.syncStatus === "NOT_FOUND" && b.syncStatus === "OK") {- return -1;- }- if (a.syncStatus === "OK" && b.syncStatus === "NOT_FOUND") {- return 1;- }- return b.createdTs - a.createdTs;- });+ let list = [...props.databaseList];+ if (!props.showMissingDatabases) {+ list = list.filter((db) => db.syncStatus === "OK");+ } else {+ list.sort((a, b) => {+ if (a.syncStatus === "NOT_FOUND" && b.syncStatus === "OK") {+ return -1;+ }+ if (a.syncStatus === "OK" && b.syncStatus === "NOT_FOUND") {+ return 1;+ }+ return b.createdTs - a.createdTs;+ });+ }+return list;});@@ -470,24 +483,28 @@ const pagedDataSource = computed(() => {return table.getRowModel().rows.map((row) => row.original);});-watch(- () => props.pageSize,- (ps) => {- table.setPageSize(ps);- },- { immediate: true }-);const showPagination = computed(() => {return mixedDatabaseList.value.length > props.pageSize;});const handleChangePage = (page: number) => {table.setPageIndex(page - 1);- if (wrapper.value) {+ if (props.scrollOnPageChange && wrapper.value) {const parent = getScrollParent(wrapper.value);parent.scrollTo(0, 0);}};+watch(+ () => props.pageSize,+ (ps) => {+ table.setPageSize(ps);+ },+ { immediate: true }+);+watch(+ () => props.showMissingDatabases,+ () => handleChangePage(1)+);const showReservedDatabaseList = () => {const count = regularDatabaseList.value.length;diff --git a/frontend/src/components/ProjectDeploymentConfigPanel.vue b/frontend/src/components/ProjectDeploymentConfigPanel.vueindex 3d26d5c60f..74bc68e759 100644--- a/frontend/src/components/ProjectDeploymentConfigPanel.vue+++ b/frontend/src/components/ProjectDeploymentConfigPanel.vue@@ -149,15 +149,14 @@ import {EMPTY_ID,DeploymentConfigPatch,LabelSelectorRequirement,+ Database,} from "../types";import DeploymentConfigTool, { DeploymentMatrix } from "./DeploymentConfigTool";import { validateDeploymentConfig } from "../utils";import {pushNotification,- useDatabaseStore,useDeploymentStore,useEnvironmentList,- useEnvironmentStore,useProjectStore,} from "@/store";@@ -177,13 +176,16 @@ export default defineComponent({required: true,type: Object as PropType<Project>,},+ databaseList: {+ type: Array as PropType<Database[]>,+ default: () => [],+ },allowEdit: {default: true,type: Boolean,},},setup(props) {- const databaseStore = useDatabaseStore();const deploymentStore = useDeploymentStore();const { t } = useI18n();const dialog = useDialog();@@ -206,19 +208,8 @@ export default defineComponent({return true;});- const prepareList = () => {- useEnvironmentStore().fetchEnvironmentList();- databaseStore.fetchDatabaseListByProjectId(props.project.id);- };-const environmentList = useEnvironmentList();- const databaseList = computed(() =>- databaseStore.getDatabaseListByProjectId(props.project.id)- );-- watchEffect(prepareList);-const resetStates = async () => {await nextTick(); // Waiting for all watchers donestate.error = undefined;@@ -359,7 +350,6 @@ export default defineComponent({isDeploymentConfigDirty,allowUpdateDeploymentConfig,environmentList,- databaseList,addStage,revertDeploymentConfig,updateDeploymentConfig,diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex a703a55df2..2c28346d92 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -991,7 +991,8 @@"access-denied": "You don't have the permission to access this database.","schema": {"select": "Select schema"- }+ },+ "show-missing-databases": "Show missing databases"},"repository": {"branch-observe-file-change": "The branch where Bytebase observes the file change.",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 332063a3f1..85fe32138d 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -991,7 +991,8 @@"access-denied": "你没有访问该数据库的权限","schema": {"select": "选择 schema"- }+ },+ "show-missing-databases": "显示未找到的数据库"},"repository": {"branch-observe-file-change": "Bytebase 跟踪文件变更的分支。",diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vueindex bbcb528f2b..915bcb2881 100644--- a/frontend/src/views/InstanceDetail.vue+++ b/frontend/src/views/InstanceDetail.vue@@ -23,7 +23,7 @@:tab-item-list="tabItemList":selected-index="state.selectedIndex"@select-index="- (index) => {+ (index: number) => {state.selectedIndex = index;}"@@ -54,11 +54,21 @@</button></div></div>- <DatabaseTable- v-if="state.selectedIndex == DATABASE_TAB"- :mode="'INSTANCE'"- :database-list="databaseList"- />+ <div v-if="state.selectedIndex == DATABASE_TAB">+ <div class="mb-2 pl-4">+ <BBCheckbox+ :title="$t('database.show-missing-databases')"+ :value="state.showMissingDatabases"+ @toggle="state.showMissingDatabases = $event"+ />+ </div>+ <DatabaseTable+ mode="INSTANCE"+ :scroll-on-page-change="false"+ :show-missing-databases="state.showMissingDatabases"+ :database-list="databaseList"+ />+ </div><InstanceUserTablev-else-if="state.selectedIndex == USER_TAB":instance-user-list="instanceUserList"@@ -177,6 +187,7 @@ interface LocalState {showCreateDatabaseModal: boolean;syncingSchema: boolean;showFeatureModal: boolean;+ showMissingDatabases: boolean;}const props = defineProps({@@ -201,6 +212,7 @@ const state = reactive<LocalState>({showCreateDatabaseModal: false,syncingSchema: false,showFeatureModal: false,+ showMissingDatabases: false,});const instance = computed((): Instance => {diff --git a/frontend/src/views/ProjectDetail.vue b/frontend/src/views/ProjectDetail.vueindex 8b0a8583aa..9ac4b1adef 100644--- a/frontend/src/views/ProjectDetail.vue+++ b/frontend/src/views/ProjectDetail.vue@@ -11,6 +11,7 @@v-if="isTenantProject"id="deployment-config":project="project"+ :database-list="databaseList":allow-edit="allowEdit"/><ProjectDatabasesPanel@@ -114,7 +115,9 @@ export default defineComponent({const databaseList = computed(() => {const list = cloneDeep(- databaseStore.getDatabaseListByProjectId(project.value.id)+ databaseStore+ .getDatabaseListByProjectId(project.value.id)+ .filter((db) => db.syncStatus === "OK"));return sortDatabaseList(list, environmentList.value);});