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: add description input for plans without issue (#17259)
boojack4b30f2f6deb7
diff --git a/frontend/src/components/Plan/components/HeaderSection/DescriptionInput.vue b/frontend/src/components/Plan/components/HeaderSection/DescriptionInput.vuenew file mode 100644index 0000000000..a273a100bd--- /dev/null+++ b/frontend/src/components/Plan/components/HeaderSection/DescriptionInput.vue@@ -0,0 +1,115 @@+<template>+ <div class="flex-1">+ <NInput+ v-model:value="state.description"+ :placeholder="$t('issue.add-some-description')"+ :disabled="!allowEdit || state.isUpdating"+ :loading="state.isUpdating"+ :style="style"+ size="tiny"+ type="textarea"+ :autosize="{ minRows: 1, maxRows: 3 }"+ @focus="state.isFocused = true"+ @blur="onBlur"+ @update:value="onUpdateValue"+ />+ </div>+</template>++<script setup lang="ts">+import { create } from "@bufbuild/protobuf";+import { NInput } from "naive-ui";+import type { CSSProperties } from "vue";+import { computed, reactive } from "vue";+import { useI18n } from "vue-i18n";+import { planServiceClientConnect } from "@/grpcweb";+import {+ pushNotification,+ useCurrentUserV1,+ extractUserId,+ useCurrentProjectV1,+} from "@/store";+import { UpdatePlanRequestSchema } from "@/types/proto-es/v1/plan_service_pb";+import { PlanSchema } from "@/types/proto-es/v1/plan_service_pb";+import { hasProjectPermissionV2 } from "@/utils";+import { usePlanContext } from "../../logic";++const { t } = useI18n();+const currentUser = useCurrentUserV1();+const { project } = useCurrentProjectV1();+const { isCreating, plan, readonly } = usePlanContext();++const state = reactive({+ isFocused: false,+ isUpdating: false,+ description: plan.value.description,+});++const allowEdit = computed(() => {+ if (readonly.value) {+ return false;+ }+ if (isCreating.value) {+ return true;+ }+ if (extractUserId(plan.value.creator) === currentUser.value.email) {+ return true;+ }+ if (hasProjectPermissionV2(project.value, "bb.plans.update")) {+ return true;+ }+ return false;+});++const style = computed(() => {+ const style: CSSProperties = {+ "--n-color-disabled": "transparent",+ };+ const border = state.isFocused+ ? "1px solid rgb(var(--color-control-border))"+ : "none";+ style["--n-border"] = border;+ style["--n-border-disabled"] = border;++ return style;+});++const onBlur = async () => {+ state.isFocused = false;+ if (isCreating.value) {+ return;+ }++ if (state.description === plan.value.description) {+ return;+ }++ try {+ state.isUpdating = true;+ const planPatch = create(PlanSchema, {+ ...plan.value,+ description: state.description,+ });+ const request = create(UpdatePlanRequestSchema, {+ plan: planPatch,+ updateMask: { paths: ["description"] },+ });+ const response = await planServiceClientConnect.updatePlan(request);+ Object.assign(plan.value, response);+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("common.updated"),+ });+ } finally {+ state.isUpdating = false;+ }+};++const onUpdateValue = (value: string) => {+ if (!isCreating.value) {+ return;+ }+ plan.value.description = value;+};+</script>diff --git a/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue b/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vueindex 8abb7c4a6f..d063b0d2ea 100644--- a/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue+++ b/frontend/src/components/Plan/components/HeaderSection/HeaderSection.vue@@ -1,16 +1,22 @@<template>- <div- class="flex flex-row items-center justify-between gap-2 py-2 px-2 sm:px-4"- >- <NTag v-if="showDraftTag" round>- <template #icon>- <CircleDotDashedIcon class="w-4 h-4" />- </template>- {{ $t("common.draft") }}- </NTag>- <TitleInput />- <div class="flex flex-row items-center justify-end">- <Actions />+ <div class="py-2 px-2 sm:px-4">+ <div class="flex flex-row items-center justify-between gap-2">+ <TitleInput />+ <div class="flex flex-row items-center justify-end">+ <Actions />+ </div>+ </div>+ <div+ v-if="showDraftTag || showDescriptionInput"+ class="flex flex-row items-start justify-start gap-x-1 mt-0.5"+ >+ <NTag v-if="showDraftTag" round size="small">+ <template #icon>+ <CircleDotDashedIcon class="w-4 h-4" />+ </template>+ {{ $t("common.draft") }}+ </NTag>+ <DescriptionInput v-if="showDescriptionInput" /></div></div></template>@@ -21,6 +27,7 @@ import { NTag } from "naive-ui";import { computed } from "vue";import { usePlanContext } from "../../logic";import Actions from "./Actions";+import DescriptionInput from "./DescriptionInput.vue";import TitleInput from "./TitleInput.vue";const { isCreating, plan } = usePlanContext();@@ -28,4 +35,8 @@ const { isCreating, plan } = usePlanContext();const showDraftTag = computed(() => {return !isCreating.value && !plan.value.issue && !plan.value.rollout;});++const showDescriptionInput = computed(() => {+ return !plan.value.issue;+});</script>