Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update ui for reorder env (#17804)
ecmadaoc49bec4ed218
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex c4e51a66e4..3cc5ed75eb 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -68,7 +68,6 @@},"revert": "Revert","confirm-to-revert": "Confirm to revert your editing?",- "apply": "Apply","reorder": "Reorder","id": "ID","name": "Name",@@ -1467,6 +1466,7 @@"delete": "Delete this environment","delete-description": "Delete environment will also remove it from related instances and databases. @:common.cannot-undo-this-action","create": "Create Environment",+ "reorder": "Reorder Environments","successfully-updated-environment": "Successfully updated environment '{name}'.","production-environment": "Production environment","access-control": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 394fcb7dcd..5807bbbc38 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -68,7 +68,6 @@},"revert": "Revertir","confirm-to-revert": "¿Confirmar para revertir la edición?",- "apply": "Aplicar","reorder": "Reordenar","id": "ID","name": "Nombre",@@ -1467,6 +1466,7 @@"delete": "Eliminar este entorno","delete-description": "Eliminar el entorno también lo eliminará de las instancias y bases de datos relacionadas. @:common.cannot-undo-this-action","create": "Crear entorno",+ "reorder": "Reordenar entornos","successfully-updated-environment": "entorno '{name}' actualizado exitosamente.","production-environment": "Entorno de producción","access-control": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 3a65f9ce93..02c9b4ee28 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -68,7 +68,6 @@},"revert": "元に戻す","confirm-to-revert": "編集を元に戻してもよろしいですか?",- "apply": "適用","reorder": "並び替え","id": "ID","name": "名前",@@ -1467,6 +1466,7 @@"delete": "この環境を削除します","delete-description": "環境を削除すると、関連するインスタンスとデータベースからも削除されます。@:common.cannot-undo-this-action","create": "環境を作成する",+ "reorder": "環境の並べ替え","successfully-updated-environment": "環境「{name}」は正常に更新されました","production-environment": "本番環境","access-control": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 9b6ab0c381..f3d9b7a3f1 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -68,7 +68,6 @@},"revert": "Hoàn tác","confirm-to-revert": "Xác nhận hoàn tác chỉnh sửa của bạn?",- "apply": "Áp dụng","reorder": "Sắp xếp lại","id": "ID","name": "Tên",@@ -1467,6 +1466,7 @@"delete": "Xóa môi trường này","delete-description": "Xóa môi trường cũng sẽ xóa nó khỏi các phiên bản và cơ sở dữ liệu liên quan. @:common.cannot-undo-this-action","create": "Tạo môi trường",+ "reorder": "Sắp xếp lại môi trường","successfully-updated-environment": "Đã cập nhật thành công môi trường '{name}'.","production-environment": "Môi trường sản xuất","access-control": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 8023403ab0..270b78ea52 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -68,7 +68,6 @@},"revert": "恢复","confirm-to-revert": "确定撤销编辑?",- "apply": "应用","reorder": "排序","id": "ID","name": "名称",@@ -1467,6 +1466,7 @@"delete": "删除此环境","delete-description": "删除环境也会将其从相关实例和数据库中删除。@:common.cannot-undo-this-action","create": "创建环境",+ "reorder": "重新排序环境","successfully-updated-environment": "环境'{name}'更新成功","production-environment": "生产环境","access-control": {diff --git a/frontend/src/views/DashboardLanding.vue b/frontend/src/views/DashboardLanding.vueindex f7b841461b..de6151c3fd 100644--- a/frontend/src/views/DashboardLanding.vue+++ b/frontend/src/views/DashboardLanding.vue@@ -131,8 +131,7 @@<script lang="tsx" setup>import { computedAsync } from "@vueuse/core";-import { Volume2Icon } from "lucide-vue-next";-import { SettingsIcon, GripVerticalIcon } from "lucide-vue-next";+import { Volume2Icon, SettingsIcon, GripVerticalIcon } from "lucide-vue-next";import { NButton, NCheckbox, NDivider } from "naive-ui";import { computed, reactive } from "vue";import { useRouter } from "vue-router";diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vueindex 71bf25b0f7..8bba53637b 100644--- a/frontend/src/views/EnvironmentDashboard.vue+++ b/frontend/src/views/EnvironmentDashboard.vue@@ -16,22 +16,19 @@:tab="() => renderTab(item.data, index)"><EnvironmentDetail- v-if="!state.reorder":environment-name="item.id":buttons-class="buttonsClass"@delete="doDelete"/></NTabPane><template #suffix>- <div- v-if="!state.reorder"- class="flex items-center justify-end space-x-2 px-2 pb-1"- >+ <div class="flex items-center justify-end space-x-2 px-2 pb-1"><NButtonv-if="hasWorkspacePermissionV2('bb.settings.get') &&hasWorkspacePermissionV2('bb.settings.set')"+ :disabled="environmentList.length <= 1"@click="startReorder"><template #icon>@@ -52,21 +49,9 @@</div></template></NTabs>- <div v-if="state.reorder" class="flex justify-start pt-5 gap-x-3 px-5">- <NButton @click.prevent="discardReorder">- {{ $t("common.cancel") }}- </NButton>- <NButton- type="primary"- :disabled="!orderChanged"- @click.prevent="doReorder"- >- {{ $t("common.apply") }}- </NButton>- </div></div>- <Drawer v-model:show="state.showCreateModal">+ <Drawer :show="state.showCreateModal" @close="discardReorder"><EnvironmentForm:create="true":environment="getEnvironmentCreate()"@@ -85,20 +70,54 @@</DrawerContent></EnvironmentForm></Drawer>++ <Drawer v-model:show="state.reorder" :close-on-esc="true">+ <DrawerContent+ :title="$t('environment.reorder')"+ class="w-[30rem] max-w-[90vw]"+ >+ <div>+ <Draggable+ v-model="state.reorderedEnvironmentList"+ item-key="id"+ animation="300"+ >+ <template+ #item="{ element, index }: { element: Environment; index: number }"+ >+ <div+ :key="element.id"+ class="flex items-center justify-between p-2 hover:bg-gray-100 rounded-sm cursor-grab"+ >+ <div class="flex items-center gap-x-2">+ <span class="textinfo"> {{ index + 1 }}.</span>+ <EnvironmentV1Name :environment="element" :link="false" />+ </div>+ <GripVerticalIcon class="w-5 h-5 text-gray-500" />+ </div>+ </template>+ </Draggable>+ </div>+ <template #footer>+ <div class="flex items-center justify-end gap-x-2">+ <NButton @click="discardReorder">{{ $t("common.cancel") }}</NButton>+ <NButton type="primary" :disabled="!orderChanged" @click="doReorder">+ {{ $t("common.confirm") }}+ </NButton>+ </div>+ </template>+ </DrawerContent>+ </Drawer></template><script lang="ts" setup>import { create } from "@bufbuild/protobuf";-import {- ChevronLeftIcon,- ChevronRightIcon,- PlusIcon,- ListOrderedIcon,-} from "lucide-vue-next";+import { PlusIcon, ListOrderedIcon, GripVerticalIcon } from "lucide-vue-next";import { NTabs, NTabPane, NButton } from "naive-ui";import { onMounted, computed, reactive, watch, h } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";+import Draggable from "vuedraggable";import type { BBTabItem } from "@/bbkit/types";import {EnvironmentForm,@@ -106,7 +125,7 @@ import {Buttons as EnvironmentFormButtons,} from "@/components/EnvironmentForm";import { Drawer, DrawerContent } from "@/components/v2";-import { EnvironmentV1Name, MiniActionButton } from "@/components/v2";+import { EnvironmentV1Name } from "@/components/v2";import {useUIStateStore,useEnvironmentV1Store,@@ -123,7 +142,7 @@ import type { Policy } from "@/types/proto-es/v1/org_policy_service_pb";import { PolicyResourceType } from "@/types/proto-es/v1/org_policy_service_pb";import { EnvironmentSetting_EnvironmentSchema } from "@/types/proto-es/v1/setting_service_pb";import type { Environment } from "@/types/v1/environment";-import { arraySwap, hasWorkspacePermissionV2 } from "@/utils";+import { hasWorkspacePermissionV2 } from "@/utils";import { type VueClass } from "@/utils";import EnvironmentDetail from "@/views/EnvironmentDetail.vue";@@ -192,17 +211,11 @@ watch(const environmentList = useEnvironmentV1List();const tabItemList = computed((): BBTabItem[] => {- if (environmentList.value) {- const list = state.reorder- ? state.reorderedEnvironmentList- : environmentList.value;- return list.map((item, index: number): BBTabItem => {- const title = `${index + 1}. ${item.title}`;- const id = item.id;- return { title, id, data: item };- });- }- return [];+ return environmentList.value.map((item, index: number): BBTabItem => {+ const title = `${index + 1}. ${item.title}`;+ const id = item.id;+ return { title, id, data: item };+ });});const getEnvironmentCreate = () => {@@ -248,12 +261,6 @@ const startReorder = () => {const stopReorder = () => {state.reorder = false;- state.reorderedEnvironmentList = [];-};--const reorderEnvironment = (sourceIndex: number, targetIndex: number) => {- arraySwap(state.reorderedEnvironmentList, sourceIndex, targetIndex);- selectEnvironment(targetIndex);};const orderChanged = computed(() => {@@ -274,6 +281,11 @@ const doReorder = () => {.reorderEnvironmentList(state.reorderedEnvironmentList).then(() => {stopReorder();+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.updated"),+ });});};@@ -305,43 +317,12 @@ const onTabChange = (id: string) => {};const renderTab = (env: Environment, index: number) => {- const child = [+ return h("div", { class: "flex items-center space-x-2 py-1" }, [+ h("span", { class: "text-opacity-60" }, `${index + 1}.`),h(EnvironmentV1Name, {environment: env,link: false,}),- ];- if (state.reorder) {- if (index > 0) {- child.unshift(- h(- MiniActionButton,- {- onClick: () => reorderEnvironment(index, index - 1),- },- {- default: () => h(ChevronLeftIcon, { class: "w-4 h-4" }),- }- )- );- }- if (index < tabItemList.value.length - 1) {- child.push(- h(- MiniActionButton,- {- onClick: () => reorderEnvironment(index, index + 1),- },- {- default: () => h(ChevronRightIcon, { class: "w-4 h-4" }),- }- )- );- }- } else {- child.unshift(h("span", { class: "text-opacity-60" }, `${index + 1}.`));- }-- return h("div", { class: "flex items-center space-x-2 py-1" }, child);+ ]);};</script>