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: improve plan description field UX (#17294)
Danny Xu41523ebd5adc
diff --git a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vueindex 5b7d4c9776..a342e7f2b8 100644--- a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue+++ b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue@@ -1,35 +1,72 @@<template>- <div class="flex-1">- <div v-if="!state.isExpanded" class="py-1 truncate pr-4">- <span class="text-sm text-control mr-2"- >{{ $t("common.description") }}:</span+ <div ref="descriptionRef" class="flex-1">+ <div v-if="!state.isExpanded" class="py-1">+ <button+ v-if="!state.description && allowEdit"+ class="flex items-center gap-1 text-sm italic text-gray-400 hover:text-gray-600 hover:bg-gray-50 px-2 py-0.5 -ml-2 rounded"+ @click="handleExpand($event)">- <span- class="text-sm cursor-text hover:opacity-80"- :class="state.description ? 'text-gray-700' : 'italic text-gray-400'"- @click="toggleExpanded"+ <svg+ class="w-4 h-4"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M12 4v16m8-8H4"+ />+ </svg>+ {{ $t("plan.description.placeholder") }}+ </button>+ <div+ v-else+ class="cursor-pointer hover:bg-gray-50 px-3 py-2 -ml-3 rounded border border-transparent hover:border-gray-200 transition-colors"+ @click="handleExpand($event)">- {{ state.description || $t("plan.description.placeholder") }}- </span>+ <div class="description-preview">+ <MarkdownEditor+ :content="state.description"+ mode="preview"+ :project="project"+ :issue-list="[]"+ class="pointer-events-none"+ />+ </div>+ </div></div>- <div v-else>- <div class="flex items-center justify-between mt-2">+ <div v-else class="py-2">+ <div class="flex items-center justify-between mb-3"><span class="text-base font-medium">{{$t("common.description")}}</span>- <NButton- size="tiny"- type="default"- @click="toggleExpanded"+ <button+ class="inline-flex items-center gap-1 px-3 py-1 text-sm font-medium text-gray-600 hover:text-gray-900 hover:bg-gray-100 border border-gray-300 rounded-md":disabled="state.isUpdating"+ @click="handleCollapse">+ <svg+ class="w-4 h-4"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M5 15l7-7 7 7"+ />+ </svg>{{ $t("common.collapse") }}- </NButton>+ </button></div><MarkdownEditor:content="state.description"mode="editor"- :autofocus="true"+ :autofocus="state.shouldAutoFocus":project="project":placeholder="$t('plan.description.placeholder')":issue-list="[]"@@ -41,8 +78,7 @@<script setup lang="ts">import { create } from "@bufbuild/protobuf";-import { NButton } from "naive-ui";-import { computed, reactive, watch } from "vue";+import { computed, reactive, watch, onMounted, onUnmounted, ref } from "vue";import { useI18n } from "vue-i18n";import MarkdownEditor from "@/components/MarkdownEditor";import { planServiceClientConnect } from "@/grpcweb";@@ -62,10 +98,14 @@ const currentUser = useCurrentUserV1();const { project } = useCurrentProjectV1();const { isCreating, plan, readonly } = usePlanContext();+const descriptionRef = ref<HTMLDivElement>();+const state = reactive({isUpdating: false,description: plan.value.description,isExpanded: false,+ shouldAutoFocus: false,+ justExpanded: false,});const allowEdit = computed(() => {@@ -84,10 +124,42 @@ const allowEdit = computed(() => {return false;});-const toggleExpanded = () => {- state.isExpanded = !state.isExpanded;+const handleExpand = (event: MouseEvent) => {+ if (!allowEdit.value) return;+ event.stopPropagation();+ state.shouldAutoFocus = true;+ state.isExpanded = true;+ state.justExpanded = true;+ // Add a small delay before allowing click outside to work+ setTimeout(() => {+ state.shouldAutoFocus = false;+ state.justExpanded = false;+ }, 100);};+const handleCollapse = () => {+ state.isExpanded = false;+};++const handleClickOutside = (event: MouseEvent) => {+ if (!state.isExpanded) return;+ if (state.justExpanded) return; // Prevent immediate collapse after expanding+ if (!descriptionRef.value) return;++ const target = event.target as Node;+ if (!descriptionRef.value.contains(target)) {+ state.isExpanded = false;+ }+};++onMounted(() => {+ document.addEventListener("click", handleClickOutside);+});++onUnmounted(() => {+ document.removeEventListener("click", handleClickOutside);+});+const onUpdateValue = (value: string) => {state.description = value;if (isCreating.value) {@@ -147,3 +219,58 @@ watch({ immediate: true });</script>++<style scoped>+.description-preview {+ max-height: 150px;+ overflow: hidden;+ position: relative;+}++.description-preview::after {+ content: "";+ position: absolute;+ bottom: 0;+ left: 0;+ right: 0;+ height: 30px;+ background: linear-gradient(+ to bottom,+ rgba(255, 255, 255, 0),+ rgba(255, 255, 255, 1)+ );+ pointer-events: none;+}++/* Make markdown content more compact in preview */+.description-preview :deep(*) {+ margin-top: 0 !important;+ margin-bottom: 0.5rem !important;+}++.description-preview :deep(p:last-child),+.description-preview :deep(ul:last-child),+.description-preview :deep(ol:last-child) {+ margin-bottom: 0 !important;+}++.description-preview :deep(h1),+.description-preview :deep(h2),+.description-preview :deep(h3) {+ margin-bottom: 0.75rem !important;+}++.description-preview :deep(ul),+.description-preview :deep(ol) {+ padding-left: 1.5rem !important;+}++.description-preview :deep(li) {+ margin-bottom: 0.25rem !important;+}++.description-preview :deep(pre) {+ padding: 0.5rem !important;+ margin-bottom: 0.5rem !important;+}+</style>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex ebedac800a..8cefc323e6 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1174,7 +1174,7 @@"reopen-confirm": "Are you sure to reopen this plan?"},"description": {- "placeholder": "Add your description here for this plan..."+ "placeholder": "Add a description"}},"rollout": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 73c54dce71..23005525ab 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1174,7 +1174,7 @@"reopen-confirm": "¿Estás seguro de que deseas reabrir este plan?"},"description": {- "placeholder": "Añade tu descripción aquí para este plan..."+ "placeholder": "Añadir descripción"}},"rollout": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 936821ff30..bec77d5523 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1174,7 +1174,7 @@"reopen-confirm": "このプランを再開してもよろしいですか?"},"description": {- "placeholder": "このプランの説明をここに追加してください..."+ "placeholder": "説明を追加"}},"rollout": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 8f5b027d7e..3f9d15aa82 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1174,7 +1174,7 @@"reopen-confirm": "Bạn có chắc chắn muốn mở lại kế hoạch này không?"},"description": {- "placeholder": "Thêm mô tả của bạn vào đây cho kế hoạch này..."+ "placeholder": "Thêm mô tả"}},"rollout": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex a235cc8ffa..d21c6e1735 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1174,7 +1174,7 @@"reopen-confirm": "确定重新开启该变更计划?"},"description": {- "placeholder": "在此添加该更变计划的描述..."+ "placeholder": "添加描述"}},"rollout": {