Skip to content

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

Add v-data-source-type directive to convert datasource type to readable text

天舟d558c21dbc85
diff --git a/frontend/src/components/DataSourceTable.vue b/frontend/src/components/DataSourceTable.vue
index 3aa0742bb5..d01d494b79 100644
--- a/frontend/src/components/DataSourceTable.vue
+++ b/frontend/src/components/DataSourceTable.vue
@@ -33,7 +33,7 @@
<BBTableCell :leftPadding="4">
<span class="">{{ dataSource.name }}</span>
</BBTableCell>
- <BBTableCell>
+ <BBTableCell v-data-source-type>
{{ dataSource.type }}
</BBTableCell>
<BBTableCell>
diff --git a/frontend/src/directives/data-source-type.ts b/frontend/src/directives/data-source-type.ts
new file mode 100644
index 0000000000..5015267527
--- /dev/null
+++ b/frontend/src/directives/data-source-type.ts
@@ -0,0 +1,14 @@
+import { DataSourceType } from "../types";
+
+const directive = {
+ beforeMount(el: HTMLElement) {
+ const dataSourceType = el.innerText as DataSourceType;
+ if (dataSourceType == "RO") {
+ el.innerText = "Read Only";
+ } else if (dataSourceType == "RW") {
+ el.innerText = "Read & Write";
+ }
+ },
+};
+
+export default directive;
diff --git a/frontend/src/main.js b/frontend/src/main.js
index 3e16f825e8..b605a91241 100644
--- a/frontend/src/main.js
+++ b/frontend/src/main.js
@@ -24,6 +24,7 @@ import {
BBTableSearch,
BBTableTabFilter,
} from "./bbkit";
+import dataSourceType from "./directives/data-source-type";
import { isDemo, isDevOrDemo, humanizeTs, sizeToFit } from "./utils";
if (isDevOrDemo()) {
@@ -46,6 +47,7 @@ app
// The normal hljs.initHighlightingOnLoad() won't work because router change would cause vue
// to re-render the page and remove the event listener required for
.directive("highlight", highlight)
+ .directive("data-source-type", dataSourceType)
.use(store)
.use(router)
.component("BBAlert", BBAlert)
diff --git a/frontend/src/views/DataSourceDetail.vue b/frontend/src/views/DataSourceDetail.vue
index c3620719c5..2b465ec079 100644
--- a/frontend/src/views/DataSourceDetail.vue
+++ b/frontend/src/views/DataSourceDetail.vue
@@ -36,7 +36,8 @@
<div>
<div class="flex items-center">
<h1 class="text-xl font-bold leading-7 text-main truncate">
- {{ dataSource.name }} - {{ dataSource.type }}
+ {{ dataSource.name }} -
+ <span v-data-source-type>{{ dataSource.type }}</span>
</h1>
</div>
<dl class="flex flex-col mt-2 sm:flex-row sm:flex-wrap">