From c8f494fe7c6b2f1dde696e09e20c73f3013a9c52 Mon Sep 17 00:00:00 2001 From: Twyco Date: Thu, 1 Oct 2026 22:32:02 +0200 Subject: [PATCH] feat: simplify ticket links to action and ticket (KAN-12) --- .../detail/TicketDetailRelationships.vue | 62 ++++++------------- .../tickets/detail/TicketRelationshipLink.vue | 26 +------- .../js/composables/useTicketLinkActions.ts | 57 +++++++++++++++++ resources/js/locales/en.ts | 7 +-- resources/js/types/ticket-detail.ts | 11 ++++ tests/Fixtures/ticket-detail.mjs | 58 +++++++++++++++-- .../Fixtures/ticket-relationships-browser.mjs | 37 +++++------ 7 files changed, 161 insertions(+), 97 deletions(-) create mode 100644 resources/js/composables/useTicketLinkActions.ts diff --git a/resources/js/components/tickets/detail/TicketDetailRelationships.vue b/resources/js/components/tickets/detail/TicketDetailRelationships.vue index 4246a85..625c7a0 100644 --- a/resources/js/components/tickets/detail/TicketDetailRelationships.vue +++ b/resources/js/components/tickets/detail/TicketDetailRelationships.vue @@ -12,8 +12,12 @@ import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader } from '@/components/ui/card'; import { useFormProtection } from '@/composables/useFormProtection'; import { useLocalization } from '@/composables/useLocalization'; +import { useTicketLinkActions } from '@/composables/useTicketLinkActions'; import { show as showTicket } from '@/routes/projects/tickets'; -import type { TicketDetailRelationshipsProps } from '@/types/ticket-detail'; +import type { + TicketDetailRelationshipsProps, + TicketLinkFormData, +} from '@/types/ticket-detail'; const props = defineProps(); defineEmits<{ editParent: [] }>(); @@ -33,7 +37,7 @@ const canAddLink = computed( props.ticketLinkTypes.length > 0 && props.ticketLinkOptions.length > 0, ); -const form = useForm({ +const form = useForm({ ticket_link_type_id: props.ticketLinkTypes[0]?.id ?? '', link_direction: 'source', linked_ticket_id: '', @@ -41,10 +45,9 @@ const form = useForm({ const protection = useFormProtection(form, { isDirty: () => props.canEditTicket && form.isDirty, }); -const selectedType = computed(() => - props.ticketLinkTypes.find( - (type) => String(type.id) === String(form.ticket_link_type_id), - ), +const { actions, selectedAction, selectedActionLabel } = useTicketLinkActions( + () => props.ticketLinkTypes, + form, ); const selectedTicket = computed(() => props.ticketLinkOptions.find( @@ -221,40 +224,18 @@ function submit(): void { />
- @@ -281,26 +262,19 @@ function submit(): void { />

{{ ticket.ticket_key }}{{ - form.link_direction === 'source' - ? selectedType.label - : selectedType.counterpart_label - }}{{ selectedActionLabel }}

-

- {{ t('ticketRelationships.directionHelp') }} -