Files
KanbanGit/resources/js/pages/projects/settings/Metadata.vue
T
Twyco a46695c2eb
linter / quality (pull_request) Successful in 1m18s
tests / ci (8.4) (pull_request) Successful in 1m54s
Implement Fluid Emerald app redesign
2026-07-18 16:45:54 +02:00

817 lines
38 KiB
Vue

<script setup lang="ts">
import { Form, Head, Link } from '@inertiajs/vue3';
import ProjectTicketMetadataSettingsController from '@/actions/App/Http/Controllers/ProjectTicketMetadataSettingsController';
import Heading from '@/components/Heading.vue';
import InputError from '@/components/InputError.vue';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from '@/components/ui/card';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import AppLayout from '@/layouts/AppLayout.vue';
import { index, show } from '@/routes/projects/index';
import {
board as boardSettings,
general as generalSettings,
metadata as metadataSettings,
notifications as notificationSettings,
repositories as repositorySettings,
} from '@/routes/projects/settings';
import type {
BreadcrumbItem,
ProjectTicketMetadataSettingsPageProps,
} from '@/types';
import { Checkbox } from '@/components/ui/checkbox';
const props = defineProps<ProjectTicketMetadataSettingsPageProps>();
const breadcrumbs: BreadcrumbItem[] = [
{
title: 'Projects',
href: index(),
},
{
title: props.project.name,
href: show(props.project.id),
},
{
title: 'Ticket settings',
href: metadataSettings(props.project.id),
},
];
const replacementTicketTypes = (ticketTypeId: number) =>
props.ticketTypes.filter((ticketType) => ticketType.id !== ticketTypeId);
</script>
<template>
<AppLayout :breadcrumbs="breadcrumbs" :project="project">
<Head :title="`${project.name} ticket settings`" />
<div class="app-page">
<div
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
>
<div class="space-y-3">
<Badge variant="outline" class="px-3 py-1">
{{ project.key }}
</Badge>
<Heading
:title="`${project.name} ticket settings`"
description="Configure project-specific ticket types, priorities, custom field definitions, and ticket link labels."
/>
</div>
<div class="flex flex-wrap gap-3">
<Button
v-if="$page.props.auth.permissions.globalAdmin"
as-child
variant="outline"
>
<Link :href="generalSettings(project.id)">
General settings
</Link>
</Button>
<Button as-child variant="outline">
<Link :href="boardSettings(project.id)">
Board settings
</Link>
</Button>
<Button as-child variant="outline">
<Link :href="repositorySettings(project.id)">
Repository settings
</Link>
</Button>
<Button as-child variant="outline">
<Link :href="notificationSettings(project.id)">
Notification settings
</Link>
</Button>
<Button as-child variant="outline">
<Link :href="show(project.id)">Back to project</Link>
</Button>
</div>
</div>
<div
v-if="status"
:class="[
'rounded-xl border px-4 py-3 text-sm',
error
? 'border-red-200/80 bg-red-50/60 text-red-800/80 dark:border-red-900/60 dark:bg-red-950/20 dark:text-red-200/80'
: 'border-emerald-200 bg-emerald-50 text-emerald-900 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-100',
]"
>
{{ status }}
</div>
<Card v-if="templateState?.inheritsFromTemplate">
<CardHeader>
<CardTitle>
Template inheritance: {{ templateState.templateName }}
</CardTitle>
<CardDescription>
Inherited sections stay synced with the template
baseline. Local edits in these settings are treated as
project-specific overrides.
</CardDescription>
</CardHeader>
<CardContent class="flex flex-wrap gap-2">
<Badge
v-for="area in templateState.inheritedAreas"
:key="`inherited-${area.value}`"
variant="outline"
>
{{ area.label }} · inherited
</Badge>
<Badge
v-for="area in templateState.overriddenAreas"
:key="`overridden-${area.value}`"
>
{{ area.label }} · overridden
</Badge>
</CardContent>
</Card>
<div class="grid gap-6 xl:grid-cols-2">
<Card class="gap-0 overflow-hidden">
<CardHeader class="border-b">
<CardTitle>General ticket settings</CardTitle>
</CardHeader>
<CardContent class="space-y-4 p-6">
<Form
v-bind="
ProjectTicketMetadataSettingsController.update.form(
project.id,
)
"
class="border-border space-y-4 rounded-xl border border-dashed p-4"
v-slot="{ errors, processing }"
>
<Label for="enable-story-points">
<Checkbox
id="enable-story-points"
name="show_story_points"
:default-value="project.show_story_points"
value="1"
/>
Enable story points for tickets
</Label>
<InputError :message="errors.show_story_points" />
<Label for="enable-author">
<Checkbox
id="enable-author"
name="show_author"
:default-value="project.show_author"
value="1"
/>
Show author on ticket details
</Label>
<InputError :message="errors.show_author" />
<Button type="submit" :disabled="processing">
Save
</Button>
</Form>
</CardContent>
</Card>
<Card class="gap-0 overflow-hidden">
<CardHeader class="border-b">
<CardTitle>Ticket types</CardTitle>
</CardHeader>
<CardContent class="space-y-4 p-6">
<Form
v-bind="
ProjectTicketMetadataSettingsController.storeType.form(
project.id,
)
"
class="border-border space-y-4 rounded-xl border border-dashed p-4"
v-slot="{ errors, processing }"
>
<div class="grid gap-2">
<Label for="type-name">New type name</Label>
<Input
id="type-name"
name="name"
required
placeholder="Bug"
/>
<InputError :message="errors.name" />
<Label for="type-is-parent">
<Checkbox
id="type-is-parent"
name="is_parent"
value="1"
/>
Ticket type can act as a parent
</Label>
<InputError :message="errors.is_parent" />
</div>
<Button type="submit" :disabled="processing">
Add type
</Button>
</Form>
<div
v-for="ticketType in ticketTypes"
:key="ticketType.id"
class="border-border rounded-xl border p-4"
>
<Form
v-bind="
ProjectTicketMetadataSettingsController.updateType.form(
[project.id, ticketType.id],
)
"
class="grid gap-4"
v-slot="{ errors, processing }"
>
<div class="grid gap-2">
<div
v-if="ticketType.is_parent"
class="flex flex-wrap items-center gap-2"
>
<Badge variant="secondary">
Parent type
</Badge>
<span
class="text-muted-foreground text-xs"
>
This flag is fixed after creation.
</span>
</div>
<Label :for="`type-name-${ticketType.id}`">
Name
</Label>
<Input
:id="`type-name-${ticketType.id}`"
name="name"
:default-value="ticketType.name"
required
/>
<InputError :message="errors.name" />
</div>
<div class="grid gap-2">
<Label
:for="`type-position-${ticketType.id}`"
>
Position
</Label>
<Input
:id="`type-position-${ticketType.id}`"
name="position"
type="number"
min="1"
:max="ticketTypes.length"
:default-value="ticketType.position"
required
/>
<InputError :message="errors.position" />
</div>
<div
class="flex flex-wrap justify-between gap-3"
>
<Button
type="submit"
variant="outline"
:disabled="processing"
>
Save
</Button>
</div>
</Form>
<Form
v-bind="
ProjectTicketMetadataSettingsController.destroyType.form(
[project.id, ticketType.id],
)
"
class="mt-3 grid gap-3"
v-slot="{ errors, processing: deleting }"
>
<div
v-if="
(ticketType.tickets_count ?? 0) > 0 &&
ticketTypes.length > 1
"
class="grid gap-2"
>
<Label
:for="`replacement-type-${ticketType.id}`"
>
Replacement type for
{{ ticketType.tickets_count }} assigned
ticket{{
ticketType.tickets_count === 1
? ''
: 's'
}}
</Label>
<select
:id="`replacement-type-${ticketType.id}`"
name="replacement_ticket_type_id"
class="border-input bg-background shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 rounded-md border px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px]"
required
>
<option value="">Choose type</option>
<option
v-for="replacementTicketType in replacementTicketTypes(
ticketType.id,
)"
:key="replacementTicketType.id"
:value="replacementTicketType.id"
>
{{ replacementTicketType.name }}
</option>
</select>
<InputError
:message="
errors.replacement_ticket_type_id
"
/>
</div>
<div
class="flex flex-wrap items-center justify-between gap-3"
>
<p
v-if="
(ticketType.tickets_count ?? 0) > 0
"
class="text-muted-foreground text-sm"
>
Assigned tickets will be moved before
this type is deleted.
</p>
<Button
type="submit"
variant="destructive"
:disabled="deleting"
>
Delete
</Button>
</div>
</Form>
</div>
</CardContent>
</Card>
<Card class="gap-0 overflow-hidden">
<CardHeader class="border-b">
<CardTitle>Priorities</CardTitle>
<CardDescription>
Priorities are fully project-specific and can be
reordered or removed.
</CardDescription>
</CardHeader>
<CardContent class="space-y-4 p-6">
<Form
v-bind="
ProjectTicketMetadataSettingsController.storePriority.form(
project.id,
)
"
class="border-border space-y-4 rounded-xl border border-dashed p-4"
v-slot="{ errors, processing }"
>
<div class="grid gap-2">
<Label for="priority-name"
>New priority name</Label
>
<Input
id="priority-name"
name="name"
required
placeholder="Urgent"
/>
<InputError :message="errors.name" />
</div>
<Button type="submit" :disabled="processing">
Add priority
</Button>
</Form>
<div
v-for="ticketPriority in ticketPriorities"
:key="ticketPriority.id"
class="border-border rounded-xl border p-4"
>
<Form
v-bind="
ProjectTicketMetadataSettingsController.updatePriority.form(
[project.id, ticketPriority.id],
)
"
class="grid gap-4"
v-slot="{ errors, processing }"
>
<div class="grid gap-2">
<Label
:for="`priority-name-${ticketPriority.id}`"
>
Name
</Label>
<Input
:id="`priority-name-${ticketPriority.id}`"
name="name"
:default-value="ticketPriority.name"
required
/>
<InputError :message="errors.name" />
</div>
<div class="grid gap-2">
<Label
:for="`priority-position-${ticketPriority.id}`"
>
Position
</Label>
<Input
:id="`priority-position-${ticketPriority.id}`"
name="position"
type="number"
min="1"
:max="ticketPriorities.length"
:default-value="ticketPriority.position"
required
/>
<InputError :message="errors.position" />
</div>
<div
class="flex flex-wrap justify-between gap-3"
>
<Button
type="submit"
variant="outline"
:disabled="processing"
>
Save
</Button>
</div>
</Form>
<Form
v-bind="
ProjectTicketMetadataSettingsController.destroyPriority.form(
[project.id, ticketPriority.id],
)
"
class="mt-3 flex justify-end"
v-slot="{ processing: deleting }"
>
<Button
type="submit"
variant="destructive"
:disabled="deleting"
>
Delete
</Button>
</Form>
</div>
</CardContent>
</Card>
<Card class="gap-0 overflow-hidden">
<CardHeader class="border-b">
<CardTitle>Custom fields</CardTitle>
<CardDescription>
Define project-specific user or number fields for
upcoming ticket data.
</CardDescription>
</CardHeader>
<CardContent class="space-y-4 p-6">
<Form
v-bind="
ProjectTicketMetadataSettingsController.storeFieldDefinition.form(
project.id,
)
"
class="border-border space-y-4 rounded-xl border border-dashed p-4"
v-slot="{ errors, processing }"
>
<div class="grid gap-2">
<Label for="field-label">New field label</Label>
<Input
id="field-label"
name="label"
required
placeholder="Reviewer"
/>
<InputError :message="errors.label" />
</div>
<div class="grid gap-2">
<Label for="field-type">Field type</Label>
<select
id="field-type"
name="field_type"
class="border-input bg-background shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 rounded-md border px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px]"
>
<option
v-for="option in fieldTypeOptions"
:key="option.value"
:value="option.value"
>
{{ option.label }}
</option>
</select>
<InputError :message="errors.field_type" />
</div>
<Button type="submit" :disabled="processing">
Add field
</Button>
</Form>
<div
v-for="fieldDefinition in ticketFieldDefinitions"
:key="fieldDefinition.id"
class="border-border rounded-xl border p-4"
>
<Form
v-bind="
ProjectTicketMetadataSettingsController.updateFieldDefinition.form(
[project.id, fieldDefinition.id],
)
"
class="grid gap-4"
v-slot="{ errors, processing }"
>
<div class="grid gap-2">
<Label
:for="`field-label-${fieldDefinition.id}`"
>
Label
</Label>
<Input
:id="`field-label-${fieldDefinition.id}`"
name="label"
:default-value="fieldDefinition.label"
required
/>
<InputError :message="errors.label" />
</div>
<div class="grid gap-2">
<Label
:for="`field-type-${fieldDefinition.id}`"
>
Field type
</Label>
<select
:id="`field-type-${fieldDefinition.id}`"
name="field_type"
class="border-input bg-background shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 rounded-md border px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px]"
>
<option
v-for="option in fieldTypeOptions"
:key="option.value"
:value="option.value"
:selected="
option.value ===
fieldDefinition.field_type
"
>
{{ option.label }}
</option>
</select>
<InputError :message="errors.field_type" />
</div>
<div class="grid gap-2">
<Label
:for="`field-position-${fieldDefinition.id}`"
>
Position
</Label>
<Input
:id="`field-position-${fieldDefinition.id}`"
name="position"
type="number"
min="1"
:max="ticketFieldDefinitions.length"
:default-value="
fieldDefinition.position
"
required
/>
<InputError :message="errors.position" />
</div>
<div
class="flex flex-wrap justify-between gap-3"
>
<Button
type="submit"
variant="outline"
:disabled="processing"
>
Save
</Button>
</div>
</Form>
<Form
v-bind="
ProjectTicketMetadataSettingsController.destroyFieldDefinition.form(
[project.id, fieldDefinition.id],
)
"
class="mt-3 flex justify-end"
v-slot="{ processing: deleting }"
>
<Button
type="submit"
variant="destructive"
:disabled="deleting"
>
Delete
</Button>
</Form>
</div>
</CardContent>
</Card>
<Card class="gap-0 overflow-hidden">
<CardHeader class="border-b">
<CardTitle>Link types</CardTitle>
<CardDescription>
Define project-specific labels for ticket-to-ticket
relationships.
</CardDescription>
</CardHeader>
<CardContent class="space-y-4 p-6">
<Form
v-bind="
ProjectTicketMetadataSettingsController.storeLinkType.form(
project.id,
)
"
class="border-border space-y-4 rounded-xl border border-dashed p-4"
v-slot="{ errors, processing }"
>
<div class="grid gap-2">
<Label for="link-type-name">
Source label
</Label>
<Input
id="link-type-name"
name="name"
required
placeholder="Blocks"
/>
<InputError :message="errors.name" />
</div>
<div class="grid gap-2">
<Label for="link-type-counterpart-name">
Counterpart label
</Label>
<Input
id="link-type-counterpart-name"
name="counterpart_name"
required
placeholder="Blocked by"
/>
<InputError
:message="errors.counterpart_name"
/>
</div>
<Button type="submit" :disabled="processing">
Add link type
</Button>
</Form>
<div
v-for="ticketLinkType in ticketLinkTypes"
:key="ticketLinkType.id"
class="border-border rounded-xl border p-4"
>
<Form
v-bind="
ProjectTicketMetadataSettingsController.updateLinkType.form(
[project.id, ticketLinkType.id],
)
"
class="grid gap-4"
v-slot="{ errors, processing }"
>
<div class="grid gap-2">
<Label
:for="`link-type-name-${ticketLinkType.id}`"
>
Source label
</Label>
<Input
:id="`link-type-name-${ticketLinkType.id}`"
name="name"
:default-value="ticketLinkType.label"
required
/>
<InputError :message="errors.name" />
</div>
<div class="grid gap-2">
<Label
:for="`link-type-counterpart-name-${ticketLinkType.id}`"
>
Counterpart label
</Label>
<Input
:id="`link-type-counterpart-name-${ticketLinkType.id}`"
name="counterpart_name"
:default-value="
ticketLinkType.counterpart_label
"
required
/>
<InputError
:message="errors.counterpart_name"
/>
</div>
<div class="grid gap-2">
<Label
:for="`link-type-position-${ticketLinkType.id}`"
>
Position
</Label>
<Input
:id="`link-type-position-${ticketLinkType.id}`"
name="position"
type="number"
min="1"
:max="ticketLinkTypes.length"
:default-value="ticketLinkType.position"
required
/>
<InputError :message="errors.position" />
</div>
<div
class="flex flex-wrap justify-between gap-3"
>
<Button
type="submit"
variant="outline"
:disabled="processing"
>
Save
</Button>
</div>
</Form>
<Form
v-bind="
ProjectTicketMetadataSettingsController.destroyLinkType.form(
[project.id, ticketLinkType.id],
)
"
class="mt-3 flex justify-end"
v-slot="{ processing: deleting }"
>
<Button
type="submit"
variant="destructive"
:disabled="deleting"
>
Delete
</Button>
</Form>
</div>
</CardContent>
</Card>
</div>
</div>
</AppLayout>
</template>