Skip to content

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

Adjust instance table display

天舟da456f06a9ba
diff --git a/frontend/src/components/DatabaseTable.vue b/frontend/src/components/DatabaseTable.vue
index 45144d7ce5..97a71e65a0 100644
--- a/frontend/src/components/DatabaseTable.vue
+++ b/frontend/src/components/DatabaseTable.vue
@@ -8,16 +8,19 @@
@click-row="clickDatabase"
>
<template v-slot:body="{ rowData: database }">
- <BBTableCell :leftPadding="4" class="w-16">
- {{ database.name }}
+ <BBTableCell v-if="showProjectColumn" :leftPadding="4" class="w-16">
+ {{ database.project.key }}
</BBTableCell>
- <BBTableCell v-if="mode != 'PROJECT'" class="w-16">
- {{ projectName(database.project) }}
+ <BBTableCell
+ :leftPadding="showProjectColumn ? undefined : 4"
+ class="w-16"
+ >
+ {{ database.name }}
</BBTableCell>
- <BBTableCell v-if="mode != 'INSTANCE'" class="w-12">
+ <BBTableCell v-if="showEnvironmentColumn" class="w-12">
{{ environmentName(database.instance.environment) }}
</BBTableCell>
- <BBTableCell v-if="mode == 'ALL'" class="w-24">
+ <BBTableCell v-if="showInstanceColumn" class="w-24">
{{ instanceName(database.instance) }}
</BBTableCell>
<BBTableCell class="w-8" v-database-sync-status>
@@ -31,74 +34,96 @@
</template>
<script lang="ts">
-import { PropType } from "vue";
+import { computed, PropType } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
-import { databaseSlug } from "../utils";
+import { databaseSlug, isDBAOrOwner } from "../utils";
import { Database } from "../types";
import { BBTableColumn } from "../bbkit/types";
type Mode = "ALL" | "INSTANCE" | "PROJECT";
-const columnListMap: Map<Mode, BBTableColumn[]> = new Map([
+const columnListMap: Map<Mode | "ALL_HIDE_INSTANCE", BBTableColumn[]> = new Map(
[
- "ALL",
[
- {
- title: "Name",
- },
- {
- title: "Project",
- },
- {
- title: "Environment",
- },
- {
- title: "Instance",
- },
- {
- title: "Sync status",
- },
- {
- title: "Last successful sync",
- },
+ "ALL",
+ [
+ {
+ title: "Project",
+ },
+ {
+ title: "Name",
+ },
+ {
+ title: "Environment",
+ },
+ {
+ title: "Instance",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
],
- ],
- [
- "INSTANCE",
[
- {
- title: "Name",
- },
- {
- title: "Project",
- },
- {
- title: "Sync status",
- },
- {
- title: "Last successful sync",
- },
+ "ALL_HIDE_INSTANCE",
+ [
+ {
+ title: "Project",
+ },
+ {
+ title: "Name",
+ },
+ {
+ title: "Environment",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
+ ],
+ [
+ "INSTANCE",
+ [
+ {
+ title: "Name",
+ },
+ {
+ title: "Project",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
],
- ],
- [
- "PROJECT",
[
- {
- title: "Name",
- },
- {
- title: "Environment",
- },
- {
- title: "Sync status",
- },
- {
- title: "Last successful sync",
- },
+ "PROJECT",
+ [
+ {
+ title: "Name",
+ },
+ {
+ title: "Environment",
+ },
+ {
+ title: "Sync status",
+ },
+ {
+ title: "Last successful sync",
+ },
+ ],
],
- ],
-]);
+ ]
+);
export default {
name: "DatabaseTable",
@@ -125,13 +150,37 @@ export default {
const store = useStore();
const router = useRouter();
+ const currentUser = computed(() => store.getters["auth/currentUser"]());
+
+ const showProjectColumn = computed(() => {
+ return props.mode != "PROJECT";
+ });
+
+ const showEnvironmentColumn = computed(() => {
+ return props.mode != "INSTANCE";
+ });
+
+ const showInstanceColumn = computed(() => {
+ return props.mode == "ALL" && isDBAOrOwner(currentUser.value.role);
+ });
+
+ const columnList = computed(() => {
+ if (props.mode == "ALL" && !showInstanceColumn.value) {
+ return columnListMap.get("ALL_HIDE_INSTANCE");
+ }
+ return columnListMap.get(props.mode);
+ });
+
const clickDatabase = function (section: number, row: number) {
const database = props.databaseList[row];
router.push(`/db/${databaseSlug(database)}`);
};
return {
- columnList: columnListMap.get(props.mode),
+ showProjectColumn,
+ showEnvironmentColumn,
+ showInstanceColumn,
+ columnList,
clickDatabase,
};
},