Skip to content

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

feat(frontend): custom database label management (#8605)

Liu Ji0ac204e098d8
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index bb978c1240..308c102bfe 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -143,6 +143,7 @@
<YAxisRadioGroup
v-else
v-model:label="state.label"
+ :database-list="databaseList"
class="text-sm m-px"
/>
</template>
diff --git a/frontend/src/components/CreateDatabasePrepForm/DatabaseLabelForm.vue b/frontend/src/components/CreateDatabasePrepForm/DatabaseLabelForm.vue
index 60f29482e3..cbc4c49237 100644
--- a/frontend/src/components/CreateDatabasePrepForm/DatabaseLabelForm.vue
+++ b/frontend/src/components/CreateDatabasePrepForm/DatabaseLabelForm.vue
@@ -6,8 +6,8 @@
v-bind="$attrs"
>
<div class="flex flex-row items-center space-x-1">
- <label for="instance" class="textlabel capitalize">
- {{ hidePrefix(item.label) }}
+ <label for="instance" class="textlabel">
+ {{ displayLabelKey(item.label) }}
<span v-if="item.required" class="text-red-600">*</span>
</label>
</div>
@@ -34,6 +34,7 @@ import {
validateLabelsWithTemplate,
parseLabelListInTemplate,
PRESET_LABEL_KEYS,
+ displayLabelKey,
} from "@/utils";
const props = defineProps<{
diff --git a/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue b/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
index 271e004985..9082eccff2 100644
--- a/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
@@ -1,6 +1,6 @@
<template>
- <div class="flex flex-col">
- <div class="sm:col-span-2 sm:col-start-1 border-b mb-7 pb-7">
+ <div class="flex flex-col divide-y gap-y-7">
+ <div>
<p class="text-lg font-medium leading-7 text-main">
{{ $t("common.environment") }}
</p>
@@ -14,7 +14,8 @@
@select-environment-id="handleSelectEnvironmentUID"
/>
</div>
- <Secrets :database="database" />
+ <Labels :database="database" class="pt-5" />
+ <Secrets :database="database" class="pt-5" />
</div>
</template>
@@ -23,6 +24,7 @@ import { cloneDeep } from "lodash-es";
import { computed } from "vue";
import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";
import { type ComposedDatabase } from "@/types";
+import Labels from "./components/Labels.vue";
import Secrets from "./components/Secrets.vue";
const props = defineProps<{
diff --git a/frontend/src/components/DatabaseDetail/Settings/components/Labels.vue b/frontend/src/components/DatabaseDetail/Settings/components/Labels.vue
new file mode 100644
index 0000000000..5353cc42dd
--- /dev/null
+++ b/frontend/src/components/DatabaseDetail/Settings/components/Labels.vue
@@ -0,0 +1,176 @@
+<template>
+ <div class="space-y-4">
+ <div class="flex items-center">
+ <div class="flex-1">
+ <div class="flex items-center">
+ <p class="text-lg font-medium leading-7 text-main flex">
+ {{ $t("common.labels") }}
+ </p>
+ </div>
+ </div>
+ </div>
+ <div>
+ <LabelListEditor
+ ref="labelListEditorRef"
+ v-model:kv-list="state.kvList"
+ :readonly="state.mode === 'view'"
+ :show-errors="dirty"
+ class="max-w-[30rem]"
+ />
+ </div>
+ <div class="flex flex-row justify-end items-center gap-x-3">
+ <template v-if="state.mode === 'view'">
+ <NButton :disabled="!allowAdmin" @click="beginEdit">
+ {{ $t("common.edit") }}
+ </NButton>
+ </template>
+ <template v-if="state.mode === 'edit'">
+ <NButton @click="handleCancel">
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ :disabled="!allowSave || state.isUpdating"
+ :loading="state.isUpdating"
+ type="primary"
+ @click="handleSave"
+ >
+ {{ $t("common.save") }}
+ </NButton>
+ </template>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { cloneDeep, isEqual } from "lodash-es";
+import { NButton } from "naive-ui";
+import { computed, reactive, ref, watch } from "vue";
+import { useI18n } from "vue-i18n";
+import { LabelListEditor } from "@/components/Label/";
+import {
+ pushNotification,
+ useCurrentUserV1,
+ useDatabaseV1Store,
+} from "@/store";
+import { type ComposedDatabase } from "@/types";
+import { Database } from "@/types/proto/v1/database_service";
+import {
+ PRESET_LABEL_KEYS,
+ convertKVListToLabels,
+ convertLabelsToKVList,
+ hasPermissionInProjectV1,
+ hasWorkspacePermissionV1,
+} from "@/utils";
+
+type LocalState = {
+ kvList: { key: string; value: string }[];
+ mode: "view" | "edit";
+ isUpdating: boolean;
+};
+
+const props = defineProps<{
+ database: ComposedDatabase;
+}>();
+
+const { t } = useI18n();
+const labelListEditorRef = ref<InstanceType<typeof LabelListEditor>>();
+const me = useCurrentUserV1();
+const state = reactive<LocalState>({
+ kvList: [],
+ mode: "view",
+ isUpdating: false,
+});
+
+const allowAdmin = computed(() => {
+ const project = props.database.projectEntity;
+ return (
+ hasWorkspacePermissionV1(
+ "bb.permission.workspace.manage-label",
+ me.value.userRole
+ ) ||
+ hasPermissionInProjectV1(
+ project.iamPolicy,
+ me.value,
+ "bb.permission.project.manage-general"
+ )
+ );
+});
+
+const convert = () => {
+ const labels = cloneDeep(props.database.labels);
+ // Pre-fill preset label keys with empty values
+ for (const key of PRESET_LABEL_KEYS) {
+ if (!(key in labels)) {
+ labels[key] = "";
+ }
+ }
+ return convertLabelsToKVList(labels, true /* sort */);
+};
+
+const dirty = computed(() => {
+ const original = convert();
+ const local = state.kvList;
+ return !isEqual(original, local);
+});
+
+const allowSave = computed(() => {
+ if (!dirty.value) return false;
+ const errors = labelListEditorRef.value?.flattenErrors ?? [];
+ return errors.length === 0;
+});
+
+const beginEdit = () => {
+ state.mode = "edit";
+};
+
+const handleCancel = () => {
+ state.kvList = convert();
+ state.mode = "view";
+};
+
+const handleSave = async () => {
+ if (!allowSave.value) return;
+ state.isUpdating = true;
+ try {
+ // Won't omit empty `bb.tenant` value.
+ // Otherwise the server API won't update the labels field correctly.
+ const labels = convertKVListToLabels(state.kvList, false /* !omitEmpty */);
+
+ const patch = {
+ ...Database.fromPartial(props.database),
+ labels,
+ };
+ await useDatabaseV1Store().updateDatabase({
+ database: patch,
+ updateMask: ["labels"],
+ });
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+ state.mode = "view";
+ } finally {
+ state.isUpdating = false;
+ }
+};
+
+watch(
+ allowAdmin,
+ () => {
+ state.mode = "view";
+ },
+ { immediate: true }
+);
+
+watch(
+ () => props.database.labels,
+ () => {
+ state.kvList = convert();
+ },
+ {
+ immediate: true,
+ deep: true,
+ }
+);
+</script>
diff --git a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
index e1c98256f0..26c30b064b 100644
--- a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
@@ -1,5 +1,5 @@
<template>
- <div class="space-y-4">
+ <div class="space-y-4" v-bind="$attrs">
<div class="flex items-center">
<div class="flex-1">
<div class="flex items-center">
diff --git a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
index c6954a2e05..fdc2271840 100644
--- a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
+++ b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
@@ -15,7 +15,11 @@
<template v-else>
<div class="flex justify-end items-center py-0.5 space-x-2">
- <YAxisRadioGroup v-model:label="state.label" class="text-sm" />
+ <YAxisRadioGroup
+ v-model:label="state.label"
+ :database-list="databaseList"
+ class="text-sm"
+ />
<BBTableSearch
v-if="showSearchBox"
class="w-60"
diff --git a/frontend/src/components/DeploymentConfigTool/SelectorItem.vue b/frontend/src/components/DeploymentConfigTool/SelectorItem.vue
index 0f2aa24409..e33b4caa9c 100644
--- a/frontend/src/components/DeploymentConfigTool/SelectorItem.vue
+++ b/frontend/src/components/DeploymentConfigTool/SelectorItem.vue
@@ -6,7 +6,7 @@
:options="keys"
:disabled="!editable"
:modifier="labelKeyModifier"
- :capitalize="true"
+ :capitalize="false"
class="select key"
/>
<LabelSelect
@@ -33,19 +33,17 @@
<script lang="ts" setup>
/* eslint-disable vue/no-mutating-props */
-import { uniq } from "lodash-es";
import { computed, PropType, watch } from "vue";
+import { ComposedDatabase } from "@/types";
import {
LabelSelectorRequirement,
OperatorType,
} from "@/types/proto/v1/project_service";
-import { ComposedDatabase } from "../../types";
import {
+ displayLabelKey,
+ getAvailableLabelKeyList,
getLabelValuesFromDatabaseV1List,
- hidePrefix,
- PRESET_LABEL_KEYS,
- RESERVED_LABEL_KEYS,
-} from "../../utils";
+} from "@/utils";
import LabelSelect from "./LabelSelect.vue";
const OPERATORS: OperatorType[] = [
@@ -73,9 +71,12 @@ defineEmits<{
}>();
const keys = computed(() => {
- const availableList = [...RESERVED_LABEL_KEYS, ...PRESET_LABEL_KEYS];
- const allKeys = props.databaseList.flatMap((db) => Object.keys(db.labels));
- return uniq(allKeys).filter((key) => availableList.includes(key));
+ return getAvailableLabelKeyList(
+ props.databaseList,
+ true /* withReserved */,
+ true /* withPreset */,
+ true /* sort */
+ );
});
const allowMultipleValues = computed(() => {
return props.selector.key !== "bb.environment";
@@ -94,11 +95,7 @@ const resetValues = () => {
};
const labelKeyModifier = (key: string | number) => {
- const formattedKey = hidePrefix(key as string);
- if (formattedKey === "environment") {
- return "Environment ID";
- }
- return formattedKey;
+ return displayLabelKey(key as string);
};
const operatorToText = (op: string | number) => {
diff --git a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
index e6799a9087..8c18a09b6a 100644
--- a/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue
@@ -133,6 +133,7 @@ import {
TaskRun,
TaskRun_Status,
} from "@/types/proto/v1/rollout_service";
+import { ErrorList } from "../common";
import CommonDrawer from "./CommonDrawer.vue";
type LocalState = {
diff --git a/frontend/src/components/Label/LabelEditorRow.vue b/frontend/src/components/Label/LabelEditorRow.vue
new file mode 100644
index 0000000000..8ae2179746
--- /dev/null
+++ b/frontend/src/components/Label/LabelEditorRow.vue
@@ -0,0 +1,80 @@
+<template>
+ <template v-if="!isReservedLabel(kv.key)">
+ <div class="contents text-sm">
+ <div class="flex flex-col">
+ <span class="text-xs font-medium"> Key {{ index + 1 }} </span>
+ <span v-if="isPresetLabel(kv.key) || readonly" class="leading-[34px]">
+ {{ displayLabelKey(kv.key) }}
+ </span>
+ <NInput
+ v-else
+ :value="kv.key"
+ :placeholder="$t('setting.label.key-placeholder')"
+ :status="errors.key.length > 0 ? 'error' : undefined"
+ @update:value="$emit('update-key', $event)"
+ />
+ </div>
+ <div class="flex flex-col">
+ <span class="text-xs font-medium"> Value {{ index + 1 }} </span>
+ <span v-if="readonly" class="leading-[34px]">
+ <template v-if="kv.value">{{ kv.value }}</template>
+ <span v-else class="text-control-placeholder">
+ {{ $t("label.empty-label-value") }}
+ </span>
+ </span>
+ <NInput
+ v-else
+ :value="kv.value"
+ :placeholder="$t('setting.label.value-placeholder')"
+ :status="errors.value.length > 0 ? 'error' : undefined"
+ @update:value="$emit('update-value', $event)"
+ />
+ </div>
+ <div class="flex flex-row self-stretch items-center pt-4">
+ <NButton
+ quaternary
+ size="small"
+ style="--n-padding: 0 6px"
+ :class="[
+ !isPresetLabel(kv.key) && !readonly ? 'visible' : 'invisible',
+ ]"
+ @click="$emit('remove')"
+ >
+ <template #icon>
+ <heroicons:trash />
+ </template>
+ </NButton>
+ </div>
+ </div>
+ <div v-if="combinedErrors.length > 0" class="text-xs text-error col-span-3">
+ <ErrorList :errors="combinedErrors" bullets="always" />
+ </div>
+ </template>
+</template>
+
+<script setup lang="ts">
+import { NButton, NInput } from "naive-ui";
+import { computed } from "vue";
+import { isReservedLabel, isPresetLabel, displayLabelKey } from "@/utils";
+import ErrorList from "../misc/ErrorList.vue";
+
+const props = defineProps<{
+ kv: { key: string; value: string };
+ index: number;
+ readonly: boolean;
+ errors: {
+ key: string[];
+ value: string[];
+ };
+}>();
+
+defineEmits<{
+ (event: "update-key", key: string): void;
+ (event: "update-value", value: string): void;
+ (event: "remove"): void;
+}>();
+
+const combinedErrors = computed(() => {
+ return [...props.errors.key, ...props.errors.value];
+});
+</script>
diff --git a/frontend/src/components/Label/LabelListEditor.vue b/frontend/src/components/Label/LabelListEditor.vue
new file mode 100644
index 0000000000..ab008b6840
--- /dev/null
+++ b/frontend/src/components/Label/LabelListEditor.vue
@@ -0,0 +1,153 @@
+<template>
+ <div class="flex flex-col gap-y-2">
+ <div
+ class="grid gap-x-1 gap-y-2"
+ style="grid-template-columns: 1fr 1fr auto"
+ >
+ <LabelEditorRow
+ v-for="(kv, i) in kvList"
+ :key="i"
+ :kv="kv"
+ :index="i"
+ :readonly="readonly"
+ :errors="errorsForKV(kv.key)"
+ @update-key="updateKey(i, $event)"
+ @update-value="updateValue(i, $event)"
+ @remove="handleRemove(i)"
+ />
+ </div>
+
+ <div v-if="!readonly">
+ <NButton size="small" :disabled="!allowAddLabel" @click="handleAdd">
+ <template #icon>
+ <heroicons:plus />
+ </template>
+ {{ $t("label.add-label") }}
+ </NButton>
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { cloneDeep } from "lodash-es";
+import { NButton } from "naive-ui";
+import { computed } from "vue";
+import { useI18n } from "vue-i18n";
+import {
+ validateLabelKey,
+ MAX_LABEL_VALUE_LENGTH,
+ isPresetLabel,
+} from "@/utils";
+import LabelEditorRow from "./LabelEditorRow.vue";
+
+export type KV = { key: string; value: string };
+
+const props = defineProps<{
+ kvList: KV[];
+ readonly: boolean;
+ showErrors: boolean;
+}>();
+
+const emit = defineEmits<{
+ (event: "update:kvList", kvList: KV[]): void;
+}>();
+
+const { t } = useI18n();
+
+const errorMap = computed(() => {
+ const map: Record<
+ string,
+ {
+ key: string[];
+ value: string[];
+ }
+ > = {};
+ for (const kv of props.kvList) {
+ const { key, value } = kv;
+ const errors = {
+ key: [] as string[],
+ value: [] as string[],
+ };
+ if (!key) {
+ errors.key.push(t("label.error.key-necessary"));
+ } else if (!validateLabelKey(key)) {
+ errors.key.push(t("label.error.key-format"));
+ }
+ if (!value) {
+ if (!isPresetLabel(key)) {
+ errors.value.push(t("label.error.value-necessary"));
+ }
+ } else if (value.length > MAX_LABEL_VALUE_LENGTH) {
+ errors.value.push(
+ t("label.error.max-value-length-exceeded", {
+ length: MAX_LABEL_VALUE_LENGTH,
+ })
+ );
+ }
+
+ map[key] = errors;
+ }
+
+ return map;
+});
+
+const errorsForKV = (key: string) => {
+ if (!props.showErrors) {
+ return { key: [], value: [] };
+ }
+ return errorMap.value[key] ?? { key: [], value: [] };
+};
+
+const flattenErrorsForKV = (key: string, value: string) => {
+ const errors = errorsForKV(key);
+ return [...errors.key, ...errors.value];
+};
+
+const flattenErrors = computed(() => {
+ const flattenErrors: { key: string; errors: string[] }[] = [];
+ props.kvList.forEach((kv) => {
+ const { key, value } = kv;
+ const errors = flattenErrorsForKV(key, value);
+ if (errors.length > 0) {
+ flattenErrors.push({ key, errors });
+ }
+ });
+ return flattenErrors;
+});
+
+const allowAddLabel = computed(() => {
+ return flattenErrors.value.length === 0;
+});
+
+const updateKey = (index: number, key: string) => {
+ const list = cloneDeep(props.kvList);
+ const kv = list[index];
+ if (!kv) return;
+ kv.key = key;
+ emit("update:kvList", list);
+};
+
+const updateValue = (index: number, value: string) => {
+ const list = cloneDeep(props.kvList);
+ const kv = list[index];
+ if (!kv) return;
+ kv.value = value;
+ emit("update:kvList", list);
+};
+
+const handleRemove = (index: number) => {
+ const list = cloneDeep(props.kvList);
+ list.splice(index, 1);
+ emit("update:kvList", list);
+};
+
+const handleAdd = () => {
+ const list = cloneDeep(props.kvList);
+ emit("update:kvList", [...list, { key: "", value: "" }]);
+};
+
+defineExpose({
+ errorMap,
+ flattenErrors,
+});
+</script>
diff --git a/frontend/src/components/Label/index.ts b/frontend/src/components/Label/index.ts
new file mode 100644
index 0000000000..2c9c84ae3c
--- /dev/null
+++ b/frontend/src/components/Label/index.ts
@@ -0,0 +1,3 @@
+import LabelListEditor from "./LabelListEditor.vue";
+
+export { LabelListEditor };
diff --git a/frontend/src/components/TenantDatabaseTable/DatabaseMatrixItem.vue b/frontend/src/components/TenantDatabaseTable/DatabaseMatrixItem.vue
index d3e540f728..da4122b717 100644
--- a/frontend/src/components/TenantDatabaseTable/DatabaseMatrixItem.vue
+++ b/frontend/src/components/TenantDatabaseTable/DatabaseMatrixItem.vue
@@ -67,8 +67,8 @@
:key="label.key"
class="flex items-center space-y-1"
>
- <span class="capitalize text-left">
- {{ hidePrefix(label.key) }}
+ <span class="text-left">
+ {{ displayLabelKey(label.key) }}
</span>
<span
class="flex-1 h-px mx-2 border-b border-control-border border-dashed"
@@ -85,7 +85,12 @@ import { NPopover } from "naive-ui";
import { computed, PropType } from "vue";
import { State } from "@/types/proto/v1/common";
import { ComposedDatabase } from "../../types";
-import { databaseV1Slug, hidePrefix, PRESET_LABEL_KEYS } from "../../utils";
+import {
+ convertLabelsToKVList,
+ databaseV1Slug,
+ isReservedLabel,
+ displayLabelKey,
+} from "../../utils";
import { InstanceV1Name } from "../v2";
const props = defineProps({
@@ -96,16 +101,9 @@ const props = defineProps({
});
const displayLabelList = computed(() => {
- return Object.keys(props.database.labels)
- .map((key) => {
- const value = props.database.labels[key];
- return { key, value };
- })
- .filter((kv) => {
- if (!kv.value) return false;
- if (!PRESET_LABEL_KEYS.includes(kv.key)) return false;
- return true;
- });
+ return convertLabelsToKVList(props.database.labels, true /* sort */)
+ .filter((kv) => !isReservedLabel(kv.key))
+ .filter((kv) => kv.value !== "");
});
const databaseDetailUrl = computed((): string => {
diff --git a/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue b/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue
index 25bf8d9616..643b9736a9 100644
--- a/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue
+++ b/frontend/src/components/TenantDatabaseTable/DeployDatabaseTable.vue
@@ -8,8 +8,8 @@
>
<template #header>
<tr>
- <BBTableHeaderCell compact class="w-1/12 pl-3 pr-2 capitalize">
- {{ hidePrefix(label) }}
+ <BBTableHeaderCell compact class="w-1/12 pl-3 pr-2 whitespace-nowrap">
+ {{ displayLabelKey(label) }}
</BBTableHeaderCell>
<BBTableHeaderCell
@@ -106,14 +106,15 @@
import { groupBy } from "lodash-es";
import { NPopover } from "naive-ui";
import { computed, withDefaults } from "vue";
+import type { ComposedDatabase, LabelKeyType } from "@/types";
import { Environment } from "@/types/proto/v1/environment_service";
import { DeploymentConfig } from "@/types/proto/v1/project_service";
-import type { ComposedDatabase, LabelKeyType } from "../../types";
import {
- hidePrefix,
getLabelValuesFromDatabaseV1List,
getPipelineFromDeploymentScheduleV1,
-} from "../../utils";
+ displayLabelKey,
+ getSemanticLabelValue,
+} from "@/utils";
import { DeploymentStage } from "../DeploymentConfigTool";
import DatabaseMatrixItem from "./DatabaseMatrixItem.vue";
@@ -148,7 +149,9 @@ const xAxisValueList = computed(() => {
const databaseGroupList = computed(() => {
const key = props.label;
- const dict = groupBy(props.databaseList, (db) => db.labels[key] ?? "");
+ const dict = groupBy(props.databaseList, (db) =>
+ getSemanticLabelValue(db, key)
+ );
const rows = yAxisValueList.value.map((labelValue) => {
const databaseList = dict[labelValue] || [];
return {
diff --git a/frontend/src/components/TenantDatabaseTable/YAxisRadioGroup.vue b/frontend/src/components/TenantDatabaseTable/YAxisRadioGroup.vue
index bde97f06bf..55f7951b55 100644
--- a/frontend/src/components/TenantDatabaseTable/YAxisRadioGroup.vue
+++ b/frontend/src/components/TenantDatabaseTable/YAxisRadioGroup.vue
@@ -11,24 +11,20 @@
:value="key"
class="capitalize"
>
- {{ capitalize(hidePrefix(key)) }}
+ {{ displayLabelKey(key) }}
</option>
</select>
</div>
</template>
<script lang="ts" setup>
-import { capitalize } from "lodash-es";
import { computed, withDefaults } from "vue";
-import { LabelKeyType } from "../../types";
-import {
- hidePrefix,
- PRESET_LABEL_KEYS,
- RESERVED_LABEL_KEYS,
-} from "../../utils";
+import { ComposedDatabase, LabelKeyType } from "@/types";
+import { displayLabelKey, getAvailableLabelKeyList } from "@/utils";
const props = withDefaults(
defineProps<{
+ databaseList: ComposedDatabase[];
label: LabelKeyType;
excludedKeyList?: LabelKeyType[];
}>(),
@@ -37,14 +33,17 @@ const props = withDefaults(
}
);
-const LABEL_KEY_LIST = [...RESERVED_LABEL_KEYS, ...PRESET_LABEL_KEYS];
-
const emit = defineEmits<{
(event: "update:label", label: LabelKeyType): void;
}>();
const labelKeyList = computed(() => {
- return LABEL_KEY_LIST.filter((key) => !props.excludedKeyList.includes(key));
+ return getAvailableLabelKeyList(
+ props.databaseList,
+ true /* withReserved */,
+ true /* withPreset */,
+ true /* sort */
+ ).filter((key) => !props.excludedKeyList.includes(key));
});
const visible = computed(() => {
diff --git a/frontend/src/components/TransferDatabaseForm/SelectDatabaseLabel.vue b/frontend/src/components/TransferDatabaseForm/SelectDatabaseLabel.vue
index 90691e1fe1..be57829420 100644
--- a/frontend/src/components/TransferDatabaseForm/SelectDatabaseLabel.vue
+++ b/frontend/src/components/TransferDatabaseForm/SelectDatabaseLabel.vue
@@ -4,8 +4,8 @@
class="space-y-4 flex flex-col justify-center items-center"
>
<div v-for="key in PRESET_LABEL_KEYS" :key="key" class="w-64">
- <label class="textlabel capitalize">
- {{ hidePrefix(key) }}
+ <label class="textlabel">
+ {{ displayLabelKey(key) }}
<span v-if="isRequiredLabel(key)" style="color: red">*</span>
</label>
@@ -50,6 +50,7 @@ import {
parseLabelListInTemplate,
PRESET_LABEL_KEYS,
PRESET_LABEL_KEY_PLACEHOLDERS,
+ displayLabelKey,
} from "@/utils";
import { useProjectV1ByUID } from "@/store";
import { TenantMode } from "@/types/proto/v1/project_service";
diff --git a/frontend/src/components/misc/ErrorList.vue b/frontend/src/components/misc/ErrorList.vue
index da82a653fe..e6feaa8860 100644
--- a/frontend/src/components/misc/ErrorList.vue
+++ b/frontend/src/components/misc/ErrorList.vue
@@ -1,7 +1,7 @@
<template>
<ul
class="flex flex-col whitespace-nowrap"
- :class="[errors.length > 1 && bullets && 'list-disc pl-4']"
+ :class="[showBullets && 'list-disc pl-4']"
>
<li v-for="(error, i) in errors" :key="i">
<slot name="prefix" />
@@ -11,13 +11,28 @@
</template>
<script setup lang="ts">
-withDefaults(
+import { computed } from "vue";
+
+const props = withDefaults(
defineProps<{
errors: string[];
- bullets?: boolean;
+ bullets?: "on-demand" | "always" | "none";
}>(),
{
- bullets: true,
+ bullets: "on-demand",
}
);
+
+const showBullets = computed(() => {
+ switch (props.bullets) {
+ case "on-demand":
+ return props.errors.length > 1;
+ case "always":
+ return true;
+ case "none":
+ return false;
+ }
+ console.error("should never reach this line");
+ return false;
+});
</script>
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 569b8477ac..81742aa9fc 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1958,7 +1958,8 @@
"label": {
"key": "Key",
"values": "Values",
- "value-placeholder": "Label value..."
+ "value-placeholder": "Label value...",
+ "key-placeholder": "Label key..."
}
},
"sql-editor": {
@@ -2148,7 +2149,9 @@
"value-duplicated": "Duplicated values",
"max-length-exceeded": "Length cannot exceed {len} characters",
"max-label-count-exceeded": "Cannot exceed {count} labels",
- "cannot-edit-reserved-label": "Cannot edit reserved label \"{key}\""
+ "cannot-edit-reserved-label": "Cannot edit reserved label \"{key}\"",
+ "max-value-length-exceeded": "Value's length cannot exceed {length} characters",
+ "key-format": "Only alphanumeric characters ([a-z0-9A-Z]), hyphens (-), underscores (_) and dots (.) are allowed. And must begin and ends with alphanumeric characters."
},
"placeholder": {
"select-key": "Select key...",
@@ -2161,7 +2164,8 @@
"db-name-template-tips": "Specify a template to enforce database naming. For example, if your database db1 is geo-splitted into US, Asia, Europe and you want to enforce names as db1__US, db1__ASIA, db1__EU, then the template could be {placeholder}. {link}.",
"confirm-change": "Are you sure to change '{label}' ?",
"parsed-from-template": "Parsed from {name} by template {template}.",
- "cannot-transfer-template-not-match": "Database '{name}' cannot be transferred to this project. Since its name doesn't match the template {template}."
+ "cannot-transfer-template-not-match": "Database '{name}' cannot be transferred to this project. Since its name doesn't match the template {template}.",
+ "add-label": "Add label"
},
"oauth": {
"unknown-event": "Unexpected event type, OAuth failed."
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 21c1eea03b..01a39cbba8 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1954,7 +1954,8 @@
"label": {
"key": "Clave",
"values": "Valores",
- "value-placeholder": "Valor de etiqueta..."
+ "value-placeholder": "Valor de etiqueta...",
+ "key-placeholder": "Clave de etiqueta..."
}
},
"sql-editor": {
@@ -2144,7 +2145,9 @@
"value-duplicated": "Valores duplicados",
"max-length-exceeded": "La longitud no puede superar {len} caracteres",
"max-label-count-exceeded": "No se pueden exceder las {count} etiquetas",
- "cannot-edit-reserved-label": "No se puede editar la etiqueta reservada \"{key}\""
+ "cannot-edit-reserved-label": "No se puede editar la etiqueta reservada \"{key}\"",
+ "max-value-length-exceeded": "La longitud del valor no puede exceder {longitud} caracteres",
+ "key-format": "Sólo se permiten caracteres alfanuméricos ([a-z0-9A-Z]), guiones (-), guiones bajos (_) y puntos (.). \nY debe comenzar y terminar con caracteres alfanuméricos."
},
"placeholder": {
"select-key": "Seleccionar clave...",
@@ -2157,7 +2160,8 @@
"db-name-template-tips": "Especifique una plantilla para aplicar la denominación de la base de datos. Por ejemplo, si su base de datos db1 está dividida geográficamente en EE. UU., Asia y Europa y desea aplicar nombres como db1__US, db1__ASIA, db1__EU, entonces la plantilla podría ser {placeholder}. {link}.",
"confirm-change": "¿Estás seguro de cambiar '{label}'?",
"parsed-from-template": "Analizado desde {name} por la plantilla {template}.",
- "cannot-transfer-template-not-match": "La base de datos '{name}' no puede ser transferida a este proyecto, ya que su nombre no coincide con la plantilla {template}."
+ "cannot-transfer-template-not-match": "La base de datos '{name}' no puede ser transferida a este proyecto, ya que su nombre no coincide con la plantilla {template}.",
+ "add-label": "Agregar etiqueta"
},
"oauth": {
"unknown-event": "Tipo de evento inesperado, OAuth falló."
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 306d4f48a4..da4a58bc0e 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1953,7 +1953,8 @@
"label": {
"key": "Key",
"values": "值",
- "value-placeholder": "标签值…"
+ "value-placeholder": "标签值…",
+ "key-placeholder": "标签 key..."
}
},
"sql-editor": {
@@ -2144,7 +2145,9 @@
"value-duplicated": "值重复了",
"max-length-exceeded": "长度不能超过 {len} 字符",
"max-label-count-exceeded": "不能多于 {count} 个标签",
- "cannot-edit-reserved-label": "不能编辑预留标签 \"{key}\""
+ "cannot-edit-reserved-label": "不能编辑预留标签 \"{key}\"",
+ "max-value-length-exceeded": "值长的度不能超过 {length} 字符",
+ "key-format": "仅允许使用字母和数字 ([a-z0-9A-Z])、连字符 (-)、下划线 (_) 和点 (.)。\n并且必须以字母和数字开头和结尾。"
},
"placeholder": {
"select-key": "选择 Key…",
@@ -2157,7 +2160,8 @@
"db-name-template-tips": "使用模版来约束数据库命名。例如:您的数据库 db1 是按照地域分割为 US,Asia,Europe 并且您希望它们的名字是 db1__US, db1__ASIA, db1__EU,那么模版可以指定为 {placeholder}。{link}。",
"confirm-change": "您确定要修改 '{label}' 吗?",
"parsed-from-template": "从 {name} 中依据模板 {template} 解析得出",
- "cannot-transfer-template-not-match": "数据库 '{name}' 无法转移到这个项目,因为它的名称不符合模板 {template}。"
+ "cannot-transfer-template-not-match": "数据库 '{name}' 无法转移到这个项目,因为它的名称不符合模板 {template}。",
+ "add-label": "添加标签"
},
"oauth": {
"unknown-event": "未知的事件类型,认证失败"
diff --git a/frontend/src/store/modules/v1/databaseSecret.ts b/frontend/src/store/modules/v1/databaseSecret.ts
index 1c250b377e..06fcbf0bfb 100644
--- a/frontend/src/store/modules/v1/databaseSecret.ts
+++ b/frontend/src/store/modules/v1/databaseSecret.ts
@@ -1,3 +1,4 @@
+import { Status } from "nice-grpc-common";
import { defineStore } from "pinia";
import { reactive } from "vue";
import { databaseServiceClient } from "@/grpcweb";
@@ -12,9 +13,14 @@ export const useDatabaseSecretStore = defineStore("database-secret", () => {
};
const fetchSecretList = async (parent: string) => {
- const res = await databaseServiceClient.listSecrets({
- parent,
- });
+ const res = await databaseServiceClient.listSecrets(
+ {
+ parent,
+ },
+ {
+ ignoredCodes: [Status.NOT_FOUND, Status.PERMISSION_DENIED],
+ }
+ );
secretMapByDatabase.set(parent, res.secrets);
return res.secrets;
};
diff --git a/frontend/src/utils/label.ts b/frontend/src/utils/label.ts
index ea10393dc3..d442154aea 100644
--- a/frontend/src/utils/label.ts
+++ b/frontend/src/utils/label.ts
@@ -1,3 +1,14 @@
+import { capitalize, orderBy, uniq } from "lodash-es";
+import { useEnvironmentV1Store } from "@/store";
+import { ComposedDatabase } from "@/types";
+import {
+ LabelSelector,
+ LabelSelectorRequirement,
+ OperatorType,
+ Schedule,
+} from "@/types/proto/v1/project_service";
+import { extractEnvironmentResourceName } from "./v1";
+
export const MAX_LABEL_VALUE_LENGTH = 63;
export const RESERVED_LABEL_KEYS = ["bb.environment"];
@@ -35,3 +46,198 @@ export const parseLabelListInTemplate = (template: string): string[] => {
return labelList;
};
+
+export const validateLabelKey = (key: string) => {
+ if (key.length === 0) return false;
+ if (key.length >= 64) return false;
+ return (
+ key.match(/^[a-z0-9A-Z]/) &&
+ key.match(/[a-z0-9A-Z]$/) &&
+ key.match(/[a-z0-9A-Z-_.]*/)
+ );
+};
+
+export const isReservedLabel = (key: string) => {
+ return RESERVED_LABEL_KEYS.includes(key);
+};
+
+export const isPresetLabel = (key: string) => {
+ return PRESET_LABEL_KEYS.includes(key);
+};
+
+export const getAvailableLabelKeyList = (
+ databaseList: ComposedDatabase[],
+ withReserved: boolean,
+ withPreset: boolean,
+ sort = true
+) => {
+ const keys = uniq(databaseList.flatMap((db) => Object.keys(db.labels)));
+ if (withReserved) {
+ RESERVED_LABEL_KEYS.forEach((key) => {
+ if (!keys.includes(key)) keys.push(key);
+ });
+ }
+ if (withPreset) {
+ PRESET_LABEL_KEYS.forEach((key) => {
+ if (!keys.includes(key)) keys.push(key);
+ });
+ }
+ if (sort) {
+ return orderBy(
+ keys,
+ [
+ (key) => (isReservedLabel(key) ? -1 : 1),
+ (key) => (isPresetLabel(key) ? -1 : 1),
+ (key) => key,
+ ],
+ ["asc", "asc", "asc"]
+ );
+ }
+ return keys;
+};
+
+export const convertLabelsToKVList = (
+ labels: Record<string, string>,
+ sort = true
+) => {
+ const list = Object.keys(labels).map((key) => ({
+ key,
+ value: labels[key],
+ }));
+
+ if (sort) {
+ // 1. Preset
+ // 2. Others (lexicographical order)
+ // ...
+ // 3. Hidden
+ return orderBy(
+ list,
+ [
+ (kv) => (isReservedLabel(kv.key) ? 1 : -1),
+ (kv) => (isPresetLabel(kv.key) ? -1 : 1),
+ (kv) => kv.key,
+ ],
+ ["asc", "asc", "asc"]
+ );
+ }
+ return list;
+};
+
+export const convertKVListToLabels = (
+ list: { key: string; value: string }[],
+ omitEmpty = true // true to omit empty values in the returned kv object
+) => {
+ const labels: Record<string, string> = {};
+ for (const kv of list) {
+ const { key, value } = kv;
+ if (!value && omitEmpty) continue;
+ labels[key] = value;
+ }
+ return labels;
+};
+
+export const displayLabelKey = (key: string) => {
+ if (key === "bb.environment") {
+ return "Environment ID";
+ }
+
+ if (key.startsWith("bb.")) {
+ const word = key.split("bb.")[1];
+ return capitalize(word);
+ }
+ return key;
+};
+
+export const getPipelineFromDeploymentScheduleV1 = (
+ databaseList: ComposedDatabase[],
+ schedule: Schedule | undefined
+): ComposedDatabase[][] => {
+ const stages: ComposedDatabase[][] = [];
+
+ const collectedIds = new Set<string>();
+ schedule?.deployments.forEach((deployment) => {
+ const dbs: ComposedDatabase[] = [];
+ databaseList.forEach((db) => {
+ if (collectedIds.has(db.uid)) return;
+ if (isDatabaseMatchesSelectorV1(db, deployment.spec?.labelSelector)) {
+ dbs.push(db);
+ collectedIds.add(db.uid);
+ }
+ });
+ stages.push(dbs);
+ });
+
+ return stages;
+};
+
+export const getLabelValuesFromDatabaseV1List = (
+ key: string,
+ databaseList: ComposedDatabase[],
+ withEmptyValue = false
+): string[] => {
+ if (key === "bb.environment") {
+ const environmentList = useEnvironmentV1Store().getEnvironmentList();
+ return environmentList.map((env) =>
+ extractEnvironmentResourceName(env.name)
+ );
+ }
+
+ const valueList = databaseList.flatMap((db) => {
+ if (key in db.labels) {
+ return getSemanticLabelValue(db, key);
+ }
+ return [];
+ });
+ // Select all distinct database label values of {{key}}
+ const distinctValueList = uniq(valueList);
+
+ if (withEmptyValue) {
+ // plus one more "<empty value>" if needed
+ distinctValueList.push("");
+ }
+
+ return distinctValueList;
+};
+
+export const isDatabaseMatchesSelectorV1 = (
+ database: ComposedDatabase,
+ selector: LabelSelector | undefined
+): boolean => {
+ const rules = selector?.matchExpressions ?? [];
+ return rules.every((rule) => {
+ switch (rule.operator) {
+ case OperatorType.OPERATOR_TYPE_IN:
+ return checkLabelIn(database, rule);
+ case OperatorType.OPERATOR_TYPE_EXISTS:
+ return checkLabelExists(database, rule);
+ default:
+ // unknown operators are taken as mismatch
+ console.warn(`known operator "${rule.operator}"`);
+ return false;
+ }
+ });
+};
+
+export const getSemanticLabelValue = (db: ComposedDatabase, key: string) => {
+ if (key === "bb.environment") {
+ return extractEnvironmentResourceName(db.effectiveEnvironment);
+ }
+ return db.labels[key] ?? "";
+};
+
+const checkLabelIn = (
+ db: ComposedDatabase,
+ rule: LabelSelectorRequirement
+): boolean => {
+ const value = getSemanticLabelValue(db, rule.key);
+ if (!value) return false;
+
+ return rule.values.includes(value);
+};
+
+const checkLabelExists = (
+ db: ComposedDatabase,
+ rule: LabelSelectorRequirement
+): boolean => {
+ return !!getSemanticLabelValue(db, rule.key);
+};
diff --git a/frontend/src/utils/v1/databaseLabel.ts b/frontend/src/utils/v1/databaseLabel.ts
deleted file mode 100644
index 9512f3424f..0000000000
--- a/frontend/src/utils/v1/databaseLabel.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { uniq } from "lodash-es";
-import { useEnvironmentV1Store } from "@/store";
-import { Database } from "@/types/proto/v1/database_service";
-import { extractEnvironmentResourceName } from "./environment";
-
-export const getLabelValuesFromDatabaseV1List = (
- key: string,
- databaseList: Database[],
- withEmptyValue = false
-): string[] => {
- if (key === "bb.environment") {
- const environmentList = useEnvironmentV1Store().getEnvironmentList();
- return environmentList.map((env) =>
- extractEnvironmentResourceName(env.name)
- );
- }
-
- const valueList = databaseList.flatMap((db) => {
- if (key in db.labels) {
- return [db.labels[key]];
- }
- return [];
- });
- // Select all distinct database label values of {{key}}
- const distinctValueList = uniq(valueList);
-
- if (withEmptyValue) {
- // plus one more "<empty value>" if needed
- distinctValueList.push("");
- }
-
- return distinctValueList;
-};
diff --git a/frontend/src/utils/v1/index.ts b/frontend/src/utils/v1/index.ts
index ff282efda1..bae3cbc9a4 100644
--- a/frontend/src/utils/v1/index.ts
+++ b/frontend/src/utils/v1/index.ts
@@ -4,11 +4,9 @@ export * from "./instance";
export * from "./database";
export * from "./databaseGroup";
export * from "./backup";
-export * from "./databaseLabel";
export * from "./project";
export * from "./projectWebhook";
export * from "./deploymentConfig";
-export * from "./label";
export * from "./role";
export * from "./user";
export * from "./instance";
diff --git a/frontend/src/utils/v1/label.ts b/frontend/src/utils/v1/label.ts
deleted file mode 100644
index fe4e7c973a..0000000000
--- a/frontend/src/utils/v1/label.ts
+++ /dev/null
@@ -1,65 +0,0 @@
-import { ComposedDatabase } from "@/types";
-import {
- LabelSelector,
- LabelSelectorRequirement,
- OperatorType,
- Schedule,
-} from "@/types/proto/v1/project_service";
-
-export const getPipelineFromDeploymentScheduleV1 = (
- databaseList: ComposedDatabase[],
- schedule: Schedule | undefined
-): ComposedDatabase[][] => {
- const stages: ComposedDatabase[][] = [];
-
- const collectedIds = new Set<string>();
- schedule?.deployments.forEach((deployment) => {
- const dbs: ComposedDatabase[] = [];
- databaseList.forEach((db) => {
- if (collectedIds.has(db.uid)) return;
- if (isDatabaseMatchesSelectorV1(db, deployment.spec?.labelSelector)) {
- dbs.push(db);
- collectedIds.add(db.uid);
- }
- });
- stages.push(dbs);
- });
-
- return stages;
-};
-
-export const isDatabaseMatchesSelectorV1 = (
- database: ComposedDatabase,
- selector: LabelSelector | undefined
-): boolean => {
- const rules = selector?.matchExpressions ?? [];
- return rules.every((rule) => {
- switch (rule.operator) {
- case OperatorType.OPERATOR_TYPE_IN:
- return checkLabelIn(database, rule);
- case OperatorType.OPERATOR_TYPE_EXISTS:
- return checkLabelExists(database, rule);
- default:
- // unknown operators are taken as mismatch
- console.warn(`known operator "${rule.operator}"`);
- return false;
- }
- });
-};
-
-const checkLabelIn = (
- db: ComposedDatabase,
- rule: LabelSelectorRequirement
-): boolean => {
- const value = db.labels[rule.key];
- if (!value) return false;
-
- return rule.values.includes(value);
-};
-
-const checkLabelExists = (
- db: ComposedDatabase,
- rule: LabelSelectorRequirement
-): boolean => {
- return !!db.labels[rule.key];
-};
diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vue
index 7133619014..df1b983999 100644
--- a/frontend/src/views/DatabaseDetail.vue
+++ b/frontend/src/views/DatabaseDetail.vue
@@ -81,18 +81,6 @@
<span class="mr-1">{{ $t("schema-diagram.self") }}</span>
<SchemaDiagramIcon />
</dd>
- <DatabaseLabelProps
- :labels="database.labels"
- :database="database"
- :allow-edit="allowEditDatabaseLabels"
- @update:labels="updateLabels"
- >
- <template #label="{ label }">
- <span class="textlabel capitalize">
- {{ hidePrefix(label) }}&nbsp;-&nbsp;
- </span>
- </template>
- </DatabaseLabelProps>
</dl>
</div>
<div
@@ -256,7 +244,6 @@ import {
DatabaseSettingsPanel,
SQLEditorButtonV1,
} from "@/components/DatabaseDetail";
-import { DatabaseLabelProps } from "@/components/DatabaseLabels";
import DatabaseOverviewPanel from "@/components/DatabaseOverviewPanel.vue";
import DatabaseSlowQueryPanel from "@/components/DatabaseSlowQueryPanel.vue";
import { SchemaDiagram, SchemaDiagramIcon } from "@/components/SchemaDiagram";
@@ -273,7 +260,6 @@ import {
useCurrentUserV1,
useDatabaseV1Store,
useDBSchemaV1Store,
- useGracefulRequest,
useEnvironmentV1Store,
} from "@/store";
import {
@@ -287,7 +273,6 @@ import { TenantMode } from "@/types/proto/v1/project_service";
import {
idFromSlug,
hasWorkspacePermissionV1,
- hidePrefix,
allowGhostMigrationV1,
isPITRDatabaseV1,
isArchivedDatabaseV1,
@@ -489,11 +474,6 @@ const allowAlterSchema = computed(() => {
);
});
-const allowEditDatabaseLabels = computed((): boolean => {
- // only allowed to edit database labels when allowAdmin
- return allowAdmin.value;
-});
-
const availableDatabaseTabItemList = computed(() => {
const db = database.value;
return databaseTabItemList.value.filter((item) => {
@@ -595,17 +575,6 @@ const createMigration = async (
});
};
-const updateLabels = (labels: Record<string, string>) => {
- useGracefulRequest(async () => {
- const databasePatch = { ...database.value };
- databasePatch.labels = labels;
- await databaseV1Store.updateDatabase({
- database: databasePatch,
- updateMask: ["labels"],
- });
- });
-};
-
const selectedTabItem = computed(() => {
return availableDatabaseTabItemList.value[state.selectedIndex];
});
diff --git a/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue b/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
index 9eb9711f21..7ac3fea6eb 100644
--- a/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
@@ -82,7 +82,7 @@
</template>
<script lang="ts" setup>
-import { isEqual, upperFirst } from "lodash-es";
+import { isEqual } from "lodash-es";
import {
NCheckboxGroup,
NCheckbox,
@@ -99,6 +99,7 @@ import {
useDatabaseV1Store,
useTabStore,
} from "@/store/modules";
+import { displayLabelKey } from "@/utils";
interface LocalState {
showFeatureModal: boolean;
@@ -200,10 +201,7 @@ const unmatchedDatabases = computed(() => {
});
const getFormattedLabelKey = (labelKey: string) => {
- if (labelKey.startsWith("bb.")) {
- return upperFirst(labelKey.substring(3));
- }
- return labelKey;
+ return displayLabelKey(labelKey);
};
watch(selectedLabelsValue, () => {