Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: use naive-ui in environment page (#9507)
Liu Jic233bb328884
diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vueindex 537c8c26ab..15e88c9a8b 100644--- a/frontend/src/components/EnvironmentForm.vue+++ b/frontend/src/components/EnvironmentForm.vue@@ -4,22 +4,18 @@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">+ <div class="flex flex-col gap-y-6">+ <div class="flex flex-col gap-y-2"><label for="name" class="textlabel">{{ $t("common.environment-name") }}<span class="text-red-600">*</span></label>- <BBTextField- class="mt-2 w-full"+ <NInput+ v-model:value="state.environment.title":disabled="!allowEdit"- :required="true"- :value="state.environment.title"- @input="handleEnvironmentNameChange"+ size="large"/>- </div>- <div class="mt-2"><ResourceIdFieldref="resourceIdField"resource-type="environment"@@ -30,12 +26,12 @@/></div>- <div class="col-span-1 mt-6">+ <div class="flex flex-col gap-y-2"><label class="textlabel flex items-center">{{ $t("policy.environment-tier.name") }}<FeatureBadge feature="bb.feature.environment-tier-policy" /></label>- <p class="mt-2 text-sm text-gray-600">+ <p class="text-sm text-gray-600"><i18n-t tag="span" keypath="policy.environment-tier.description"><template #newline><br /></template></i18n-t>@@ -47,93 +43,80 @@}}<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) => {+ <NCheckbox+ :checked="state.environmentTier === EnvironmentTier.PROTECTED"+ :disabled="!allowEdit"+ style="--n-label-padding: 0 0 0 1rem"+ @update:checked="(on: boolean) => {state.environmentTier = on ? EnvironmentTier.PROTECTED : EnvironmentTier.UNPROTECTED}"- />- <div>- <div class="textlabel">- {{ $t("policy.environment-tier.mark-env-as-production") }}- </div>- </div>- </div>- </div>+ >+ {{ $t("policy.environment-tier.mark-env-as-production") }}+ </NCheckbox></div>- <div class="col-span-1 mt-6">++ <div class="flex flex-col gap-y-2"><label class="textlabel">{{ $t("policy.rollout.name") }}</label><spanv-show="!create && valueChanged('rolloutPolicy')"- class="textlabeltip"+ class="textlabeltip !ml-0">{{ $t("policy.rollout.tip") }}</span>- <div class="mt-1 textinfolabel">+ <div class="textinfolabel">{{ $t("policy.rollout.info") }}</div><RolloutPolicyConfigv-model:policy="state.rolloutPolicy"- class="mt-3"+ :disabled="!allowEdit"/></div>- <div class="col-span-1 mt-6">++ <div class="flex flex-col gap-y-2"><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">+ <span+ v-show="valueChanged('backupPolicy')"+ class="textlabeltip !ml-0"+ >{{ $t("policy.backup.tip") }}</span+ >+ <NRadioGroup+ v-model:value="state.backupPolicy.backupPlanPolicy!.schedule"+ :disabled="!allowEdit"+ class="!flex flex-col gap-y-2"+ >+ <NRadio+ :value="BackupPlanSchedule.UNSET"+ style="--n-label-padding: 0 0 0 1rem"+ >+ <div class="flex flex-col"><div class="textlabel">{{ $t("policy.backup.not-enforced") }}</div>- <div class="mt-1 textinfolabel">+ <div class="textinfolabel">{{ $t("policy.backup.not-enforced-info") }}</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">+ </NRadio>+ <NRadio+ :value="BackupPlanSchedule.DAILY"+ style="--n-label-padding: 0 0 0 1rem"+ >+ <div class="flex flex-col"><div class="textlabel flex">{{ $t("policy.backup.daily") }}<FeatureBadge feature="bb.feature.backup-policy" /></div>- <div class="mt-1 textinfolabel">+ <div class="textinfolabel">{{ $t("policy.backup.daily-info") }}</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">+ </NRadio>+ <NRadio+ :value="BackupPlanSchedule.WEEKLY"+ style="--n-label-padding: 0 0 0 1rem"+ >+ <div class="flex flex-col"><div class="textlabel flex">{{ $t("policy.backup.weekly") }}<FeatureBadge feature="bb.feature.backup-policy" />@@ -142,38 +125,39 @@{{ $t("policy.backup.weekly-info") }}</div></div>- </div>- </div>+ </NRadio>+ </NRadioGroup></div>- <div v-if="!create" class="col-span-1 mt-6">++ <div v-if="!create" class="flex flex-col gap-y-2"><label class="textlabel">{{ $t("sql-review.title") }}</label>- <div class="mt-3">- <div v-if="sqlReviewPolicy" class="inline-flex items-center">- <BBSwitch+ <div>+ <div+ v-if="sqlReviewPolicy"+ class="inline-flex items-center gap-x-2"+ >+ <Switchv-if="allowEditSQLReviewPolicy"- class="mr-2"- :text="true":value="sqlReviewPolicy.enforce"- @toggle="toggleSQLReviewPolicy"+ :text="true"+ @update:value="toggleSQLReviewPolicy"/>- <button- type="button"- class="text-sm font-medium text-accent hover:underline-2"- @click.prevent="onSQLReviewPolicyClick"+ <NButton+ quaternary+ type="primary"+ @click="onSQLReviewPolicyClick">{{ sqlReviewPolicy.name }}- </button>+ </NButton></div>- <button+ <NButtonv-else-if="hasPermission"- type="button"- class="btn-normal py-2 px-4 gap-x-1 items-center"@click.prevent="onSQLReviewPolicyClick">{{ $t("sql-review.configure-policy") }}- </button>+ </NButton><span v-else class="textinfolabel">{{ $t("sql-review.no-policy-set") }}</span>@@ -215,23 +199,21 @@/></template><div v-else></div>- <div v-if="allowEdit">- <button- type="button"- class="btn-normal py-2 px-4"++ <div v-if="allowEdit" class="flex items-center justify-end gap-x-3">+ <NButton: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"+ </NButton>+ <NButton+ type="primary":disabled="!valueChanged()"@click.prevent="updateEnvironment">{{ $t("common.update") }}- </button>+ </NButton></div></div></div>@@ -256,13 +238,12 @@<script lang="ts" setup>import { cloneDeep, isEqual, isEmpty } from "lodash-es";-import { NButton } from "naive-ui";+import { NButton, NCheckbox, NInput, NRadioGroup } from "naive-ui";import { Status } from "nice-grpc-common";import { computed, reactive, PropType, watch, watchEffect, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";-import { BBSwitch } from "@/bbkit";-import { DrawerContent } from "@/components/v2";+import { DrawerContent, Switch } from "@/components/v2";import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";import {pushNotification,@@ -382,10 +363,6 @@ const sqlReviewPolicy = computed((): SQLReviewPolicy | undefined => {return sqlReviewStore.getReviewPolicyByEnvironmentUID(environmentId.value);});-const handleEnvironmentNameChange = (event: Event) => {- state.environment.title = (event.target as HTMLInputElement).value;-};-const onSQLReviewPolicyClick = () => {if (sqlReviewPolicy.value) {router.push({diff --git a/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue b/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vueindex 06a6ef7d8c..387f7da190 100644--- a/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue+++ b/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue@@ -1,11 +1,13 @@<template>- <div class="rollout-policy-config flex flex-col gap-y-2">+ <div class="flex flex-col gap-y-2"><div class="flex flex-col gap-y-2"><NRadio:checked="rolloutPolicy.automatic"+ :disabled="disabled"+ style="--n-label-padding: 0 0 0 1rem"@update:checked="selectAutomaticRollout">- <div class="flex flex-col gap-y-2">+ <div class="flex flex-col gap-y-1"><div class="textlabel">{{ $t("policy.rollout.auto") }}</div>@@ -18,9 +20,11 @@<div class="flex flex-col gap-y-2"><NRadio:checked="isManualRolloutByDedicatedRolesChecked"+ :disabled="disabled"+ style="--n-label-padding: 0 0 0 1rem"@update:checked="toggleAllDedicatedRoles">- <div class="flex flex-col gap-y-2">+ <div class="flex flex-col gap-y-1"><div class="textlabel flex flex-row gap-x-1"><span>{{ $t("policy.rollout.manual-by-dedicated-roles") }}</span><FeatureBadge feature="bb.feature.approval-policy" />@@ -33,6 +37,8 @@<div class="flex flex-col gap-y-2 pl-8"><NCheckbox:checked="isWorkspaceOwnerChecked"+ :disabled="disabled"+ style="--n-label-padding: 0 0 0 1rem"@update:checked="toggleDedicatedRoles($event, 'workspace', [VirtualRoleType.OWNER])"@@ -43,6 +49,8 @@</NCheckbox><NCheckbox:checked="isDBAChecked"+ :disabled="disabled"+ style="--n-label-padding: 0 0 0 1rem"@update:checked="toggleDedicatedRoles($event, 'workspace', [VirtualRoleType.DBA])"@@ -53,6 +61,8 @@</NCheckbox><NCheckbox:checked="isProjectOwnerChecked"+ :disabled="disabled"+ style="--n-label-padding: 0 0 0 1rem"@update:checked="toggleDedicatedRoles($event, 'project', [PresetRoleType.OWNER])"@@ -63,6 +73,8 @@</NCheckbox><NCheckbox:checked="isProjectReleaserChecked"+ :disabled="disabled"+ style="--n-label-padding: 0 0 0 1rem"@update:checked="toggleDedicatedRoles($event, 'project', [PresetRoleType.RELEASER])"@@ -73,6 +85,8 @@</NCheckbox><NCheckbox:checked="isIssueCreatorChecked"+ :disabled="disabled"+ style="--n-label-padding: 0 0 0 1rem"@update:checked="toggleDedicatedRoles($event, 'issue', [VirtualRoleType.CREATOR])"@@ -86,6 +100,8 @@<div class="flex flex-col gap-y-2"><NRadio:checked="isIssueLastApproverChecked"+ :disabled="disabled"+ style="--n-label-padding: 0 0 0 1rem"@update:checked="toggleLastApprover"><div class="textlabel flex flex-row gap-x-1">@@ -108,6 +124,7 @@ import FeatureBadge from "../FeatureGuard/FeatureBadge.vue";const props = defineProps<{policy: Policy;+ disabled?: boolean;}>();const emit = defineEmits<{(event: "update:policy", policy: Policy): void;@@ -226,10 +243,3 @@ watch({ immediate: true, deep: true });</script>--<style lang="postcss" scoped>-.rollout-policy-config :deep(.n-radio),-.rollout-policy-config :deep(.n-checkbox) {- --n-label-padding: 0 0 0 1rem !important;-}-</style>diff --git a/frontend/src/components/v2/Form/Switch.vue b/frontend/src/components/v2/Form/Switch.vuenew file mode 100644index 0000000000..966d02e1e0--- /dev/null+++ b/frontend/src/components/v2/Form/Switch.vue@@ -0,0 +1,38 @@+<template>+ <NSwitch+ class="bb-switch"+ style="+ --n-width: max(+ var(--n-rail-width),+ calc(var(--n-rail-width) + var(--n-button-width) - var(--n-rail-height))+ );+ "+ >+ <template v-if="text" #checked>+ <span style="font-size: 10px">{{ $t("common.on") }}</span>+ </template>+ <template v-if="text" #unchecked>+ <span style="font-size: 10px">{{ $t("common.off") }}</span>+ </template>+ </NSwitch>+</template>++<script lang="ts" setup>+import { NSwitch } from "naive-ui";++defineProps<{+ text?: boolean;+}>();+</script>++<style lang="postcss" scoped>+.bb-switch :deep(.n-switch__checked) {+ padding-right: calc(var(--n-rail-height) - var(--n-offset) + 1px) !important;+}+.bb-switch :deep(.n-switch__unchecked) {+ padding-left: calc(var(--n-rail-height) - var(--n-offset) + 1px) !important;+}+.bb-switch :deep(.n-switch__button-placeholder) {+ width: calc(1.25 * var(--n-rail-height)) !important;+}+</style>diff --git a/frontend/src/components/v2/Form/index.ts b/frontend/src/components/v2/Form/index.tsindex ffee298d35..8314d1ad62 100644--- a/frontend/src/components/v2/Form/index.ts+++ b/frontend/src/components/v2/Form/index.ts@@ -5,6 +5,7 @@ import ResourceIdField from "./ResourceIdField.vue";import SearchBox from "./SearchBox.vue";import SpinnerButton from "./SpinnerButton.vue";import SpinnerSwitch from "./SpinnerSwitch.vue";+import Switch from "./Switch.vue";export * from "./types";export {@@ -15,4 +16,5 @@ export {SpinnerButton,SearchBox,ResourceIdField,+ Switch,};diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vueindex 49f5b931c1..890833e652 100644--- a/frontend/src/views/EnvironmentDashboard.vue+++ b/frontend/src/views/EnvironmentDashboard.vue@@ -22,22 +22,17 @@:active="index == state.selectedIndex"class="flex-1 overflow-y-scroll">- <div v-if="state.reorder" class="flex justify-center pt-5">- <button- type="button"- class="btn-normal py-2 px-4"- @click.prevent="discardReorder"- >+ <div v-if="state.reorder" class="flex justify-center pt-5 gap-x-3">+ <NButton @click.prevent="discardReorder">{{ $t("common.cancel") }}- </button>- <button- type="submit"- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"+ </NButton>+ <NButton+ type="primary":disabled="!orderChanged"@click.prevent="doReorder">{{ $t("common.apply") }}- </button>+ </NButton></div><EnvironmentDetailv-elsediff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vueindex fd1a82c40b..b80450104b 100644--- a/frontend/src/views/EnvironmentDetail.vue+++ b/frontend/src/views/EnvironmentDetail.vue@@ -29,27 +29,20 @@</p></div>- <div class="flex items-center justify-end pt-4 mt-4 border-t">- <button- type="button"- class="btn-normal py-2 px-4"- @click="state.showDisableAutoBackupModal = false"- >+ <div class="flex items-center justify-end gap-x-3 pt-4 mt-4 border-t">+ <NButton @click="state.showDisableAutoBackupModal = false">{{ $t("common.no") }}- </button>- <button- type="submit"- class="btn-primary ml-3 inline-flex justify-center py-2 px-4"- @click="disableEnvironmentAutoBackup"- >+ </NButton>+ <NButton type="primary" @click="disableEnvironmentAutoBackup">{{ $t("common.yes") }}- </button>+ </NButton></div></BBModal></template><script lang="ts" setup>import { cloneDeep } from "lodash-es";+import { NButton } from "naive-ui";import { computed, reactive, watchEffect } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";