feat(KAN-26): add reusable ticket presentations
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<script setup lang="ts">
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ArrowUpRight } from 'lucide-vue-next';
|
||||
import TicketMetadata from '@/components/tickets/TicketMetadata.vue';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { useLocalization } from '@/composables/useLocalization';
|
||||
import { show as showTicket } from '@/routes/projects/tickets';
|
||||
import type {
|
||||
TicketPresentationEmits,
|
||||
TicketPresentationProps,
|
||||
} from '@/types/ticket-presentation';
|
||||
|
||||
withDefaults(defineProps<TicketPresentationProps>(), {
|
||||
showDescription: true,
|
||||
showStatus: true,
|
||||
});
|
||||
|
||||
const emit = defineEmits<TicketPresentationEmits>();
|
||||
const { t } = useLocalization();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<article
|
||||
:class="[
|
||||
'bg-card text-card-foreground min-w-0 rounded-md border shadow-sm',
|
||||
ticket.is_blocked ? 'border-warning' : 'border-border',
|
||||
]"
|
||||
>
|
||||
<Link
|
||||
:href="showTicket({ project: projectId, ticket: ticket.id })"
|
||||
:aria-label="
|
||||
t('tickets.open', {
|
||||
key: ticket.ticket_key,
|
||||
title: ticket.title,
|
||||
})
|
||||
"
|
||||
class="focus-visible:ring-ring/35 gap-card min-h-control hover:bg-accent/35 group flex min-w-0 flex-col rounded-t-md p-4 transition-[background-color,box-shadow] focus-visible:outline-none focus-visible:ring-2"
|
||||
@click="emit('open', ticket.id)"
|
||||
>
|
||||
<div class="flex min-w-0 items-start justify-between gap-3">
|
||||
<Badge
|
||||
variant="outline"
|
||||
class="wrap-anywhere max-w-full whitespace-normal"
|
||||
>
|
||||
{{ ticket.ticket_key }}
|
||||
</Badge>
|
||||
<ArrowUpRight
|
||||
class="text-muted-foreground group-hover:text-primary size-4 shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<h3
|
||||
class="text-body group-hover:text-primary wrap-anywhere min-w-0 font-semibold"
|
||||
>
|
||||
{{ ticket.title }}
|
||||
</h3>
|
||||
|
||||
<TicketMetadata :ticket="ticket" :show-status="showStatus" />
|
||||
|
||||
<p
|
||||
v-if="showDescription && ticket.description"
|
||||
class="text-caption text-muted-foreground wrap-anywhere line-clamp-3"
|
||||
>
|
||||
{{ ticket.description }}
|
||||
</p>
|
||||
|
||||
<p
|
||||
v-if="ticket.is_blocked && ticket.blocked_comment"
|
||||
class="text-caption text-warning-foreground bg-warning wrap-anywhere rounded-sm px-3 py-2"
|
||||
>
|
||||
{{
|
||||
t('tickets.blockerComment', {
|
||||
comment: ticket.blocked_comment,
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
</Link>
|
||||
|
||||
<div v-if="$slots.actions" class="border-t p-4">
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
@@ -0,0 +1,88 @@
|
||||
<script setup lang="ts">
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { ArrowUpRight } from 'lucide-vue-next';
|
||||
import TicketMetadata from '@/components/tickets/TicketMetadata.vue';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { useLocalization } from '@/composables/useLocalization';
|
||||
import { show as showTicket } from '@/routes/projects/tickets';
|
||||
import type {
|
||||
TicketPresentationEmits,
|
||||
TicketPresentationProps,
|
||||
} from '@/types/ticket-presentation';
|
||||
|
||||
withDefaults(defineProps<TicketPresentationProps>(), {
|
||||
showDescription: true,
|
||||
showStatus: true,
|
||||
});
|
||||
|
||||
const emit = defineEmits<TicketPresentationEmits>();
|
||||
const { t } = useLocalization();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<li
|
||||
:class="[
|
||||
'bg-card text-card-foreground min-w-0 rounded-md border',
|
||||
ticket.is_blocked ? 'border-warning' : 'border-border',
|
||||
]"
|
||||
>
|
||||
<div class="flex min-w-0 flex-col lg:flex-row lg:items-stretch">
|
||||
<Link
|
||||
:href="showTicket({ project: projectId, ticket: ticket.id })"
|
||||
:aria-label="
|
||||
t('tickets.open', {
|
||||
key: ticket.ticket_key,
|
||||
title: ticket.title,
|
||||
})
|
||||
"
|
||||
class="focus-visible:ring-ring/35 gap-card min-h-control hover:bg-accent/35 group flex min-w-0 flex-1 flex-col rounded-t-md p-4 transition-[background-color,box-shadow] focus-visible:outline-none focus-visible:ring-2 lg:rounded-l-md lg:rounded-tr-none"
|
||||
@click="emit('open', ticket.id)"
|
||||
>
|
||||
<div class="flex min-w-0 items-start gap-3">
|
||||
<Badge
|
||||
variant="outline"
|
||||
class="wrap-anywhere max-w-full whitespace-normal"
|
||||
>
|
||||
{{ ticket.ticket_key }}
|
||||
</Badge>
|
||||
<h3
|
||||
class="text-body group-hover:text-primary wrap-anywhere min-w-0 flex-1 font-semibold"
|
||||
>
|
||||
{{ ticket.title }}
|
||||
</h3>
|
||||
<ArrowUpRight
|
||||
class="text-muted-foreground group-hover:text-primary size-4 shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<TicketMetadata :ticket="ticket" :show-status="showStatus" />
|
||||
|
||||
<p
|
||||
v-if="showDescription && ticket.description"
|
||||
class="text-caption text-muted-foreground wrap-anywhere line-clamp-2"
|
||||
>
|
||||
{{ ticket.description }}
|
||||
</p>
|
||||
|
||||
<p
|
||||
v-if="ticket.is_blocked && ticket.blocked_comment"
|
||||
class="text-caption text-warning-foreground bg-warning wrap-anywhere rounded-sm px-3 py-2"
|
||||
>
|
||||
{{
|
||||
t('tickets.blockerComment', {
|
||||
comment: ticket.blocked_comment,
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
</Link>
|
||||
|
||||
<div
|
||||
v-if="$slots.actions"
|
||||
class="border-t p-4 lg:flex lg:w-80 lg:items-center lg:border-l lg:border-t-0"
|
||||
>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</template>
|
||||
@@ -0,0 +1,91 @@
|
||||
<script setup lang="ts">
|
||||
import { CircleUserRound, OctagonAlert } from 'lucide-vue-next';
|
||||
import { computed } from 'vue';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { UserAvatar } from '@/components/ui/avatar';
|
||||
import { useLocalization } from '@/composables/useLocalization';
|
||||
import { ticketStatusLabel } from '@/lib/tickets';
|
||||
import type { TicketModel } from '@/types/models/ticket-model';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
showStatus?: boolean;
|
||||
ticket: TicketModel;
|
||||
}>(),
|
||||
{
|
||||
showStatus: true,
|
||||
},
|
||||
);
|
||||
|
||||
const { t } = useLocalization();
|
||||
const statusLabel = computed(() =>
|
||||
ticketStatusLabel(props.ticket.ticket_status, t('tickets.noStatus')),
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="gap-stack flex min-w-0 flex-wrap items-center">
|
||||
<Badge
|
||||
v-if="ticket.is_blocked"
|
||||
variant="warning"
|
||||
:aria-label="t('tickets.blocked')"
|
||||
>
|
||||
<OctagonAlert aria-hidden="true" />
|
||||
{{ t('tickets.blocked') }}
|
||||
</Badge>
|
||||
|
||||
<Badge
|
||||
variant="secondary"
|
||||
:aria-label="
|
||||
t('tickets.typeLabel', { name: ticket.ticket_type.name })
|
||||
"
|
||||
:data-ticket-type-id="ticket.ticket_type.id"
|
||||
>
|
||||
{{ ticket.ticket_type.name }}
|
||||
</Badge>
|
||||
|
||||
<Badge
|
||||
variant="outline"
|
||||
:aria-label="
|
||||
t('tickets.priorityLabel', {
|
||||
name: ticket.ticket_priority.name,
|
||||
})
|
||||
"
|
||||
:data-ticket-priority-id="ticket.ticket_priority.id"
|
||||
>
|
||||
{{ ticket.ticket_priority.name }}
|
||||
</Badge>
|
||||
|
||||
<Badge
|
||||
v-if="showStatus"
|
||||
variant="outline"
|
||||
:aria-label="t('tickets.statusLabel', { name: statusLabel })"
|
||||
:data-ticket-status-id="ticket.ticket_status?.id"
|
||||
>
|
||||
{{ statusLabel }}
|
||||
</Badge>
|
||||
|
||||
<span
|
||||
v-if="ticket.assignee"
|
||||
class="text-caption text-muted-foreground flex min-w-0 items-center gap-1.5"
|
||||
:aria-label="
|
||||
t('tickets.assignedTo', { name: ticket.assignee.name })
|
||||
"
|
||||
>
|
||||
<UserAvatar
|
||||
:user="ticket.assignee"
|
||||
size="sm"
|
||||
:label="ticket.assignee.name"
|
||||
/>
|
||||
<span class="max-w-40 truncate">{{ ticket.assignee.name }}</span>
|
||||
</span>
|
||||
|
||||
<span
|
||||
v-else
|
||||
class="text-caption text-muted-foreground flex items-center gap-1.5"
|
||||
>
|
||||
<CircleUserRound class="size-4" aria-hidden="true" />
|
||||
{{ t('tickets.unassigned') }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default as TicketCard } from './TicketCard.vue';
|
||||
export { default as TicketListItem } from './TicketListItem.vue';
|
||||
Reference in New Issue
Block a user