Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore(frontend): consolidate database group UI to naive-ui (#9516)
Liu Jic13ae91b2b6c
diff --git a/frontend/src/bbkit/BBModal.vue b/frontend/src/bbkit/BBModal.vueindex 131500c83b..4e8a0bf7be 100644--- a/frontend/src/bbkit/BBModal.vue+++ b/frontend/src/bbkit/BBModal.vue@@ -1,6 +1,6 @@<template><NModal- :show="true"+ :show="show":auto-focus="false":trap-focus="trapFocus":close-on-esc="false"@@ -51,6 +51,10 @@ export default defineComponent({},inheritAttrs: false,props: {+ show: {+ type: Boolean,+ default: true,+ },title: {default: "",type: [String, Function] as PropType<string | RenderFunction>,@@ -89,7 +93,7 @@ export default defineComponent({default: undefined,},},- emits: ["close"],+ emits: ["close", "update:show"],setup(props, { emit }) {const { id, upmost, events } = useOverlayStack();@@ -106,6 +110,7 @@ export default defineComponent({if (!pass) return;}emit("close");+ emit("update:show", false);};const renderTitle = () => {diff --git a/frontend/src/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vueindex f90b40d437..6efb31a7a8 100644--- a/frontend/src/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vue+++ b/frontend/src/components/AlterSchemaPrepForm/DatabaseGroupPrevEditorModal.vue@@ -18,22 +18,21 @@/></div><div class="flex flex-row justify-end items-center shrink-0">- <label- for="sql-file-input"- class="text-sm border px-3 leading-8 flex items-center rounded cursor-pointer hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-60"- >- <heroicons-outline:arrow-up-tray- class="w-4 h-auto mr-1 text-gray-500"- />- {{ $t("issue.upload-sql") }}- <input- id="sql-file-input"- type="file"- accept=".sql,.txt,application/sql,text/plain"- class="hidden"- @change="handleUploadFile"- />- </label>+ <NButton class="relative">+ <template #icon>+ <UploadIcon class="w-4 h-4 text-control-light" />+ </template>+ <template #default>+ {{ $t("issue.upload-sql") }}+ <input+ id="sql-file-input"+ type="file"+ accept=".sql,.txt,application/sql,text/plain"+ class="opacity-0 absolute inset-0"+ @change="handleUploadFile"+ />+ </template>+ </NButton></div></div><div class="relative w-full h-96 border rounded overflow-clip">@@ -45,33 +44,34 @@/></div></div>- <div class="w-full flex flex-row justify-end items-center mt-4 pr-px">- <div class="flex justify-end items-center space-x-3">- <button type="button" class="btn-normal" @click="dismissModal">+ <div class="w-full flex flex-row justify-end items-center mt-4">+ <div class="flex justify-end items-center gap-x-3">+ <NButton @click="dismissModal">{{ $t("common.cancel") }}- </button>- <button- class="btn-primary whitespace-nowrap"+ </NButton>+ <NButton+ type="primary":disabled="!allowPreviewIssue"@click="handlePreviewIssue">{{ $t("schema-editor.preview-issue") }}- </button>+ </NButton></div></div></BBModal><!-- Close modal confirm dialog --><ActionConfirmModal- v-if="state.showActionConfirmModal"+ v-model:show="state.showActionConfirmModal":title="$t('schema-editor.confirm-to-close.title')":description="$t('schema-editor.confirm-to-close.description')"- @close="state.showActionConfirmModal = false"@confirm="emit('close')"/></template><script lang="ts" setup>+import { UploadIcon } from "lucide-vue-next";+import { NButton } from "naive-ui";import { computed, onMounted, PropType, reactive } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vueindex 9d3b42e94e..e06a959245 100644--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue@@ -123,10 +123,9 @@<!-- Close modal confirm dialog --><ActionConfirmModal- v-if="state.showActionConfirmModal"+ v-model:show="state.showActionConfirmModal":title="$t('schema-editor.confirm-to-close.title')":description="$t('schema-editor.confirm-to-close.description')"- @close="state.showActionConfirmModal = false"@confirm="emit('close')"/></template>diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vueindex 713325d807..d4ab9ee240 100644--- a/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupForm.vue@@ -9,12 +9,7 @@<div class="w-full grid grid-cols-3 gap-x-6 pb-6 mb-4 border-b"><div><p class="text-lg mb-2">{{ $t("common.name") }}</p>- <input- v-model="state.placeholder"- required- type="text"- class="textfield w-full"- />+ <NInput v-model:value="state.placeholder" /><div class="mt-2"><ResourceIdFieldref="resourceIdField"@@ -29,38 +24,25 @@<div><p class="text-lg mb-2">{{ $t("common.environment") }}</p><EnvironmentSelect+ v-model:environment="state.environmentId":disabled="!isCreating || disableEditDatabaseGroupFields"- :selected-id="state.environmentId"- @select-environment-id="- (environmentId: any) => {- state.environmentId = environmentId;- }- "/></div><div v-if="resourceType === 'DATABASE_GROUP'"><p class="text-lg mb-2">{{ $t("common.project") }}</p>- <input- required- type="text"- readonly- disabled- :value="project.title"- class="textfield w-full"+ <ProjectSelect+ :project="project.uid"+ :disabled="true"+ style="width: auto"/></div><div v-if="resourceType === 'SCHEMA_GROUP'"><p class="text-lg mb-2">{{ $t("database-group.self") }}</p><DatabaseGroupSelect+ v-model:selected="state.selectedDatabaseGroupId":disabled="!isCreating || disableEditDatabaseGroupFields"- :project-id="project.name"- :environment-id="state.environmentId || ''"- :selected-id="state.selectedDatabaseGroupId"- @select-database-group-id="- (id: any) => {- state.selectedDatabaseGroupId = id;- }- "+ :project="project.name"+ :environment="state.environmentId || ''"/></div></div>@@ -96,6 +78,7 @@<script lang="ts" setup>import { useDebounceFn } from "@vueuse/core";import { head } from "lodash-es";+import { NInput } from "naive-ui";import { Status } from "nice-grpc-web";import { computed, onMounted, reactive, ref, watch } from "vue";import { useI18n } from "vue-i18n";@@ -123,8 +106,7 @@ import {import { DatabaseGroup, SchemaGroup } from "@/types/proto/v1/project_service";import { convertCELStringToExpr } from "@/utils/databaseGroup/cel";import { getErrorCode } from "@/utils/grpcweb";-import EnvironmentSelect from "../EnvironmentSelect.vue";-import { ResourceIdField } from "../v2";+import { EnvironmentSelect, ProjectSelect, ResourceIdField } from "../v2";import DatabaseGroupSelect from "./DatabaseGroupSelect.vue";import MatchedDatabaseView from "./MatchedDatabaseView.vue";import MatchedTableView from "./MatchedTableView.vue";diff --git a/frontend/src/components/DatabaseGroup/DatabaseGroupSelect.vue b/frontend/src/components/DatabaseGroup/DatabaseGroupSelect.vueindex 2ccc3cf795..d15cfd4ad2 100644--- a/frontend/src/components/DatabaseGroup/DatabaseGroupSelect.vue+++ b/frontend/src/components/DatabaseGroup/DatabaseGroupSelect.vue@@ -1,37 +1,32 @@<template>- <BBSelect- :selected-item="state.selectedDatabaseGroup"- :item-list="dbGroupList"+ <NSelect+ :value="state.selectedDatabaseGroup"+ :options="dbGroupOptions":disabled="disabled":placeholder="'Select Database Group'"- :show-prefix-item="true"- @select-item="(item: DatabaseGroup) => $emit('select-database-group-id', item.name)"- >- <template #menuItem="{ item }">- {{ item.databasePlaceholder }}- </template>- </BBSelect>+ @update:value="$emit('update:selected', $event)"+ /></template><script lang="ts" setup>+import { SelectOption } from "naive-ui";import { computed, reactive, watch } from "vue";import { useDBGroupStore } from "@/store";-import { ComposedDatabaseGroup } from "@/types";import { DatabaseGroup } from "@/types/proto/v1/project_service";interface LocalState {- selectedDatabaseGroup?: ComposedDatabaseGroup;+ selectedDatabaseGroup?: string;}const props = defineProps<{- projectId: string;- selectedId?: string;- environmentId?: string;+ project: string;+ selected?: string;+ environment?: string;disabled?: boolean;}>();const emit = defineEmits<{- (event: "select-database-group-id", name?: string): void;+ (event: "update:selected", name: string | undefined): void;}>();const state = reactive<LocalState>({@@ -42,33 +37,37 @@ const dbGroupStore = useDBGroupStore();const dbGroupList = computed(() => {return dbGroupStore- .getDBGroupListByProjectName(props.projectId)+ .getDBGroupListByProjectName(props.project).filter((dbGroup) =>- props.environmentId- ? dbGroup.environment.uid === props.environmentId- : true+ props.environment ? dbGroup.environment.uid === props.environment : true);});+const dbGroupOptions = computed(() => {+ return dbGroupList.value.map<SelectOption>((dbGroup) => ({+ value: dbGroup.name,+ label: dbGroup.databaseGroupName,+ }));+});const invalidateSelectionIfNeeded = () => {if (state.selectedDatabaseGroup &&!dbGroupList.value.find(- (item: DatabaseGroup) => item.name == state.selectedDatabaseGroup?.name+ (item: DatabaseGroup) => item.name == state.selectedDatabaseGroup)) {state.selectedDatabaseGroup = undefined;- emit("select-database-group-id", undefined);+ emit("update:selected", undefined);}};watch(- () => props,+ [() => props.project, () => props.selected, () => props.environment],() => {invalidateSelectionIfNeeded();state.selectedDatabaseGroup = dbGroupList.value.find(- (item) => item.name === props.selectedId- );+ (item) => item.name === props.selected+ )?.name;},{ immediate: true, deep: true });diff --git a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vueindex c9dd79c130..120ce573be 100644--- a/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue+++ b/frontend/src/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue@@ -24,11 +24,10 @@</div><DatabaseGroupPanel- v-if="state.showDatabaseGroupPanel"+ v-model:show="state.showDatabaseGroupPanel":project="project":resource-type="state.resourceType":database-group="state.editingDatabaseGroup"- @close="state.showDatabaseGroupPanel = false"/><FeatureModaldiff --git a/frontend/src/components/SchemaEditorV1/Modals/ActionConfirmModal.vue b/frontend/src/components/SchemaEditorV1/Modals/ActionConfirmModal.vueindex b68f82a26e..c705ac3105 100644--- a/frontend/src/components/SchemaEditorV1/Modals/ActionConfirmModal.vue+++ b/frontend/src/components/SchemaEditorV1/Modals/ActionConfirmModal.vue@@ -1,25 +1,33 @@<template><BBModal:title="props.title"+ :show="show"class="shadow-inner outline outline-gray-200"@close="dismissModal"><div class="w-80 mb-6"><p>{{ props.description }}</p></div>- <div class="w-full flex items-center justify-end mt-2 space-x-3 pr-1 pb-1">- <button type="button" class="btn-cancel" @click="dismissModal">+ <div class="w-full flex items-center justify-end mt-2 gap-x-3">+ <NButton v-bind="negativeButtonProps" @click="dismissModal">{{ $t("common.cancel") }}- </button>- <button :class="`btn-${props.style}`" @click="handleConfirmButtonClick">+ </NButton>+ <NButton v-bind="positiveButtonProps" @click="handleConfirmButtonClick">{{ $t("common.confirm") }}- </button>+ </NButton></div></BBModal></template><script lang="ts" setup>+import { ButtonProps, NButton } from "naive-ui";+import { PropType } from "vue";+const props = defineProps({+ show: {+ type: Boolean,+ default: true,+ },title: {type: String,default: "",@@ -28,22 +36,29 @@ const props = defineProps({type: String,default: "",},- style: {- type: String,- default: "primary",+ negativeButtonProps: {+ type: Object as PropType<ButtonProps>,+ default: () => ({ quaternary: true }),+ },+ positiveButtonProps: {+ type: Object as PropType<ButtonProps>,+ default: () => ({ type: "primary" }),},});const emit = defineEmits<{(event: "close"): void;(event: "confirm"): void;+ (event: "update:show", show: boolean): void;}>();const handleConfirmButtonClick = async () => {emit("confirm");+ emit("update:show", false);};const dismissModal = () => {emit("close");+ emit("update:show", false);};</script>diff --git a/frontend/src/components/v2/Select/EnvironmentSelect.vue b/frontend/src/components/v2/Select/EnvironmentSelect.vueindex b545adb509..68f7672186 100644--- a/frontend/src/components/v2/Select/EnvironmentSelect.vue+++ b/frontend/src/components/v2/Select/EnvironmentSelect.vue@@ -6,6 +6,7 @@:placeholder="$t('environment.select')":filterable="true":filter="filterByName"+ :render-label="renderLabel"class="bb-environment-select"@update:value="$emit('update:environment', $event)"/>@@ -13,10 +14,11 @@<script lang="ts" setup>import { NSelect, SelectOption } from "naive-ui";-import { computed, watchEffect } from "vue";+import { computed, h, watchEffect } from "vue";import { useEnvironmentV1Store, useProjectV1Store } from "@/store";import { State } from "@/types/proto/v1/common";import { Environment } from "@/types/proto/v1/environment_service";+import { EnvironmentV1Name } from "../Model";interface EnvironmentSelectOption extends SelectOption {value: string;@@ -27,11 +29,13 @@ const props = withDefaults(defineProps<{environment?: string | undefined;includeArchived?: boolean;+ showProductionIcon?: boolean;filter?: (environment: Environment, index: number) => boolean;}>(),{environment: undefined,includeArchived: false,+ showProductionIcon: true,filter: () => true,});@@ -80,6 +84,15 @@ const options = computed(() => {);});+const renderLabel = (option: SelectOption) => {+ const { environment } = option as EnvironmentSelectOption;+ return h(EnvironmentV1Name, {+ environment,+ showIcon: props.showProductionIcon,+ link: false,+ });+};+const filterByName = (pattern: string, option: SelectOption) => {const { environment } = option as EnvironmentSelectOption;pattern = pattern.toLowerCase();diff --git a/frontend/src/views/DatabaseGroupDetail.vue b/frontend/src/views/DatabaseGroupDetail.vueindex 9cebf17127..dc54fdb3d2 100644--- a/frontend/src/views/DatabaseGroupDetail.vue+++ b/frontend/src/views/DatabaseGroupDetail.vue@@ -113,12 +113,11 @@</div><DatabaseGroupPanel- v-if="editState.showConfigurePanel"+ v-model:show="editState.showConfigurePanel":project="project":resource-type="editState.type":database-group="editState.databaseGroup":parent-database-group="editState.parentDatabaseGroup"- @close="editState.showConfigurePanel = false"/><DatabaseGroupPrevEditorModaldiff --git a/frontend/src/views/ProfileDashboard.vue b/frontend/src/views/ProfileDashboard.vueindex dc2e3799e7..cab4c69974 100644--- a/frontend/src/views/ProfileDashboard.vue+++ b/frontend/src/views/ProfileDashboard.vue@@ -236,11 +236,12 @@<!-- Close modal confirm dialog --><ActionConfirmModal- v-if="state.showDisable2FAConfirmModal"+ v-model:show="state.showDisable2FAConfirmModal":title="$t('two-factor.disable.self')":description="$t('two-factor.disable.description')"- :style="'danger'"- @close="state.showDisable2FAConfirmModal = false"+ :positive-button-props="{+ type: 'error',+ }"@confirm="handleDisable2FA"/></template>