Skip to content

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

chore: use NDataTable instead of BBGrid (#16277)

boojackdab1cc915686
diff --git a/frontend/src/assets/css/tailwind.css b/frontend/src/assets/css/tailwind.css
index d3b8cd8449..b36618c3bd 100644
--- a/frontend/src/assets/css/tailwind.css
+++ b/frontend/src/assets/css/tailwind.css
@@ -80,43 +80,6 @@
@tailwind components;
@tailwind utilities;
-@layer components {
- .bb-grid {
- @apply grid border-block-border;
- }
- .bb-grid-row {
- @apply contents;
- }
- .bb-grid-header-cell {
- @apply flex items-center bg-gray-50 text-left text-xs font-medium text-gray-500 tracking-wider;
- }
- .bb-grid:not(.compact) .bb-grid-header-cell {
- @apply px-2 py-2;
- @apply first:pl-4 last:pr-4;
- }
- .bb-grid.compact .bb-grid-header-cell {
- @apply px-1 py-2;
- @apply first:pl-2 last:pr-2;
- }
- .bb-grid-cell {
- @apply border-t border-block-border flex items-center text-sm leading-5 whitespace-pre-wrap break-all;
- }
- .bb-grid:not(.compact) .bb-grid-cell {
- @apply px-2 py-2;
- @apply first:pl-4 last:pr-4;
- }
- .bb-grid.compact .bb-grid-cell {
- @apply px-1 py-2;
- @apply first:pl-2 last:pr-2;
- }
- .bb-grid-row.clickable:hover > .bb-grid-cell {
- @apply cursor-pointer bg-gray-100;
- }
- .bb-grid.hide-header .bb-grid-row:first-child .bb-grid-cell {
- @apply border-t-0;
- }
-}
-
.btn-primary {
@apply select-none inline-flex border border-transparent rounded text-accent-text bg-accent hover:bg-accent-hover disabled:bg-accent disabled:opacity-50 disabled:cursor-not-allowed px-4 py-2 text-sm leading-5 font-medium focus:ring-control focus:outline-none focus-visible:ring-2 focus:ring-offset-2;
}
diff --git a/frontend/src/bbkit/BBGrid/BBGrid.vue b/frontend/src/bbkit/BBGrid/BBGrid.vue
deleted file mode 100644
index f552e81524..0000000000
--- a/frontend/src/bbkit/BBGrid/BBGrid.vue
+++ /dev/null
@@ -1,164 +0,0 @@
-<template>
- <div
- role="table"
- class="bb-grid border-block-border"
- :class="[showHeader ? 'show-header' : 'hide-header', gridClass]"
- v-bind="$attrs"
- >
- <template v-if="customHeader">
- <slot name="header" />
- </template>
- <div
- v-else-if="showHeader"
- role="table-row"
- class="bb-grid-row bb-grid-header-row group"
- >
- <div
- v-for="(column, i) in columnList"
- :key="i"
- role="table-cell"
- class="bb-grid-header-cell"
- :class="[headerClass, column.class]"
- >
- {{ column.title }}
- </div>
- </div>
-
- <template v-if="ready">
- <template v-for="(item, row) in dataSource" :key="rowKeyOf(item, row)">
- <div
- row="table-row"
- class="bb-grid-row group"
- :class="{
- clickable: rowClickable && isRowClickable(item, row),
- }"
- @click="handleClick(item, 0, row, $event)"
- >
- <slot name="item" :item="item" :row="row" />
- </div>
- <div
- v-if="isRowExpanded(item, row)"
- row="table-row"
- class="bb-grid-row"
- >
- <div
- class="bb-grid-cell"
- :class="expandedRowClass"
- :style="{
- gridColumnStart: 1,
- gridColumnEnd: columnList.length + 1,
- }"
- >
- <slot name="expanded-item" :item="item" :row="row" />
- </div>
- </div>
- </template>
- </template>
-
- <slot name="placeholder">
- <div
- v-if="ready && dataSource.length === 0 && showPlaceholder"
- class="flex flex-col items-center justify-center text-control-placeholder border-t"
- :style="{
- 'grid-column': `auto / span ${columnList.length}`,
- }"
- >
- <slot name="placeholder-content">
- <p class="py-8">{{ $t("common.no-data") }}</p>
- </slot>
- </div>
- </slot>
- <slot name="loading">
- <div
- v-if="!ready"
- class="flex flex-col items-center justify-center text-control-placeholder border-t"
- :style="{
- 'grid-column': `auto / span ${columnList.length}`,
- }"
- >
- <p class="py-8">
- <BBSpin />
- </p>
- </div>
- </slot>
- </div>
-
- <slot name="footer" />
-</template>
-
-<script lang="ts" setup>
-import { computed } from "vue";
-import type { VueClass } from "@/utils";
-import type { BBGridColumn } from "../types";
-import { useResponsiveGridColumns } from "./useResponsiveGridColumns";
-import BBSpin from "../BBSpin.vue";
-
-type DataType = any; // vue does not support generic typed components yet
-
-const emit = defineEmits<{
- (
- event: "click-row",
- item: DataType,
- section: number,
- row: number,
- e: MouseEvent
- ): void;
-}>();
-
-const props = withDefaults(
- defineProps<{
- columnList?: BBGridColumn[];
- dataSource?: DataType[];
- rowKey?: string | ((item: DataType, row: number) => any);
- showHeader?: boolean;
- customHeader?: boolean;
- headerClass?: VueClass;
- rowClickable?: boolean;
- showPlaceholder?: boolean;
- ready?: boolean;
- isRowExpanded?: (item: DataType, row: number) => boolean;
- isRowClickable?: (item: DataType, row: number) => boolean;
- expandedRowClass?: VueClass;
- }>(),
- {
- columnList: () => [],
- dataSource: () => [],
- rowKey: undefined,
- showHeader: true,
- customHeader: false,
- headerClass: undefined,
- rowClickable: true,
- showPlaceholder: false,
- ready: true,
- isRowExpanded: () => false,
- isRowClickable: () => true,
- expandedRowClass: undefined,
- }
-);
-
-const gridClass = useResponsiveGridColumns(
- computed(() => props.columnList.map((col) => col.width))
-);
-
-const rowKeyOf = (item: DataType, row: number) => {
- const { rowKey } = props;
- if (typeof rowKey === "function") {
- return rowKey(item, row);
- }
- if (typeof rowKey === "string") {
- return item[rowKey];
- }
- return row;
-};
-
-const handleClick = (
- item: DataType,
- section: number,
- row: number,
- e: MouseEvent
-) => {
- if (props.rowClickable && props.isRowClickable(item, row)) {
- emit("click-row", item, section, row, e);
- }
-};
-</script>
diff --git a/frontend/src/bbkit/BBGrid/index.ts b/frontend/src/bbkit/BBGrid/index.ts
deleted file mode 100644
index dcdf6d5f87..0000000000
--- a/frontend/src/bbkit/BBGrid/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-import BBGrid from "./BBGrid.vue";
-
-export * from "./useResponsiveGridColumns";
-
-export { BBGrid };
diff --git a/frontend/src/bbkit/BBGrid/useResponsiveGridColumns.ts b/frontend/src/bbkit/BBGrid/useResponsiveGridColumns.ts
deleted file mode 100644
index 113f989822..0000000000
--- a/frontend/src/bbkit/BBGrid/useResponsiveGridColumns.ts
+++ /dev/null
@@ -1,93 +0,0 @@
-import { useStyleTag } from "@vueuse/core";
-import { uniqueId } from "lodash-es";
-import { computed, onUnmounted, unref } from "vue";
-import type { MaybeRef } from "@/types";
-
-const breakpoints = {
- default: "0",
- sm: "640px",
- md: "768px",
- lg: "1024px",
- xl: "1280px",
- "2xl": "1536px",
- "3xl": "1920px",
- "4xl": "2160px",
-} as const;
-
-export type ScreenSize = keyof typeof breakpoints;
-export type ColumnWidth = string | Partial<{ [S in ScreenSize]: string }>;
-
-const screenSizes = Object.keys(breakpoints) as ScreenSize[];
-
-export const useResponsiveGridColumns = (widths: MaybeRef<ColumnWidth[]>) => {
- const className = `${uniqueId("bb-responsive-grid-columns-")}`;
- const css = computed(() => {
- const _widths = unref(widths);
- const rules = screenSizes
- .map((screen) => {
- if (_widths.some((width) => isDefinedScreen(width, screen))) {
- return generateCSS(className, _widths, screen);
- }
- return "";
- })
- .join("");
-
- return rules;
- });
- const tag = useStyleTag(css);
- onUnmounted(() => tag.unload());
- return className;
-};
-
-const isDefinedScreen = (width: ColumnWidth, screen: ScreenSize) => {
- if (typeof width === "string") {
- return screen === "default";
- }
-
- return typeof width[screen] === "string";
-};
-
-const generateGridTemplateColumns = (
- widths: ColumnWidth[],
- screen: ScreenSize
-) => {
- return widths
- .map((width) => getColumnWidthByScreen(width, screen))
- .filter((value) => value !== "")
- .join(" ");
-};
-
-const generateCSS = (
- className: string,
- widths: ColumnWidth[],
- screen: ScreenSize
-) => {
- const styleValue = generateGridTemplateColumns(widths, screen);
- const rule = `.${className}{grid-template-columns:${styleValue};}`;
- if (screen === "default") {
- return rule;
- } else {
- const size = breakpoints[screen];
- return `@media (min-width: ${size}) { ${rule} }`;
- }
-};
-
-const getColumnWidthByScreen = (target: ColumnWidth, screen: ScreenSize) => {
- if (typeof target === "string") {
- return target;
- }
- const index = screenSizes.indexOf(screen);
- if (index < 0) {
- throw new Error(`unexpected screen size "${screen}"`);
- }
-
- for (let i = index; i >= 0; i--) {
- const s = screenSizes[i];
- const value = target[s];
- if (typeof value === "string") {
- return value;
- }
- }
-
- return "";
-};
diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.ts
index 8c61a97b11..e492aacabf 100644
--- a/frontend/src/bbkit/index.ts
+++ b/frontend/src/bbkit/index.ts
@@ -4,7 +4,6 @@ import BBAvatar from "./BBAvatar.vue";
import BBBadge from "./BBBadge.vue";
import BBBetaBadge from "./BBBetaBadge.vue";
import BBButtonConfirm from "./BBButtonConfirm.vue";
-import { BBGrid } from "./BBGrid";
import BBModal from "./BBModal.vue";
import BBSpin from "./BBSpin.vue";
import BBTextField from "./BBTextField.vue";
@@ -18,7 +17,6 @@ export {
BBButtonConfirm,
BBModal,
BBSpin,
- BBGrid,
BBTextField,
BBBadge,
BBBetaBadge,
diff --git a/frontend/src/bbkit/types.ts b/frontend/src/bbkit/types.ts
index e381aa357f..df5ca0d759 100644
--- a/frontend/src/bbkit/types.ts
+++ b/frontend/src/bbkit/types.ts
@@ -1,6 +1,3 @@
-import type { VueClass } from "@/utils";
-import type { ColumnWidth } from "./BBGrid";
-
export type BBButtonType =
| "NORMAL"
| "PRIMARY"
@@ -10,17 +7,6 @@ export type BBButtonType =
export type BBButtonConfirmType = "NORMAL" | "DELETE" | "ARCHIVE" | "RESTORE";
-export type BBGridColumn = {
- title?: string;
- width: ColumnWidth;
- class?: VueClass;
-};
-
-export type BBGridRow<T = any> = {
- item: T;
- row: number;
-};
-
export type BBTabItem<T = any> = {
title: string;
// Used as the anchor
diff --git a/frontend/src/components/Changelist/ChangelistDetail/ChangeTable/ChangeTable.vue b/frontend/src/components/Changelist/ChangelistDetail/ChangeTable/ChangeTable.vue
index 1eed0d5b4b..cc1120f074 100644
--- a/frontend/src/components/Changelist/ChangelistDetail/ChangeTable/ChangeTable.vue
+++ b/frontend/src/components/Changelist/ChangelistDetail/ChangeTable/ChangeTable.vue
@@ -1,43 +1,19 @@
<template>
- <BBGrid
- :data-source="changes"
- :column-list="columns"
- :show-placeholder="true"
- :row-clickable="true"
- class="border"
- @click-row="handleClickRow"
- >
- <template #item="{ item: change, row }: BBGridRow<Change>">
- <div v-if="reorderMode" class="bb-grid-cell justify-center gap-x-1">
- <ReorderButtons
- v-if="reorderMode"
- :row="row"
- :changes="changes"
- @move="$emit('reorder-move', row, $event)"
- />
- </div>
- <div class="bb-grid-cell">
- <Source :change="change" />
- </div>
-
- <div class="bb-grid-cell">
- <DatabaseForChange :change="change" />
- </div>
- <div class="bb-grid-cell">
- <SQL :change="change" />
- </div>
- <div class="bb-grid-cell">
- <RemoveChangeButton @click="$emit('remove-change', change)" />
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="changes"
+ :striped="true"
+ :bordered="true"
+ :row-props="getRowProps"
+ />
</template>
-<script setup lang="ts">
+<script setup lang="tsx">
+import { NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import type { BBGridColumn, BBGridRow } from "@/bbkit";
-import { BBGrid } from "@/bbkit";
import type { Changelist_Change as Change } from "@/types/proto/v1/changelist_service";
import DatabaseForChange from "./DatabaseForChange.vue";
import RemoveChangeButton from "./RemoveChangeButton.vue";
@@ -58,28 +34,63 @@ const emit = defineEmits<{
const { t } = useI18n();
-const columns = computed((): BBGridColumn[] => {
- const columns: BBGridColumn[] = [
- { title: t("changelist.change-source.source"), width: "auto" },
- { title: t("common.database"), width: "1fr" },
- { title: t("common.sql"), width: "3fr" },
- {
- title: "",
- width: "6rem",
- },
- ];
+const columns = computed((): DataTableColumn<Change>[] => {
+ const cols: DataTableColumn<Change>[] = [];
+
if (props.reorderMode) {
- columns.unshift({
+ cols.push({
title: "",
- width: "4rem",
- class: "justify-center",
+ key: "reorder",
+ width: 64,
+ align: "center",
+ render: (change, index) => (
+ <div class="flex justify-center gap-x-1">
+ <ReorderButtons
+ row={index}
+ changes={props.changes}
+ onMove={(delta: -1 | 1) => emit("reorder-move", index, delta)}
+ />
+ </div>
+ ),
});
}
- return columns;
+ cols.push(
+ {
+ title: t("changelist.change-source.source"),
+ key: "source",
+ width: 120,
+ render: (change) => <Source change={change} />,
+ },
+ {
+ title: t("common.database"),
+ key: "database",
+ render: (change) => <DatabaseForChange change={change} />,
+ },
+ {
+ title: t("common.sql"),
+ key: "sql",
+ render: (change) => <SQL change={change} />,
+ },
+ {
+ title: "",
+ key: "operations",
+ width: 96,
+ render: (change) => (
+ <RemoveChangeButton onClick={() => emit("remove-change", change)} />
+ ),
+ }
+ );
+
+ return cols;
});
-const handleClickRow = (item: Change) => {
- emit("select-change", item);
+const getRowProps = (change: Change) => {
+ return {
+ style: "cursor: pointer;",
+ onClick: () => {
+ emit("select-change", change);
+ },
+ };
};
</script>
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowTable.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowTable.vue
index 34d90e9914..83d5e371e0 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/FlowTable.vue
@@ -1,48 +1,12 @@
<template>
- <BBGrid
- class="border w-full"
- :column-list="COLUMN_LIST"
- :data-source="store.config.rules"
- :row-clickable="false"
- :show-placeholder="true"
- row-key="uid"
- v-bind="$attrs"
- >
- <template #item="{ item: rule }: { item: LocalApprovalRule }">
- <div class="bb-grid-cell whitespace-nowrap">
- {{ rule.template?.title }}
- </div>
- <div class="bb-grid-cell justify-center">
- <NButton
- quaternary
- size="small"
- type="info"
- class="!rounded !w-[var(--n-height)] !p-0"
- @click="state.viewFlow = rule.template.flow"
- >
- {{ rule.template.flow?.steps.length }}
- </NButton>
- </div>
- <div class="bb-grid-cell">
- {{ rule.template?.description }}
- </div>
- <div class="bb-grid-cell gap-x-2">
- <template>
- <NButton size="small" @click="editApprovalTemplate(rule)">
- {{ allowAdmin ? $t("common.edit") : $t("common.view") }}
- </NButton>
- <SpinnerButton
- size="small"
- :tooltip="$t('custom-approval.approval-flow.delete')"
- :disabled="!allowAdmin"
- :on-confirm="() => deleteRule(rule)"
- >
- {{ $t("common.delete") }}
- </SpinnerButton>
- </template>
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="store.config.rules"
+ :striped="true"
+ :bordered="true"
+ :row-key="(rule: LocalApprovalRule) => rule.uid"
+ />
<BBModal
v-if="state.viewFlow"
@@ -55,11 +19,12 @@
</BBModal>
</template>
-<script lang="ts" setup>
-import { NButton } from "naive-ui";
+<script lang="tsx" setup>
+import { NButton, NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
-import { BBGrid, BBModal, type BBGridColumn } from "@/bbkit";
+import { BBModal } from "@/bbkit";
import { pushNotification, useWorkspaceApprovalSettingStore } from "@/store";
import type { LocalApprovalRule } from "@/types";
import type { ApprovalFlow } from "@/types/proto/v1/issue_service";
@@ -79,22 +44,58 @@ const store = useWorkspaceApprovalSettingStore();
const context = useCustomApprovalContext();
const { hasFeature, showFeatureModal, allowAdmin, dialog } = context;
-const COLUMN_LIST = computed(() => {
- const columns: BBGridColumn[] = [
- { title: t("common.name"), width: "1fr" },
+const columns = computed((): DataTableColumn<LocalApprovalRule>[] => {
+ return [
+ {
+ title: t("common.name"),
+ key: "name",
+ render: (rule) => (
+ <div class="whitespace-nowrap">{rule.template?.title}</div>
+ ),
+ },
{
title: t("custom-approval.approval-flow.approval-nodes"),
- width: "6rem",
- class: "justify-center text-center whitespace-pre-wrap capitalize",
+ key: "nodes",
+ width: 120,
+ align: "center",
+ render: (rule) => (
+ <NButton
+ quaternary
+ size="small"
+ type="info"
+ class="!rounded !w-[var(--n-height)] !p-0"
+ onClick={() => (state.viewFlow = rule.template.flow)}
+ >
+ {rule.template.flow?.steps.length}
+ </NButton>
+ ),
+ },
+ {
+ title: t("common.description"),
+ key: "description",
+ render: (rule) => rule.template?.description,
},
- { title: t("common.description"), width: "2fr" },
{
title: t("common.operations"),
- width: "10rem",
+ key: "operations",
+ width: 200,
+ render: (rule) => (
+ <div class="flex gap-x-2">
+ <NButton size="small" onClick={() => editApprovalTemplate(rule)}>
+ {allowAdmin.value ? t("common.edit") : t("common.view")}
+ </NButton>
+ <SpinnerButton
+ size="small"
+ tooltip={t("custom-approval.approval-flow.delete")}
+ disabled={!allowAdmin.value}
+ onConfirm={() => deleteRule(rule)}
+ >
+ {t("common.delete")}
+ </SpinnerButton>
+ </div>
+ ),
},
];
-
- return columns;
});
const editApprovalTemplate = (rule: LocalApprovalRule) => {
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
index 62a18a9fdc..143627d9ae 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/RulesPanel/RulesSection.vue
@@ -6,36 +6,23 @@
</div>
</div>
<div>
- <BBGrid
- :column-list="COLUMNS"
- :data-source="rows"
- :row-clickable="false"
- row-key="level"
- class="border"
- >
- <template #item="{ item: row }: { item: Row }">
- <div class="bb-grid-cell">
- {{ levelText(row.level) }}
- </div>
- <div class="bb-grid-cell flex items-center space-x-2">
- <RuleSelect
- class="flex-1 max-w-md min-w-[10rem]"
- :value="row.rule"
- :link="true"
- :on-update="(rule) => updateRow(row, rule)"
- />
- <RiskTips :level="row.level" :source="source" :rule="row.rule" />
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="rows"
+ :striped="true"
+ :bordered="true"
+ :row-key="(row: Row) => String(row.level)"
+ />
</div>
</div>
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
+import { NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import { BBGrid, type BBGridColumn } from "@/bbkit";
import { pushNotification, useWorkspaceApprovalSettingStore } from "@/store";
import type { ParsedApprovalRule } from "@/types";
import { DEFAULT_RISK_LEVEL, PresetRiskLevelList } from "@/types";
@@ -58,18 +45,30 @@ const { t } = useI18n();
const store = useWorkspaceApprovalSettingStore();
const context = useCustomApprovalContext();
-const COLUMNS = computed(() => {
- const columns: BBGridColumn[] = [
+const columns = computed((): DataTableColumn<Row>[] => {
+ return [
{
title: t("custom-approval.risk.self"),
- width: "10rem",
+ key: "level",
+ width: 160,
+ render: (row) => levelText(row.level),
},
{
title: t("custom-approval.approval-flow.self"),
- width: "1fr",
+ key: "rule",
+ render: (row) => (
+ <div class="flex items-center space-x-2">
+ <RuleSelect
+ class="flex-1 max-w-md min-w-[10rem]"
+ value={row.rule}
+ link={true}
+ onUpdate={(rule: string | undefined) => updateRow(row, rule)}
+ />
+ <RiskTips level={row.level} source={props.source} rule={row.rule} />
+ </div>
+ ),
},
];
- return columns;
});
const filter = useRiskFilter();
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
index 061d8b2d01..a808a7d163 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/common/StepsTable.vue
@@ -1,75 +1,29 @@
<template>
- <BBGrid
- :column-list="COLUMNS"
- :data-source="steps"
- :row-clickable="false"
- class="border"
- >
- <template #item="{ item: step, row }: { item: ApprovalStep; row: number }">
- <div class="bb-grid-cell justify-center text-center !pl-2">
- {{ row + 1 }}
- </div>
- <div class="bb-grid-cell">
- <RoleSelect
- v-if="editable"
- :suffix="''"
- :value="step.nodes[0]?.role"
- style="width: 80%"
- @update:value="
- (role) => {
- step.nodes[0] = {
- type: ApprovalNode_Type.ANY_IN_GROUP,
- role: role as string,
- };
- $emit('update');
- }
- "
- />
- <template v-else>
- {{ approvalNodeText(step.nodes[0]) }}
- </template>
- </div>
- <div v-if="editable" class="bb-grid-cell gap-x-1">
- <NButton
- :disabled="row === 0 || !allowAdmin"
- size="tiny"
- @click="reorder(step, row, -1)"
- >
- <heroicons:arrow-up />
- </NButton>
- <NButton
- :disabled="row === steps.length - 1 || !allowAdmin"
- size="tiny"
- @click="reorder(step, row, 1)"
- >
- <heroicons:arrow-down />
- </NButton>
- <SpinnerButton
- size="tiny"
- :tooltip="$t('custom-approval.approval-flow.node.delete')"
- :disabled="!allowAdmin"
- :on-confirm="() => removeStep(step, row)"
- >
- <heroicons:trash />
- </SpinnerButton>
- </div>
- </template>
- <template v-if="editable && allowAdmin" #footer>
+ <div>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="steps"
+ :striped="true"
+ :bordered="true"
+ />
+ <div v-if="editable && allowAdmin" class="mt-4">
<NButton @click="addStep">
<template #icon><heroicons:plus /></template>
<span>
{{ $t("custom-approval.approval-flow.node.add") }}
</span>
</NButton>
- </template>
- </BBGrid>
+ </div>
+ </div>
</template>
-<script lang="ts" setup>
-import { NButton } from "naive-ui";
+<script lang="tsx" setup>
+import { ArrowUpIcon, ArrowDownIcon, TrashIcon } from "lucide-vue-next";
+import { NButton, NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import { BBGrid, type BBGridColumn } from "@/bbkit";
import { RoleSelect } from "@/components/v2";
import { PresetRoleType } from "@/types";
import type { ApprovalFlow } from "@/types/proto/v1/issue_service";
@@ -96,19 +50,76 @@ const { t } = useI18n();
const context = useCustomApprovalContext();
const { allowAdmin } = context;
-const COLUMNS = computed(() => {
- const columns: BBGridColumn[] = [
+const columns = computed((): DataTableColumn<ApprovalStep>[] => {
+ const cols: DataTableColumn<ApprovalStep>[] = [
{
title: t("custom-approval.approval-flow.node.order"),
- width: "4rem",
- class: "justify-center !pl-2",
+ key: "order",
+ width: 80,
+ align: "center",
+ render: (_, index) => index + 1,
+ },
+ {
+ title: t("custom-approval.approval-flow.node.approver"),
+ key: "approver",
+ render: (step) => {
+ if (props.editable) {
+ return (
+ <RoleSelect
+ suffix=""
+ value={step.nodes[0]?.role}
+ style="width: 80%"
+ onUpdate:value={(val: string | string[]) => {
+ const role = Array.isArray(val) ? val[0] : val;
+ step.nodes[0] = {
+ type: ApprovalNode_Type.ANY_IN_GROUP,
+ role: role,
+ };
+ emit("update");
+ }}
+ />
+ );
+ }
+ return approvalNodeText(step.nodes[0]);
+ },
},
- { title: t("custom-approval.approval-flow.node.approver"), width: "1fr" },
];
+
if (props.editable) {
- columns.push({ title: t("common.operations"), width: "auto" });
+ cols.push({
+ title: t("common.operations"),
+ key: "operations",
+ width: 200,
+ render: (step, index) => (
+ <div class="flex gap-x-1">
+ <NButton
+ disabled={index === 0 || !allowAdmin.value}
+ size="tiny"
+ onClick={() => reorder(step, index, -1)}
+ >
+ <ArrowUpIcon />
+ </NButton>
+ <NButton
+ disabled={index === steps.value.length - 1 || !allowAdmin.value}
+ size="tiny"
+ onClick={() => reorder(step, index, 1)}
+ >
+ <ArrowDownIcon />
+ </NButton>
+ <SpinnerButton
+ size="tiny"
+ tooltip={t("custom-approval.approval-flow.node.delete")}
+ disabled={!allowAdmin.value}
+ onConfirm={() => removeStep(step, index)}
+ >
+ <TrashIcon />
+ </SpinnerButton>
+ </div>
+ ),
+ });
}
- return columns;
+
+ return cols;
});
const steps = computed(() => {
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue
index e59003b852..77d4d29c6d 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/RuleTemplateTable.vue
@@ -1,25 +1,11 @@
<template>
- <BBGrid
- class="border"
- :column-list="COLUMNS"
- :data-source="filteredTemplateList"
- :row-clickable="false"
- row-key="key"
- >
- <template #item="{ item: tpl }: { item: RuleTemplate }">
- <div class="bb-grid-cell !pl-2 !pr-1 break-normal">
- {{ titleOfTemplate(tpl) }}
- </div>
- <div class="bb-grid-cell gap-x-1 !pl-1 !pr-2">
- <NButton size="tiny" @click="applyTemplate(tpl)">
- {{ $t("custom-approval.risk-rule.template.load") }}
- </NButton>
- <NButton size="tiny" @click="viewTemplate = tpl">
- {{ $t("common.view") }}
- </NButton>
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="filteredTemplateList"
+ :striped="true"
+ :bordered="true"
+ />
<BBModal
v-if="viewTemplate"
@@ -41,11 +27,12 @@
</BBModal>
</template>
-<script lang="ts" setup>
-import { NButton, useDialog } from "naive-ui";
+<script lang="tsx" setup>
+import { NButton, NDataTable, useDialog } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
-import { BBGrid, BBModal, type BBGridColumn } from "@/bbkit";
+import { BBModal } from "@/bbkit";
import type { ConditionGroupExpr } from "@/plugins/cel";
import { buildCELExpr } from "@/plugins/cel";
import { Expr } from "@/types/proto/google/type/expr";
@@ -79,20 +66,29 @@ const templateList = useRuleTemplates();
const viewTemplate = ref<RuleTemplate>();
const nDialog = useDialog();
-const COLUMNS = computed(() => {
- const columns: BBGridColumn[] = [
+const columns = computed((): DataTableColumn<RuleTemplate>[] => {
+ return [
{
title: t("custom-approval.risk-rule.rule-name"),
- width: "1fr",
- class: "!pl-2 !pr-1 !py-0.5",
+ key: "name",
+ render: (tpl) => titleOfTemplate(tpl),
},
{
title: t("common.operations"),
- width: "auto",
- class: "!px-1",
+ key: "operations",
+ width: 200,
+ render: (tpl) => (
+ <div class="flex gap-x-1">
+ <NButton size="tiny" onClick={() => applyTemplate(tpl)}>
+ {t("custom-approval.risk-rule.template.load")}
+ </NButton>
+ <NButton size="tiny" onClick={() => (viewTemplate.value = tpl)}>
+ {t("common.view")}
+ </NButton>
+ </div>
+ ),
},
];
- return columns;
});
const filteredTemplateList = computed(() => {
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskTable.vue b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskTable.vue
index 09382e132e..e3f835ba59 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskTable.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskTable.vue
@@ -1,49 +1,18 @@
<template>
- <BBGrid
- :column-list="COLUMN_LIST"
- :data-source="riskList"
- :row-clickable="false"
- :show-placeholder="true"
- row-key="name"
- class="border"
- >
- <template #item="{ item: risk }: { item: Risk }">
- <div class="bb-grid-cell">
- {{ levelText(risk.level) }}
- </div>
- <div class="bb-grid-cell">
- {{ risk.title }}
- </div>
- <div class="bb-grid-cell justify-center">
- <SpinnerSwitch
- :value="risk.active"
- :disabled="!allowUpdateRisk"
- :on-toggle="(active) => toggleRisk(risk, active)"
- size="small"
- />
- </div>
- <div class="bb-grid-cell gap-x-2">
- <NButton size="small" @click="editRisk(risk)">
- {{ allowUpdateRisk ? $t("common.edit") : $t("common.view") }}
- </NButton>
- <SpinnerButton
- size="small"
- :tooltip="$t('custom-approval.risk-rule.delete')"
- :disabled="!allowDeleteRisk"
- :on-confirm="() => deleteRisk(risk)"
- >
- {{ $t("common.delete") }}
- </SpinnerButton>
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="riskList"
+ :striped="true"
+ :bordered="true"
+ />
</template>
-<script lang="ts" setup>
-import { NButton } from "naive-ui";
+<script lang="tsx" setup>
+import { NButton, NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import { BBGrid, type BBGridColumn } from "@/bbkit";
import { pushNotification, useRiskStore } from "@/store";
import type { Risk } from "@/types/proto/v1/risk_service";
import { hasWorkspacePermissionV2 } from "@/utils";
@@ -58,25 +27,53 @@ const { t } = useI18n();
const context = useRiskCenterContext();
const { hasFeature, showFeatureModal } = context;
-const COLUMN_LIST = computed(() => {
- const columns: BBGridColumn[] = [
+const columns = computed((): DataTableColumn<Risk>[] => {
+ return [
{
title: t("custom-approval.risk-rule.risk.self"),
- width: "6rem",
+ key: "level",
+ width: 120,
+ render: (risk) => levelText(risk.level),
+ },
+ {
+ title: t("common.name"),
+ key: "title",
},
- { title: t("common.name"), width: "1fr" },
{
title: t("custom-approval.risk-rule.active"),
- width: "6rem",
- class: "justify-center",
+ key: "active",
+ width: 120,
+ align: "center",
+ render: (risk) => (
+ <SpinnerSwitch
+ value={risk.active}
+ disabled={!allowUpdateRisk.value}
+ onToggle={(active: boolean) => toggleRisk(risk, active)}
+ size="small"
+ />
+ ),
},
{
title: t("common.operations"),
- width: "10rem",
+ key: "operations",
+ width: 200,
+ render: (risk) => (
+ <div class="flex gap-x-2">
+ <NButton size="small" onClick={() => editRisk(risk)}>
+ {allowUpdateRisk.value ? t("common.edit") : t("common.view")}
+ </NButton>
+ <SpinnerButton
+ size="small"
+ tooltip={t("custom-approval.risk-rule.delete")}
+ disabled={!allowDeleteRisk.value}
+ onConfirm={() => deleteRisk(risk)}
+ >
+ {t("common.delete")}
+ </SpinnerButton>
+ </div>
+ ),
},
];
-
- return columns;
});
const allowUpdateRisk = computed(() => {
diff --git a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
index 5fe1ebbded..602172b559 100644
--- a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
@@ -37,40 +37,14 @@
:instance="database.instanceResource"
/>
<div>
- <BBGrid
- :column-list="COLUMNS"
- :row-clickable="false"
- :ready="ready"
- :show-placeholder="true"
- :data-source="secretList"
- class="border"
- >
- <template #item="{ item: secret }: SecretRow">
- <div class="bb-grid-cell">
- {{ extractSecretName(secret.name) }}
- </div>
- <div class="bb-grid-cell">
- {{ secret.description }}
- </div>
- <div class="bb-grid-cell gap-x-1">
- <NButton
- size="tiny"
- :disabled="!allowEdit"
- @click="showDetail(secret)"
- >
- {{ $t("common.edit") }}
- </NButton>
- <SpinnerButton
- size="tiny"
- :disabled="!allowDelete"
- :tooltip="$t('database.secret.delete-tips')"
- :on-confirm="() => handleDelete(secret)"
- >
- {{ $t("common.delete") }}
- </SpinnerButton>
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="secretList"
+ :loading="!ready"
+ :striped="true"
+ :bordered="true"
+ />
</div>
<Drawer
@@ -192,12 +166,13 @@
/>
</template>
-<script setup lang="ts">
+<script setup lang="tsx">
import { cloneDeep } from "lodash-es";
-import { NButton, NInput } from "naive-ui";
+import { NButton, NInput, NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed, ref, watch, nextTick } from "vue";
import { useI18n } from "vue-i18n";
-import { type BBGridColumn, type BBGridRow, BBGrid, BBSpin } from "@/bbkit";
+import { BBSpin } from "@/bbkit";
import {
FeatureAttention,
FeatureBadge,
@@ -220,8 +195,6 @@ export type Detail = {
errors: string[];
};
-export type SecretRow = BBGridRow<Secret>;
-
const props = defineProps<{
database: ComposedDatabase;
allowEdit: boolean;
@@ -239,22 +212,42 @@ const detail = ref<Detail>();
const showFeatureModal = ref(false);
const subscriptionV1Store = useSubscriptionV1Store();
-const COLUMNS = computed(() => {
- const columns: BBGridColumn[] = [
+const columns = computed((): DataTableColumn<Secret>[] => {
+ return [
{
title: t("common.name"),
- width: "minmax(12rem, 1fr)",
+ key: "name",
+ render: (secret) => extractSecretName(secret.name),
},
{
title: t("common.description"),
- width: "3fr",
+ key: "description",
},
{
title: t("common.operations"),
- width: "8rem",
+ key: "operations",
+ width: 200,
+ render: (secret) => (
+ <div class="flex gap-x-1">
+ <NButton
+ size="tiny"
+ disabled={!props.allowEdit}
+ onClick={() => showDetail(secret)}
+ >
+ {t("common.edit")}
+ </NButton>
+ <SpinnerButton
+ size="tiny"
+ disabled={!props.allowDelete}
+ tooltip={t("database.secret.delete-tips")}
+ onConfirm={() => handleDelete(secret)}
+ >
+ {t("common.delete")}
+ </SpinnerButton>
+ </div>
+ ),
},
];
- return columns;
});
const extractSecretName = (name: string) => {
diff --git a/frontend/src/components/IssueV1/components/GrantRequest/DatabaseResourceTable.vue b/frontend/src/components/IssueV1/components/GrantRequest/DatabaseResourceTable.vue
index d8c976588f..7c1714ad96 100644
--- a/frontend/src/components/IssueV1/components/GrantRequest/DatabaseResourceTable.vue
+++ b/frontend/src/components/IssueV1/components/GrantRequest/DatabaseResourceTable.vue
@@ -1,39 +1,19 @@
<template>
- <BBGrid
- :column-list="COLUMN_LIST"
- :data-source="databaseResourceList"
- :row-clickable="true"
- row-key="name"
- class="border"
- >
- <template #item="{ item }">
- <div class="bb-grid-cell">
- {{ extractDatabaseName(item) }}
- </div>
- <div class="bb-grid-cell">
- <span class="line-clamp-1">{{ extractTableName(item) }}</span>
- </div>
- <div class="bb-grid-cell">
- <EnvironmentV1Name
- :environment="
- extractComposedDatabase(item).effectiveEnvironmentEntity
- "
- />
- </div>
- <div class="bb-grid-cell">
- <InstanceV1Name
- :instance="extractComposedDatabase(item).instanceResource"
- />
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="databaseResourceList"
+ :striped="true"
+ :bordered="true"
+ />
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
+import { NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { watch } from "vue";
import { useI18n } from "vue-i18n";
-import { BBGrid, type BBGridColumn } from "@/bbkit";
import { EnvironmentV1Name, InstanceV1Name } from "@/components/v2";
import { useDatabaseV1Store, batchGetOrFetchDatabases } from "@/store";
import type { DatabaseResource } from "@/types";
@@ -90,17 +70,38 @@ watch(
}
);
-const COLUMN_LIST = computed(() => {
- const columns: BBGridColumn[] = [
- { title: t("common.database"), width: "1fr" },
- { title: t("common.table"), width: "0.5fr" },
+const columns = computed((): DataTableColumn<DatabaseResource>[] => {
+ return [
+ {
+ title: t("common.database"),
+ key: "database",
+ render: (row) => extractDatabaseName(row),
+ },
+ {
+ title: t("common.table"),
+ key: "table",
+ render: (row) => (
+ <span class="line-clamp-1">{extractTableName(row)}</span>
+ ),
+ },
{
title: t("common.environment"),
- width: "0.5fr",
+ key: "environment",
+ render: (row) => (
+ <EnvironmentV1Name
+ environment={extractComposedDatabase(row).effectiveEnvironmentEntity}
+ />
+ ),
+ },
+ {
+ title: t("common.instance"),
+ key: "instance",
+ render: (row) => (
+ <InstanceV1Name
+ instance={extractComposedDatabase(row).instanceResource}
+ />
+ ),
},
- { title: t("common.instance"), width: "1fr" },
];
-
- return columns;
});
</script>
diff --git a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunTable.vue b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunTable.vue
index 07d80832ab..6bd9ba8c6a 100644
--- a/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunTable.vue
+++ b/frontend/src/components/IssueV1/components/TaskRunSection/TaskRunTable.vue
@@ -26,7 +26,6 @@ import { last } from "lodash-es";
import { NButton, type DataTableColumn, NDataTable } from "naive-ui";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
-import type { BBGridRow } from "@/bbkit";
import HumanizeDate from "@/components/misc/HumanizeDate.vue";
import { Drawer, DrawerContent } from "@/components/v2";
import { useSheetV1Store } from "@/store";
@@ -49,8 +48,6 @@ defineOptions({
inheritAttrs: false,
});
-export type TaskRunGridRow = BBGridRow<ComposedTaskRun>;
-
defineProps<{
taskRunList: ComposedTaskRun[];
}>();
@@ -145,15 +142,12 @@ const columnList = computed((): DataTableColumn<ComposedTaskRun>[] => {
key: "actions",
title: "",
width: 60,
- render: (taskRun: ComposedTaskRun) => (
- <NButton
- v-if={shouldShowDetailButton(taskRun)}
- size="tiny"
- onClick={() => showDetail(taskRun)}
- >
- {t("common.detail")}
- </NButton>
- ),
+ render: (taskRun: ComposedTaskRun) =>
+ shouldShowDetailButton(taskRun) ? (
+ <NButton size="tiny" onClick={() => showDetail(taskRun)}>
+ {t("common.detail")}
+ </NButton>
+ ) : null,
},
];
});
diff --git a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
index 40826e824d..01a1d44cba 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberRolePanel/index.vue
@@ -77,88 +77,13 @@
</div>
</NTooltip>
</div>
- <BBGrid
- :column-list="getGridColumns(role.role)"
- :row-clickable="false"
- :data-source="role.singleBindingList"
- class="border"
- >
- <template
- #item="{ item, row }: { item: SingleBinding; row: number }"
- >
- <div class="bb-grid-cell">
- <span
- :class="[
- 'text-blue-600 cursor-pointer hover:opacity-80',
- checkRoleExpired(item) ? 'line-through' : '',
- ]"
- @click="editingBinding = item.rawBinding"
- >
- {{
- item.rawBinding.condition?.title ||
- displayRoleTitle(item.rawBinding.role)
- }}
- </span>
- </div>
- <template
- v-if="isRoleShouldShowDatabaseRelatedColumns(role.role)"
- >
- <div class="bb-grid-cell">
- <span class="shrink-0 mr-1">{{
- extractDatabaseName(item.databaseResource)
- }}</span>
- <template v-if="item.databaseResource">
- <InstanceV1Name
- class="text-gray-500"
- :instance="
- extractDatabase(item.databaseResource)
- .instanceResource
- "
- :link="false"
- />
- </template>
- </div>
- <div class="bb-grid-cell">
- {{ extractSchemaName(item.databaseResource) }}
- </div>
- <div class="bb-grid-cell">
- {{ extractTableName(item.databaseResource) }}
- </div>
- </template>
- <div class="bb-grid-cell flex items-center space-x-1">
- <span :class="checkRoleExpired(item) ? 'line-through' : ''">
- {{ extractExpiration(item.expiration) }}
- </span>
- <RoleExpiredTip v-if="checkRoleExpired(item)" />
- </div>
- <div class="bb-grid-cell">
- <RoleDescription :description="item.description || ''" />
- </div>
- <div class="bb-grid-cell space-x-1">
- <NTooltip trigger="hover">
- <template #trigger>
- <NButton
- tag="div"
- text
- class="cursor-pointer opacity-60 hover:opacity-100"
- :disabled="!allowDeleteCondition(item)"
- @click="handleDeleteCondition(role, row)"
- >
- <heroicons-outline:trash class="w-4 h-4" />
- </NButton>
- </template>
- <template #default>
- <template v-if="!allowDeleteCondition(item)">
- {{ $t("project.members.cannot-remove-last-owner") }}
- </template>
- <template v-else>
- {{ $t("common.delete") }}
- </template>
- </template>
- </NTooltip>
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="getDataTableColumns(role.role)"
+ :data="role.singleBindingList"
+ :striped="true"
+ :bordered="true"
+ />
</template>
</div>
</template>
@@ -208,13 +133,14 @@
/>
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
import { cloneDeep, isEqual } from "lodash-es";
-import { Building2Icon } from "lucide-vue-next";
-import { NButton, NTag, NTooltip, useDialog } from "naive-ui";
+import { Building2Icon, PenIcon, TrashIcon } from "lucide-vue-next";
+import { NButton, NTag, NTooltip, NDataTable, useDialog } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
-import { BBButtonConfirm, BBGrid } from "@/bbkit";
+import { BBButtonConfirm } from "@/bbkit";
import type { MemberBinding } from "@/components/Member/types";
import GroupMemberNameCell from "@/components/User/Settings/UserDataTableByGroup/cells/GroupMemberNameCell.vue";
import GroupNameCell from "@/components/User/Settings/UserDataTableByGroup/cells/GroupNameCell.vue";
@@ -312,48 +238,134 @@ const isRoleShouldShowDatabaseRelatedColumns = (role: string) => {
);
};
-const getGridColumns = (role: string) => {
- const placeholder = {
- title: "",
- width: "2rem",
- };
- const conditionName = {
- title: t("project.members.condition-name"),
- width: "minmax(min-content, auto)",
- };
- const databaseRelatedColumns = [
+const getDataTableColumns = (
+ role: string
+): DataTableColumn<SingleBinding>[] => {
+ const columns: DataTableColumn<SingleBinding>[] = [
{
- title: t("common.database"),
- width: "minmax(min-content, auto)",
+ title: t("project.members.condition-name"),
+ key: "conditionName",
+ render: (singleBinding) => {
+ const conditionTitle = singleBinding.rawBinding.condition?.title;
+ const roleTitle = displayRoleTitle(singleBinding.rawBinding.role);
+ return conditionTitle || roleTitle;
+ },
},
+ ];
+
+ if (isRoleShouldShowDatabaseRelatedColumns(role)) {
+ columns.push(
+ {
+ title: t("common.database"),
+ key: "database",
+ render: (singleBinding) => {
+ const databaseName = extractDatabaseName(
+ singleBinding.databaseResource
+ );
+ if (singleBinding.databaseResource) {
+ const database = extractDatabase(singleBinding.databaseResource);
+ return (
+ <div class="flex items-center gap-x-1">
+ <InstanceV1Name
+ instance={database.instanceResource}
+ link={false}
+ />
+ <span>/</span>
+ <span>{databaseName}</span>
+ </div>
+ );
+ }
+ return databaseName;
+ },
+ },
+ {
+ title: t("common.schema"),
+ key: "schema",
+ render: (singleBinding) =>
+ extractSchemaName(singleBinding.databaseResource),
+ },
+ {
+ title: t("common.table"),
+ key: "table",
+ render: (singleBinding) =>
+ extractTableName(singleBinding.databaseResource),
+ }
+ );
+ }
+
+ columns.push(
{
- title: t("common.schema"),
- width: "minmax(min-content, auto)",
+ title: t("common.expiration"),
+ key: "expiration",
+ render: (singleBinding) => {
+ const content = extractExpiration(singleBinding.expiration);
+ if (checkRoleExpired(singleBinding)) {
+ return <RoleExpiredTip>{content}</RoleExpiredTip>;
+ }
+ return content;
+ },
},
{
- title: t("common.table"),
- width: "minmax(min-content, auto)",
+ title: t("common.description"),
+ key: "description",
+ render: (singleBinding) => (
+ <RoleDescription description={singleBinding.description || ""} />
+ ),
},
- ];
- const expiration = {
- title: t("common.expiration"),
- width: "minmax(min-content, auto)",
- };
- const description = {
- title: t("common.description"),
- width: "minmax(min-content, auto)",
- };
- if (isRoleShouldShowDatabaseRelatedColumns(role)) {
- return [
- conditionName,
- ...databaseRelatedColumns,
- expiration,
- description,
- placeholder,
- ];
- } else {
- return [conditionName, expiration, description, placeholder];
- }
+ {
+ title: "",
+ key: "operations",
+ width: 32,
+ render: (singleBinding) => (
+ <div class="flex justify-end pr-2">
+ <NButton
+ text
+ class="cursor-pointer opacity-60 hover:opacity-100"
+ onClick={() => {
+ editingBinding.value = Binding.fromPartial({
+ role: role,
+ members: [props.binding.binding],
+ condition: singleBinding.rawBinding.condition,
+ parsedExpr: singleBinding.rawBinding.parsedExpr,
+ });
+ }}
+ >
+ <PenIcon class="w-4 h-4" />
+ </NButton>
+ {roleList.value.filter((r) => r.role === role)[0]?.singleBindingList
+ .length > 1 && (
+ <NTooltip
+ disabled={allowDeleteCondition(singleBinding)}
+ v-slots={{
+ trigger: () => (
+ <NButton
+ text
+ class="cursor-pointer opacity-60 hover:opacity-100"
+ disabled={!allowDeleteCondition(singleBinding)}
+ onClick={() => {
+ const item = roleList.value.find((r) => r.role === role);
+ if (item) {
+ const index =
+ item.singleBindingList.indexOf(singleBinding);
+ if (index >= 0) {
+ handleDeleteCondition(item, index);
+ }
+ }
+ }}
+ >
+ <TrashIcon class="w-4 h-4" />
+ </NButton>
+ ),
+ default: () => t("project.members.cannot-remove-last-owner"),
+ }}
+ />
+ )}
+ </div>
+ ),
+ }
+ );
+
+ return columns;
};
// To prevent user accidentally removing roles and lock the project permanently, we take following measures:
diff --git a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
index 265a790e91..072238f7c9 100644
--- a/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
+++ b/frontend/src/components/SchemaTemplate/FieldTemplateTable.vue
@@ -1,74 +1,21 @@
<template>
- <BBGrid
- :column-list="columnList"
- :data-source="templateList"
- :is-row-clickable="isRowClickable"
- class="border"
- @click-row="clickRow"
- >
- <template #item="{ item }: { item: SchemaTemplateSetting_FieldTemplate }">
- <div class="bb-grid-cell">
- {{ item.category || "-" }}
- </div>
- <div class="bb-grid-cell flex justify-start items-center">
- <EngineIcon :engine="item.engine" custom-class="ml-0 mr-1" />
- {{ item.column?.name }}
- </div>
- <div class="bb-grid-cell flex gap-x-1">
- <span v-if="getSemanticType(item.catalog?.semanticType)">
- {{ getSemanticType(item.catalog?.semanticType)?.title }}
- </span>
- <span v-else class="text-control-placeholder italic"> N/A </span>
- </div>
- <div v-if="classificationConfig" class="bb-grid-cell flex gap-x-1">
- <ClassificationLevelBadge
- :classification="item.catalog?.classification"
- :classification-config="classificationConfig"
- />
- </div>
- <div class="bb-grid-cell">
- {{ item.column?.type }}
- </div>
- <div class="bb-grid-cell">
- {{ getColumnDefaultValuePlaceholder(item.column!) }}
- </div>
- <div class="bb-grid-cell">
- {{ item.column?.userComment }}
- </div>
- <div class="bb-grid-cell">
- <DatabaseLabelsCell
- :labels="item.catalog?.labels ?? {}"
- :show-count="2"
- />
- </div>
- <div class="bb-grid-cell flex items-center justify-start gap-x-2">
- <MiniActionButton @click.stop="$emit('view', item)">
- <PencilIcon class="w-4 h-4" />
- </MiniActionButton>
- <NPopconfirm v-if="!readonly" @positive-click="deleteTemplate(item.id)">
- <template #trigger>
- <MiniActionButton tag="div" @click.stop>
- <TrashIcon class="w-4 h-4" />
- </MiniActionButton>
- </template>
- <div class="whitespace-nowrap">
- {{ $t("common.delete") + ` '${item.column?.name}'?` }}
- </div>
- </NPopconfirm>
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="templateList"
+ :striped="true"
+ :bordered="true"
+ :row-props="rowProps"
+ />
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
import { pullAt } from "lodash-es";
-import { PencilIcon } from "lucide-vue-next";
-import { TrashIcon } from "lucide-vue-next";
-import { NPopconfirm } from "naive-ui";
+import { PencilIcon, TrashIcon } from "lucide-vue-next";
+import { NPopconfirm, NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import type { BBGridColumn } from "@/bbkit";
-import { BBGrid } from "@/bbkit";
import { getColumnDefaultValuePlaceholder } from "@/components/SchemaEditorLite";
import { MiniActionButton } from "@/components/v2";
import { DatabaseLabelsCell } from "@/components/v2/Model/DatabaseV1Table/cells";
@@ -94,63 +41,127 @@ const emit = defineEmits<{
const { t } = useI18n();
const settingStore = useSettingV1Store();
-const columnList = computed((): BBGridColumn[] => {
- return [
- {
- title: t("schema-template.form.category"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("schema-template.form.column-name"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("settings.sensitive-data.semantic-types.table.semantic-type"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("schema-template.classification.self"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- hide: !classificationConfig.value,
- },
- {
- title: t("schema-template.form.column-type"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("schema-template.form.default-value"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("schema-template.form.comment"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("common.labels"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("common.operations"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- ].filter((col) => !col.hide);
-});
+const columns = computed(
+ (): DataTableColumn<SchemaTemplateSetting_FieldTemplate>[] => {
+ const cols: DataTableColumn<SchemaTemplateSetting_FieldTemplate>[] = [
+ {
+ title: t("schema-template.form.category"),
+ key: "category",
+ render: (item) => item.category || "-",
+ },
+ {
+ title: t("schema-template.form.column-name"),
+ key: "name",
+ render: (item) => (
+ <div class="flex justify-start items-center">
+ <EngineIcon engine={item.engine} customClass="ml-0 mr-1" />
+ {item.column?.name ?? ""}
+ </div>
+ ),
+ },
+ {
+ title: t("settings.sensitive-data.semantic-types.table.semantic-type"),
+ key: "semanticType",
+ render: (item) => {
+ const semanticType = getSemanticType(item.catalog?.semanticType);
+ if (semanticType) {
+ return semanticType.title;
+ }
+ return <span class="text-control-placeholder italic">N/A</span>;
+ },
+ },
+ ];
-const clickRow = (template: SchemaTemplateSetting_FieldTemplate) => {
- emit("apply", template);
-};
+ if (classificationConfig.value) {
+ cols.push({
+ title: t("schema-template.classification.self"),
+ key: "classification",
+ render: (item) => (
+ <ClassificationLevelBadge
+ classification={item.catalog?.classification}
+ classificationConfig={classificationConfig.value!}
+ />
+ ),
+ });
+ }
-const isRowClickable = (template: SchemaTemplateSetting_FieldTemplate) => {
- return template.engine === props.engine;
+ cols.push(
+ {
+ title: t("schema-template.form.column-type"),
+ key: "type",
+ render: (item) => item.column?.type ?? "",
+ },
+ {
+ title: t("schema-template.form.default-value"),
+ key: "default",
+ render: (item) => getColumnDefaultValuePlaceholder(item.column!),
+ },
+ {
+ title: t("schema-template.form.comment"),
+ key: "comment",
+ render: (item) => item.column?.userComment ?? "",
+ },
+ {
+ title: t("common.labels"),
+ key: "labels",
+ render: (item) => (
+ <DatabaseLabelsCell
+ labels={item.catalog?.labels ?? {}}
+ showCount={2}
+ />
+ ),
+ },
+ {
+ title: t("common.operations"),
+ key: "operations",
+ width: 160,
+ render: (item) => (
+ <div class="flex items-center justify-start gap-x-2">
+ <MiniActionButton
+ onClick={(e: MouseEvent) => {
+ e.stopPropagation();
+ emit("view", item);
+ }}
+ >
+ <PencilIcon class="w-4 h-4" />
+ </MiniActionButton>
+ {!props.readonly && (
+ <NPopconfirm onPositiveClick={() => deleteTemplate(item.id)}>
+ {{
+ trigger: () => (
+ <MiniActionButton
+ onClick={(e: MouseEvent) => e.stopPropagation()}
+ >
+ <TrashIcon class="w-4 h-4" />
+ </MiniActionButton>
+ ),
+ default: () => (
+ <div class="whitespace-nowrap">
+ {t("common.delete")} '{item.column?.name}'?
+ </div>
+ ),
+ }}
+ </NPopconfirm>
+ )}
+ </div>
+ ),
+ }
+ );
+
+ return cols;
+ }
+);
+
+const rowProps = (row: SchemaTemplateSetting_FieldTemplate) => {
+ if (!props.readonly && row.engine === props.engine) {
+ return {
+ style: "cursor: pointer;",
+ onClick: () => {
+ emit("apply", row);
+ },
+ };
+ }
+ return {};
};
const deleteTemplate = async (id: string) => {
diff --git a/frontend/src/components/SchemaTemplate/TableTemplateTable.vue b/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
index a04d64a0da..4d4c78f868 100644
--- a/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
+++ b/frontend/src/components/SchemaTemplate/TableTemplateTable.vue
@@ -1,55 +1,21 @@
<template>
- <BBGrid
- :column-list="columnList"
- :data-source="templateList"
- :is-row-clickable="isRowClickable"
- class="border"
- @click-row="clickRow"
- >
- <template #item="{ item }: { item: SchemaTemplateSetting_TableTemplate }">
- <div class="bb-grid-cell">
- {{ item.category || "-" }}
- </div>
- <div class="bb-grid-cell flex justify-start items-center">
- <EngineIcon :engine="item.engine" custom-class="ml-0 mr-1" />
- {{ item.table?.name }}
- </div>
- <div v-if="classificationConfig" class="bb-grid-cell flex gap-x-1">
- <ClassificationLevelBadge
- :classification="item.catalog?.classification"
- :classification-config="classificationConfig"
- />
- </div>
- <div class="bb-grid-cell">
- {{ item.table?.userComment }}
- </div>
- <div class="bb-grid-cell flex items-center justify-start gap-x-2">
- <MiniActionButton @click.stop="$emit('view', item)">
- <PencilIcon class="w-4 h-4" />
- </MiniActionButton>
- <NPopconfirm v-if="!readonly" @positive-click="deleteTemplate(item.id)">
- <template #trigger>
- <MiniActionButton tag="div" @click.stop>
- <TrashIcon class="w-4 h-4" />
- </MiniActionButton>
- </template>
- <div class="whitespace-nowrap">
- {{ $t("common.delete") + ` '${item.table?.name}'?` }}
- </div>
- </NPopconfirm>
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="templateList"
+ :striped="true"
+ :bordered="true"
+ :row-props="rowProps"
+ />
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
import { pullAt } from "lodash-es";
import { PencilIcon, TrashIcon } from "lucide-vue-next";
-import { NPopconfirm } from "naive-ui";
+import { NPopconfirm, NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import type { BBGridColumn } from "@/bbkit";
-import { BBGrid } from "@/bbkit";
import { MiniActionButton } from "@/components/v2";
import { useSettingV1Store } from "@/store";
import type { Engine } from "@/types/proto/v1/common";
@@ -73,43 +39,96 @@ const emit = defineEmits<{
const { t } = useI18n();
const settingStore = useSettingV1Store();
-const columnList = computed((): BBGridColumn[] => {
- return [
- {
- title: t("schema-template.form.category"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("schema-template.form.table-name"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("schema-template.classification.self"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- hide: !classificationConfig.value,
- },
- {
- title: t("schema-template.form.comment"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- {
- title: t("common.operations"),
- width: "minmax(min-content, auto)",
- class: "capitalize",
- },
- ].filter((col) => !col.hide);
-});
+const columns = computed(
+ (): DataTableColumn<SchemaTemplateSetting_TableTemplate>[] => {
+ const cols: DataTableColumn<SchemaTemplateSetting_TableTemplate>[] = [
+ {
+ title: t("schema-template.form.category"),
+ key: "category",
+ render: (item) => item.category || "-",
+ },
+ {
+ title: t("schema-template.form.table-name"),
+ key: "name",
+ render: (item) => (
+ <div class="flex justify-start items-center">
+ <EngineIcon engine={item.engine} customClass="ml-0 mr-1" />
+ {item.table?.name ?? ""}
+ </div>
+ ),
+ },
+ ];
-const clickRow = (template: SchemaTemplateSetting_TableTemplate) => {
- emit("apply", template);
-};
+ if (classificationConfig.value) {
+ cols.push({
+ title: t("schema-template.classification.self"),
+ key: "classification",
+ render: (item) => (
+ <ClassificationLevelBadge
+ classification={item.catalog?.classification}
+ classificationConfig={classificationConfig.value!}
+ />
+ ),
+ });
+ }
+
+ cols.push(
+ {
+ title: t("schema-template.form.comment"),
+ key: "comment",
+ render: (item) => item.table?.userComment ?? "",
+ },
+ {
+ title: t("common.operations"),
+ key: "operations",
+ width: 160,
+ render: (item) => (
+ <div class="flex items-center justify-start gap-x-2">
+ <MiniActionButton
+ onClick={(e: MouseEvent) => {
+ e.stopPropagation();
+ emit("view", item);
+ }}
+ >
+ <PencilIcon class="w-4 h-4" />
+ </MiniActionButton>
+ {!props.readonly && (
+ <NPopconfirm onPositiveClick={() => deleteTemplate(item.id)}>
+ {{
+ trigger: () => (
+ <MiniActionButton
+ onClick={(e: MouseEvent) => e.stopPropagation()}
+ >
+ <TrashIcon class="w-4 h-4" />
+ </MiniActionButton>
+ ),
+ default: () => (
+ <div class="whitespace-nowrap">
+ {t("common.delete")} '{item.table?.name}'?
+ </div>
+ ),
+ }}
+ </NPopconfirm>
+ )}
+ </div>
+ ),
+ }
+ );
-const isRowClickable = (template: SchemaTemplateSetting_TableTemplate) => {
- return template.engine === props.engine;
+ return cols;
+ }
+);
+
+const rowProps = (row: SchemaTemplateSetting_TableTemplate) => {
+ if (!props.readonly && row.engine === props.engine) {
+ return {
+ style: "cursor: pointer;",
+ onClick: () => {
+ emit("apply", row);
+ },
+ };
+ }
+ return {};
};
const deleteTemplate = async (id: string) => {
diff --git a/frontend/src/components/v2/Model/Instance/InstanceRoleTable/InstanceRoleTable.vue b/frontend/src/components/v2/Model/Instance/InstanceRoleTable/InstanceRoleTable.vue
index 873acd0570..57ab25a961 100644
--- a/frontend/src/components/v2/Model/Instance/InstanceRoleTable/InstanceRoleTable.vue
+++ b/frontend/src/components/v2/Model/Instance/InstanceRoleTable/InstanceRoleTable.vue
@@ -1,27 +1,19 @@
<template>
- <BBGrid
- class="border"
- :column-list="columnList"
- :data-source="instanceRoleList"
- :row-clickable="false"
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="instanceRoleList"
+ :striped="true"
+ :bordered="true"
v-bind="$attrs"
- >
- <template #item="{ item: instanceRole }: { item: InstanceRole }">
- <div class="bb-grid-cell">
- {{ instanceRole.roleName }}
- </div>
- <div class="bb-grid-cell whitespace-pre-wrap break-all">
- {{ (instanceRole.attribute ?? "").replaceAll("\n", "\n\n") }}
- </div>
- </template>
- </BBGrid>
+ />
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
+import { NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
-import type { BBGridColumn } from "@/bbkit";
-import { BBGrid } from "@/bbkit";
import type { InstanceRole } from "@/types/proto/v1/instance_role_service";
defineProps<{
@@ -29,14 +21,21 @@ defineProps<{
}>();
const { t } = useI18n();
-const columnList = computed((): BBGridColumn[] => [
+const columns = computed((): DataTableColumn<InstanceRole>[] => [
{
title: t("common.user"),
- width: "minmax(auto, 12rem)",
+ key: "user",
+ width: 200,
+ render: (instanceRole) => instanceRole.roleName,
},
{
title: t("instance.grants"),
- width: "1fr",
+ key: "grants",
+ render: (instanceRole) => (
+ <div class="whitespace-pre-wrap break-all">
+ {(instanceRole.attribute ?? "").replaceAll("\n", "\n\n")}
+ </div>
+ ),
},
]);
</script>
diff --git a/frontend/src/views/sql-editor/SheetPanel/SheetTable/SheetTable.vue b/frontend/src/views/sql-editor/SheetPanel/SheetTable/SheetTable.vue
index 72e0faf979..aeff9cd21d 100644
--- a/frontend/src/views/sql-editor/SheetPanel/SheetTable/SheetTable.vue
+++ b/frontend/src/views/sql-editor/SheetPanel/SheetTable/SheetTable.vue
@@ -1,43 +1,22 @@
<template>
- <BBGrid
- :column-list="columns"
- :data-source="sortedSheetList"
- :show-placeholder="true"
- :ready="!isLoading"
- row-key="name"
- @click-row="handleSheetClick"
- >
- <template #item="{ item: sheet }: BBGridRow<Worksheet>">
- <!-- eslint-disable-next-line vue/no-v-html -->
- <div class="bb-grid-cell" v-html="titleHTML(sheet)"></div>
- <div class="bb-grid-cell">
- <SheetConnection :sheet="sheet" />
- </div>
- <div class="bb-grid-cell">
- <ProjectV1Name :project="projectForSheet(sheet)" :link="false" />
- </div>
- <div class="bb-grid-cell">
- {{ visibilityDisplayName(sheet.visibility) }}
- </div>
- <div v-if="showCreator" class="bb-grid-cell">
- {{ creatorForSheet(sheet) }}
- </div>
- <div class="bb-grid-cell">
- <HumanizeDate :date="getDateForPbTimestamp(sheet.updateTime)" />
- </div>
- <div class="bb-grid-cell" @click.stop>
- <Dropdown :sheet="sheet" :view="view" />
- </div>
- </template>
- </BBGrid>
+ <NDataTable
+ size="small"
+ :columns="columns"
+ :data="sortedSheetList"
+ :loading="isLoading"
+ :striped="true"
+ :bordered="true"
+ :row-key="(sheet: Worksheet) => sheet.name"
+ :row-props="getRowProps"
+ />
</template>
-<script lang="ts" setup>
+<script lang="tsx" setup>
import { escape, orderBy } from "lodash-es";
+import { NDataTable } from "naive-ui";
+import type { DataTableColumn } from "naive-ui";
import { computed, onMounted } from "vue";
import { useI18n } from "vue-i18n";
-import type { BBGridRow, BBGridColumn } from "@/bbkit";
-import { BBGrid } from "@/bbkit";
import HumanizeDate from "@/components/misc/HumanizeDate.vue";
import { ProjectV1Name } from "@/components/v2";
import { useUserStore, useProjectV1Store } from "@/store";
@@ -72,43 +51,70 @@ const handleSheetClick = (sheet: Worksheet) => {
emit("select-sheet", sheet);
};
-const columns = computed(() => {
- const NAME: BBGridColumn = {
- title: t("common.name"),
- width: "2fr",
- };
- const CONNECTION: BBGridColumn = {
- title: t("sql-editor.sheet.connection"),
- width: "minmax(auto, 2fr)",
- };
- const PROJECT: BBGridColumn = {
- title: t("common.project"),
- width: "minmax(auto, 1fr)",
- };
- const VISIBILITY: BBGridColumn = {
- title: t("common.visibility"),
- width: "minmax(auto, 8rem)",
- };
- const CREATOR: BBGridColumn = {
- title: t("common.creator"),
- width: "minmax(auto, 1fr)",
- };
- const UPDATED: BBGridColumn = {
- title: t("common.updated-at"),
- width: "minmax(auto, 10rem)",
- };
- const OPERATION: BBGridColumn = {
- title: "",
- width: "auto",
- };
- const columns = [NAME, CONNECTION, PROJECT, VISIBILITY];
+const columns = computed((): DataTableColumn<Worksheet>[] => {
+ const cols: DataTableColumn<Worksheet>[] = [
+ {
+ title: t("common.name"),
+ key: "name",
+ render: (sheet) => <div v-html={titleHTML(sheet)} />,
+ },
+ {
+ title: t("sql-editor.sheet.connection"),
+ key: "connection",
+ render: (sheet) => <SheetConnection sheet={sheet} />,
+ },
+ {
+ title: t("common.project"),
+ key: "project",
+ render: (sheet) => (
+ <ProjectV1Name project={projectForSheet(sheet)} link={false} />
+ ),
+ },
+ {
+ title: t("common.visibility"),
+ key: "visibility",
+ width: 150,
+ render: (sheet) => visibilityDisplayName(sheet.visibility),
+ },
+ ];
+
if (showCreator.value) {
- columns.push(CREATOR);
+ cols.push({
+ title: t("common.creator"),
+ key: "creator",
+ render: (sheet) => creatorForSheet(sheet),
+ });
}
- columns.push(UPDATED, OPERATION);
- return columns;
+
+ cols.push(
+ {
+ title: t("common.updated-at"),
+ key: "updatedAt",
+ width: 180,
+ render: (sheet) => (
+ <HumanizeDate date={getDateForPbTimestamp(sheet.updateTime)} />
+ ),
+ },
+ {
+ title: "",
+ key: "operations",
+ width: 50,
+ render: (sheet) => <Dropdown sheet={sheet} view={props.view} />,
+ }
+ );
+
+ return cols;
});
+const getRowProps = (sheet: Worksheet) => {
+ return {
+ style: "cursor: pointer;",
+ onClick: () => {
+ handleSheetClick(sheet);
+ },
+ };
+};
+
const filteredList = computed(() => {
const keyword = props.keyword?.toLowerCase()?.trim();
if (!keyword) return sheetList.value;