Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: add issue created comment with editable description (#17301)

boojack905fc57793bb
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
index f16cd465ec..6c8d710641 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
@@ -1,7 +1,7 @@
<template>
<div class="flex flex-col">
<ul>
- <IssueCreatedComment :issue-comments="issueComments" :issue="issue" />
+ <IssueCreatedCommentV1 :issue-comments="issueComments" :issue="issue" />
<IssueCommentView
class="group"
v-for="(item, index) in issueComments"
@@ -45,12 +45,13 @@
state.editCommentMode &&
state.activeComment?.name === item.comment.name
"
- class="flex space-x-2 mt-4 items-center justify-end"
+ class="flex space-x-2 mt-2 items-center justify-end"
>
- <NButton quaternary @click.prevent="cancelEditComment">
+ <NButton quaternary size="small" @click.prevent="cancelEditComment">
{{ $t("common.cancel") }}
</NButton>
<NButton
+ size="small"
:disabled="!allowUpdateComment"
@click.prevent="doUpdateComment"
>
@@ -118,7 +119,7 @@ import {
isUserEditableComment,
type DistinctIssueComment,
} from "./IssueCommentView";
-import IssueCreatedComment from "./IssueCommentView/IssueCreatedComment.vue";
+import IssueCreatedCommentV1 from "./IssueCommentView/IssueCreatedCommentV1.vue";
interface LocalState {
editCommentMode: boolean;
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
index d87a0a2dc1..936e3d0d4d 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCommentAction.vue
@@ -1,7 +1,14 @@
<template>
- <div class="ml-3 min-w-0 flex-1">
- <div class="rounded-lg border border-gray-200 bg-white overflow-hidden">
- <div class="px-4 py-2.5 bg-gray-50">
+ <div class="min-w-0 flex-1">
+ <div
+ class="rounded-lg border overflow-hidden"
+ :class="
+ $slots.comment
+ ? 'ml-3 border-gray-200 bg-white'
+ : 'ml-1 border-transparent'
+ "
+ >
+ <div class="px-3 py-2" :class="$slots.comment ? 'bg-gray-50' : ''">
<div class="flex items-center justify-between">
<div class="flex items-center gap-x-2 text-sm min-w-0 flex-wrap">
<ActionCreator
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedComment.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedComment.vue
deleted file mode 100644
index a4917e37c4..0000000000
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedComment.vue
+++ /dev/null
@@ -1,48 +0,0 @@
-<template>
- <li>
- <div class="relative pb-4">
- <span
- v-if="issueComments.length > 0"
- class="absolute left-4 -ml-px h-full w-0.5 bg-block-border"
- aria-hidden="true"
- ></span>
- <div class="relative flex items-start">
- <div>
- <div class="relative pl-0.5">
- <div
- class="w-7 h-7 bg-control-bg rounded-full ring-4 ring-white flex items-center justify-center"
- >
- <PlusIcon class="w-5 h-5 text-control" />
- </div>
- </div>
- </div>
-
- <div class="ml-3 min-w-0 flex-1">
- <div class="min-w-0 flex-1 pt-1 flex justify-between">
- <div class="text-sm text-control-light space-x-1">
- <ActionCreator :creator="issue.creator" />
- <span>{{ $t("activity.sentence.created-issue") }}</span>
- <HumanizeTs
- :ts="getTimeForPbTimestampProtoEs(issue.createTime, 0) / 1000"
- class="ml-1 text-gray-400"
- />
- </div>
- </div>
- </div>
- </div>
- </div>
- </li>
-</template>
-
-<script lang="ts" setup>
-import { PlusIcon } from "lucide-vue-next";
-import HumanizeTs from "@/components/misc/HumanizeTs.vue";
-import { getTimeForPbTimestampProtoEs, type ComposedIssue } from "@/types";
-import ActionCreator from "./ActionCreator.vue";
-import type { DistinctIssueComment } from "./common";
-
-defineProps<{
- issue: ComposedIssue;
- issueComments: DistinctIssueComment[];
-}>();
-</script>
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue
new file mode 100644
index 0000000000..389b11f85c
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue
@@ -0,0 +1,209 @@
+<template>
+ <li>
+ <div class="relative pb-4">
+ <span
+ v-if="issueComments.length > 0"
+ class="absolute left-4 -ml-px h-full w-0.5 bg-block-border"
+ aria-hidden="true"
+ ></span>
+ <div class="relative flex items-start">
+ <div class="relative">
+ <div class="pt-1.5 bg-white"></div>
+ <UserAvatar :user="creator" />
+ <div
+ class="absolute -bottom-1 -right-1 w-4 h-4 bg-control-bg rounded-full ring-2 ring-white flex items-center justify-center"
+ >
+ <PlusIcon class="w-3 h-3 text-control" />
+ </div>
+ </div>
+
+ <div class="ml-3 min-w-0 flex-1">
+ <div
+ class="rounded-lg border border-gray-200 bg-white overflow-hidden"
+ >
+ <div class="px-3 py-2 bg-gray-50">
+ <div class="flex items-center justify-between">
+ <div
+ class="flex items-center gap-x-2 text-sm min-w-0 flex-wrap"
+ >
+ <ActionCreator :creator="issue.creator" />
+ <span class="text-gray-600 break-words min-w-0">{{
+ $t("activity.sentence.created-issue")
+ }}</span>
+ <HumanizeTs
+ :ts="
+ getTimeForPbTimestampProtoEs(issue.createTime, 0) / 1000
+ "
+ class="text-gray-500"
+ />
+ </div>
+ <NButton
+ v-if="allowEdit && !state.isEditing"
+ quaternary
+ size="tiny"
+ @click.prevent="startEdit"
+ >
+ <PencilIcon class="w-3.5 h-3.5" />
+ </NButton>
+ </div>
+ </div>
+ <div
+ class="px-4 py-3 border-t border-gray-200 text-sm text-gray-700"
+ >
+ <p v-if="!state.isEditing && !description">
+ <i class="text-gray-400 italic">{{
+ $t("issue.no-description-provided")
+ }}</i>
+ </p>
+ <MarkdownEditor
+ v-else
+ :mode="state.isEditing ? 'editor' : 'preview'"
+ :content="state.isEditing ? state.editContent : description"
+ :project="project"
+ :issue-list="issueList"
+ @change="(val: string) => (state.editContent = val)"
+ @submit="saveEdit"
+ @cancel="cancelEdit"
+ />
+ <div
+ v-if="state.isEditing"
+ class="flex space-x-2 mt-2 items-center justify-end"
+ >
+ <NButton quaternary size="small" @click.prevent="cancelEdit">
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ size="small"
+ :disabled="!allowSave"
+ :loading="state.isSaving"
+ @click.prevent="saveEdit"
+ >
+ {{ $t("common.save") }}
+ </NButton>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </li>
+</template>
+
+<script lang="ts" setup>
+import { create } from "@bufbuild/protobuf";
+import { PlusIcon, PencilIcon } from "lucide-vue-next";
+import { NButton } from "naive-ui";
+import { computed, reactive, ref } from "vue";
+import MarkdownEditor from "@/components/MarkdownEditor";
+import UserAvatar from "@/components/User/UserAvatar.vue";
+import HumanizeTs from "@/components/misc/HumanizeTs.vue";
+import { planServiceClientConnect, issueServiceClientConnect } from "@/grpcweb";
+import { useUserStore, useCurrentUserV1, extractUserId } from "@/store";
+import { useCurrentProjectV1 } from "@/store";
+import { getTimeForPbTimestampProtoEs, type ComposedIssue } from "@/types";
+import { UpdateIssueRequestSchema } from "@/types/proto-es/v1/issue_service_pb";
+import {
+ UpdatePlanRequestSchema,
+ PlanSchema,
+} from "@/types/proto-es/v1/plan_service_pb";
+import { hasProjectPermissionV2 } from "@/utils";
+import ActionCreator from "./ActionCreator.vue";
+import type { DistinctIssueComment } from "./common";
+
+const props = defineProps<{
+ issue: ComposedIssue;
+ issueComments: DistinctIssueComment[];
+}>();
+
+const userStore = useUserStore();
+const currentUser = useCurrentUserV1();
+const { project } = useCurrentProjectV1();
+
+const issueList = ref([]);
+
+const state = reactive({
+ isEditing: false,
+ editContent: "",
+ isSaving: false,
+});
+
+const creator = computed(() => {
+ return userStore.getUserByIdentifier(props.issue.creator);
+});
+
+const description = computed(() => {
+ // Try to get description from plan first, then fallback to issue description
+ return (
+ (props.issue.plan
+ ? props.issue.planEntity?.description
+ : props.issue.description) || ""
+ );
+});
+
+const allowEdit = computed(() => {
+ // Check if user is the creator or has permission to update
+ if (extractUserId(props.issue.creator) === currentUser.value.email) {
+ return true;
+ }
+ // Check for plan update permission if we have a plan, otherwise issue update
+ if (props.issue.planEntity) {
+ return hasProjectPermissionV2(project.value, "bb.plans.update");
+ }
+ return hasProjectPermissionV2(project.value, "bb.issues.update");
+});
+
+const allowSave = computed(() => {
+ return state.editContent !== description.value;
+});
+
+const startEdit = () => {
+ state.editContent = description.value;
+ state.isEditing = true;
+};
+
+const cancelEdit = () => {
+ state.isEditing = false;
+ state.editContent = "";
+};
+
+const saveEdit = async () => {
+ if (!allowSave.value) return;
+
+ try {
+ state.isSaving = true;
+
+ if (props.issue.plan) {
+ // Update plan description
+ const planPatch = create(PlanSchema, {
+ name: props.issue.plan,
+ description: state.editContent,
+ });
+ const request = create(UpdatePlanRequestSchema, {
+ plan: planPatch,
+ updateMask: { paths: ["description"] },
+ });
+ const response = await planServiceClientConnect.updatePlan(request);
+ if (props.issue.planEntity) {
+ Object.assign(props.issue.planEntity, response);
+ }
+ } else {
+ // Update issue description
+ const request = create(UpdateIssueRequestSchema, {
+ issue: {
+ ...props.issue,
+ description: state.editContent,
+ },
+ updateMask: { paths: ["description"] },
+ });
+ const response = await issueServiceClientConnect.updateIssue(request);
+ Object.assign(props.issue, response);
+ }
+
+ cancelEdit();
+ } catch (error) {
+ console.error("Failed to update description:", error);
+ } finally {
+ state.isSaving = false;
+ }
+};
+</script>
diff --git a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
index 3f9cfb0985..01a3d50b99 100644
--- a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
+++ b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
@@ -4,7 +4,8 @@
v-if="mode === 'editor'"
v-model:value="state.activeTab"
type="line"
- class="mb-3"
+ :size="'small'"
+ class="mb-2"
@update:value="handleTabChange"
>
<NTab name="write" :tab="$t('issue.comment-editor.write')" />
diff --git a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
index a342e7f2b8..afc902557a 100644
--- a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
@@ -1,67 +1,61 @@
<template>
- <div ref="descriptionRef" class="flex-1">
- <div v-if="!state.isExpanded" class="py-1">
- <button
+ <div class="flex-1">
+ <template v-if="!state.isExpanded">
+ <NButton
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"
+ text
+ size="small"
+ class="italic opacity-60"
@click="handleExpand($event)"
>
- <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>
+ <template #icon>
+ <PlusIcon class="w-4 h-4" />
+ </template>
{{ $t("plan.description.placeholder") }}
- </button>
+ </NButton>
<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"
+ class="mt-1 cursor-pointer px-2 py-1 rounded-md border border-transparent hover:border-gray-200 transition-all duration-200"
@click="handleExpand($event)"
>
- <div class="description-preview">
- <MarkdownEditor
- :content="state.description"
- mode="preview"
- :project="project"
- :issue-list="[]"
- class="pointer-events-none"
- />
- </div>
+ <MarkdownEditor
+ mode="preview"
+ class="pointer-events-none"
+ :content="state.description"
+ :project="project"
+ :issue-list="[]"
+ />
</div>
- </div>
+ </template>
<div v-else class="py-2">
- <div class="flex items-center justify-between mb-3">
+ <div class="flex items-center justify-between">
<span class="text-base font-medium">{{
$t("common.description")
}}</span>
- <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") }}
- </button>
+ <div class="flex items-center gap-2">
+ <template v-if="!isCreating">
+ <NButton
+ size="small"
+ :disabled="
+ state.isUpdating ||
+ !allowEdit ||
+ state.description === plan.description
+ "
+ @click="handleSave"
+ >
+ {{ $t("common.save") }}
+ </NButton>
+ <NButton size="small" quaternary @click="handleCancel">
+ {{ $t("common.cancel") }}
+ </NButton>
+ </template>
+ <NButton v-else size="tiny" @click="handleCancel">
+ <template #icon>
+ <ChevronUpIcon class="w-4 h-4" />
+ </template>
+ {{ $t("common.collapse") }}
+ </NButton>
+ </div>
</div>
<MarkdownEditor
:content="state.description"
@@ -78,27 +72,22 @@
<script setup lang="ts">
import { create } from "@bufbuild/protobuf";
-import { computed, reactive, watch, onMounted, onUnmounted, ref } from "vue";
-import { useI18n } from "vue-i18n";
+import { PlusIcon, ChevronUpIcon } from "lucide-vue-next";
+import { NButton } from "naive-ui";
+import { computed, reactive, watch } from "vue";
import MarkdownEditor from "@/components/MarkdownEditor";
+import { useResourcePoller } from "@/components/Plan/logic/poller";
import { planServiceClientConnect } from "@/grpcweb";
-import {
- pushNotification,
- useCurrentUserV1,
- extractUserId,
- useCurrentProjectV1,
-} from "@/store";
+import { 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 descriptionRef = ref<HTMLDivElement>();
+const { refreshResources } = useResourcePoller();
const state = reactive({
isUpdating: false,
@@ -137,78 +126,49 @@ const handleExpand = (event: MouseEvent) => {
}, 100);
};
-const handleCollapse = () => {
+const handleCancel = () => {
+ state.description = plan.value.description;
state.isExpanded = false;
+ if (isCreating.value) {
+ plan.value.description = state.description;
+ }
};
-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)) {
+const handleSave = async () => {
+ if (isCreating.value) {
+ plan.value.description = state.description;
state.isExpanded = false;
+ return;
}
-};
-onMounted(() => {
- document.addEventListener("click", handleClickOutside);
-});
+ if (!allowEdit.value) return;
-onUnmounted(() => {
- document.removeEventListener("click", handleClickOutside);
-});
+ 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);
+ refreshResources(["plan"], true /** force */);
+ state.isExpanded = false;
+ } finally {
+ state.isUpdating = false;
+ }
+};
const onUpdateValue = (value: string) => {
state.description = value;
if (isCreating.value) {
- plan.value.description = value;
+ plan.value.description = state.description;
}
};
-let debounceTimer: NodeJS.Timeout | null = null;
-
-watch(
- () => state.description,
- (newValue) => {
- if (isCreating.value || !allowEdit.value) {
- return;
- }
-
- if (newValue === plan.value.description) {
- return;
- }
-
- if (debounceTimer) {
- clearTimeout(debounceTimer);
- }
-
- debounceTimer = setTimeout(async () => {
- 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;
- }
- }, 1000);
- }
-);
-
watch(
() => plan.value.description,
(newValue) => {
@@ -219,58 +179,3 @@ 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/components/Plan/components/IssueReviewView/DescriptionSection/DescriptionSection.vue b/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/DescriptionSection.vue
deleted file mode 100644
index ceed4e1d04..0000000000
--- a/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/DescriptionSection.vue
+++ /dev/null
@@ -1,222 +0,0 @@
-<template>
- <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)"
- >
- <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)"
- >
- <MarkdownEditor
- :content="state.description"
- mode="preview"
- :project="project"
- :issue-list="[]"
- class="pointer-events-none"
- />
- </div>
- </div>
- <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>
- <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") }}
- </button>
- </div>
- <MarkdownEditor
- :content="state.description"
- mode="editor"
- :autofocus="state.shouldAutoFocus"
- :project="project"
- :placeholder="$t('plan.description.placeholder')"
- :issue-list="[]"
- @change="onUpdateValue"
- />
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { create } from "@bufbuild/protobuf";
-import { computed, reactive, watch, onMounted, onUnmounted, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import MarkdownEditor from "@/components/MarkdownEditor";
-import { useResourcePoller } from "@/components/Plan/logic/poller";
-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 "../../..";
-
-const { t } = useI18n();
-const currentUser = useCurrentUserV1();
-const { project } = useCurrentProjectV1();
-const { isCreating, plan, readonly } = usePlanContext();
-const { refreshResources } = useResourcePoller();
-
-const descriptionRef = ref<HTMLDivElement>();
-
-const state = reactive({
- isUpdating: false,
- description: plan.value.description,
- isExpanded: false,
- shouldAutoFocus: false,
- justExpanded: false,
-});
-
-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 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) {
- plan.value.description = value;
- }
-};
-
-let debounceTimer: NodeJS.Timeout | null = null;
-
-watch(
- () => state.description,
- (newValue) => {
- if (isCreating.value || !allowEdit.value) {
- return;
- }
-
- if (newValue === plan.value.description) {
- return;
- }
-
- if (debounceTimer) {
- clearTimeout(debounceTimer);
- }
-
- debounceTimer = setTimeout(async () => {
- 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);
- refreshResources(["plan"], true /** force */);
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
- } finally {
- state.isUpdating = false;
- }
- }, 1000);
- }
-);
-
-watch(
- () => plan.value.description,
- (newValue) => {
- if (state.description !== newValue) {
- state.description = newValue;
- }
- },
- { immediate: true }
-);
-</script>
diff --git a/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/index.ts b/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/index.ts
deleted file mode 100644
index ba70462a80..0000000000
--- a/frontend/src/components/Plan/components/IssueReviewView/DescriptionSection/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default as DescriptionSection } from "./DescriptionSection.vue";
diff --git a/frontend/src/components/Plan/components/IssueReviewView/IssueReviewView.vue b/frontend/src/components/Plan/components/IssueReviewView/IssueReviewView.vue
index 956f5c4bb0..45a6fc4d93 100644
--- a/frontend/src/components/Plan/components/IssueReviewView/IssueReviewView.vue
+++ b/frontend/src/components/Plan/components/IssueReviewView/IssueReviewView.vue
@@ -1,11 +1,8 @@
<template>
<div class="flex-1 flex w-full">
<!-- Left Panel - Activity -->
- <div class="flex-1 shrink px-4 py-4 space-y-4">
- <DescriptionSection />
-
+ <div class="flex-1 shrink p-4 space-y-4">
<OverviewSection v-if="shouldShowOverview" />
-
<ActivitySection />
</div>
@@ -24,7 +21,6 @@ import { Issue_Type, IssueStatus } from "@/types/proto-es/v1/issue_service_pb";
import { hasProjectPermissionV2 } from "@/utils";
import { usePlanContextWithIssue } from "../..";
import { ActivitySection } from "./ActivitySection";
-import { DescriptionSection } from "./DescriptionSection";
import OverviewSection from "./OverviewSection.vue";
import { Sidebar } from "./Sidebar";
@@ -55,6 +51,7 @@ const allowChange = computed(() => {
const shouldShowOverview = computed(() => {
return issue.value.type === Issue_Type.DATABASE_CHANGE || rollout?.value;
});
+
// TODO(steven): remove ComposedIssue.
const composedIssue = computed(() => {
const composedIssue = issue.value as ComposedIssue;
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 967eb6f6e2..db64e064de 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -860,6 +860,7 @@
},
"add-some-description": "Add some description...",
"leave-a-comment": "Leave a comment...",
+ "no-description-provided": "No description provided",
"comment-editor": {
"write": "Write",
"preview": "Preview",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 19fcb3467f..bc31721629 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -860,6 +860,7 @@
},
"add-some-description": "Agregar alguna descripción...",
"leave-a-comment": "Dejar un comentario...",
+ "no-description-provided": "No se proporcionó ninguna descripción",
"comment-editor": {
"write": "Escribir",
"preview": "Vista previa",
@@ -2910,4 +2911,4 @@
"last-visit": "Última visita",
"changelog-for-version": "Registro de cambios para {version}"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 9efa1330cd..43b230d792 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -860,6 +860,7 @@
},
"add-some-description": "説明を追加してください…",
"leave-a-comment": "コメントを残す…",
+ "no-description-provided": "説明なし",
"comment-editor": {
"write": "編集",
"preview": "プレビュー",
@@ -2910,4 +2911,4 @@
"last-visit": "最終訪問",
"changelog-for-version": "{version} の変更履歴"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 98a7187685..a3f3b10ab8 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -860,6 +860,7 @@
},
"add-some-description": "Thêm mô tả...",
"leave-a-comment": "Để lại bình luận...",
+ "no-description-provided": "Không có mô tả nào được cung cấp",
"comment-editor": {
"write": "Viết",
"preview": "Xem trước",
@@ -2910,4 +2911,4 @@
"last-visit": "Lần truy cập cuối",
"changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f004ac862a..c1d2131474 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -860,6 +860,7 @@
},
"add-some-description": "添加一些描述…",
"leave-a-comment": "发表一条评论…",
+ "no-description-provided": "未提供描述",
"comment-editor": {
"write": "编辑",
"preview": "预览",
@@ -2910,4 +2911,4 @@
"last-visit": "上次访问",
"changelog-for-version": "{version} 的更新日志"
}
-}
+}
\ No newline at end of file