Skip to content

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

chore: ui optimize for instance license (#6793)

ecmadaofad37eb9033e
diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.go
index 91dc232a3c..80a2e6bfb8 100644
--- a/backend/api/v1/instance_service.go
+++ b/backend/api/v1/instance_service.go
@@ -113,7 +113,7 @@ func (s *InstanceService) CreateInstance(ctx context.Context, request *v1pb.Crea
return convertToInstance(instanceMessage), nil
}
- instanceCountLimit := s.licenseService.LoadSubscription(ctx).InstanceCount
+ instanceCountLimit := s.licenseService.GetInstanceLicenseCount(ctx)
if instanceMessage.Activation {
if err := s.store.CheckActivationLimit(ctx, instanceCountLimit); err != nil {
if common.ErrorCode(err) == common.Invalid {
@@ -197,7 +197,7 @@ func (s *InstanceService) UpdateInstance(ctx context.Context, request *v1pb.Upda
}
}
- instanceCountLimit := s.licenseService.LoadSubscription(ctx).InstanceCount
+ instanceCountLimit := s.licenseService.GetInstanceLicenseCount(ctx)
if v := patch.Activation; v != nil && *v {
if err := s.store.CheckActivationLimit(ctx, instanceCountLimit); err != nil {
if common.ErrorCode(err) == common.Invalid {
diff --git a/backend/enterprise/api/license.go b/backend/enterprise/api/license.go
index 1a18d18e52..2ffdc85f52 100644
--- a/backend/enterprise/api/license.go
+++ b/backend/enterprise/api/license.go
@@ -71,6 +71,8 @@ type LicenseService interface {
GetEffectivePlan() api.PlanType
// GetPlanLimitValue gets the limit value for the plan.
GetPlanLimitValue(name api.PlanLimit) int64
+ // GetInstanceLicenseCount returns the instance count limit for current subscription.
+ GetInstanceLicenseCount(ctx context.Context) int
// RefreshCache will invalidate and refresh the subscription cache.
RefreshCache(ctx context.Context)
}
diff --git a/backend/enterprise/service/license.go b/backend/enterprise/service/license.go
index 6485140cc3..031d31e267 100644
--- a/backend/enterprise/service/license.go
+++ b/backend/enterprise/service/license.go
@@ -4,6 +4,7 @@ package service
import (
"context"
"encoding/json"
+ "math"
"time"
"github.com/golang-jwt/jwt/v4"
@@ -116,6 +117,15 @@ func (s *LicenseService) IsFeatureEnabledForInstance(feature api.FeatureType, in
return featureEnabledForPlan && instance.Activation
}
+// GetInstanceLicenseCount returns the instance count limit for current subscription.
+func (s *LicenseService) GetInstanceLicenseCount(ctx context.Context) int {
+ instanceCount := s.LoadSubscription(ctx).InstanceCount
+ if instanceCount < 0 {
+ return math.MaxInt
+ }
+ return instanceCount
+}
+
// GetEffectivePlan gets the effective plan.
func (s *LicenseService) GetEffectivePlan() api.PlanType {
ctx := context.Background()
diff --git a/frontend/src/assets/css/tailwind.css b/frontend/src/assets/css/tailwind.css
index a43b73a37f..15f0c8aee6 100644
--- a/frontend/src/assets/css/tailwind.css
+++ b/frontend/src/assets/css/tailwind.css
@@ -266,7 +266,8 @@
}
.tooltip-wrapper:hover .tooltip,
-.tooltip-wrapper:hover .tooltip-left {
+.tooltip-wrapper:hover .tooltip-left,
+.tooltip-wrapper:hover .tooltip-top {
@apply visible z-50;
}
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
index 864be5c806..707978db26 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
@@ -1,5 +1,9 @@
<template>
<div class="w-full">
+ <FeatureAttentionForInstanceLicense
+ custom-class="mb-5"
+ feature="bb.feature.database-grouping"
+ />
<div class="w-full grid grid-cols-3 gap-x-6 pb-6 mb-4 border-b">
<div>
<p class="text-lg mb-2">{{ $t("common.name") }}</p>
diff --git a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
index 57c1d6a402..fbdfe11606 100644
--- a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
+++ b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
@@ -73,15 +73,11 @@
>
<NEllipsis class="text-sm" line-clamp="1">
{{ database.databaseName }}
+ ({{ database.instanceEntity.environmentEntity.title }})
</NEllipsis>
<div class="flex flex-row justify-end items-center shrink-0">
- <InstanceV1EngineIcon :instance="database.instanceEntity" />
- <NEllipsis
- class="ml-1 text-sm text-gray-400 max-w-[124px]"
- line-clamp="1"
- >
- ({{ database.instanceEntity.environmentEntity.title }})
- {{ database.instanceEntity.title }}
+ <NEllipsis class="ml-1 text-sm text-gray-400" line-clamp="1">
+ <InstanceV1Name :instance="database.instanceEntity" :link="false" />
</NEllipsis>
</div>
</div>
@@ -93,7 +89,11 @@
import { NEllipsis } from "naive-ui";
import { ref, watch, reactive } from "vue";
import { ConditionGroupExpr } from "@/plugins/cel";
-import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";
+import {
+ useDatabaseV1Store,
+ useEnvironmentV1Store,
+ useSubscriptionV1Store,
+} from "@/store";
import { ComposedDatabase, ComposedProject } from "@/types";
import { InstanceV1EngineIcon } from "../v2";
import { DatabaseGroup } from "@/types/proto/v1/project_service";
@@ -119,6 +119,7 @@ const props = defineProps<{
const environmentStore = useEnvironmentV1Store();
const databaseStore = useDatabaseV1Store();
+const subscriptionV1Store = useSubscriptionV1Store();
const state = reactive<LocalState>({
isRequesting: false,
showMatchedDatabaseList: true,
@@ -153,8 +154,19 @@ const updateMatchingState = useDebounceFn(async () => {
unmatchedDatabaseList.value = [];
for (const item of result.matchedDatabases) {
const database = await databaseStore.getOrFetchDatabaseByName(item.name);
- if (database) {
+ if (!database) {
+ continue;
+ }
+
+ if (
+ subscriptionV1Store.hasInstanceFeature(
+ "bb.feature.database-grouping",
+ database.instanceEntity
+ )
+ ) {
matchedDatabaseList.value.push(database);
+ } else {
+ unmatchedDatabaseList.value.push(database);
}
}
for (const item of result.unmatchedDatabases) {
diff --git a/frontend/src/components/FeatureGuard/FeatureAttention.vue b/frontend/src/components/FeatureGuard/FeatureAttention.vue
index 039f2ae5ca..ddf017f4c2 100644
--- a/frontend/src/components/FeatureGuard/FeatureAttention.vue
+++ b/frontend/src/components/FeatureGuard/FeatureAttention.vue
@@ -8,21 +8,25 @@
:action-text="actionText"
@click-action="onClick"
/>
+ <InstanceAssignment
+ :show="state.showInstanceAssignmentDrawer"
+ @dismiss="state.showInstanceAssignmentDrawer = false"
+ />
</template>
<script lang="ts" setup>
-import { PropType, computed } from "vue";
+import { reactive, PropType, computed } from "vue";
import { FeatureType, planTypeToString } from "@/types";
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
-import {
- useSubscriptionV1Store,
- featureToRef,
- pushNotification,
-} from "@/store";
+import { useSubscriptionV1Store, pushNotification } from "@/store";
import { PlanType } from "@/types/proto/v1/subscription_service";
import { Instance } from "@/types/proto/v1/instance_service";
+interface LocalState {
+ showInstanceAssignmentDrawer: boolean;
+}
+
const props = defineProps({
feature: {
required: true,
@@ -47,8 +51,13 @@ const props = defineProps({
const router = useRouter();
const { t } = useI18n();
const subscriptionStore = useSubscriptionV1Store();
+const state = reactive<LocalState>({
+ showInstanceAssignmentDrawer: false,
+});
-const hasFeature = featureToRef(props.feature, props.instance);
+const hasFeature = computed(() => {
+ return subscriptionStore.hasInstanceFeature(props.feature, props.instance);
+});
const instanceMissingLicense = computed(() => {
return subscriptionStore.instanceMissingLicense(
@@ -109,12 +118,7 @@ const descriptionText = computed(() => {
const onClick = () => {
if (instanceMissingLicense.value) {
- router.push({
- name: "setting.workspace.subscription",
- query: {
- manageLicense: 1,
- },
- });
+ state.showInstanceAssignmentDrawer = true;
} else if (subscriptionStore.canTrial) {
const isUpgrade = subscriptionStore.canUpgradeTrial;
subscriptionStore.trialSubscription(PlanType.ENTERPRISE).then(() => {
diff --git a/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue b/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue
index c8859b0640..72a942ff76 100644
--- a/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue
+++ b/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue
@@ -8,14 +8,21 @@
:action-text="$t('subscription.instance-assignment.assign-license')"
@click-action="onClick"
/>
+ <InstanceAssignment
+ :show="state.showInstanceAssignmentDrawer"
+ @dismiss="state.showInstanceAssignmentDrawer = false"
+ />
</template>
<script lang="ts" setup>
-import { PropType, computed } from "vue";
+import { reactive, PropType, computed } from "vue";
import { FeatureType, instanceLimitFeature } from "@/types";
-import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
+interface LocalState {
+ showInstanceAssignmentDrawer: boolean;
+}
+
const props = defineProps({
feature: {
required: true,
@@ -28,18 +35,14 @@ const props = defineProps({
},
});
-const router = useRouter();
const { t } = useI18n();
-
+const state = reactive<LocalState>({
+ showInstanceAssignmentDrawer: false,
+});
const featureKey = props.feature.split(".").join("-");
const onClick = () => {
- router.push({
- name: "setting.workspace.subscription",
- query: {
- manageLicense: 1,
- },
- });
+ state.showInstanceAssignmentDrawer = true;
};
const descriptionText = computed(() => {
diff --git a/frontend/src/components/FeatureGuard/FeatureBadge.vue b/frontend/src/components/FeatureGuard/FeatureBadge.vue
index db97b10c3a..48ba20da87 100644
--- a/frontend/src/components/FeatureGuard/FeatureBadge.vue
+++ b/frontend/src/components/FeatureGuard/FeatureBadge.vue
@@ -1,21 +1,38 @@
<template>
+ <div
+ v-if="instanceMissingLicense"
+ class="tooltip-wrapper cursor-pointer"
+ @click="state.showInstanceAssignmentDrawer = true"
+ >
+ <heroicons-solid:lock-closed class="text-accent w-5 h-5" />
+ <span class="w-56 text-sm -translate-y-full -translate-x-1/3 tooltip">
+ {{ $t("subscription.instance-assignment.missing-license-attention") }}
+ </span>
+ </div>
<router-link
- v-if="!hasFeature"
- :to="`/setting/subscription${
- instanceMissingLicense ? '?manageLicense=1' : ''
- }`"
+ v-else-if="!hasFeature"
+ to="/setting/subscription"
exact-active-class=""
>
<heroicons-solid:sparkles class="text-accent w-5 h-5" />
</router-link>
+ <InstanceAssignment
+ v-if="!hasFeature"
+ :show="state.showInstanceAssignmentDrawer"
+ @dismiss="state.showInstanceAssignmentDrawer = false"
+ />
</template>
<script lang="ts" setup>
-import { PropType, computed } from "vue";
+import { reactive, PropType, computed } from "vue";
import { FeatureType } from "@/types";
import { useSubscriptionV1Store } from "@/store";
import { Instance } from "@/types/proto/v1/instance_service";
+interface LocalState {
+ showInstanceAssignmentDrawer: boolean;
+}
+
const props = defineProps({
feature: {
required: true,
@@ -27,6 +44,10 @@ const props = defineProps({
},
});
+const state = reactive<LocalState>({
+ showInstanceAssignmentDrawer: false,
+});
+
const subscriptionStore = useSubscriptionV1Store();
const hasFeature = computed(() => {
diff --git a/frontend/src/components/FeatureGuard/FeatureModal.vue b/frontend/src/components/FeatureGuard/FeatureModal.vue
index d8b70b9434..5f0be5a5ca 100644
--- a/frontend/src/components/FeatureGuard/FeatureModal.vue
+++ b/frontend/src/components/FeatureGuard/FeatureModal.vue
@@ -1,12 +1,13 @@
<template>
- <BBModal
- :title="$t('subscription.disabled-feature')"
- @close="$emit('cancel')"
- >
+ <BBModal :title="title" @close="$emit('cancel')">
<div class="min-w-0 md:min-w-[400px] max-w-4xl">
- <div class="flex items-start space-x-2">
+ <div class="flex items-start space-x-2 mt-3">
<div class="flex items-center">
- <heroicons-solid:sparkles class="h-6 w-6 text-accent" />
+ <heroicons-solid:lock-closed
+ v-if="instanceMissingLicense"
+ class="text-accent w-6 h-6"
+ />
+ <heroicons-solid:sparkles v-else class="h-6 w-6 text-accent" />
</div>
<h3
id="modal-headline"
@@ -96,7 +97,11 @@
</button>
</template>
<button v-else type="button" class="btn-primary" @click.prevent="ok">
- {{ $t("common.learn-more") }}
+ {{
+ instanceMissingLicense
+ ? $t("subscription.instance-assignment.assign-license")
+ : $t("common.learn-more")
+ }}
</button>
</div>
</div>
@@ -104,7 +109,7 @@
</template>
<script lang="ts" setup>
-import { PropType } from "vue";
+import { PropType, computed } from "vue";
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import { useSubscriptionV1Store, pushNotification } from "@/store";
@@ -129,15 +134,24 @@ const router = useRouter();
const subscriptionStore = useSubscriptionV1Store();
-const instanceMissingLicense = subscriptionStore.instanceMissingLicense(
- props.feature,
- props.instance
-);
+const instanceMissingLicense = computed(() => {
+ return subscriptionStore.instanceMissingLicense(
+ props.feature,
+ props.instance
+ );
+});
+
+const title = computed(() => {
+ if (instanceMissingLicense.value) {
+ return t("subscription.instance-assignment.require-license");
+ }
+ return t("subscription.disabled-feature");
+});
const ok = () => {
router.push({
name: "setting.workspace.subscription",
- query: instanceMissingLicense
+ query: instanceMissingLicense.value
? {
manageLicense: 1,
}
diff --git a/frontend/src/components/InstanceAssignment.vue b/frontend/src/components/InstanceAssignment.vue
index 29e0e5f604..64a721acf8 100644
--- a/frontend/src/components/InstanceAssignment.vue
+++ b/frontend/src/components/InstanceAssignment.vue
@@ -1,126 +1,134 @@
<template>
- <DrawerContent :title="$t('subscription.instance-assignment.manage-license')">
- <div class="divide-block-border space-y-5 w-[40rem] h-full">
- <div>
- <div class="flex space-x-2">
- <div class="text-gray-400">
- {{ $t("subscription.instance-assignment.used-and-total-license") }}
+ <Drawer :show="show" @close="$emit('dismiss')">
+ <DrawerContent
+ :title="$t('subscription.instance-assignment.manage-license')"
+ >
+ <div class="divide-block-border space-y-5 w-[40rem] h-full">
+ <div>
+ <div class="flex space-x-2">
+ <div class="text-gray-400">
+ {{
+ $t("subscription.instance-assignment.used-and-total-license")
+ }}
+ </div>
+ <LearnMoreLink
+ url="https://www.bytebase.com/docs/administration/license?source=console"
+ class="ml-1 text-sm"
+ />
+ </div>
+ <div class="mt-1 text-4xl flex items-center gap-x-2">
+ <span>{{ assignedLicenseCount }}</span>
+ <span class="text-xl">/</span>
+ <span>{{ totalLicenseCount }}</span>
</div>
- <LearnMoreLink
- url="https://www.bytebase.com/docs/administration/license?source=console"
- class="ml-1 text-sm"
- />
- </div>
- <div class="mt-1 text-4xl flex items-center gap-x-2">
- <span>{{ assignedLicenseCount }}</span>
- <span class="text-xl">/</span>
- <span>{{ totalLicenseCount }}</span>
</div>
- </div>
- <BBTable
- ref="tableRef"
- :column-list="columnList"
- :section-data-source="datasource"
- :show-header="true"
- :custom-header="true"
- :left-bordered="true"
- :right-bordered="true"
- :top-bordered="true"
- :bottom-bordered="true"
- :compact-section="true"
- :row-clickable="false"
- >
- <template #header>
- <th
- v-for="(column, index) in columnList"
- :key="index"
- scope="col"
- class="pl-2 first:pl-4 py-2 text-left text-xs font-medium text-gray-500 tracking-wider capitalize"
- :class="[column.center && 'text-center pr-2']"
+ <BBTable
+ ref="tableRef"
+ :column-list="columnList"
+ :section-data-source="datasource"
+ :show-header="true"
+ :custom-header="true"
+ :left-bordered="true"
+ :right-bordered="true"
+ :top-bordered="true"
+ :bottom-bordered="true"
+ :compact-section="true"
+ :row-clickable="false"
+ >
+ <template #header>
+ <th
+ v-for="(column, index) in columnList"
+ :key="index"
+ scope="col"
+ class="pl-2 first:pl-4 py-2 text-left text-xs font-medium text-gray-500 tracking-wider capitalize"
+ :class="[column.center && 'text-center pr-2']"
+ >
+ <template v-if="index === 0">
+ <input
+ v-if="instanceList.length > 0"
+ type="checkbox"
+ class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
+ :checked="allSelectionState.checked"
+ :indeterminate="allSelectionState.indeterminate"
+ :disabled="
+ !allSelectionState.checked &&
+ instanceList.length > instanceCount
+ "
+ @input="
+ selectAllInstances(
+ ($event.target as HTMLInputElement).checked
+ )
+ "
+ />
+ </template>
+ <template v-else>{{ $t(column.title) }}</template>
+ </th>
+ </template>
+ <template
+ #body="{ rowData: instance }: { rowData: ComposedInstance }"
>
- <template v-if="index === 0">
+ <BBTableCell
+ class="w-[1%]"
+ @click.stop="
+ toggleSelectInstance(instance, !isInstanceSelected(instance))
+ "
+ >
+ <!-- width: 1% means as narrow as possible -->
<input
- v-if="instanceList.length > 0"
type="checkbox"
- class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
- :checked="allSelectionState.checked"
- :indeterminate="allSelectionState.indeterminate"
- :disabled="
- !allSelectionState.checked &&
- instanceList.length > instanceCount
- "
- @input="
- selectAllInstances(
- ($event.target as HTMLInputElement).checked
- )
- "
+ class="ml-2 h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
+ :checked="isInstanceSelected(instance)"
+ :disabled="state.selectedInstance.size == instanceCount"
/>
- </template>
- <template v-else>{{ $t(column.title) }}</template>
- </th>
- </template>
- <template #body="{ rowData: instance }: { rowData: ComposedInstance }">
- <BBTableCell
- class="w-[1%]"
- @click.stop="
- toggleSelectInstance(instance, !isInstanceSelected(instance))
- "
- >
- <!-- width: 1% means as narrow as possible -->
- <input
- type="checkbox"
- class="ml-2 h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
- :checked="isInstanceSelected(instance)"
- :disabled="state.selectedInstance.size == instanceCount"
- />
- </BBTableCell>
- <BBTableCell class="bb-grid-cell">
- <div class="flex items-center gap-x-1">
- <InstanceV1EngineIcon :instance="instance" />
- <router-link
- :to="`/instance/${instanceV1Slug(instance)}`"
- class="hover:underline"
- active-class="link"
- exact-active-class="link"
- >
- {{ instanceV1Name(instance) }}
- </router-link>
- </div>
- </BBTableCell>
- <BBTableCell class="bb-grid-cell">
- <EnvironmentV1Name
- :environment="instance.environmentEntity"
- :link="false"
- />
- </BBTableCell>
- <BBTableCell class="bb-grid-cell">
- {{ hostPortOfInstanceV1(instance) }}
- </BBTableCell>
- </template>
- </BBTable>
- </div>
+ </BBTableCell>
+ <BBTableCell class="bb-grid-cell">
+ <div class="flex items-center gap-x-1">
+ <InstanceV1EngineIcon :instance="instance" />
+ <router-link
+ :to="`/instance/${instanceV1Slug(instance)}`"
+ class="hover:underline"
+ active-class="link"
+ exact-active-class="link"
+ >
+ {{ instanceV1Name(instance) }}
+ </router-link>
+ </div>
+ </BBTableCell>
+ <BBTableCell class="bb-grid-cell">
+ <EnvironmentV1Name
+ :environment="instance.environmentEntity"
+ :link="false"
+ />
+ </BBTableCell>
+ <BBTableCell class="bb-grid-cell">
+ {{ hostPortOfInstanceV1(instance) }}
+ </BBTableCell>
+ </template>
+ </BBTable>
+ </div>
- <template #footer>
- <div class="w-full flex justify-between items-center">
- <div class="w-full flex justify-end items-center gap-x-3">
- <NButton @click.prevent="cancel">
- {{ $t("common.cancel") }}
- </NButton>
- <NButton
- :disabled="
- !assignmentChanged ||
- state.processing ||
- state.selectedInstance.size > instanceCount
- "
- type="primary"
- @click.prevent="updateAssignment"
- >
- {{ $t("common.confirm") }}
- </NButton>
+ <template #footer>
+ <div class="w-full flex justify-between items-center">
+ <div class="w-full flex justify-end items-center gap-x-3">
+ <NButton @click.prevent="cancel">
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ :disabled="
+ !assignmentChanged ||
+ state.processing ||
+ state.selectedInstance.size > instanceCount
+ "
+ type="primary"
+ @click.prevent="updateAssignment"
+ >
+ {{ $t("common.confirm") }}
+ </NButton>
+ </div>
</div>
- </div>
- </template>
- </DrawerContent>
+ </template>
+ </DrawerContent>
+ </Drawer>
</template>
<script lang="ts" setup>
@@ -135,10 +143,18 @@ import {
useInstanceV1Store,
useInstanceV1List,
useSubscriptionV1Store,
+ useDatabaseV1Store,
} from "@/store";
import { ComposedInstance } from "@/types";
import { EnvironmentV1Name, InstanceV1EngineIcon } from "@/components/v2";
-import { DrawerContent } from "@/components/v2";
+import { Drawer, DrawerContent } from "@/components/v2";
+
+defineProps({
+ show: {
+ default: false,
+ type: Boolean,
+ },
+});
const columnList: BBTableColumn[] = [
{
@@ -168,6 +184,7 @@ const state = reactive<LocalState>({
processing: false,
});
const instanceV1Store = useInstanceV1Store();
+const databaseV1Store = useDatabaseV1Store();
const subscriptionStore = useSubscriptionV1Store();
const { t } = useI18n();
@@ -183,17 +200,14 @@ watchEffect(() => {
});
const totalLicenseCount = computed((): string => {
- if (instanceCount.value > 0) {
- return `${instanceCount.value}`;
+ if (instanceCount.value === Number.MAX_VALUE) {
+ return t("subscription.unlimited");
}
- return t("subscription.unlimited");
+ return `${instanceCount.value}`;
});
const assignedLicenseCount = computed((): string => {
- if (instanceCount.value > 0) {
- return `${state.selectedInstance.size}`;
- }
- return t("subscription.unlimited");
+ return `${state.selectedInstance.size}`;
});
const tableRef = ref<HTMLTableElement>();
@@ -275,6 +289,7 @@ const updateAssignment = async () => {
// deactivate instance
instance.activation = false;
await instanceV1Store.updateInstance(instance, ["activation"]);
+ databaseV1Store.updateDatabaseInstance(instance);
}
if (instance.activation && selectedInstanceName.has(instance.name)) {
// remove unchanged
@@ -290,6 +305,7 @@ const updateAssignment = async () => {
// activate instance
instance.activation = true;
await instanceV1Store.updateInstance(instance, ["activation"]);
+ databaseV1Store.updateDatabaseInstance(instance);
}
pushNotification({
diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vue
index 2fdedc098b..69b4fd7d91 100644
--- a/frontend/src/components/InstanceForm/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm/InstanceForm.vue
@@ -878,6 +878,15 @@ watch(
}
);
+watch(
+ () => props.instance?.activation,
+ (val) => {
+ if (val !== undefined) {
+ basicInfo.value.activation = val;
+ }
+ }
+);
+
const engineList = computed(() => {
return supportedEngineV1List();
});
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index 031dc01a21..6222b01e3b 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -212,12 +212,16 @@
v-if="quickAction === 'quickaction.bb.subscription.license-assignment'"
class="flex flex-col items-center w-24"
>
- <router-link
- to="/setting/subscription?manageLicense=1"
+ <button
class="btn-icon-primary p-3"
+ @click.prevent="
+ () =>
+ (state.quickActionType =
+ 'quickaction.bb.subscription.license-assignment')
+ "
>
<heroicons-outline:academic-cap class="w-5 h-5" />
- </router-link>
+ </button>
<h3
class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"
>
@@ -284,6 +288,13 @@
v-if="state.showRequestExportPanel"
@close="state.showRequestExportPanel = false"
/>
+
+ <InstanceAssignment
+ :show="
+ state.quickActionType === 'quickaction.bb.subscription.license-assignment'
+ "
+ @dismiss="state.quickActionType = undefined"
+ />
</template>
<script lang="ts" setup>
@@ -438,10 +449,8 @@ const QuickActionMap: Record<string, Partial<Action>> = {
"quickaction.bb.subscription.license-assignment": {
name: t("subscription.instance-assignment.manage-license"),
perform: () =>
- router.push({
- name: "setting.workspace.subscription",
- query: { manageLicense: 1 },
- }),
+ (state.quickActionType =
+ "quickaction.bb.subscription.license-assignment"),
},
};
diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vue
index e64d6b6456..d8c17c3acd 100644
--- a/frontend/src/components/RepositoryForm.vue
+++ b/frontend/src/components/RepositoryForm.vue
@@ -199,6 +199,25 @@
class="ml-1"
/>
</div>
+ <BBAttention
+ v-if="
+ instanceWithoutLicense.length > 0 &&
+ hasFeature('bb.feature.vcs-schema-write-back')
+ "
+ class="my-4"
+ :style="`WARN`"
+ :title="
+ $t('subscription.features.bb-feature-vcs-schema-write-back.title')
+ "
+ :description="
+ $t('subscription.instance-assignment.missing-license-for-instances', {
+ count: instanceWithoutLicense.length,
+ name: instanceWithoutLicense.map((ins) => ins.title).join(','),
+ })
+ "
+ :action-text="$t('subscription.instance-assignment.assign-license')"
+ @click-action="state.showInstanceAssignmentDrawer = true"
+ />
<input
v-if="hasFeature('bb.feature.vcs-schema-write-back')"
id="schemapathtemplate"
@@ -305,6 +324,23 @@
})
}}
</div>
+ <BBAttention
+ v-if="
+ instanceWithoutLicense.length > 0 &&
+ hasFeature('bb.feature.vcs-sql-review')
+ "
+ class="my-4"
+ :style="`WARN`"
+ :title="$t('subscription.features.bb-feature-sql-review.title')"
+ :description="
+ $t('subscription.instance-assignment.missing-license-for-instances', {
+ count: instanceWithoutLicense.length,
+ name: instanceWithoutLicense.map((ins) => ins.title).join(','),
+ })
+ "
+ :action-text="$t('subscription.instance-assignment.assign-license')"
+ @click-action="state.showInstanceAssignmentDrawer = true"
+ />
<div class="flex space-x-4 mt-2">
<BBCheckbox
:disabled="!allowEdit"
@@ -323,13 +359,21 @@
@cancel="state.showFeatureModal = false"
/>
</div>
+ <InstanceAssignment
+ :show="state.showInstanceAssignmentDrawer"
+ @dismiss="state.showInstanceAssignmentDrawer = false"
+ />
</template>
<script lang="ts" setup>
import { reactive, PropType, computed } from "vue";
import { useI18n } from "vue-i18n";
import { ExternalRepositoryInfo, RepositoryConfig } from "@/types";
-import { hasFeature, useSubscriptionV1Store } from "@/store";
+import {
+ hasFeature,
+ useSubscriptionV1Store,
+ useDatabaseV1Store,
+} from "@/store";
import {
Project,
TenantMode,
@@ -344,9 +388,9 @@ const FILE_OPTIONAL_DIRECTORY_WILDCARD = "*, **";
const SINGLE_ASTERISK_REGEX = /\/\*\//g;
const DOUBLE_ASTERISKS_REGEX = /\/\*\*\//g;
-// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface LocalState {
showFeatureModal: boolean;
+ showInstanceAssignmentDrawer: boolean;
}
defineEmits<{
@@ -393,10 +437,21 @@ const { t } = useI18n();
const state = reactive<LocalState>({
showFeatureModal: false,
+ showInstanceAssignmentDrawer: false,
});
const subscriptionStore = useSubscriptionV1Store();
+const databaseV1List = computed(() => {
+ return useDatabaseV1Store().databaseListByProject(props.project.name);
+});
+
+const instanceWithoutLicense = computed(() => {
+ return databaseV1List.value
+ .map((db) => db.instanceEntity)
+ .filter((ins) => !ins.activation);
+});
+
const isTenantProject = computed(() => {
return props.project.tenantMode === TenantMode.TENANT_MODE_ENABLED;
});
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index c0cfa85274..a608430a2f 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1886,11 +1886,13 @@
"instance-assignment": {
"license": "License",
"assign-license": "Assign License",
- "missing-license-attention": "You need to assign license to instance to enable this feature.",
+ "require-license": "Require instance license",
+ "missing-license-attention": "You need to assign license to the instance to enable this feature.",
"n-license-remain": "remain {n}",
"manage-license": "Manage License",
"used-and-total-license": "Assigned / Total Instance License",
- "success-notification": "Successfully update license assignment"
+ "success-notification": "Successfully update license assignment",
+ "missing-license-for-instances": "You have {count} instances ({name}) missing required license to unlock this feature."
},
"update": {
"success": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 66c26ad852..980139a18b 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1872,11 +1872,13 @@
"instance-assignment": {
"license": "Licencia",
"assign-license": "Asignar licencia",
+ "require-license": "Requerir licencia de instancia",
"missing-license-attention": "Debe asignar una licencia a la instancia para habilitar esta función.",
"n-license-remain": "permanecer {n}",
"manage-license": "Administrar licencia",
"used-and-total-license": "Licencia asignada / total",
- "success-notification": "Actualizar correctamente la asignación de licencia"
+ "success-notification": "Actualizar correctamente la asignación de licencia",
+ "missing-license-for-instances": "Tienes {count} instancias ({name}) a las que les falta la licencia requerida para desbloquear esta función."
},
"update": {
"success": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f852e7b7e5..5bff11bd85 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1881,11 +1881,13 @@
"instance-assignment": {
"license": "证书",
"assign-license": "分配证书",
+ "require-license": "需要实例证书",
"missing-license-attention": "请给实例分配证书以解锁该功能。",
"n-license-remain": "剩余 {n}",
"manage-license": "管理证书",
"used-and-total-license": "已分配 / 总实例证书",
- "success-notification": "证书分配更新成功"
+ "success-notification": "证书分配更新成功",
+ "missing-license-for-instances": "您有 {count} 个实例({name})缺失开启该功能的证书。"
},
"update": {
"success": {
diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.ts
index 342f6171e8..c9a6abf530 100644
--- a/frontend/src/store/modules/v1/database.ts
+++ b/frontend/src/store/modules/v1/database.ts
@@ -4,6 +4,7 @@ import { uniq } from "lodash-es";
import { databaseServiceClient } from "@/grpcweb";
import {
+ ComposedInstance,
ComposedDatabase,
emptyDatabase,
EMPTY_ID,
@@ -48,6 +49,19 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {
});
return composedDatabaseList;
};
+ const updateDatabaseInstance = (instance: ComposedInstance) => {
+ for (const [_, database] of databaseMapByName) {
+ if (database.instance !== instance.name) {
+ continue;
+ }
+ if (databaseMapByName.has(database.name)) {
+ databaseMapByName.get(database.name)!.instanceEntity = instance;
+ }
+ if (databaseMapByUID.has(database.uid)) {
+ databaseMapByUID.get(database.uid)!.instanceEntity = instance;
+ }
+ }
+ };
const fetchDatabaseList = async (args: Partial<ListDatabasesRequest>) => {
const { databases } = await databaseServiceClient.listDatabases(args);
const composedDatabaseList = await upsertDatabaseMap(databases);
@@ -161,6 +175,7 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {
getOrFetchDatabaseByUID,
updateDatabase,
fetchDatabaseSchema,
+ updateDatabaseInstance,
};
});
diff --git a/frontend/src/store/modules/v1/subscription.ts b/frontend/src/store/modules/v1/subscription.ts
index 9725ae63e3..0dcec45891 100644
--- a/frontend/src/store/modules/v1/subscription.ts
+++ b/frontend/src/store/modules/v1/subscription.ts
@@ -198,7 +198,7 @@ export const useSubscriptionV1Store = defineStore("subscription_v1", {
trial: {
plan: planType,
days: this.trialingDays,
- instanceCount: -1,
+ instanceCount: 20,
},
});
this.setSubscription(subscription);
diff --git a/frontend/src/types/plan.ts b/frontend/src/types/plan.ts
index 8dea4c1ebb..0fc614bd3e 100644
--- a/frontend/src/types/plan.ts
+++ b/frontend/src/types/plan.ts
@@ -26,6 +26,7 @@ export type FeatureType =
| "bb.feature.online-migration"
| "bb.feature.schema-drift"
| "bb.feature.sql-review"
+ | "bb.feature.mybatis-sql-review"
| "bb.feature.task-schedule-time"
| "bb.feature.encrypted-secrets"
| "bb.feature.database-grouping"
@@ -64,15 +65,16 @@ export const instanceLimitFeature = new Set<FeatureType>([
"bb.feature.instance-ssh-connection",
"bb.feature.sync-schema-all-versions",
"bb.feature.index-advisor",
+ "bb.feature.database-grouping",
// Policy Control
"bb.feature.sensitive-data",
"bb.feature.custom-approval",
+ // VCS Integration
+ "bb.feature.vcs-sql-review",
+ "bb.feature.mybatis-sql-review",
+ "bb.feature.vcs-schema-write-back",
// TODO:
- // "bb.feature.vcs-schema-write-back",
- // "bb.feature.database-grouping",
- // "bb.feature.mybatis-sql-review",
// "bb.feature.online-migration",
- // "bb.feature.vcs-sql-review",
]);
export const planTypeToString = (planType: PlanType): string => {
diff --git a/frontend/src/views/DatabaseGroupDetail.vue b/frontend/src/views/DatabaseGroupDetail.vue
index 72fd90f433..ac17d90a34 100644
--- a/frontend/src/views/DatabaseGroupDetail.vue
+++ b/frontend/src/views/DatabaseGroupDetail.vue
@@ -67,6 +67,11 @@
<hr class="my-4" />
+ <FeatureAttentionForInstanceLicense
+ custom-class="m-5"
+ feature="bb.feature.database-grouping"
+ />
+
<div class="w-full px-3 max-w-5xl grid grid-cols-5 gap-x-6">
<div class="col-span-3">
<p class="pl-1 text-lg mb-2">
diff --git a/frontend/src/views/SettingWorkspaceSubscription.vue b/frontend/src/views/SettingWorkspaceSubscription.vue
index ba9588cf5a..25744ef5ed 100644
--- a/frontend/src/views/SettingWorkspaceSubscription.vue
+++ b/frontend/src/views/SettingWorkspaceSubscription.vue
@@ -47,7 +47,7 @@
class="mt-1 text-4xl flex items-center gap-x-2 cursor-pointer group"
@click="state.showInstanceAssignmentDrawer = true"
>
- <span class="group-hover:underline">{{ availableLicenseCount }}</span>
+ <span class="group-hover:underline">{{ activateLicenseCount }}</span>
<span class="text-xl">/</span>
<span class="group-hover:underline">{{ totalLicenseCount }}</span>
<heroicons-outline:pencil class="h-6 w-6" />
@@ -132,12 +132,10 @@
/>
</div>
- <Drawer
+ <InstanceAssignment
:show="state.showInstanceAssignmentDrawer"
- @close="state.showInstanceAssignmentDrawer = false"
- >
- <InstanceAssignment @dismiss="state.showInstanceAssignmentDrawer = false" />
- </Drawer>
+ @dismiss="state.showInstanceAssignmentDrawer = false"
+ />
</template>
<script lang="ts" setup>
@@ -153,7 +151,6 @@ import {
} from "@/store";
import { storeToRefs } from "pinia";
import { hasWorkspacePermissionV1 } from "@/utils";
-import { Drawer } from "@/components/v2";
interface LocalState {
loading: boolean;
@@ -214,17 +211,14 @@ const { expireAt, isTrialing, isExpired, instanceCount } =
storeToRefs(subscriptionStore);
const totalLicenseCount = computed((): string => {
- if (instanceCount.value > 0) {
- return `${instanceCount.value}`;
+ if (instanceCount.value === Number.MAX_VALUE) {
+ return t("subscription.unlimited");
}
- return t("subscription.unlimited");
+ return `${instanceCount.value}`;
});
-const availableLicenseCount = computed((): string => {
- if (instanceCount.value > 0) {
- return `${instanceV1Store.activateInstanceCount}`;
- }
- return t("subscription.unlimited");
+const activateLicenseCount = computed((): string => {
+ return `${instanceV1Store.activateInstanceCount}`;
});
const currentPlan = computed((): string => {