Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update feature badge (#8033)
ecmadao06371484a942
diff --git a/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue b/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vueindex 11313f93f3..28e5506793 100644--- a/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue+++ b/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue@@ -10,7 +10,11 @@:description="$t('subscription.instance-assignment.missing-license-attention')"- :action-text="$t('subscription.instance-assignment.assign-license')"+ :action-text="+ canManageSubscription+ ? $t('subscription.instance-assignment.assign-license')+ : ''+ "@click-action="onClick"/><InstanceAssignment@@ -20,11 +24,12 @@</template><script lang="ts" setup>-import { reactive } from "vue";+import { reactive, computed } from "vue";import { BBAttentionStyle } from "@/bbkit";-import { useSubscriptionV1Store } from "@/store";+import { useSubscriptionV1Store, useCurrentUserV1 } from "@/store";import { FeatureType, instanceLimitFeature } from "@/types";import { PlanType } from "@/types/proto/v1/subscription_service";+import { hasWorkspacePermissionV1 } from "@/utils";interface LocalState {showInstanceAssignmentDrawer: boolean;@@ -42,8 +47,16 @@ const state = reactive<LocalState>({const subscriptionV1Store = useSubscriptionV1Store();const featureKey = props.feature.split(".").join("-");+const currentUserV1 = useCurrentUserV1();const onClick = () => {state.showInstanceAssignmentDrawer = true;};++const canManageSubscription = computed((): boolean => {+ return hasWorkspacePermissionV1(+ "bb.permission.workspace.manage-subscription",+ currentUserV1.value.userRole+ );+});</script>diff --git a/frontend/src/components/FeatureGuard/FeatureBadge.vue b/frontend/src/components/FeatureGuard/FeatureBadge.vueindex 6b9a1e8907..fd8caced28 100644--- a/frontend/src/components/FeatureGuard/FeatureBadge.vue+++ b/frontend/src/components/FeatureGuard/FeatureBadge.vue@@ -1,3 +1,5 @@+<!-- This component is used when uses don't have available plan to access the feature, or the instance is missing required license. -->+<!-- Normally this should be a blocker to use the feature --><template><divv-if="instanceMissingLicense"@@ -41,7 +43,7 @@</NTooltip></template><InstanceAssignment- v-if="instanceMissingLicense"+ v-if="instanceMissingLicense && canManageSubscription":show="state.showInstanceAssignmentDrawer"@dismiss="state.showInstanceAssignmentDrawer = false"/>@@ -50,9 +52,10 @@<script lang="ts" setup>import { NTooltip } from "naive-ui";import { reactive, PropType, computed } from "vue";-import { useSubscriptionV1Store } from "@/store";+import { useSubscriptionV1Store, useCurrentUserV1 } from "@/store";import { FeatureType, planTypeToString } from "@/types";import { Instance } from "@/types/proto/v1/instance_service";+import { hasWorkspacePermissionV1 } from "@/utils";interface LocalState {showInstanceAssignmentDrawer: boolean;@@ -83,6 +86,7 @@ const state = reactive<LocalState>({});const subscriptionStore = useSubscriptionV1Store();+const currentUserV1 = useCurrentUserV1();const hasFeature = computed(() => {return subscriptionStore.hasInstanceFeature(props.feature, props.instance);@@ -94,4 +98,11 @@ const instanceMissingLicense = computed(() => {props.instance);});++const canManageSubscription = computed((): boolean => {+ return hasWorkspacePermissionV1(+ "bb.permission.workspace.manage-subscription",+ currentUserV1.value.userRole+ );+});</script>diff --git a/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue b/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vueindex 06d2b3fbbe..4111514c30 100644--- a/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue+++ b/frontend/src/components/FeatureGuard/FeatureBadgeForInstanceLicense.vue@@ -1,3 +1,6 @@+<!-- 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><divv-if="show || instanceMissingLicense"@@ -20,7 +23,7 @@</NTooltip></div><InstanceAssignment- v-if="!hasFeature || show"+ v-if="(instanceMissingLicense || show) && canManageSubscription":show="state.showInstanceAssignmentDrawer"@dismiss="state.showInstanceAssignmentDrawer = false"/>@@ -29,9 +32,10 @@<script lang="ts" setup>import { NTooltip } from "naive-ui";import { reactive, PropType, computed } from "vue";-import { useSubscriptionV1Store } from "@/store";+import { useSubscriptionV1Store, useCurrentUserV1 } from "@/store";import { FeatureType } from "@/types";import { Instance } from "@/types/proto/v1/instance_service";+import { hasWorkspacePermissionV1 } from "@/utils";interface LocalState {showInstanceAssignmentDrawer: boolean;@@ -62,10 +66,7 @@ const state = reactive<LocalState>({});const subscriptionStore = useSubscriptionV1Store();--const hasFeature = computed(() => {- return subscriptionStore.hasInstanceFeature(props.feature, props.instance);-});+const currentUserV1 = useCurrentUserV1();const instanceMissingLicense = computed(() => {return subscriptionStore.instanceMissingLicense(@@ -73,4 +74,11 @@ const instanceMissingLicense = computed(() => {props.instance);});++const canManageSubscription = computed((): boolean => {+ return hasWorkspacePermissionV1(+ "bb.permission.workspace.manage-subscription",+ currentUserV1.value.userRole+ );+});</script>diff --git a/frontend/src/components/InstanceForm/ScanIntervalInput.vue b/frontend/src/components/InstanceForm/ScanIntervalInput.vueindex 27ae8c235a..3924a4ddfa 100644--- a/frontend/src/components/InstanceForm/ScanIntervalInput.vue+++ b/frontend/src/components/InstanceForm/ScanIntervalInput.vue@@ -9,54 +9,50 @@<div class="flex items-center gap-x-6"><NRadio:checked="mode === 'DEFAULT'"- :disabled="!allowEdit"+ :disabled="!allowEdit || !hasSecretFeature"value="DEFAULT"@click="handleModeChange('DEFAULT')">{{ $t("instance.scan-interval.default-never") }}</NRadio>- <NRadio- :checked="mode === 'CUSTOM'"- :disabled="!allowEdit"- value="CUSTOM"- class="!items-center"- @click="handleModeChange('CUSTOM')"- >- <div class="flex items-center gap-x-1.5">- <span>{{ $t("common.custom") }}</span>- <NInputNumber- v-model:value="minutes"- :show-button="false"- :min="30"- placeholder=""- size="small"- style="width: 4rem"- :disabled="mode !== 'CUSTOM'"- />- <span>{{ $t("common.minutes") }}</span>- <FeatureBadgeForInstanceLicense- feature="bb.feature.custom-instance-scan-interval"- :instance="instance"- />- </div>- </NRadio>+ <div class="flex items-center">+ <NRadio+ :checked="mode === 'CUSTOM'"+ :disabled="!allowEdit || !hasSecretFeature"+ value="CUSTOM"+ class="!items-center"+ @click="handleModeChange('CUSTOM')"+ >+ <div class="flex items-center gap-x-1.5">+ <span>{{ $t("common.custom") }}</span>+ <NInputNumber+ v-model:value="minutes"+ :show-button="false"+ :min="30"+ placeholder=""+ size="small"+ style="width: 4rem"+ :disabled="mode !== 'CUSTOM'"+ />+ <span>{{ $t("common.minutes") }}</span>+ </div>+ </NRadio>+ <FeatureBadge+ feature="bb.feature.custom-instance-scan-interval"+ :instance="instance"+ :clickable="allowEdit"+ />+ </div></div>-- <InstanceAssignment- :show="showInstanceAssignment"- @dismiss="handleInstanceAssignmentDismiss"- /></div></template><script setup lang="ts">import { NInputNumber, NRadio } from "naive-ui";-import { computed, reactive, ref } from "vue";+import { computed, reactive } from "vue";import { useSubscriptionV1Store } from "@/store";import { Duration } from "@/types/proto/google/protobuf/duration";-import FeatureBadgeForInstanceLicense from "../FeatureGuard/FeatureBadgeForInstanceLicense.vue";-import InstanceAssignment from "../InstanceAssignment.vue";import { useInstanceFormContext } from "./context";type Mode = "DEFAULT" | "CUSTOM";@@ -72,8 +68,13 @@ const emit = defineEmits<{const subscriptionStore = useSubscriptionV1Store();const { instance } = useInstanceFormContext();-const showInstanceAssignment = ref(false);-const ongoingInstanceAssignmentCallback = ref<() => void>();++const hasSecretFeature = computed(() => {+ return subscriptionStore.hasInstanceFeature(+ "bb.feature.custom-instance-scan-interval",+ instance.value+ );+});const mode = computed(() => {const duration = props.scanInterval;@@ -104,19 +105,6 @@ const minutes = computed({return;}- if (- !subscriptionStore.hasInstanceFeature(- "bb.feature.custom-instance-scan-interval",- instance.value- )- ) {- showInstanceAssignment.value = true;- ongoingInstanceAssignmentCallback.value = () => {- minutes.value = value;- };- return;- }-state.minutes = value;const duration = Duration.fromPartial({seconds: value * 60,@@ -129,38 +117,7 @@ const handleModeChange = (mode: Mode) => {if (mode === "DEFAULT") {minutes.value = undefined;} else {- if (- !subscriptionStore.hasInstanceFeature(- "bb.feature.custom-instance-scan-interval",- instance.value- )- ) {- showInstanceAssignment.value = true;- ongoingInstanceAssignmentCallback.value = () => {- handleModeChange(mode);- };- return;- }-minutes.value = state.minutes ?? 1440;}};--const handleInstanceAssignmentDismiss = () => {- showInstanceAssignment.value = false;- const callback = ongoingInstanceAssignmentCallback.value;- if (!callback) return;- ongoingInstanceAssignmentCallback.value = undefined;- // Check the feature again, if we successfully assigned the instance's- // license, we should run the callback, which is the operation caused the- // drawer to open.- if (- subscriptionStore.hasInstanceFeature(- "bb.feature.custom-instance-scan-interval",- instance.value- )- ) {- callback();- }-};</script>