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: optimize issue labels (#11950)
ecmadaod4923b9e738f
diff --git a/frontend/src/components/IssueV1/components/IssueLabelSelector.vue b/frontend/src/components/IssueV1/components/IssueLabelSelector.vuenew file mode 100644index 0000000000..ea5dcbff7c--- /dev/null+++ b/frontend/src/components/IssueV1/components/IssueLabelSelector.vue@@ -0,0 +1,104 @@+<template>+ <NSelect+ :multiple="true"+ :options="options"+ :disabled="disabled"+ :size="size"+ :consistent-menu-width="true"+ :max-tag-count="maxTagCount"+ :render-label="renderLabel"+ :render-tag="renderTag"+ :value="issueLabels"+ @update:value="onLablesUpdate"+ />+</template>++<script setup lang="ts">+import { NCheckbox, NSelect, NTag } from "naive-ui";+import type { SelectOption } from "naive-ui";+import type { SelectBaseOption } from "naive-ui/lib/select/src/interface";+import { computed, h } from "vue";+import { Label } from "@/types/proto/v1/project_service";++type IsseuLabelOption = SelectOption & {+ value: string;+ color: string;+};++const props = withDefaults(+ defineProps<{+ disabled: boolean;+ selected: string[];+ labels: Label[];+ size: "small" | "medium" | "large";+ maxTagCount: number | "responsive";+ }>(),+ {+ size: "medium",+ maxTagCount: "responsive",+ }+);++const emit = defineEmits<{+ (event: "update:selected", selected: string[]): void;+}>();++const issueLabels = computed(() => {+ const pool = new Set(props.labels.map((label) => label.value));+ return props.selected.filter((label) => pool.has(label));+});++const options = computed(() => {+ return props.labels.map<IsseuLabelOption>((label) => ({+ label: label.value,+ value: label.value,+ color: label.color,+ }));+});++const onLablesUpdate = async (labels: string[]) => {+ emit("update:selected", labels);+};++const renderLabel = (option: IsseuLabelOption, selected: boolean) => {+ const { color, value } = option as IsseuLabelOption;+ return h("div", { class: "flex items-center gap-x-2" }, [+ h(NCheckbox, { checked: selected, size: "small" }),+ h("div", {+ class: "w-4 h-4 rounded cursor-pointer relative",+ style: `background-color: ${color};`,+ onClick: () => {},+ }),+ value,+ ]);+};++const renderTag = ({+ option,+ handleClose,+}: {+ option: SelectBaseOption;+ handleClose: () => void;+}) => {+ const { color, value } = option as IsseuLabelOption;++ return h(+ NTag,+ {+ size: props.size,+ closable: true,+ onClose: handleClose,+ },+ {+ default: () =>+ h("div", { class: "flex items-center gap-x-2" }, [+ h("div", {+ class: "w-4 h-4 rounded",+ style: `background-color: ${color};`,+ }),+ value,+ ]),+ }+ );+};+</script>diff --git a/frontend/src/components/IssueV1/components/IssueTableV1.vue b/frontend/src/components/IssueV1/components/IssueTableV1.vueindex 7c2d369a0d..dfe7c67349 100644--- a/frontend/src/components/IssueV1/components/IssueTableV1.vue+++ b/frontend/src/components/IssueV1/components/IssueTableV1.vue@@ -40,7 +40,7 @@<script lang="ts" setup>import { useElementSize } from "@vueuse/core";import type { DataTableColumn } from "naive-ui";-import { NPerformantEllipsis, NDataTable, NDynamicTags, NTag } from "naive-ui";+import { NPerformantEllipsis, NDataTable } from "naive-ui";import { reactive, computed, watch, ref, h } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";@@ -61,6 +61,7 @@ import {extractProjectResourceName,humanizeTs,} from "@/utils";+import IssueLabelSelector from "./IssueLabelSelector.vue";import IssueStatusIconWithTaskSummary from "./IssueStatusIconWithTaskSummary.vue";type Mode = "ALL" | "PROJECT";@@ -129,6 +130,7 @@ const columnList = computed((): DataTableColumn<ComposedIssue>[] => {title: t("common.labels"),resizable: true,minWidth: 120,+ hide: !showExtendedColumns.value,render: (issue) => {const labelMap: Map<string, Label> =issue.projectEntity.issueLabels.reduce((map, label) => {@@ -136,26 +138,17 @@ const columnList = computed((): DataTableColumn<ComposedIssue>[] => {return map;}, new Map<string, Label>());- return h(NDynamicTags, {- size: "small",+ const labels = issue.labels.filter((label) => labelMap.has(label));+ if (labels.length === 0) {+ return h("span", {}, "-");+ }++ return h(IssueLabelSelector, {disabled: true,- class: "issue-row-dynamic-tags",- value: issue.labels.filter((label) => labelMap.has(label)),- renderTag: (value: string) =>- h(- NTag,- { closable: false, size: "small" },- {- default: () =>- h("div", { class: "flex items-center gap-x-2" }, [- h("div", {- class: "w-4 h-4 rounded cursor-pointer relative",- style: `background-color: ${labelMap.get(value)?.color};`,- }),- value,- ]),- }- ),+ selected: labels,+ size: "small",+ maxTagCount: "responsive",+ labels: issue.projectEntity.issueLabels,});},},@@ -409,7 +402,12 @@ const isIssueExpanded = (issue: ComposedIssue): boolean => {</script><style scoped lang="postcss">-:deep(.issue-row-dynamic-tags) > :last-child {+:deep(.n-base-selection-tags) {+ @apply !bg-transparent !p-0;+}+:deep(.n-base-suffix),+:deep(.n-base-selection__border),+:deep(.n-base-selection__state-border) {@apply !hidden;}</style>diff --git a/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue b/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vueindex 6f0238c726..33c015dc90 100644--- a/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue+++ b/frontend/src/components/IssueV1/components/Sidebar/IssueLabels.vue@@ -3,37 +3,26 @@<div class="flex items-center gap-x-1 textlabel"><span>{{ $t("common.labels") }}</span></div>- <NSelect- :multiple="true"- :options="options"+ <IssueLabelSelector:disabled="!hasEditPermission"- :consistent-menu-width="true"- max-tag-count="responsive"- :render-label="renderLabel"- :render-tag="renderTag"- :value="issueLabels"- @update:value="onLablesUpdate"+ :selected="issue.labels"+ :labels="issue.projectEntity.issueLabels"+ :size="'medium'"+ @update:selected="onLablesUpdate"/></div></template><script setup lang="ts">-import { NCheckbox, NSelect, NTag } from "naive-ui";-import type { SelectOption } from "naive-ui";-import type { SelectBaseOption } from "naive-ui/lib/select/src/interface";-import { computed, h } from "vue";+import { computed } from "vue";import { useI18n } from "vue-i18n";+import IssueLabelSelector from "@/components/IssueV1/components/IssueLabelSelector.vue";import { useIssueContext } from "@/components/IssueV1/logic";import { issueServiceClient } from "@/grpcweb";import { pushNotification, useCurrentUserV1 } from "@/store";import { Issue } from "@/types/proto/v1/issue_service";import { hasProjectPermissionV2 } from "@/utils";-type IsseuLabelOption = SelectOption & {- value: string;- color: string;-};-const { isCreating, issue } = useIssueContext();const { t } = useI18n();const currentUser = useCurrentUserV1();@@ -46,23 +35,6 @@ const hasEditPermission = computed(() =>));-const issueLabels = computed(() => {- const pool = new Set(- issue.value.projectEntity.issueLabels.map((label) => label.value)- );- return issue.value.labels.filter((label) => pool.has(label));-});--const options = computed(() => {- return issue.value.projectEntity.issueLabels.map<IsseuLabelOption>(- (label) => ({- label: label.value,- value: label.value,- color: label.color,- })- );-});-const onLablesUpdate = async (labels: string[]) => {if (isCreating.value) {issue.value.labels = labels;@@ -83,42 +55,4 @@ const onLablesUpdate = async (labels: string[]) => {});}};--const renderLabel = (option: IsseuLabelOption, selected: boolean) => {- const { color, value } = option as IsseuLabelOption;- return h("div", { class: "flex items-center gap-x-2" }, [- h(NCheckbox, { checked: selected, size: "small" }),- h("div", {- class: "w-4 h-4 rounded cursor-pointer relative",- style: `background-color: ${color};`,- onClick: () => {},- }),- value,- ]);-};--const renderTag = (props: {- option: SelectBaseOption;- handleClose: () => void;-}) => {- const { color, value } = props.option as IsseuLabelOption;-- return h(- NTag,- {- closable: true,- onClose: props.handleClose,- },- {- default: () =>- h("div", { class: "flex items-center gap-x-2" }, [- h("div", {- class: "w-4 h-4 rounded",- style: `background-color: ${color};`,- }),- value,- ]),- }- );-};</script>