Skip to content

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

chore: update feature guard in frontend (#6828)

ecmadaodcf4500dc54d
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index 527aa6785f..c58ffc0fac 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -1886,7 +1886,7 @@ func (s *ProjectService) GetSchemaGroup(ctx context.Context, request *v1pb.GetSc
return s.convertStoreToAPISchemaGroupFull(ctx, schemaGroup, databaseGroup, projectResourceID)
}
-func (s *ProjectService) getMatchedAndUnmatchedDatabasesInDatabaseGroup(ctx context.Context, databaseGroup *store.DatabaseGroupMessage, allDatabases []*store.DatabaseMessage) ([]*store.DatabaseMessage, []*store.DatabaseMessage, error) {
+func getMatchedAndUnmatchedDatabasesInDatabaseGroup(ctx context.Context, databaseGroup *store.DatabaseGroupMessage, allDatabases []*store.DatabaseMessage) ([]*store.DatabaseMessage, []*store.DatabaseMessage, error) {
prog, err := common.ValidateGroupCELExpr(databaseGroup.Expression.Expression)
if err != nil {
return nil, nil, err
@@ -1894,6 +1894,8 @@ func (s *ProjectService) getMatchedAndUnmatchedDatabasesInDatabaseGroup(ctx cont
var matches []*store.DatabaseMessage
var unmatches []*store.DatabaseMessage
+ // DONOT check bb.feature.database-grouping for instance. The API here is read-only in the frontend, we need to show if the instance is matched but missing required license.
+ // The feature guard will works during issue creation.
for _, database := range allDatabases {
res, _, err := prog.ContextEval(ctx, map[string]any{
"resource": map[string]any{
@@ -1911,18 +1913,7 @@ func (s *ProjectService) getMatchedAndUnmatchedDatabasesInDatabaseGroup(ctx cont
return nil, nil, status.Errorf(codes.Internal, "expect bool result")
}
if boolVal, ok := val.(bool); ok && boolVal {
- instance, err := s.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &database.InstanceID})
- if err != nil {
- return nil, nil, status.Errorf(codes.Internal, "failed to found instance %s with error: %v", database.InstanceID, err.Error())
- }
- if instance == nil {
- return nil, nil, status.Errorf(codes.Internal, "cannot found instance %s", database.InstanceID)
- }
- if s.licenseService.IsFeatureEnabledForInstance(api.FeatureDatabaseGrouping, instance) == nil {
- matches = append(matches, database)
- } else {
- unmatches = append(unmatches, database)
- }
+ matches = append(matches, database)
} else {
unmatches = append(unmatches, database)
}
@@ -1938,7 +1929,7 @@ func (s *ProjectService) convertStoreToAPIDatabaseGroupFull(ctx context.Context,
return nil, status.Errorf(codes.Internal, err.Error())
}
- matches, unmatches, err := s.getMatchedAndUnmatchedDatabasesInDatabaseGroup(ctx, databaseGroup, databases)
+ matches, unmatches, err := getMatchedAndUnmatchedDatabasesInDatabaseGroup(ctx, databaseGroup, databases)
if err != nil {
return nil, err
}
@@ -1990,7 +1981,7 @@ func (s *ProjectService) getMatchesAndUnmatchedTables(ctx context.Context, schem
if err != nil {
return nil, nil, status.Errorf(codes.Internal, err.Error())
}
- matchesDatabases, _, err := s.getMatchedAndUnmatchedDatabasesInDatabaseGroup(ctx, databaseGroup, allDatabases)
+ matchesDatabases, _, err := getMatchedAndUnmatchedDatabasesInDatabaseGroup(ctx, databaseGroup, allDatabases)
if err != nil {
return nil, nil, err
}
diff --git a/backend/server/webhook.go b/backend/server/webhook.go
index 6894c0bd1e..57db7acc87 100644
--- a/backend/server/webhook.go
+++ b/backend/server/webhook.go
@@ -1920,7 +1920,11 @@ func getSQLAdviceFileList(adviceMap map[string][]advisor.Advice) []string {
}
fileToErrorCount[filePath] = errorCount
}
+ sort.Strings(fileList)
sort.Slice(fileList, func(i int, j int) bool {
+ if fileToErrorCount[fileList[i]] == fileToErrorCount[fileList[j]] {
+ return i < j
+ }
return fileToErrorCount[fileList[i]] > fileToErrorCount[fileList[j]]
})
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index 405861f2b6..e4d708adb4 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -84,7 +84,7 @@
:database-list="schemaDatabaseList"
:show-selection-column="true"
@select-database="
- (db) =>
+ (db: ComposedDatabase) =>
toggleDatabaseSelection(db, !isDatabaseSelected(db))
"
>
diff --git a/frontend/src/components/AlterSchemaPrepForm/GhostDialog.vue b/frontend/src/components/AlterSchemaPrepForm/GhostDialog.vue
index 2709b96312..855acc3d4e 100644
--- a/frontend/src/components/AlterSchemaPrepForm/GhostDialog.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/GhostDialog.vue
@@ -35,10 +35,7 @@
<div @click="state.mode = 'online'">
<div class="textlabel flex items-center space-x-2">
<span>{{ $t("issue.migration-mode.online.title") }}</span>
- <FeatureBadge
- feature="bb.feature.online-migration"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.online-migration" />
<BBBetaBadge />
</div>
<div class="textinfolabel mt-1">
diff --git a/frontend/src/components/ColumnTable.vue b/frontend/src/components/ColumnTable.vue
index c725f65097..5b813caeb4 100644
--- a/frontend/src/components/ColumnTable.vue
+++ b/frontend/src/components/ColumnTable.vue
@@ -14,19 +14,26 @@
class="w-[1%] text-center"
>
<!-- width: 1% means as narrow as possible -->
- <input
- type="checkbox"
- class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
- :disabled="!allowAdmin"
- :checked="isSensitiveColumn(column)"
- @input="
- toggleSensitiveColumn(
- column,
- ($event.target as HTMLInputElement).checked,
- $event
- )
- "
- />
+ <div class="flex items-center justify-center">
+ <FeatureBadge
+ feature="bb.feature.sensitive-data"
+ custom-class="mr-2"
+ :instance="database.instanceEntity"
+ />
+ <input
+ type="checkbox"
+ class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"
+ :disabled="!allowAdmin || instanceMissingLicense"
+ :checked="isSensitiveColumn(column)"
+ @input="
+ toggleSensitiveColumn(
+ column,
+ ($event.target as HTMLInputElement).checked,
+ $event
+ )
+ "
+ />
+ </div>
</BBTableCell>
<BBTableCell class="w-16" :left-padding="showSensitiveColumn ? 2 : 4">
{{ column.name }}
@@ -65,6 +72,7 @@
<FeatureModal
v-if="state.showFeatureModal"
feature="bb.feature.sensitive-data"
+ :instance="database.instanceEntity"
@cancel="state.showFeatureModal = false"
/>
</template>
@@ -75,7 +83,7 @@ import { computed, PropType, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { Column, ComposedDatabase } from "@/types";
import { ColumnMetadata, TableMetadata } from "@/types/proto/store/database";
-import { featureToRef, useCurrentUserV1 } from "@/store";
+import { useCurrentUserV1, useSubscriptionV1Store } from "@/store";
import { hasWorkspacePermissionV1 } from "@/utils";
import { BBTableColumn } from "@/bbkit/types";
import { usePolicyV1Store } from "@/store/modules/v1/policy";
@@ -120,8 +128,18 @@ const state = reactive<LocalState>({
const engine = computed(() => {
return props.database.instanceEntity.engine;
});
+const subscriptionV1Store = useSubscriptionV1Store();
+
+const instanceMissingLicense = computed(() => {
+ return subscriptionV1Store.instanceMissingLicense(
+ "bb.feature.sensitive-data",
+ props.database.instanceEntity
+ );
+});
+const hasSensitiveDataFeature = computed(() => {
+ return subscriptionV1Store.hasFeature("bb.feature.sensitive-data");
+});
-const hasSensitiveDataFeature = featureToRef("bb.feature.sensitive-data");
const showSensitiveColumn = computed(() => {
return (
hasSensitiveDataFeature.value &&
@@ -255,7 +273,7 @@ const isSensitiveColumn = (column: Column) => {
};
const toggleSensitiveColumn = (column: Column, on: boolean, e: Event) => {
- if (!hasSensitiveDataFeature.value) {
+ if (!hasSensitiveDataFeature.value || instanceMissingLicense.value) {
state.showFeatureModal = true;
// Revert UI states
diff --git a/frontend/src/components/DatabaseBackupPanel.vue b/frontend/src/components/DatabaseBackupPanel.vue
index 3b23e8dc0b..cd8ee33f22 100644
--- a/frontend/src/components/DatabaseBackupPanel.vue
+++ b/frontend/src/components/DatabaseBackupPanel.vue
@@ -150,7 +150,7 @@
<DatabaseBackupCreateForm
:database="database"
@create="
- (backupName) => {
+ (backupName: string) => {
createBackup(backupName);
state.showCreateBackupModal = false;
}
diff --git a/frontend/src/components/DatabaseDetail/PITRRestoreButton.vue b/frontend/src/components/DatabaseDetail/PITRRestoreButton.vue
index 152594bf9b..5cbe3b6eb5 100644
--- a/frontend/src/components/DatabaseDetail/PITRRestoreButton.vue
+++ b/frontend/src/components/DatabaseDetail/PITRRestoreButton.vue
@@ -19,7 +19,7 @@
<span>{{ action.text }}</span>
<FeatureBadge
feature="bb.feature.pitr"
- class="text-accent ml-2 -mr-1"
+ custom-class="ml-2 -mr-1"
:instance="database.instanceEntity"
/>
</template>
diff --git a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
index 1a3d86f3b5..33ead97201 100644
--- a/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/components/Secrets.vue
@@ -24,7 +24,7 @@
</p>
<FeatureBadge
feature="bb.feature.encrypted-secrets"
- class="text-accent ml-2"
+ custom-class="ml-2"
:instance="database.instanceEntity"
/>
</div>
@@ -203,8 +203,8 @@ import { type ComposedDatabase } from "@/types";
import {
pushNotification,
useDatabaseSecretStore,
- featureToRef,
useCurrentUserV1,
+ useSubscriptionV1Store,
} from "@/store";
import { useGracefulRequest } from "@/store/modules/utils";
import { hasPermissionInProjectV1, hasWorkspacePermissionV1 } from "@/utils";
@@ -233,6 +233,7 @@ const parent = computed(() => {
const detail = ref<Detail>();
const showFeatureModal = ref(false);
const currentUserV1 = useCurrentUserV1();
+const subscriptionV1Store = useSubscriptionV1Store();
const COLUMNS = computed(() => {
const columns: BBGridColumn[] = [
@@ -274,10 +275,12 @@ const extractSecretName = (name: string) => {
return "";
};
-const hasSecretFeature = featureToRef(
- "bb.feature.encrypted-secrets",
- props.database.instanceEntity
-);
+const hasSecretFeature = computed(() => {
+ return subscriptionV1Store.hasInstanceFeature(
+ "bb.feature.encrypted-secrets",
+ props.database.instanceEntity
+ );
+});
const showDetail = (secret?: Secret) => {
if (!hasSecretFeature.value) {
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
index 707978db26..41002ecda2 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
@@ -1,6 +1,7 @@
<template>
<div class="w-full">
<FeatureAttentionForInstanceLicense
+ v-if="existMatchedUnactivateInstance"
custom-class="mb-5"
feature="bb.feature.database-grouping"
/>
@@ -76,17 +77,15 @@
<div class="col-span-2">
<MatchedDatabaseView
v-if="resourceType === 'DATABASE_GROUP'"
- :project="project"
- :environment-id="state.environmentId || ''"
- :database-group="databaseGroup as DatabaseGroup"
- :expr="state.expr"
+ :loading="state.isRequesting"
+ :matched-database-list="matchedDatabaseList"
+ :unmatched-database-list="unmatchedDatabaseList"
/>
<MatchedTableView
v-if="resourceType === 'SCHEMA_GROUP'"
- :project="project"
- :schema-group="databaseGroup as SchemaGroup"
- :database-group-name="selectedDatabaseGroupName || ''"
- :expr="state.expr"
+ :loading="state.isRequesting"
+ :matched-table-list="matchedTableList"
+ :unmatched-table-list="unmatchedTableList"
/>
</div>
</div>
@@ -95,7 +94,8 @@
<script lang="ts" setup>
import { Status } from "nice-grpc-web";
-import { computed, onMounted, reactive, ref } from "vue";
+import { computed, onMounted, reactive, ref, watch } from "vue";
+import { useDebounceFn } from "@vueuse/core";
import { useI18n } from "vue-i18n";
import {
ConditionGroupExpr,
@@ -106,13 +106,15 @@ import ExprEditor from "./common/ExprEditor";
import { ResourceType } from "./common/ExprEditor/context";
import { DatabaseGroup, SchemaGroup } from "@/types/proto/v1/project_service";
import {
+ ComposedSchemaGroupTable,
+ ComposedDatabase,
ComposedDatabaseGroup,
ComposedProject,
ResourceId,
ValidatedMessage,
} from "@/types";
import { convertCELStringToExpr } from "@/utils/databaseGroup/cel";
-import { useDBGroupStore } from "@/store";
+import { useDBGroupStore, useSubscriptionV1Store } from "@/store";
import { getErrorCode } from "@/utils/grpcweb";
import EnvironmentSelect from "../EnvironmentSelect.vue";
import MatchedDatabaseView from "./MatchedDatabaseView.vue";
@@ -136,6 +138,7 @@ const props = defineProps<{
}>();
type LocalState = {
+ isRequesting: boolean;
resourceId: string;
placeholder: string;
environmentId?: string;
@@ -145,7 +148,9 @@ type LocalState = {
const { t } = useI18n();
const dbGroupStore = useDBGroupStore();
+const subscriptionV1Store = useSubscriptionV1Store();
const state = reactive<LocalState>({
+ isRequesting: false,
resourceId: "",
placeholder: "",
expr: wrapAsGroup(emptySimpleExpr()),
@@ -288,4 +293,90 @@ defineExpose({
};
},
});
+
+const matchedDatabaseList = ref<ComposedDatabase[]>([]);
+const unmatchedDatabaseList = ref<ComposedDatabase[]>([]);
+const updateDatabaseMatchingState = useDebounceFn(async () => {
+ if (props.resourceType !== "DATABASE_GROUP") {
+ return;
+ }
+ if (!state.environmentId) {
+ return;
+ }
+
+ state.isRequesting = true;
+ const result = await dbGroupStore.fetchDatabaseGroupMatchList({
+ projectName: props.project.name,
+ environmentId: state.environmentId,
+ expr: state.expr,
+ });
+
+ matchedDatabaseList.value = result.matchedDatabaseList;
+ unmatchedDatabaseList.value = result.unmatchedDatabaseList;
+ state.isRequesting = false;
+}, 500);
+
+watch(
+ [() => props.project.name, () => state.environmentId, () => state.expr],
+ updateDatabaseMatchingState,
+ {
+ immediate: true,
+ deep: true,
+ }
+);
+
+const matchedTableList = ref<ComposedSchemaGroupTable[]>([]);
+const unmatchedTableList = ref<ComposedSchemaGroupTable[]>([]);
+const updateTableMatchingState = useDebounceFn(async () => {
+ if (props.resourceType !== "SCHEMA_GROUP") {
+ return;
+ }
+ if (!selectedDatabaseGroupName.value) {
+ return;
+ }
+
+ state.isRequesting = true;
+ const result = await dbGroupStore.fetchSchemaGroupMatchList({
+ projectName: props.project.name,
+ databaseGroupName: selectedDatabaseGroupName.value,
+ expr: state.expr,
+ });
+
+ matchedTableList.value = result.matchedTableList;
+ unmatchedTableList.value = result.unmatchedTableList;
+ state.isRequesting = false;
+}, 500);
+
+watch(
+ [
+ () => props.project.name,
+ () => selectedDatabaseGroupName.value,
+ () => state.expr,
+ ],
+ updateTableMatchingState,
+ {
+ immediate: true,
+ deep: true,
+ }
+);
+
+const existMatchedUnactivateInstance = computed(() => {
+ if (props.resourceType === "DATABASE_GROUP") {
+ return matchedDatabaseList.value.some(
+ (database) =>
+ !subscriptionV1Store.hasInstanceFeature(
+ "bb.feature.database-grouping",
+ database.instanceEntity
+ )
+ );
+ } else {
+ return matchedTableList.value.some(
+ (tb) =>
+ !subscriptionV1Store.hasInstanceFeature(
+ "bb.feature.database-grouping",
+ tb.databaseEntity.instanceEntity
+ )
+ );
+ }
+});
</script>
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
index d718203433..76ce818018 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
@@ -214,17 +214,17 @@ const doConfirm = async () => {
})
);
const resourceId = formState.resourceId;
- await dbGroupStore.createDatabaseGroup(
- props.project.name,
- {
+ await dbGroupStore.createDatabaseGroup({
+ projectName: props.project.name,
+ databaseGroup: {
name: `${props.project.name}/databaseGroups/${resourceId}`,
databasePlaceholder: formState.placeholder,
databaseExpr: Expr.fromJSON({
expression: celString || "true",
}),
},
- resourceId
- );
+ databaseGroupId: resourceId,
+ });
} else {
const environment = environmentStore.getEnvironmentByUID(
formState.environmentId || ""
@@ -259,17 +259,17 @@ const doConfirm = async () => {
})
);
const resourceId = formState.resourceId;
- await dbGroupStore.createSchemaGroup(
- formState.selectedDatabaseGroupId,
- {
+ await dbGroupStore.createSchemaGroup({
+ dbGroupName: formState.selectedDatabaseGroupId,
+ schemaGroup: {
name: `${formState.selectedDatabaseGroupId}/schemaGroups/${resourceId}`,
tablePlaceholder: formState.placeholder,
tableExpr: Expr.fromJSON({
expression: celString || "true",
}),
},
- resourceId
- );
+ schemaGroupId: resourceId,
+ });
} else {
const celString = await convertParsedExprToCELString(
ParsedExpr.fromJSON({
diff --git a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
index 54d3cde1b4..f7e1543ed5 100644
--- a/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
+++ b/frontend/src/components/DatabaseGroup/MatchedDatabaseView.vue
@@ -1,7 +1,7 @@
<template>
<div class="mb-2 flex flex-row items-center">
<span class="text-lg mr-2">{{ $t("common.databases") }}</span>
- <BBLoader v-show="state.isRequesting" class="opacity-60" />
+ <BBLoader v-show="loading" class="opacity-60" />
</div>
<div
class="w-full border rounded min-h-[20rem] max-h-[24rem] overflow-y-auto"
@@ -28,12 +28,17 @@
<div
v-for="database in matchedDatabaseList"
:key="database.name"
- class="w-full flex flex-row justify-between items-center px-2 py-1 gap-x-2"
+ class="w-full flex flex-row justify-start items-center px-2 py-1 gap-x-2"
>
<NEllipsis class="text-sm" line-clamp="1">
{{ database.databaseName }}
</NEllipsis>
- <div class="flex flex-row justify-end items-center shrink-0">
+ <div class="flex-1 flex flex-row justify-end items-center shrink-0">
+ <FeatureBadge
+ feature="bb.feature.database-grouping"
+ custom-class="mr-2"
+ :instance="database.instanceEntity"
+ />
<InstanceV1EngineIcon :instance="database.instanceEntity" />
<NEllipsis
class="ml-1 text-sm text-gray-400 max-w-[124px]"
@@ -87,111 +92,24 @@
<script lang="ts" setup>
import { NEllipsis } from "naive-ui";
-import { ref, watch, reactive } from "vue";
-import { ConditionGroupExpr, buildCELExpr } from "@/plugins/cel";
-import {
- useDatabaseV1Store,
- useEnvironmentV1Store,
- useSubscriptionV1Store,
-} from "@/store";
-import { ComposedDatabase, ComposedProject } from "@/types";
+import { reactive } from "vue";
+import { ComposedDatabase } from "@/types";
import { InstanceV1EngineIcon } from "../v2";
-import { DatabaseGroup } from "@/types/proto/v1/project_service";
-import { projectServiceClient } from "@/grpcweb";
-import { buildDatabaseGroupExpr } from "@/utils/databaseGroup/cel";
-import { Expr } from "@/types/proto/google/type/expr";
-import { useDebounceFn } from "@vueuse/core";
import BBLoader from "@/bbkit/BBLoader.vue";
-import { databaseGroupNamePrefix } from "@/store/modules/v1/common";
-import { convertParsedExprToCELString } from "@/utils";
-import { ParsedExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
interface LocalState {
- isRequesting: boolean;
showMatchedDatabaseList: boolean;
showUnmatchedDatabaseList: boolean;
}
-const props = defineProps<{
- project: ComposedProject;
- environmentId: string;
- expr: ConditionGroupExpr;
- databaseGroup?: DatabaseGroup;
+defineProps<{
+ loading: boolean;
+ matchedDatabaseList: ComposedDatabase[];
+ unmatchedDatabaseList: ComposedDatabase[];
}>();
-const environmentStore = useEnvironmentV1Store();
-const databaseStore = useDatabaseV1Store();
-const subscriptionV1Store = useSubscriptionV1Store();
const state = reactive<LocalState>({
- isRequesting: false,
showMatchedDatabaseList: true,
showUnmatchedDatabaseList: true,
});
-const matchedDatabaseList = ref<ComposedDatabase[]>([]);
-const unmatchedDatabaseList = ref<ComposedDatabase[]>([]);
-
-const updateMatchingState = useDebounceFn(async () => {
- state.isRequesting = true;
-
- const environment = environmentStore.getEnvironmentByUID(props.environmentId);
- const celString = await convertParsedExprToCELString(
- ParsedExpr.fromJSON({
- expr: buildCELExpr(
- buildDatabaseGroupExpr({
- environmentId: environment.name,
- conditionGroupExpr: props.expr,
- })
- ),
- })
- );
- const validateOnlyResourceId = `creating-database-group-${Date.now()}`;
- const result = await projectServiceClient.createDatabaseGroup({
- parent: props.project.name,
- databaseGroup: {
- name: `${props.project.name}/${databaseGroupNamePrefix}${validateOnlyResourceId}`,
- databasePlaceholder: validateOnlyResourceId,
- databaseExpr: Expr.fromJSON({
- expression: celString,
- }),
- },
- databaseGroupId: validateOnlyResourceId,
- validateOnly: true,
- });
-
- matchedDatabaseList.value = [];
- unmatchedDatabaseList.value = [];
- for (const item of result.matchedDatabases) {
- const database = await databaseStore.getOrFetchDatabaseByName(item.name);
- 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) {
- const database = await databaseStore.getOrFetchDatabaseByName(item.name);
- if (
- database &&
- database.instanceEntity.environmentEntity.uid === props.environmentId
- ) {
- unmatchedDatabaseList.value.push(database);
- }
- }
-
- state.isRequesting = false;
-}, 500);
-
-watch(() => props, updateMatchingState, {
- immediate: true,
- deep: true,
-});
</script>
diff --git a/frontend/src/components/DatabaseGroup/MatchedTableView.vue b/frontend/src/components/DatabaseGroup/MatchedTableView.vue
index 0212e6e9c8..092428107a 100644
--- a/frontend/src/components/DatabaseGroup/MatchedTableView.vue
+++ b/frontend/src/components/DatabaseGroup/MatchedTableView.vue
@@ -1,7 +1,7 @@
<template>
<div class="mb-2 flex flex-row items-center">
<span class="text-lg mr-2">{{ $t("db.tables") }}</span>
- <BBLoader v-show="state.isRequesting" class="opacity-60" />
+ <BBLoader v-show="loading" class="opacity-60" />
</div>
<div
class="w-full border rounded min-h-[20rem] max-h-[24rem] overflow-y-auto"
@@ -30,7 +30,7 @@
>
<span class="text-sm">{{ table.table }}</span>
<div class="flex flex-row justify-end items-center">
- <DatabaseView :database-name="table.database" />
+ <DatabaseView :database="table.databaseEntity" />
</div>
</div>
</div>
@@ -60,7 +60,7 @@
>
<span class="text-sm">{{ table.table }}</span>
<div class="flex flex-row justify-end items-center">
- <DatabaseView :database-name="table.database" />
+ <DatabaseView :database="table.databaseEntity" />
</div>
</div>
</div>
@@ -68,80 +68,24 @@
</template>
<script lang="ts" setup>
-import { ref, watch, reactive } from "vue";
-import { ConditionGroupExpr, buildCELExpr } from "@/plugins/cel";
-import { ComposedProject } from "@/types";
+import { reactive } from "vue";
+import { ComposedSchemaGroupTable } from "@/types";
import { DatabaseView } from "../v2";
-import {
- SchemaGroup,
- SchemaGroup_Table,
-} from "@/types/proto/v1/project_service";
-import { projectServiceClient } from "@/grpcweb";
-import { Expr } from "@/types/proto/google/type/expr";
-import { useDebounceFn } from "@vueuse/core";
-import {
- databaseGroupNamePrefix,
- schemaGroupNamePrefix,
-} from "@/store/modules/v1/common";
import BBLoader from "@/bbkit/BBLoader.vue";
-import { convertParsedExprToCELString } from "@/utils";
-import { ParsedExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
interface LocalState {
- isRequesting: boolean;
showMatchedTableList: boolean;
showUnmatchedTableList: boolean;
}
-const props = defineProps<{
- project: ComposedProject;
- databaseGroupName: string;
- expr: ConditionGroupExpr;
- schemaGroup?: SchemaGroup;
+defineProps<{
+ loading: boolean;
+ matchedTableList: ComposedSchemaGroupTable[];
+ unmatchedTableList: ComposedSchemaGroupTable[];
}>();
const state = reactive<LocalState>({
- isRequesting: false,
showMatchedTableList: true,
showUnmatchedTableList: true,
});
-const matchedTableList = ref<SchemaGroup_Table[]>([]);
-const unmatchedTableList = ref<SchemaGroup_Table[]>([]);
-
-const updateMatchingState = useDebounceFn(async () => {
- state.isRequesting = true;
- try {
- const celString = await convertParsedExprToCELString(
- ParsedExpr.fromJSON({
- expr: buildCELExpr(props.expr),
- })
- );
- const validateOnlyResourceId = `creating-schema-group-${Date.now()}`;
- const databaseGroupName = `${props.project.name}/${databaseGroupNamePrefix}${props.databaseGroupName}`;
- const result = await projectServiceClient.createSchemaGroup({
- parent: databaseGroupName,
- schemaGroup: {
- name: `${databaseGroupName}/${schemaGroupNamePrefix}${validateOnlyResourceId}`,
- tablePlaceholder: validateOnlyResourceId,
- tableExpr: Expr.fromJSON({
- expression: celString || "true",
- }),
- },
- schemaGroupId: validateOnlyResourceId,
- validateOnly: true,
- });
- matchedTableList.value = result.matchedTables;
- unmatchedTableList.value = result.unmatchedTables;
- } catch (error) {
- console.error(error);
- matchedTableList.value = [];
- unmatchedTableList.value = [];
- }
- state.isRequesting = false;
-}, 500);
-
-watch(() => props, updateMatchingState, {
- immediate: true,
- deep: true,
-});
</script>
diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vue
index 3d20e66f9e..3873b92c07 100644
--- a/frontend/src/components/EnvironmentForm.vue
+++ b/frontend/src/components/EnvironmentForm.vue
@@ -33,10 +33,7 @@
<div class="col-span-1 mt-6">
<label class="textlabel flex items-center">
{{ $t("policy.environment-tier.name") }}
- <FeatureBadge
- feature="bb.feature.environment-tier-policy"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.environment-tier-policy" />
</label>
<p class="mt-2 text-sm text-gray-600">
<i18n-t tag="span" keypath="policy.environment-tier.description">
@@ -120,10 +117,7 @@
<div class="-mt-0.5">
<div class="textlabel flex">
{{ $t("policy.rollout.auto") }}
- <FeatureBadge
- feature="bb.feature.approval-policy"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.approval-policy" />
</div>
<div class="mt-1 textinfolabel">
{{ $t("policy.rollout.auto-info") }}
@@ -168,10 +162,7 @@
<div class="-mt-0.5">
<div class="textlabel flex">
{{ $t("policy.backup.daily") }}
- <FeatureBadge
- feature="bb.feature.backup-policy"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.backup-policy" />
</div>
<div class="mt-1 textinfolabel">
{{ $t("policy.backup.daily-info") }}
@@ -190,10 +181,7 @@
<div class="-mt-0.5">
<div class="textlabel flex">
{{ $t("policy.backup.weekly") }}
- <FeatureBadge
- feature="bb.feature.backup-policy"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.backup-policy" />
</div>
<div class="mt-1 textinfolabel">
{{ $t("policy.backup.weekly-info") }}
diff --git a/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue b/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue
index 72a942ff76..7a2a210eeb 100644
--- a/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue
+++ b/frontend/src/components/FeatureGuard/FeatureAttentionForInstanceLicense.vue
@@ -3,8 +3,10 @@
v-if="instanceLimitFeature.has(feature)"
:class="customClass"
:style="`INFO`"
- :title="$t(`subscription.features.${featureKey}.title`)"
- :description="descriptionText"
+ :title="$t(`subscription.features.${featureKey}.desc`)"
+ :description="
+ $t('subscription.instance-assignment.missing-license-attention')
+ "
:action-text="$t('subscription.instance-assignment.assign-license')"
@click-action="onClick"
/>
@@ -15,9 +17,8 @@
</template>
<script lang="ts" setup>
-import { reactive, PropType, computed } from "vue";
+import { reactive, PropType } from "vue";
import { FeatureType, instanceLimitFeature } from "@/types";
-import { useI18n } from "vue-i18n";
interface LocalState {
showInstanceAssignmentDrawer: boolean;
@@ -35,7 +36,6 @@ const props = defineProps({
},
});
-const { t } = useI18n();
const state = reactive<LocalState>({
showInstanceAssignmentDrawer: false,
});
@@ -44,13 +44,4 @@ const featureKey = props.feature.split(".").join("-");
const onClick = () => {
state.showInstanceAssignmentDrawer = true;
};
-
-const descriptionText = computed(() => {
- const attention = t(
- "subscription.instance-assignment.missing-license-attention"
- );
- const description = t(`subscription.features.${featureKey}.desc`);
-
- return `${description} ${attention}`;
-});
</script>
diff --git a/frontend/src/components/FeatureGuard/FeatureBadge.vue b/frontend/src/components/FeatureGuard/FeatureBadge.vue
index 48ba20da87..d469b64399 100644
--- a/frontend/src/components/FeatureGuard/FeatureBadge.vue
+++ b/frontend/src/components/FeatureGuard/FeatureBadge.vue
@@ -1,13 +1,17 @@
<template>
<div
v-if="instanceMissingLicense"
- class="tooltip-wrapper cursor-pointer"
+ :class="['text-accentcursor-pointer', customClass]"
@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>
+ <NTooltip :show-arrow="true">
+ <template #trigger>
+ <heroicons-solid:lock-closed class="text-accent w-5 h-5" />
+ </template>
+ <span class="w-56 text-sm">
+ {{ $t("subscription.instance-assignment.missing-license-attention") }}
+ </span>
+ </NTooltip>
</div>
<router-link
v-else-if="!hasFeature"
@@ -28,6 +32,7 @@ import { reactive, PropType, computed } from "vue";
import { FeatureType } from "@/types";
import { useSubscriptionV1Store } from "@/store";
import { Instance } from "@/types/proto/v1/instance_service";
+import { NTooltip } from "naive-ui";
interface LocalState {
showInstanceAssignmentDrawer: boolean;
@@ -42,6 +47,11 @@ const props = defineProps({
type: Object as PropType<Instance>,
default: undefined,
},
+ customClass: {
+ require: false,
+ default: "",
+ type: String,
+ },
});
const state = reactive<LocalState>({
diff --git a/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue b/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
index 67f2a0ce5b..1c5b64b744 100644
--- a/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
+++ b/frontend/src/components/GeneralSetting/AIAugmentationSetting.vue
@@ -18,10 +18,7 @@
$t("settings.general.workspace.plugin.openai.openai-key.self")
}}</span>
- <FeatureBadge
- feature="bb.feature.plugin.openai"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.plugin.openai" />
<span
v-if="!allowEdit"
@@ -63,10 +60,7 @@
$t("settings.general.workspace.plugin.openai.openai-endpoint.self")
}}</span>
- <FeatureBadge
- feature="bb.feature.plugin.openai"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.plugin.openai" />
<span
v-if="!allowEdit"
diff --git a/frontend/src/components/GeneralSetting/BrandingSetting.vue b/frontend/src/components/GeneralSetting/BrandingSetting.vue
index 12fda77e8f..7758e481ec 100644
--- a/frontend/src/components/GeneralSetting/BrandingSetting.vue
+++ b/frontend/src/components/GeneralSetting/BrandingSetting.vue
@@ -75,7 +75,7 @@
>
<FeatureBadge
feature="bb.feature.branding"
- class="text-white pointer-events-none"
+ custom-class="text-white pointer-events-none"
/>
{{ $t("common.update") }}
</button>
diff --git a/frontend/src/components/GeneralSetting/SecuritySetting.vue b/frontend/src/components/GeneralSetting/SecuritySetting.vue
index 08f48add2f..1393497d4a 100644
--- a/frontend/src/components/GeneralSetting/SecuritySetting.vue
+++ b/frontend/src/components/GeneralSetting/SecuritySetting.vue
@@ -23,7 +23,7 @@
$t("settings.general.workspace.watermark.enable")
}}</span>
- <FeatureBadge feature="bb.feature.watermark" class="text-accent" />
+ <FeatureBadge feature="bb.feature.watermark" />
<span
v-if="!allowEdit"
@@ -50,10 +50,7 @@
$t("settings.general.workspace.disallow-signup.enable")
}}</span>
- <FeatureBadge
- feature="bb.feature.disallow-signup"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.disallow-signup" />
<span
v-if="!allowEdit"
@@ -79,7 +76,7 @@
<span class="font-medium">{{
$t("settings.general.workspace.require-2fa.enable")
}}</span>
- <FeatureBadge feature="bb.feature.2fa" class="text-accent" />
+ <FeatureBadge feature="bb.feature.2fa" />
<span
v-if="!allowEdit"
class="text-sm text-gray-400 -translate-y-2 tooltip"
diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vue
index 69b4fd7d91..86adfd4a58 100644
--- a/frontend/src/components/InstanceForm/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm/InstanceForm.vue
@@ -506,7 +506,6 @@
</label>
<FeatureBadge
feature="bb.feature.instance-ssh-connection"
- class="text-accent"
:instance="instance"
/>
</div>
diff --git a/frontend/src/components/Project/ProjectCreatePanel.vue b/frontend/src/components/Project/ProjectCreatePanel.vue
index e32985a535..676cdbbaaf 100644
--- a/frontend/src/components/Project/ProjectCreatePanel.vue
+++ b/frontend/src/components/Project/ProjectCreatePanel.vue
@@ -79,10 +79,7 @@
<LearnMoreLink
url="https://www.bytebase.com/docs/concepts/batch-mode/?source=console"
/>
- <FeatureBadge
- feature="bb.feature.multi-tenancy"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.multi-tenancy" />
</div>
</div>
</div>
diff --git a/frontend/src/components/Project/ProjectGeneralSettingPanel.vue b/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
index 197de3b931..acc362c804 100644
--- a/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
+++ b/frontend/src/components/Project/ProjectGeneralSettingPanel.vue
@@ -77,10 +77,7 @@
<LearnMoreLink
url="https://www.bytebase.com/docs/concepts/batch-mode/?source=console"
/>
- <FeatureBadge
- feature="bb.feature.multi-tenancy"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.multi-tenancy" />
</label>
</div>
</div>
diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vue
index d8c17c3acd..52a084e71e 100644
--- a/frontend/src/components/RepositoryForm.vue
+++ b/frontend/src/components/RepositoryForm.vue
@@ -170,10 +170,7 @@
<div class="textlabel flex gap-x-1">
{{ $t("repository.schema-path-template") }}
<span v-if="isProjectSchemaChangeTypeSDL" class="text-red-600">*</span>
- <FeatureBadge
- feature="bb.feature.vcs-schema-write-back"
- class="text-accent"
- />
+ <FeatureBadge feature="bb.feature.vcs-schema-write-back" />
</div>
<div class="mt-1 textinfolabel space-x-1">
<span v-if="isProjectSchemaChangeTypeSDL">
@@ -269,11 +266,8 @@
</div>
<div>
<div class="textlabel flex gap-x-1">
- {{ $t("repository.sheet-path-template")
- }}<FeatureBadge
- feature="bb.feature.vcs-sheet-sync"
- class="text-accent"
- />
+ {{ $t("repository.sheet-path-template") }}
+ <FeatureBadge feature="bb.feature.vcs-sheet-sync" />
</div>
<div class="mt-1 textinfolabel">
{{ $t("repository.sheet-path-template-description") }}
@@ -308,7 +302,7 @@
<div v-if="canEnableSQLReview">
<div class="textlabel flex gap-x-1">
{{ $t("repository.sql-review-ci") }}
- <FeatureBadge feature="bb.feature.vcs-sql-review" class="text-accent" />
+ <FeatureBadge feature="bb.feature.vcs-sql-review" />
</div>
<div class="mt-1 textinfolabel">
{{
diff --git a/frontend/src/components/SlowQuery/Panel/IndexAdvisor.vue b/frontend/src/components/SlowQuery/Panel/IndexAdvisor.vue
index 11381ae9b2..7db7d51255 100644
--- a/frontend/src/components/SlowQuery/Panel/IndexAdvisor.vue
+++ b/frontend/src/components/SlowQuery/Panel/IndexAdvisor.vue
@@ -30,7 +30,7 @@
<div class="btn btn-primary !w-auto" @click="state.showFeatureModal = true">
{{ $t("subscription.features.bb-feature-index-advisor.title") }}
<FeatureBadge
- class="ml-1"
+ custom-class="ml-1"
feature="bb.feature.index-advisor"
:instance="slowQueryLog.database.instanceEntity"
/>
diff --git a/frontend/src/components/v2/Model/DatabaseView.vue b/frontend/src/components/v2/Model/DatabaseView.vue
index 7348161953..984f27bcf4 100644
--- a/frontend/src/components/v2/Model/DatabaseView.vue
+++ b/frontend/src/components/v2/Model/DatabaseView.vue
@@ -1,9 +1,11 @@
<template>
- <div
- v-if="database && instance"
- class="flex flex-row justify-start items-center"
- >
- <InstanceV1EngineIcon :instance="instance" />
+ <div v-if="database" class="flex flex-row justify-start items-center">
+ <FeatureBadge
+ feature="bb.feature.database-grouping"
+ custom-class="mr-2"
+ :instance="database.instanceEntity"
+ />
+ <InstanceV1EngineIcon :instance="database.instanceEntity" />
<span class="text-sm ml-0.5 text-gray-500">{{
database.databaseName
}}</span>
@@ -11,27 +13,10 @@
</template>
<script lang="ts" setup>
-import { useDatabaseV1Store, useInstanceV1Store } from "@/store";
import { ComposedDatabase } from "@/types";
-import { onMounted, ref } from "vue";
import { InstanceV1EngineIcon } from "./Instance";
-import { Instance } from "@/types/proto/v1/instance_service";
-const props = defineProps<{
- databaseName: string;
+defineProps<{
+ database: ComposedDatabase;
}>();
-
-const databaseStore = useDatabaseV1Store();
-const instanceStore = useInstanceV1Store();
-const database = ref<ComposedDatabase>();
-const instance = ref<Instance>();
-
-onMounted(async () => {
- database.value = await databaseStore.getOrFetchDatabaseByName(
- props.databaseName
- );
- instance.value = await instanceStore.getOrFetchInstanceByName(
- database.value.instance
- );
-});
</script>
diff --git a/frontend/src/store/modules/dbGroup.ts b/frontend/src/store/modules/dbGroup.ts
index a6af0fb662..2cbd699a2b 100644
--- a/frontend/src/store/modules/dbGroup.ts
+++ b/frontend/src/store/modules/dbGroup.ts
@@ -4,15 +4,30 @@ import { ref } from "vue";
import { projectServiceClient } from "@/grpcweb";
import { DatabaseGroup, SchemaGroup } from "@/types/proto/v1/project_service";
import { convertDatabaseGroupExprFromCEL } from "@/utils/databaseGroup/cel";
-import { useEnvironmentV1Store, useProjectV1Store } from "./v1";
-import { ComposedDatabaseGroup, ComposedSchemaGroup } from "@/types";
+import {
+ useEnvironmentV1Store,
+ useProjectV1Store,
+ useDatabaseV1Store,
+} from "./v1";
+import {
+ ComposedSchemaGroupTable,
+ ComposedDatabaseGroup,
+ ComposedSchemaGroup,
+ ComposedDatabase,
+} from "@/types";
import { Environment } from "@/types/proto/v1/environment_service";
import {
databaseGroupNamePrefix,
getProjectNameAndDatabaseGroupName,
getProjectNameAndDatabaseGroupNameAndSchemaGroupName,
projectNamePrefix,
+ schemaGroupNamePrefix,
} from "./v1/common";
+import { ConditionGroupExpr, buildCELExpr } from "@/plugins/cel";
+import { Expr } from "@/types/proto/google/type/expr";
+import { convertParsedExprToCELString } from "@/utils";
+import { ParsedExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
+import { buildDatabaseGroupExpr } from "@/utils/databaseGroup/cel";
const composeDatabaseGroup = async (
databaseGroup: DatabaseGroup
@@ -126,26 +141,102 @@ export const useDBGroupStore = defineStore("db-group", () => {
return dbGroupMapByName.value.get(name);
};
- const createDatabaseGroup = async (
- projectName: string,
+ const createDatabaseGroup = async ({
+ projectName,
+ databaseGroup,
+ databaseGroupId,
+ validateOnly = false,
+ }: {
+ projectName: string;
databaseGroup: Pick<
DatabaseGroup,
"name" | "databasePlaceholder" | "databaseExpr"
- >,
- name: string
- ) => {
+ >;
+ databaseGroupId: string;
+ validateOnly?: boolean;
+ }) => {
const createdDatabaseGroup = await projectServiceClient.createDatabaseGroup(
{
parent: projectName,
databaseGroup,
- databaseGroupId: name,
+ databaseGroupId,
+ validateOnly,
}
);
- const composedData = await composeDatabaseGroup(createdDatabaseGroup);
- dbGroupMapByName.value.set(createdDatabaseGroup.name, composedData);
+
+ if (!validateOnly) {
+ const composedData = await composeDatabaseGroup(createdDatabaseGroup);
+ dbGroupMapByName.value.set(createdDatabaseGroup.name, composedData);
+ }
return createdDatabaseGroup;
};
+ const fetchDatabaseGroupMatchList = async ({
+ projectName,
+ environmentId,
+ expr,
+ }: {
+ projectName: string;
+ environmentId: string;
+ expr: ConditionGroupExpr;
+ }) => {
+ const environment =
+ useEnvironmentV1Store().getEnvironmentByUID(environmentId);
+
+ const celString = await convertParsedExprToCELString(
+ ParsedExpr.fromJSON({
+ expr: buildCELExpr(
+ buildDatabaseGroupExpr({
+ environmentId: environment.name,
+ conditionGroupExpr: expr,
+ })
+ ),
+ })
+ );
+
+ const validateOnlyResourceId = `creating-database-group-${Date.now()}`;
+
+ const result = await createDatabaseGroup({
+ projectName: projectName,
+ databaseGroup: {
+ name: `${projectName}/${databaseGroupNamePrefix}${validateOnlyResourceId}`,
+ databasePlaceholder: validateOnlyResourceId,
+ databaseExpr: Expr.fromJSON({
+ expression: celString,
+ }),
+ },
+ databaseGroupId: validateOnlyResourceId,
+ validateOnly: true,
+ });
+
+ const matchedDatabaseList: ComposedDatabase[] = [];
+ const unmatchedDatabaseList: ComposedDatabase[] = [];
+ const databaseStore = useDatabaseV1Store();
+
+ for (const item of result.matchedDatabases) {
+ const database = await databaseStore.getOrFetchDatabaseByName(item.name);
+ if (!database) {
+ continue;
+ }
+
+ matchedDatabaseList.push(database);
+ }
+ for (const item of result.unmatchedDatabases) {
+ const database = await databaseStore.getOrFetchDatabaseByName(item.name);
+ if (
+ database &&
+ database.instanceEntity.environmentEntity.uid === environmentId
+ ) {
+ unmatchedDatabaseList.push(database);
+ }
+ }
+
+ return {
+ matchedDatabaseList,
+ unmatchedDatabaseList,
+ };
+ };
+
const updateDatabaseGroup = async (
databaseGroup: Pick<
DatabaseGroup,
@@ -233,21 +324,101 @@ export const useDBGroupStore = defineStore("db-group", () => {
return schemaGroupMapByName.value.get(name);
};
- const createSchemaGroup = async (
- dbGroupName: string,
- schemaGroup: Pick<SchemaGroup, "name" | "tablePlaceholder" | "tableExpr">,
- name: string
- ) => {
+ const createSchemaGroup = async ({
+ dbGroupName,
+ schemaGroup,
+ schemaGroupId,
+ validateOnly = false,
+ }: {
+ dbGroupName: string;
+ schemaGroup: Pick<SchemaGroup, "name" | "tablePlaceholder" | "tableExpr">;
+ schemaGroupId: string;
+ validateOnly?: boolean;
+ }) => {
const createdSchemaGroup = await projectServiceClient.createSchemaGroup({
parent: dbGroupName,
schemaGroup,
- schemaGroupId: name,
+ schemaGroupId,
+ validateOnly,
});
const composedData = await composeSchemaGroup(createdSchemaGroup);
- schemaGroupMapByName.value.set(composedData.name, composedData);
+ if (!validateOnly) {
+ schemaGroupMapByName.value.set(composedData.name, composedData);
+ }
return composedData;
};
+ const fetchSchemaGroupMatchList = async ({
+ projectName,
+ databaseGroupName,
+ expr,
+ }: {
+ projectName: string;
+ databaseGroupName: string;
+ expr: ConditionGroupExpr;
+ }) => {
+ const celString = await convertParsedExprToCELString(
+ ParsedExpr.fromJSON({
+ expr: buildCELExpr(expr),
+ })
+ );
+ const validateOnlyResourceId = `creating-schema-group-${Date.now()}`;
+ const parent = `${projectName}/${databaseGroupNamePrefix}${databaseGroupName}`;
+
+ try {
+ const result = await createSchemaGroup({
+ dbGroupName: parent,
+ schemaGroup: {
+ name: `${databaseGroupName}/${schemaGroupNamePrefix}${validateOnlyResourceId}`,
+ tablePlaceholder: validateOnlyResourceId,
+ tableExpr: Expr.fromJSON({
+ expression: celString || "true",
+ }),
+ },
+ schemaGroupId: validateOnlyResourceId,
+ validateOnly: true,
+ });
+
+ const matchedTableList: ComposedSchemaGroupTable[] = [];
+ const unmatchedTableList: ComposedSchemaGroupTable[] = [];
+ const databaseStore = useDatabaseV1Store();
+
+ for (const item of result.matchedTables) {
+ const database = await databaseStore.getOrFetchDatabaseByName(
+ item.database
+ );
+ if (!database) {
+ continue;
+ }
+
+ matchedTableList.push({
+ ...item,
+ databaseEntity: database,
+ });
+ }
+ for (const item of result.unmatchedTables) {
+ const database = await databaseStore.getOrFetchDatabaseByName(
+ item.database
+ );
+ unmatchedTableList.push({
+ ...item,
+ databaseEntity: database,
+ });
+ }
+
+ return {
+ matchedTableList,
+ unmatchedTableList,
+ };
+ } catch (e) {
+ console.error(e);
+ return {
+ matchedTableList: [],
+ unmatchedTableList: [],
+ };
+ }
+ };
+
const updateSchemaGroup = async (
schemaGroup: Pick<SchemaGroup, "name" | "tablePlaceholder" | "tableExpr">
) => {
@@ -297,5 +468,7 @@ export const useDBGroupStore = defineStore("db-group", () => {
createSchemaGroup,
updateSchemaGroup,
deleteSchemaGroup,
+ fetchDatabaseGroupMatchList,
+ fetchSchemaGroupMatchList,
};
});
diff --git a/frontend/src/store/modules/v1/common.ts b/frontend/src/store/modules/v1/common.ts
index 2fa6b5ccee..318e67db86 100644
--- a/frontend/src/store/modules/v1/common.ts
+++ b/frontend/src/store/modules/v1/common.ts
@@ -14,6 +14,7 @@ export const schemaGroupNamePrefix = "schemaGroups/";
export const externalVersionControlPrefix = "externalVersionControls/";
export const logNamePrefix = "logs/";
export const reviewNamePrefix = "reviews/";
+export const secretNamePrefix = "secrets/";
export const getNameParentTokens = (
name: string,
diff --git a/frontend/src/store/modules/v1/databaseSecret.ts b/frontend/src/store/modules/v1/databaseSecret.ts
index c85662f409..7500632d1a 100644
--- a/frontend/src/store/modules/v1/databaseSecret.ts
+++ b/frontend/src/store/modules/v1/databaseSecret.ts
@@ -1,12 +1,21 @@
+import { reactive } from "vue";
import { defineStore } from "pinia";
import { databaseServiceClient } from "@/grpcweb";
import { Secret } from "@/types/proto/v1/database_service";
+import { secretNamePrefix } from "./common";
export const useDatabaseSecretStore = defineStore("database-secret", () => {
+ const secretMapByDatabase = reactive(new Map<string, Secret[]>());
+
+ const getSecretListByDatabase = (database: string) => {
+ return secretMapByDatabase.get(database) ?? [];
+ };
+
const fetchSecretList = async (parent: string) => {
const res = await databaseServiceClient.listSecrets({
parent,
});
+ secretMapByDatabase.set(parent, res.secrets);
return res.secrets;
};
@@ -15,18 +24,42 @@ export const useDatabaseSecretStore = defineStore("database-secret", () => {
updateMask: string[],
allowMissing: boolean
) => {
- return await databaseServiceClient.updateSecret({
+ const database = secret.name.split(secretNamePrefix)[0];
+ const updatedSecret = await databaseServiceClient.updateSecret({
secret,
updateMask,
allowMissing,
});
+ if (secretMapByDatabase.has(database)) {
+ const list = secretMapByDatabase.get(database) ?? [];
+ const index = list.findIndex((s) => s.name === secret.name);
+ if (index >= 0) {
+ list[index] = updatedSecret;
+ secretMapByDatabase.set(database, list);
+ }
+ }
+ return updatedSecret;
};
const deleteSecret = async (name: string) => {
- return await databaseServiceClient.deleteSecret({
+ await databaseServiceClient.deleteSecret({
name,
});
+ const database = name.split(secretNamePrefix)[0];
+ if (secretMapByDatabase.has(database)) {
+ const list = secretMapByDatabase.get(database) ?? [];
+ const index = list.findIndex((s) => s.name === name);
+ if (index >= 0) {
+ list.splice(index, 1);
+ secretMapByDatabase.set(database, list);
+ }
+ }
};
- return { fetchSecretList, upsertSecret, deleteSecret };
+ return {
+ fetchSecretList,
+ upsertSecret,
+ deleteSecret,
+ getSecretListByDatabase,
+ };
});
diff --git a/frontend/src/types/dbGroup.ts b/frontend/src/types/dbGroup.ts
index f2ef8955fd..bb874db8bf 100644
--- a/frontend/src/types/dbGroup.ts
+++ b/frontend/src/types/dbGroup.ts
@@ -1,12 +1,17 @@
import { ConditionGroupExpr } from "@/plugins/cel";
import { Environment } from "./proto/v1/environment_service";
-import { DatabaseGroup, SchemaGroup } from "./proto/v1/project_service";
-import { ComposedProject } from "./v1";
+import {
+ DatabaseGroup,
+ Project,
+ SchemaGroup,
+ SchemaGroup_Table,
+} from "./proto/v1/project_service";
+import { ComposedDatabase } from "@/types";
export interface ComposedDatabaseGroup extends DatabaseGroup {
databaseGroupName: string;
projectName: string;
- project: ComposedProject;
+ project: Project;
environmentName: string;
environment: Environment;
simpleExpr: ConditionGroupExpr;
@@ -15,3 +20,7 @@ export interface ComposedDatabaseGroup extends DatabaseGroup {
export interface ComposedSchemaGroup extends SchemaGroup {
databaseGroup: ComposedDatabaseGroup;
}
+
+export interface ComposedSchemaGroupTable extends SchemaGroup_Table {
+ databaseEntity: ComposedDatabase;
+}
diff --git a/frontend/src/types/plan.ts b/frontend/src/types/plan.ts
index 0fc614bd3e..7cd8042466 100644
--- a/frontend/src/types/plan.ts
+++ b/frontend/src/types/plan.ts
@@ -59,6 +59,7 @@ export const instanceLimitFeature = new Set<FeatureType>([
"bb.feature.encrypted-secrets",
"bb.feature.sql-review",
"bb.feature.task-schedule-time",
+ "bb.feature.online-migration",
// Database Management
"bb.feature.pitr",
"bb.feature.read-replica-connection",
@@ -73,8 +74,6 @@ export const instanceLimitFeature = new Set<FeatureType>([
"bb.feature.vcs-sql-review",
"bb.feature.mybatis-sql-review",
"bb.feature.vcs-schema-write-back",
- // TODO:
- // "bb.feature.online-migration",
]);
export const planTypeToString = (planType: PlanType): string => {
diff --git a/frontend/src/utils/v1/database.ts b/frontend/src/utils/v1/database.ts
index c57023ebbf..5485072aff 100644
--- a/frontend/src/utils/v1/database.ts
+++ b/frontend/src/utils/v1/database.ts
@@ -9,6 +9,7 @@ import {
hasFeature,
useCurrentUserIamPolicy,
useEnvironmentV1Store,
+ useSubscriptionV1Store,
} from "@/store";
import { hasWorkspacePermissionV1 } from "../role";
import { Engine, State } from "@/types/proto/v1/common";
@@ -179,9 +180,14 @@ const MIN_GHOST_SUPPORT_MYSQL_VERSION = "5.7.0";
export function allowGhostMigrationV1(
databaseList: ComposedDatabase[]
): boolean {
+ const subscriptionV1Store = useSubscriptionV1Store();
return databaseList.every((db) => {
return (
db.instanceEntity.engine === Engine.MYSQL &&
+ subscriptionV1Store.hasInstanceFeature(
+ "bb.feature.online-migration",
+ db.instanceEntity
+ ) &&
semverCompare(
db.instanceEntity.engineVersion,
MIN_GHOST_SUPPORT_MYSQL_VERSION,
diff --git a/frontend/src/views/BannerUpgradeSubscription.vue b/frontend/src/views/BannerUpgradeSubscription.vue
index bea0594d07..0b5d8675cf 100644
--- a/frontend/src/views/BannerUpgradeSubscription.vue
+++ b/frontend/src/views/BannerUpgradeSubscription.vue
@@ -13,7 +13,13 @@
<span
class="underline cursor-pointer hover:opacity-60"
@click="state.showModal = true"
- >{{ neededPlan }}</span
+ >{{
+ t("subscription.plan-features", {
+ plan: t(
+ `subscription.plan.${planTypeToString(neededPlan)}.title`
+ ),
+ })
+ }}</span
>
</template>
<template #currentPlan>
@@ -43,8 +49,17 @@
</p>
<div class="pl-4 my-2">
<ul class="list-disc list-inside">
- <li v-for="feature in overusedFeatureList" :key="feature">
- {{ feature }}
+ <li v-for="item in overUsedFeatureList" :key="item.feature">
+ {{
+ $t(
+ `subscription.features.${item.feature.split(".").join("-")}.title`
+ )
+ }}
+ ({{
+ $t(
+ `subscription.plan.${planTypeToString(item.requiredPlan)}.title`
+ )
+ }})
</li>
</ul>
</div>
@@ -60,11 +75,18 @@
</template>
<script lang="ts" setup>
-import { reactive } from "vue";
+import { reactive, watch, ref } from "vue";
import {
useIdentityProviderStore,
useInstanceV1Store,
useSubscriptionV1Store,
+ usePolicyV1Store,
+ useSettingV1Store,
+ defaultBackupSchedule,
+ defaultApprovalStrategy,
+ useDBGroupStore,
+ useDatabaseV1Store,
+ useDatabaseSecretStore,
} from "@/store";
import { onMounted } from "vue";
import { computed } from "vue";
@@ -74,10 +96,11 @@ import { EnvironmentTier } from "@/types/proto/v1/environment_service";
import { useI18n } from "vue-i18n";
import { PlanType } from "@/types/proto/v1/subscription_service";
import { useRouter } from "vue-router";
-import { useSettingV1Store } from "@/store/modules/v1/setting";
+import { PolicyType } from "@/types/proto/v1/org_policy_service";
interface LocalState {
showModal: boolean;
+ ready: boolean;
}
const { t } = useI18n();
@@ -85,95 +108,151 @@ const router = useRouter();
const subscriptionStore = useSubscriptionV1Store();
const state = reactive<LocalState>({
showModal: false,
+ ready: false,
});
const idpStore = useIdentityProviderStore();
const settingV1Store = useSettingV1Store();
const instanceStore = useInstanceV1Store();
const environmentV1Store = useEnvironmentV1Store();
+const policyV1Store = usePolicyV1Store();
+const dbV1Store = useDatabaseV1Store();
+const dbSecretStore = useDatabaseSecretStore();
+const dbGroupStore = useDBGroupStore();
-const showBanner = computed(() => {
- return (
- subscriptionStore.currentPlan !== PlanType.ENTERPRISE &&
- overusedFeatureList.value.length > 0
- );
-});
+const usedFeatureList = ref<FeatureType[]>([]);
-const neededPlan = computed(() => {
- let plan = PlanType.TEAM;
- if (overusedEnterprisePlanFeatureList.value.length > 0) {
- plan = PlanType.ENTERPRISE;
- }
- return t("subscription.plan-features", {
- plan: t(`subscription.plan.${planTypeToString(plan)}.title`),
- });
-});
+watch(
+ () => state.ready,
+ async (ready) => {
+ if (!ready) {
+ return;
+ }
+ const set: Set<FeatureType> = new Set();
-const currentPlan = computed(() => {
- return t(
- `subscription.plan.${planTypeToString(subscriptionStore.currentPlan)}.title`
- );
-});
+ if (idpStore.identityProviderList.length > 0) {
+ set.add("bb.feature.sso");
+ }
-const overusedEnterprisePlanFeatureList = computed(() => {
- if (subscriptionStore.currentPlan === PlanType.ENTERPRISE) {
- return [];
- }
+ // setting
+ if (settingV1Store.brandingLogo) {
+ set.add("bb.feature.branding");
+ }
+ const watermarkSetting = settingV1Store.getSettingByName(
+ "bb.workspace.watermark"
+ );
+ if (watermarkSetting?.value?.stringValue === "1") {
+ set.add("bb.feature.watermark");
+ }
+ if (settingV1Store.workspaceProfileSetting?.disallowSignup ?? false) {
+ set.add("bb.feature.disallow-signup");
+ }
+ if (settingV1Store.workspaceProfileSetting?.require2fa ?? false) {
+ set.add("bb.feature.2fa");
+ }
+ const openAIKeySetting = settingV1Store.getSettingByName(
+ "bb.plugin.openai.key"
+ );
+ if (openAIKeySetting?.value?.stringValue) {
+ set.add("bb.feature.plugin.openai");
+ }
+ const imSetting = settingV1Store.getSettingByName("bb.app.im");
+ if (imSetting?.value?.appImSettingValue?.appId) {
+ set.add("bb.feature.im.approval");
+ }
- const list: FeatureType[] = [];
+ for (const environment of environmentV1Store.environmentList) {
+ if (environment.tier === EnvironmentTier.PROTECTED) {
+ set.add("bb.feature.environment-tier-policy");
+ }
+ if (!set.has("bb.feature.backup-policy")) {
+ const backupPolicy =
+ await policyV1Store.getOrFetchPolicyByParentAndType({
+ parentPath: environment.name,
+ policyType: PolicyType.BACKUP_PLAN,
+ });
+ if (
+ backupPolicy?.backupPlanPolicy?.schedule ??
+ defaultBackupSchedule !== defaultBackupSchedule
+ ) {
+ set.add("bb.feature.backup-policy");
+ }
+ }
- if (idpStore.identityProviderList.length > 0) {
- list.push("bb.feature.sso");
- }
- if (settingV1Store.brandingLogo) {
- list.push("bb.feature.branding");
- }
- const watermarkSetting = settingV1Store.getSettingByName(
- "bb.workspace.watermark"
- );
- if (watermarkSetting && watermarkSetting.value?.stringValue === "1") {
- list.push("bb.feature.watermark");
- }
- if (settingV1Store.workspaceProfileSetting?.disallowSignup ?? false) {
- list.push("bb.feature.disallow-signup");
- }
- if (settingV1Store.workspaceProfileSetting?.require2fa ?? false) {
- list.push("bb.feature.2fa");
+ if (!set.has("bb.feature.approval-policy")) {
+ const approvalPolicy =
+ await policyV1Store.getOrFetchPolicyByParentAndType({
+ parentPath: environment.name,
+ policyType: PolicyType.DEPLOYMENT_APPROVAL,
+ });
+ if (
+ approvalPolicy?.deploymentApprovalPolicy?.defaultStrategy ??
+ defaultApprovalStrategy !== defaultApprovalStrategy
+ ) {
+ set.add("bb.feature.approval-policy");
+ }
+ }
+ }
+
+ // database
+ for (const databse of dbV1Store.databaseList) {
+ const list = await dbSecretStore.fetchSecretList(databse.name);
+ if (list.length > 0) {
+ set.add("bb.feature.encrypted-secrets");
+ break;
+ }
+ }
+ if (dbGroupStore.getAllDatabaseGroupList().length > 0) {
+ set.add("bb.feature.database-grouping");
+ }
+
+ usedFeatureList.value = [...set.values()];
}
- const openAIKeySetting = settingV1Store.getSettingByName(
- "bb.plugin.openai.key"
- );
- if (openAIKeySetting && openAIKeySetting.value?.stringValue) {
- list.push("bb.feature.plugin.openai");
+);
+
+const overUsedFeatureList = computed(() => {
+ const currentPlan = subscriptionStore.currentPlan;
+ const resp = [];
+ for (const feature of usedFeatureList.value) {
+ const requiredPlan = subscriptionStore.getMinimumRequiredPlan(feature);
+ if (requiredPlan > currentPlan) {
+ resp.push({
+ feature,
+ requiredPlan,
+ });
+ }
}
- for (const environment of environmentV1Store.environmentList) {
- if (environment.tier === EnvironmentTier.PROTECTED) {
- list.push("bb.feature.environment-tier-policy");
- break;
+ return resp;
+});
+
+const neededPlan = computed(() => {
+ let plan = PlanType.FREE;
+
+ for (const feature of usedFeatureList.value) {
+ const requiredPlan = subscriptionStore.getMinimumRequiredPlan(feature);
+ if (requiredPlan > plan) {
+ plan = requiredPlan;
}
}
- return list;
+ return plan;
});
-const overusedFeatureList = computed(() => {
- const list: string[] = [];
- for (const feature of overusedEnterprisePlanFeatureList.value) {
- list.push(t(`subscription.features.${feature.split(".").join("-")}.title`));
- }
- if (instanceStore.activateInstanceCount >= subscriptionStore.instanceCount) {
- list.push(
- t("subscription.overuse-modal.instance-count-exceeds", {
- count: instanceStore.activateInstanceCount,
- limit: subscriptionStore.instanceCount,
- })
- );
- }
- return list;
+const showBanner = computed(() => {
+ return (
+ overUsedFeatureList.value.length > 0 &&
+ neededPlan.value > subscriptionStore.currentPlan
+ );
+});
+
+const currentPlan = computed(() => {
+ return t(
+ `subscription.plan.${planTypeToString(subscriptionStore.currentPlan)}.title`
+ );
});
onMounted(() => {
- if (subscriptionStore.currentPlan === PlanType.ENTERPRISE) {
+ if (subscriptionStore.currentPlan !== PlanType.FREE) {
return;
}
@@ -182,9 +261,14 @@ onMounted(() => {
settingV1Store.fetchSettingList(),
environmentV1Store.fetchEnvironments(),
instanceStore.fetchInstanceList(),
- ]).catch(() => {
- // ignore
- });
+ dbGroupStore.fetchAllDatabaseGroupList(),
+ ])
+ .catch(() => {
+ // ignore
+ })
+ .finally(() => {
+ state.ready = true;
+ });
});
const gotoSubscriptionPage = () => {
diff --git a/frontend/src/views/DatabaseGroupDetail.vue b/frontend/src/views/DatabaseGroupDetail.vue
index ac17d90a34..6c92659941 100644
--- a/frontend/src/views/DatabaseGroupDetail.vue
+++ b/frontend/src/views/DatabaseGroupDetail.vue
@@ -68,6 +68,7 @@
<hr class="my-4" />
<FeatureAttentionForInstanceLicense
+ v-if="existMatchedUnactivateInstance"
custom-class="m-5"
feature="bb.feature.database-grouping"
/>
@@ -85,10 +86,9 @@
</div>
<div class="col-span-2">
<MatchedDatabaseView
- :project="project"
- :environment-id="environment.uid"
- :expr="state.expr!"
- :database-group="databaseGroup"
+ :loading="false"
+ :matched-database-list="matchedDatabaseList"
+ :unmatched-database-list="unmatchedDatabaseList"
/>
</div>
</div>
@@ -130,7 +130,12 @@
<script lang="ts" setup>
import { onMounted, reactive, computed, watch, ref } from "vue";
-import { useDBGroupStore, useProjectV1Store } from "@/store";
+import { useDebounceFn } from "@vueuse/core";
+import {
+ useDBGroupStore,
+ useProjectV1Store,
+ useSubscriptionV1Store,
+} from "@/store";
import {
databaseGroupNamePrefix,
projectNamePrefix,
@@ -142,7 +147,7 @@ import ExprEditor from "@/components/DatabaseGroup/common/ExprEditor";
import MatchedDatabaseView from "@/components/DatabaseGroup/MatchedDatabaseView.vue";
import SchemaGroupTable from "@/components/DatabaseGroup/SchemaGroupTable.vue";
import { ResourceType } from "@/components/DatabaseGroup/common/ExprEditor/context";
-import { ComposedDatabaseGroup } from "@/types";
+import { ComposedDatabase, ComposedDatabaseGroup } from "@/types";
import { NButton } from "naive-ui";
import DatabaseGroupPrevEditorModal from "@/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vue";
@@ -171,6 +176,8 @@ const props = defineProps({
const projectStore = useProjectV1Store();
const dbGroupStore = useDBGroupStore();
+const subscriptionV1Store = useSubscriptionV1Store();
+
const state = reactive<LocalState>({
isLoaded: false,
});
@@ -196,7 +203,7 @@ const schemaGroupList = computed(() => {
databaseGroupResourceName.value
);
});
-const environment = computed(() => databaseGroup.value.environment);
+const environment = computed(() => databaseGroup.value?.environment);
const project = computed(() => {
return projectStore.getProjectByName(
`${projectNamePrefix}${props.projectName}`
@@ -250,4 +257,55 @@ watch(
immediate: true,
}
);
+
+const matchedDatabaseList = ref<ComposedDatabase[]>([]);
+const unmatchedDatabaseList = ref<ComposedDatabase[]>([]);
+
+const updateDatabaseMatchingState = useDebounceFn(async () => {
+ if (!state.isLoaded) {
+ return;
+ }
+ if (!environment.value) {
+ return;
+ }
+ if (!project.value) {
+ return;
+ }
+ if (!state.expr) {
+ return;
+ }
+
+ const result = await dbGroupStore.fetchDatabaseGroupMatchList({
+ projectName: project.value.name,
+ environmentId: environment.value.uid,
+ expr: state.expr,
+ });
+
+ matchedDatabaseList.value = result.matchedDatabaseList;
+ unmatchedDatabaseList.value = result.unmatchedDatabaseList;
+}, 500);
+
+watch(
+ [
+ () => state.isLoaded,
+ () => project.value,
+ () => environment.value,
+ () => state.expr,
+ ],
+ updateDatabaseMatchingState,
+ {
+ immediate: true,
+ deep: true,
+ }
+);
+
+const existMatchedUnactivateInstance = computed(() => {
+ return matchedDatabaseList.value.some(
+ (database) =>
+ !subscriptionV1Store.hasInstanceFeature(
+ "bb.feature.database-grouping",
+ database.instanceEntity
+ )
+ );
+});
</script>
diff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vue
index 2242288387..e6f1dfedd9 100644
--- a/frontend/src/views/ProfileDashboard.vue
+++ b/frontend/src/views/ProfileDashboard.vue
@@ -112,7 +112,7 @@
<PhoneNumberInput
v-if="state.editing"
:value="state.editingUser?.phone || ''"
- @update="(value) => updateUser('phone', value)"
+ @update="(value: string) => updateUser('phone', value)"
/>
<template v-else>
{{ user.phone }}
@@ -170,7 +170,7 @@
class="text-lg font-medium flex flex-row justify-start items-center"
>
{{ $t("two-factor.self") }}
- <FeatureBadge :feature="'bb.feature.2fa'" class="ml-2 text-accent" />
+ <FeatureBadge :feature="'bb.feature.2fa'" custom-class="ml-2" />
</span>
<div class="space-x-2">
<NButton @click="enable2FA">
diff --git a/frontend/src/views/SchemaGroupDetail.vue b/frontend/src/views/SchemaGroupDetail.vue
index bdf46da521..226e1f4a82 100644
--- a/frontend/src/views/SchemaGroupDetail.vue
+++ b/frontend/src/views/SchemaGroupDetail.vue
@@ -61,6 +61,12 @@
<hr class="my-4" />
+ <FeatureAttentionForInstanceLicense
+ v-if="existMatchedUnactivateInstance"
+ 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">
@@ -74,10 +80,9 @@
</div>
<div class="col-span-2">
<MatchedTableView
- :project="project"
- :database-group-name="databaseGroupName"
- :schema-group="schemaGroup"
- :expr="state.expr!"
+ :loading="false"
+ :matched-table-list="matchedTableList"
+ :unmatched-table-list="unmatchedTableList"
/>
</div>
</div>
@@ -94,8 +99,13 @@
</template>
<script lang="ts" setup>
-import { reactive, computed, watch } from "vue";
-import { useDBGroupStore, useProjectV1Store } from "@/store";
+import { reactive, computed, watch, ref } from "vue";
+import { useDebounceFn } from "@vueuse/core";
+import {
+ useDBGroupStore,
+ useProjectV1Store,
+ useSubscriptionV1Store,
+} from "@/store";
import {
databaseGroupNamePrefix,
projectNamePrefix,
@@ -107,6 +117,7 @@ import DatabaseGroupPanel from "@/components/DatabaseGroup/DatabaseGroupPanel.vu
import ExprEditor from "@/components/DatabaseGroup/common/ExprEditor";
import MatchedTableView from "@/components/DatabaseGroup/MatchedTableView.vue";
import DatabaseGroupName from "@/components/v2/Model/DatabaseGroupName.vue";
+import { ComposedSchemaGroupTable } from "@/types";
interface LocalState {
isLoaded: boolean;
@@ -131,6 +142,8 @@ const props = defineProps({
const projectStore = useProjectV1Store();
const dbGroupStore = useDBGroupStore();
+const subscriptionV1Store = useSubscriptionV1Store();
+
const state = reactive<LocalState>({
isLoaded: false,
showConfigurePanel: false,
@@ -162,4 +175,39 @@ watch(
immediate: true,
}
);
+
+const matchedTableList = ref<ComposedSchemaGroupTable[]>([]);
+const unmatchedTableList = ref<ComposedSchemaGroupTable[]>([]);
+const updateTableMatchingState = useDebounceFn(async () => {
+ if (!project.value) {
+ return;
+ }
+ if (!state.expr) {
+ return;
+ }
+
+ const result = await dbGroupStore.fetchSchemaGroupMatchList({
+ projectName: project.value.name,
+ databaseGroupName: props.databaseGroupName,
+ expr: state.expr,
+ });
+
+ matchedTableList.value = result.matchedTableList;
+ unmatchedTableList.value = result.unmatchedTableList;
+}, 500);
+
+watch([() => project.value, () => state.expr], updateTableMatchingState, {
+ immediate: true,
+ deep: true,
+});
+
+const existMatchedUnactivateInstance = computed(() => {
+ return matchedTableList.value.some(
+ (tb) =>
+ !subscriptionV1Store.hasInstanceFeature(
+ "bb.feature.database-grouping",
+ tb.databaseEntity.instanceEntity
+ )
+ );
+});
</script>
diff --git a/frontend/src/views/SettingWorkspaceIMIntegration.vue b/frontend/src/views/SettingWorkspaceIMIntegration.vue
index 9e45e35568..c31afab189 100644
--- a/frontend/src/views/SettingWorkspaceIMIntegration.vue
+++ b/frontend/src/views/SettingWorkspaceIMIntegration.vue
@@ -21,7 +21,7 @@
}}</span>
<FeatureBadge
:feature="'bb.feature.im.approval'"
- class="ml-2 text-accent"
+ custom-class="ml-2"
/>
</div>
<button
diff --git a/frontend/src/views/SettingWorkspaceSSO.vue b/frontend/src/views/SettingWorkspaceSSO.vue
index 1aefde1c0e..973a9bd28a 100644
--- a/frontend/src/views/SettingWorkspaceSSO.vue
+++ b/frontend/src/views/SettingWorkspaceSSO.vue
@@ -19,7 +19,7 @@
@click="handleCreateSSO"
>
{{ $t("common.create") }}
- <FeatureBadge :feature="'bb.feature.sso'" class="ml-2" />
+ <FeatureBadge :feature="'bb.feature.sso'" custom-class="ml-2" />
</button>
</div>
</div>
@@ -40,7 +40,7 @@
@click="handleCreateSSO"
>
{{ $t("settings.sso.create") }}
- <FeatureBadge :feature="'bb.feature.sso'" class="ml-2" />
+ <FeatureBadge :feature="'bb.feature.sso'" custom-class="ml-2" />
</button>
</div>
</div>
diff --git a/frontend/src/views/SheetDashboard.vue b/frontend/src/views/SheetDashboard.vue
index 92582b11ff..5caef26f0f 100644
--- a/frontend/src/views/SheetDashboard.vue
+++ b/frontend/src/views/SheetDashboard.vue
@@ -58,11 +58,7 @@
v-if="hasFeature('bb.feature.vcs-sheet-sync')"
class="w-4 h-auto mr-1"
/>
- <FeatureBadge
- v-else
- feature="bb.feature.vcs-sheet-sync"
- class="text-accent"
- />
+ <FeatureBadge v-else feature="bb.feature.vcs-sheet-sync" />
{{ $t("sheet.actions.sync-from-vcs") }}
</n-button>
</div>
diff --git a/frontend/src/views/SyncDatabaseSchema/index.vue b/frontend/src/views/SyncDatabaseSchema/index.vue
index 12ac4652c0..54d1c48ef2 100644
--- a/frontend/src/views/SyncDatabaseSchema/index.vue
+++ b/frontend/src/views/SyncDatabaseSchema/index.vue
@@ -139,10 +139,10 @@ import { computed, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import {
- featureToRef,
useChangeHistoryStore,
useDatabaseV1Store,
useProjectV1Store,
+ useSubscriptionV1Store,
} from "@/store";
import { UNKNOWN_ID } from "@/types";
import DatabaseSelect from "@/components/DatabaseSelect.vue";
@@ -186,6 +186,7 @@ const dialog = useDialog();
const projectStore = useProjectV1Store();
const databaseStore = useDatabaseV1Store();
const changeHistoryStore = useChangeHistoryStore();
+const subscriptionV1Store = useSubscriptionV1Store();
const targetDatabaseViewRef =
ref<InstanceType<typeof SelectTargetDatabasesView>>();
const state = reactive<LocalState>({
@@ -209,10 +210,12 @@ const database = computed(() => {
return databaseStore.getDatabaseByUID(databaseId);
});
-const hasSyncSchemaFeature = featureToRef(
- "bb.feature.sync-schema-all-versions",
- database.value?.instanceEntity
-);
+const hasSyncSchemaFeature = computed(() => {
+ return subscriptionV1Store.hasInstanceFeature(
+ "bb.feature.sync-schema-all-versions",
+ database.value?.instanceEntity
+ );
+});
const shouldShowMoreVersionButton = computed(() => {
return (
@@ -234,7 +237,8 @@ const allowNext = computed(() => {
return (
isValidId(state.sourceSchema.environmentId) &&
isValidId(state.sourceSchema.databaseId) &&
- !isUndefined(state.sourceSchema.changeHistory)
+ !isUndefined(state.sourceSchema.changeHistory) &&
+ hasSyncSchemaFeature.value
);
} else {
if (!targetDatabaseViewRef.value) {
@@ -285,11 +289,16 @@ const handleSourceEnvironmentSelect = async (environmentId: string) => {
const handleSourceDatabaseSelect = async (databaseId: string) => {
if (isValidId(databaseId)) {
const database = databaseStore.getDatabaseByUID(databaseId);
- if (database) {
- state.projectId = database.projectEntity.uid;
- state.sourceSchema.environmentId =
- database.instanceEntity.environmentEntity.uid;
- state.sourceSchema.databaseId = databaseId;
+ if (!database) {
+ return;
+ }
+ state.projectId = database.projectEntity.uid;
+ state.sourceSchema.environmentId =
+ database.instanceEntity.environmentEntity.uid;
+ state.sourceSchema.databaseId = databaseId;
+
+ if (!hasSyncSchemaFeature.value) {
+ state.showFeatureModal = true;
}
}
};
diff --git a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
index a91499c278..23705ddeda 100644
--- a/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/EditorAction.vue
@@ -78,7 +78,7 @@
<carbon:share class="h-5 w-5" /> &nbsp; {{ $t("common.share") }}
<FeatureBadge
:feature="'bb.feature.shared-sql-script'"
- class="ml-2 text-accent"
+ custom-class="ml-2"
/>
</NButton>
</template>