Skip to content

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

chore: fix & improve issue comment markdown (#17908)

ecmadaod86f79302edd
diff --git a/backend/store/issue.go b/backend/store/issue.go
index 79a76d5265..74434c1fc7 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -305,11 +305,14 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
where.And("issue.type = ANY(?)", typeStrings)
}
if v := find.Query; v != nil && *v != "" {
+ searchCondition := qb.Q()
if tsQuery := getTSQuery(*v); tsQuery != "" {
from.Space("LEFT JOIN CAST(? AS tsquery) AS query ON TRUE", tsQuery)
- where.And("issue.ts_vector @@ query")
+ searchCondition.Or("issue.ts_vector @@ query")
orderByClause = "ORDER BY ts_rank(issue.ts_vector, query) DESC, issue.id DESC"
}
+ searchCondition.Or("plan.name ILIKE ?", "%"+*v+"%")
+ where.And("(?)", searchCondition)
}
if len(find.StatusList) != 0 {
statusStrings := make([]string, 0, len(find.StatusList))
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
index 038e193237..0abee6f4ec 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentList.vue
@@ -38,7 +38,6 @@
: 'preview'
"
:content="item.comment.comment"
- :issue-list="issueList"
:project="project"
@change="(val: string) => (state.editComment = val)"
@submit="doUpdateComment"
@@ -76,7 +75,6 @@
<MarkdownEditor
mode="editor"
:content="state.newComment"
- :issue-list="issueList"
:project="project"
@change="(val: string) => (state.newComment = val)"
@submit="doCreateComment(state.newComment)"
@@ -100,19 +98,17 @@
import { create } from "@bufbuild/protobuf";
import { PencilIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
-import { computed, onMounted, reactive, ref, watch, watchEffect } from "vue";
+import { computed, onMounted, reactive, watch, watchEffect } from "vue";
import { useRoute } from "vue-router";
import MarkdownEditor from "@/components/MarkdownEditor";
import UserAvatar from "@/components/User/UserAvatar.vue";
import {
useCurrentUserV1,
useIssueCommentStore,
- useIssueV1Store,
useCurrentProjectV1,
extractUserId,
} from "@/store";
import type { ComposedIssue } from "@/types";
-import { isValidProjectName } from "@/types";
import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";
import { ListIssueCommentsRequestSchema } from "@/types/proto-es/v1/issue_service_pb";
import { hasProjectPermissionV2 } from "@/utils";
@@ -136,7 +132,6 @@ const route = useRoute();
const { project } = useCurrentProjectV1();
const { issue } = useIssueContext();
-const issueList = ref<ComposedIssue[]>([]);
const state = reactive<LocalState>({
editCommentMode: false,
@@ -145,23 +140,8 @@ const state = reactive<LocalState>({
});
const currentUser = useCurrentUserV1();
-const issueV1Store = useIssueV1Store();
const issueCommentStore = useIssueCommentStore();
-const prepareIssueListForMarkdownEditor = async () => {
- const project = issue.value.project;
- issueList.value = [];
- if (!isValidProjectName(project)) return;
-
- const list = await issueV1Store.listIssues({
- find: {
- project,
- query: "",
- },
- });
- issueList.value = list.issues;
-};
-
const prepareIssueComments = async () => {
await issueCommentStore.listIssueComments(
create(ListIssueCommentsRequestSchema, {
@@ -269,12 +249,4 @@ onMounted(() => {
}
);
});
-
-watch(
- () => issue.value.project,
- () => {
- prepareIssueListForMarkdownEditor();
- },
- { immediate: true }
-);
</script>
diff --git a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue
index badecf6cfa..013d40061d 100644
--- a/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue
+++ b/frontend/src/components/IssueV1/components/IssueCommentSection/IssueCommentView/IssueCreatedCommentV1.vue
@@ -18,9 +18,7 @@
</div>
<div class="ml-3 min-w-0 flex-1">
- <div
- class="rounded-lg border border-gray-200 bg-white overflow-hidden"
- >
+ <div class="rounded-lg border border-gray-200 bg-white">
<div class="px-3 py-2 bg-gray-50">
<div class="flex items-center justify-between">
<div
@@ -60,7 +58,6 @@
: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"
@@ -93,7 +90,7 @@
import { create } from "@bufbuild/protobuf";
import { PlusIcon, PencilIcon } from "lucide-vue-next";
import { NButton } from "naive-ui";
-import { computed, reactive, ref } from "vue";
+import { computed, reactive } from "vue";
import MarkdownEditor from "@/components/MarkdownEditor";
import UserAvatar from "@/components/User/UserAvatar.vue";
import HumanizeTs from "@/components/misc/HumanizeTs.vue";
@@ -123,8 +120,6 @@ const currentUser = useCurrentUserV1();
const userStore = useUserStore();
const { project } = useCurrentProjectV1();
-const issueList = ref([]);
-
const state = reactive({
isEditing: false,
editContent: "",
diff --git a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
index d018f2ff02..bba746cb57 100644
--- a/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
+++ b/frontend/src/components/MarkdownEditor/MarkdownEditor.vue
@@ -58,29 +58,35 @@
ref="issuePanel"
class="border rounded absolute hidden bg-white shadow-sm z-10"
>
- <ul class="text-sm rounded divide-y divide-solid">
- <li
- v-for="issue in filterIssueList"
- :key="issue.name"
- class="px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center gap-x-2"
- @click="onIssueSelect(issue)"
- >
- <IssueStatusIcon
- :issue-status="issue.status"
- :task-status="issueTaskStatus(issue)"
- />
- <span class="opacity-60">#{{ extractIssueUID(issue.name) }}</span>
- <div class="whitespace-nowrap">
- {{ issue.title }}
- </div>
- </li>
- </ul>
+ <NScrollbar class="max-h-40">
+ <ul class="text-sm rounded divide-y divide-solid">
+ <li
+ v-for="issue in filterIssueList"
+ :key="issue.name"
+ class="px-3 py-2 hover:bg-gray-100 cursor-pointer flex items-center gap-x-2"
+ @click="onIssueSelect(issue)"
+ >
+ <IssueStatusIcon
+ :issue-status="issue.status"
+ :task-status="issueTaskStatus(issue)"
+ />
+ <span class="opacity-60">#{{ extractIssueUID(issue.name) }}</span>
+ <div class="whitespace-nowrap">
+ <HighlightLabelText
+ :text="issue.title"
+ :keyword="issueSearchText"
+ />
+ </div>
+ </li>
+ </ul>
+ </NScrollbar>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
+import { useDebounceFn } from "@vueuse/core";
import {
CodeIcon,
LinkIcon,
@@ -88,11 +94,14 @@ import {
BoldIcon,
HeadingIcon,
} from "lucide-vue-next";
-import { NButton, NTooltip, NTabs, NTab } from "naive-ui";
+import { NButton, NTooltip, NTabs, NTab, NScrollbar } from "naive-ui";
import { nextTick, ref, reactive, watch, toRef, onMounted } from "vue";
import type { Component } from "vue";
import { useI18n } from "vue-i18n";
+import { HighlightLabelText } from "@/components/v2";
+import { useIssueV1Store } from "@/store";
import { type ComposedIssue } from "@/types";
+import { DEBOUNCE_SEARCH_DELAY } from "@/types";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
import { Task_Status } from "@/types/proto-es/v1/rollout_service_pb";
import {
@@ -121,8 +130,7 @@ type EditorMode = "editor" | "preview";
const props = defineProps<{
content: string;
mode: EditorMode;
- project?: Project;
- issueList: ComposedIssue[];
+ project: Project;
placeholder?: string;
autofocus?: boolean;
}>();
@@ -138,7 +146,10 @@ const state = reactive<LocalState>({
content: props.content,
activeTab: props.mode === "preview" ? "preview" : "write",
});
+
const { t } = useI18n();
+const issueV1Store = useIssueV1Store();
+const issueSearchText = ref<string>("");
watch(
() => props.mode,
@@ -457,7 +468,7 @@ const issueTaskStatus = (issue: ComposedIssue) => {
return activeTaskInRollout(issue.rolloutEntity)?.status;
};
-const adjustIssuePanelWithPosition = () => {
+const adjustIssuePanelWithPosition = useDebounceFn(() => {
if (!contentTextArea.value || !issuePanel.value) {
return;
}
@@ -473,21 +484,37 @@ const adjustIssuePanelWithPosition = () => {
const text = `${state.content.slice(0, start)}${
start === state.content.length ? " " : state.content[start]
}`;
- const matches = text.match(/#\d{0,}\s$/);
+ const matches = text.match(/#\S{0,}\s$/);
if (!matches) {
return;
}
- const id = matches[0].slice(1).trimEnd();
- filterIssueList.value = props.issueList
- .filter((issue) => extractIssueUID(issue.name).startsWith(id))
- .slice(0, 5);
+ const query = matches[0].slice(1).trimEnd();
+ const isQuery = Number.isNaN(parseInt(query));
+ issueSearchText.value = isQuery ? query : "";
+
+ issueV1Store
+ .listIssues({
+ find: {
+ project: props.project.name,
+ query: isQuery ? query : "",
+ },
+ })
+ .then((resp) => {
+ if (!isQuery && query) {
+ filterIssueList.value = resp.issues.filter((issue) =>
+ extractIssueUID(issue.name).startsWith(query)
+ );
+ } else {
+ filterIssueList.value = resp.issues;
+ }
+ });
const position = getIssuePanelPosition(contentTextArea.value);
issuePanel.value.style.display = "block";
issuePanel.value.style.left = `${position.x}px`;
issuePanel.value.style.top = `${position.y + 25}px`;
-};
+}, DEBOUNCE_SEARCH_DELAY);
const getIssuePanelPosition = (textArea: HTMLTextAreaElement) => {
const start = textArea.selectionStart;
diff --git a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
index afc902557a..590916418c 100644
--- a/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
+++ b/frontend/src/components/Plan/components/HeaderSection/DescriptionSection.vue
@@ -23,7 +23,6 @@
class="pointer-events-none"
:content="state.description"
:project="project"
- :issue-list="[]"
/>
</div>
</template>
@@ -63,7 +62,6 @@
:autofocus="state.shouldAutoFocus"
:project="project"
:placeholder="$t('plan.description.placeholder')"
- :issue-list="[]"
@change="onUpdateValue"
/>
</div>