Skip to content

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

refactor: simplify the feature guard (#16068)

ecmadao48581cbf3e7b
diff --git a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/Toolbar.vue b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/Toolbar.vue
index fae90b129e..6e960c23d3 100644
--- a/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/Toolbar.vue
+++ b/frontend/src/components/CustomApproval/Settings/components/CustomApproval/FlowsPanel/Toolbar.vue
@@ -3,7 +3,7 @@
<NButton type="primary" :disabled="!allowAdmin" @click="createRule">
<FeatureBadge
feature="bb.feature.custom-approval"
- custom-class="mr-1 text-white"
+ class="mr-1 text-white"
/>
{{ $t("common.create") }}
</NButton>
diff --git a/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue b/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue
index 94aa42b07b..8894e5308d 100644
--- a/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue
+++ b/frontend/src/components/Database/DatabaseSensitiveDataPanel.vue
@@ -1,8 +1,8 @@
<template>
<div class="w-full space-y-4">
- <FeatureAttentionForInstanceLicense
- v-if="hasSensitiveDataFeature && isMissingLicenseForInstance"
+ <FeatureAttention
feature="bb.feature.sensitive-data"
+ :instance="database.instanceResource"
/>
<div
class="flex flex-col space-x-2 lg:flex-row gap-y-4 justify-between items-end lg:items-center"
@@ -21,9 +21,9 @@
<template #icon>
<ShieldCheckIcon v-if="hasSensitiveDataFeature" class="w-4" />
<FeatureBadge
- v-else
feature="bb.feature.sensitive-data"
- custom-class="text-white"
+ class="text-white"
+ :instance="database.instanceResource"
/>
</template>
{{ $t("settings.sensitive-data.grant-access") }}
@@ -76,19 +76,14 @@ import { computed, reactive, watch } from "vue";
import {
FeatureModal,
FeatureBadge,
- FeatureAttentionForInstanceLicense,
+ FeatureAttention,
} from "@/components/FeatureGuard";
import GrantAccessDrawer from "@/components/SensitiveData/GrantAccessDrawer.vue";
import SensitiveColumnTable from "@/components/SensitiveData/components/SensitiveColumnTable.vue";
import type { MaskData } from "@/components/SensitiveData/types";
import { isCurrentColumnException } from "@/components/SensitiveData/utils";
import { SearchBox } from "@/components/v2";
-import {
- featureToRef,
- usePolicyV1Store,
- useSubscriptionV1Store,
- useDatabaseCatalog,
-} from "@/store";
+import { featureToRef, usePolicyV1Store, useDatabaseCatalog } from "@/store";
import { type ComposedDatabase } from "@/types";
import {
ObjectSchema_Type,
@@ -145,17 +140,9 @@ const hasPolicyPermission = computed(() => {
});
const policyStore = usePolicyV1Store();
-const subscriptionStore = useSubscriptionV1Store();
const hasSensitiveDataFeature = featureToRef("bb.feature.sensitive-data");
-const isMissingLicenseForInstance = computed(() =>
- subscriptionStore.instanceMissingLicense(
- "bb.feature.sensitive-data",
- props.database.instanceResource
- )
-);
-
const databaseCatalog = useDatabaseCatalog(props.database.name, false);
const flattenObjectSchema = (
diff --git a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
index bf78b71b99..6355a59b64 100644
--- a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
@@ -8,7 +8,7 @@
</p>
<FeatureBadge
feature="bb.feature.encrypted-secrets"
- custom-class="ml-2"
+ class="ml-2"
:instance="database.instanceResource"
/>
</div>
diff --git a/frontend/src/components/FeatureGuard/FeatureAttention.vue b/frontend/src/components/FeatureGuard/FeatureAttention.vue
index 8e525b44d7..a073017ea1 100644
--- a/frontend/src/components/FeatureGuard/FeatureAttention.vue
+++ b/frontend/src/components/FeatureGuard/FeatureAttention.vue
@@ -1,13 +1,14 @@
<template>
<BBAttention
- v-if="!hasFeature"
- :class="customClass"
- type="warning"
+ v-if="show"
+ v-bind="$attrs"
+ :type="hasFeature ? 'info' : 'warning'"
:title="$t(`dynamic.subscription.features.${featureKey}.title`)"
:description="descriptionText"
:action-text="actionText"
@click="onClick"
/>
+
<WeChatQRModal
v-if="state.showQRCodeModal"
:title="$t('subscription.request-with-qr')"
@@ -20,15 +21,15 @@
</template>
<script lang="ts" setup>
-import type { PropType } from "vue";
import { reactive, computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { BBAttention } from "@/bbkit";
import { useLanguage } from "@/composables/useLanguage";
-import { useSubscriptionV1Store } from "@/store";
+import { useSubscriptionV1Store, useActuatorV1Store } from "@/store";
import type { FeatureType } from "@/types";
import { planTypeToString, ENTERPRISE_INQUIRE_LINK } from "@/types";
+import { instanceLimitFeature } from "@/types";
import type {
Instance,
InstanceResource,
@@ -42,32 +43,24 @@ interface LocalState {
showQRCodeModal: boolean;
}
-const props = defineProps({
- feature: {
- required: true,
- type: String as PropType<FeatureType>,
- },
- description: {
- require: false,
- default: "",
- type: String,
- },
- customClass: {
- require: false,
- default: "",
- type: String,
- },
- instance: {
- type: Object as PropType<Instance | InstanceResource>,
- default: undefined,
- },
-});
+const props = withDefaults(
+ defineProps<{
+ feature: FeatureType;
+ description?: string;
+ instance?: Instance | InstanceResource;
+ }>(),
+ {
+ description: "",
+ instance: undefined,
+ }
+);
const router = useRouter();
const { t } = useI18n();
const { locale } = useLanguage();
-
+const actuatorStore = useActuatorV1Store();
const subscriptionStore = useSubscriptionV1Store();
+
const state = reactive<LocalState>({
showInstanceAssignmentDrawer: false,
showQRCodeModal: false,
@@ -82,7 +75,7 @@ const canManageInstanceLicense = computed((): boolean => {
});
const hasFeature = computed(() => {
- return subscriptionStore.hasInstanceFeature(props.feature, props.instance);
+ return subscriptionStore.hasInstanceFeature(props.feature);
});
const instanceMissingLicense = computed(() => {
@@ -92,25 +85,40 @@ const instanceMissingLicense = computed(() => {
);
});
-const actionText = computed(() => {
- if (instanceMissingLicense.value) {
- if (!canManageInstanceLicense.value) {
- return "";
- }
- return t("subscription.instance-assignment.assign-license");
+const existInstanceWithoutLicense = computed(() => {
+ return (
+ actuatorStore.totalInstanceCount > actuatorStore.activatedInstanceCount &&
+ instanceLimitFeature.has(props.feature)
+ );
+});
+
+const show = computed(() => {
+ if (!hasFeature.value) {
+ // show missing feature attention.
+ return true;
}
+ if (instanceMissingLicense.value || existInstanceWithoutLicense.value) {
+ // show missing instance license attention.
+ return true;
+ }
+ return false;
+});
+
+const actionText = computed(() => {
if (!hasPermission.value) {
return "";
}
- if (!subscriptionStore.canTrial) {
- return t("subscription.upgrade");
+
+ if (!hasFeature.value) {
+ return t("subscription.request-n-days-trial", {
+ days: subscriptionStore.trialingDays,
+ });
}
- if (subscriptionStore.canUpgradeTrial) {
- return t("subscription.upgrade-trial-button");
+
+ if (!canManageInstanceLicense.value) {
+ return "";
}
- return t("subscription.request-n-days-trial", {
- days: subscriptionStore.trialingDays,
- });
+ return t("subscription.instance-assignment.assign-license");
});
const featureKey = props.feature.split(".").join("-");
@@ -121,46 +129,50 @@ const descriptionText = computed(() => {
description = t(`dynamic.subscription.features.${featureKey}.desc`);
}
- if (instanceMissingLicense.value) {
- const attention = t(
- "subscription.instance-assignment.missing-license-attention"
- );
- return `${description}\n${attention}`;
- }
+ if (!hasFeature.value) {
+ const startTrial = subscriptionStore.canUpgradeTrial
+ ? t("subscription.upgrade-trial")
+ : subscriptionStore.isTrialing
+ ? ""
+ : t("subscription.trial-for-days", {
+ days: subscriptionStore.trialingDays,
+ });
+ if (!Array.isArray(subscriptionStore.featureMatrix.get(props.feature))) {
+ return `${description}\n${startTrial}`;
+ }
- const startTrial = subscriptionStore.canUpgradeTrial
- ? t("subscription.upgrade-trial")
- : subscriptionStore.isTrialing
- ? ""
- : t("subscription.trial-for-days", {
- days: subscriptionStore.trialingDays,
- });
- if (!Array.isArray(subscriptionStore.featureMatrix.get(props.feature))) {
- return `${description}\n${startTrial}`;
+ const requiredPlan = subscriptionStore.getMinimumRequiredPlan(
+ props.feature
+ );
+ const trialText = t("subscription.required-plan-with-trial", {
+ requiredPlan: t(
+ `subscription.plan.${planTypeToString(requiredPlan)}.title`
+ ),
+ startTrial: startTrial,
+ });
+
+ return `${description}\n${trialText}`;
}
- const requiredPlan = subscriptionStore.getMinimumRequiredPlan(props.feature);
- const trialText = t("subscription.required-plan-with-trial", {
- requiredPlan: t(
- `subscription.plan.${planTypeToString(requiredPlan)}.title`
- ),
- startTrial: startTrial,
- });
-
- return `${description}\n${trialText}`;
+ const attention = t(
+ "subscription.instance-assignment.missing-license-attention"
+ );
+ return `${description}\n${attention}`;
});
const onClick = () => {
- if (instanceMissingLicense.value) {
- state.showInstanceAssignmentDrawer = true;
- } else if (subscriptionStore.canTrial) {
+ if (!hasFeature.value) {
if (locale.value === "zh-CN") {
state.showQRCodeModal = true;
} else {
window.open(ENTERPRISE_INQUIRE_LINK, "_blank");
}
- } else {
- router.push(autoSubscriptionRoute(router));
+ return;
+ }
+ if (instanceMissingLicense.value || existInstanceWithoutLicense.value) {
+ state.showInstanceAssignmentDrawer = true;
+ return;
}
+ router.push(autoSubscriptionRoute(router));
};
</script>
diff --git a/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue b/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue
deleted file mode 100644
index d0b455907c..0000000000
--- a/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue
+++ /dev/null
@@ -1,68 +0,0 @@
-<template>
- <BBAttention
- v-if="
- existInstanceWithoutLicense &&
- instanceLimitFeature.has(feature) &&
- subscriptionV1Store.currentPlan !== PlanType.FREE
- "
- :class="customClass"
- :type="type ?? `info`"
- :title="$t(`dynamic.subscription.features.${featureKey}.desc`)"
- :description="
- $t('subscription.instance-assignment.missing-license-attention')
- "
- :action-text="
- canManageSubscription
- ? $t('subscription.instance-assignment.assign-license')
- : ''
- "
- @click="onClick"
- />
- <InstanceAssignment
- :show="state.showInstanceAssignmentDrawer"
- @dismiss="state.showInstanceAssignmentDrawer = false"
- />
-</template>
-
-<script lang="ts" setup>
-import { reactive, computed } from "vue";
-import { BBAttention } from "@/bbkit";
-import { useSubscriptionV1Store, useActuatorV1Store } from "@/store";
-import type { FeatureType } from "@/types";
-import { instanceLimitFeature } from "@/types";
-import { PlanType } from "@/types/proto/v1/subscription_service";
-import { hasWorkspacePermissionV2 } from "@/utils";
-import InstanceAssignment from "../InstanceAssignment.vue";
-
-interface LocalState {
- showInstanceAssignmentDrawer: boolean;
-}
-
-const props = defineProps<{
- type?: "warning" | "info";
- feature: FeatureType;
- customClass?: string;
-}>();
-
-const state = reactive<LocalState>({
- showInstanceAssignmentDrawer: false,
-});
-
-const subscriptionV1Store = useSubscriptionV1Store();
-const actuatorStore = useActuatorV1Store();
-const featureKey = props.feature.split(".").join("-");
-
-const onClick = () => {
- state.showInstanceAssignmentDrawer = true;
-};
-
-const canManageSubscription = computed((): boolean => {
- return hasWorkspacePermissionV2("bb.instances.update");
-});
-
-const existInstanceWithoutLicense = computed(() => {
- return (
- actuatorStore.totalInstanceCount > actuatorStore.activatedInstanceCount
- );
-});
-</script>
diff --git a/frontend/src/components/FeatureGuard/FeatureBadge.vue b/frontend/src/components/FeatureGuard/FeatureBadge.vue
index 2bf464772d..6133970d4d 100644
--- a/frontend/src/components/FeatureGuard/FeatureBadge.vue
+++ b/frontend/src/components/FeatureGuard/FeatureBadge.vue
@@ -3,7 +3,8 @@
<template>
<div
v-if="instanceMissingLicense"
- :class="['text-accent cursor-pointer', customClass]"
+ class="text-accent cursor-pointer"
+ v-bind="$attrs"
@click="
(e: MouseEvent) => {
e.stopPropagation();
@@ -21,7 +22,7 @@
</span>
</NTooltip>
</div>
- <div v-else-if="!hasFeature" :class="['text-accent', customClass]">
+ <div v-else-if="!hasFeature" class="text-accent" v-bind="$attrs">
<NTooltip :show-arrow="true">
<template #trigger>
<router-link
@@ -57,7 +58,6 @@
<script lang="ts" setup>
import { NTooltip } from "naive-ui";
-import type { PropType } from "vue";
import { reactive, computed } from "vue";
import { useSubscriptionV1Store } from "@/store";
import type { FeatureType } from "@/types";
@@ -73,25 +73,17 @@ interface LocalState {
showInstanceAssignmentDrawer: boolean;
}
-const props = defineProps({
- feature: {
- required: true,
- type: String as PropType<FeatureType>,
- },
- instance: {
- type: Object as PropType<Instance | InstanceResource>,
- default: undefined,
- },
- customClass: {
- require: false,
- default: "",
- type: String,
- },
- clickable: {
- type: Boolean,
- default: false,
- },
-});
+const props = withDefaults(
+ defineProps<{
+ feature: FeatureType;
+ instance?: Instance | InstanceResource;
+ clickable?: boolean;
+ }>(),
+ {
+ instance: undefined,
+ clickable: false,
+ }
+);
const state = reactive<LocalState>({
showInstanceAssignmentDrawer: false,
@@ -100,7 +92,7 @@ const state = reactive<LocalState>({
const subscriptionStore = useSubscriptionV1Store();
const hasFeature = computed(() => {
- return subscriptionStore.hasInstanceFeature(props.feature, props.instance);
+ return subscriptionStore.hasInstanceFeature(props.feature);
});
const instanceMissingLicense = computed(() => {
diff --git a/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue b/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue
deleted file mode 100644
index 2d7af0558d..0000000000
--- a/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue
+++ /dev/null
@@ -1,89 +0,0 @@
-<!-- This component is used when the instance is missing required license. -->
-<!-- Normally this should NOT be a blocker to use the feature, it's just a warning message. -->
-<!-- We can force to show this warning by passing props:show as true -->
-<template>
- <div
- v-if="show || instanceMissingLicense"
- :class="['text-accent cursor-pointer', customClass]"
- @click="
- (e: MouseEvent) => {
- e.stopPropagation();
- e.preventDefault();
- state.showInstanceAssignmentDrawer = true;
- }
- "
- >
- <NTooltip :show-arrow="true">
- <template #trigger>
- <slot name="default">
- <heroicons-outline:exclamation class="text-warning w-5 h-5" />
- </slot>
- </template>
- <span class="w-56 text-sm">
- {{
- tooltip ||
- $t("subscription.instance-assignment.missing-license-for-feature", {
- feature: $t(
- `dynamic.subscription.features.${feature.split(".").join("-")}.title`
- ).toLowerCase(),
- })
- }}
- </span>
- </NTooltip>
- </div>
- <InstanceAssignment
- v-if="(instanceMissingLicense || show) && canManageSubscription"
- :show="state.showInstanceAssignmentDrawer"
- @dismiss="state.showInstanceAssignmentDrawer = false"
- />
-</template>
-
-<script lang="ts" setup>
-import { NTooltip } from "naive-ui";
-import { reactive, computed } from "vue";
-import { useSubscriptionV1Store } from "@/store";
-import type { FeatureType } from "@/types";
-import type {
- Instance,
- InstanceResource,
-} from "@/types/proto/v1/instance_service";
-import { hasWorkspacePermissionV2 } from "@/utils";
-import InstanceAssignment from "../InstanceAssignment.vue";
-
-interface LocalState {
- showInstanceAssignmentDrawer: boolean;
-}
-
-const props = withDefaults(
- defineProps<{
- show?: boolean;
- feature: FeatureType;
- instance?: Instance | InstanceResource;
- customClass?: string;
- tooltip?: string;
- }>(),
- {
- show: false,
- instance: undefined,
- customClass: "",
- tooltip: "",
- }
-);
-
-const state = reactive<LocalState>({
- showInstanceAssignmentDrawer: false,
-});
-
-const subscriptionStore = useSubscriptionV1Store();
-
-const instanceMissingLicense = computed(() => {
- return subscriptionStore.instanceMissingLicense(
- props.feature,
- props.instance
- );
-});
-
-const canManageSubscription = computed((): boolean => {
- return hasWorkspacePermissionV2("bb.instances.update");
-});
-</script>
diff --git a/frontend/src/components/FeatureGuard/index.ts b/frontend/src/components/FeatureGuard/index.ts
index 02663c8263..aacc1175bc 100644
--- a/frontend/src/components/FeatureGuard/index.ts
+++ b/frontend/src/components/FeatureGuard/index.ts
@@ -1,13 +1,5 @@
import FeatureAttention from "./FeatureAttention.vue";
-import FeatureAttentionForInstanceLicense from "./FeatureAttentionForInstanceLicense.vue";
import FeatureBadge from "./FeatureBadge.vue";
-import FeatureBadgeForInstanceLicense from "./FeatureBadgeForInstanceLicense.vue";
import FeatureModal from "./FeatureModal.vue";
-export {
- FeatureAttention,
- FeatureAttentionForInstanceLicense,
- FeatureBadge,
- FeatureBadgeForInstanceLicense,
- FeatureModal,
-};
+export { FeatureAttention, FeatureBadge, FeatureModal };
diff --git a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
index d5b3c397ea..440673a5c3 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/GhostSection/GhostSection.vue
@@ -25,14 +25,10 @@
</i18n-t>
</template>
</NTooltip>
- <FeatureBadge feature="bb.feature.online-migration" />
- <FeatureBadgeForInstanceLicense
+ <FeatureBadge
feature="bb.feature.online-migration"
- :show="hasOnlineMigrationFeature && showMissingInstanceLicense"
:instance="instance"
- >
- <LockIcon class="w-4 h-4 text-accent" />
- </FeatureBadgeForInstanceLicense>
+ />
</div>
<GhostSwitch />
</div>
@@ -50,14 +46,11 @@
</template>
<script lang="ts" setup>
-import { LockIcon } from "lucide-vue-next";
import { NTooltip } from "naive-ui";
import { computed } from "vue";
import { FeatureBadge, FeatureModal } from "@/components/FeatureGuard";
-import FeatureBadgeForInstanceLicense from "@/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue";
import { databaseForTask, useIssueContext } from "@/components/IssueV1/logic";
import LearnMoreLink from "@/components/LearnMoreLink.vue";
-import { featureToRef } from "@/store";
import { isDatabaseChangeRelatedIssue } from "@/utils";
import GhostConfigButton from "./GhostConfigButton.vue";
import GhostFlagsPanel from "./GhostFlagsPanel.vue";
@@ -66,8 +59,7 @@ import { allowGhostForTask, provideIssueGhostContext } from "./common";
const { issue, selectedTask } = useIssueContext();
-const { viewType, showFeatureModal, showMissingInstanceLicense } =
- provideIssueGhostContext();
+const { viewType, showFeatureModal } = provideIssueGhostContext();
const shouldShowGhostSection = computed(() => {
if (!isDatabaseChangeRelatedIssue(issue.value)) {
@@ -87,8 +79,6 @@ const shouldShowGhostSection = computed(() => {
return viewType.value !== "NONE";
});
-const hasOnlineMigrationFeature = featureToRef("bb.feature.online-migration");
-
const instance = computed(() => {
return databaseForTask(issue.value, selectedTask.value).instanceResource;
});
diff --git a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/ReviewSection.vue b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/ReviewSection.vue
index e1bf2ac8cb..c484771435 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/ReviewSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/ReviewSection.vue
@@ -6,7 +6,10 @@
<div>
<div class="textlabel flex items-center gap-x-1">
{{ $t("issue.approval-flow.self") }}
- <FeatureBadge feature="bb.feature.custom-approval" />
+ <FeatureBadge
+ feature="bb.feature.custom-approval"
+ :instance="selectedDatabase.instanceResource"
+ />
</div>
</div>
</template>
@@ -56,7 +59,7 @@
class="flex items-center text-sm text-control-placeholder gap-x-1"
>
{{ $t("custom-approval.approval-flow.skip") }}
- <FeatureBadgeForInstanceLicense
+ <FeatureBadge
v-if="!isGrantRequestIssue(issue)"
feature="bb.feature.custom-approval"
:instance="selectedDatabase.instanceResource"
@@ -67,7 +70,11 @@
<div v-if="isCreating" class="flex flex-col gap-y-1">
<div class="textlabel flex items-center gap-x-1">
{{ $t("issue.approval-flow.self") }}
- <FeatureBadge feature="bb.feature.custom-approval" />
+ <FeatureBadge
+ v-if="!isGrantRequestIssue(issue)"
+ feature="bb.feature.custom-approval"
+ :instance="selectedDatabase.instanceResource"
+ />
</div>
<div class="text-control-placeholder text-xs">
{{ $t("issue.approval-flow.pre-issue-created-tips") }}
@@ -79,7 +86,6 @@
import { NButton, NTooltip } from "naive-ui";
import { computed, ref } from "vue";
import { BBSpin } from "@/bbkit";
-import { FeatureBadgeForInstanceLicense } from "@/components/FeatureGuard";
import FeatureBadge from "@/components/FeatureGuard/FeatureBadge.vue";
import {
databaseForTask,
diff --git a/frontend/src/components/Role/Setting/RoleSetting.vue b/frontend/src/components/Role/Setting/RoleSetting.vue
index f2cb9c3ce7..bcf095028f 100644
--- a/frontend/src/components/Role/Setting/RoleSetting.vue
+++ b/frontend/src/components/Role/Setting/RoleSetting.vue
@@ -20,11 +20,11 @@
>
<template #icon>
<PlusIcon class="h-4 w-4" />
+ <FeatureBadge
+ feature="bb.feature.custom-role"
+ class="mr-1 text-white"
+ />
</template>
- <FeatureBadge
- feature="bb.feature.custom-role"
- custom-class="mr-1 text-white"
- />
{{ $t("role.setting.add") }}
</NButton>
</div>
diff --git a/frontend/src/components/Role/Setting/components/RolePanel.vue b/frontend/src/components/Role/Setting/components/RolePanel.vue
index 35251460e2..8e10953450 100644
--- a/frontend/src/components/Role/Setting/components/RolePanel.vue
+++ b/frontend/src/components/Role/Setting/components/RolePanel.vue
@@ -86,7 +86,7 @@
<NButton type="primary" :disabled="!allowSave" @click="handleSave">
<FeatureBadge
feature="bb.feature.custom-role"
- custom-class="mr-1 text-white"
+ class="mr-1 text-white"
/>
{{ mode === "ADD" ? $t("common.add") : $t("common.update") }}
</NButton>
diff --git a/frontend/src/components/SchemaEditorLite/Panels/TableEditor.vue b/frontend/src/components/SchemaEditorLite/Panels/TableEditor.vue
index 15a60d64c6..99da66f9c8 100644
--- a/frontend/src/components/SchemaEditorLite/Panels/TableEditor.vue
+++ b/frontend/src/components/SchemaEditorLite/Panels/TableEditor.vue
@@ -47,8 +47,10 @@
:disabled="disableChangeTable"
@click="state.showSchemaTemplateDrawer = true"
>
- <FeatureBadge feature="bb.feature.schema-template" />
- <PlusIcon class="w-4 h-auto mr-1 text-gray-400" />
+ <template #icon>
+ <PlusIcon class="w-4 h-auto mr-1 text-gray-400" />
+ <FeatureBadge feature="bb.feature.schema-template" />
+ </template>
{{ $t("schema-editor.actions.add-from-template") }}
</NButton>
</template>
diff --git a/frontend/src/components/v2/Model/DatabaseView.vue b/frontend/src/components/v2/Model/DatabaseView.vue
index 2410ce8c51..9212967387 100644
--- a/frontend/src/components/v2/Model/DatabaseView.vue
+++ b/frontend/src/components/v2/Model/DatabaseView.vue
@@ -2,7 +2,7 @@
<div class="flex flex-row justify-start items-center gap-x-1" v-bind="$attrs">
<FeatureBadge
feature="bb.feature.database-grouping"
- custom-class="mr-2"
+ class="mr-2"
:instance="database.instanceResource"
/>
<InstanceV1EngineIcon :instance="database.instanceResource" />
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 43cc447c79..e11d3cc9be 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1999,8 +1999,7 @@
"manage-license": "Manage Instance License",
"used-and-total-license": "Assigned / Total Instance License",
"used-and-total-user": "Active / Total User Limit",
- "success-notification": "Successfully update license assignment",
- "missing-license-for-feature": "Missing instance license to enable {feature}. Click to assign now."
+ "success-notification": "Successfully update license assignment"
},
"update": {
"success": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index b303d0d9b6..185e7d28f8 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1999,8 +1999,7 @@
"manage-license": "Administrar licencia",
"used-and-total-license": "Licencia asignada / total",
"used-and-total-user": "Límite de usuarios activos/totales",
- "success-notification": "Actualizar correctamente la asignación de licencia",
- "missing-license-for-feature": "Falta la licencia de instancia para habilitar {feature}. Haga clic para asignar ahora."
+ "success-notification": "Actualizar correctamente la asignación de licencia"
},
"update": {
"success": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index e0999c7e8e..d70d69b161 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1999,8 +1999,7 @@
"manage-license": "ライセンスの管理",
"used-and-total-license": "割り当てられた/合計インスタンスライセンス",
"used-and-total-user": "アクティブ/合計ユーザー制限",
- "success-notification": "ライセンスの割り当てが正常に更新されました",
- "missing-license-for-feature": "{feature} を有効にするためのインスタンスライセンスがありません。クリックしてライセンスを割り当てます。"
+ "success-notification": "ライセンスの割り当てが正常に更新されました"
},
"update": {
"success": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index fe3b28b4c4..4f817ff18c 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1999,8 +1999,7 @@
"manage-license": "Quản lý giấy phép phiên bản",
"used-and-total-license": "Giấy phép phiên bản đã gán / Tổng số",
"used-and-total-user": "Giới hạn người dùng đang hoạt động / Tổng số",
- "success-notification": "Đã cập nhật thành công gán giấy phép",
- "missing-license-for-feature": "Thiếu giấy phép phiên bản để bật {feature}. Nhấp để gán ngay."
+ "success-notification": "Đã cập nhật thành công gán giấy phép"
},
"update": {
"success": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 4f9ed68e3b..78fc4f9edf 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1999,8 +1999,7 @@
"manage-license": "管理证书",
"used-and-total-license": "已分配 / 总实例证书",
"used-and-total-user": "活跃/总用户限制",
- "success-notification": "证书分配更新成功",
- "missing-license-for-feature": "缺少实例证书以启用{feature}。点击去分配证书。"
+ "success-notification": "证书分配更新成功"
},
"update": {
"success": {
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index d359a8c311..459d339e13 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -154,7 +154,7 @@
class="text-lg font-medium flex flex-row justify-start items-center"
>
{{ $t("two-factor.self") }}
- <FeatureBadge :feature="'bb.feature.2fa'" custom-class="ml-2" />
+ <FeatureBadge :feature="'bb.feature.2fa'" class="ml-2" />
</span>
<div class="space-x-2">
<NButton v-if="user.email === currentUser.email" @click="enable2FA">
diff --git a/frontend/src/views/SettingWorkspaceCustomApproval.vue b/frontend/src/views/SettingWorkspaceCustomApproval.vue
index c2a38416ca..699fa41eca 100644
--- a/frontend/src/views/SettingWorkspaceCustomApproval.vue
+++ b/frontend/src/views/SettingWorkspaceCustomApproval.vue
@@ -1,10 +1,6 @@
<template>
<div class="w-full space-y-4 text-sm">
- <FeatureAttentionForInstanceLicense
- v-if="hasCustomApprovalFeature"
- feature="bb.feature.custom-approval"
- />
- <FeatureAttention v-else feature="bb.feature.custom-approval" />
+ <FeatureAttention feature="bb.feature.custom-approval" />
<CustomApproval v-if="state.ready" />
<div v-else class="w-full py-[4rem] flex justify-center items-center">
@@ -30,11 +26,7 @@ import {
provideCustomApprovalContext,
TabValueList,
} from "@/components/CustomApproval/Settings/components/CustomApproval/";
-import {
- FeatureAttention,
- FeatureAttentionForInstanceLicense,
- FeatureModal,
-} from "@/components/FeatureGuard";
+import { FeatureAttention, FeatureModal } from "@/components/FeatureGuard";
import { useRouteHash } from "@/composables/useRouteHash";
import {
featureToRef,
diff --git a/frontend/src/views/SettingWorkspaceRiskCenter.vue b/frontend/src/views/SettingWorkspaceRiskCenter.vue
index b5855d3920..62a36874b0 100644
--- a/frontend/src/views/SettingWorkspaceRiskCenter.vue
+++ b/frontend/src/views/SettingWorkspaceRiskCenter.vue
@@ -1,14 +1,5 @@
<template>
- <FeatureAttentionForInstanceLicense
- v-if="hasCustomApprovalFeature"
- feature="bb.feature.custom-approval"
- custom-class="mb-4"
- />
- <FeatureAttention
- v-else
- feature="bb.feature.custom-approval"
- custom-class="mb-4"
- />
+ <FeatureAttention feature="bb.feature.custom-approval" class="mb-4" />
<div class="w-full space-y-4 text-sm">
<div class="textinfolabel">
@@ -46,11 +37,7 @@ import {
provideRiskCenterContext,
} from "@/components/CustomApproval/Settings/components/RiskCenter";
import { provideRiskFilter } from "@/components/CustomApproval/Settings/components/common";
-import {
- FeatureAttention,
- FeatureAttentionForInstanceLicense,
- FeatureModal,
-} from "@/components/FeatureGuard";
+import { FeatureAttention, FeatureModal } from "@/components/FeatureGuard";
import { featureToRef, useRiskStore } from "@/store";
import { hasWorkspacePermissionV2 } from "@/utils";
diff --git a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
index c919116a0d..f9198b5068 100644
--- a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
@@ -1,5 +1,5 @@
<template>
- <FeatureAttention custom-class="mb-4" feature="bb.feature.sql-review" />
+ <FeatureAttention class="mb-4" feature="bb.feature.sql-review" />
<SQLReviewCreation
v-if="state.editMode"
key="sql-review-creation"
diff --git a/frontend/src/views/SettingWorkspaceSSO.vue b/frontend/src/views/SettingWorkspaceSSO.vue
index cddcc3f2e8..b1a7779bbb 100644
--- a/frontend/src/views/SettingWorkspaceSSO.vue
+++ b/frontend/src/views/SettingWorkspaceSSO.vue
@@ -20,10 +20,7 @@
<template #icon>
<PlusIcon class="h-4 w-4" />
</template>
- <FeatureBadge
- :feature="'bb.feature.sso'"
- custom-class="mr-1 text-white"
- />
+ <FeatureBadge :feature="'bb.feature.sso'" class="mr-1 text-white" />
{{ $t("settings.sso.create") }}
</NButton>
</div>
diff --git a/frontend/src/views/SettingWorkspaceSemanticTypes.vue b/frontend/src/views/SettingWorkspaceSemanticTypes.vue
index b5c8d0b880..d8f5ef0b37 100644
--- a/frontend/src/views/SettingWorkspaceSemanticTypes.vue
+++ b/frontend/src/views/SettingWorkspaceSemanticTypes.vue
@@ -1,9 +1,6 @@
<template>
<div class="w-full space-y-4">
- <FeatureAttention
- v-if="!hasSensitiveDataFeature"
- feature="bb.feature.sensitive-data"
- />
+ <FeatureAttention feature="bb.feature.sensitive-data" />
<SemanticTypesView />
</div>
</template>
@@ -11,7 +8,4 @@
<script lang="tsx" setup>
import { FeatureAttention } from "@/components/FeatureGuard";
import { SemanticTypesView } from "@/components/SensitiveData";
-import { featureToRef } from "@/store";
-
-const hasSensitiveDataFeature = featureToRef("bb.feature.sensitive-data");
</script>
diff --git a/frontend/src/views/SettingWorkspaceUsers.vue b/frontend/src/views/SettingWorkspaceUsers.vue
index a6abeddcdf..38f8159bb3 100644
--- a/frontend/src/views/SettingWorkspaceUsers.vue
+++ b/frontend/src/views/SettingWorkspaceUsers.vue
@@ -74,8 +74,8 @@
"
>
<template #icon>
- <SettingsIcon v-if="hasDirectorySyncFeature" class="h-5 w-5" />
- <FeatureBadge v-else feature="bb.feature.directory-sync" />
+ <SettingsIcon class="h-5 w-5" />
+ <FeatureBadge feature="bb.feature.directory-sync" />
</template>
{{ $t(`settings.members.entra-sync.self`) }}
</NButton>
diff --git a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
index 0bc75cc57d..022b7d5021 100644
--- a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
+++ b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
@@ -24,11 +24,10 @@
"
>
<template #icon>
- <PlusIcon v-if="hasDBGroupFeature" class="w-4" />
+ <PlusIcon class="w-4" />
<FeatureBadge
- v-else
feature="bb.feature.database-grouping"
- custom-class="text-white"
+ class="text-white"
/>
</template>
{{ $t("database-group.create") }}
diff --git a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
index 4e9063a7a8..997f597d05 100644
--- a/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
+++ b/frontend/src/views/project/ProjectDatabaseGroupDetail.vue
@@ -4,16 +4,7 @@
v-bind="$attrs"
class="h-full flex-1 relative space-y-4"
>
- <FeatureAttention
- feature="bb.feature.database-grouping"
- custom-class="mb-4"
- />
-
- <FeatureAttentionForInstanceLicense
- custom-class="mb-4"
- type="info"
- feature="bb.feature.database-grouping"
- />
+ <FeatureAttention feature="bb.feature.database-grouping" class="mb-4" />
<div
v-if="hasDatabaseGroupFeature && !state.editing"
@@ -69,7 +60,6 @@ import { computed, reactive, watchEffect } from "vue";
import { useRouter } from "vue-router";
import DatabaseGroupForm from "@/components/DatabaseGroup/DatabaseGroupForm.vue";
import FeatureAttention from "@/components/FeatureGuard/FeatureAttention.vue";
-import FeatureAttentionForInstanceLicense from "@/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue";
import { useDBGroupStore, useProjectByName, featureToRef } from "@/store";
import {
databaseGroupNamePrefix,
diff --git a/frontend/src/views/project/ProjectMaskingExemption.vue b/frontend/src/views/project/ProjectMaskingExemption.vue
index 81a20c0d39..9b9d160ff0 100644
--- a/frontend/src/views/project/ProjectMaskingExemption.vue
+++ b/frontend/src/views/project/ProjectMaskingExemption.vue
@@ -41,11 +41,10 @@
"
>
<template #icon>
- <ShieldCheckIcon v-if="hasSensitiveDataFeature" class="w-4" />
+ <ShieldCheckIcon class="w-4" />
<FeatureBadge
- v-else
feature="bb.feature.sensitive-data"
- custom-class="text-white"
+ class="text-white"
/>
</template>
{{ $t("project.masking-exemption.grant-exemption") }}
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataBlock.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataBlock.vue
index f74d3ddc3e..f15aecca6f 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataBlock.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataBlock.vue
@@ -23,19 +23,12 @@
v-if="isSensitiveColumn(header.index)"
class="ml-0.5 shrink-0"
/>
- <template v-else-if="isColumnMissingSensitive(header.index)">
- <FeatureBadgeForInstanceLicense
- v-if="hasSensitiveFeature"
- :show="true"
- custom-class="ml-0.5 shrink-0"
- feature="bb.feature.sensitive-data"
- />
- <FeatureBadge
- v-else
- feature="bb.feature.sensitive-data"
- custom-class="ml-0.5 shrink-0"
- />
- </template>
+ <FeatureBadge
+ v-else-if="isColumnMissingSensitive(header.index)"
+ feature="bb.feature.sensitive-data"
+ class="ml-0.5 shrink-0"
+ :instance="database.instanceResource"
+ />
:
</div>
<div class="flex-1">
@@ -62,11 +55,8 @@
<script setup lang="ts">
import type { Table } from "@tanstack/vue-table";
import { computed } from "vue";
-import {
- FeatureBadge,
- FeatureBadgeForInstanceLicense,
-} from "@/components/FeatureGuard";
-import { useSubscriptionV1Store } from "@/store";
+import { FeatureBadge } from "@/components/FeatureGuard";
+import { useConnectionOfCurrentSQLEditorTab } from "@/store";
import type { QueryRow, RowValue } from "@/types/proto/v1/sql_service";
import TableCell from "./DataTable/TableCell.vue";
import SensitiveDataIcon from "./DataTable/common/SensitiveDataIcon.vue";
@@ -81,11 +71,7 @@ const props = defineProps<{
}>();
const { keyword } = useSQLResultViewContext();
-const subscriptionStore = useSubscriptionV1Store();
+const { database } = useConnectionOfCurrentSQLEditorTab();
const rows = computed(() => props.table.getRowModel().rows);
-
-const hasSensitiveFeature = computed(() => {
- return subscriptionStore.hasFeature("bb.feature.sensitive-data");
-});
</script>
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue
index 10be542837..203b294007 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/DataTable/DataTable.vue
@@ -44,19 +44,12 @@
v-if="isSensitiveColumn(header.index)"
class="ml-0.5 shrink-0"
/>
- <template v-else-if="isColumnMissingSensitive(header.index)">
- <FeatureBadgeForInstanceLicense
- v-if="hasSensitiveFeature"
- :show="true"
- custom-class="ml-0.5 shrink-0"
- feature="bb.feature.sensitive-data"
- />
- <FeatureBadge
- v-else
- feature="bb.feature.sensitive-data"
- custom-class="ml-0.5 shrink-0"
- />
- </template>
+ <FeatureBadge
+ v-else-if="isColumnMissingSensitive(header.index)"
+ feature="bb.feature.sensitive-data"
+ class="ml-0.5 shrink-0"
+ :instance="database.instanceResource"
+ />
<ColumnSortedIcon
:is-sorted="header.column.getIsSorted()"
@@ -64,7 +57,7 @@
header.column.getToggleSortingHandler()?.($event)
"
/>
-
+
<!-- Add binary format button if this column has binary data -->
<BinaryFormatButton
v-if="isColumnWithBinaryData(header.index)"
@@ -137,21 +130,21 @@
import type { Table } from "@tanstack/vue-table";
import { NEmpty } from "naive-ui";
import { computed, nextTick, onMounted, ref, watch } from "vue";
-import {
- FeatureBadge,
- FeatureBadgeForInstanceLicense,
-} from "@/components/FeatureGuard";
-import { useSubscriptionV1Store } from "@/store";
+import { FeatureBadge } from "@/components/FeatureGuard";
+import { useConnectionOfCurrentSQLEditorTab } from "@/store";
import { type QueryRow, type RowValue } from "@/types/proto/v1/sql_service";
import { useSQLResultViewContext } from "../context";
import TableCell from "./TableCell.vue";
+import {
+ setColumnFormatOverride,
+ setBinaryFormat,
+ getBinaryFormat,
+} from "./binary-format-store";
+import BinaryFormatButton from "./common/BinaryFormatButton.vue";
import ColumnSortedIcon from "./common/ColumnSortedIcon.vue";
import SensitiveDataIcon from "./common/SensitiveDataIcon.vue";
-import BinaryFormatButton from "./common/BinaryFormatButton.vue";
import { useSelectionContext } from "./common/selection-logic";
import useTableColumnWidthLogic from "./useTableResize";
-import { setColumnFormatOverride, setBinaryFormat, getBinaryFormat } from "./binary-format-store";
-import { useConnectionOfCurrentSQLEditorTab } from "@/store";
const props = defineProps<{
table: Table<QueryRow>;
@@ -171,7 +164,6 @@ const {
} = useSelectionContext();
const containerRef = ref<HTMLDivElement>();
const tableRef = ref<HTMLTableElement>();
-const subscriptionStore = useSubscriptionV1Store();
const tableResize = useTableColumnWidthLogic({
tableRef,
@@ -181,10 +173,7 @@ const tableResize = useTableColumnWidthLogic({
});
const { keyword } = useSQLResultViewContext();
-
-const hasSensitiveFeature = computed(() => {
- return subscriptionStore.hasFeature("bb.feature.sensitive-data");
-});
+const { database } = useConnectionOfCurrentSQLEditorTab();
const rows = computed(() => props.table.getRowModel().rows);
@@ -194,129 +183,127 @@ const columnFormatOverrides = ref<Map<number, string | null>>(new Map());
// Check if a column contains any binary data
const isColumnWithBinaryData = (columnIndex: number): boolean => {
const columnRows = props.table.getPrePaginationRowModel().rows;
-
+
// Check each row in the column for binary data
for (const row of columnRows) {
const cell = row.getVisibleCells()[columnIndex];
if (!cell) continue;
-
+
const value = cell.getValue<RowValue>();
if (value?.bytesValue) {
return true;
}
}
-
+
return false;
};
// Determine the suitable format for a column based on column type and content
const getColumnServerFormat = (columnIndex: number): string | null => {
// Get column type name from direct columnTypeNames prop
- let columnType = '';
-
+ let columnType = "";
+
// Use column type names from props
if (props.columnTypeNames && columnIndex < props.columnTypeNames.length) {
columnType = props.columnTypeNames[columnIndex].toLowerCase();
}
-
+
// Default format based on column type (default to HEX)
let defaultFormat = "HEX";
-
+
// Detect BIT column types (bit, varbit, bit varying) - for binary format display
- const isBitColumn = (
+ const isBitColumn =
// Generic bit types
- columnType === 'bit' ||
- columnType.startsWith('bit(') ||
- (columnType.includes('bit') && !columnType.includes('binary')) ||
-
+ columnType === "bit" ||
+ columnType.startsWith("bit(") ||
+ (columnType.includes("bit") && !columnType.includes("binary")) ||
// PostgreSQL bit types
- columnType === 'varbit' ||
- columnType === 'bit varying'
- );
-
+ columnType === "varbit" ||
+ columnType === "bit varying";
+
// Detect BINARY column types (binary, varbinary, bytea, blob, etc) - for hex format display
- const isBinaryColumn = (
+ const isBinaryColumn =
// Generic binary types
- columnType === 'binary' ||
- columnType.includes('binary') ||
-
+ columnType === "binary" ||
+ columnType.includes("binary") ||
// MySQL/MariaDB binary types
- columnType.startsWith('binary(') ||
- columnType.startsWith('varbinary') ||
- columnType.includes('blob') ||
- columnType === 'longblob' ||
- columnType === 'mediumblob' ||
- columnType === 'tinyblob' ||
-
+ columnType.startsWith("binary(") ||
+ columnType.startsWith("varbinary") ||
+ columnType.includes("blob") ||
+ columnType === "longblob" ||
+ columnType === "mediumblob" ||
+ columnType === "tinyblob" ||
// PostgreSQL binary type
- columnType === 'bytea' ||
-
+ columnType === "bytea" ||
// SQL Server binary types
- columnType === 'image' ||
- columnType === 'varbinary(max)' ||
-
+ columnType === "image" ||
+ columnType === "varbinary(max)" ||
// Oracle binary types
- columnType === 'raw' ||
- columnType === 'long raw'
- )
-
+ columnType === "raw" ||
+ columnType === "long raw";
+
// BIT columns default to binary format
if (isBitColumn) {
defaultFormat = "BINARY";
}
-
+
// BINARY/VARBINARY/BLOB columns default to HEX format
if (isBinaryColumn) {
defaultFormat = "HEX";
}
-
+
const columnRows = props.table.getPrePaginationRowModel().rows;
-
+
// Look through rows to find byte values and determine format
for (const row of columnRows) {
const cell = row.getVisibleCells()[columnIndex];
if (!cell) continue;
-
+
const value = cell.getValue<RowValue>();
if (value?.bytesValue) {
// Get default format based on content
// Ensure bytesValue exists before converting to array
const byteArray = value.bytesValue ? Array.from(value.bytesValue) : [];
-
+
// For single byte values (could be boolean)
- if (byteArray.length === 1 && (byteArray[0] === 0 || byteArray[0] === 1)) {
+ if (
+ byteArray.length === 1 &&
+ (byteArray[0] === 0 || byteArray[0] === 1)
+ ) {
return "BOOLEAN";
}
-
+
// Check if it's readable text
- const isReadableText = byteArray.every(byte => byte >= 32 && byte <= 126);
+ const isReadableText = byteArray.every(
+ (byte) => byte >= 32 && byte <= 126
+ );
if (isReadableText) {
return "TEXT";
}
-
+
// Return default format based on column type
return defaultFormat;
}
}
-
+
return null;
};
// Check if a column has any single-bit values
const hasColumnSingleBitValues = (columnIndex: number): boolean => {
const columnRows = props.table.getPrePaginationRowModel().rows;
-
+
// Check if any row in this column has a single-bit value
for (const row of columnRows) {
const cell = row.getVisibleCells()[columnIndex];
if (!cell) continue;
-
+
const value = cell.getValue<RowValue>();
if (value?.bytesValue?.length === 1) {
return true;
}
}
-
+
return false;
};
@@ -332,17 +319,16 @@ const setColumnFormat = (columnIndex: number, format: string | null) => {
} else {
columnFormatOverrides.value.set(columnIndex, format);
}
-
+
// Store the format in the binary format store for use during copy
- const { database } = useConnectionOfCurrentSQLEditorTab();
- const databaseName = database.value?.name || '';
+ const databaseName = database.value?.name || "";
setColumnFormatOverride({
colIndex: columnIndex,
format,
setIndex: props.setIndex,
- databaseName
+ databaseName,
});
-
+
// Force a re-render
columnFormatOverrides.value = new Map(columnFormatOverrides.value);
};
@@ -350,14 +336,17 @@ const setColumnFormat = (columnIndex: number, format: string | null) => {
onMounted(() => {
nextTick(() => {
tableResize.reset();
-
+
// Store auto-detected formats for all binary columns
// This ensures the format is available for copy operations
- const { database } = useConnectionOfCurrentSQLEditorTab();
- const databaseName = database.value?.name || '';
-
+ const databaseName = database.value?.name || "";
+
// For each column with binary data, store its server-detected format
- for (let colIndex = 0; colIndex < props.table.getAllColumns().length; colIndex++) {
+ for (
+ let colIndex = 0;
+ colIndex < props.table.getAllColumns().length;
+ colIndex++
+ ) {
if (isColumnWithBinaryData(colIndex)) {
const serverFormat = getColumnServerFormat(colIndex);
if (serverFormat) {
@@ -365,7 +354,7 @@ onMounted(() => {
// This would override cell-specific formats for all cells in the column
// We only want to set it when the user explicitly chooses a format
// setColumnFormatOverride(colIndex, serverFormat, props.setIndex, databaseName);
-
+
// Only set formats for cells that don't already have a format
const rows = props.table.getPrePaginationRowModel().rows;
rows.forEach((row, rowIndex) => {
@@ -376,7 +365,7 @@ onMounted(() => {
rowIndex,
colIndex,
setIndex: props.setIndex,
- databaseName
+ databaseName,
});
if (!existingFormat) {
// Only set if no format exists yet
@@ -385,7 +374,7 @@ onMounted(() => {
colIndex,
format: serverFormat,
setIndex: props.setIndex,
- databaseName
+ databaseName,
});
}
}