Skip to content

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

chore: add change menu to db group table (#13557)

boojackfff97655141b
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupDataTable.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupDataTable.vue
index 645c920608..700908b976 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupDataTable.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupDataTable.vue
@@ -7,26 +7,26 @@
:bordered="bordered"
:loading="loading"
:row-key="(data: ComposedDatabaseGroup) => data.name"
- :checked-row-keys="Array.from(state.selectedDatabaseGroupNameList)"
:row-props="rowProps"
:pagination="{ pageSize: 20 }"
:paginate-single-page="false"
- @update:checked-row-keys="
- (val) => (state.selectedDatabaseGroupNameList = new Set(val as string[]))
- "
- ></NDataTable>
+ />
</template>
<script lang="tsx" setup>
-import { NButton, NDataTable, NTag, type DataTableColumn } from "naive-ui";
-import { computed, reactive, watch } from "vue";
+import {
+ NButton,
+ NDataTable,
+ NTag,
+ NDropdown,
+ type DataTableColumn,
+} from "naive-ui";
+import { computed } from "vue";
import { useI18n } from "vue-i18n";
+import { useRouter } from "vue-router";
import type { ComposedDatabaseGroup } from "@/types";
-
-interface LocalState {
- // The selected database group name list.
- selectedDatabaseGroupNameList: Set<string>;
-}
+import { hasPermissionToCreateChangeDatabaseIssueInProject } from "@/utils";
+import { generateDatabaseGroupIssueRoute } from "@/utils/databaseGroup/issue";
type DatabaseGroupDataTableColumn = DataTableColumn<ComposedDatabaseGroup> & {
hide?: boolean;
@@ -37,14 +37,11 @@ const props = withDefaults(
databaseGroupList: ComposedDatabaseGroup[];
bordered?: boolean;
loading?: boolean;
- showSelection?: boolean;
showProject?: boolean;
- showEdit?: boolean;
customClick?: boolean;
}>(),
{
bordered: true,
- showSelection: true,
showProject: true,
}
);
@@ -60,23 +57,9 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
-const state = reactive<LocalState>({
- selectedDatabaseGroupNameList: new Set(),
-});
+const router = useRouter();
const columnList = computed((): DatabaseGroupDataTableColumn[] => {
- const SELECTION: DatabaseGroupDataTableColumn = {
- type: "selection",
- multiple: false,
- hide: !props.showSelection,
- cellProps: () => {
- return {
- onClick: (e: MouseEvent) => {
- e.stopPropagation();
- },
- };
- },
- };
const NAME: DatabaseGroupDataTableColumn = {
key: "title",
title: t("common.name"),
@@ -102,32 +85,44 @@ const columnList = computed((): DatabaseGroupDataTableColumn[] => {
},
};
const EDIT_BUTTON: DatabaseGroupDataTableColumn = {
- key: "edit",
+ key: "actions",
title: "",
- hide: !props.showEdit,
width: 150,
render: (data) => {
return (
- <div class="flex justify-end">
- <NButton
- size="small"
- onClick={(e) => {
- e.preventDefault();
- e.stopPropagation();
- emit("edit", data);
- }}
+ <div class="flex justify-end gap-2">
+ <NDropdown
+ trigger="hover"
+ options={[
+ {
+ label: `${t("database.edit-schema")} (DDL)`,
+ key: "bb.issue.database.schema.update",
+ },
+ {
+ label: `${t("database.change-data")} (DML)`,
+ key: "bb.issue.database.data.update",
+ },
+ ]}
+ onSelect={(key) => doDatabaseGroupChangeAction(key, data)}
>
- {t("common.configure")}
- </NButton>
+ <NButton
+ size="small"
+ disabled={
+ !hasPermissionToCreateChangeDatabaseIssueInProject(
+ data.projectEntity
+ )
+ }
+ >
+ {t("common.change")}
+ </NButton>
+ </NDropdown>
</div>
);
},
};
// Maybe we can add more columns here. e.g. matched databases, etc.
- return [SELECTION, NAME, PROJECT, EDIT_BUTTON].filter(
- (column) => !column.hide
- );
+ return [NAME, PROJECT, EDIT_BUTTON].filter((column) => !column.hide);
});
const data = computed(() => {
@@ -142,19 +137,15 @@ const rowProps = (databaseGroup: ComposedDatabaseGroup) => {
emit("row-click", e, databaseGroup);
return;
}
-
- state.selectedDatabaseGroupNameList = new Set([databaseGroup.name]);
},
};
};
-watch(
- () => state.selectedDatabaseGroupNameList,
- () => {
- emit(
- "update:selected-database-groups",
- state.selectedDatabaseGroupNameList
- );
- }
-);
+const doDatabaseGroupChangeAction = (
+ key: string,
+ databaseGroup: ComposedDatabaseGroup
+) => {
+ const issueRoute = generateDatabaseGroupIssueRoute(key as any, databaseGroup);
+ router.push(issueRoute);
+};
</script>
diff --git a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue
index 3353f9b602..0c9fd8bca2 100644
--- a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue
+++ b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue
@@ -4,10 +4,10 @@
<DatabaseGroupDataTable
:database-group-list="databaseGroupList"
- :show-edit="allowEdit"
:custom-click="true"
:show-selection="false"
:show-project="false"
+ :loading="isLoading"
@row-click="handleDatabaseGroupClick"
@edit="handleEditDatabaseGroup"
/>
@@ -29,7 +29,7 @@
<script lang="ts" setup>
import { cloneDeep } from "lodash-es";
-import { computed, onMounted, reactive } from "vue";
+import { computed, onMounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";
import DatabaseGroupDataTable from "@/components/DatabaseGroup/DatabaseGroupDataTable.vue";
import { PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL } from "@/router/dashboard/projectV1";
@@ -46,7 +46,6 @@ interface LocalState {
const props = defineProps<{
project: ComposedProject;
- allowEdit: boolean;
}>();
const router = useRouter();
@@ -55,6 +54,7 @@ const state = reactive<LocalState>({
showFeatureModal: false,
showDatabaseGroupPanel: false,
});
+const isLoading = ref(true);
const hasDatabaseGroupFeature = computed(() => {
return hasFeature("bb.feature.database-grouping");
@@ -66,6 +66,7 @@ const databaseGroupList = computed(() => {
onMounted(async () => {
await dbGroupStore.getOrFetchDBGroupListByProjectName(props.project.name);
+ isLoading.value = false;
});
const handleDatabaseGroupClick = (
diff --git a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
index b5e2b475f9..cefc260a3e 100644
--- a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
+++ b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
@@ -1,5 +1,5 @@
<template>
- <ProjectDatabaseGroupPanel :project="project" :allow-edit="allowEdit" />
+ <ProjectDatabaseGroupPanel :project="project" />
</template>
<script setup lang="ts">
@@ -10,7 +10,6 @@ import { projectNamePrefix } from "@/store/modules/v1/common";
const props = defineProps<{
projectId: string;
- allowEdit: boolean;
}>();
const { project } = useProjectByName(