fix: make project template inheritance granular and safe
CI/CD / test_and_check_app (push) Failing after 3m8s
CI/CD / Publish immutable image (push) Skipped
CI/CD / test_and_check_app (pull_request) Failing after 3m8s
CI/CD / Publish immutable image (pull_request) Skipped

This commit is contained in:
Nico Schröder
2026-09-08 10:25:52 +00:00
committed by Twyco
parent fed6a282a4
commit 9895fc36db
50 changed files with 1504 additions and 624 deletions
@@ -0,0 +1,177 @@
<script setup lang="ts">
import { useForm } from '@inertiajs/vue3';
import ProjectController from '@/actions/App/Http/Controllers/ProjectController';
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 { Label } from '@/components/ui/label';
import type { ProjectTemplateState, ProjectTemplateStateArea } from '@/types';
import { computed } from 'vue';
const props = defineProps<{
areas: string[];
projectId: number;
templateState?: ProjectTemplateState | null;
}>();
const form = useForm<{
areas: string[];
status_replacements: Record<string, number | undefined>;
}>({
areas: [],
status_replacements: {},
});
const activeArea = computed(() => form.areas[0]);
const inheritedAreas = computed(
() =>
props.templateState?.inheritedAreas.filter((area) =>
props.areas.includes(area.value),
) ?? [],
);
const overriddenAreas = computed(
() =>
props.templateState?.overriddenAreas.filter((area) =>
props.areas.includes(area.value),
) ?? [],
);
const statusRequirement = computed(
() => props.templateState?.resetRequirements?.ticket_statuses,
);
const canReset = (area: ProjectTemplateStateArea): boolean => {
if (area.value !== 'ticket_statuses') {
return true;
}
return (
statusRequirement.value?.removedStatuses.every(
(status) =>
form.status_replacements[String(status.id)] !== undefined,
) ?? true
);
};
const resetArea = (area: ProjectTemplateStateArea): void => {
if (!canReset(area)) {
return;
}
form.areas = [area.value];
form.post(ProjectController.resetTemplate.url(props.projectId), {
preserveScroll: true,
onSuccess: () => form.reset(),
});
};
</script>
<template>
<Card
v-if="
templateState?.inheritsFromTemplate &&
(inheritedAreas.length > 0 || overriddenAreas.length > 0)
"
>
<CardHeader>
<CardTitle>
Template inheritance: {{ templateState.templateName }}
</CardTitle>
<CardDescription>
Every setting area inherits independently. Local changes stay
unchanged when the template is updated until that area is reset.
</CardDescription>
</CardHeader>
<CardContent class="space-y-4">
<div class="flex flex-wrap gap-2">
<Badge
v-for="area in inheritedAreas"
:key="`inherited-${area.value}`"
variant="outline"
>
{{ area.label }} · inherited
</Badge>
</div>
<div
v-for="area in overriddenAreas"
:key="`overridden-${area.value}`"
class="space-y-3 rounded-lg border p-4"
>
<div class="flex flex-wrap items-center justify-between gap-3">
<Badge>{{ area.label }} · template overridden</Badge>
<Button
type="button"
size="sm"
variant="outline"
:disabled="form.processing || !canReset(area)"
@click="resetArea(area)"
>
{{
activeArea === area.value && form.processing
? 'Resetting…'
: 'Reset to template'
}}
</Button>
</div>
<div
v-if="area.value === 'ticket_statuses' && statusRequirement"
class="space-y-3"
>
<p class="text-muted-foreground text-sm">
Choose where tickets in local statuses should move
before those statuses are removed.
</p>
<div
v-for="status in statusRequirement.removedStatuses"
:key="status.id"
class="grid gap-2 sm:grid-cols-2 sm:items-center"
>
<Label :for="`replacement-${status.id}`">
{{ status.name }} ({{ status.ticketCount }} tickets)
</Label>
<div class="grid gap-1">
<select
:id="`replacement-${status.id}`"
v-model="
form.status_replacements[String(status.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 focus-visible:ring-[3px]"
>
<option :value="undefined" disabled>
Select replacement status
</option>
<option
v-for="option in statusRequirement.replacementOptions"
:key="option.id"
:value="option.id"
>
{{ option.name }}
</option>
</select>
<InputError
:message="
form.errors[
`status_replacements.${status.id}`
]
"
/>
</div>
</div>
</div>
<InputError :message="form.errors.areas" />
</div>
</CardContent>
</Card>
</template>
+10 -25
View File
@@ -3,6 +3,7 @@ import { Form, Head, Link } from '@inertiajs/vue3';
import ProjectBoardSettingsController from '@/actions/App/Http/Controllers/ProjectBoardSettingsController';
import Heading from '@/components/Heading.vue';
import InputError from '@/components/InputError.vue';
import TemplateInheritancePanel from '@/components/projects/TemplateInheritancePanel.vue';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
@@ -138,31 +139,15 @@ const statusAllowsTarget = (
{{ status }}
</div>
<Card v-if="templateState?.inheritsFromTemplate">
<CardHeader>
<CardTitle>
Template inheritance: {{ templateState.templateName }}
</CardTitle>
<CardDescription>
This project stays linked to its template. Sections below show whether the current configuration is still inherited or has local 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>
<TemplateInheritancePanel
:areas="[
'board_columns',
'ticket_statuses',
'status_transitions',
]"
:project-id="project.id"
:template-state="templateState"
/>
<Card>
<CardHeader>
@@ -50,10 +50,6 @@ const switchTemplateForm = useForm({
)?.id,
});
const resetTemplateForm = useForm({
confirmation_key: '',
});
const deleteForm = useForm({
confirmation_key: '',
});
@@ -76,10 +72,6 @@ const canSwitchTemplate = computed(
switchTemplateForm.source_template_id !== undefined,
);
const isResetConfirmationValid = computed(
() => resetTemplateForm.confirmation_key === props.project.key,
);
const isDeleteConfirmationValid = computed(
() => deleteForm.confirmation_key === props.project.key,
);
@@ -89,19 +81,12 @@ const submitSwitchTemplate = (): void => {
return;
}
switchTemplateForm.post(ProjectController.switchTemplate.url(props.project.id), {
preserveScroll: true,
});
};
const submitResetTemplate = (): void => {
if (!isResetConfirmationValid.value) {
return;
}
resetTemplateForm.post(ProjectController.resetTemplate.url(props.project.id), {
preserveScroll: true,
});
switchTemplateForm.post(
ProjectController.switchTemplate.url(props.project.id),
{
preserveScroll: true,
},
);
};
const submitDelete = (): void => {
@@ -209,56 +194,84 @@ const submitDelete = (): void => {
<CardHeader>
<CardTitle>Template baseline</CardTitle>
<CardDescription>
Switch this project to another published template or reset it back to the currently linked template baseline. Both actions can overwrite local configuration.
Switch this project to another published template. Use
the inheritance panels to reset individual settings to
the currently linked template.
</CardDescription>
</CardHeader>
<CardContent class="space-y-6">
<div class="grid gap-4 md:grid-cols-2">
<div class="border-border/70 rounded-xl border p-4">
<p class="text-muted-foreground text-xs font-semibold uppercase tracking-[0.18em]">
<p
class="text-muted-foreground text-xs font-semibold uppercase tracking-[0.18em]"
>
Current linked template
</p>
<p class="text-foreground mt-2 text-sm font-semibold">
{{ currentTemplate?.name ?? 'No linked template' }}
<p
class="text-foreground mt-2 text-sm font-semibold"
>
{{
currentTemplate?.name ??
'No linked template'
}}
</p>
<p class="text-muted-foreground mt-2 text-sm">
{{
templateState?.inheritsFromTemplate
? 'Inherited and overridden areas stay visible after switching or resetting.'
? 'Inherited and overridden areas stay visible after switching.'
: 'This project currently behaves like a standalone baseline.'
}}
</p>
</div>
<div class="border-border/70 rounded-xl border p-4">
<p class="text-muted-foreground text-xs font-semibold uppercase tracking-[0.18em]">
<p
class="text-muted-foreground text-xs font-semibold uppercase tracking-[0.18em]"
>
Warning
</p>
<p class="text-foreground mt-2 text-sm font-medium">
Template changes can replace board workflow, ticket metadata, repositories, and notifications for copied areas.
Switching templates can replace inherited board
workflow, ticket metadata, repositories, and
notifications.
</p>
<p class="text-muted-foreground mt-2 text-sm">
Confirm each action with the exact project key to avoid accidental overwrites.
Confirm each action with the exact project key
to avoid accidental overwrites.
</p>
</div>
</div>
<div class="grid gap-6 xl:grid-cols-2">
<form class="space-y-4 rounded-xl border p-4" @submit.prevent="submitSwitchTemplate">
<div class="grid gap-6">
<form
class="space-y-4 rounded-xl border p-4"
@submit.prevent="submitSwitchTemplate"
>
<div class="space-y-1">
<h3 class="text-sm font-semibold">Switch to another template</h3>
<h3 class="text-sm font-semibold">
Switch to another template
</h3>
<p class="text-muted-foreground text-sm">
Applying a different template replaces the copied areas with that template's current baseline.
Applying a different template replaces the
copied areas with that template's current
baseline.
</p>
</div>
<div class="grid gap-2">
<Label for="source_template_id">Published template</Label>
<Label for="source_template_id"
>Published template</Label
>
<select
id="source_template_id"
v-model="switchTemplateForm.source_template_id"
:disabled="switchTemplateForm.processing || availableSwitchTemplates.length === 0"
v-model="
switchTemplateForm.source_template_id
"
:disabled="
switchTemplateForm.processing ||
availableSwitchTemplates.length === 0
"
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 :value="undefined" disabled>
@@ -272,68 +285,54 @@ const submitDelete = (): void => {
{{ template.name }}
</option>
</select>
<InputError :message="switchTemplateForm.errors.source_template_id" />
<InputError
:message="
switchTemplateForm.errors
.source_template_id
"
/>
</div>
<div class="grid gap-2">
<Label for="switch_confirmation_key">Confirmation key</Label>
<Label for="switch_confirmation_key"
>Confirmation key</Label
>
<Input
id="switch_confirmation_key"
v-model="switchTemplateForm.confirmation_key"
v-model="
switchTemplateForm.confirmation_key
"
:disabled="switchTemplateForm.processing"
placeholder="Type the project key exactly"
/>
<InputError :message="switchTemplateForm.errors.confirmation_key" />
<InputError
:message="
switchTemplateForm.errors
.confirmation_key
"
/>
</div>
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<div
class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"
>
<p class="text-muted-foreground text-sm">
Existing project-specific configuration in copied areas may be replaced or removed.
Existing project-specific configuration in
copied areas may be replaced or removed.
</p>
<Button
type="submit"
variant="outline"
:disabled="switchTemplateForm.processing || !canSwitchTemplate"
:disabled="
switchTemplateForm.processing ||
!canSwitchTemplate
"
>
Switch template
</Button>
</div>
</form>
<form class="space-y-4 rounded-xl border p-4" @submit.prevent="submitResetTemplate">
<div class="space-y-1">
<h3 class="text-sm font-semibold">Reset to current template baseline</h3>
<p class="text-muted-foreground text-sm">
Re-apply the currently linked template and clear local divergence inside copied areas.
</p>
</div>
<div class="grid gap-2">
<Label for="reset_confirmation_key">Confirmation key</Label>
<Input
id="reset_confirmation_key"
v-model="resetTemplateForm.confirmation_key"
:disabled="resetTemplateForm.processing || !currentTemplate"
placeholder="Type the project key exactly"
/>
<InputError :message="resetTemplateForm.errors.confirmation_key" />
</div>
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<p class="text-muted-foreground text-sm">
This restores the current template baseline for copied areas and rewinds project-level overrides there.
</p>
<Button
type="submit"
variant="outline"
:disabled="resetTemplateForm.processing || !isResetConfirmationValid || !currentTemplate"
>
Reset to baseline
</Button>
</div>
</form>
</div>
</CardContent>
</Card>
@@ -3,6 +3,7 @@ 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 TemplateInheritancePanel from '@/components/projects/TemplateInheritancePanel.vue';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
@@ -115,31 +116,17 @@ const replacementTicketTypes = (ticketTypeId: number) =>
{{ 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>
<TemplateInheritancePanel
:areas="[
'project_settings',
'ticket_types',
'ticket_priorities',
'ticket_fields',
'ticket_link_types',
]"
:project-id="project.id"
:template-state="templateState"
/>
<div class="grid gap-6 xl:grid-cols-2">
<Card class="gap-0 overflow-hidden">
@@ -699,7 +686,9 @@ const replacementTicketTypes = (ticketTypeId: number) =>
required
placeholder="Blocked by"
/>
<InputError :message="errors.counterpart_name" />
<InputError
:message="errors.counterpart_name"
/>
</div>
<Button type="submit" :disabled="processing">
@@ -745,7 +734,9 @@ const replacementTicketTypes = (ticketTypeId: number) =>
<Input
:id="`link-type-counterpart-name-${ticketLinkType.id}`"
name="counterpart_name"
:default-value="ticketLinkType.counterpart_label"
:default-value="
ticketLinkType.counterpart_label
"
required
/>
<InputError
@@ -4,6 +4,7 @@ import { computed, reactive } from 'vue';
import ProjectNotificationSettingsController from '@/actions/App/Http/Controllers/ProjectNotificationSettingsController';
import Heading from '@/components/Heading.vue';
import InputError from '@/components/InputError.vue';
import TemplateInheritancePanel from '@/components/projects/TemplateInheritancePanel.vue';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
@@ -89,7 +90,8 @@ const breadcrumbs: BreadcrumbItem[] = [
let filterStateCounter = 0;
const nextFilterStateId = (): string => `notification-filter-${filterStateCounter++}`;
const nextFilterStateId = (): string =>
`notification-filter-${filterStateCounter++}`;
const parseInFilterValues = (value: string): string[] =>
value
@@ -100,7 +102,8 @@ const parseInFilterValues = (value: string): string[] =>
const supportsFilterValue = (operator: string): boolean =>
!['exists', 'not_exists'].includes(operator);
const supportsArrayFilterValue = (operator: string): boolean => operator === 'in';
const supportsArrayFilterValue = (operator: string): boolean =>
operator === 'in';
const createFilter = (): NotificationFilterFormState => ({
attribute: defaultFilterAttribute,
@@ -159,8 +162,9 @@ const resetCreateFilters = (): void => {
createFilterState.filters = [];
};
const editFilters = (notificationActionId: number): NotificationFilterFormState[] =>
editFilterState[notificationActionId] ?? [];
const editFilters = (
notificationActionId: number,
): NotificationFilterFormState[] => editFilterState[notificationActionId] ?? [];
const addEditFilter = (notificationActionId: number): void => {
editFilterState[notificationActionId] = [
@@ -169,10 +173,13 @@ const addEditFilter = (notificationActionId: number): void => {
];
};
const removeEditFilter = (notificationActionId: number, index: number): void => {
editFilterState[notificationActionId] = editFilters(notificationActionId).filter(
(_, candidateIndex) => candidateIndex !== index,
);
const removeEditFilter = (
notificationActionId: number,
index: number,
): void => {
editFilterState[notificationActionId] = editFilters(
notificationActionId,
).filter((_, candidateIndex) => candidateIndex !== index);
};
const createSerializedFilters = computed<string>(() =>
@@ -305,31 +312,11 @@ const notificationActionTimestamp = (
{{ status }}
</div>
<Card v-if="templateState?.inheritsFromTemplate">
<CardHeader>
<CardTitle>
Template inheritance: {{ templateState.templateName }}
</CardTitle>
<CardDescription>
Notification rules can remain inherited from the template or diverge here as project-level 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>
<TemplateInheritancePanel
:areas="['notification_actions']"
:project-id="project.id"
:template-state="templateState"
/>
<div class="grid gap-6 xl:grid-cols-[24rem_minmax(0,1fr)]">
<div class="space-y-6">
@@ -543,7 +530,10 @@ const notificationActionTimestamp = (
/>
<div
v-if="createFilterState.filters.length === 0"
v-if="
createFilterState.filters.length ===
0
"
class="text-muted-foreground text-sm"
>
No filters configured. This action runs
@@ -552,8 +542,7 @@ const notificationActionTimestamp = (
<div
v-for="(
filter,
filterIndex
filter, filterIndex
) in createFilterState.filters"
:key="filter.id"
class="grid gap-3 rounded-md border p-3"
@@ -572,8 +561,12 @@ const notificationActionTimestamp = (
>
<option
v-for="filterAttributeOption in filterAttributeOptions"
:key="filterAttributeOption.value"
:value="filterAttributeOption.value"
:key="
filterAttributeOption.value
"
:value="
filterAttributeOption.value
"
>
{{
filterAttributeOption.label
@@ -595,8 +588,12 @@ const notificationActionTimestamp = (
>
<option
v-for="filterOperatorOption in filterOperatorOptions"
:key="filterOperatorOption.value"
:value="filterOperatorOption.value"
:key="
filterOperatorOption.value
"
:value="
filterOperatorOption.value
"
>
{{
filterOperatorOption.label
@@ -607,7 +604,11 @@ const notificationActionTimestamp = (
</div>
<div
v-if="supportsFilterValue(filter.operator)"
v-if="
supportsFilterValue(
filter.operator,
)
"
class="grid gap-2"
>
<Label
@@ -662,7 +663,9 @@ const notificationActionTimestamp = (
</div>
<InputError
:message="notificationFilterError(errors)"
:message="
notificationFilterError(errors)
"
/>
</div>
@@ -1029,8 +1032,7 @@ const notificationActionTimestamp = (
<div
v-for="(
filter,
filterIndex
filter, filterIndex
) in editFilters(notificationAction.id)"
:key="filter.id"
class="grid gap-3 rounded-md border p-3"
@@ -1049,8 +1051,12 @@ const notificationActionTimestamp = (
>
<option
v-for="filterAttributeOption in filterAttributeOptions"
:key="filterAttributeOption.value"
:value="filterAttributeOption.value"
:key="
filterAttributeOption.value
"
:value="
filterAttributeOption.value
"
>
{{
filterAttributeOption.label
@@ -1072,8 +1078,12 @@ const notificationActionTimestamp = (
>
<option
v-for="filterOperatorOption in filterOperatorOptions"
:key="filterOperatorOption.value"
:value="filterOperatorOption.value"
:key="
filterOperatorOption.value
"
:value="
filterOperatorOption.value
"
>
{{
filterOperatorOption.label
@@ -1084,7 +1094,11 @@ const notificationActionTimestamp = (
</div>
<div
v-if="supportsFilterValue(filter.operator)"
v-if="
supportsFilterValue(
filter.operator,
)
"
class="grid gap-2"
>
<Label
@@ -1144,7 +1158,9 @@ const notificationActionTimestamp = (
</div>
<InputError
:message="notificationFilterError(errors)"
:message="
notificationFilterError(errors)
"
/>
</div>
@@ -4,6 +4,7 @@ import { computed, watch } from 'vue';
import ProjectRepositorySettingsController from '@/actions/App/Http/Controllers/ProjectRepositorySettingsController';
import Heading from '@/components/Heading.vue';
import InputError from '@/components/InputError.vue';
import TemplateInheritancePanel from '@/components/projects/TemplateInheritancePanel.vue';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import {
@@ -277,31 +278,11 @@ const submitUpdate = (): void => {
{{ status }}
</div>
<Card v-if="templateState?.inheritsFromTemplate">
<CardHeader>
<CardTitle>
Template inheritance: {{ templateState.templateName }}
</CardTitle>
<CardDescription>
Repository links can stay inherited from the template or be replaced with 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>
<TemplateInheritancePanel
:areas="['repository_connections']"
:project-id="project.id"
:template-state="templateState"
/>
<Card>
<CardHeader>
@@ -320,9 +301,9 @@ const submitUpdate = (): void => {
</Link>
</Button>
<p class="text-muted-foreground text-sm">
Without a matching personal connection, {{ appName }} only
shows the repository name and links you to your user
settings.
Without a matching personal connection,
{{ appName }} only shows the repository name and links
you to your user settings.
</p>
</CardContent>
</Card>
@@ -647,8 +628,8 @@ const submitUpdate = (): void => {
>
This project link is visible, but you need a
matching Git connection in your user
settings before {{ appName }} can open or query
this repository for you.
settings before {{ appName }} can open or
query this repository for you.
</p>
<div class="mt-4 flex justify-end">
@@ -683,9 +664,9 @@ const submitUpdate = (): void => {
<CardHeader class="border-b">
<CardTitle>Detected personal sources</CardTitle>
<CardDescription>
{{ appName }} loads repositories from your personal
Git connections and offers them for project
linking.
{{ appName }} loads repositories from your
personal Git connections and offers them for
project linking.
</CardDescription>
</CardHeader>
+11
View File
@@ -78,6 +78,17 @@ export type ProjectTemplateState = {
inheritsFromTemplate: boolean;
overriddenAreas: ProjectTemplateStateArea[];
overriddenConfiguration?: Record<string, unknown>;
resetRequirements?: Record<
string,
{
removedStatuses: Array<{
id: number;
name: string;
ticketCount: number;
}>;
replacementOptions: Array<{ id: number; name: string }>;
}
>;
templateConfiguration?: Record<string, unknown>;
templateId: number;
templateName: string;