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: modals to drawers (#7501)
Liu Jib3f4a1388ead
diff --git a/frontend/src/components/IssueV1/IssueDetailPage.vue b/frontend/src/components/IssueV1/IssueDetailPage.vueindex a482e38dbb..0f2df3444a 100644--- a/frontend/src/components/IssueV1/IssueDetailPage.vue+++ b/frontend/src/components/IssueV1/IssueDetailPage.vue@@ -20,20 +20,17 @@<ActivitySection v-if="!isCreating" />- <IssueReviewActionDialog- v-if="ongoingIssueReviewAction"- :action="ongoingIssueReviewAction.action"+ <IssueReviewActionPanel+ :action="ongoingIssueReviewAction?.action"@close="ongoingIssueReviewAction = undefined"/>- <IssueStatusActionDialog- v-if="ongoingIssueStatusAction"- :action="ongoingIssueStatusAction.action"+ <IssueStatusActionPanel+ :action="ongoingIssueStatusAction?.action"@close="ongoingIssueStatusAction = undefined"/>- <TaskRolloutActionDialog- v-if="ongoingTaskRolloutAction"- :action="ongoingTaskRolloutAction.action"- :task-list="ongoingTaskRolloutAction.taskList"+ <TaskRolloutActionPanel+ :action="ongoingTaskRolloutAction?.action"+ :task-list="ongoingTaskRolloutAction?.taskList ?? []"@close="ongoingTaskRolloutAction = undefined"/></div>@@ -56,9 +53,9 @@ import {StatementSection,DescriptionSection,ActivitySection,- IssueReviewActionDialog,- IssueStatusActionDialog,- TaskRolloutActionDialog,+ IssueReviewActionPanel,+ IssueStatusActionPanel,+ TaskRolloutActionPanel,} from "./components";import {IssueReviewAction,diff --git a/frontend/src/components/IssueV1/components/Dialog/CommonDialog.vue b/frontend/src/components/IssueV1/components/Dialog/CommonDialog.vuedeleted file mode 100644index e91ef881d9..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/CommonDialog.vue+++ /dev/null@@ -1,29 +0,0 @@-<template>- <BBModal- :title="title"- class="relative overflow-hidden !w-[30rem] !max-w-[30rem]"- header-class="overflow-hidden"- @close="$emit('close')"- >- <slot />- <div- v-if="loading"- class="absolute inset-0 flex items-center justify-center bg-white/50"- >- <BBSpin />- </div>- </BBModal>-</template>--<script setup lang="ts">-import { BBModal, BBSpin } from "@/bbkit";--defineProps<{- title: string;- loading: boolean;-}>();--defineEmits<{- (event: "close"): void;-}>();-</script>diff --git a/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/ReviewDialog.vue b/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/ReviewDialog.vuedeleted file mode 100644index 52f87dce43..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/ReviewDialog.vue+++ /dev/null@@ -1,91 +0,0 @@-<template>- <CommonDialog :title="title" :loading="state.loading" @close="$emit('close')">- <ReviewForm- :action="action"- @cancel="$emit('close')"- @confirm="handleConfirm"- />- </CommonDialog>-</template>--<script setup lang="ts">-import { computed, reactive } from "vue";-import { useI18n } from "vue-i18n";-import {- IssueReviewAction,- targetReviewStatusForReviewAction,- useIssueContext,-} from "@/components/IssueV1";-import { issueServiceClient } from "@/grpcweb";-import { Issue_Approver_Status } from "@/types/proto/v1/issue_service";-import CommonDialog from "../CommonDialog.vue";-import ReviewForm from "./ReviewForm.vue";--type LocalState = {- loading: boolean;-};--const props = defineProps<{- action: IssueReviewAction;-}>();--const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const state = reactive<LocalState>({- loading: false,-});--const { issue, events } = useIssueContext();--const title = computed(() => {- switch (props.action) {- case "APPROVE":- return t("custom-approval.issue-review.approve-issue");- case "SEND_BACK":- return t("custom-approval.issue-review.send-back-issue");- case "RE_REQUEST":- return t("custom-approval.issue-review.re-request-review-issue");- }- return ""; // Make linter happy-});--const handleConfirm = async (- params: {- action: IssueReviewAction;- comment?: string;- },- onSuccess: () => void-) => {- state.loading = true;- try {- const { action, comment = "" } = params;- const status = targetReviewStatusForReviewAction(action);- if (status === Issue_Approver_Status.APPROVED) {- await issueServiceClient.approveIssue({- name: issue.value.name,- comment,- });- onSuccess();- } else if (status === Issue_Approver_Status.PENDING) {- await issueServiceClient.requestIssue({- name: issue.value.name,- comment,- });- } else if (status === Issue_Approver_Status.REJECTED) {- await issueServiceClient.rejectIssue({- name: issue.value.name,- comment,- });- }-- // notify the issue logic to update issue status- events.emit("status-changed", { eager: true });- } finally {- state.loading = false;- emit("close");- }-};-</script>diff --git a/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/ReviewForm.vue b/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/ReviewForm.vuedeleted file mode 100644index 9d860ca81d..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/ReviewForm.vue+++ /dev/null@@ -1,105 +0,0 @@-<template>- <div class="mt-2 flex flex-col gap-y-4">- <div class="text-sm">- {{ issue.title }}- </div>- <div class="flex flex-col gap-y-1">- <p class="textlabel">- {{ $t("common.comment") }}- <RequiredStar v-show="props.action === 'SEND_BACK'" />- </p>- <NInput- v-model:value="comment"- type="textarea"- :placeholder="$t('issue.leave-a-comment')"- :autosize="{- minRows: 3,- maxRows: 10,- }"- />- </div>- <div class="py-1 flex justify-end gap-x-3">- <NButton @click="$emit('cancel')">- {{ $t("common.cancel") }}- </NButton>- <NButton- :disabled="!allowConfirm"- v-bind="issueReviewActionButtonProps(action)"- @click="handleConfirm"- >- {{ issueReviewActionDisplayName(action) }}- </NButton>- </div>- </div>-</template>--<script lang="ts" setup>-import { NButton, NInput } from "naive-ui";-import { computed, ref } from "vue";-import {- IssueReviewAction,- issueReviewActionButtonProps,- issueReviewActionDisplayName,- useIssueContext,-} from "@/components/IssueV1";-import RequiredStar from "@/components/RequiredStar.vue";--const props = defineProps<{- action: IssueReviewAction;-}>();--const emit = defineEmits<{- (event: "cancel"): void;- (- event: "confirm",- params: {- action: IssueReviewAction;- comment?: string;- },- onSuccess: () => void- ): void;-}>();--const { issue } = useIssueContext();-const comment = ref("");--const allowConfirm = computed(() => {- if (props.action === "SEND_BACK" && comment.value === "") {- return false;- }-- return true;-});--const handleConfirm = (e: MouseEvent) => {- const button = e.target as HTMLElement;- const { left, top, width, height } = button.getBoundingClientRect();- const { innerWidth: winWidth, innerHeight: winHeight } = window;- const onSuccess = () => {- if (props.action !== "APPROVE") {- return;- }- // import the effect lib asynchronously- import("canvas-confetti").then(({ default: confetti }) => {- // Create a confetti effect from the position of the LGTM button- confetti({- particleCount: 100,- spread: 70,- origin: {- x: (left + width / 2) / winWidth,- y: (top + height / 2) / winHeight,- },- });- });- };-- emit(- "confirm",- {- action: props.action,- comment: comment.value,- },- onSuccess- );-};-</script>diff --git a/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/index.ts b/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/index.tsdeleted file mode 100644index 970b1c5fb0..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/IssueReviewActionDialog/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import IssueReviewActionDialog from "./ReviewDialog.vue";--export default IssueReviewActionDialog;diff --git a/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/Dialog.vue b/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/Dialog.vuedeleted file mode 100644index c826abf173..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/Dialog.vue+++ /dev/null@@ -1,76 +0,0 @@-<template>- <CommonDialog :title="title" :loading="state.loading" @close="$emit('close')">- <Form :action="action" @cancel="$emit('close')" @confirm="handleConfirm" />- </CommonDialog>-</template>--<script setup lang="ts">-import { computed, reactive } from "vue";-import { useI18n } from "vue-i18n";-import { IssueStatusAction, useIssueContext } from "@/components/IssueV1/logic";-import CommonDialog from "../CommonDialog.vue";-import Form from "./Form.vue";--type LocalState = {- loading: boolean;-};--const props = defineProps<{- action: IssueStatusAction;-}>();-const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const state = reactive<LocalState>({- loading: false,-});-const { events } = useIssueContext();--const title = computed(() => {- const { action } = props;-- switch (action) {- case "RESOLVE":- return t("issue.status-transition.modal.resolve");- case "CANCEL":- return t("issue.status-transition.modal.cancel");- case "REOPEN":- return t("issue.status-transition.modal.reopen");- }- return "";-});--const handleConfirm = async (- action: IssueStatusAction,- comment: string | undefined-) => {- state.loading = true;- // TODO- try {- await new Promise((r) => setTimeout(r, 1000));-- // notify the issue logic to update issue status- events.emit("status-changed", { eager: true });- } finally {- state.loading = false;- emit("close");- }-- // Trying to avoid some kind of concurrency and race condition, we fetch the- // latest snapshot of issue from the server-side and check whether this- // transition is applicable again.- // const latestIssue = await useIssueStore().fetchIssueById(issue.value.id);-- // const { action: transition } = props;- // const applicableList = getApplicableIssueStatusTransitionList(latestIssue);- // if (!isApplicableTransition(transition, applicableList)) {- // return cleanup();- // }-- // changeIssueStatus(transition.to, comment);- // isTransiting.value = false;- // emit("updated");-};-</script>diff --git a/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/Form.vue b/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/Form.vuedeleted file mode 100644index 78b559aaf5..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/Form.vue+++ /dev/null@@ -1,54 +0,0 @@-<template>- <div class="mt-2 flex flex-col gap-y-4">- <div class="text-sm">- {{ issue.title }}- </div>- <div class="flex flex-col gap-y-1">- <p class="textlabel">- {{ $t("common.comment") }}- </p>- <NInput- v-model:value="comment"- type="textarea"- :placeholder="$t('issue.leave-a-comment')"- :autosize="{- minRows: 3,- maxRows: 10,- }"- />- </div>- <div class="py-1 flex justify-end gap-x-3">- <NButton @click="$emit('cancel')">- {{ $t("common.cancel") }}- </NButton>- <NButton- v-bind="issueStatusActionButtonProps(action)"- @click="$emit('confirm', action, comment)"- >- {{ issueStatusActionDisplayName(action) }}- </NButton>- </div>- </div>-</template>--<script lang="ts" setup>-import { ref } from "vue";-import {- IssueStatusAction,- issueStatusActionButtonProps,- issueStatusActionDisplayName,- useIssueContext,-} from "@/components/IssueV1/logic";--defineProps<{- action: IssueStatusAction;-}>();--defineEmits<{- (event: "cancel"): void;- (event: "confirm", action: IssueStatusAction, comment?: string): void;-}>();--const { issue } = useIssueContext();-const comment = ref("");-</script>diff --git a/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/index.ts b/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/index.tsdeleted file mode 100644index 730b42ef1f..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/IssueStatusActionDialog/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import IssueStatusActionDialog from "./Dialog.vue";--export default IssueStatusActionDialog;diff --git a/frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/Form.vue b/frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/Form.vuedeleted file mode 100644index 7de02270d1..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/Form.vue+++ /dev/null@@ -1,92 +0,0 @@-<template>- <div class="mt-2 flex flex-col gap-y-4">- <div class="text-sm">- <label v-if="taskList.length > 1" class="textlabel">- {{ $t("common.tasks") }}- </label>- <ul class="mt-1 max-h-[6rem] overflow-y-auto">- <li- v-for="item in distinctTaskList"- :key="item.task.uid"- class="text-sm textinfolabel"- >- <span class="textinfolabel">- {{ item.task.title }}- </span>- <span v-if="item.similar.length > 0" class="ml-2 text-gray-400">- {{- $t("task.n-similar-tasks", {- count: item.similar.length + 1,- })- }}- </span>- </li>- </ul>- <PlanCheckBar- v-if="taskList.length === 1 && action === 'ROLLOUT'"- :allow-run-checks="false"- :task="taskList[0]"- class="pt-2"- />- </div>- <div class="flex flex-col gap-y-1">- <p class="textlabel">- {{ $t("common.comment") }}- </p>- <NInput- v-model:value="comment"- type="textarea"- :placeholder="$t('issue.leave-a-comment')"- :autosize="{- minRows: 3,- maxRows: 10,- }"- />- </div>- <div class="py-1 flex justify-end gap-x-3">- <NButton @click="$emit('cancel')">- {{ $t("common.cancel") }}- </NButton>- <NButton- v-bind="taskRolloutActionButtonProps(action)"- @click="$emit('confirm', action, comment)"- >- {{ taskRolloutActionDialogButtonName(action, taskList) }}- </NButton>- </div>- </div>-</template>--<script lang="ts" setup>-import { groupBy } from "lodash-es";-import { computed, ref } from "vue";-import { PlanCheckBar } from "@/components/IssueV1/components/PlanCheckSection";-import {- TaskRolloutAction,- taskRolloutActionButtonProps,- taskRolloutActionDialogButtonName,-} from "@/components/IssueV1/logic";-import { Task } from "@/types/proto/v1/rollout_service";--const props = defineProps<{- action: TaskRolloutAction;- taskList: Task[];-}>();--defineEmits<{- (event: "cancel"): void;- (event: "confirm", action: TaskRolloutAction, comment?: string): void;-}>();--const comment = ref("");--const distinctTaskList = computed(() => {- type DistinctTaskList = { task: Task; similar: Task[] };- const groups = groupBy(props.taskList, (task) => task.title);-- return Object.keys(groups).map<DistinctTaskList>((taskName) => {- const [task, ...similar] = groups[taskName];- return { task, similar };- });-});-</script>diff --git a/frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/index.ts b/frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/index.tsdeleted file mode 100644index a48f196b60..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/index.ts+++ /dev/null@@ -1,3 +0,0 @@-import TaskRolloutActionDialog from "./Dialog.vue";--export default TaskRolloutActionDialog;diff --git a/frontend/src/components/IssueV1/components/Dialog/index.ts b/frontend/src/components/IssueV1/components/Dialog/index.tsdeleted file mode 100644index 13ceb5f29c..0000000000--- a/frontend/src/components/IssueV1/components/Dialog/index.ts+++ /dev/null@@ -1,9 +0,0 @@-import IssueReviewActionDialog from "./IssueReviewActionDialog";-import IssueStatusActionDialog from "./IssueStatusActionDialog";-import TaskRolloutActionDialog from "./TaskRolloutActionDialog";--export {- IssueReviewActionDialog,- IssueStatusActionDialog,- TaskRolloutActionDialog,-};diff --git a/frontend/src/components/IssueV1/components/Panel/CommonDrawer.vue b/frontend/src/components/IssueV1/components/Panel/CommonDrawer.vuenew file mode 100644index 0000000000..e22f144e78--- /dev/null+++ b/frontend/src/components/IssueV1/components/Panel/CommonDrawer.vue@@ -0,0 +1,40 @@+<template>+ <Drawer :show="show" :mask-closable="false" @close="$emit('close')">+ <DrawerContent+ :title="title"+ class="relative overflow-hidden !w-[30rem] !max-w-[30rem]"+ >+ <template #default>+ <slot />++ <div+ v-if="loading"+ v-zindexable="{ enabled: true }"+ class="absolute inset-0 flex items-center justify-center bg-white/50"+ >+ <BBSpin />+ </div>+ </template>++ <template v-if="$slots.footer" #footer>+ <slot name="footer" />+ </template>+ </DrawerContent>+ </Drawer>+</template>++<script setup lang="ts">+import { zindexable as vZindexable } from "vdirs";+import { BBSpin } from "@/bbkit";+import { Drawer, DrawerContent } from "@/components/v2";++defineProps<{+ title: string;+ show: boolean;+ loading: boolean;+}>();++defineEmits<{+ (event: "close"): void;+}>();+</script>diff --git a/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vuenew file mode 100644index 0000000000..66e0a6dccc--- /dev/null+++ b/frontend/src/components/IssueV1/components/Panel/IssueReviewActionPanel.vue@@ -0,0 +1,150 @@+<template>+ <CommonDrawer+ :show="action !== undefined"+ :title="title"+ :loading="state.loading"+ @close="$emit('close')"+ >+ <template #default>+ <div v-if="action" class="flex flex-col gap-y-4">+ <p class="textlabel">+ {{ $t("common.comment") }}+ <RequiredStar v-show="props.action === 'SEND_BACK'" />+ </p>+ <NInput+ v-model:value="comment"+ type="textarea"+ :placeholder="$t('issue.leave-a-comment')"+ :autosize="{+ minRows: 3,+ maxRows: 10,+ }"+ />+ </div>+ </template>+ <template #footer>+ <div v-if="action" class="py-1 flex justify-end gap-x-3">+ <NButton @click="$emit('close')">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ :disabled="!allowConfirm"+ v-bind="issueReviewActionButtonProps(action)"+ @click="handleClickConfirm"+ >+ {{ issueReviewActionDisplayName(action) }}+ </NButton>+ </div>+ </template>+ </CommonDrawer>+</template>++<script setup lang="ts">+import { computed, reactive, ref } from "vue";+import { useI18n } from "vue-i18n";+import {+ useIssueContext,+ IssueReviewAction,+ targetReviewStatusForReviewAction,+ issueReviewActionButtonProps,+ issueReviewActionDisplayName,+} from "@/components/IssueV1/logic";+import { issueServiceClient } from "@/grpcweb";+import { Issue_Approver_Status } from "@/types/proto/v1/issue_service";+import CommonDrawer from "./CommonDrawer.vue";++type LocalState = {+ loading: boolean;+};++const props = defineProps<{+ action?: IssueReviewAction;+}>();+const emit = defineEmits<{+ (event: "close"): void;+}>();++const { t } = useI18n();+const state = reactive<LocalState>({+ loading: false,+});+const { events, issue } = useIssueContext();+const comment = ref("");++const title = computed(() => {+ switch (props.action) {+ case "APPROVE":+ return t("custom-approval.issue-review.approve-issue");+ case "SEND_BACK":+ return t("custom-approval.issue-review.send-back-issue");+ case "RE_REQUEST":+ return t("custom-approval.issue-review.re-request-review-issue");+ }+ return ""; // Make linter happy+});++const allowConfirm = computed(() => {+ if (props.action === "SEND_BACK" && comment.value === "") {+ return false;+ }++ return true;+});++const handleClickConfirm = (e: MouseEvent) => {+ const button = e.target as HTMLElement;+ const { left, top, width, height } = button.getBoundingClientRect();+ const { innerWidth: winWidth, innerHeight: winHeight } = window;+ const onSuccess = () => {+ if (props.action !== "APPROVE") {+ return;+ }+ // import the effect lib asynchronously+ import("canvas-confetti").then(({ default: confetti }) => {+ // Create a confetti effect from the position of the LGTM button+ confetti({+ particleCount: 100,+ spread: 70,+ origin: {+ x: (left + width / 2) / winWidth,+ y: (top + height / 2) / winHeight,+ },+ });+ });+ };++ handleConfirm(onSuccess);+};++const handleConfirm = async (onSuccess: () => void) => {+ const { action } = props;+ if (!action) return;+ state.loading = true;+ try {+ const status = targetReviewStatusForReviewAction(action);+ if (status === Issue_Approver_Status.APPROVED) {+ await issueServiceClient.approveIssue({+ name: issue.value.name,+ comment: comment.value,+ });+ onSuccess();+ } else if (status === Issue_Approver_Status.PENDING) {+ await issueServiceClient.requestIssue({+ name: issue.value.name,+ comment: comment.value,+ });+ } else if (status === Issue_Approver_Status.REJECTED) {+ await issueServiceClient.rejectIssue({+ name: issue.value.name,+ comment: comment.value,+ });+ }++ // notify the issue logic to update issue status+ events.emit("status-changed", { eager: true });+ } finally {+ state.loading = false;+ emit("close");+ }+};+</script>diff --git a/frontend/src/components/IssueV1/components/Panel/IssueStatusActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/IssueStatusActionPanel.vuenew file mode 100644index 0000000000..7f830a77cd--- /dev/null+++ b/frontend/src/components/IssueV1/components/Panel/IssueStatusActionPanel.vue@@ -0,0 +1,126 @@+<template>+ <CommonDrawer+ :show="action !== undefined"+ :title="title"+ :loading="state.loading"+ @close="$emit('close')"+ >+ <template #default>+ <div v-if="action" class="flex flex-col gap-y-4">+ <div class="text-sm">+ {{ issue.title }}+ </div>+ <div class="flex flex-col gap-y-1">+ <p class="textlabel">+ {{ $t("common.comment") }}+ </p>+ <NInput+ v-model:value="comment"+ type="textarea"+ :placeholder="$t('issue.leave-a-comment')"+ :autosize="{+ minRows: 3,+ maxRows: 10,+ }"+ />+ </div>+ </div>+ </template>+ <template #footer>+ <div v-if="action" class="py-1 flex justify-end gap-x-3">+ <NButton @click="$emit('close')">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ v-bind="issueStatusActionButtonProps(action) !== undefined"+ @click="handleConfirm(action, comment)"+ >+ {{ issueStatusActionDisplayName(action) }}+ </NButton>+ </div>+ </template>+ </CommonDrawer>+</template>++<script setup lang="ts">+import { computed, reactive, ref } from "vue";+import { useI18n } from "vue-i18n";+import {+ IssueStatusAction,+ useIssueContext,+ issueStatusActionButtonProps,+ issueStatusActionDisplayName,+} from "@/components/IssueV1/logic";+import { pushNotification } from "@/store";+import CommonDrawer from "./CommonDrawer.vue";++type LocalState = {+ loading: boolean;+};++const props = defineProps<{+ action?: IssueStatusAction;+}>();+const emit = defineEmits<{+ (event: "close"): void;+}>();++const { t } = useI18n();+const state = reactive<LocalState>({+ loading: false,+});+const { events, issue } = useIssueContext();+const comment = ref("");++const title = computed(() => {+ const { action } = props;++ switch (action) {+ case "RESOLVE":+ return t("issue.status-transition.modal.resolve");+ case "CANCEL":+ return t("issue.status-transition.modal.cancel");+ case "REOPEN":+ return t("issue.status-transition.modal.reopen");+ }+ return "";+});++const handleConfirm = async (+ action: IssueStatusAction,+ comment: string | undefined+) => {+ state.loading = true;+ // TODO+ try {+ await new Promise((r) => setTimeout(r, 1000));++ // notify the issue logic to update issue status+ events.emit("status-changed", { eager: true });++ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.updated"),+ });+ } finally {+ state.loading = false;+ emit("close");+ }++ // Trying to avoid some kind of concurrency and race condition, we fetch the+ // latest snapshot of issue from the server-side and check whether this+ // transition is applicable again.+ // const latestIssue = await useIssueStore().fetchIssueById(issue.value.id);++ // const { action: transition } = props;+ // const applicableList = getApplicableIssueStatusTransitionList(latestIssue);+ // if (!isApplicableTransition(transition, applicableList)) {+ // return cleanup();+ // }++ // changeIssueStatus(transition.to, comment);+ // isTransiting.value = false;+ // emit("updated");+};+</script>diff --git a/frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/Dialog.vue b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vuesimilarity index 53%rename from frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/Dialog.vuerename to frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vueindex 7ed06c2f90..8a924b073f 100644--- a/frontend/src/components/IssueV1/components/Dialog/TaskRolloutActionDialog/Dialog.vue+++ b/frontend/src/components/IssueV1/components/Panel/TaskRolloutActionPanel.vue@@ -1,20 +1,83 @@<template>- <CommonDialog :title="title" :loading="state.loading" @close="$emit('close')">- <Form- :action="action"- :task-list="taskList"- @cancel="$emit('close')"- @confirm="handleConfirm"- />- </CommonDialog>+ <CommonDrawer+ :show="action !== undefined"+ :title="title"+ :loading="state.loading"+ @close="$emit('close')"+ >+ <template #default>+ <div v-if="action" class="flex flex-col gap-y-4">+ <div class="text-sm">+ <label v-if="taskList.length > 1" class="textlabel">+ {{ $t("common.tasks") }}+ </label>+ <ul class="mt-1 max-h-[45vh] overflow-y-auto">+ <li+ v-for="item in distinctTaskList"+ :key="item.task.uid"+ class="text-sm textinfolabel"+ >+ <span class="textinfolabel">+ {{ item.task.title }}+ </span>+ <span v-if="item.similar.length > 0" class="ml-2 text-gray-400">+ {{+ $t("task.n-similar-tasks", {+ count: item.similar.length + 1,+ })+ }}+ </span>+ </li>+ </ul>+ <PlanCheckBar+ v-if="taskList.length === 1 && action === 'ROLLOUT'"+ :allow-run-checks="false"+ :task="taskList[0]"+ class="pt-2"+ />+ </div>+ <div class="flex flex-col gap-y-1">+ <p class="textlabel">+ {{ $t("common.comment") }}+ </p>+ <NInput+ v-model:value="comment"+ type="textarea"+ :placeholder="$t('issue.leave-a-comment')"+ :autosize="{+ minRows: 3,+ maxRows: 10,+ }"+ />+ </div>+ </div>+ </template>+ <template #footer>+ <div v-if="action" class="flex justify-end gap-x-4">+ <NButton @click="$emit('close')">+ {{ $t("common.cancel") }}+ </NButton>+ <NButton+ v-bind="taskRolloutActionButtonProps(action)"+ @click="handleConfirm(action, comment)"+ >+ {{ taskRolloutActionDialogButtonName(action, taskList) }}+ </NButton>+ </div>+ </template>+ </CommonDrawer></template><script setup lang="ts">-import { computed, reactive } from "vue";+import { groupBy } from "lodash-es";+import { computed, reactive, ref } from "vue";import { useI18n } from "vue-i18n";+import { PlanCheckBar } from "@/components/IssueV1/components/PlanCheckSection";import {TaskRolloutAction,stageForTask,+ taskRolloutActionButtonProps,+ taskRolloutActionDialogButtonName,taskRolloutActionDisplayName,taskRunListForTask,useIssueContext,@@ -26,15 +89,13 @@ import {TaskRun,TaskRun_Status,} from "@/types/proto/v1/rollout_service";-import CommonDialog from "../CommonDialog.vue";-import Form from "./Form.vue";type LocalState = {loading: boolean;};const props = defineProps<{- action: TaskRolloutAction;+ action?: TaskRolloutAction;taskList: Task[];}>();const emit = defineEmits<{@@ -46,8 +107,11 @@ const state = reactive<LocalState>({loading: false,});const { issue, events } = useIssueContext();+const comment = ref("");const title = computed(() => {+ if (!props.action) return "";+const action = taskRolloutActionDisplayName(props.action);if (props.taskList.length > 1) {return t("task.action-all-tasks-in-current-stage", { action });@@ -55,6 +119,16 @@ const title = computed(() => {return action;});+const distinctTaskList = computed(() => {+ type DistinctTaskList = { task: Task; similar: Task[] };+ const groups = groupBy(props.taskList, (task) => task.title);++ return Object.keys(groups).map<DistinctTaskList>((taskName) => {+ const [task, ...similar] = groups[taskName];+ return { task, similar };+ });+});+const handleConfirm = async (action: TaskRolloutAction,comment: string | undefineddiff --git a/frontend/src/components/IssueV1/components/Panel/index.ts b/frontend/src/components/IssueV1/components/Panel/index.tsnew file mode 100644index 0000000000..32b6821416--- /dev/null+++ b/frontend/src/components/IssueV1/components/Panel/index.ts@@ -0,0 +1,9 @@+import IssueReviewActionPanel from "./IssueReviewActionPanel.vue";+import IssueStatusActionPanel from "./IssueStatusActionPanel.vue";+import TaskRolloutActionPanel from "./TaskRolloutActionPanel.vue";++export {+ IssueStatusActionPanel,+ IssueReviewActionPanel,+ TaskRolloutActionPanel,+};diff --git a/frontend/src/components/IssueV1/components/index.ts b/frontend/src/components/IssueV1/components/index.tsindex 15df71bdd0..28ee67d0b4 100644--- a/frontend/src/components/IssueV1/components/index.ts+++ b/frontend/src/components/IssueV1/components/index.ts@@ -8,7 +8,7 @@ import StatementSection from "./StatementSection";import TaskListSection from "./TaskListSection";import TaskRunSection from "./TaskRunSection";-export * from "./Dialog";+export * from "./Panel";export {BannerSection,HeaderSection,diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex aa7b3718e2..6a31a054b9 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -317,7 +317,7 @@"warn": "警告","error": "错误"},- "earliest-allowed-time-no-modify": "您无法修改此字段因为您不是该工单的审核人或者它不在待执行状态。",+ "earliest-allowed-time-no-modify": "您无法修改此字段,因为您不是该工单的审核人或者它不在待执行状态。","type": {"bb-task-database-schema-update-ghost-sync": "同步数据","bb-task-database-schema-update-ghost-cutover": "切换表",