Skip to content

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

chore: rework some ux (#14261)

ecmadao2d90e08be11d
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
index ee64852aa2..bc04093011 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue
@@ -1,75 +1,97 @@
<template>
- <div class="w-full">
- <FeatureAttentionForInstanceLicense
- v-if="existMatchedUnactivateInstance"
- custom-class="mb-4"
- type="warning"
- feature="bb.feature.database-grouping"
- />
- <div class="w-full grid grid-cols-3 gap-x-6">
- <div>
- <p class="text-lg mb-2">{{ $t("common.name") }}</p>
- <NInput v-model:value="state.placeholder" />
- <div class="mt-2">
- <ResourceIdField
- ref="resourceIdField"
- editing-class="mt-4"
- resource-type="database-group"
- :readonly="!isCreating"
- :value="state.resourceId"
- :resource-title="state.placeholder"
- :validate="validateResourceId"
+ <div class="w-full h-full flex flex-col">
+ <div class="flex-1">
+ <FeatureAttentionForInstanceLicense
+ v-if="existMatchedUnactivateInstance"
+ custom-class="mb-4"
+ type="warning"
+ feature="bb.feature.database-grouping"
+ />
+ <div class="w-full grid grid-cols-3 gap-x-6">
+ <div>
+ <p class="text-lg mb-2">{{ $t("common.name") }}</p>
+ <NInput v-model:value="state.placeholder" />
+ <div class="mt-2">
+ <ResourceIdField
+ ref="resourceIdField"
+ editing-class="mt-4"
+ resource-type="database-group"
+ :readonly="!isCreating"
+ :value="state.resourceId"
+ :resource-title="state.placeholder"
+ :validate="validateResourceId"
+ />
+ </div>
+ </div>
+ </div>
+ <NDivider />
+ <div class="w-full grid grid-cols-5 gap-x-6">
+ <div class="col-span-3">
+ <p class="pl-1 text-lg mb-2">
+ {{ $t("database-group.condition.self") }}
+ </p>
+ <ExprEditor
+ :expr="state.expr"
+ :allow-admin="true"
+ :enable-raw-expression="true"
+ :factor-list="FactorList"
+ :factor-support-dropdown="factorSupportDropdown"
+ :factor-options-map="DatabaseGroupFactorOptionsMap(project)"
+ />
+ <p
+ v-if="matchingError"
+ class="mt-2 text-sm border border-red-600 px-2 py-1 rounded-lg bg-red-50 text-red-600"
+ >
+ {{ matchingError }}
+ </p>
+ </div>
+ <div class="col-span-2">
+ <MatchedDatabaseView
+ :loading="state.isRequesting"
+ :matched-database-list="matchedDatabaseList"
+ :unmatched-database-list="unmatchedDatabaseList"
/>
</div>
</div>
- </div>
- <NDivider />
- <div class="w-full grid grid-cols-5 gap-x-6">
- <div class="col-span-3">
- <p class="pl-1 text-lg mb-2">
- {{ $t("database-group.condition.self") }}
- </p>
- <ExprEditor
- :expr="state.expr"
- :allow-admin="true"
- :enable-raw-expression="true"
- :factor-list="FactorList"
- :factor-support-dropdown="factorSupportDropdown"
- :factor-options-map="DatabaseGroupFactorOptionsMap(project)"
- />
- <p
- v-if="matchingError"
- class="mt-2 text-sm border border-red-600 px-2 py-1 rounded-lg bg-red-50 text-red-600"
- >
- {{ matchingError }}
+ <NDivider />
+ <div class="w-full pl-1">
+ <p class="text-lg mb-2">
+ {{ $t("common.options") }}
</p>
- </div>
- <div class="col-span-2">
- <MatchedDatabaseView
- :loading="state.isRequesting"
- :matched-database-list="matchedDatabaseList"
- :unmatched-database-list="unmatchedDatabaseList"
- />
+ <div>
+ <NCheckbox
+ v-model:checked="state.multitenancy"
+ size="large"
+ :label="$t('database-group.multitenancy.self')"
+ />
+ <p class="text-sm text-gray-400 pl-6 ml-0.5">
+ {{ $t("database-group.multitenancy.description") }}
+ <LearnMoreLink
+ url="https://www.bytebase.com/docs/change-database/batch-change/?source=console#multitenancy"
+ class="text-sm"
+ />
+ </p>
+ </div>
</div>
</div>
- <NDivider />
- <div class="w-full pl-1">
- <p class="text-lg mb-2">
- {{ $t("common.options") }}
- </p>
- <div>
- <NCheckbox
- v-model:checked="state.multitenancy"
- size="large"
- :label="$t('database-group.multitenancy.self')"
- />
- <p class="text-sm text-gray-400 pl-6 ml-0.5">
- {{ $t("database-group.multitenancy.description") }}
- <LearnMoreLink
- url="https://www.bytebase.com/docs/change-database/batch-change/?source=console#multitenancy"
- class="text-sm"
- />
- </p>
+
+ <div class="space-y-6 w-full sticky bottom-0 bg-white">
+ <NDivider />
+ <div class="w-full flex justify-between items-center">
+ <div>
+ <NButton v-if="!isCreating" text @click="doDelete">
+ <template #icon>
+ <Trash2Icon class="w-4 h-auto" />
+ </template>
+ {{ $t("common.delete") }}
+ </NButton>
+ </div>
+ <div class="flex flex-row justify-end items-center gap-x-2">
+ <NButton @click="$emit('dismiss')">{{ $t("common.cancel") }}</NButton>
+ <NButton type="primary" :disabled="!allowConfirm" @click="doConfirm">
+ {{ isCreating ? $t("common.save") : $t("common.confirm") }}
+ </NButton>
+ </div>
</div>
</div>
</div>
@@ -77,20 +99,31 @@
<script lang="ts" setup>
import { useDebounceFn } from "@vueuse/core";
-import { cloneDeep } from "lodash-es";
-import { NCheckbox, NInput, NDivider } from "naive-ui";
+import { cloneDeep, head, isEqual } from "lodash-es";
+import { Trash2Icon } from "lucide-vue-next";
+import { NCheckbox, NButton, NInput, NDivider, useDialog } from "naive-ui";
import { ClientError, Status } from "nice-grpc-web";
import { computed, onMounted, reactive, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
+import { useRouter } from "vue-router";
import ExprEditor from "@/components/ExprEditor";
import LearnMoreLink from "@/components/LearnMoreLink.vue";
import type { ConditionGroupExpr } from "@/plugins/cel";
import {
emptySimpleExpr,
validateSimpleExpr,
+ buildCELExpr,
wrapAsGroup,
} from "@/plugins/cel";
-import { useDBGroupStore, useSubscriptionV1Store } from "@/store";
+import {
+ PROJECT_V1_ROUTE_DATABASE_GROUPS,
+ PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
+} from "@/router/dashboard/projectV1";
+import {
+ useDBGroupStore,
+ useSubscriptionV1Store,
+ pushNotification,
+} from "@/store";
import {
databaseGroupNamePrefix,
getProjectNameAndDatabaseGroupName,
@@ -102,7 +135,10 @@ import type {
ResourceId,
ValidatedMessage,
} from "@/types";
+import { Expr as CELExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
+import { Expr } from "@/types/proto/google/type/expr";
import type { DatabaseGroup } from "@/types/proto/v1/database_group_service";
+import { batchConvertParsedExprToCELString } from "@/utils";
import { getErrorCode } from "@/utils/grpcweb";
import { FeatureAttentionForInstanceLicense } from "../FeatureGuard";
import { ResourceIdField } from "../v2";
@@ -115,6 +151,11 @@ const props = defineProps<{
databaseGroup?: DatabaseGroup;
}>();
+const emit = defineEmits<{
+ (event: "dismiss"): void;
+ (event: "created", databaseGroupName: string): void;
+}>();
+
type LocalState = {
isRequesting: boolean;
resourceId: string;
@@ -136,6 +177,8 @@ const state = reactive<LocalState>({
});
const { databaseList } = useDatabaseV1List(props.project.name);
const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();
+const router = useRouter();
+const dialog = useDialog();
const isCreating = computed(() => props.databaseGroup === undefined);
@@ -246,6 +289,133 @@ const existMatchedUnactivateInstance = computed(() => {
);
});
+const doDelete = () => {
+ dialog.error({
+ title: "Confirm to delete",
+ positiveText: t("common.confirm"),
+ negativeText: t("common.cancel"),
+ onPositiveClick: async () => {
+ const databaseGroup = props.databaseGroup as DatabaseGroup;
+ await dbGroupStore.deleteDatabaseGroup(databaseGroup.name);
+ if (
+ router.currentRoute.value.name ===
+ PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL
+ ) {
+ router.replace({
+ name: PROJECT_V1_ROUTE_DATABASE_GROUPS,
+ });
+ }
+ emit("dismiss");
+ },
+ });
+};
+
+const allowConfirm = computed(() => {
+ if (existMatchedUnactivateInstance.value) {
+ return false;
+ }
+ return (
+ resourceIdField.value?.resourceId &&
+ state.placeholder &&
+ validateSimpleExpr(state.expr)
+ );
+});
+
+const doConfirm = async () => {
+ const formState = {
+ ...state,
+ resourceId: resourceIdField.value?.resourceId || "",
+ existMatchedUnactivateInstance: existMatchedUnactivateInstance.value,
+ };
+ if (!formState || !allowConfirm.value) {
+ return;
+ }
+
+ let celExpr: CELExpr | undefined = undefined;
+ try {
+ celExpr = await buildCELExpr(formState.expr);
+ } catch (error) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: `CEL expression error occurred`,
+ description: (error as Error).message,
+ });
+ return;
+ }
+
+ const celStrings = await batchConvertParsedExprToCELString([celExpr!]);
+ const celString = head(celStrings);
+ if (!celString) {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: `CEL expression error occurred`,
+ description: "CEL expression is empty",
+ });
+ return;
+ }
+
+ if (isCreating.value) {
+ const resourceId = formState.resourceId;
+ await dbGroupStore.createDatabaseGroup({
+ projectName: props.project.name,
+ databaseGroup: {
+ name: `${props.project.name}/databaseGroups/${resourceId}`,
+ databasePlaceholder: formState.placeholder,
+ databaseExpr: Expr.fromPartial({
+ expression: celString,
+ }),
+ multitenancy: formState.multitenancy,
+ },
+ databaseGroupId: resourceId,
+ });
+ emit("created", resourceId);
+ } else {
+ if (!props.databaseGroup) {
+ return;
+ }
+
+ const updateMask: string[] = [];
+ if (
+ !isEqual(props.databaseGroup.databasePlaceholder, formState.placeholder)
+ ) {
+ updateMask.push("database_placeholder");
+ }
+ if (
+ !isEqual(
+ props.databaseGroup.databaseExpr,
+ Expr.fromPartial({
+ expression: celString,
+ })
+ )
+ ) {
+ updateMask.push("database_expr");
+ }
+ if (!isEqual(props.databaseGroup.multitenancy, formState.multitenancy)) {
+ updateMask.push("multitenancy");
+ }
+ await dbGroupStore.updateDatabaseGroup(
+ {
+ ...props.databaseGroup!,
+ databasePlaceholder: formState.placeholder,
+ databaseExpr: Expr.fromPartial({
+ expression: celString,
+ }),
+ multitenancy: formState.multitenancy,
+ },
+ updateMask
+ );
+ }
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: isCreating.value ? t("common.created") : t("common.updated"),
+ });
+ emit("dismiss");
+};
+
defineExpose({
getFormState: () => {
return {
diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
index 28b0da2f38..2b088f5590 100644
--- a/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupPanel.vue
@@ -13,52 +13,20 @@
ref="formRef"
:project="project"
:database-group="props.databaseGroup"
+ @dismiss="() => emit('close')"
+ @created="
+ (databaseGroupName: string) => emit('created', databaseGroupName)
+ "
/>
- <template #footer>
- <div class="w-full flex justify-between items-center">
- <div>
- <NButton v-if="showDeleteButton" text @click="doDelete">
- <template #icon>
- <Trash2Icon class="w-4 h-auto" />
- </template>
- {{ $t("common.delete") }}
- </NButton>
- </div>
- <div class="flex flex-row justify-end items-center gap-x-2">
- <NButton @click="$emit('close')">{{ $t("common.cancel") }}</NButton>
- <NButton
- type="primary"
- :disabled="!allowConfirm"
- @click="doConfirm"
- >
- {{ isCreating ? $t("common.save") : $t("common.confirm") }}
- </NButton>
- </div>
- </div>
- </template>
</DrawerContent>
</Drawer>
</template>
<script lang="ts" setup>
-import { head, isEqual } from "lodash-es";
-import { Trash2Icon } from "lucide-vue-next";
-import { NButton, useDialog } from "naive-ui";
import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
import { Drawer, DrawerContent } from "@/components/v2";
-import { buildCELExpr, validateSimpleExpr } from "@/plugins/cel/logic";
-import {
- PROJECT_V1_ROUTE_DATABASE_GROUPS,
- PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
-} from "@/router/dashboard/projectV1";
-import { pushNotification, useDBGroupStore } from "@/store";
import type { ComposedDatabaseGroup, ComposedProject } from "@/types";
-import { Expr as CELExpr } from "@/types/proto/google/api/expr/v1alpha1/syntax";
-import { Expr } from "@/types/proto/google/type/expr";
-import type { DatabaseGroup } from "@/types/proto/v1/database_group_service";
-import { batchConvertParsedExprToCELString } from "@/utils";
import DatabaseGroupForm from "./DatabaseGroupForm.vue";
const props = defineProps<{
@@ -73,9 +41,6 @@ const emit = defineEmits<{
}>();
const { t } = useI18n();
-const router = useRouter();
-const dialog = useDialog();
-const dbGroupStore = useDBGroupStore();
const formRef = ref<InstanceType<typeof DatabaseGroupForm>>();
const isCreating = computed(() => props.databaseGroup === undefined);
@@ -85,136 +50,4 @@ const title = computed(() => {
? t("database-group.create")
: t("database-group.edit");
});
-
-const allowConfirm = computed(() => {
- if (!formRef.value) {
- return false;
- }
-
- const formState = formRef.value?.getFormState();
- if (formState.existMatchedUnactivateInstance) {
- return false;
- }
- return (
- formState.resourceId &&
- formState.placeholder &&
- validateSimpleExpr(formState.expr)
- );
-});
-
-const showDeleteButton = computed(() => {
- return !isCreating.value;
-});
-
-const doDelete = () => {
- dialog.error({
- title: "Confirm to delete",
- positiveText: t("common.confirm"),
- negativeText: t("common.cancel"),
- onPositiveClick: async () => {
- const databaseGroup = props.databaseGroup as DatabaseGroup;
- await dbGroupStore.deleteDatabaseGroup(databaseGroup.name);
- if (
- router.currentRoute.value.name ===
- PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL
- ) {
- router.replace({
- name: PROJECT_V1_ROUTE_DATABASE_GROUPS,
- });
- }
- emit("close");
- },
- });
-};
-
-const doConfirm = async () => {
- const formState = formRef.value?.getFormState();
- if (!formState || !allowConfirm.value) {
- return;
- }
-
- let celExpr: CELExpr | undefined = undefined;
- try {
- celExpr = await buildCELExpr(formState.expr);
- } catch (error) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: `CEL expression error occurred`,
- description: (error as Error).message,
- });
- return;
- }
-
- const celStrings = await batchConvertParsedExprToCELString([celExpr!]);
- const celString = head(celStrings);
- if (!celString) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: `CEL expression error occurred`,
- description: "CEL expression is empty",
- });
- return;
- }
-
- if (isCreating.value) {
- const resourceId = formState.resourceId;
- await dbGroupStore.createDatabaseGroup({
- projectName: props.project.name,
- databaseGroup: {
- name: `${props.project.name}/databaseGroups/${resourceId}`,
- databasePlaceholder: formState.placeholder,
- databaseExpr: Expr.fromPartial({
- expression: celString,
- }),
- multitenancy: formState.multitenancy,
- },
- databaseGroupId: resourceId,
- });
- emit("created", resourceId);
- } else {
- if (!props.databaseGroup) {
- return;
- }
-
- const updateMask: string[] = [];
- if (
- !isEqual(props.databaseGroup.databasePlaceholder, formState.placeholder)
- ) {
- updateMask.push("database_placeholder");
- }
- if (
- !isEqual(
- props.databaseGroup.databaseExpr,
- Expr.fromPartial({
- expression: celString,
- })
- )
- ) {
- updateMask.push("database_expr");
- }
- if (!isEqual(props.databaseGroup.multitenancy, formState.multitenancy)) {
- updateMask.push("multitenancy");
- }
- await dbGroupStore.updateDatabaseGroup(
- {
- ...props.databaseGroup!,
- databasePlaceholder: formState.placeholder,
- databaseExpr: Expr.fromPartial({
- expression: celString,
- }),
- multitenancy: formState.multitenancy,
- },
- updateMask
- );
- }
-
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: isCreating.value ? t("common.created") : t("common.updated"),
- });
- emit("close");
-};
</script>
diff --git a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue
index bc6a525f6a..f399c88076 100644
--- a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue
+++ b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue
@@ -1,15 +1,11 @@
<template>
- <div class="w-full space-y-4">
- <FeatureAttention feature="bb.feature.database-grouping" />
-
- <DatabaseGroupDataTable
- :database-group-list="dbGroupList"
- :custom-click="true"
- :loading="!ready"
- :show-actions="true"
- @row-click="handleDatabaseGroupClick"
- />
- </div>
+ <DatabaseGroupDataTable
+ :database-group-list="filteredDbGroupList"
+ :custom-click="true"
+ :loading="!ready"
+ :show-actions="true"
+ @row-click="handleDatabaseGroupClick"
+ />
<DatabaseGroupPanel
:show="state.showDatabaseGroupPanel"
@@ -17,41 +13,43 @@
:database-group="state.editingDatabaseGroup"
@close="state.showDatabaseGroupPanel = false"
/>
-
- <FeatureModal
- :open="state.showFeatureModal"
- feature="bb.feature.database-grouping"
- @cancel="state.showFeatureModal = false"
- />
</template>
<script lang="ts" setup>
-import { reactive } from "vue";
+import { reactive, computed } from "vue";
import { useRouter } from "vue-router";
import DatabaseGroupDataTable from "@/components/DatabaseGroup/DatabaseGroupDataTable.vue";
import { PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL } from "@/router/dashboard/projectV1";
import { useDBGroupListByProject } from "@/store";
import type { ComposedDatabaseGroup, ComposedProject } from "@/types";
-import { FeatureAttention, FeatureModal } from "../FeatureGuard";
import DatabaseGroupPanel from "./DatabaseGroupPanel.vue";
interface LocalState {
showDatabaseGroupPanel: boolean;
- showFeatureModal: boolean;
editingDatabaseGroup?: ComposedDatabaseGroup;
}
const props = defineProps<{
project: ComposedProject;
+ filter: string;
}>();
const router = useRouter();
const state = reactive<LocalState>({
- showFeatureModal: false,
showDatabaseGroupPanel: false,
});
const { dbGroupList, ready } = useDBGroupListByProject(props.project.name);
+const filteredDbGroupList = computed(() => {
+ const filter = props.filter.trim().toLowerCase();
+ if (!filter) {
+ return dbGroupList.value;
+ }
+ return dbGroupList.value.filter((group) => {
+ return group.databaseGroupName.toLowerCase().includes(filter);
+ });
+});
+
const handleDatabaseGroupClick = (
event: MouseEvent,
databaseGroup: ComposedDatabaseGroup
diff --git a/frontend/src/components/Project/useProjectSidebar.ts b/frontend/src/components/Project/useProjectSidebar.ts
index 91507e2468..3b9b3e4242 100644
--- a/frontend/src/components/Project/useProjectSidebar.ts
+++ b/frontend/src/components/Project/useProjectSidebar.ts
@@ -144,7 +144,6 @@ export const useProjectSidebar = (
title: t("project.masking-access.self"),
path: PROJECT_V1_ROUTE_MASKING_ACCESS,
type: "div",
- hide: !isDev(),
},
{
title: t("common.groups"),
diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vue
index 15edf33c81..a5049ef2a0 100644
--- a/frontend/src/components/QuickActionPanel.vue
+++ b/frontend/src/components/QuickActionPanel.vue
@@ -56,14 +56,6 @@
</Drawer>
<template v-if="project">
- <DatabaseGroupPanel
- :show="
- state.quickActionType === 'quickaction.bb.group.database-group.create'
- "
- :project="project"
- @close="state.quickActionType = undefined"
- @created="onDatabaseGroupCreated"
- />
<GrantRequestPanel
v-if="
state.quickActionType ===
@@ -97,13 +89,12 @@ import {
ChevronsDownIcon,
FileSearchIcon,
FileDownIcon,
- ShieldCheckIcon,
} from "lucide-vue-next";
import { NButton, NEllipsis } from "naive-ui";
import type { PropType, VNode } from "vue";
import { reactive, computed, watch, h } from "vue";
import { useI18n } from "vue-i18n";
-import { useRoute, useRouter } from "vue-router";
+import { useRoute } from "vue-router";
import { CreateDatabasePrepPanel } from "@/components/CreateDatabasePrepForm";
import GrantRequestPanel from "@/components/GrantRequestPanel";
import {
@@ -114,10 +105,6 @@ import {
import ProjectCreatePanel from "@/components/Project/ProjectCreatePanel.vue";
import { TransferDatabaseForm } from "@/components/TransferDatabaseForm";
import { Drawer, DrawerContent } from "@/components/v2";
-import {
- PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
- PROJECT_V1_ROUTE_MASKING_ACCESS_CREATE,
-} from "@/router/dashboard/projectV1";
import { PROJECT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRoutes";
import {
useCommandStore,
@@ -129,13 +116,11 @@ import {
import { projectNamePrefix } from "@/store/modules/v1/common";
import {
type QuickActionType,
- type DatabaseGroupQuickActionType,
type FeatureType,
PresetRoleType,
} from "@/types";
import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
import { hasProjectPermissionV2 } from "@/utils";
-import DatabaseGroupPanel from "./DatabaseGroup/DatabaseGroupPanel.vue";
import { FeatureModal } from "./FeatureGuard";
interface LocalState {
@@ -164,7 +149,6 @@ const props = defineProps({
const { t } = useI18n();
const route = useRoute();
-const router = useRouter();
const commandStore = useCommandStore();
const subscriptionStore = useSubscriptionV1Store();
const projectStore = useProjectV1Store();
@@ -174,10 +158,6 @@ const hasDBAWorkflowFeature = computed(() => {
return subscriptionStore.hasFeature("bb.feature.dba-workflow");
});
-const hasSensitiveDataFeature = computed(() => {
- return subscriptionStore.hasFeature("bb.feature.sensitive-data");
-});
-
const state = reactive<LocalState>({
quickActionType: undefined,
});
@@ -231,23 +211,6 @@ const reorderEnvironment = () => {
commandStore.dispatchCommand("bb.environment.reorder");
};
-const openDatabaseGroupDrawer = (quickAction: DatabaseGroupQuickActionType) => {
- if (!subscriptionStore.hasFeature("bb.feature.database-grouping")) {
- state.feature = "bb.feature.database-grouping";
- return;
- }
- state.quickActionType = quickAction;
-};
-
-const onDatabaseGroupCreated = (databaseGroupName: string) => {
- router.push({
- name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
- params: {
- databaseGroupName,
- },
- });
-};
-
const availableQuickActionList = computed((): QuickAction[] => {
const fullList: QuickAction[] = [
{
@@ -268,13 +231,6 @@ const availableQuickActionList = computed((): QuickAction[] => {
action: createDatabase,
icon: h(DatabaseIcon),
},
- {
- type: "quickaction.bb.group.database-group.create",
- title: t("database-group.create"),
- action: () =>
- openDatabaseGroupDrawer("quickaction.bb.group.database-group.create"),
- icon: h(PlusIcon),
- },
{
type: "quickaction.bb.environment.create",
title: t("environment.create"),
@@ -315,17 +271,6 @@ const availableQuickActionList = computed((): QuickAction[] => {
(state.quickActionType = "quickaction.bb.issue.grant.request.exporter"),
icon: h(FileDownIcon),
},
- {
- type: "quickaction.bb.database.masking-access",
- title: t("project.masking-access.grant-access"),
- hide: !hasSensitiveDataFeature.value,
- action: () => {
- router.push({
- name: PROJECT_V1_ROUTE_MASKING_ACCESS_CREATE,
- });
- },
- icon: h(ShieldCheckIcon),
- },
];
return props.quickActionList.reduce((list, quickAction) => {
diff --git a/frontend/src/components/SensitiveData/GrantAccessForm.vue b/frontend/src/components/SensitiveData/GrantAccessForm.vue
index 84c39ad6f7..3e64ed594c 100644
--- a/frontend/src/components/SensitiveData/GrantAccessForm.vue
+++ b/frontend/src/components/SensitiveData/GrantAccessForm.vue
@@ -1,6 +1,6 @@
<template>
- <div class="space-y-6 h-full relative">
- <div class="space-y-8 mb-8">
+ <div class="h-full flex flex-col">
+ <div class="space-y-8 flex-1">
<div class="w-full">
<div class="flex items-center gap-x-1 mb-2">
<span>{{ $t("common.resources") }}</span>
diff --git a/frontend/src/layouts/ProjectV1Layout.vue b/frontend/src/layouts/ProjectV1Layout.vue
index b9fc843f57..59699dcb30 100644
--- a/frontend/src/layouts/ProjectV1Layout.vue
+++ b/frontend/src/layouts/ProjectV1Layout.vue
@@ -45,8 +45,6 @@ import NoPermissionPlaceholder from "@/components/misc/NoPermissionPlaceholder.v
import {
PROJECT_V1_ROUTE_DETAIL,
PROJECT_V1_ROUTE_DATABASES,
- PROJECT_V1_ROUTE_DATABASE_GROUPS,
- PROJECT_V1_ROUTE_MASKING_ACCESS,
} from "@/router/dashboard/projectV1";
import { WORKSPACE_ROUTE_MY_ISSUES } from "@/router/dashboard/workspaceRoutes";
import { useRecentVisit } from "@/router/useRecentVisit";
@@ -146,13 +144,8 @@ const quickActionProjectPermissionMap: Map<QuickActionType, Permission[]> =
"quickaction.bb.database.create",
["bb.instances.list", "bb.issues.create"],
],
- ["quickaction.bb.group.database-group.create", ["bb.projects.update"]],
["quickaction.bb.issue.grant.request.querier", ["bb.issues.create"]],
["quickaction.bb.issue.grant.request.exporter", ["bb.issues.create"]],
- [
- "quickaction.bb.database.masking-access",
- ["bb.databases.list", "bb.policies.create"],
- ],
]);
const getQuickActionList = (list: QuickActionType[]): QuickActionType[] => {
@@ -169,14 +162,6 @@ const getQuickActionList = (list: QuickActionType[]): QuickActionType[] => {
});
};
-const quickActionListForDatabaseGroup = computed((): QuickActionType[] => {
- if (project.value.state !== State.ACTIVE) {
- return [];
- }
-
- return ["quickaction.bb.group.database-group.create"];
-});
-
const quickActionListForDatabase = computed((): QuickActionType[] => {
if (project.value.state !== State.ACTIVE) {
return [];
@@ -197,22 +182,10 @@ const quickActionListForDatabase = computed((): QuickActionType[] => {
return actions;
});
-const quickActionListForMaskingAccess = computed((): QuickActionType[] => {
- if (project.value.state !== State.ACTIVE) {
- return [];
- }
-
- return ["quickaction.bb.database.masking-access"];
-});
-
const quickActionList = computed(() => {
switch (route.name) {
case PROJECT_V1_ROUTE_DATABASES:
return getQuickActionList(quickActionListForDatabase.value);
- case PROJECT_V1_ROUTE_MASKING_ACCESS:
- return getQuickActionList(quickActionListForMaskingAccess.value);
- case PROJECT_V1_ROUTE_DATABASE_GROUPS:
- return getQuickActionList(quickActionListForDatabaseGroup.value);
}
return [];
});
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index b303ea4e0c..de358747fa 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -10,6 +10,7 @@ export const PROJECT_V1_ROUTE_MASKING_ACCESS_CREATE = `${PROJECT_V1_ROUTE_DASHBO
export const PROJECT_V1_ROUTE_DATABASE_DETAIL = `${PROJECT_V1_ROUTE_DASHBOARD}.database.detail`;
export const PROJECT_V1_ROUTE_DATABASE_CHANGE_HISTORY_DETAIL = `${PROJECT_V1_ROUTE_DASHBOARD}.database.change-history.detail`;
export const PROJECT_V1_ROUTE_DATABASE_GROUPS = `${PROJECT_V1_ROUTE_DASHBOARD}.database-group`;
+export const PROJECT_V1_ROUTE_DATABASE_GROUPS_CREATE = `${PROJECT_V1_ROUTE_DASHBOARD}.database-group.create`;
export const PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL = `${PROJECT_V1_ROUTE_DASHBOARD}.database-group.detail`;
export const PROJECT_V1_ROUTE_DEPLOYMENT_CONFIG = `${PROJECT_V1_ROUTE_DASHBOARD}.deployment-config`;
export const PROJECT_V1_ROUTE_BRANCHES = `${PROJECT_V1_ROUTE_DASHBOARD}.branch`;
@@ -118,6 +119,17 @@ const projectV1Routes: RouteRecordRaw[] = [
import("@/views/project/ProjectDatabaseGroupDashboard.vue"),
props: true,
},
+ {
+ path: "create",
+ name: PROJECT_V1_ROUTE_DATABASE_GROUPS_CREATE,
+ meta: {
+ overrideTitle: true,
+ requiredProjectPermissionList: () => ["bb.projects.update"],
+ },
+ component: () =>
+ import("@/views/project/ProjectDatabaseGroupCreate.vue"),
+ props: true,
+ },
{
path: ":databaseGroupName",
name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
diff --git a/frontend/src/views/project/ProjectDatabaseGroupCreate.vue b/frontend/src/views/project/ProjectDatabaseGroupCreate.vue
new file mode 100644
index 0000000000..a034b8ced7
--- /dev/null
+++ b/frontend/src/views/project/ProjectDatabaseGroupCreate.vue
@@ -0,0 +1,33 @@
+<template>
+ <DatabaseGroupForm
+ ref="formRef"
+ :project="project"
+ @dismiss="() => router.back()"
+ @created="(databaseGroupName: string) => {
+ router.push({
+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,
+ params: {
+ databaseGroupName,
+ },
+ });
+ }"
+ />
+</template>
+
+<script lang="tsx" setup>
+import { computed } from "vue";
+import { useRouter } from "vue-router";
+import DatabaseGroupForm from "@/components/DatabaseGroup/DatabaseGroupForm.vue";
+import { PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL } from "@/router/dashboard/projectV1";
+import { useProjectByName } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+
+const props = defineProps<{
+ projectId: string;
+}>();
+
+const { project } = useProjectByName(
+ computed(() => `${projectNamePrefix}${props.projectId}`)
+);
+const router = useRouter();
+</script>
diff --git a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
index cefc260a3e..55608fdd9c 100644
--- a/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
+++ b/frontend/src/views/project/ProjectDatabaseGroupDashboard.vue
@@ -1,12 +1,69 @@
<template>
- <ProjectDatabaseGroupPanel :project="project" />
+ <div class="flex flex-col gap-y-4">
+ <FeatureAttention feature="bb.feature.database-grouping" />
+
+ <div class="flex flex-row items-center justify-end gap-x-2">
+ <SearchBox
+ v-model:value="state.searchText"
+ :placeholder="$t('common.filter-by-name')"
+ />
+ <NButton
+ v-if="allowCreate"
+ type="primary"
+ @click="
+ () => {
+ if (!hasDBGroupFeature) {
+ state.showFeatureModal = true;
+ return;
+ }
+ router.push({
+ name: PROJECT_V1_ROUTE_DATABASE_GROUPS_CREATE,
+ });
+ }
+ "
+ >
+ <template #icon>
+ <PlusIcon v-if="hasDBGroupFeature" class="w-4" />
+ <FeatureBadge
+ v-else
+ feature="bb.feature.database-grouping"
+ custom-class="text-white"
+ />
+ </template>
+ {{ $t("database-group.create") }}
+ </NButton>
+ </div>
+ <ProjectDatabaseGroupPanel :project="project" :filter="state.searchText" />
+ </div>
+
+ <FeatureModal
+ :open="state.showFeatureModal"
+ feature="bb.feature.database-grouping"
+ @cancel="state.showFeatureModal = false"
+ />
</template>
<script setup lang="ts">
-import { computed } from "vue";
+import { PlusIcon } from "lucide-vue-next";
+import { NButton } from "naive-ui";
+import { computed, reactive } from "vue";
+import { useRouter } from "vue-router";
import ProjectDatabaseGroupPanel from "@/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue";
-import { useProjectByName } from "@/store";
+import {
+ FeatureAttention,
+ FeatureModal,
+ FeatureBadge,
+} from "@/components/FeatureGuard";
+import { SearchBox } from "@/components/v2";
+import { PROJECT_V1_ROUTE_DATABASE_GROUPS_CREATE } from "@/router/dashboard/projectV1";
+import { useProjectByName, hasFeature } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
+import { hasProjectPermissionV2 } from "@/utils";
+
+interface LocalState {
+ showFeatureModal: boolean;
+ searchText: string;
+}
const props = defineProps<{
projectId: string;
@@ -15,4 +72,17 @@ const props = defineProps<{
const { project } = useProjectByName(
computed(() => `${projectNamePrefix}${props.projectId}`)
);
+const router = useRouter();
+const state = reactive<LocalState>({
+ showFeatureModal: false,
+ searchText: "",
+});
+
+const allowCreate = computed(() =>
+ hasProjectPermissionV2(project.value, "bb.projects.update")
+);
+
+const hasDBGroupFeature = computed(() =>
+ hasFeature("bb.feature.database-grouping")
+);
</script>
diff --git a/frontend/src/views/project/ProjectDatabaseMaskingAccess.vue b/frontend/src/views/project/ProjectDatabaseMaskingAccess.vue
index f2aec6ad8f..8aad3464e3 100644
--- a/frontend/src/views/project/ProjectDatabaseMaskingAccess.vue
+++ b/frontend/src/views/project/ProjectDatabaseMaskingAccess.vue
@@ -1,7 +1,7 @@
<template>
<div class="space-y-4">
<div
- class="flex flex-col sm:flex-row gap-y-4 justify-between items-end sm:items-center"
+ class="flex flex-col lg:flex-row gap-y-4 justify-between items-end lg:items-center"
>
<NInputGroup style="width: auto">
<DatabaseSelect
@@ -25,11 +25,38 @@
/>
</NInputGroup>
- <SearchBox
- ref="searchField"
- v-model:value="state.searchText"
- :placeholder="$t('settings.members.search-member')"
- />
+ <div class="flex flex-row items-center justify-end gap-x-2">
+ <SearchBox
+ ref="searchField"
+ v-model:value="state.searchText"
+ :placeholder="$t('settings.members.search-member')"
+ />
+ <NButton
+ v-if="allowCreate"
+ type="primary"
+ @click="
+ () => {
+ if (!hasSensitiveDataFeature) {
+ state.showFeatureModal = true;
+ return;
+ }
+ router.push({
+ name: PROJECT_V1_ROUTE_MASKING_ACCESS_CREATE,
+ });
+ }
+ "
+ >
+ <template #icon>
+ <ShieldCheckIcon v-if="hasSensitiveDataFeature" class="w-4" />
+ <FeatureBadge
+ v-else
+ feature="bb.feature.sensitive-data"
+ custom-class="text-white"
+ />
+ </template>
+ {{ $t("project.masking-access.grant-access") }}
+ </NButton>
+ </div>
</div>
<MaskingExceptionUserTable
size="medium"
@@ -39,24 +66,35 @@
:filter-exception="filterException"
/>
</div>
+
+ <FeatureModal
+ :open="state.showFeatureModal"
+ feature="bb.feature.sensitive-data"
+ @cancel="state.showFeatureModal = false"
+ />
</template>
<script lang="tsx" setup>
-import { NInputGroup } from "naive-ui";
+import { ShieldCheckIcon } from "lucide-vue-next";
+import { NInputGroup, NButton } from "naive-ui";
import { computed, reactive } from "vue";
+import { useRouter } from "vue-router";
+import { FeatureModal, FeatureBadge } from "@/components/FeatureGuard";
import MaskingExceptionUserTable from "@/components/SensitiveData/MaskingExceptionUserTable.vue";
import MaskingActionDropdown from "@/components/SensitiveData/components/MaskingActionDropdown.vue";
import MaskingLevelDropdown from "@/components/SensitiveData/components/MaskingLevelDropdown.vue";
import { SearchBox, DatabaseSelect } from "@/components/v2";
-import { useProjectByName } from "@/store";
+import { PROJECT_V1_ROUTE_MASKING_ACCESS_CREATE } from "@/router/dashboard/projectV1";
+import { useProjectByName, hasFeature } from "@/store";
import { projectNamePrefix } from "@/store/modules/v1/common";
import { MaskingLevel } from "@/types/proto/v1/common";
import type { MaskingExceptionPolicy_MaskingException } from "@/types/proto/v1/org_policy_service";
import { MaskingExceptionPolicy_MaskingException_Action as Action } from "@/types/proto/v1/org_policy_service";
-import { extractDatabaseResourceName } from "@/utils";
+import { extractDatabaseResourceName, hasProjectPermissionV2 } from "@/utils";
interface LocalState {
searchText: string;
+ showFeatureModal: boolean;
selectedEnvironmentName?: string;
selectedDatabaseName?: string;
selectedMaskLevel?: MaskingLevel;
@@ -69,12 +107,25 @@ const props = defineProps<{
const state = reactive<LocalState>({
searchText: "",
+ showFeatureModal: false,
});
+const router = useRouter();
const { project } = useProjectByName(
computed(() => `${projectNamePrefix}${props.projectId}`)
);
+const hasSensitiveDataFeature = computed(() => {
+ return hasFeature("bb.feature.sensitive-data");
+});
+
+const allowCreate = computed(() => {
+ return (
+ hasProjectPermissionV2(project.value, "bb.databases.list") &&
+ hasProjectPermissionV2(project.value, "bb.policies.create")
+ );
+});
+
const filterException = (
exception: MaskingExceptionPolicy_MaskingException
): boolean => {