Skip to content

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

merge head

spinningbot7e40a432480a
diff --cc frontend/src/views/DatabaseDetail.vue
index 955a232cb6,95095e7073..c42c8d04af
--- a/frontend/src/views/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail.vue
@@@ -184,40 -367,32 +186,40 @@@
</template>
<script lang="ts">
-import { computed, reactive, watchEffect } from "vue";
+import { computed, onMounted, reactive, watch } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
-import DataSourceTable from "../components/DataSourceTable.vue";
-import DataSourceConnectionPanel from "../components/DataSourceConnectionPanel.vue";
-import TableTable from "../components/TableTable.vue";
-import MigrationHistoryTable from "../components/MigrationHistoryTable.vue";
import MemberSelect from "../components/MemberSelect.vue";
import ProjectSelect from "../components/ProjectSelect.vue";
-import { consoleLink, idFromSlug, instanceSlug, isDBAOrOwner } from "../utils";
+import DatabaseOverviewPanel from "../components/DatabaseOverviewPanel.vue";
+import {
- databaseConsoleLink,
++ consoleLink,
+ idFromSlug,
+ instanceSlug,
+ isDBAOrOwner,
+} from "../utils";
import {
- DataSource,
ProjectId,
- DataSourcePatch,
UNKNOWN_ID,
DEFAULT_PROJECT_ID,
- MigrationSchemaStatus,
- InstanceMigration,
} from "../types";
-import { cloneDeep, isEmpty, isEqual } from "lodash";
+import { isEmpty } from "lodash";
+
+const OVERVIEW_TAB = 0;
+
+type DatabaseTabItem = {
+ name: string;
+ hash: string;
+};
+
+const databaseTabItemList: DatabaseTabItem[] = [
+ { name: "Overview", hash: "overview" },
+];
interface LocalState {
- editingDataSource?: DataSource;
showModal: boolean;
editingProjectId: ProjectId;
- migrationSetupStatus: MigrationSchemaStatus;
+ selectedIndex: number;
}
export default {
@@@ -251,12 -429,36 +253,11 @@@
);
});
- const consoleLink = computed(() => {
- const consoleURL = store.getters["setting/settingByName"](
- "bb.console.database"
- ).value;
- const prepareTableList = () => {
- store.dispatch(
- "table/fetchTableListByDatabaseId",
- idFromSlug(props.databaseSlug)
- );
- };
-
- watchEffect(prepareTableList);
-
- const prepareMigrationHistoryList = () => {
- store
- .dispatch("instance/checkMigrationSetup", database.value.instance.id)
- .then((migration: InstanceMigration) => {
- state.migrationSetupStatus = migration.status;
- if (state.migrationSetupStatus == "OK") {
- store.dispatch("instance/migrationHistory", {
- instanceId: database.value.instance.id,
- databaseName: database.value.name,
- });
- }
- });
- };
-
- watchEffect(prepareMigrationHistoryList);
-
+ const databaseConsoleLink = computed(() => {
+ const consoleURL =
+ store.getters["setting/settingByName"]("bb.console.url").value;
if (!isEmpty(consoleURL)) {
- return databaseConsoleLink(consoleURL, database.value.name, "");
+ return consoleLink(consoleURL, database.value.name);
}
return "";
});
@@@ -311,53 -572,70 +312,53 @@@
});
};
- const isEditingDataSource = (dataSource: DataSource) => {
- return (
- state.editingDataSource && state.editingDataSource.id == dataSource.id
- );
+ const selectTab = (index: number) => {
+ state.selectedIndex = index;
- router.replace({
++ router.resolve({
+ name: "workspace.database.detail",
+ hash: "#" + databaseTabItemList[index].hash,
+ });
};
- const allowSaveDataSource = computed(() => {
- for (const dataSource of dataSourceList.value) {
- if (dataSource.id == state.editingDataSource!.id) {
- return !isEqual(dataSource, state.editingDataSource);
+ const selectDatabaseTabOnHash = () => {
+ if (router.currentRoute.value.hash) {
+ for (let i = 0; i < databaseTabItemList.length; i++) {
+ if (
+ databaseTabItemList[i].hash ==
+ router.currentRoute.value.hash.slice(1)
+ ) {
+ selectTab(i);
+ break;
+ }
}
+ } else {
+ selectTab(OVERVIEW_TAB);
}
- return false;
- });
-
- const editDataSource = (dataSource: DataSource) => {
- state.editingDataSource = cloneDeep(dataSource);
- };
-
- const cancelEditDataSource = () => {
- state.editingDataSource = undefined;
};
- const saveEditDataSource = () => {
- const dataSourcePatch: DataSourcePatch = {
- username: state.editingDataSource?.username,
- password: state.editingDataSource?.password,
- };
- store
- .dispatch("dataSource/patchDataSource", {
- databaseId: state.editingDataSource!.database.id,
- dataSourceId: state.editingDataSource!.id,
- dataSource: dataSourcePatch,
- })
- .then(() => {
- state.editingDataSource = undefined;
- });
- };
+ onMounted(() => {
+ selectDatabaseTabOnHash();
+ });
- const configInstance = () => {
- router.push(`/instance/${instanceSlug(database.value.instance)}`);
- };
+ watch(
+ () => router.currentRoute.value.hash,
+ () => {
+ if (router.currentRoute.value.name == "workspace.database.detail") {
+ selectDatabaseTabOnHash();
+ }
+ }
+ );
return {
+ OVERVIEW_TAB,
state,
database,
- consoleLink,
- tableList,
- attentionTitle,
- migrationHistoryList,
+ databaseConsoleLink,
- hasDataSourceFeature,
allowChangeProject,
- allowViewDataSource,
- allowChangeDataSource,
- readWriteDataSourceList,
- readonlyDataSourceList,
tryTransferProject,
updateProject,
- isEditingDataSource,
- allowSaveDataSource,
- editDataSource,
- cancelEditDataSource,
- saveEditDataSource,
- configInstance,
+ selectTab,
+ databaseTabItemList,
};
},
};