Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): ship some quick action dialogs to drawers (#6497)
Liu Jie40a527ecd96
diff --git a/frontend/src/bbkit/BBModal.vue b/frontend/src/bbkit/BBModal.vueindex 28dceee171..a0f7f31354 100644--- a/frontend/src/bbkit/BBModal.vue+++ b/frontend/src/bbkit/BBModal.vue@@ -96,7 +96,7 @@ export default defineComponent({const { stack, id, index, active } = useModalStack();const style = computed(() => ({- "z-index": 40 + index.value, // "40 + " because the container in BBModalStack is z-40+ "z-index": 4000 + index.value, // "4000 + " because the container in BBModalStack is z-4000}));const overrides = ref<Overrides>({diff --git a/frontend/src/bbkit/BBModalStack.vue b/frontend/src/bbkit/BBModalStack.vueindex 280682a9d6..d41ad1fe73 100644--- a/frontend/src/bbkit/BBModalStack.vue+++ b/frontend/src/bbkit/BBModalStack.vue@@ -74,7 +74,7 @@ export default defineComponent({<style scope>.bb-modal-mask {- @apply fixed inset-0 w-full h-screen flex items-center justify-center z-40;+ @apply fixed inset-0 w-full h-screen flex items-center justify-center z-[4000];background-color: rgba(209, 213, 219, 0.8); /* bg-gray-300 */}</style>diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex 92e84abb7d..9d08fb737d 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -1,16 +1,42 @@<template>- <div class="space-y-4 max-w-min overflow-x-hidden">- <div class="overflow-x-auto">- <div v-if="ready" class="w-[calc(100vw-8rem)] lg:w-[56rem]">+ <DrawerContent>+ <template #header>+ <div class="flex flex-col gap-y-1">+ <span>{{+ isAlterSchema+ ? $t("database.alter-schema")+ : $t("database.change-data")+ }}</span>+ <i18n-t+ v-if="projectId && isTenantProject"+ class="text-sm textinfolabel"+ tag="span"+ keypath="deployment-config.pipeline-generated-from-deployment-config"+ >+ <template #deployment_config>+ <router-link+ :to="`/project/${projectV1Slug(state.project!)}#databases`"+ class="underline hover:bg-link-hover"+ active-class=""+ exact-active-class=""+ >+ {{ $t("common.deployment-config") }}+ </router-link>+ </template>+ </i18n-t>+ </div>+ </template>++ <div+ class="space-y-4 w-[calc(100vw-8rem)] lg:w-[60rem] max-w-[calc(100vw-8rem)] overflow-x-auto"+ >+ <div v-if="ready"><template v-if="projectId"><template v-if="isTenantProject"><!-- tenant mode project --><NTabs v-model:value="state.alterType"><NTabPane :tab="$t('alter-schema.alter-db-group')" name="TENANT">- <div- class="overflow-y-auto"- style="max-height: calc(100vh - 360px)"- >+ <div><ProjectTenantView:state="state":database-list="schemaDatabaseList"@@ -50,11 +76,7 @@</div></NRadio></div>- <div- v-if="state.databaseSelectedTab === 'DATABASE'"- class="overflow-y-auto"- style="max-height: calc(100vh - 400px)"- >+ <div v-if="state.databaseSelectedTab === 'DATABASE'"><DatabaseV1Tablemode="PROJECT_SHORT"table-class="border"@@ -97,11 +119,7 @@:database-list="schemalessDatabaseList"/></div>- <div- v-else-if="state.databaseSelectedTab === 'DATABASE_GROUP'"- class="overflow-y-auto"- style="max-height: calc(100vh - 340px)"- >+ <div v-else-if="state.databaseSelectedTab === 'DATABASE_GROUP'"><SelectSchemaGroupsTable:database-group-list="databaseGroupList":selected-database-group-name="@@ -131,10 +149,7 @@</template><template v-else><!-- standard mode project, single/multiple databases ui -->- <div- class="overflow-y-auto"- style="max-height: calc(100vh - 380px)"- >+ <div><ProjectStandardView:state="state":project="state.project"@@ -143,7 +158,7 @@@select-database="selectDatabase"><template #header>- <div class="flex items-center justify-end mx-2 mb-2">+ <div class="flex items-center justify-end mx-2"><BBTableSearchclass="m-px":placeholder="$t('database.search-database')"@@ -193,11 +208,7 @@</aside></div><!-- a simple table -->- <div- v-if="state.databaseSelectedTab === 'DATABASE'"- class="overflow-y-auto"- style="max-height: calc(100vh - 340px)"- >+ <div v-if="state.databaseSelectedTab === 'DATABASE'"><DatabaseV1Tablemode="ALL_SHORT"table-class="border"@@ -212,11 +223,7 @@:database-list="schemalessDatabaseList"/></div>- <div- v-else-if="state.databaseSelectedTab === 'DATABASE_GROUP'"- class="overflow-y-auto"- style="max-height: calc(100vh - 340px)"- >+ <div v-else-if="state.databaseSelectedTab === 'DATABASE_GROUP'"><SelectSchemaGroupsTable:database-group-list="databaseGroupList":selected-database-group-name="state.selectedDatabaseGroupName"@@ -230,57 +237,52 @@</div><divv-if="!ready"- class="w-[calc(100vw-8rem)] lg:w-[56rem] h-[20rem] flex items-center justify-center"+ class="w-full h-[20rem] flex items-center justify-center"><BBSpin /></div></div>- <!-- Create button group -->- <div- class="pt-4 border-t border-block-border flex items-center justify-between"- >- <div>- <div- v-if="flattenSelectedDatabaseUidList.length > 0"- class="textinfolabel"- >- {{- $t("database.selected-n-databases", {- n: flattenSelectedDatabaseUidList.length,- })- }}+ <template #footer>+ <div class="flex-1 flex items-center justify-between">+ <div>+ <div+ v-if="flattenSelectedDatabaseUidList.length > 0"+ class="textinfolabel"+ >+ {{+ $t("database.selected-n-databases", {+ n: flattenSelectedDatabaseUidList.length,+ })+ }}+ </div></div>- </div>- <div class="flex items-center justify-end">- <button- type="button"- class="btn-normal py-2 px-4"- @click.prevent="cancel"- >- {{ $t("common.cancel") }}- </button>- <button- v-if="showGenerateMultiDb"- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="!allowGenerateMultiDb"- @click.prevent="generateMultiDb"- >- {{ $t("common.next") }}- </button>-- <button- v-if="showGenerateTenant"- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="!allowGenerateTenant"- @click.prevent="generateTenant"- >- {{ $t("common.next") }}- </button>+ <div class="flex items-center justify-end gap-x-3">+ <NButton @click.prevent="cancel">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ v-if="showGenerateMultiDb"+ type="primary"+ :disabled="!allowGenerateMultiDb"+ @click.prevent="generateMultiDb"+ >+ {{ $t("common.next") }}+ </NButton>++ <NButton+ v-if="showGenerateTenant"+ type="primary"+ :disabled="!allowGenerateTenant"+ @click.prevent="generateTenant"+ >+ {{ $t("common.next") }}+ </NButton>+ </div></div>- </div>- </div>+ </template>+ </DrawerContent><FeatureModalv-if="featureModalContext.feature"@@ -302,7 +304,7 @@import { useEventListener } from "@vueuse/core";import dayjs from "dayjs";import { cloneDeep } from "lodash-es";-import { NTabs, NTabPane, NRadio } from "naive-ui";+import { NButton, NTabs, NTabPane, NRadio } from "naive-ui";import { computed, reactive, PropType, ref } from "vue";import { useRouter } from "vue-router";@@ -319,6 +321,7 @@ import {instanceV1HasAlterSchema,filterDatabaseV1ByKeyword,sortDatabaseV1List,+ projectV1Slug,} from "@/utils";import {hasFeature,@@ -329,7 +332,7 @@ import {useProjectV1Store,useDBGroupStore,} from "@/store";-import { DatabaseV1Table } from "../v2";+import { DatabaseV1Table, DrawerContent } from "../v2";import { Project, TenantMode } from "@/types/proto/v1/project_service";import { State } from "@/types/proto/v1/common";import ProjectStandardView, {@@ -400,7 +403,7 @@ const state = reactive<LocalState>({? projectV1Store.getProjectByUID(props.projectId): undefined,alterType: "MULTI_DB",- selectedDatabaseUidListForEnvironment: new Map(),+ selectedDatabaseUidListForEnvironment: new Map<string, string[]>(),selectedDatabaseIdListForTenantMode: new Set<string>(),deployingTenantDatabaseList: [],label: "bb.environment",diff --git a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepButtonGroup.vue b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepButtonGroup.vuenew file mode 100644index 0000000000..611e0c070b--- /dev/null+++ b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepButtonGroup.vue@@ -0,0 +1,22 @@+<template>+ <div v-if="form" class="flex justify-end gap-x-3">+ <NButton @click.prevent="form?.cancel">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ type="primary"+ :disabled="!form?.allowCreate"+ @click.prevent="form?.create"+ >+ {{ $t("common.create") }}+ </NButton>+ </div>+</template>++<script setup lang="ts">+import CreateDatabasePrepForm from "./CreateDatabasePrepForm.vue";++defineProps<{+ form?: InstanceType<typeof CreateDatabasePrepForm>;+}>();+</script>diff --git a/frontend/src/components/CreateDatabasePrepForm.vue b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vuesimilarity index 94%rename from frontend/src/components/CreateDatabasePrepForm.vuerename to frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vueindex accbe4ed7f..1ac097b38e 100644--- a/frontend/src/components/CreateDatabasePrepForm.vue+++ b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue@@ -1,6 +1,6 @@<template><div class="space-y-6 divide-y divide-block-border">- <div class="w-72 mx-12 space-y-4">+ <div class="w-72 mx-auto space-y-4"><div class="w-full"><label for="project" class="textlabel">{{ $t("common.project") }} <span style="color: red">*</span>@@ -199,25 +199,8 @@/></div></div>-- <!-- Create button group -->- <div class="w-full pt-4 flex justify-end">- <button- type="button"- class="btn-normal py-2 px-4"- @click.prevent="cancel"- >- {{ $t("common.cancel") }}- </button>- <button- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="!allowCreate"- @click.prevent="create"- >- {{ $t("common.create") }}- </button>- </div></div>+<FeatureModalv-if="state.showFeatureModal"feature="bb.feature.multi-tenancy"@@ -237,16 +220,17 @@ import { useRouter } from "vue-router";import { isEmpty } from "lodash-es";import { useEventListener } from "@vueuse/core";+import { InstanceV1EngineIcon } from "@/components/v2";import {DatabaseLabelForm,DatabaseNameTemplateTips,useDBNameTemplateInputState,-} from "./CreateDatabasePrepForm/";-import InstanceSelect from "./InstanceSelect.vue";-import EnvironmentSelect from "./EnvironmentSelect.vue";-import ProjectSelect from "./ProjectSelect.vue";-import MemberSelect from "./MemberSelect.vue";-import InstanceRoleSelect from "./InstanceRoleSelect.vue";+} from "./";+import InstanceSelect from "@/components/InstanceSelect.vue";+import EnvironmentSelect from "@/components/EnvironmentSelect.vue";+import ProjectSelect from "@/components/ProjectSelect.vue";+import MemberSelect from "@/components/MemberSelect.vue";+import InstanceRoleSelect from "@/components/InstanceRoleSelect.vue";import {IssueCreate,SYSTEM_BOT_ID,@@ -257,7 +241,7 @@ import {PITRContext,ComposedInstance,unknownInstance,-} from "../types";+} from "@/types";import { TenantMode } from "@/types/proto/v1/project_service";import { INTERNAL_RDS_INSTANCE_USER_LIST } from "@/types/InstanceUser";import {@@ -267,7 +251,7 @@ import {instanceV1HasCollationAndCharacterSet,instanceV1HasCreateDatabase,issueSlug,-} from "../utils";+} from "@/utils";import {hasFeature,useCurrentUserV1,@@ -279,7 +263,6 @@ import {} from "@/store";import { UserRole } from "@/types/proto/v1/auth_service";import { Engine } from "@/types/proto/v1/common";-import { InstanceV1EngineIcon } from "./v2";import { InstanceRole } from "@/types/proto/v1/instance_role_service";import { Backup } from "@/types/proto/v1/database_service";@@ -603,4 +586,10 @@ watchEffect(() => {delete labels[key];}});++defineExpose({+ allowCreate,+ cancel,+ create,+});</script>diff --git a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepPanel.vue b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepPanel.vuenew file mode 100644index 0000000000..0cd22340ea--- /dev/null+++ b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepPanel.vue@@ -0,0 +1,48 @@+<template>+ <DrawerContent :title="$t('quick-action.create-db')">+ <CreateDatabasePrepForm+ ref="form"+ :project-id="projectId"+ :environment-id="environmentId"+ :instance-id="instanceId"+ :backup="backup"+ @dismiss="$emit('dismiss')"+ />+ <template #footer>+ <CreateDatabasePrepButtonGroup :form="form" />+ </template>+ </DrawerContent>+</template>++<script setup lang="ts">+import { PropType, ref } from "vue";+import CreateDatabasePrepForm from "./CreateDatabasePrepForm.vue";+import { DrawerContent } from "@/components/v2";+import CreateDatabasePrepButtonGroup from "./CreateDatabasePrepButtonGroup.vue";+import { Backup } from "@/types/proto/v1/database_service";++defineProps({+ projectId: {+ type: String,+ default: undefined,+ },+ environmentId: {+ type: String,+ default: undefined,+ },+ instanceId: {+ type: String,+ default: undefined,+ },+ backup: {+ type: Object as PropType<Backup>,+ default: undefined,+ },+});++defineEmits<{+ (event: "dismiss"): void;+}>();++const form = ref<InstanceType<typeof CreateDatabasePrepForm>>();+</script>diff --git a/frontend/src/components/CreateDatabasePrepForm/index.ts b/frontend/src/components/CreateDatabasePrepForm/index.tsindex d1bbc703d1..f28898d1e2 100644--- a/frontend/src/components/CreateDatabasePrepForm/index.ts+++ b/frontend/src/components/CreateDatabasePrepForm/index.ts@@ -1,5 +1,16 @@import DatabaseLabelForm from "./DatabaseLabelForm.vue";import DatabaseNameTemplateTips from "./DatabaseNameTemplateTips.vue";+import CreateDatabasePrepForm from "./CreateDatabasePrepForm.vue";+import CreateDatabasePrepPanel from "./CreateDatabasePrepPanel.vue";+import CreateDatabasePrepButtonGroup from "./CreateDatabasePrepButtonGroup.vue";-export { DatabaseLabelForm, DatabaseNameTemplateTips };+export {+ DatabaseLabelForm,+ DatabaseNameTemplateTips,+ CreateDatabasePrepForm,+ CreateDatabasePrepPanel,+ CreateDatabasePrepButtonGroup,+};export * from "./logic";++export default CreateDatabasePrepForm;diff --git a/frontend/src/components/DatabaseBackup/BackupTable.vue b/frontend/src/components/DatabaseBackup/BackupTable.vueindex d594b7e94a..a9164b50c8 100644--- a/frontend/src/components/DatabaseBackup/BackupTable.vue+++ b/frontend/src/components/DatabaseBackup/BackupTable.vue@@ -66,54 +66,67 @@</BBGrid></div>+ <Drawer+ :show="state.restoreBackupContext !== undefined"+ @close="state.restoreBackupContext = undefined"+ >+ <DrawerContent+ v-if="state.restoreBackupContext"+ :title="$t('database.restore-database')"+ >+ <div class="w-72">+ <div v-if="allowRestoreInPlace" class="space-y-4">+ <RestoreTargetForm+ :target="state.restoreBackupContext.target"+ first="NEW"+ @change="state.restoreBackupContext!.target = $event"+ />+ </div>++ <div class="mt-2">+ <CreateDatabasePrepForm+ v-if="state.restoreBackupContext.target === 'NEW'"+ ref="createDatabasePrepForm"+ :project-id="database.projectEntity.uid"+ :environment-id="database.instanceEntity.environmentEntity.uid"+ :instance-id="database.instanceEntity.uid"+ :backup="state.restoreBackupContext.backup"+ @dismiss="state.restoreBackupContext = undefined"+ />+ </div>+ <div+ v-if="state.creatingRestoreIssue"+ class="absolute inset-0 z-10 bg-white/70 flex items-center justify-center"+ >+ <BBSpin />+ </div>+ </div>++ <template #footer>+ <div v-if="state.restoreBackupContext.target === 'NEW'">+ <CreateDatabasePrepButtonGroup :form="createDatabasePrepForm" />+ </div>++ <div+ v-if="state.restoreBackupContext.target === 'IN-PLACE'"+ class="w-full flex justify-end gap-x-3"+ >+ <NButton @click="state.restoreBackupContext = undefined">+ {{ $t("common.cancel") }}+ </NButton>++ <NButton type="primary" @click="doRestoreInPlace">+ {{ $t("common.confirm") }}+ </NButton>+ </div>+ </template>+ </DrawerContent>+ </Drawer><BBModal- v-if="state.restoreBackupContext"+ v-if="false && state.restoreBackupContext":title="$t('database.restore-database')"@close="state.restoreBackupContext = undefined">- <div v-if="allowRestoreInPlace" class="space-y-4 w-[35rem]">- <RestoreTargetForm- :target="state.restoreBackupContext.target"- @change="state.restoreBackupContext!.target = $event"- />- </div>-- <CreateDatabasePrepForm- v-if="state.restoreBackupContext.target === 'NEW'"- :project-id="database.projectEntity.uid"- :environment-id="database.instanceEntity.environmentEntity.uid"- :instance-id="database.instanceEntity.uid"- :backup="state.restoreBackupContext.backup"- @dismiss="state.restoreBackupContext = undefined"- />-- <div- v-if="state.restoreBackupContext.target === 'IN-PLACE'"- class="w-full pt-6 mt-4 flex justify-end gap-x-3 border-t border-block-border"- >- <button- type="button"- class="btn-normal py-2 px-4"- @click="state.restoreBackupContext = undefined"- >- {{ $t("common.cancel") }}- </button>-- <button- type="button"- class="btn-primary py-2 px-4"- @click="doRestoreInPlace"- >- {{ $t("common.confirm") }}- </button>- </div>-- <div- v-if="state.creatingRestoreIssue"- class="absolute inset-0 z-10 bg-white/70 flex items-center justify-center"- >- <BBSpin />- </div></BBModal><FeatureModal@@ -125,7 +138,7 @@</template><script lang="ts" setup>-import { computed, PropType, reactive } from "vue";+import { computed, PropType, reactive, ref } from "vue";import { useRouter } from "vue-router";import { useI18n } from "vue-i18n";import { NButton } from "naive-ui";@@ -139,7 +152,11 @@ import {} from "@/types";import { issueSlug, extractBackupResourceName } from "@/utils";import { featureToRef, useIssueStore } from "@/store";-import CreateDatabasePrepForm from "@/components/CreateDatabasePrepForm.vue";+import { Drawer, DrawerContent } from "@/components/v2";+import {+ CreateDatabasePrepForm,+ CreateDatabasePrepButtonGroup,+} from "@/components/CreateDatabasePrepForm";import HumanizeDate from "@/components/misc/HumanizeDate.vue";import EllipsisText from "@/components/EllipsisText.vue";import {@@ -202,6 +219,8 @@ const allowRestoreInPlace = computed((): boolean => {});const hasPITRFeature = featureToRef("bb.feature.pitr");+const createDatabasePrepForm =+ ref<InstanceType<typeof CreateDatabasePrepForm>>();const columnList = computed(() => {const columns: BBGridColumn[] = [diff --git a/frontend/src/components/DatabaseBackup/RestoreTargetForm.vue b/frontend/src/components/DatabaseBackup/RestoreTargetForm.vueindex 45b2bfa44a..ef1bd3c1ba 100644--- a/frontend/src/components/DatabaseBackup/RestoreTargetForm.vue+++ b/frontend/src/components/DatabaseBackup/RestoreTargetForm.vue@@ -1,50 +1,38 @@<template>- <div class="mx-4 space-y-6 divide-y divide-block-border">- <div class="grid gap-y-6 gap-x-4 grid-cols-4">- <div class="col-span-3 col-start-2">- <label class="textlabel">- {{ $t("database.pitr.restore-to") }}- </label>- <div class="flex items-center gap-6 textlabel py-1">- <label class="flex items-center gap-2">- <input- type="radio"- :checked="state.target === 'NEW'"- @input="$emit('change', 'NEW')"- />- <span>{{ $t("database.pitr.restore-to-new-db") }}</span>- </label>- <label class="flex items-center">- <input- type="radio"- :checked="state.target === 'IN-PLACE'"- @input="$emit('change', 'IN-PLACE')"- />- <span class="ml-2 flex items-center">- {{ $t("database.pitr.restore-to-in-place") }}-- <FeatureBadge- feature="bb.feature.pitr"- class="text-accent ml-1"- />- </span>- </label>- </div>- <div- v-if="state.target === 'IN-PLACE'"- class="flex items-center gap-2 text-error mt-2"- >- <heroicons-outline:exclamation-circle class="w-4 h-4" />- <span class="whitespace-nowrap text-sm">- {{ $t("database.pitr.will-overwrite-current-database") }}- </span>- </div>- </div>+ <div class="flex flex-col gap-y-2">+ <label class="textlabel">+ {{ $t("database.pitr.restore-to") }}+ </label>+ <div class="flex items-center gap-x-6 gap-y-2 flex-wrap">+ <NRadio+ v-for="value in targets"+ :key="value"+ :checked="state.target === value"+ @update:checked="check(value, $event)"+ >+ <template v-if="value === 'IN-PLACE'">+ {{ $t("database.pitr.restore-to-in-place") }}+ </template>+ <template v-if="value === 'NEW'">+ {{ $t("database.pitr.restore-to-new-db") }}+ </template>+ </NRadio>+ </div>+ <div+ v-if="state.target === 'IN-PLACE'"+ class="flex items-center gap-2 text-error"+ >+ <heroicons-outline:exclamation-circle class="w-4 h-4" />+ <span class="whitespace-nowrap text-sm">+ {{ $t("database.pitr.will-overwrite-current-database") }}+ </span></div></div></template><script lang="ts" setup>+import { NRadio } from "naive-ui";+import { computed } from "vue";import { PropType, reactive, watch } from "vue";export type RestoreTarget = "IN-PLACE" | "NEW";@@ -58,9 +46,13 @@ const props = defineProps({type: String as PropType<RestoreTarget>,required: true,},+ first: {+ type: String as PropType<RestoreTarget>,+ default: "IN-PLACE",+ },});-defineEmits<{+const emit = defineEmits<{(event: "change", target: RestoreTarget): void;}>();@@ -68,6 +60,16 @@ const state = reactive<LocalState>({target: props.target,});+const targets = computed((): RestoreTarget[] => {+ return props.first === "IN-PLACE" ? ["IN-PLACE", "NEW"] : ["NEW", "IN-PLACE"];+});++const check = (value: RestoreTarget, on: boolean) => {+ if (on) {+ emit("change", value);+ }+};+watch(() => props.target,(target) => {diff --git a/frontend/src/components/DatabaseDetail/ChangeHistoryBrief.vue b/frontend/src/components/DatabaseDetail/ChangeHistoryBrief.vueindex 28271fee69..bf268d2385 100644--- a/frontend/src/components/DatabaseDetail/ChangeHistoryBrief.vue+++ b/frontend/src/components/DatabaseDetail/ChangeHistoryBrief.vue@@ -1,7 +1,7 @@<template><div class="w-full space-y-4 text-sm"><div class="flex items-center gap-x-4">- <label class="w-1/4 flex justify-end textlabel">+ <label class="w-1/4 flex justify-start textlabel">{{ $t("common.version") }}</label><div class="flex-1">@@ -16,7 +16,7 @@</div><div v-if="changeHistory" class="flex items-center gap-x-4">- <label class="w-1/4 flex justify-end textlabel">+ <label class="w-1/4 flex justify-start textlabel">{{ $t("common.issue") }}</label><div class="flex-1">@@ -31,7 +31,7 @@</div><div class="flex items-start gap-x-4">- <label class="w-1/4 flex justify-end textlabel">+ <label class="w-1/4 flex justify-start textlabel">{{ $t("common.sql") }}</label><div class="flex-1">@@ -58,7 +58,7 @@</div><div class="flex items-center gap-x-4">- <label class="w-1/4 flex justify-end textlabel">+ <label class="w-1/4 flex justify-start textlabel">{{ $t("common.created-at") }}</label><div class="flex-1">@@ -68,7 +68,7 @@</div><div class="flex items-center gap-x-4">- <label class="w-1/4 flex justify-end textlabel">+ <label class="w-1/4 flex justify-start textlabel">{{ $t("common.creator") }}</label><div v-if="creator" class="flex-1">diff --git a/frontend/src/components/DatabaseDetail/PITRRestoreButton.vue b/frontend/src/components/DatabaseDetail/PITRRestoreButton.vueindex aa381b87ee..2197e169d5 100644--- a/frontend/src/components/DatabaseDetail/PITRRestoreButton.vue+++ b/frontend/src/components/DatabaseDetail/PITRRestoreButton.vue@@ -32,146 +32,107 @@<BBBetaBadge corner /></div>- <BBModal- v-if="state.showDatabasePITRModal"- :title="$t('database.pitr.restore')"- @close="state.showDatabasePITRModal = false"- >- <div class="w-112 flex flex-col items-center gap-4">- <div class="w-full textinfolabel">- <i18n-t- :keypath="- state.mode === 'LAST_MIGRATION'- ? 'database.pitr.restore-before-last-migration-help-info'- : 'database.pitr.help-info'- "- tag="p"- >- <template #link>- <a- class="normal-link inline-flex items-center"- href="https://www.bytebase.com/docs/disaster-recovery/point-in-time-recovery-for-mysql"- target="__BLANK"- >- {{ $t("common.learn-more") }}- <heroicons-outline:external-link class="w-4 h-4" />- </a>- </template>- </i18n-t>- </div>-- <template- v-if="state.step === 'LAST_MIGRATION_INFO' && lastChangeHistory"- >- <ChangeHistoryBrief- :database="database"- :change-history="lastChangeHistory"- />- </template>-- <template v-else>- <div class="w-72 space-y-4">- <div class="space-y-2">- <label class="textlabel w-full flex items-baseline">- <span>{{ $t("database.pitr.point-in-time") }}</span>- <span class="text-gray-400 text-xs ml-2">{{ timezone }}</span>- <span class="text-red-600 ml-1">*</span>- </label>- <NDatePicker- v-model:value="state.pitrTimestampMS"- type="datetime"- :disabled="state.mode === 'LAST_MIGRATION'"- />- <div v-if="pitrTimestampError" class="text-sm text-red-600">- {{ pitrTimestampError }}- </div>- </div>+ <Drawer v-model:show="state.showDatabasePITRModal">+ <DrawerContent :title="$t('database.pitr.restore')">+ <div class="w-72 flex flex-col items-center gap-4">+ <div class="w-full textinfolabel">+ <i18n-t+ :keypath="+ state.mode === 'LAST_MIGRATION'+ ? 'database.pitr.restore-before-last-migration-help-info'+ : 'database.pitr.help-info'+ "+ tag="p"+ >+ <template #link>+ <a+ class="normal-link inline-flex items-center"+ href="https://www.bytebase.com/docs/disaster-recovery/point-in-time-recovery-for-mysql"+ target="__BLANK"+ >+ {{ $t("common.learn-more") }}+ <heroicons-outline:external-link class="w-4 h-4" />+ </a>+ </template>+ </i18n-t>+ </div>- <div class="space-y-2">- <label class="textlabel w-full flex flex-col gap-1">- {{ $t("database.pitr.restore-to") }}- </label>- <div class="flex items-center gap-3 textlabel">- <label class="flex items-center">- <input- type="radio"- :checked="state.target === 'IN-PLACE'"- @input="state.target = 'IN-PLACE'"- />- <span class="ml-2">- {{ $t("database.pitr.restore-to-in-place") }}- </span>- </label>- <label class="flex items-center gap-2">- <input- type="radio"- :checked="state.target === 'NEW'"- @input="state.target = 'NEW'"- />- <span>{{ $t("database.pitr.restore-to-new-db") }}</span>+ <template+ v-if="state.step === 'LAST_MIGRATION_INFO' && lastChangeHistory"+ >+ <ChangeHistoryBrief+ :database="database"+ :change-history="lastChangeHistory"+ />+ </template>++ <template v-else>+ <div class="w-72 space-y-4">+ <div class="space-y-2">+ <label class="textlabel w-full flex items-baseline">+ <span>{{ $t("database.pitr.point-in-time") }}</span>+ <span class="text-gray-400 text-xs ml-2">{{ timezone }}</span>+ <span class="text-red-600 ml-1">*</span></label>+ <NDatePicker+ v-model:value="state.pitrTimestampMS"+ type="datetime"+ :disabled="state.mode === 'LAST_MIGRATION'"+ />+ <div v-if="pitrTimestampError" class="text-sm text-red-600">+ {{ pitrTimestampError }}+ </div></div>- <div- v-if="state.target === 'IN-PLACE'"- class="flex items-center gap-2 text-error mt-2"- >- <heroicons-outline:exclamation-circle class="w-4 h-4" />- <span class="whitespace-nowrap text-sm">- {{ $t("database.pitr.will-overwrite-current-database") }}- </span>- </div>- </div>+ <RestoreTargetForm+ :target="state.target"+ @change="state.target = $event"+ />- <CreatePITRDatabaseForm- v-if="state.target === 'NEW'"- ref="createDatabaseForm"- :database="database"- :context="state.createContext"- @update="state.createContext = $event"- />- </div>- </template>+ <CreatePITRDatabaseForm+ v-if="state.target === 'NEW'"+ ref="createDatabaseForm"+ :database="database"+ :context="state.createContext"+ @update="state.createContext = $event"+ />+ </div>+ </template>- <div- class="w-full pt-6 mt-6 flex justify-end gap-x-3 border-t border-block-border"- >- <button- type="button"- class="btn-normal py-2 px-4"- @click.prevent="resetUI"+ <div+ v-if="state.loading"+ class="absolute inset-0 z-10 bg-white/70 flex items-center justify-center">- {{ $t("common.cancel") }}- </button>-- <button- v-if="state.step === 'LAST_MIGRATION_INFO'"- type="button"- class="btn-primary py-2 px-4"- @click.prevent="initLastChangeParams"- >- {{ $t("common.next") }}- </button>-- <button- v-if="state.step === 'PITR_FORM'"- type="button"- class="btn-primary py-2 px-4"- :disabled="!!pitrTimestampError"- @click.prevent="onConfirm"- >- {{ $t("common.confirm") }}- </button>+ <BBSpin />+ </div></div>- <div- v-if="state.loading"- class="absolute inset-0 z-10 bg-white/70 flex items-center justify-center"- >- <BBSpin />- </div>- </div>- </BBModal>+ <template #footer>+ <div class="flex justify-end gap-x-3">+ <NButton @click.prevent="resetUI">+ {{ $t("common.cancel") }}+ </NButton>++ <NButton+ v-if="state.step === 'LAST_MIGRATION_INFO'"+ type="primary"+ @click.prevent="initLastChangeParams"+ >+ {{ $t("common.next") }}+ </NButton>++ <NButton+ v-if="state.step === 'PITR_FORM'"+ type="primary"+ :disabled="!!pitrTimestampError"+ @click.prevent="onConfirm"+ >+ {{ $t("common.confirm") }}+ </NButton>+ </div>+ </template>+ </DrawerContent>+ </Drawer><FeatureModalv-if="state.showFeatureModal"@@ -183,14 +144,17 @@<script lang="ts" setup>import { computed, PropType, reactive, ref, toRef } from "vue";import { useRouter } from "vue-router";-import { NDatePicker } from "naive-ui";+import { NButton, NDatePicker } from "naive-ui";import dayjs from "dayjs";import { useI18n } from "vue-i18n";+import { CreateDatabaseContext, ComposedDatabase } from "@/types";import { usePITRLogic } from "@/plugins";import { issueSlug } from "@/utils";import { featureToRef } from "@/store";+import { Drawer, DrawerContent } from "@/components/v2";import CreatePITRDatabaseForm from "./CreatePITRDatabaseForm.vue";+import RestoreTargetForm from "../DatabaseBackup/RestoreTargetForm.vue";import { CreatePITRDatabaseContext } from "./utils";import BBContextMenuButton, {type ButtonAction,diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vueindex f447c9c3a0..e622c3c066 100644--- a/frontend/src/components/EnvironmentForm.vue+++ b/frontend/src/components/EnvironmentForm.vue@@ -1,315 +1,314 @@<template>- <div- class="px-4 py-2 divide-y divide-block-border"- :class="create ? 'w-160' : 'w-full'"- >- <div class="grid grid-cols-1 gap-x-4">- <div class="col-span-1">- <label for="name" class="textlabel">- {{ $t("common.environment-name") }}- <span class="text-red-600">*</span>- </label>- <BBTextField- class="mt-2 w-full"- :disabled="!allowEdit"- :required="true"- :value="state.environment.title"- @input="handleEnvironmentNameChange"- />- </div>-- <div class="mt-2">- <ResourceIdField- ref="resourceIdField"- resource-type="environment"- :readonly="!create"- :value="state.environment.name"- :resource-title="state.environment.title"- :validate="validateResourceId"- />- </div>+ <component :is="drawer ? DrawerContent : 'div'" v-bind="bindings">+ <div+ class="divide-y divide-block-border"+ :class="drawer ? 'w-[36rem]' : 'w-full px-4 pb-4'"+ >+ <div class="grid grid-cols-1 gap-x-4">+ <div class="col-span-1">+ <label for="name" class="textlabel">+ {{ $t("common.environment-name") }}+ <span class="text-red-600">*</span>+ </label>+ <BBTextField+ class="mt-2 w-full"+ :disabled="!allowEdit"+ :required="true"+ :value="state.environment.title"+ @input="handleEnvironmentNameChange"+ />+ </div>- <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"+ <div class="mt-2">+ <ResourceIdField+ ref="resourceIdField"+ resource-type="environment"+ :readonly="!create"+ :value="state.environment.name"+ :resource-title="state.environment.title"+ :validate="validateResourceId"/>- </label>- <p class="mt-2 text-sm text-gray-600">- <i18n-t tag="span" keypath="policy.environment-tier.description">- <template #newline><br /></template>- </i18n-t>- <a- class="inline-flex items-center text-blue-600 ml-1 hover:underline"- href="https://www.bytebase.com/docs/administration/environment-policy/tier"- target="_blank"- >{{ $t("common.learn-more")- }}<heroicons-outline:external-link class="w-4 h-4"- /></a>- </p>- <div class="mt-4 flex flex-col space-y-4">- <div class="flex space-x-4">- <BBCheckbox- :value="state.environmentTier === EnvironmentTier.PROTECTED"- :disabled="!allowEdit"- @toggle="(on: boolean) => {+ </div>++ <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"+ />+ </label>+ <p class="mt-2 text-sm text-gray-600">+ <i18n-t tag="span" keypath="policy.environment-tier.description">+ <template #newline><br /></template>+ </i18n-t>+ <a+ class="inline-flex items-center text-blue-600 ml-1 hover:underline"+ href="https://www.bytebase.com/docs/administration/environment-policy/tier"+ target="_blank"+ >{{ $t("common.learn-more")+ }}<heroicons-outline:external-link class="w-4 h-4"+ /></a>+ </p>+ <div class="mt-4 flex flex-col space-y-4">+ <div class="flex space-x-4">+ <BBCheckbox+ :value="state.environmentTier === EnvironmentTier.PROTECTED"+ :disabled="!allowEdit"+ @toggle="(on: boolean) => {state.environmentTier = on ? EnvironmentTier.PROTECTED : EnvironmentTier.UNPROTECTED}"- />- <div>- <div class="textlabel">- {{ $t("policy.environment-tier.mark-env-as-production") }}+ />+ <div>+ <div class="textlabel">+ {{ $t("policy.environment-tier.mark-env-as-production") }}+ </div></div></div></div></div>- </div>- <div class="col-span-1 mt-6">- <label class="textlabel">- {{ $t("policy.rollout.name") }}- </label>- <span v-show="valueChanged('approvalPolicy')" class="textlabeltip">{{- $t("policy.rollout.tip")- }}</span>- <div class="mt-1 textinfolabel">- {{ $t("policy.rollout.info") }}- </div>- <div class="mt-4 flex flex-col space-y-4">- <div class="flex space-x-4">- <input- v-model="state.approvalPolicy.deploymentApprovalPolicy!.defaultStrategy"- name="manual-approval-always"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- :value="ApprovalStrategy.MANUAL"- :disabled="!allowEdit"- />- <div class="-mt-0.5">- <div class="textlabel">- {{ $t("policy.rollout.manual") }}- </div>- <div class="mt-1 textinfolabel">- {{ $t("policy.rollout.manual-info") }}+ <div class="col-span-1 mt-6">+ <label class="textlabel">+ {{ $t("policy.rollout.name") }}+ </label>+ <span v-show="valueChanged('approvalPolicy')" class="textlabeltip">{{+ $t("policy.rollout.tip")+ }}</span>+ <div class="mt-1 textinfolabel">+ {{ $t("policy.rollout.info") }}+ </div>+ <div class="mt-4 flex flex-col space-y-4">+ <div class="flex space-x-4">+ <input+ v-model="state.approvalPolicy.deploymentApprovalPolicy!.defaultStrategy"+ name="manual-approval-always"+ tabindex="-1"+ type="radio"+ class="text-accent disabled:text-accent-disabled focus:ring-accent"+ :value="ApprovalStrategy.MANUAL"+ :disabled="!allowEdit"+ />+ <div class="-mt-0.5">+ <div class="textlabel">+ {{ $t("policy.rollout.manual") }}+ </div>+ <div class="mt-1 textinfolabel">+ {{ $t("policy.rollout.manual-info") }}+ </div></div></div>- </div>- <AssigneeGroupEditor- class="ml-8"- :policy="state.approvalPolicy"- :allow-edit="allowEdit"- @update="(assigneeGroupList) => {+ <AssigneeGroupEditor+ class="ml-8"+ :policy="state.approvalPolicy"+ :allow-edit="allowEdit"+ @update="(assigneeGroupList) => {state.approvalPolicy.deploymentApprovalPolicy!.deploymentApprovalStrategies = assigneeGroupList}"- />-- <div class="flex space-x-4">- <input- v-model="state.approvalPolicy.deploymentApprovalPolicy!.defaultStrategy"- name="manual-approval-never"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- :value="ApprovalStrategy.AUTOMATIC"- :disabled="!allowEdit"/>- <div class="-mt-0.5">- <div class="textlabel flex">- {{ $t("policy.rollout.auto") }}- <FeatureBadge- feature="bb.feature.approval-policy"- class="text-accent"- />- </div>- <div class="mt-1 textinfolabel">- {{ $t("policy.rollout.auto-info") }}++ <div class="flex space-x-4">+ <input+ v-model="state.approvalPolicy.deploymentApprovalPolicy!.defaultStrategy"+ name="manual-approval-never"+ tabindex="-1"+ type="radio"+ class="text-accent disabled:text-accent-disabled focus:ring-accent"+ :value="ApprovalStrategy.AUTOMATIC"+ :disabled="!allowEdit"+ />+ <div class="-mt-0.5">+ <div class="textlabel flex">+ {{ $t("policy.rollout.auto") }}+ <FeatureBadge+ feature="bb.feature.approval-policy"+ class="text-accent"+ />+ </div>+ <div class="mt-1 textinfolabel">+ {{ $t("policy.rollout.auto-info") }}+ </div></div></div></div></div>- </div>- <div class="col-span-1 mt-6">- <label class="textlabel"> {{ $t("policy.backup.name") }} </label>- <span v-show="valueChanged('backupPolicy')" class="textlabeltip">{{- $t("policy.backup.tip")- }}</span>- <div class="mt-4 flex flex-col space-y-4">- <div class="flex space-x-4">- <input- v-model="state.backupPolicy.backupPlanPolicy!.schedule"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- :value="BackupPlanSchedule.UNSET"- :disabled="!allowEdit"- />- <div class="-mt-0.5">- <div class="textlabel">- {{ $t("policy.backup.not-enforced") }}- </div>- <div class="mt-1 textinfolabel">- {{ $t("policy.backup.not-enforced-info") }}+ <div class="col-span-1 mt-6">+ <label class="textlabel"> {{ $t("policy.backup.name") }} </label>+ <span v-show="valueChanged('backupPolicy')" class="textlabeltip">{{+ $t("policy.backup.tip")+ }}</span>+ <div class="mt-4 flex flex-col space-y-4">+ <div class="flex space-x-4">+ <input+ v-model="state.backupPolicy.backupPlanPolicy!.schedule"+ tabindex="-1"+ type="radio"+ class="text-accent disabled:text-accent-disabled focus:ring-accent"+ :value="BackupPlanSchedule.UNSET"+ :disabled="!allowEdit"+ />+ <div class="-mt-0.5">+ <div class="textlabel">+ {{ $t("policy.backup.not-enforced") }}+ </div>+ <div class="mt-1 textinfolabel">+ {{ $t("policy.backup.not-enforced-info") }}+ </div></div></div>- </div>- <div class="flex space-x-4">- <input- v-model="state.backupPolicy.backupPlanPolicy!.schedule"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- :value="BackupPlanSchedule.DAILY"- :disabled="!allowEdit"- />- <div class="-mt-0.5">- <div class="textlabel flex">- {{ $t("policy.backup.daily") }}- <FeatureBadge- feature="bb.feature.backup-policy"- class="text-accent"- />- </div>- <div class="mt-1 textinfolabel">- {{ $t("policy.backup.daily-info") }}+ <div class="flex space-x-4">+ <input+ v-model="state.backupPolicy.backupPlanPolicy!.schedule"+ tabindex="-1"+ type="radio"+ class="text-accent disabled:text-accent-disabled focus:ring-accent"+ :value="BackupPlanSchedule.DAILY"+ :disabled="!allowEdit"+ />+ <div class="-mt-0.5">+ <div class="textlabel flex">+ {{ $t("policy.backup.daily") }}+ <FeatureBadge+ feature="bb.feature.backup-policy"+ class="text-accent"+ />+ </div>+ <div class="mt-1 textinfolabel">+ {{ $t("policy.backup.daily-info") }}+ </div></div></div>- </div>- <div class="flex space-x-4">- <input- v-model="state.backupPolicy.backupPlanPolicy!.schedule"- tabindex="-1"- type="radio"- class="text-accent disabled:text-accent-disabled focus:ring-accent"- :value="BackupPlanSchedule.WEEKLY"- :disabled="!allowEdit"- />- <div class="-mt-0.5">- <div class="textlabel flex">- {{ $t("policy.backup.weekly") }}- <FeatureBadge- feature="bb.feature.backup-policy"- class="text-accent"- />- </div>- <div class="mt-1 textinfolabel">- {{ $t("policy.backup.weekly-info") }}+ <div class="flex space-x-4">+ <input+ v-model="state.backupPolicy.backupPlanPolicy!.schedule"+ tabindex="-1"+ type="radio"+ class="text-accent disabled:text-accent-disabled focus:ring-accent"+ :value="BackupPlanSchedule.WEEKLY"+ :disabled="!allowEdit"+ />+ <div class="-mt-0.5">+ <div class="textlabel flex">+ {{ $t("policy.backup.weekly") }}+ <FeatureBadge+ feature="bb.feature.backup-policy"+ class="text-accent"+ />+ </div>+ <div class="mt-1 textinfolabel">+ {{ $t("policy.backup.weekly-info") }}+ </div></div></div></div></div>- </div>- <div v-if="!create" class="col-span-1 mt-6">- <label class="textlabel">- {{ $t("sql-review.title") }}- </label>- <div class="mt-3">- <div v-if="sqlReviewPolicy" class="inline-flex items-center">- <BBSwitch- v-if="allowEditSQLReviewPolicy"- class="mr-2"- :text="true"- :value="sqlReviewPolicy.enforce"- @toggle="toggleSQLReviewPolicy"- />+ <div v-if="!create" class="col-span-1 mt-6">+ <label class="textlabel">+ {{ $t("sql-review.title") }}+ </label>+ <div class="mt-3">+ <div v-if="sqlReviewPolicy" class="inline-flex items-center">+ <BBSwitch+ v-if="allowEditSQLReviewPolicy"+ class="mr-2"+ :text="true"+ :value="sqlReviewPolicy.enforce"+ @toggle="toggleSQLReviewPolicy"+ />+ <button+ type="button"+ class="text-sm font-medium text-accent hover:underline-2"+ @click.prevent="onSQLReviewPolicyClick"+ >+ {{ sqlReviewPolicy.name }}+ </button>+ </div><button+ v-else-if="hasPermission"type="button"- class="text-sm font-medium text-accent hover:underline-2"+ class="btn-normal py-2 px-4 gap-x-1 items-center"@click.prevent="onSQLReviewPolicyClick">- {{ sqlReviewPolicy.name }}+ {{ $t("sql-review.configure-policy") }}</button>+ <span v-else class="textinfolabel">+ {{ $t("sql-review.no-policy-set") }}+ </span></div>+ </div>+ </div>++ <div v-if="!drawer" class="mt-6 flex justify-between items-center pt-5">+ <template+ v-if="(state.environment as Environment).state === State.ACTIVE"+ >+ <BBButtonConfirm+ v-if="allowArchive"+ :style="'ARCHIVE'"+ :button-text="$t('environment.archive')"+ :ok-text="$t('common.archive')"+ :confirm-title="+ $t('environment.archive') + ` '${(state.environment as Environment).title}'?`+ "+ :confirm-description="$t('environment.archive-info')"+ :require-confirm="true"+ @confirm="archiveEnvironment"+ />+ </template>+ <template+ v-else-if="(state.environment as Environment).state === State.DELETED"+ >+ <BBButtonConfirm+ v-if="allowRestore"+ :style="'RESTORE'"+ :button-text="$t('environment.restore')"+ :ok-text="$t('common.restore')"+ :confirm-title="+ $t('environment.restore') + ` '${(state.environment as Environment).title}'?`+ "+ :confirm-description="''"+ :require-confirm="true"+ @confirm="restoreEnvironment"+ />+ </template>+ <div v-else></div>+ <div v-if="allowEdit"><button- v-else-if="hasPermission"type="button"- class="btn-normal py-2 px-4 gap-x-1 items-center"- @click.prevent="onSQLReviewPolicyClick"+ class="btn-normal py-2 px-4"+ :disabled="!valueChanged()"+ @click.prevent="revertEnvironment"+ >+ {{ $t("common.revert") }}+ </button>+ <button+ type="submit"+ class="btn-primary ml-3 inline-flex justify-center py-2 px-4"+ :disabled="!valueChanged()"+ @click.prevent="updateEnvironment">- {{ $t("sql-review.configure-policy") }}+ {{ $t("common.update") }}</button>- <span v-else class="textinfolabel">- {{ $t("sql-review.no-policy-set") }}- </span></div></div></div>- <!-- Create button group -->- <div v-if="create" class="mt-6 flex justify-end pt-5">- <button- type="button"- class="btn-normal py-2 px-4"- @click.prevent="$emit('cancel')"- >- {{ $t("common.cancel") }}- </button>- <button- type="submit"- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="!allowCreate"- @click.prevent="createEnvironment"- >- {{ $t("common.create") }}- </button>- </div>- <!-- Update button group -->- <div v-else class="mt-6 flex justify-between items-center pt-5">- <template- v-if="(state.environment as Environment).state === State.ACTIVE"- >- <BBButtonConfirm- v-if="allowArchive"- :style="'ARCHIVE'"- :button-text="$t('environment.archive')"- :ok-text="$t('common.archive')"- :confirm-title="- $t('environment.archive') + ` '${(state.environment as Environment).title}'?`- "- :confirm-description="$t('environment.archive-info')"- :require-confirm="true"- @confirm="archiveEnvironment"- />- </template>- <template- v-else-if="(state.environment as Environment).state === State.DELETED"- >- <BBButtonConfirm- v-if="allowRestore"- :style="'RESTORE'"- :button-text="$t('environment.restore')"- :ok-text="$t('common.restore')"- :confirm-title="- $t('environment.restore') + ` '${(state.environment as Environment).title}'?`- "- :confirm-description="''"- :require-confirm="true"- @confirm="restoreEnvironment"- />- </template>- <div v-else></div>- <div v-if="allowEdit">- <button- type="button"- class="btn-normal py-2 px-4"- :disabled="!valueChanged()"- @click.prevent="revertEnvironment"- >- {{ $t("common.revert") }}- </button>- <button- type="submit"- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="!valueChanged()"- @click.prevent="updateEnvironment"+ <template v-if="drawer" #footer>+ <div class="flex justify-end items-center gap-x-3">+ <NButton @click.prevent="$emit('cancel')">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ type="primary"+ :disabled="!allowCreate"+ @click.prevent="createEnvironment">- {{ $t("common.update") }}- </button>+ {{ $t("common.create") }}+ </NButton></div>- </div>- </div>+ <!-- Update button group -->+ </template>+ </component></template><script lang="ts" setup>@@ -318,12 +317,14 @@ import { cloneDeep, isEqual, isEmpty } from "lodash-es";import { Status } from "nice-grpc-common";import { useRouter } from "vue-router";import { useI18n } from "vue-i18n";+import { NButton } from "naive-ui";-import type { ResourceId, SQLReviewPolicy, ValidatedMessage } from "../types";+import type { ResourceId, SQLReviewPolicy, ValidatedMessage } from "@/types";import { useEnvironmentV1Store } from "@/store/modules/v1/environment";import { environmentNamePrefix } from "@/store/modules/v1/common";import { getErrorCode } from "@/utils/grpcweb";import { BBSwitch } from "@/bbkit";+import { DrawerContent } from "@/components/v2";import { hasWorkspacePermissionV1, sqlReviewPolicySlug } from "@/utils";import {pushNotification,@@ -375,6 +376,10 @@ const props = defineProps({required: true,type: Number as PropType<EnvironmentTier>,},+ drawer: {+ type: Boolean,+ default: false,+ },});const emit = defineEmits([@@ -399,6 +404,15 @@ const environmentV1Store = useEnvironmentV1Store();const sqlReviewStore = useSQLReviewStore();const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();+const bindings = computed(() => {+ if (props.drawer) {+ return {+ title: t("environment.create"),+ };+ }+ return {};+});+const environmentId = computed(() => {if (props.create) {return;diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vueindex 8393b16174..3b16b8b8e3 100644--- a/frontend/src/components/InstanceForm/InstanceForm.vue+++ b/frontend/src/components/InstanceForm/InstanceForm.vue@@ -1,572 +1,546 @@<template>- <div- class="space-y-6 divide-y divide-block-border"- :class="- modal && ['max-h-[calc(100vh-10rem)] overflow-hidden flex flex-col']- "- >- <div- class="divide-y divide-block-border w-[850px]"- :class="modal && ['flex-1 overflow-y-auto']"- >- <div v-if="isCreating" class="w-full mt-4 mb-6 grid grid-cols-4 gap-2">- <template v-for="engine in engineList" :key="engine">- <div- class="flex relative justify-start p-2 border rounded cursor-pointer hover:bg-control-bg-hover"- :class="- basicInfo.engine === engine && 'font-medium bg-control-bg-hover'- "- @click.capture="changeInstanceEngine(engine)"- >- <div class="flex flex-row justify-start items-center">- <input- type="radio"- class="btn mr-2"- :checked="basicInfo.engine === engine"- />- <img- v-if="EngineIconPath[engine]"- class="w-5 h-auto max-h-[20px] object-contain mr-1"- :src="EngineIconPath[engine]"- />- <p class="text-center text-sm">- {{ engineNameV1(engine) }}- </p>- <template v-if="isEngineBeta(engine)">- <BBBetaBadge- class="absolute -top-px -right-px rounded text-xs !bg-gray-500 px-1 !py-0"+ <component :is="drawer ? DrawerContent : 'div'" v-bind="bindings">+ <div class="space-y-6 divide-y divide-block-border">+ <div class="divide-y divide-block-border w-[850px]">+ <div v-if="isCreating" class="w-full mt-4 mb-6 grid grid-cols-4 gap-2">+ <template v-for="engine in engineList" :key="engine">+ <div+ class="flex relative justify-start p-2 border rounded cursor-pointer hover:bg-control-bg-hover"+ :class="+ basicInfo.engine === engine && 'font-medium bg-control-bg-hover'+ "+ @click.capture="changeInstanceEngine(engine)"+ >+ <div class="flex flex-row justify-start items-center">+ <input+ type="radio"+ class="btn mr-2"+ :checked="basicInfo.engine === engine"/>- </template>+ <img+ v-if="EngineIconPath[engine]"+ class="w-5 h-auto max-h-[20px] object-contain mr-1"+ :src="EngineIconPath[engine]"+ />+ <p class="text-center text-sm">+ {{ engineNameV1(engine) }}+ </p>+ <template v-if="isEngineBeta(engine)">+ <BBBetaBadge+ class="absolute -top-px -right-px rounded text-xs !bg-gray-500 px-1 !py-0"+ />+ </template>+ </div></div>- </div>- </template>- </div>-- <!-- Instance Name -->- <div class="pt-4 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-4">- <div class="sm:col-span-2 sm:col-start-1">- <label for="name" class="textlabel flex flex-row items-center">- {{ $t("instance.instance-name") }}- <span class="text-red-600 mr-2">*</span>- <template v-if="props.instance">- <InstanceV1EngineIcon- :instance="props.instance"- :tooltip="false"- />- <span class="ml-1">{{ props.instance.engineVersion }}</span>- </template>- </label>- <input- id="name"- v-model="basicInfo.title"- required- name="name"- type="text"- class="textfield mt-1 w-full"- :disabled="!allowEdit"- />- </div>-- <div- :key="basicInfo.environment"- class="sm:col-span-3 sm:col-start-1 -mt-4"- >- <ResourceIdField- ref="resourceIdField"- v-model:value="resourceId"- class="max-w-full flex-nowrap"- resource-type="instance"- :readonly="!isCreating"- :resource-title="basicInfo.title"- :validate="validateResourceId"- />- </div>-- <div class="sm:col-span-2 sm:col-start-1">- <label for="environment" class="textlabel">- {{ $t("common.environment") }}- </label>- <EnvironmentSelect- id="environment"- class="mt-1 w-full"- name="environment"- :disabled="!isCreating"- :selected-id="environment.uid"- @select-environment-id="handleSelectEnvironmentUID"- />+ </template></div>- <div class="sm:col-span-3 sm:col-start-1">- <template v-if="basicInfo.engine !== Engine.SPANNER">- <label for="host" class="textlabel block">- <template v-if="basicInfo.engine === Engine.SNOWFLAKE">- {{ $t("instance.account-name") }}- <span class="text-red-600 mr-2">*</span>- </template>- <template v-else>- {{ $t("instance.host-or-socket") }}- <span class="text-red-600 mr-2">*</span>+ <!-- Instance Name -->+ <div class="pt-4 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-4">+ <div class="sm:col-span-2 sm:col-start-1">+ <label for="name" class="textlabel flex flex-row items-center">+ {{ $t("instance.instance-name") }}+ <span class="text-red-600 mr-2">*</span>+ <template v-if="props.instance">+ <InstanceV1EngineIcon+ :instance="props.instance"+ :tooltip="false"+ />+ <span class="ml-1">{{ props.instance.engineVersion }}</span></template></label><input- id="host"- v-model="adminDataSource.host"+ id="name"+ v-model="basicInfo.title"required+ name="name"type="text"- name="host"- :placeholder="- basicInfo.engine === Engine.SNOWFLAKE- ? $t('instance.your-snowflake-account-name')- : $t('instance.sentence.host.snowflake')- "class="textfield mt-1 w-full":disabled="!allowEdit"/>- <div- v-if="basicInfo.engine === Engine.SNOWFLAKE"- class="mt-2 textinfolabel"- >- {{ $t("instance.sentence.proxy.snowflake") }}- </div>- </template>- <SpannerHostInput- v-else- v-model:host="adminDataSource.host"- :allow-edit="allowEdit"- />- </div>+ </div>- <template v-if="basicInfo.engine !== Engine.SPANNER">- <div class="sm:col-span-1">- <label for="port" class="textlabel block">- {{ $t("instance.port") }}- </label>- <input- id="port"- type="text"- name="port"- class="textfield mt-1 w-full"- :value="adminDataSource.port"- :placeholder="defaultPort"- :disabled="!allowEdit || !allowEditPort"- @wheel="(e: WheelEvent) => (e.target as HTMLInputElement).blur()"- @input="adminDataSource.port = trimInputValue($event.target)"+ <div+ :key="basicInfo.environment"+ class="sm:col-span-3 sm:col-start-1 -mt-4"+ >+ <ResourceIdField+ ref="resourceIdField"+ v-model:value="resourceId"+ class="max-w-full flex-nowrap"+ resource-type="instance"+ :readonly="!isCreating"+ :resource-title="basicInfo.title"+ :validate="validateResourceId"/></div>- </template>- <div- v-if="basicInfo.engine === Engine.MONGODB"- class="sm:col-span-4 sm:col-start-1"- >- <label- for="connectionStringSchema"- class="textlabel flex flex-row items-center"- >- {{ $t("data-source.connection-string-schema") }}- </label>- <label- v-for="type in mongodbConnectionStringSchemaList"- :key="type"- class="radio h-7"- >- <input- type="radio"- class="btn"- name="connectionStringSchema"- :value="type"- :checked="type === currentMongoDBConnectionSchema"- @change="handleMongodbConnectionStringSchemaChange"+ <div class="sm:col-span-2 sm:col-start-1">+ <label for="environment" class="textlabel">+ {{ $t("common.environment") }}+ </label>+ <EnvironmentSelect+ id="environment"+ class="mt-1 w-full"+ name="environment"+ :disabled="!isCreating"+ :selected-id="environment.uid"+ @select-environment-id="handleSelectEnvironmentUID"/>- <span class="label">- {{ type }}- </span>- </label>- </div>+ </div>- <!--Do not show external link on create to reduce cognitive load-->- <div v-if="!isCreating" class="sm:col-span-3 sm:col-start-1">- <label for="external-link" class="textlabel inline-flex">- <span class>- {{- basicInfo.engine === Engine.SNOWFLAKE- ? $t("instance.snowflake-web-console")- : $t("instance.external-link")- }}- </span>- <button- class="ml-1 btn-icon"- :disabled="instanceLink.trim().length === 0"- @click.prevent="window.open(urlfy(instanceLink), '_blank')"- >- <heroicons-outline:external-link class="w-4 h-4" />- </button>- </label>- <template v-if="basicInfo.engine === Engine.SNOWFLAKE">- <input- id="external-link"- required- name="external-link"- type="text"- class="textfield mt-1 w-full"- disabled="true"- :value="instanceLink"+ <div class="sm:col-span-3 sm:col-start-1">+ <template v-if="basicInfo.engine !== Engine.SPANNER">+ <label for="host" class="textlabel block">+ <template v-if="basicInfo.engine === Engine.SNOWFLAKE">+ {{ $t("instance.account-name") }}+ <span class="text-red-600 mr-2">*</span>+ </template>+ <template v-else>+ {{ $t("instance.host-or-socket") }}+ <span class="text-red-600 mr-2">*</span>+ </template>+ </label>+ <input+ id="host"+ v-model="adminDataSource.host"+ required+ type="text"+ name="host"+ :placeholder="+ basicInfo.engine === Engine.SNOWFLAKE+ ? $t('instance.your-snowflake-account-name')+ : $t('instance.sentence.host.snowflake')+ "+ class="textfield mt-1 w-full"+ :disabled="!allowEdit"+ />+ <div+ v-if="basicInfo.engine === Engine.SNOWFLAKE"+ class="mt-2 textinfolabel"+ >+ {{ $t("instance.sentence.proxy.snowflake") }}+ </div>+ </template>+ <SpannerHostInput+ v-else+ v-model:host="adminDataSource.host"+ :allow-edit="allowEdit"/>- </template>- <template v-else>- <div class="mt-1 textinfolabel">- {{ $t("instance.sentence.console.snowflake") }}+ </div>++ <template v-if="basicInfo.engine !== Engine.SPANNER">+ <div class="sm:col-span-1">+ <label for="port" class="textlabel block">+ {{ $t("instance.port") }}+ </label>+ <input+ id="port"+ type="text"+ name="port"+ class="textfield mt-1 w-full"+ :value="adminDataSource.port"+ :placeholder="defaultPort"+ :disabled="!allowEdit || !allowEditPort"+ @wheel="(e: WheelEvent) => (e.target as HTMLInputElement).blur()"+ @input="adminDataSource.port = trimInputValue($event.target)"+ /></div>- <input- id="external-link"- v-model="basicInfo.externalLink"- required- name="external-link"- type="text"- :disabled="!allowEdit"- class="textfield mt-1 w-full"- :placeholder="snowflakeExtraLinkPlaceHolder"- /></template>++ <div+ v-if="basicInfo.engine === Engine.MONGODB"+ class="sm:col-span-4 sm:col-start-1"+ >+ <label+ for="connectionStringSchema"+ class="textlabel flex flex-row items-center"+ >+ {{ $t("data-source.connection-string-schema") }}+ </label>+ <label+ v-for="type in mongodbConnectionStringSchemaList"+ :key="type"+ class="radio h-7"+ >+ <input+ type="radio"+ class="btn"+ name="connectionStringSchema"+ :value="type"+ :checked="type === currentMongoDBConnectionSchema"+ @change="handleMongodbConnectionStringSchemaChange"+ />+ <span class="label">+ {{ type }}+ </span>+ </label>+ </div>++ <!--Do not show external link on create to reduce cognitive load-->+ <div v-if="!isCreating" class="sm:col-span-3 sm:col-start-1">+ <label for="external-link" class="textlabel inline-flex">+ <span class>+ {{+ basicInfo.engine === Engine.SNOWFLAKE+ ? $t("instance.snowflake-web-console")+ : $t("instance.external-link")+ }}+ </span>+ <button+ class="ml-1 btn-icon"+ :disabled="instanceLink.trim().length === 0"+ @click.prevent="window.open(urlfy(instanceLink), '_blank')"+ >+ <heroicons-outline:external-link class="w-4 h-4" />+ </button>+ </label>+ <template v-if="basicInfo.engine === Engine.SNOWFLAKE">+ <input+ id="external-link"+ required+ name="external-link"+ type="text"+ class="textfield mt-1 w-full"+ disabled="true"+ :value="instanceLink"+ />+ </template>+ <template v-else>+ <div class="mt-1 textinfolabel">+ {{ $t("instance.sentence.console.snowflake") }}+ </div>+ <input+ id="external-link"+ v-model="basicInfo.externalLink"+ required+ name="external-link"+ type="text"+ :disabled="!allowEdit"+ class="textfield mt-1 w-full"+ :placeholder="snowflakeExtraLinkPlaceHolder"+ />+ </template>+ </div></div>- </div>- <!-- Connection Info -->- <p class="mt-6 pt-4 w-full text-lg leading-6 font-medium text-gray-900">- {{ $t("instance.connection-info") }}- </p>-- <div- v-if="!isCreating && !hasReadOnlyDataSource && allowEdit"- class="mt-2 flex flex-row justify-start items-center bg-yellow-50 border-none rounded-lg p-2 px-3"- >- <heroicons-outline:exclamation- class="h-6 w-6 text-yellow-400 flex-shrink-0 mr-1"- />- <span class="text-yellow-800 text-sm">- {{ $t("instance.no-read-only-data-source-warn") }}- </span>- <button- type="button"- class="btn-normal ml-4 text-sm"- @click.prevent="handleCreateRODataSource"+ <!-- Connection Info -->+ <p class="mt-6 pt-4 w-full text-lg leading-6 font-medium text-gray-900">+ {{ $t("instance.connection-info") }}+ </p>++ <div+ v-if="!isCreating && !hasReadOnlyDataSource && allowEdit"+ class="mt-2 flex flex-row justify-start items-center bg-yellow-50 border-none rounded-lg p-2 px-3">- {{ $t("common.create") }}- </button>- </div>+ <heroicons-outline:exclamation+ class="h-6 w-6 text-yellow-400 flex-shrink-0 mr-1"+ />+ <span class="text-yellow-800 text-sm">+ {{ $t("instance.no-read-only-data-source-warn") }}+ </span>+ <button+ type="button"+ class="btn-normal ml-4 text-sm"+ @click.prevent="handleCreateRODataSource"+ >+ {{ $t("common.create") }}+ </button>+ </div>- <div- class="mt-2 grid grid-cols-1 gap-y-2 gap-x-4 border-none sm:grid-cols-3"- >- <NTabs- v-if="!isCreating"- v-model:value="state.currentDataSourceType"- class="sm:col-span-3"- type="line"+ <div+ class="mt-2 grid grid-cols-1 gap-y-2 gap-x-4 border-none sm:grid-cols-3">- <NTab :name="DataSourceType.ADMIN">- {{ $t("common.admin") }}- </NTab>- <NTab- :name="DataSourceType.READ_ONLY"- class="relative"- :disabled="!hasReadOnlyDataSource"+ <NTabs+ v-if="!isCreating"+ v-model:value="state.currentDataSourceType"+ class="sm:col-span-3"+ type="line">- <span>{{ $t("common.read-only") }}</span>- <BBButtonConfirm- v-if="hasReadOnlyDataSource"- :style="'DELETE'"- class="absolute left-full ml-1"- :require-confirm="!readonlyDataSource?.pendingCreate"- :ok-text="$t('common.delete')"- :confirm-title="- $t('data-source.delete-read-only-data-source') + '?'- "- @confirm="handleDeleteRODataSource"+ <NTab :name="DataSourceType.ADMIN">+ {{ $t("common.admin") }}+ </NTab>+ <NTab+ :name="DataSourceType.READ_ONLY"+ class="relative"+ :disabled="!hasReadOnlyDataSource"+ >+ <span>{{ $t("common.read-only") }}</span>+ <BBButtonConfirm+ v-if="hasReadOnlyDataSource"+ :style="'DELETE'"+ class="absolute left-full ml-1"+ :require-confirm="!readonlyDataSource?.pendingCreate"+ :ok-text="$t('common.delete')"+ :confirm-title="+ $t('data-source.delete-read-only-data-source') + '?'+ "+ @confirm="handleDeleteRODataSource"+ />+ </NTab>+ </NTabs>++ <template v-if="basicInfo.engine !== Engine.SPANNER">+ <CreateDataSourceExample+ class-name="sm:col-span-3 border-none mt-2"+ :create-instance-flag="isCreating"+ :engine="basicInfo.engine"+ :data-source-type="state.currentDataSourceType"/>- </NTab>- </NTabs>-- <template v-if="basicInfo.engine !== Engine.SPANNER">- <CreateDataSourceExample- class-name="sm:col-span-3 border-none mt-2"- :create-instance-flag="isCreating"- :engine="basicInfo.engine"- :data-source-type="state.currentDataSourceType"- />- <div class="mt-2 sm:col-span-1 sm:col-start-1">- <label for="username" class="textlabel block">- {{ $t("common.username") }}- </label>- <!-- For mysql, username can be empty indicating anonymous user.+ <div class="mt-2 sm:col-span-1 sm:col-start-1">+ <label for="username" class="textlabel block">+ {{ $t("common.username") }}+ </label>+ <!-- For mysql, username can be empty indicating anonymous user.But it's a very bad practice to use anonymous user for admin operation,thus we make it REQUIRED here.-->- <input- id="username"- v-model="currentDataSource.username"- name="username"- type="text"- class="textfield mt-1 w-full"- :disabled="!allowEdit"- :placeholder="- basicInfo.engine === Engine.CLICKHOUSE- ? $t('common.default')- : ''- "- />- </div>- <div class="mt-2 sm:col-span-1 sm:col-start-1">- <div class="flex flex-row items-center space-x-2">- <label for="password" class="textlabel block">- {{ $t("common.password") }}- </label>- <BBCheckbox- v-if="!isCreating && allowUsingEmptyPassword"- :title="$t('common.empty')"- :value="currentDataSource.useEmptyPassword"+ <input+ id="username"+ v-model="currentDataSource.username"+ name="username"+ type="text"+ class="textfield mt-1 w-full":disabled="!allowEdit"- @toggle="toggleUseEmptyPassword"+ :placeholder="+ basicInfo.engine === Engine.CLICKHOUSE+ ? $t('common.default')+ : ''+ "/></div>- <input- id="password"- name="password"- type="text"- class="textfield mt-1 w-full"- autocomplete="off"- :placeholder="- currentDataSource.useEmptyPassword- ? $t('instance.no-password')- : $t('instance.password-write-only')- "- :disabled="!allowEdit || currentDataSource.useEmptyPassword"- :value="- currentDataSource.useEmptyPassword- ? ''- : currentDataSource.updatedPassword- "- @input="- currentDataSource.updatedPassword = trimInputValue(- $event.target- )- "- />- </div>- </template>- <SpannerCredentialInput- v-else- v-model:value="currentDataSource.updatedPassword"- :write-only="!isCreating"- class="mt-2 sm:col-span-3 sm:col-start-1"- />-- <template v-if="basicInfo.engine === Engine.ORACLE">- <OracleSIDAndServiceNameInput- v-model:sid="currentDataSource.sid"- v-model:service-name="currentDataSource.serviceName"- :allow-edit="allowEdit"+ <div class="mt-2 sm:col-span-1 sm:col-start-1">+ <div class="flex flex-row items-center space-x-2">+ <label for="password" class="textlabel block">+ {{ $t("common.password") }}+ </label>+ <BBCheckbox+ v-if="!isCreating && allowUsingEmptyPassword"+ :title="$t('common.empty')"+ :value="currentDataSource.useEmptyPassword"+ :disabled="!allowEdit"+ @toggle="toggleUseEmptyPassword"+ />+ </div>+ <input+ id="password"+ name="password"+ type="text"+ class="textfield mt-1 w-full"+ autocomplete="off"+ :placeholder="+ currentDataSource.useEmptyPassword+ ? $t('instance.no-password')+ : $t('instance.password-write-only')+ "+ :disabled="!allowEdit || currentDataSource.useEmptyPassword"+ :value="+ currentDataSource.useEmptyPassword+ ? ''+ : currentDataSource.updatedPassword+ "+ @input="+ currentDataSource.updatedPassword = trimInputValue(+ $event.target+ )+ "+ />+ </div>+ </template>+ <SpannerCredentialInput+ v-else+ v-model:value="currentDataSource.updatedPassword"+ :write-only="!isCreating"+ class="mt-2 sm:col-span-3 sm:col-start-1"/>- </template>- <template v-if="showAuthenticationDatabase">- <div class="sm:col-span-1 sm:col-start-1">- <div class="flex flex-row items-center space-x-2">- <label for="authenticationDatabase" class="textlabel block">- {{ $t("instance.authentication-database") }}- </label>- </div>- <input- id="authenticationDatabase"- name="authenticationDatabase"- type="text"- class="textfield mt-1 w-full"- autocomplete="off"- placeholder="admin"- :value="currentDataSource.authenticationDatabase"- @input="- currentDataSource.authenticationDatabase = trimInputValue(- $event.target- )- "+ <template v-if="basicInfo.engine === Engine.ORACLE">+ <OracleSIDAndServiceNameInput+ v-model:sid="currentDataSource.sid"+ v-model:service-name="currentDataSource.serviceName"+ :allow-edit="allowEdit"/>- </div>- </template>+ </template>- <template- v-if="- state.currentDataSourceType === DataSourceType.READ_ONLY &&- (hasReadonlyReplicaHost || hasReadonlyReplicaPort)- "- >- <div- v-if="hasReadonlyReplicaHost"- class="mt-2 sm:col-span-1 sm:col-start-1"- >- <div class="flex flex-row items-center space-x-2">- <label for="host" class="textlabel block">- {{ $t("data-source.read-replica-host") }}- </label>+ <template v-if="showAuthenticationDatabase">+ <div class="sm:col-span-1 sm:col-start-1">+ <div class="flex flex-row items-center space-x-2">+ <label for="authenticationDatabase" class="textlabel block">+ {{ $t("instance.authentication-database") }}+ </label>+ </div>+ <input+ id="authenticationDatabase"+ name="authenticationDatabase"+ type="text"+ class="textfield mt-1 w-full"+ autocomplete="off"+ placeholder="admin"+ :value="currentDataSource.authenticationDatabase"+ @input="+ currentDataSource.authenticationDatabase = trimInputValue(+ $event.target+ )+ "+ /></div>- <input- id="host"- name="host"- type="text"- class="textfield mt-1 w-full"- autocomplete="off"- :value="currentDataSource.host"- @input="handleCurrentDataSourceHostInput"- />- </div>+ </template>- <div- v-if="hasReadonlyReplicaPort"- class="mt-2 sm:col-span-1 sm:col-start-1"+ <template+ v-if="+ state.currentDataSourceType === DataSourceType.READ_ONLY &&+ (hasReadonlyReplicaHost || hasReadonlyReplicaPort)+ ">- <div class="flex flex-row items-center space-x-2">- <label for="port" class="textlabel block">- {{ $t("data-source.read-replica-port") }}- </label>+ <div+ v-if="hasReadonlyReplicaHost"+ class="mt-2 sm:col-span-1 sm:col-start-1"+ >+ <div class="flex flex-row items-center space-x-2">+ <label for="host" class="textlabel block">+ {{ $t("data-source.read-replica-host") }}+ </label>+ </div>+ <input+ id="host"+ name="host"+ type="text"+ class="textfield mt-1 w-full"+ autocomplete="off"+ :value="currentDataSource.host"+ @input="handleCurrentDataSourceHostInput"+ /></div>++ <div+ v-if="hasReadonlyReplicaPort"+ class="mt-2 sm:col-span-1 sm:col-start-1"+ >+ <div class="flex flex-row items-center space-x-2">+ <label for="port" class="textlabel block">+ {{ $t("data-source.read-replica-port") }}+ </label>+ </div>+ <input+ id="port"+ name="port"+ type="text"+ class="textfield mt-1 w-full"+ autocomplete="off"+ :value="currentDataSource.port"+ @input="handleCurrentDataSourcePortInput"+ />+ </div>+ </template>++ <div v-if="showDatabase" class="mt-2 sm:col-span-1 sm:col-start-1">+ <label for="database" class="textlabel block">+ {{ $t("common.database") }}+ </label><input- id="port"- name="port"+ id="database"+ v-model="currentDataSource.database"+ name="database"type="text"class="textfield mt-1 w-full"- autocomplete="off"- :value="currentDataSource.port"- @input="handleCurrentDataSourcePortInput"+ :disabled="!allowEdit"+ :placeholder="$t('common.database')"/></div>- </template>-- <div v-if="showDatabase" class="mt-2 sm:col-span-1 sm:col-start-1">- <label for="database" class="textlabel block">- {{ $t("common.database") }}- </label>- <input- id="database"- v-model="currentDataSource.database"- name="database"- type="text"- class="textfield mt-1 w-full"- :disabled="!allowEdit"- :placeholder="$t('common.database')"- />- </div>- <div v-if="showSSL" class="mt-2 sm:col-span-3 sm:col-start-1">- <div class="flex flex-row items-center">- <label for="ssl" class="textlabel block">- {{ $t("data-source.ssl-connection") }}- </label>- </div>- <template v-if="currentDataSource.pendingCreate">- <SslCertificateForm- :value="currentDataSource"- @change="handleCurrentDataSourceSslChange"- />- </template>- <template v-else>- <template v-if="currentDataSource.updateSsl">+ <div v-if="showSSL" class="mt-2 sm:col-span-3 sm:col-start-1">+ <div class="flex flex-row items-center">+ <label for="ssl" class="textlabel block">+ {{ $t("data-source.ssl-connection") }}+ </label>+ </div>+ <template v-if="currentDataSource.pendingCreate"><SslCertificateForm:value="currentDataSource"@change="handleCurrentDataSourceSslChange"/></template><template v-else>- <button- class="btn-normal mt-2"- :disabled="!allowEdit"- @click.prevent="handleEditSsl"- >- {{ $t("common.edit") }} - {{ $t("common.write-only") }}- </button>+ <template v-if="currentDataSource.updateSsl">+ <SslCertificateForm+ :value="currentDataSource"+ @change="handleCurrentDataSourceSslChange"+ />+ </template>+ <template v-else>+ <button+ class="btn-normal mt-2"+ :disabled="!allowEdit"+ @click.prevent="handleEditSsl"+ >+ {{ $t("common.edit") }} - {{ $t("common.write-only") }}+ </button>+ </template></template>- </template>- </div>-- <div v-if="showSSH" class="mt-2 sm:col-span-3 sm:col-start-1">- <div class="flex flex-row items-center gap-x-1">- <label for="ssh" class="textlabel block">- {{ $t("data-source.ssh-connection") }}- </label>- <FeatureBadge- feature="bb.feature.instance-ssh-connection"- class="text-accent"- /></div>- <template v-if="currentDataSource.pendingCreate">- <SshConnectionForm- :value="currentDataSource"- @change="handleCurrentDataSourceSshChange"- />- </template>- <template v-else>- <template v-if="currentDataSource.updateSsh">++ <div v-if="showSSH" class="mt-2 sm:col-span-3 sm:col-start-1">+ <div class="flex flex-row items-center gap-x-1">+ <label for="ssh" class="textlabel block">+ {{ $t("data-source.ssh-connection") }}+ </label>+ <FeatureBadge+ feature="bb.feature.instance-ssh-connection"+ class="text-accent"+ />+ </div>+ <template v-if="currentDataSource.pendingCreate"><SshConnectionForm:value="currentDataSource"@change="handleCurrentDataSourceSshChange"/></template><template v-else>- <button- class="btn-normal mt-2"- :disabled="!allowEdit"- @click.prevent="handleEditSsh"- >- {{ $t("common.edit") }} - {{ $t("common.write-only") }}- </button>+ <template v-if="currentDataSource.updateSsh">+ <SshConnectionForm+ :value="currentDataSource"+ @change="handleCurrentDataSourceSshChange"+ />+ </template>+ <template v-else>+ <button+ class="btn-normal mt-2"+ :disabled="!allowEdit"+ @click.prevent="handleEditSsh"+ >+ {{ $t("common.edit") }} - {{ $t("common.write-only") }}+ </button>+ </template></template>- </template>+ </div></div>- </div>- <BBAttention- v-if="outboundIpList && actuatorStore.isSaaSMode"- class="my-5 border-none"- :style="'INFO'"- :title="$t('instance.sentence.outbound-ip-list')"- :description="outboundIpList"- />+ <BBAttention+ v-if="outboundIpList && actuatorStore.isSaaSMode"+ class="my-5 border-none"+ :style="'INFO'"+ :title="$t('instance.sentence.outbound-ip-list')"+ :description="outboundIpList"+ />- <div class="mt-6 pt-0 border-none">- <div class="flex flex-row space-x-2">- <button- type="button"- class="btn-normal whitespace-nowrap flex items-center gap-x-1"- :disabled="!allowCreate || state.isRequesting || !allowEdit"- @click.prevent="testConnection(false /* !silent */)"- >- <BBSpin v-if="state.isTestingConnection" />- <span>{{ $t("instance.test-connection") }}</span>- </button>+ <div class="mt-6 pt-0 border-none">+ <div class="flex flex-row space-x-2">+ <button+ type="button"+ class="btn-normal whitespace-nowrap flex items-center gap-x-1"+ :disabled="!allowCreate || state.isRequesting || !allowEdit"+ @click.prevent="testConnection(false /* !silent */)"+ >+ <BBSpin v-if="state.isTestingConnection" />+ <span>{{ $t("instance.test-connection") }}</span>+ </button>+ </div></div></div>- </div>- <!-- Action Button Group -->- <div class="pt-4">- <div class="w-full flex justify-between items-center">- <div class="w-full flex justify-end items-center gap-x-4">- <template v-if="isCreating">- <NButton- :disabled="state.isRequesting || state.isTestingConnection"- @click.prevent="cancel"- >- {{ $t("common.cancel") }}- </NButton>- <NButton- :disabled="- !allowCreate || state.isRequesting || state.isTestingConnection- "- :loading="state.isRequesting"- type="primary"- @click.prevent="tryCreate"- >- {{ $t("common.create") }}- </NButton>- </template>- <template v-else>+ <!-- Action Button Group -->+ <div v-if="!drawer" class="pt-4">+ <div class="w-full flex justify-between items-center">+ <div class="w-full flex justify-end items-center gap-x-4"><NButtonv-if="allowEdit":disabled="!allowUpdate || state.isRequesting"@@ -576,11 +550,34 @@>{{ $t("common.update") }}</NButton>- </template>+ </div></div></div></div>- </div>++ <template v-if="drawer" #footer>+ <div class="w-full flex justify-between items-center">+ <div class="w-full flex justify-end items-center gap-x-3">+ <NButton+ :disabled="state.isRequesting || state.isTestingConnection"+ @click.prevent="cancel"+ >+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ :disabled="+ !allowCreate || state.isRequesting || state.isTestingConnection+ "+ :loading="state.isRequesting"+ type="primary"+ @click.prevent="tryCreate"+ >+ {{ $t("common.create") }}+ </NButton>+ </div>+ </div>+ </template>+ </component><FeatureModalv-if="state.showFeatureModal"@@ -649,7 +646,7 @@ import SpannerHostInput from "./SpannerHostInput.vue";import SpannerCredentialInput from "./SpannerCredentialInput.vue";import OracleSIDAndServiceNameInput from "./OracleSIDAndServiceNameInput.vue";import { instanceNamePrefix } from "@/store/modules/v1/common";-import { InstanceV1EngineIcon } from "@/components/v2";+import { DrawerContent, InstanceV1EngineIcon } from "@/components/v2";import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";import {DataSource,@@ -664,7 +661,7 @@ const props = defineProps({type: Object as PropType<Instance>,default: undefined,},- modal: {+ drawer: {type: Boolean,default: false,},@@ -672,6 +669,15 @@ const props = defineProps({const emit = defineEmits(["dismiss"]);+const bindings = computed(() => {+ if (props.drawer) {+ return {+ title: t("quick-action.add-instance"),+ };+ }+ return {};+});+const cancel = () => {emit("dismiss");};diff --git a/frontend/src/components/Project/ProjectCreatePanel.vue b/frontend/src/components/Project/ProjectCreatePanel.vuenew file mode 100644index 0000000000..fd0afe6f86--- /dev/null+++ b/frontend/src/components/Project/ProjectCreatePanel.vue@@ -0,0 +1,251 @@+<template>+ <DrawerContent :title="$t('quick-action.create-project')">+ <form class="w-96 space-y-6 divide-y divide-block-border">+ <div class="grid gap-y-6 gap-x-4 grid-cols-1">+ <div class="col-span-1">+ <label+ for="name"+ class="text-base leading-6 font-medium text-control"+ >+ {{ $t("project.create-modal.project-name") }}+ <span class="text-red-600">*</span>+ </label>+ <BBTextField+ class="mt-4 w-full"+ :required="true"+ :placeholder="'Project name'"+ :value="state.project.title"+ @input="+ state.project.title = ($event.target as HTMLInputElement).value+ "+ />+ </div>+ <div class="-mt-2">+ <ResourceIdField+ ref="resourceIdField"+ resource-type="project"+ :value="state.resourceId"+ :resource-title="state.project.title"+ :validate="validateResourceId"+ @update:value="state.resourceId = $event"+ />+ </div>+ <div class="col-span-1">+ <label+ for="name"+ class="text-base leading-6 font-medium text-control"+ >+ {{ $t("project.create-modal.key") }}+ <span class="text-red-600">*</span>+ <span class="ml-1 text-sm font-normal">+ {{ $t("project.create-modal.key-hint") }}+ </span>+ </label>+ <BBTextField+ class="mt-4 w-full uppercase"+ :required="true"+ :value="state.project.key"+ @input="+ state.project.key = ($event.target as HTMLInputElement).value+ "+ />+ </div>+ <div class="col-span-1">+ <div for="name" class="text-base leading-6 font-medium text-control">+ {{ $t("common.mode") }}+ <span class="text-red-600">*</span>+ </div>+ <div class="mt-2 textlabel">+ <div class="radio-set-row">+ <div class="radio">+ <input+ v-model="state.project.tenantMode"+ tabindex="-1"+ type="radio"+ class="btn"+ :value="TenantMode.TENANT_MODE_DISABLED"+ />+ <label class="label">{{ $t("project.mode.standard") }}</label>+ </div>+ <div class="radio">+ <input+ v-model="state.project.tenantMode"+ tabindex="-1"+ type="radio"+ class="btn"+ :value="TenantMode.TENANT_MODE_ENABLED"+ />+ <label class="label">{{ $t("project.mode.tenant") }}</label>+ <FeatureBadge+ feature="bb.feature.multi-tenancy"+ class="text-accent"+ />+ </div>+ </div>+ </div>+ </div>+ </div>+ </form>++ <div+ v-if="state.isCreating"+ class="absolute inset-0 bg-white/50 flex justify-center items-center"+ >+ <BBSpin />+ </div>++ <template #footer>+ <div class="flex justify-end items-center gap-x-3">+ <NButton @click.prevent="cancel">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ type="primary"+ :disabled="!allowCreate"+ @click.prevent="create"+ >+ {{ $t("common.create") }}+ </NButton>+ </div>+ </template>+ </DrawerContent>++ <FeatureModal+ v-if="state.showFeatureModal"+ feature="bb.feature.multi-tenancy"+ @cancel="state.showFeatureModal = false"+ />+</template>++<script lang="ts" setup>+import { computed, reactive, ref } from "vue";+import { useRouter } from "vue-router";+import { isEmpty } from "lodash-es";+import { useI18n } from "vue-i18n";+import { NButton } from "naive-ui";+import { useEventListener } from "@vueuse/core";+import { Status } from "nice-grpc-common";++import { projectV1Slug, randomString } from "@/utils";+import { ResourceId, ValidatedMessage, emptyProject } from "@/types";+import { hasFeature, pushNotification, useUIStateStore } from "@/store";+import { useProjectV1Store } from "@/store/modules/v1/project";+import { projectNamePrefix } from "@/store/modules/v1/common";+import { getErrorCode } from "@/utils/grpcweb";+import { DrawerContent } from "@/components/v2";+import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";+import { Project, TenantMode } from "@/types/proto/v1/project_service";++interface LocalState {+ project: Project;+ resourceId: string;+ showFeatureModal: boolean;+ isCreating: boolean;+}++const emit = defineEmits<{+ (event: "dismiss"): void;+}>();++const router = useRouter();+const { t } = useI18n();+const projectV1Store = useProjectV1Store();++const state = reactive<LocalState>({+ project: {+ ...emptyProject(),+ title: "New Project",+ key: randomString(3).toUpperCase(),+ },+ resourceId: "",+ showFeatureModal: false,+ isCreating: false,+});+const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();++useEventListener("keydown", (e) => {+ if (e.code == "Escape") {+ emit("dismiss");+ }+});++const validateResourceId = async (+ resourceId: ResourceId+): Promise<ValidatedMessage[]> => {+ if (!resourceId) {+ return [];+ }++ try {+ const project = await projectV1Store.getOrFetchProjectByName(+ projectNamePrefix + resourceId+ );+ if (project) {+ return [+ {+ type: "error",+ message: t("resource-id.validation.duplicated", {+ resource: t("resource.project"),+ }),+ },+ ];+ }+ } catch (error) {+ if (getErrorCode(error) !== Status.NOT_FOUND) {+ throw error;+ }+ }++ return [];+};++const allowCreate = computed(() => {+ if (isEmpty(state.project.title)) return false;+ if (!resourceIdField.value?.isValidated) return false;+ return true;+});++const create = async () => {+ if (+ state.project.tenantMode === TenantMode.TENANT_MODE_ENABLED &&+ !hasFeature("bb.feature.multi-tenancy")+ ) {+ state.showFeatureModal = true;+ return;+ }+ if (!allowCreate.value) {+ return;+ }++ try {+ state.isCreating = true;+ const createdProject = await projectV1Store.createProject(+ state.project,+ state.resourceId+ );+ useUIStateStore().saveIntroStateByKey({+ key: "project.visit",+ newState: true,+ });+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("project.create-modal.success-prompt", {+ name: createdProject.title,+ }),+ });+ const url = {+ path: `/project/${projectV1Slug(createdProject)}`,+ hash: "",+ };+ router.push(url);+ emit("dismiss");+ } finally {+ state.isCreating = false;+ }+};++const cancel = () => {+ emit("dismiss");+};+</script>diff --git a/frontend/src/components/ProjectCreate.vue b/frontend/src/components/ProjectCreate.vuedeleted file mode 100644index 7a02e0e1f2..0000000000--- a/frontend/src/components/ProjectCreate.vue+++ /dev/null@@ -1,241 +0,0 @@-<template>- <form class="w-96 py-2 space-y-6 divide-y divide-block-border">- <div class="grid gap-y-6 gap-x-4 grid-cols-1">- <div class="col-span-1">- <label for="name" class="text-base leading-6 font-medium text-control">- {{ $t("project.create-modal.project-name") }}- <span class="text-red-600">*</span>- </label>- <BBTextField- class="mt-4 w-full"- :required="true"- :placeholder="'Project name'"- :value="state.project.title"- @input="- state.project.title = ($event.target as HTMLInputElement).value- "- />- </div>- <div class="-mt-2">- <ResourceIdField- ref="resourceIdField"- resource-type="project"- :value="state.resourceId"- :resource-title="state.project.title"- :validate="validateResourceId"- @update:value="state.resourceId = $event"- />- </div>- <div class="col-span-1">- <label for="name" class="text-base leading-6 font-medium text-control">- {{ $t("project.create-modal.key") }}- <span class="text-red-600">*</span>- <span class="ml-1 text-sm font-normal">- {{ $t("project.create-modal.key-hint") }}- </span>- </label>- <BBTextField- class="mt-4 w-full uppercase"- :required="true"- :value="state.project.key"- @input="state.project.key = ($event.target as HTMLInputElement).value"- />- </div>- <div class="col-span-1">- <div for="name" class="text-base leading-6 font-medium text-control">- {{ $t("common.mode") }}- <span class="text-red-600">*</span>- </div>- <div class="mt-2 textlabel">- <div class="radio-set-row">- <div class="radio">- <input- v-model="state.project.tenantMode"- tabindex="-1"- type="radio"- class="btn"- :value="TenantMode.TENANT_MODE_DISABLED"- />- <label class="label">{{ $t("project.mode.standard") }}</label>- </div>- <div class="radio">- <input- v-model="state.project.tenantMode"- tabindex="-1"- type="radio"- class="btn"- :value="TenantMode.TENANT_MODE_ENABLED"- />- <label class="label">{{ $t("project.mode.tenant") }}</label>- <FeatureBadge- feature="bb.feature.multi-tenancy"- class="text-accent"- />- </div>- </div>- </div>- </div>- </div>- <!-- Create button group -->- <div class="pt-4 flex justify-end">- <button- type="button"- class="btn-normal py-2 px-4"- @click.prevent="cancel"- >- {{ $t("common.cancel") }}- </button>- <button- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="!allowCreate"- @click.prevent="create"- >- {{ $t("common.create") }}- </button>- </div>- </form>-- <div- v-if="state.isCreating"- class="absolute inset-0 bg-white/50 flex justify-center items-center"- >- <BBSpin />- </div>-- <FeatureModal- v-if="state.showFeatureModal"- feature="bb.feature.multi-tenancy"- @cancel="state.showFeatureModal = false"- />-</template>--<script lang="ts" setup>-import { computed, reactive, ref } from "vue";-import { useRouter } from "vue-router";-import { isEmpty } from "lodash-es";-import { useI18n } from "vue-i18n";-import { useEventListener } from "@vueuse/core";-import { Status } from "nice-grpc-common";--import { projectV1Slug, randomString } from "@/utils";-import { ResourceId, ValidatedMessage, emptyProject } from "@/types";-import { hasFeature, pushNotification, useUIStateStore } from "@/store";-import { useProjectV1Store } from "@/store/modules/v1/project";-import { projectNamePrefix } from "@/store/modules/v1/common";-import { getErrorCode } from "@/utils/grpcweb";-import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";-import { Project, TenantMode } from "@/types/proto/v1/project_service";--interface LocalState {- project: Project;- resourceId: string;- showFeatureModal: boolean;- isCreating: boolean;-}--const emit = defineEmits<{- (event: "dismiss"): void;-}>();--const router = useRouter();-const { t } = useI18n();-const projectV1Store = useProjectV1Store();--const state = reactive<LocalState>({- project: {- ...emptyProject(),- title: "New Project",- key: randomString(3).toUpperCase(),- },- resourceId: "",- showFeatureModal: false,- isCreating: false,-});-const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();--useEventListener("keydown", (e) => {- if (e.code == "Escape") {- emit("dismiss");- }-});--const validateResourceId = async (- resourceId: ResourceId-): Promise<ValidatedMessage[]> => {- if (!resourceId) {- return [];- }-- try {- const project = await projectV1Store.getOrFetchProjectByName(- projectNamePrefix + resourceId- );- if (project) {- return [- {- type: "error",- message: t("resource-id.validation.duplicated", {- resource: t("resource.project"),- }),- },- ];- }- } catch (error) {- if (getErrorCode(error) !== Status.NOT_FOUND) {- throw error;- }- }-- return [];-};--const allowCreate = computed(() => {- if (isEmpty(state.project.title)) return false;- if (!resourceIdField.value?.isValidated) return false;- return true;-});--const create = async () => {- if (- state.project.tenantMode === TenantMode.TENANT_MODE_ENABLED &&- !hasFeature("bb.feature.multi-tenancy")- ) {- state.showFeatureModal = true;- return;- }- if (!allowCreate.value) {- return;- }-- try {- state.isCreating = true;- const createdProject = await projectV1Store.createProject(- state.project,- state.resourceId- );- useUIStateStore().saveIntroStateByKey({- key: "project.visit",- newState: true,- });- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("project.create-modal.success-prompt", {- name: createdProject.title,- }),- });- const url = {- path: `/project/${projectV1Slug(createdProject)}`,- hash: "",- };- router.push(url);- emit("dismiss");- } finally {- state.isCreating = false;- }-};--const cancel = () => {- emit("dismiss");-};-</script>diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vueindex e4dd0fd800..b790182e59 100644--- a/frontend/src/components/QuickActionPanel.vue+++ b/frontend/src/components/QuickActionPanel.vue@@ -48,20 +48,6 @@</h3></div>- <div- v-if="quickAction === 'quickaction.bb.database.request'"- class="flex flex-col items-center w-24"- >- <button class="btn-icon-primary p-3" @click.prevent="requestDatabase">- <heroicons-outline:database class="w-5 h-5" />- </button>- <h3- class="flex-1 mt-1.5 text-center text-sm font-normal text-main tracking-tight"- >- {{ $t("quick-action.request-db") }}- </h3>- </div>-<divv-if="quickAction === 'quickaction.bb.database.schema.update'"class="flex flex-col items-center w-24"@@ -223,78 +209,55 @@</template></template></div>- <BBModal- v-if="state.showModal"- class="relative overflow-hidden"- :title="state.modalTitle"- :subtitle="state.modalSubtitle"- :data-label="`bb-${kebabCase(state.modalTitle)}-modal`"- @close="state.showModal = false"++ <Drawer+ :show="state.quickActionType !== undefined"+ @close="state.quickActionType = undefined">- <template v-if="state.quickActionType == 'quickaction.bb.project.create'">- <ProjectCreate @dismiss="state.showModal = false" />- </template>- <template- v-else-if="state.quickActionType == 'quickaction.bb.instance.create'"- >- <InstanceForm :modal="true" @dismiss="state.showModal = false" />- </template>- <template- v-else-if="- state.quickActionType == 'quickaction.bb.database.schema.update'+ <ProjectCreatePanel+ v-if="state.quickActionType === 'quickaction.bb.project.create'"+ @dismiss="state.quickActionType = undefined"+ />+ <InstanceForm+ v-if="state.quickActionType === 'quickaction.bb.instance.create'"+ :drawer="true"+ @dismiss="state.quickActionType = undefined"+ />+ <CreateDatabasePrepPanel+ v-if="state.quickActionType === 'quickaction.bb.database.create'"+ :project-id="projectId"+ @dismiss="state.quickActionType = undefined"+ />+ <AlterSchemaPrepForm+ v-if="state.quickActionType === 'quickaction.bb.database.schema.update'"+ :project-id="projectId"+ :type="'bb.issue.database.schema.update'"+ @dismiss="state.quickActionType = undefined"+ />+ <AlterSchemaPrepForm+ v-if="state.quickActionType === 'quickaction.bb.database.data.update'"+ :project-id="projectId"+ :type="'bb.issue.database.data.update'"+ @dismiss="state.quickActionType = undefined"+ />+ <TransferDatabaseForm+ v-if="+ projectId &&+ state.quickActionType === 'quickaction.bb.project.database.transfer'"- >- <AlterSchemaPrepForm- :project-id="projectId"- :type="'bb.issue.database.schema.update'"- @dismiss="state.showModal = false"- />- </template>- <template- v-else-if="state.quickActionType == 'quickaction.bb.database.data.update'"- >- <AlterSchemaPrepForm- :project-id="projectId"- :type="'bb.issue.database.data.update'"- @dismiss="state.showModal = false"- />- </template>- <template- v-else-if="state.quickActionType == 'quickaction.bb.database.create'"- >- <CreateDatabasePrepForm- :project-id="projectId"- @dismiss="state.showModal = false"- />- </template>- <template- v-else-if="state.quickActionType == 'quickaction.bb.database.request'"- >- <RequestDatabasePrepForm @dismiss="state.showModal = false" />- </template>- <template- v-else-if="- state.quickActionType == 'quickaction.bb.project.database.transfer'- "- >- <TransferDatabaseForm- v-if="projectId"- :project-id="projectId"- @dismiss="state.showModal = false"- />- </template>- <template- v-else-if="- state.quickActionType == 'quickaction.bb.project.database.transfer-out'+ :project-id="projectId"+ @dismiss="state.quickActionType = undefined"+ />+ <TransferOutDatabaseForm+ v-if="+ projectId &&+ state.quickActionType === 'quickaction.bb.project.database.transfer-out'"- >- <TransferOutDatabaseForm- v-if="projectId"- :project-id="projectId"- @dismiss="state.showModal = false"- />- </template>- </BBModal>+ :project-id="projectId"+ @dismiss="state.quickActionType = undefined"+ />+ </Drawer>+<FeatureModalv-if="state.showFeatureModal && state.featureName !== ''":feature="state.featureName"@@ -304,12 +267,12 @@<script lang="ts" setup>import { Action, defineAction, useRegisterActions } from "@bytebase/vue-kbar";-import { kebabCase } from "lodash-es";import { reactive, PropType, computed, watch } from "vue";import { useI18n } from "vue-i18n";import { useRoute, useRouter } from "vue-router";-import { QuickActionType } from "../types";-import { idFromSlug, isDev } from "../utils";++import { QuickActionType } from "@/types";+import { idFromSlug, isDev } from "@/utils";import {useCommandStore,useCurrentUserIamPolicy,@@ -318,21 +281,18 @@ import {useRouterStore,useSubscriptionV1Store,} from "@/store";-import ProjectCreate from "../components/ProjectCreate.vue";-import InstanceForm from "../components/InstanceForm/";-import AlterSchemaPrepForm from "./AlterSchemaPrepForm/";-import CreateDatabasePrepForm from "../components/CreateDatabasePrepForm.vue";-import RequestDatabasePrepForm from "../components/RequestDatabasePrepForm.vue";-import TransferDatabaseForm from "../components/TransferDatabaseForm.vue";-import TransferOutDatabaseForm from "../components/TransferOutDatabaseForm";+import { Drawer } from "@/components/v2";+import ProjectCreatePanel from "@/components/Project/ProjectCreatePanel.vue";+import InstanceForm from "@/components/InstanceForm/";+import AlterSchemaPrepForm from "@/components/AlterSchemaPrepForm/";+import { CreateDatabasePrepPanel } from "@/components/CreateDatabasePrepForm";+import TransferDatabaseForm from "@/components/TransferDatabaseForm.vue";+import TransferOutDatabaseForm from "@/components/TransferOutDatabaseForm";interface LocalState {- showModal: boolean;featureName: string;showFeatureModal: boolean;- modalTitle: string;- modalSubtitle: string;- quickActionType: QuickActionType;+ quickActionType: QuickActionType | undefined;}const props = defineProps({@@ -354,12 +314,9 @@ const hasCustomRoleFeature = computed(() => {});const state = reactive<LocalState>({- showModal: false,featureName: "",showFeatureModal: false,- modalTitle: "",- modalSubtitle: "",- quickActionType: "quickaction.bb.instance.create",+ quickActionType: undefined,});const projectId = computed((): string | undefined => {@@ -382,28 +339,19 @@ const shouldShowAlterDatabaseEntries = computed(() => {});watch(route, () => {- state.showModal = false;+ state.quickActionType = undefined;});const createProject = () => {- state.modalTitle = t("quick-action.create-project");- state.modalSubtitle = "";state.quickActionType = "quickaction.bb.project.create";- state.showModal = true;};const transferDatabase = () => {- state.modalTitle = t("quick-action.transfer-in-db-title");- state.modalSubtitle = "";state.quickActionType = "quickaction.bb.project.database.transfer";- state.showModal = true;};const transferOutDatabase = () => {- state.modalTitle = t("quick-action.transfer-out-db-title");- state.modalSubtitle = "";state.quickActionType = "quickaction.bb.project.database.transfer-out";- state.showModal = true;};const createInstance = () => {@@ -413,36 +361,19 @@ const createInstance = () => {state.showFeatureModal = true;return;}- state.modalTitle = t("quick-action.create-instance");- state.modalSubtitle = "";state.quickActionType = "quickaction.bb.instance.create";- state.showModal = true;};const alterSchema = () => {- state.modalTitle = t("database.alter-schema");state.quickActionType = "quickaction.bb.database.schema.update";- state.showModal = true;};const changeData = () => {- state.modalTitle = t("database.change-data");state.quickActionType = "quickaction.bb.database.data.update";- state.showModal = true;};const createDatabase = () => {- state.modalTitle = t("quick-action.create-db");- state.modalSubtitle = "";state.quickActionType = "quickaction.bb.database.create";- state.showModal = true;-};--const requestDatabase = () => {- state.modalTitle = "Request database";- state.modalSubtitle = "";- state.quickActionType = "quickaction.bb.database.request";- state.showModal = true;};const createEnvironment = () => {@@ -508,10 +439,6 @@ const QuickActionMap: Record<string, Partial<Action>> = {name: t("quick-action.new-db"),perform: () => createDatabase(),},- "quickaction.bb.database.request": {- name: t("quick-action.request-db"),- perform: () => requestDatabase(),- },"quickaction.bb.database.schema.update": {name: t("database.alter-schema"),perform: () => alterSchema(),diff --git a/frontend/src/components/RequestDatabasePrepForm.vue b/frontend/src/components/RequestDatabasePrepForm.vuedeleted file mode 100644index da492fc7db..0000000000--- a/frontend/src/components/RequestDatabasePrepForm.vue+++ /dev/null@@ -1,274 +0,0 @@-<template>- <form class="mx-4 space-y-6 divide-y divide-block-border">- <div class="grid gap-y-6 gap-x-4 grid-cols-2">- <div class="col-span-2 col-start-1 w-64">- <label for="project" class="textlabel">- Project <span style="color: red">*</span>- </label>- <ProjectSelect- id="project"- class="mt-1"- name="project"- :selected-id="state.projectId"- @select-project-id="- (projectId) => {- state.projectId = projectId;- }- "- />- </div>-- <div class="col-span-2 col-start-1 w-64">- <label for="environment" class="textlabel">- Environment <span style="color: red">*</span>- </label>- <EnvironmentSelect- id="environment"- class="mt-1 w-full"- name="environment"- :selected-id="state.environmentId"- @select-environment-id="- (environmentId) => {- state.environmentId = environmentId;- }- "- />- </div>-- <template v-if="state.environmentId">- <div class="col-span-2 col-start-1 w-64 space-y-2">- <div class="hidden radio-set-row justify-between">- <div class="radio">- <input- v-model="state.create"- name="Create new"- tabindex="-1"- type="radio"- class="btn"- value="ON"- />- <label class="label whitespace-nowrap">Create new</label>- </div>- <div class="radio">- <input- v-model="state.create"- name="Access existing"- tabindex="-1"- type="radio"- class="btn"- value="OFF"- />- <label class="label whitespace-nowrap">Access existing DB</label>- </div>- </div>-- <div class="space-y-1">- <label for="database" class="textlabel">- Database name <span style="color: red">*</span>- <span v-if="alreadyGranted" class="text-error">- Already granted!- </span>- </label>- <BBTextField- v-if="state.create == 'ON'"- type="text"- class="w-full text-sm"- :required="true"- :value="state.databaseName"- :placeholder="'New database name'"- @end-editing="(text: string) => (state.databaseName = text)"- @input="state.databaseName = $event.target.value"- />- <div v-else class="flex flex-row space-x-4">- <DatabaseSelect- :selected-id="state.databaseId"- :mode="'ENVIRONMENT'"- :environment-id="state.environmentId"- @select-database-id="- (databaseId) => {- state.databaseId = databaseId;- }- "- />- <BBSwitch- :label="'Read only'"- :value="state.readonly"- @toggle="- (on: boolean) => {- state.readonly = on;- }- "- />- </div>- </div>- </div>- </template>- </div>- <!-- Create button group -->- <div class="pt-4 flex justify-end">- <button- type="button"- class="btn-normal py-2 px-4"- @click.prevent="cancel"- >- Cancel- </button>- <button- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- :disabled="!allowRequest"- @click.prevent="request"- >- Request- </button>- </div>- </form>-</template>--<script lang="ts">-import {- computed,- reactive,- onMounted,- onUnmounted,- defineComponent,-} from "vue";-import { useRouter } from "vue-router";-import { isEmpty } from "lodash-es";--import ProjectSelect from "@/components/ProjectSelect.vue";-import DatabaseSelect from "@/components/DatabaseSelect.vue";-import EnvironmentSelect from "@/components/EnvironmentSelect.vue";-import { UNKNOWN_ID } from "@/types";-import { allowDatabaseV1Access } from "@/utils";-import {- useCurrentUserV1,- useEnvironmentV1Store,- useDatabaseV1Store,-} from "@/store";-import { DataSourceType } from "@/types/proto/v1/instance_service";--interface LocalState {- environmentId: string;- projectId: string;- // Radio button only accept string value- create: "ON" | "OFF";- databaseName: string;- databaseId: string;- readonly: boolean;-}--export default defineComponent({- name: "RequestDatabasePrepForm",- components: { ProjectSelect, DatabaseSelect, EnvironmentSelect },- emits: ["dismiss"],- setup(props, { emit }) {- const databaseStore = useDatabaseV1Store();- const router = useRouter();-- const currentUserV1 = useCurrentUserV1();-- const keyboardHandler = (e: KeyboardEvent) => {- if (e.code == "Escape") {- cancel();- }- };-- onMounted(() => {- document.addEventListener("keydown", keyboardHandler);- });-- onUnmounted(() => {- document.removeEventListener("keydown", keyboardHandler);- });-- const state = reactive<LocalState>({- environmentId: String(UNKNOWN_ID),- projectId: String(UNKNOWN_ID),- create: "ON",- databaseName: "",- databaseId: String(UNKNOWN_ID),- readonly: true,- });-- const alreadyGranted = computed(() => {- if (state.create == "ON") {- return false;- }-- if (!state.databaseId) {- return false;- }-- const database = databaseStore.getDatabaseByUID(state.databaseId);- return allowDatabaseV1Access(- database,- currentUserV1.value,- state.readonly ? DataSourceType.READ_ONLY : DataSourceType.ADMIN- );- });-- const allowRequest = computed(() => {- return (- state.environmentId !== String(UNKNOWN_ID) &&- state.projectId !== String(UNKNOWN_ID) &&- ((state.create == "ON" && !isEmpty(state.databaseName)) ||- (state.create == "OFF" && state.databaseId !== String(UNKNOWN_ID))) &&- !alreadyGranted.value- );- });-- const cancel = () => {- emit("dismiss");- };-- const request = () => {- emit("dismiss");-- const environment = useEnvironmentV1Store().getEnvironmentByUID(- state.environmentId- );- if (state.create == "ON") {- router.push({- name: "workspace.issue.detail",- params: {- issueSlug: "new",- },- query: {- template: "bb.issue.database.create",- name: `[${environment.title}] Request new database '${state.databaseName}'`,- environment: state.environmentId,- project: state.projectId,- databaseName: state.databaseName,- },- });- } else {- const database = databaseStore.getDatabaseByUID(state.databaseId);- router.push({- name: "workspace.issue.detail",- params: {- issueSlug: "new",- },- query: {- template: "bb.issue.database.grant",- name: `[${environment.title}] Request database '${- database.databaseName- }' ${state.readonly ? "Readonly access" : "Read & Write access"}`,- environment: state.environmentId,- project: state.projectId,- databaseList: state.databaseId,- readonly: state.readonly ? "true" : "false",- },- });- }- };-- return {- state,- alreadyGranted,- allowRequest,- cancel,- request,- };- },-});-</script>diff --git a/frontend/src/components/TransferDatabaseForm/TransferMultipleDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm/TransferMultipleDatabaseForm.vueindex c51889fe1c..52f9fe2acf 100644--- a/frontend/src/components/TransferDatabaseForm/TransferMultipleDatabaseForm.vue+++ b/frontend/src/components/TransferDatabaseForm/TransferMultipleDatabaseForm.vue@@ -1,147 +1,149 @@<template>- <div class="px-4 w-[60rem]">- <slot name="transfer-source-selector" />-- <NCollapse- class="overflow-y-auto"- style="max-height: calc(100vh - 380px)"- arrow-placement="left"- :default-expanded-names="environmentList.map((env) => env.uid)"+ <DrawerContent :title="$t('quick-action.transfer-in-db-title')">+ <div+ class="px-4 w-[calc(100vw-8rem)] lg:w-[60rem] max-w-[calc(100vw-8rem)]">- <NCollapseItem- v-for="{- environment,- databaseList: databaseListInEnvironment,- } in databaseListGroupByEnvironment"- :key="environment.uid"- :name="environment.uid"- >- <template #header>- <label class="flex items-center gap-x-2" @click.stop="">- <input- type="checkbox"- class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed focus:ring-accent ml-0.5"- v-bind="- getAllSelectionStateForEnvironment(- environment,- databaseListInEnvironment- )- "- @click.stop=""- @input="- toggleAllDatabasesSelectionForEnvironment(- environment,- databaseListInEnvironment,- ($event.target as HTMLInputElement).checked- )- "- />- <div>{{ environment.title }}</div>- <ProductionEnvironmentV1Icon :environment="environment" />- </label>- </template>+ <slot name="transfer-source-selector" />- <template #header-extra>- <div class="flex items-center text-xs text-gray-500 mr-2">- {{- $t(- "database.n-selected-m-in-total",- getSelectionStateSummaryForEnvironment(- environment,- databaseListInEnvironment- )- )- }}- </div>- </template>-- <BBGrid- class="relative bg-white border"- :column-list="gridColumnList"- :show-header="false"- :data-source="databaseListInEnvironment"- row-key="id"- @click-row="handleClickRow"+ <NCollapse+ arrow-placement="left"+ :default-expanded-names="environmentList.map((env) => env.uid)"+ >+ <NCollapseItem+ v-for="{+ environment,+ databaseList: databaseListInEnvironment,+ } in databaseListGroupByEnvironment"+ :key="environment.uid"+ :name="environment.uid">- <template #item="{ item: database }: { item: ComposedDatabase }">- <div class="bb-grid-cell gap-x-2 !pl-[23px]">+ <template #header>+ <label class="flex items-center gap-x-2" @click.stop=""><inputtype="checkbox"- class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed focus:ring-accent"- :checked="- isDatabaseSelectedForEnvironment(- database.uid,- environment.uid+ class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed focus:ring-accent ml-0.5"+ v-bind="+ getAllSelectionStateForEnvironment(+ environment,+ databaseListInEnvironment)"- @input="(e: any) => toggleDatabaseIdForEnvironment(database.uid, environment.uid, e.target.checked)"@click.stop=""+ @input="+ toggleAllDatabasesSelectionForEnvironment(+ environment,+ databaseListInEnvironment,+ ($event.target as HTMLInputElement).checked+ )+ "/>- <span- class="font-medium text-main"- :class="database.syncState !== State.ACTIVE && 'opacity-40'"- >{{ database.databaseName }}</span- >- </div>- <div v-if="showProjectColumn" class="bb-grid-cell">- {{ database.projectEntity.title }}- </div>- <div class="bb-grid-cell gap-x-1 textinfolabel justify-end">- <InstanceV1Name- :instance="database.instanceEntity"- :link="false"- />+ <div>{{ environment.title }}</div>+ <ProductionEnvironmentV1Icon :environment="environment" />+ </label>+ </template>++ <template #header-extra>+ <div class="flex items-center text-xs text-gray-500 mr-2">+ {{+ $t(+ "database.n-selected-m-in-total",+ getSelectionStateSummaryForEnvironment(+ environment,+ databaseListInEnvironment+ )+ )+ }}</div></template>- </BBGrid>- </NCollapseItem>- </NCollapse>- <!-- Update button group -->- <div class="mt-4 pt-4 border-t border-block-border flex justify-between">- <div>- <div- v-if="combinedSelectedDatabaseUidList.length > 0"- class="textinfolabel"- >- {{- $t("database.selected-n-databases", {- n: combinedSelectedDatabaseUidList.length,- })- }}+ <BBGrid+ class="relative bg-white border"+ :column-list="gridColumnList"+ :show-header="false"+ :data-source="databaseListInEnvironment"+ row-key="id"+ @click-row="handleClickRow"+ >+ <template #item="{ item: database }: { item: ComposedDatabase }">+ <div class="bb-grid-cell gap-x-2 !pl-[23px]">+ <input+ type="checkbox"+ class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed focus:ring-accent"+ :checked="+ isDatabaseSelectedForEnvironment(+ database.uid,+ environment.uid+ )+ "+ @input="(e: any) => toggleDatabaseIdForEnvironment(database.uid, environment.uid, e.target.checked)"+ @click.stop=""+ />+ <span+ class="font-medium text-main"+ :class="database.syncState !== State.ACTIVE && 'opacity-40'"+ >{{ database.databaseName }}</span+ >+ </div>+ <div v-if="showProjectColumn" class="bb-grid-cell">+ {{ database.projectEntity.title }}+ </div>+ <div class="bb-grid-cell gap-x-1 textinfolabel justify-end">+ <InstanceV1Name+ :instance="database.instanceEntity"+ :link="false"+ />+ </div>+ </template>+ </BBGrid>+ </NCollapseItem>+ </NCollapse>+ </div>++ <template #footer>+ <div class="flex-1 flex items-center justify-between">+ <div>+ <div+ v-if="combinedSelectedDatabaseUidList.length > 0"+ class="textinfolabel"+ >+ {{+ $t("database.selected-n-databases", {+ n: combinedSelectedDatabaseUidList.length,+ })+ }}+ </div>+ </div>+ <div class="flex items-center gap-x-3">+ <NButton @click.prevent="$emit('dismiss')">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ type="primary"+ :disabled="!allowTransfer"+ @click.prevent="transferDatabase"+ >+ {{ $t("common.transfer") }}+ </NButton></div></div>- <div class="flex items-center">- <button- type="button"- class="btn-normal py-2 px-4"- @click.prevent="$emit('dismiss')"- >- {{ $t("common.cancel") }}- </button>- <button- type="button"- class="btn-primary py-2 px-4 ml-3"- :disabled="!allowTransfer"- @click.prevent="transferDatabase"- >- {{ $t("common.transfer") }}- </button>- </div>- </div>- </div>+ </template>+ </DrawerContent></template><script lang="ts" setup>import { computed, PropType, reactive, watch } from "vue";-import { NCollapse, NCollapseItem } from "naive-ui";+import { NButton, NCollapse, NCollapseItem } from "naive-ui";import { type BBGridColumn, BBGrid } from "@/bbkit";import { ComposedDatabase } from "@/types";import { TransferSource } from "./utils";import { useDatabaseV1Store, useEnvironmentV1List } from "@/store";import { Environment } from "@/types/proto/v1/environment_service";-import { InstanceV1Name, ProductionEnvironmentV1Icon } from "../v2";+import {+ DrawerContent,+ InstanceV1Name,+ ProductionEnvironmentV1Icon,+} from "../v2";import { State } from "@/types/proto/v1/common";type LocalState = {diff --git a/frontend/src/components/TransferOutDatabaseForm/TransferOutDatabaseForm.vue b/frontend/src/components/TransferOutDatabaseForm/TransferOutDatabaseForm.vueindex a10266faa4..c4fb05855b 100644--- a/frontend/src/components/TransferOutDatabaseForm/TransferOutDatabaseForm.vue+++ b/frontend/src/components/TransferOutDatabaseForm/TransferOutDatabaseForm.vue@@ -1,63 +1,70 @@<template>- <div class="w-[60rem] space-y-2">- <div class="flex items-center justify-between">- <div class="flex-1 flex items-center gap-x-2">- <span class="textlabel">- {{ $t("database.transfer.source-project") }}- </span>- <ProjectV1Name :project="sourceProject" :link="false" />- </div>- <div class="flex-1 flex items-center gap-x-2">- <span class="textlabel">- {{ $t("database.transfer.target-project") }}- </span>- <ProjectSelect- v-model:project="targetProjectId"- :allowed-project-role-list="- hasWorkspaceManageProjectPermission ? [] : [PresetRoleType.OWNER]- "- :include-default-project="true"- :filter="filterTargetProject"- />- </div>- </div>- <NTransfer- ref="transfer"- v-model:value="selectedValueList"- style="height: calc(100vh - 380px)"- :options="sourceTransferOptions"- :render-source-list="renderSourceList"- :render-target-list="renderTargetList"- :source-filterable="true"- :source-filter-placeholder="$t('database.search-database-name')"- />- <div class="flex items-center justify-end gap-x-2">- <NButton @click="$emit('dismiss')">{{ $t("common.cancel") }}</NButton>- <NTooltip :disabled="allowTransfer">- <template #trigger>- <NButton- type="primary"- :disabled="!allowTransfer"- tag="div"- @click="doTransfer"- >- {{ $t("common.transfer") }}- </NButton>- </template>- <ul>- <li v-for="(error, i) in validationErrors" :key="i">- {{ error }}- </li>- </ul>- </NTooltip>- </div>+ <DrawerContent :title="$t('quick-action.transfer-out-db-title')"><div- v-if="loading"- class="absolute inset-0 z-10 bg-white/70 flex items-center justify-center"+ class="w-[calc(100vw-8rem)] lg:w-[60rem] max-w-[calc(100vw-8rem)] h-full flex flex-col gap-y-2">- <BBSpin />+ <div class="flex items-center justify-between">+ <div class="flex-1 flex items-center gap-x-2">+ <span class="textlabel">+ {{ $t("database.transfer.source-project") }}+ </span>+ <ProjectV1Name :project="sourceProject" :link="false" />+ </div>+ <div class="flex-1 flex items-center gap-x-2">+ <span class="textlabel">+ {{ $t("database.transfer.target-project") }}+ </span>+ <ProjectSelect+ v-model:project="targetProjectId"+ :allowed-project-role-list="+ hasWorkspaceManageProjectPermission ? [] : [PresetRoleType.OWNER]+ "+ :include-default-project="true"+ :filter="filterTargetProject"+ />+ </div>+ </div>+ <NTransfer+ ref="transfer"+ v-model:value="selectedValueList"+ :options="sourceTransferOptions"+ :render-source-list="renderSourceList"+ :render-target-list="renderTargetList"+ :source-filterable="true"+ :source-filter-placeholder="$t('database.search-database-name')"+ style="height: 100%"+ />+ <div+ v-if="loading"+ class="absolute inset-0 z-10 bg-white/70 flex items-center justify-center"+ >+ <BBSpin />+ </div></div>- </div>++ <template #footer>+ <div class="flex items-center justify-end gap-x-3">+ <NButton @click="$emit('dismiss')">{{ $t("common.cancel") }}</NButton>+ <NTooltip :disabled="allowTransfer">+ <template #trigger>+ <NButton+ type="primary"+ :disabled="!allowTransfer"+ tag="div"+ @click="doTransfer"+ >+ {{ $t("common.transfer") }}+ </NButton>+ </template>+ <ul>+ <li v-for="(error, i) in validationErrors" :key="i">+ {{ error }}+ </li>+ </ul>+ </NTooltip>+ </div>+ </template>+ </DrawerContent></template><script setup lang="ts">@@ -71,6 +78,7 @@ import {NTooltip,} from "naive-ui";import { useI18n } from "vue-i18n";+import { cloneDeep } from "lodash-es";import { ComposedDatabase, PresetRoleType, UNKNOWN_ID } from "@/types";import {@@ -81,7 +89,7 @@ import {useProjectV1ByUID,useProjectV1Store,} from "@/store";-import { ProjectV1Name, ProjectSelect } from "../v2";+import { ProjectV1Name, ProjectSelect, DrawerContent } from "@/components/v2";import Label from "./Label.vue";import {DatabaseTreeOption,@@ -89,7 +97,6 @@ import {mapTreeOptions,} from "./common";import { Project } from "@/types/proto/v1/project_service";-import { cloneDeep } from "lodash-es";import { hasWorkspacePermissionV1 } from "@/utils";const props = defineProps<{diff --git a/frontend/src/components/v2/Container/Drawer.vue b/frontend/src/components/v2/Container/Drawer.vuenew file mode 100644index 0000000000..2096dfebdc--- /dev/null+++ b/frontend/src/components/v2/Container/Drawer.vue@@ -0,0 +1,36 @@+<template>+ <NDrawer+ width="auto"+ :show="show"+ :auto-focus="false"+ :trap-focus="false"+ @update:show="onUpdateShow"+ >+ <slot />+ </NDrawer>+</template>++<script setup lang="ts">+import { NDrawer } from "naive-ui";++withDefaults(+ defineProps<{+ show?: boolean;+ }>(),+ {+ show: true,+ }+);+const emit = defineEmits<{+ (event: "update:show", show: boolean): void;+ (event: "close"): void;+}>();++const onUpdateShow = (show: boolean) => {+ emit("update:show", show);++ if (!show) {+ emit("close");+ }+};+</script>diff --git a/frontend/src/components/v2/Container/DrawerContent.vue b/frontend/src/components/v2/Container/DrawerContent.vuenew file mode 100644index 0000000000..f7c9df9641--- /dev/null+++ b/frontend/src/components/v2/Container/DrawerContent.vue@@ -0,0 +1,26 @@+<template>+ <NDrawerContent class="relative" :closable="true" :title="title">+ <template v-if="$slots.header" #header>+ <slot name="header" />+ </template>++ <slot />++ <template v-if="$slots.footer" #footer>+ <slot name="footer" />+ </template>+ </NDrawerContent>+</template>++<script setup lang="ts">+import { NDrawerContent } from "naive-ui";++withDefaults(+ defineProps<{+ title?: string;+ }>(),+ {+ title: undefined,+ }+);+</script>diff --git a/frontend/src/components/v2/Container/index.ts b/frontend/src/components/v2/Container/index.tsnew file mode 100644index 0000000000..c7d7dce72a--- /dev/null+++ b/frontend/src/components/v2/Container/index.ts@@ -0,0 +1,4 @@+import Drawer from "./Drawer.vue";+import DrawerContent from "./DrawerContent.vue";++export { Drawer, DrawerContent };diff --git a/frontend/src/components/v2/index.ts b/frontend/src/components/v2/index.tsindex df30366a22..4970cd0ce3 100644--- a/frontend/src/components/v2/index.ts+++ b/frontend/src/components/v2/index.ts@@ -3,3 +3,4 @@ export * from "./TabFilter";export * from "./Model";export * from "./Form";export * from "./Button";+export * from "./Container";diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex d91e57cfb6..f4ca9bfc98 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1161,7 +1161,7 @@"restore-before-last-migration": "Restore to the point before last migration","restore-before-last-migration-help-info": "@:{'database.pitr.restore-before-last-migration'}. {link}.","restore-to": "Restore",- "restore-to-new-db": " To new database",+ "restore-to-new-db": "To new database","restore-to-in-place": "In place"},"show-reserved-tables": "Show Bytebase reserved tables",diff --git a/frontend/src/types/quickAction.ts b/frontend/src/types/quickAction.tsindex 2943b99f8f..857724b741 100644--- a/frontend/src/types/quickAction.ts+++ b/frontend/src/types/quickAction.ts@@ -9,7 +9,7 @@ export type InstanceQuickActionType = "quickaction.bb.instance.create";export type UserQuickActionType = "quickaction.bb.user.manage";export type DatabaseQuickActionType =| "quickaction.bb.database.create" // Used by DBA and Owner- | "quickaction.bb.database.request" // Used by Developer+ | "quickaction.bb.database.request" // Used by Developer (not yet)| "quickaction.bb.database.schema.update"| "quickaction.bb.database.data.update"| "quickaction.bb.database.troubleshoot";diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vueindex 5b3b32a71d..f2a97d66eb 100644--- a/frontend/src/views/EnvironmentDashboard.vue+++ b/frontend/src/views/EnvironmentDashboard.vue@@ -1,5 +1,5 @@<template>- <div>+ <div class="h-full overflow-hidden flex flex-col"><BBTab:tab-item-list="tabItemList":selected-index="state.selectedIndex"@@ -20,6 +20,7 @@v-for="(env, index) in environmentList":key="env.uid":active="index == state.selectedIndex"+ class="flex-1 overflow-y-scroll"><div v-if="state.reorder" class="flex justify-center pt-5"><button@@ -46,13 +47,11 @@</BBTabPanel></BBTab></div>- <BBModal- v-if="state.showCreateModal"- :title="$t('environment.create')"- @close="state.showCreateModal = false"- >++ <Drawer v-model:show="state.showCreateModal"><EnvironmentForm:create="true"+ :drawer="true":environment="getEnvironmentCreate()":approval-policy="(DEFAULT_NEW_APPROVAL_POLICY as any)":backup-policy="(DEFAULT_NEW_BACKUP_PLAN_POLICY as any)"@@ -60,7 +59,7 @@@create="doCreate"@cancel="state.showCreateModal = false"/>- </BBModal>+ </Drawer><FeatureModalv-if="state.missingRequiredFeature != undefined"@@ -84,7 +83,7 @@ import {defaultEnvironmentTier,useEnvironmentV1List,} from "@/store";-import { ProductionEnvironmentV1Icon } from "@/components/v2";+import { Drawer, ProductionEnvironmentV1Icon } from "@/components/v2";import {Environment,EnvironmentTier,diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vueindex db9d6e313f..037edd32fb 100644--- a/frontend/src/views/EnvironmentDetail.vue+++ b/frontend/src/views/EnvironmentDetail.vue@@ -50,12 +50,14 @@<script lang="ts" setup>import { computed, reactive, watchEffect } from "vue";-import ArchiveBanner from "../components/ArchiveBanner.vue";-import EnvironmentForm from "../components/EnvironmentForm.vue";-import { idFromSlug } from "../utils";-import { hasFeature, pushNotification, useLegacyBackupStore } from "@/store";import { useI18n } from "vue-i18n";import { cloneDeep } from "lodash-es";+import { useRouter } from "vue-router";++import ArchiveBanner from "@/components/ArchiveBanner.vue";+import EnvironmentForm from "@/components/EnvironmentForm.vue";+import { environmentV1Slug, idFromSlug } from "@/utils";+import { hasFeature, pushNotification, useLegacyBackupStore } from "@/store";import BBModal from "@/bbkit/BBModal.vue";import {usePolicyV1Store,@@ -105,6 +107,7 @@ const emit = defineEmits(["archive"]);const environmentV1Store = useEnvironmentV1Store();const policyV1Store = usePolicyV1Store();const backupStore = useLegacyBackupStore();+const router = useRouter();const { t } = useI18n();const state = reactive<LocalState>({@@ -216,6 +219,7 @@ const doArchive = (environment: Environment) => {emit("archive", environment);environment.state = State.DELETED;assignEnvironment(environment);+ router.replace(`/environment/${environmentV1Slug(environment)}`);});};@@ -224,6 +228,7 @@ const doRestore = (environment: Environment) => {.undeleteEnvironment(environment.name).then((environment) => {assignEnvironment(environment);+ router.replace(`/environment#${environment.uid}`);});};diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vueindex 354d097615..87b41ffe8b 100644--- a/frontend/src/views/InstanceDetail.vue+++ b/frontend/src/views/InstanceDetail.vue@@ -92,17 +92,16 @@</div></div>- <BBModal- v-if="state.showCreateDatabaseModal"+ <Drawer+ v-model:show="state.showCreateDatabaseModal":title="$t('quick-action.create-db')"- @close="state.showCreateDatabaseModal = false">- <CreateDatabasePrepForm+ <CreateDatabasePrepPanel:environment-id="environment?.uid":instance-id="instance.uid"@dismiss="state.showCreateDatabaseModal = false"/>- </BBModal>+ </Drawer><FeatureModalv-if="state.showFeatureModal"@@ -124,8 +123,8 @@ import {} from "@/utils";import ArchiveBanner from "@/components/ArchiveBanner.vue";import InstanceForm from "@/components/InstanceForm/";-import CreateDatabasePrepForm from "@/components/CreateDatabasePrepForm.vue";-import { InstanceRoleTable, DatabaseV1Table } from "@/components/v2";+import { CreateDatabasePrepPanel } from "@/components/CreateDatabasePrepForm";+import { InstanceRoleTable, DatabaseV1Table, Drawer } from "@/components/v2";import { SQLResultSet } from "@/types";import {featureToRef,diff --git a/frontend/src/views/SettingWorkspaceProject.vue b/frontend/src/views/SettingWorkspaceProject.vueindex 0caf20ed65..dfdeb6bd2f 100644--- a/frontend/src/views/SettingWorkspaceProject.vue+++ b/frontend/src/views/SettingWorkspaceProject.vue@@ -27,15 +27,6 @@</div><ProjectV1Table :project-list="filteredProjectList" />-- <BBModal- v-if="state.showCreateModal"- class="relative overflow-hidden"- :title="$t('quick-action.create-project')"- @close="state.showCreateModal = false"- >- <ProjectCreate @dismiss="state.showCreateModal = false" />- </BBModal></div></template>@@ -45,14 +36,12 @@ import { NCheckbox } from "naive-ui";import { DEFAULT_PROJECT_V1_NAME } from "../types";import { useProjectV1List } from "@/store";-import ProjectCreate from "../components/ProjectCreate.vue";import { ProjectV1Table, SearchBox } from "@/components/v2";import { State } from "@/types/proto/v1/common";import { filterProjectV1ListByKeyword } from "@/utils";interface LocalState {searchText: string;- showCreateModal: boolean;includesArchived: boolean;}@@ -60,7 +49,6 @@ const { projectList } = useProjectV1List(true /* showDeleted */);const state = reactive<LocalState>({searchText: "",- showCreateModal: false,includesArchived: false,});