Skip to content

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

Add Section support for BBTable

Tianzhou Chen97097dc01227
diff --git a/frontend/src/bbkit/BBTable/BBTable.vue b/frontend/src/bbkit/BBTable/BBTable.vue
index 8e03db2e42..b0325a587e 100644
--- a/frontend/src/bbkit/BBTable/BBTable.vue
+++ b/frontend/src/bbkit/BBTable/BBTable.vue
@@ -1,6 +1,9 @@
<template>
<div class="border-t border-b border-block-border">
- <table class="min-w-full divide-y divide-block-border">
+ <table
+ class="min-w-full divide-y divide-block-border"
+ :class="backgroundColor"
+ >
<thead v-if="showHeader" class="bg-gray-50">
<tr>
<th
@@ -13,23 +16,58 @@
</th>
</tr>
</thead>
- <tbody class="bg-normal divide-y divide-block-border">
- <tr
- v-for="(item, index) in dataSource"
- :key="index"
- class="cursor-pointer hover:bg-gray-200"
- @click.stop="$emit('click-row', index)"
- >
- <slot name="body" :rowData="item" />
- </tr>
- </tbody>
+
+ <template v-if="sectionDataSource">
+ <template v-for="(section, i) in sectionDataSource" :key="i">
+ <tbody class="bg-normal divide-y divide-block-border">
+ <th
+ :colspan="columnList.length"
+ class="text-left pl-4 pt-4 pb-2 py-text-base leading-6 font-medium text-gray-900"
+ :class="backgroundColor"
+ >
+ {{ section.title }}
+ </th>
+ <template v-if="section.list.length > 0">
+ <tr
+ v-for="(item, j) in section.list"
+ :key="j"
+ class="cursor-pointer hover:bg-gray-200"
+ @click.stop="$emit('click-row', i, j)"
+ >
+ <slot name="body" :rowData="item" />
+ </tr>
+ </template>
+ <template v-else>
+ <tr>
+ <td
+ :colspan="columnList.length"
+ class="text-center text-gray-400 font-normal"
+ >
+ Empty
+ </td>
+ </tr>
+ </template>
+ </tbody>
+ </template>
+ </template>
+ <template v-else>
+ <tbody class="bg-normal divide-y divide-block-border">
+ <tr
+ v-for="(item, index) in dataSource"
+ :key="index"
+ class="cursor-pointer hover:bg-gray-200"
+ @click.stop="$emit('click-row', 0, index)"
+ >
+ <slot name="body" :rowData="item" />
+ </tr></tbody
+ ></template>
</table>
</div>
</template>
<script lang="ts">
-import { computed, reactive, PropType } from "vue";
-import { BBTableColumn } from "../types";
+import { PropType } from "vue";
+import { BBTableColumn, BBTableSectionDataSource } from "../types";
export default {
name: "BBTable",
@@ -41,15 +79,20 @@ export default {
type: Object as PropType<BBTableColumn[]>,
},
dataSource: {
- default: function () {
- return new Array();
- },
+ default: new Array(),
type: Object as PropType<Object[]>,
},
+ sectionDataSource: {
+ type: Object as PropType<BBTableSectionDataSource<Object>[]>,
+ },
showHeader: {
default: true,
type: Boolean,
},
+ backgroundColor: {
+ default: "bg-white",
+ type: String,
+ },
},
setup(props, ctx) {},
};
diff --git a/frontend/src/bbkit/types.ts b/frontend/src/bbkit/types.ts
index 72f037c0cc..49b34804cb 100644
--- a/frontend/src/bbkit/types.ts
+++ b/frontend/src/bbkit/types.ts
@@ -2,6 +2,11 @@ export type BBTableColumn = {
title: string;
};
+export type BBTableSectionDataSource<T> = {
+ title: string;
+ list: T[];
+};
+
export type BBStepStatus =
| "CREATED"
| "RUNNING"