feat(KAN-39): rebuild general project settings and inheritance
This commit is contained in:
@@ -1,26 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import { useForm } from '@inertiajs/vue3';
|
||||
import ProjectController from '@/actions/App/Http/Controllers/ProjectController';
|
||||
import { Layers3, RotateCcw } from 'lucide-vue-next';
|
||||
import { computed, ref } from 'vue';
|
||||
import { resetTemplate } from '@/actions/App/Http/Controllers/ProjectController';
|
||||
import FormFeedback from '@/components/FormFeedback.vue';
|
||||
import InputError from '@/components/InputError.vue';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { useFormProtection } from '@/composables/useFormProtection';
|
||||
import { useLocalization } from '@/composables/useLocalization';
|
||||
import type { ProjectTemplateState, ProjectTemplateStateArea } from '@/types';
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
areas: string[];
|
||||
projectId: number;
|
||||
templateState?: ProjectTemplateState | null;
|
||||
}>();
|
||||
|
||||
const { t } = useLocalization();
|
||||
const form = useForm<{
|
||||
areas: string[];
|
||||
status_replacements: Record<string, number | undefined>;
|
||||
@@ -28,51 +34,82 @@ const form = useForm<{
|
||||
areas: [],
|
||||
status_replacements: {},
|
||||
});
|
||||
|
||||
const activeArea = computed(() => form.areas[0]);
|
||||
|
||||
const protection = useFormProtection(form);
|
||||
const pendingArea = ref<ProjectTemplateStateArea | null>(null);
|
||||
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 statusRequirement = computed(() =>
|
||||
pendingArea.value?.value === 'ticket_statuses'
|
||||
? props.templateState?.resetRequirements?.ticket_statuses
|
||||
: undefined,
|
||||
);
|
||||
|
||||
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)) {
|
||||
const canReset = computed(
|
||||
() =>
|
||||
statusRequirement.value?.removedStatuses.every((status) =>
|
||||
statusRequirement.value?.replacementOptions.some(
|
||||
(option) =>
|
||||
option.id === form.status_replacements[String(status.id)],
|
||||
),
|
||||
) ?? true,
|
||||
);
|
||||
const areaKeys = {
|
||||
project_settings: 'inheritance.area.projectSettings',
|
||||
board_columns: 'inheritance.area.boardColumns',
|
||||
ticket_statuses: 'inheritance.area.ticketStatuses',
|
||||
status_transitions: 'inheritance.area.statusTransitions',
|
||||
ticket_types: 'inheritance.area.ticketTypes',
|
||||
ticket_priorities: 'inheritance.area.ticketPriorities',
|
||||
ticket_fields: 'inheritance.area.ticketFields',
|
||||
ticket_link_types: 'inheritance.area.ticketLinkTypes',
|
||||
repository_connections: 'inheritance.area.repositoryConnections',
|
||||
notification_actions: 'inheritance.area.notificationActions',
|
||||
} as const;
|
||||
function areaLabel(area: ProjectTemplateStateArea): string {
|
||||
const key = areaKeys[area.value as keyof typeof areaKeys];
|
||||
return key ? t(key) : area.label;
|
||||
}
|
||||
function openReset(area: ProjectTemplateStateArea): void {
|
||||
form.resetAndClearErrors();
|
||||
protection.clearFeedback();
|
||||
pendingArea.value = area;
|
||||
}
|
||||
function closeReset(open: boolean): void {
|
||||
if (open || form.processing || !protection.confirmLeave()) {
|
||||
return;
|
||||
}
|
||||
|
||||
form.areas = [area.value];
|
||||
form.post(ProjectController.resetTemplate.url(props.projectId), {
|
||||
pendingArea.value = null;
|
||||
form.resetAndClearErrors();
|
||||
protection.clearFeedback();
|
||||
}
|
||||
function resetArea(): void {
|
||||
if (
|
||||
!pendingArea.value ||
|
||||
!canReset.value ||
|
||||
!overriddenAreas.value.some(
|
||||
(area) => area.value === pendingArea.value?.value,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
form.areas = [pendingArea.value.value];
|
||||
protection.submit(resetTemplate(props.projectId), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => form.reset(),
|
||||
onSuccess: () => {
|
||||
form.resetAndClearErrors();
|
||||
pendingArea.value = null;
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -81,97 +118,208 @@ const resetArea = (area: ProjectTemplateStateArea): void => {
|
||||
templateState?.inheritsFromTemplate &&
|
||||
(inheritedAreas.length > 0 || overriddenAreas.length > 0)
|
||||
"
|
||||
class="min-w-0 gap-0 overflow-hidden rounded-xl py-0 shadow-none"
|
||||
>
|
||||
<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 class="gap-stack grid-cols-1 border-b p-5 sm:p-6">
|
||||
<div class="flex items-center gap-2">
|
||||
<Layers3
|
||||
class="text-primary size-5 shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<h2 class="text-title">{{ t('inheritance.title') }}</h2>
|
||||
</div>
|
||||
<p class="text-muted-foreground break-words">
|
||||
{{
|
||||
t('inheritance.description', {
|
||||
template: templateState.templateName,
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
</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"
|
||||
<CardContent class="gap-column grid min-w-0 p-5 sm:p-6">
|
||||
<p class="text-caption text-muted-foreground">
|
||||
{{ t('inheritance.help') }}
|
||||
</p>
|
||||
<ul
|
||||
class="grid min-w-0 divide-y"
|
||||
:aria-label="t('inheritance.areas')"
|
||||
>
|
||||
<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"
|
||||
<li
|
||||
v-for="area in inheritedAreas"
|
||||
:key="area.value"
|
||||
class="flex min-w-0 flex-wrap items-center justify-between gap-3 py-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"
|
||||
<span class="min-w-0 break-words font-medium">{{
|
||||
areaLabel(area)
|
||||
}}</span>
|
||||
<Badge
|
||||
variant="outline"
|
||||
class="border-primary/25 text-primary"
|
||||
>{{ t('projectSettings.inherited') }}</Badge
|
||||
>
|
||||
<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>
|
||||
</li>
|
||||
<li
|
||||
v-for="area in overriddenAreas"
|
||||
:key="area.value"
|
||||
class="gap-stack grid min-w-0 py-3"
|
||||
>
|
||||
<div
|
||||
class="flex min-w-0 flex-wrap items-center justify-between gap-3"
|
||||
>
|
||||
<span class="min-w-0 break-words font-medium">{{
|
||||
areaLabel(area)
|
||||
}}</span>
|
||||
<Badge variant="secondary">{{
|
||||
t('projectSettings.override')
|
||||
}}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<InputError :message="form.errors.areas" />
|
||||
</div>
|
||||
<div
|
||||
class="flex flex-col items-start justify-between gap-3 sm:flex-row sm:items-center"
|
||||
>
|
||||
<p class="text-caption text-muted-foreground">
|
||||
{{ t('inheritance.overrideHelp') }}
|
||||
</p>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant="outline"
|
||||
class="shrink-0"
|
||||
:disabled="form.processing"
|
||||
:aria-label="
|
||||
t('inheritance.resetArea', {
|
||||
area: areaLabel(area),
|
||||
})
|
||||
"
|
||||
@click="openReset(area)"
|
||||
>
|
||||
<RotateCcw aria-hidden="true" />{{
|
||||
t('inheritance.reset')
|
||||
}}
|
||||
</Button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</CardContent>
|
||||
<Dialog :open="pendingArea !== null" @update:open="closeReset">
|
||||
<DialogContent
|
||||
:show-close-button="!form.processing"
|
||||
@escape-key-down="form.processing && $event.preventDefault()"
|
||||
@interact-outside="form.processing && $event.preventDefault()"
|
||||
>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{
|
||||
t('inheritance.confirmTitle')
|
||||
}}</DialogTitle>
|
||||
<DialogDescription>{{
|
||||
t('inheritance.confirmDescription', {
|
||||
area: pendingArea ? areaLabel(pendingArea) : '',
|
||||
template: templateState.templateName,
|
||||
})
|
||||
}}</DialogDescription>
|
||||
</DialogHeader>
|
||||
<form
|
||||
class="gap-column grid min-w-0"
|
||||
:aria-busy="form.processing"
|
||||
@submit.prevent="resetArea"
|
||||
>
|
||||
<FormFeedback
|
||||
:state="protection.state.value"
|
||||
:title="
|
||||
form.processing
|
||||
? t('inheritance.resetting')
|
||||
: undefined
|
||||
"
|
||||
@retry="resetArea"
|
||||
/>
|
||||
<InputError
|
||||
:message="form.errors.areas ?? form.errors['areas.0']"
|
||||
/>
|
||||
<fieldset
|
||||
class="gap-column grid min-w-0"
|
||||
:disabled="form.processing"
|
||||
>
|
||||
<legend class="sr-only">
|
||||
{{ t('inheritance.confirmTitle') }}
|
||||
</legend>
|
||||
<div
|
||||
v-if="statusRequirement"
|
||||
class="gap-column grid min-w-0"
|
||||
>
|
||||
<p class="text-caption text-muted-foreground">
|
||||
{{ t('inheritance.statusHelp') }}
|
||||
</p>
|
||||
<div
|
||||
v-for="status in statusRequirement.removedStatuses"
|
||||
:key="status.id"
|
||||
class="grid gap-2"
|
||||
>
|
||||
<Label :for="'replacement-' + status.id">{{
|
||||
t('inheritance.statusLabel', {
|
||||
status: status.name,
|
||||
count: status.ticketCount,
|
||||
})
|
||||
}}</Label>
|
||||
<select
|
||||
:id="'replacement-' + status.id"
|
||||
v-model="
|
||||
form.status_replacements[
|
||||
String(status.id)
|
||||
]
|
||||
"
|
||||
class="border-input bg-background focus-visible:border-ring focus-visible:ring-ring/50 min-h-11 w-full min-w-0 rounded-md border px-3 py-2 text-sm outline-none focus-visible:ring-2"
|
||||
:aria-invalid="
|
||||
!!form.errors[
|
||||
`status_replacements.${status.id}`
|
||||
]
|
||||
"
|
||||
:aria-describedby="
|
||||
'replacement-error-' + status.id
|
||||
"
|
||||
>
|
||||
<option :value="undefined" disabled>
|
||||
{{ t('inheritance.selectStatus') }}
|
||||
</option>
|
||||
<option
|
||||
v-for="option in statusRequirement.replacementOptions"
|
||||
:key="option.id"
|
||||
:value="option.id"
|
||||
>
|
||||
{{ option.name }}
|
||||
</option>
|
||||
</select>
|
||||
<InputError
|
||||
:id="'replacement-error-' + status.id"
|
||||
:message="
|
||||
form.errors[
|
||||
`status_replacements.${status.id}`
|
||||
]
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
class="border-destructive/25 bg-destructive/8 rounded-lg border p-3 text-sm"
|
||||
>
|
||||
{{ t('inheritance.resetWarning') }}
|
||||
</p>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
@click="closeReset(false)"
|
||||
>{{ t('common.cancel') }}</Button
|
||||
>
|
||||
<Button type="submit" :disabled="!canReset">{{
|
||||
t(
|
||||
form.processing
|
||||
? 'inheritance.resetting'
|
||||
: 'inheritance.reset',
|
||||
)
|
||||
}}</Button>
|
||||
</DialogFooter>
|
||||
</fieldset>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</Card>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<script setup lang="ts">
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { Settings2 } from 'lucide-vue-next';
|
||||
import { useAppNavigation } from '@/composables/useAppNavigation';
|
||||
import { useCurrentUrl } from '@/composables/useCurrentUrl';
|
||||
import { useLocalization } from '@/composables/useLocalization';
|
||||
import { toUrl } from '@/lib/utils';
|
||||
|
||||
defineProps<{ projectName: string; projectKey: string }>();
|
||||
const { projectSettingsItems } = useAppNavigation();
|
||||
const { isCurrentUrl } = useCurrentUrl();
|
||||
const { t } = useLocalization();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="gap-page md:p-page mx-auto flex w-full min-w-0 max-w-7xl flex-1 flex-col p-4"
|
||||
>
|
||||
<header class="gap-stack grid min-w-0">
|
||||
<div class="text-primary flex items-center gap-2">
|
||||
<Settings2 class="size-4" aria-hidden="true" />
|
||||
<p class="text-label text-muted-foreground break-all uppercase">
|
||||
{{ projectKey }}
|
||||
</p>
|
||||
</div>
|
||||
<h1 class="text-headline-mobile md:text-headline break-words">
|
||||
{{ t('navigation.projectSettings') }}
|
||||
</h1>
|
||||
<p class="text-muted-foreground break-words">
|
||||
{{ t('projectSettings.description', { project: projectName }) }}
|
||||
</p>
|
||||
</header>
|
||||
<div
|
||||
class="bg-card grid min-w-0 grid-cols-1 overflow-hidden rounded-xl border shadow-sm lg:grid-cols-[15rem_minmax(0,1fr)]"
|
||||
>
|
||||
<aside
|
||||
class="bg-muted/35 min-w-0 border-b p-3 lg:border-b-0 lg:border-r lg:p-4"
|
||||
>
|
||||
<nav
|
||||
class="flex gap-2 overflow-x-auto pb-1 lg:flex-col lg:overflow-visible lg:pb-0"
|
||||
:aria-label="t('navigation.projectSettings')"
|
||||
>
|
||||
<Link
|
||||
v-for="item in projectSettingsItems"
|
||||
:key="toUrl(item.href)"
|
||||
:href="item.href"
|
||||
:aria-current="
|
||||
isCurrentUrl(item.href) ? 'page' : undefined
|
||||
"
|
||||
:class="[
|
||||
'text-body focus-visible:ring-ring/40 flex min-h-11 shrink-0 items-center gap-2 rounded-lg border px-3 font-medium outline-none transition-colors focus-visible:ring-2 lg:w-full',
|
||||
isCurrentUrl(item.href)
|
||||
? 'border-primary/25 bg-accent text-accent-foreground shadow-xs'
|
||||
: 'text-muted-foreground hover:border-border hover:bg-background hover:text-foreground border-transparent',
|
||||
]"
|
||||
>
|
||||
<component
|
||||
:is="item.icon"
|
||||
class="size-4 shrink-0"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span class="whitespace-nowrap">{{ item.title }}</span>
|
||||
</Link>
|
||||
</nav>
|
||||
</aside>
|
||||
<div class="min-w-0 p-4 sm:p-6 lg:p-8">
|
||||
<section class="gap-page mx-auto grid w-full min-w-0 max-w-3xl">
|
||||
<slot />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -731,6 +731,84 @@ export const en = {
|
||||
'ticketForm.saved': 'All changes saved',
|
||||
'ticketForm.authorRestricted': 'Only project admins can change the author.',
|
||||
'ticketForm.blocker': 'Blocker',
|
||||
'projectSettings.pageTitle': '{project} general settings',
|
||||
'projectSettings.description':
|
||||
'Manage settings and template inheritance for {project}.',
|
||||
'projectSettings.generalDescription':
|
||||
'Review project identity, setting sources, and administrative actions.',
|
||||
'projectSettings.identity': 'Project identity',
|
||||
'projectSettings.identityDescription':
|
||||
'The name and key belong to this project and are never inherited from a template.',
|
||||
'projectSettings.name': 'Project name',
|
||||
'projectSettings.key': 'Project key',
|
||||
'projectSettings.local': 'Local',
|
||||
'projectSettings.inherited': 'Inherited',
|
||||
'projectSettings.override': 'Local override',
|
||||
'projectSettings.display': 'Ticket display',
|
||||
'projectSettings.showAuthor': 'Show author',
|
||||
'projectSettings.showStoryPoints': 'Show story points',
|
||||
'projectSettings.enabled': 'Enabled',
|
||||
'projectSettings.disabled': 'Disabled',
|
||||
'projectSettings.displayDescription':
|
||||
'Manage these display options in Ticket settings.',
|
||||
'projectSettings.template': 'Template baseline',
|
||||
'projectSettings.templateDescription':
|
||||
'Manage the linked template or reset individual areas using the inheritance panel.',
|
||||
'projectSettings.currentTemplate': 'Current linked template',
|
||||
'projectSettings.noTemplate': 'No linked template',
|
||||
'projectSettings.linked': 'Template inheritance active',
|
||||
'projectSettings.standalone': 'Standalone',
|
||||
'projectSettings.standaloneDescription':
|
||||
'This project manages its settings locally. Published template updates are not applied.',
|
||||
'projectSettings.noAlternatives': 'No other published templates',
|
||||
'projectSettings.noAlternativesDescription':
|
||||
'A different published template is required to switch this project.',
|
||||
'projectSettings.switch': 'Switch template',
|
||||
'projectSettings.switching': 'Switching template…',
|
||||
'projectSettings.switchWarning':
|
||||
'Switching templates can replace or remove project configuration in copied areas, including workflows, ticket metadata, repositories, and notifications.',
|
||||
'projectSettings.publishedTemplate': 'Published template',
|
||||
'projectSettings.selectTemplate': 'Select a template',
|
||||
'projectSettings.confirmation': 'Confirmation key',
|
||||
'projectSettings.confirmPlaceholder': 'Type {key} exactly',
|
||||
'projectSettings.confirmHelp':
|
||||
'Enter the exact project key {key} to confirm this action. The key is case sensitive.',
|
||||
'projectSettings.danger': 'Danger zone',
|
||||
'projectSettings.deleteDescription':
|
||||
'Permanently delete this project and all of its tickets, board columns, ticket metadata, repository connections, and project permissions.',
|
||||
'projectSettings.irreversible': 'This action cannot be undone.',
|
||||
'projectSettings.delete': 'Delete project',
|
||||
'projectSettings.deleting': 'Deleting project…',
|
||||
'projectSettings.updated': 'Project settings updated.',
|
||||
'inheritance.title': 'Template inheritance',
|
||||
'inheritance.description': 'Settings linked to {template}.',
|
||||
'inheritance.help':
|
||||
'Each area inherits independently. Settings outside the template are managed locally.',
|
||||
'inheritance.areas': 'Setting sources',
|
||||
'inheritance.overrideHelp':
|
||||
'Local changes stay in place when the template is updated.',
|
||||
'inheritance.reset': 'Reset to template',
|
||||
'inheritance.resetArea': 'Reset {area} to template',
|
||||
'inheritance.resetting': 'Resetting…',
|
||||
'inheritance.confirmTitle': 'Reset this setting area?',
|
||||
'inheritance.confirmDescription':
|
||||
'Replace local changes in {area} with the current baseline from {template}. Other setting areas keep their current values.',
|
||||
'inheritance.resetWarning':
|
||||
'Local configuration in this area may be replaced or removed.',
|
||||
'inheritance.statusHelp':
|
||||
'Choose where tickets in local statuses should move before those statuses are removed.',
|
||||
'inheritance.statusLabel': '{status} ({count} tickets)',
|
||||
'inheritance.selectStatus': 'Select replacement status',
|
||||
'inheritance.area.projectSettings': 'Project settings',
|
||||
'inheritance.area.boardColumns': 'Board columns',
|
||||
'inheritance.area.ticketStatuses': 'Ticket statuses',
|
||||
'inheritance.area.statusTransitions': 'Status transitions',
|
||||
'inheritance.area.ticketTypes': 'Ticket types',
|
||||
'inheritance.area.ticketPriorities': 'Ticket priorities',
|
||||
'inheritance.area.ticketFields': 'Custom ticket fields',
|
||||
'inheritance.area.ticketLinkTypes': 'Ticket link types',
|
||||
'inheritance.area.repositoryConnections': 'Repository connections',
|
||||
'inheritance.area.notificationActions': 'Notification actions',
|
||||
'gitConnections.description':
|
||||
'Connect your personal Git account to browse repositories, branches, and pull requests you can access.',
|
||||
'gitConnections.privacy':
|
||||
|
||||
@@ -1,281 +1,316 @@
|
||||
<script setup lang="ts">
|
||||
import { Head, Link, useForm } from '@inertiajs/vue3';
|
||||
import ProjectController from '@/actions/App/Http/Controllers/ProjectController';
|
||||
import Heading from '@/components/Heading.vue';
|
||||
import { Head, useForm } from '@inertiajs/vue3';
|
||||
import { Layers3, Trash2 } from 'lucide-vue-next';
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
destroy,
|
||||
switchTemplate,
|
||||
} from '@/actions/App/Http/Controllers/ProjectController';
|
||||
import FeedbackState from '@/components/FeedbackState.vue';
|
||||
import FormFeedback from '@/components/FormFeedback.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 {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { useFormProtection } from '@/composables/useFormProtection';
|
||||
import { useLocalization } from '@/composables/useLocalization';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import SettingsLayout from '@/layouts/projects/SettingsLayout.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 { general } from '@/routes/projects/settings';
|
||||
import type { BreadcrumbItem, ProjectGeneralSettingsPageProps } from '@/types';
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps<ProjectGeneralSettingsPageProps>();
|
||||
|
||||
const breadcrumbs: BreadcrumbItem[] = [
|
||||
{
|
||||
title: 'Projects',
|
||||
href: index(),
|
||||
},
|
||||
{
|
||||
title: props.project.name,
|
||||
href: show(props.project.id),
|
||||
},
|
||||
{
|
||||
title: 'General settings',
|
||||
href: generalSettings(props.project.id),
|
||||
},
|
||||
];
|
||||
|
||||
const switchTemplateForm = useForm({
|
||||
const { t } = useLocalization();
|
||||
const breadcrumbs = computed<BreadcrumbItem[]>(() => [
|
||||
{ title: t('navigation.projects'), href: index() },
|
||||
{ title: props.project.name, href: show(props.project.id) },
|
||||
{ title: t('navigation.general'), href: general(props.project.id) },
|
||||
]);
|
||||
const switchTemplateForm = useForm<{
|
||||
confirmation_key: string;
|
||||
source_template_id: number | undefined;
|
||||
}>({
|
||||
confirmation_key: '',
|
||||
source_template_id: props.sourceTemplates.find(
|
||||
(template) => template.id !== props.project.project_template_id,
|
||||
)?.id,
|
||||
source_template_id: undefined,
|
||||
});
|
||||
|
||||
const deleteForm = useForm({
|
||||
confirmation_key: '',
|
||||
});
|
||||
|
||||
const deleteForm = useForm({ confirmation_key: '' });
|
||||
const switchProtection = useFormProtection(switchTemplateForm);
|
||||
const deleteProtection = useFormProtection(deleteForm);
|
||||
const processing = computed(
|
||||
() => switchTemplateForm.processing || deleteForm.processing,
|
||||
);
|
||||
const availableSwitchTemplates = computed(() =>
|
||||
props.sourceTemplates.filter(
|
||||
(template) => template.id !== props.project.project_template_id,
|
||||
),
|
||||
);
|
||||
|
||||
const currentTemplate = computed(() => props.project.project_template ?? null);
|
||||
|
||||
const isSwitchConfirmationValid = computed(
|
||||
() => switchTemplateForm.confirmation_key === props.project.key,
|
||||
);
|
||||
|
||||
const canSwitchTemplate = computed(
|
||||
() =>
|
||||
isSwitchConfirmationValid.value &&
|
||||
switchTemplateForm.source_template_id !== undefined,
|
||||
switchTemplateForm.confirmation_key === props.project.key &&
|
||||
availableSwitchTemplates.value.some(
|
||||
(template) => template.id === switchTemplateForm.source_template_id,
|
||||
),
|
||||
);
|
||||
|
||||
const isDeleteConfirmationValid = computed(
|
||||
() => deleteForm.confirmation_key === props.project.key,
|
||||
);
|
||||
const inheritanceAreas = computed(() =>
|
||||
[
|
||||
...(props.templateState?.inheritedAreas ?? []),
|
||||
...(props.templateState?.overriddenAreas ?? []),
|
||||
].map((area) => area.value),
|
||||
);
|
||||
const settingsSource = computed(() => {
|
||||
if (!props.templateState?.inheritsFromTemplate) {
|
||||
return 'projectSettings.local';
|
||||
}
|
||||
if (
|
||||
props.templateState.inheritedAreas.some(
|
||||
(area) => area.value === 'project_settings',
|
||||
)
|
||||
) {
|
||||
return 'projectSettings.inherited';
|
||||
}
|
||||
return props.templateState.overriddenAreas.some(
|
||||
(area) => area.value === 'project_settings',
|
||||
)
|
||||
? 'projectSettings.override'
|
||||
: 'projectSettings.local';
|
||||
});
|
||||
|
||||
const submitSwitchTemplate = (): void => {
|
||||
if (!canSwitchTemplate.value) {
|
||||
function submitSwitchTemplate(): void {
|
||||
if (!canSwitchTemplate.value || processing.value) {
|
||||
return;
|
||||
}
|
||||
switchProtection.submit(switchTemplate(props.project.id), {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => switchTemplateForm.resetAndClearErrors(),
|
||||
});
|
||||
}
|
||||
|
||||
switchTemplateForm.post(
|
||||
ProjectController.switchTemplate.url(props.project.id),
|
||||
{
|
||||
preserveScroll: true,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const submitDelete = (): void => {
|
||||
if (!isDeleteConfirmationValid.value) {
|
||||
function submitDelete(): void {
|
||||
if (!isDeleteConfirmationValid.value || processing.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
deleteForm.delete(ProjectController.destroy.url(props.project.id), {
|
||||
deleteProtection.submit(destroy(props.project.id), {
|
||||
preserveScroll: true,
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout :breadcrumbs="breadcrumbs">
|
||||
<Head :title="`${project.name} general settings`" />
|
||||
|
||||
<div class="flex flex-1 flex-col gap-6 p-4">
|
||||
<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} general settings`"
|
||||
description="Review the core project identity and manage irreversible administrative actions."
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-3">
|
||||
<Button as-child variant="outline">
|
||||
<Link :href="boardSettings(project.id)">
|
||||
Board settings
|
||||
</Link>
|
||||
</Button>
|
||||
|
||||
<Button as-child variant="outline">
|
||||
<Link :href="metadataSettings(project.id)">
|
||||
Ticket 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
|
||||
<Head
|
||||
:title="t('projectSettings.pageTitle', { project: project.name })"
|
||||
/>
|
||||
<SettingsLayout :project-name="project.name" :project-key="project.key">
|
||||
<FeedbackState
|
||||
v-if="status"
|
||||
class="rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-900 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-100"
|
||||
state="success"
|
||||
:title="t('projectSettings.updated')"
|
||||
/>
|
||||
<Card
|
||||
class="min-w-0 gap-0 overflow-hidden rounded-xl py-0 shadow-none"
|
||||
>
|
||||
{{ status }}
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Project identity</CardTitle>
|
||||
<CardDescription>
|
||||
These values define the project across tickets, boards,
|
||||
and repository matching.
|
||||
</CardDescription>
|
||||
<CardHeader class="gap-stack grid-cols-1 border-b p-5 sm:p-6">
|
||||
<h2 class="text-title">{{ t('navigation.general') }}</h2>
|
||||
<p class="text-muted-foreground">
|
||||
{{ t('projectSettings.generalDescription') }}
|
||||
</p>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent 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]"
|
||||
>
|
||||
Project name
|
||||
</p>
|
||||
<p class="text-foreground mt-2 text-sm font-semibold">
|
||||
{{ project.name }}
|
||||
</p>
|
||||
<CardContent class="gap-column grid min-w-0 p-5 sm:p-6">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<h3 class="font-semibold">
|
||||
{{ t('projectSettings.identity') }}
|
||||
</h3>
|
||||
<Badge variant="secondary">{{
|
||||
t('projectSettings.local')
|
||||
}}</Badge>
|
||||
</div>
|
||||
|
||||
<div class="border-border/70 rounded-xl border p-4">
|
||||
<p
|
||||
class="text-muted-foreground text-xs font-semibold uppercase tracking-[0.18em]"
|
||||
<dl class="grid min-w-0 gap-4 sm:grid-cols-2">
|
||||
<div
|
||||
class="bg-muted/35 gap-stack grid min-w-0 rounded-lg border p-4"
|
||||
>
|
||||
<dt class="text-caption text-muted-foreground">
|
||||
{{ t('projectSettings.name') }}
|
||||
</dt>
|
||||
<dd class="break-words font-semibold">
|
||||
{{ project.name }}
|
||||
</dd>
|
||||
</div>
|
||||
<div
|
||||
class="bg-muted/35 gap-stack grid min-w-0 rounded-lg border p-4"
|
||||
>
|
||||
<dt class="text-caption text-muted-foreground">
|
||||
{{ t('projectSettings.key') }}
|
||||
</dt>
|
||||
<dd class="break-all font-semibold">
|
||||
{{ project.key }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p class="text-caption text-muted-foreground">
|
||||
{{ t('projectSettings.identityDescription') }}
|
||||
</p>
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-2 border-t pt-4"
|
||||
>
|
||||
<h3 class="font-semibold">
|
||||
{{ t('projectSettings.display') }}
|
||||
</h3>
|
||||
<Badge
|
||||
:variant="
|
||||
settingsSource === 'projectSettings.inherited'
|
||||
? 'outline'
|
||||
: 'secondary'
|
||||
"
|
||||
>{{ t(settingsSource) }}</Badge
|
||||
>
|
||||
Project key
|
||||
</p>
|
||||
<p class="text-foreground mt-2 text-sm font-semibold">
|
||||
{{ project.key }}
|
||||
</p>
|
||||
</div>
|
||||
<dl class="grid gap-3">
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<dt class="text-muted-foreground">
|
||||
{{ t('projectSettings.showAuthor') }}
|
||||
</dt>
|
||||
<dd class="font-medium">
|
||||
{{
|
||||
t(
|
||||
project.show_author
|
||||
? 'projectSettings.enabled'
|
||||
: 'projectSettings.disabled',
|
||||
)
|
||||
}}
|
||||
</dd>
|
||||
</div>
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<dt class="text-muted-foreground">
|
||||
{{ t('projectSettings.showStoryPoints') }}
|
||||
</dt>
|
||||
<dd class="font-medium">
|
||||
{{
|
||||
t(
|
||||
project.show_story_points
|
||||
? 'projectSettings.enabled'
|
||||
: 'projectSettings.disabled',
|
||||
)
|
||||
}}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p class="text-caption text-muted-foreground">
|
||||
{{ t('projectSettings.displayDescription') }}
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Template baseline</CardTitle>
|
||||
<CardDescription>
|
||||
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]"
|
||||
>
|
||||
Current linked template
|
||||
</p>
|
||||
<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.'
|
||||
: '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]"
|
||||
>
|
||||
Warning
|
||||
</p>
|
||||
<p class="text-foreground mt-2 text-sm font-medium">
|
||||
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.
|
||||
</p>
|
||||
</div>
|
||||
<TemplateInheritancePanel
|
||||
:project-id="project.id"
|
||||
:areas="inheritanceAreas"
|
||||
:template-state="templateState"
|
||||
/>
|
||||
<Card
|
||||
class="min-w-0 gap-0 overflow-hidden rounded-xl py-0 shadow-none"
|
||||
>
|
||||
<CardHeader class="gap-stack grid-cols-1 border-b p-5 sm:p-6">
|
||||
<div class="flex items-center gap-2">
|
||||
<Layers3
|
||||
class="text-primary size-5"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<h2 class="text-title">
|
||||
{{ t('projectSettings.template') }}
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-6">
|
||||
<form
|
||||
class="space-y-4 rounded-xl border p-4"
|
||||
@submit.prevent="submitSwitchTemplate"
|
||||
<p class="text-muted-foreground">
|
||||
{{ t('projectSettings.templateDescription') }}
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent class="gap-column grid min-w-0 p-5 sm:p-6">
|
||||
<div
|
||||
class="bg-muted/35 gap-stack grid min-w-0 rounded-lg border p-4"
|
||||
>
|
||||
<p class="text-caption text-muted-foreground">
|
||||
{{ t('projectSettings.currentTemplate') }}
|
||||
</p>
|
||||
<p class="break-words font-semibold">
|
||||
{{
|
||||
currentTemplate?.name ??
|
||||
t('projectSettings.noTemplate')
|
||||
}}
|
||||
</p>
|
||||
<Badge variant="outline" class="justify-self-start">{{
|
||||
t(
|
||||
templateState?.inheritsFromTemplate
|
||||
? 'projectSettings.linked'
|
||||
: 'projectSettings.standalone',
|
||||
)
|
||||
}}</Badge>
|
||||
<p
|
||||
v-if="!templateState?.inheritsFromTemplate"
|
||||
class="text-caption text-muted-foreground"
|
||||
>
|
||||
<div class="space-y-1">
|
||||
<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.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{ t('projectSettings.standaloneDescription') }}
|
||||
</p>
|
||||
</div>
|
||||
<FeedbackState
|
||||
v-if="availableSwitchTemplates.length === 0"
|
||||
state="empty"
|
||||
:title="t('projectSettings.noAlternatives')"
|
||||
:description="
|
||||
t('projectSettings.noAlternativesDescription')
|
||||
"
|
||||
/>
|
||||
<form
|
||||
v-else
|
||||
class="gap-column grid min-w-0"
|
||||
:aria-busy="switchTemplateForm.processing"
|
||||
@submit.prevent="submitSwitchTemplate"
|
||||
>
|
||||
<FormFeedback
|
||||
:state="switchProtection.state.value"
|
||||
:title="
|
||||
switchTemplateForm.processing
|
||||
? t('projectSettings.switching')
|
||||
: undefined
|
||||
"
|
||||
@retry="submitSwitchTemplate"
|
||||
/>
|
||||
<fieldset
|
||||
class="gap-column grid min-w-0"
|
||||
:disabled="processing"
|
||||
>
|
||||
<legend class="mb-3 font-semibold">
|
||||
{{ t('projectSettings.switch') }}
|
||||
</legend>
|
||||
<p
|
||||
class="border-destructive/25 bg-destructive/8 rounded-lg border p-4"
|
||||
>
|
||||
{{ t('projectSettings.switchWarning') }}
|
||||
</p>
|
||||
<div class="grid gap-2">
|
||||
<Label for="source_template_id"
|
||||
>Published template</Label
|
||||
>
|
||||
<Label for="source_template_id">{{
|
||||
t('projectSettings.publishedTemplate')
|
||||
}}</Label>
|
||||
<select
|
||||
id="source_template_id"
|
||||
v-model="
|
||||
switchTemplateForm.source_template_id
|
||||
"
|
||||
:disabled="
|
||||
switchTemplateForm.processing ||
|
||||
availableSwitchTemplates.length === 0
|
||||
class="border-input bg-background focus-visible:border-ring focus-visible:ring-ring/50 min-h-11 w-full min-w-0 rounded-md border px-3 py-2 text-sm outline-none focus-visible:ring-2"
|
||||
:aria-invalid="
|
||||
!!switchTemplateForm.errors
|
||||
.source_template_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]"
|
||||
aria-describedby="source-template-error"
|
||||
>
|
||||
<option :value="undefined" disabled>
|
||||
Select a template
|
||||
{{
|
||||
t('projectSettings.selectTemplate')
|
||||
}}
|
||||
</option>
|
||||
<option
|
||||
v-for="template in availableSwitchTemplates"
|
||||
@@ -286,120 +321,167 @@ const submitDelete = (): void => {
|
||||
</option>
|
||||
</select>
|
||||
<InputError
|
||||
id="source-template-error"
|
||||
: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">{{
|
||||
t('projectSettings.confirmation')
|
||||
}}</Label>
|
||||
<Input
|
||||
id="switch_confirmation_key"
|
||||
v-model="
|
||||
switchTemplateForm.confirmation_key
|
||||
"
|
||||
:disabled="switchTemplateForm.processing"
|
||||
placeholder="Type the project key exactly"
|
||||
autocomplete="off"
|
||||
:placeholder="
|
||||
t(
|
||||
'projectSettings.confirmPlaceholder',
|
||||
{ key: project.key },
|
||||
)
|
||||
"
|
||||
:aria-invalid="
|
||||
!!switchTemplateForm.errors
|
||||
.confirmation_key
|
||||
"
|
||||
aria-describedby="switch-confirm-help switch-confirm-error"
|
||||
/>
|
||||
<p
|
||||
id="switch-confirm-help"
|
||||
class="text-caption text-muted-foreground"
|
||||
>
|
||||
{{
|
||||
t('projectSettings.confirmHelp', {
|
||||
key: project.key,
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
<InputError
|
||||
id="switch-confirm-error"
|
||||
:message="
|
||||
switchTemplateForm.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">
|
||||
Existing project-specific configuration in
|
||||
copied areas may be replaced or removed.
|
||||
</p>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
variant="outline"
|
||||
:disabled="
|
||||
switchTemplateForm.processing ||
|
||||
!canSwitchTemplate
|
||||
"
|
||||
>
|
||||
Switch template
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card
|
||||
class="border-red-200/80 bg-red-50/60 dark:border-red-900/60 dark:bg-red-950/20"
|
||||
>
|
||||
<CardHeader>
|
||||
<CardTitle class="text-red-900 dark:text-red-100">
|
||||
Danger zone
|
||||
</CardTitle>
|
||||
<CardDescription
|
||||
class="text-red-800/80 dark:text-red-200/80"
|
||||
>
|
||||
Deleting this project is permanent. All tickets, board
|
||||
columns, ticket metadata, repository connections, and
|
||||
project permissions will be removed.
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent class="space-y-5">
|
||||
<div
|
||||
class="bg-background/80 rounded-xl border border-red-200/80 p-4 dark:border-red-900/60"
|
||||
>
|
||||
<p class="text-foreground text-sm font-medium">
|
||||
Confirm by typing the exact project key:
|
||||
<span class="font-semibold">{{ project.key }}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<form class="space-y-4" @submit.prevent="submitDelete">
|
||||
<div class="grid gap-2">
|
||||
<Label for="confirmation_key">
|
||||
Confirmation key
|
||||
</Label>
|
||||
<Input
|
||||
id="confirmation_key"
|
||||
v-model="deleteForm.confirmation_key"
|
||||
:disabled="deleteForm.processing"
|
||||
placeholder="Type the project key exactly"
|
||||
/>
|
||||
<InputError
|
||||
:message="deleteForm.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 action cannot be undone.
|
||||
</p>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
variant="destructive"
|
||||
:disabled="
|
||||
deleteForm.processing ||
|
||||
!isDeleteConfirmationValid
|
||||
"
|
||||
variant="outline"
|
||||
class="justify-self-start"
|
||||
:disabled="!canSwitchTemplate"
|
||||
>{{
|
||||
t(
|
||||
switchTemplateForm.processing
|
||||
? 'projectSettings.switching'
|
||||
: 'projectSettings.switch',
|
||||
)
|
||||
}}</Button
|
||||
>
|
||||
Delete project
|
||||
</Button>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
<Card
|
||||
class="border-destructive/30 min-w-0 gap-0 overflow-hidden rounded-xl py-0 shadow-none"
|
||||
>
|
||||
<CardHeader
|
||||
class="bg-destructive/5 gap-stack grid-cols-1 border-b p-5 sm:p-6"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<Trash2
|
||||
class="text-destructive size-5"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<h2 class="text-title">
|
||||
{{ t('projectSettings.danger') }}
|
||||
</h2>
|
||||
</div>
|
||||
<p class="text-muted-foreground">
|
||||
{{ t('projectSettings.deleteDescription') }}
|
||||
</p>
|
||||
</CardHeader>
|
||||
<CardContent class="p-5 sm:p-6">
|
||||
<form
|
||||
class="gap-column grid min-w-0"
|
||||
:aria-busy="deleteForm.processing"
|
||||
@submit.prevent="submitDelete"
|
||||
>
|
||||
<FormFeedback
|
||||
:state="deleteProtection.state.value"
|
||||
:title="
|
||||
deleteForm.processing
|
||||
? t('projectSettings.deleting')
|
||||
: undefined
|
||||
"
|
||||
@retry="submitDelete"
|
||||
/>
|
||||
<fieldset
|
||||
class="gap-column grid min-w-0"
|
||||
:disabled="processing"
|
||||
>
|
||||
<legend class="sr-only">
|
||||
{{ t('projectSettings.delete') }}
|
||||
</legend>
|
||||
<p class="text-caption font-medium">
|
||||
{{ t('projectSettings.irreversible') }}
|
||||
</p>
|
||||
<div class="grid gap-2">
|
||||
<Label for="confirmation_key">{{
|
||||
t('projectSettings.confirmation')
|
||||
}}</Label>
|
||||
<Input
|
||||
id="confirmation_key"
|
||||
v-model="deleteForm.confirmation_key"
|
||||
autocomplete="off"
|
||||
:placeholder="
|
||||
t(
|
||||
'projectSettings.confirmPlaceholder',
|
||||
{ key: project.key },
|
||||
)
|
||||
"
|
||||
:aria-invalid="
|
||||
!!deleteForm.errors.confirmation_key
|
||||
"
|
||||
aria-describedby="delete-confirm-help delete-confirm-error"
|
||||
/>
|
||||
<p
|
||||
id="delete-confirm-help"
|
||||
class="text-caption text-muted-foreground"
|
||||
>
|
||||
{{
|
||||
t('projectSettings.confirmHelp', {
|
||||
key: project.key,
|
||||
})
|
||||
}}
|
||||
</p>
|
||||
<InputError
|
||||
id="delete-confirm-error"
|
||||
:message="
|
||||
deleteForm.errors.confirmation_key
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="destructive"
|
||||
class="justify-self-start"
|
||||
:disabled="!isDeleteConfirmationValid"
|
||||
>{{
|
||||
t(
|
||||
deleteForm.processing
|
||||
? 'projectSettings.deleting'
|
||||
: 'projectSettings.delete',
|
||||
)
|
||||
}}</Button
|
||||
>
|
||||
</fieldset>
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</SettingsLayout>
|
||||
</AppLayout>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Projects;
|
||||
|
||||
use Symfony\Component\Process\Process;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProjectGeneralSettingsUiTest extends TestCase
|
||||
{
|
||||
public function test_general_settings_render_setting_sources_confirmations_and_localization(): void
|
||||
{
|
||||
$process = new Process(['node', 'tests/Fixtures/project-general-settings.mjs'], base_path());
|
||||
$process->setTimeout(60);
|
||||
$process->run();
|
||||
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||
$this->assertStringContainsString('Project general settings rendering checks passed.', $process->getOutput());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import process from 'node:process';
|
||||
|
||||
const { chromium } = await import(
|
||||
process.env.PLAYWRIGHT_MODULE ?? 'playwright'
|
||||
);
|
||||
const browser = await chromium.launch({ channel: 'chrome', headless: true });
|
||||
const base = 'http://127.0.0.1:4187';
|
||||
const context = await browser.newContext({
|
||||
viewport: { width: 1440, height: 1000 },
|
||||
});
|
||||
const page = await context.newPage();
|
||||
page.setDefaultTimeout(10000);
|
||||
const errors = [];
|
||||
page.on('pageerror', (error) => errors.push(error.message));
|
||||
const mutations = [];
|
||||
page.on('request', (request) => {
|
||||
if (['POST', 'DELETE'].includes(request.method())) {
|
||||
mutations.push(request);
|
||||
}
|
||||
});
|
||||
const dialog = () => page.getByRole('dialog');
|
||||
const button = (name) => page.getByRole('button', { name, exact: true });
|
||||
const confirmReset = () =>
|
||||
dialog().getByRole('button', { name: 'Reset to template', exact: true });
|
||||
const result = (value) =>
|
||||
context.addCookies([{ name: 'general_test_result', value, url: base }]);
|
||||
const visit = async (query = '?reset') => {
|
||||
await result('success');
|
||||
await page.goto(base + '/projects/1/settings/general' + query);
|
||||
await page.getByRole('heading', { name: 'General', exact: true }).waitFor();
|
||||
};
|
||||
const noOverflow = async () =>
|
||||
assert.equal(
|
||||
await page.evaluate(
|
||||
() => document.documentElement.scrollWidth <= window.innerWidth,
|
||||
),
|
||||
true,
|
||||
);
|
||||
const formState = (form, state) =>
|
||||
form
|
||||
.locator('[data-form-state="' + state + '"]')
|
||||
.waitFor({ state: 'visible' });
|
||||
try {
|
||||
for (const width of [1440, 390, 320]) {
|
||||
await page.setViewportSize({ width, height: 1000 });
|
||||
for (const theme of ['light', 'dark']) {
|
||||
await page.emulateMedia({ colorScheme: theme });
|
||||
await visit();
|
||||
await noOverflow();
|
||||
const nav = page.getByRole('navigation', {
|
||||
name: 'Project settings',
|
||||
exact: true,
|
||||
});
|
||||
assert.equal(
|
||||
await nav
|
||||
.getByRole('link', { name: 'General', exact: true })
|
||||
.getAttribute('aria-current'),
|
||||
'page',
|
||||
);
|
||||
assert.equal(
|
||||
await nav
|
||||
.getByRole('link', { name: 'Ticket settings', exact: true })
|
||||
.getAttribute('href'),
|
||||
'/projects/1/settings/metadata',
|
||||
);
|
||||
const sources = page.getByRole('list', { name: 'Setting sources' });
|
||||
await sources.getByText('Inherited', { exact: true }).waitFor();
|
||||
await sources
|
||||
.getByText('Local override', { exact: true })
|
||||
.first()
|
||||
.waitFor();
|
||||
assert.equal(await button('Switch template').isDisabled(), true);
|
||||
assert.equal(await button('Delete project').isDisabled(), true);
|
||||
if (width === 390 || width === 1440) {
|
||||
await page.screenshot({
|
||||
path: '/private/tmp/KAN-39-' + width + '-' + theme + '.png',
|
||||
fullPage: true,
|
||||
});
|
||||
}
|
||||
const trigger = button('Reset Project settings to template');
|
||||
await trigger.focus();
|
||||
await page.keyboard.press('Enter');
|
||||
await dialog().waitFor();
|
||||
await page.keyboard.press('Tab');
|
||||
assert.equal(
|
||||
await dialog().evaluate((element) =>
|
||||
element.contains(document.activeElement),
|
||||
),
|
||||
true,
|
||||
);
|
||||
await noOverflow();
|
||||
await page.keyboard.press('Escape');
|
||||
await dialog().waitFor({ state: 'hidden' });
|
||||
assert.equal(
|
||||
await trigger.evaluate(
|
||||
(element) => document.activeElement === element,
|
||||
),
|
||||
true,
|
||||
);
|
||||
assert.equal(
|
||||
mutations.length,
|
||||
0,
|
||||
'Opening and cancelling reset must not send a mutation',
|
||||
);
|
||||
}
|
||||
}
|
||||
await visit('?reset&noTemplate');
|
||||
await page.getByText('No linked template', { exact: true }).waitFor();
|
||||
assert.equal(await button('Reset Project settings to template').count(), 0);
|
||||
await visit('?reset&baseline');
|
||||
assert.equal(
|
||||
await page.getByText('Local override', { exact: true }).count(),
|
||||
0,
|
||||
);
|
||||
await visit('?reset&noAlternatives');
|
||||
await page
|
||||
.getByText('No other published templates', { exact: true })
|
||||
.waitFor();
|
||||
assert.equal(await button('Switch template').count(), 0);
|
||||
|
||||
await visit();
|
||||
await button('Reset Ticket statuses to template').click();
|
||||
await dialog().waitFor();
|
||||
assert.equal(await confirmReset().isDisabled(), true);
|
||||
const replacement = page.locator('#replacement-10');
|
||||
await replacement.selectOption('1');
|
||||
await result('validation');
|
||||
const resetRequest = page.waitForRequest(
|
||||
(request) => request.method() === 'POST',
|
||||
);
|
||||
await confirmReset().click();
|
||||
assert.deepEqual((await resetRequest).postDataJSON(), {
|
||||
areas: ['ticket_statuses'],
|
||||
status_replacements: { 10: 1 },
|
||||
});
|
||||
await formState(dialog(), 'validation');
|
||||
await page
|
||||
.getByText('This area could not be reset.', { exact: true })
|
||||
.waitFor();
|
||||
assert.equal(await replacement.inputValue(), '1');
|
||||
await result('server');
|
||||
await confirmReset().click();
|
||||
await formState(dialog(), 'server');
|
||||
await result('success');
|
||||
await dialog()
|
||||
.getByRole('button', { name: 'Try again', exact: true })
|
||||
.click();
|
||||
await dialog().waitFor({ state: 'hidden' });
|
||||
const sources = page.getByRole('list', { name: 'Setting sources' });
|
||||
assert.equal(
|
||||
await sources.getByText('Local override', { exact: true }).count(),
|
||||
1,
|
||||
'Resetting statuses preserves project settings override',
|
||||
);
|
||||
assert.equal(await button('Reset Ticket statuses to template').count(), 0);
|
||||
await button('Reset Project settings to template').click();
|
||||
await confirmReset().click();
|
||||
await dialog().waitFor({ state: 'hidden' });
|
||||
assert.equal(
|
||||
await sources.getByText('Local override', { exact: true }).count(),
|
||||
0,
|
||||
);
|
||||
assert.equal(await page.getByText('Enabled', { exact: true }).count(), 2);
|
||||
|
||||
await visit();
|
||||
const switchForm = page
|
||||
.locator('form')
|
||||
.filter({ has: page.locator('#source_template_id') });
|
||||
const select = page.locator('#source_template_id');
|
||||
assert.equal(
|
||||
await select.locator('option[value="1"]').count(),
|
||||
0,
|
||||
'Current template must not be selectable',
|
||||
);
|
||||
await select.selectOption('2');
|
||||
await page.locator('#switch_confirmation_key').fill('core');
|
||||
assert.equal(await button('Switch template').isDisabled(), true);
|
||||
const countBefore = mutations.length;
|
||||
await switchForm.evaluate((element) =>
|
||||
element.dispatchEvent(
|
||||
new Event('submit', { bubbles: true, cancelable: true }),
|
||||
),
|
||||
);
|
||||
assert.equal(
|
||||
mutations.length,
|
||||
countBefore,
|
||||
'Submit guard must reject a mismatching key',
|
||||
);
|
||||
await page.locator('#switch_confirmation_key').fill('CORE');
|
||||
await result('validation');
|
||||
await button('Switch template').click();
|
||||
await formState(switchForm, 'validation');
|
||||
assert.equal(
|
||||
await page.locator('#switch_confirmation_key').inputValue(),
|
||||
'CORE',
|
||||
);
|
||||
assert.equal(
|
||||
await page
|
||||
.locator('#switch_confirmation_key')
|
||||
.getAttribute('aria-invalid'),
|
||||
'true',
|
||||
);
|
||||
await page.route('**/switch-template', (route) => route.abort('failed'));
|
||||
await button('Switch template').click();
|
||||
await formState(switchForm, 'network');
|
||||
await page.unroute('**/switch-template');
|
||||
await result('success');
|
||||
const switched = page.waitForRequest(
|
||||
(request) => request.method() === 'POST',
|
||||
);
|
||||
await switchForm
|
||||
.getByRole('button', { name: 'Try again', exact: true })
|
||||
.click();
|
||||
assert.deepEqual((await switched).postDataJSON(), {
|
||||
confirmation_key: 'CORE',
|
||||
source_template_id: 2,
|
||||
});
|
||||
await page.getByText('Delivery baseline', { exact: true }).waitFor();
|
||||
assert.equal(
|
||||
await page.locator('#switch_confirmation_key').inputValue(),
|
||||
'',
|
||||
);
|
||||
assert.equal(await button('Switch template').isDisabled(), true);
|
||||
|
||||
await visit();
|
||||
const deleteForm = page
|
||||
.locator('form')
|
||||
.filter({ has: page.locator('#confirmation_key') });
|
||||
await page.locator('#confirmation_key').fill('core');
|
||||
assert.equal(await button('Delete project').isDisabled(), true);
|
||||
const beforeDelete = mutations.length;
|
||||
await deleteForm.evaluate((element) =>
|
||||
element.dispatchEvent(
|
||||
new Event('submit', { bubbles: true, cancelable: true }),
|
||||
),
|
||||
);
|
||||
assert.equal(mutations.length, beforeDelete);
|
||||
await page.locator('#confirmation_key').fill('CORE');
|
||||
await result('validation');
|
||||
await button('Delete project').click();
|
||||
await formState(deleteForm, 'validation');
|
||||
assert.equal(
|
||||
await page.locator('#confirmation_key').getAttribute('aria-invalid'),
|
||||
'true',
|
||||
);
|
||||
assert.equal(await page.locator('#confirmation_key').inputValue(), 'CORE');
|
||||
await result('success');
|
||||
const deleted = page.waitForRequest(
|
||||
(request) => request.method() === 'DELETE',
|
||||
);
|
||||
await button('Delete project').click();
|
||||
const deletion = await deleted;
|
||||
assert.equal(new URL(deletion.url()).pathname, '/projects/1');
|
||||
assert.deepEqual(deletion.postDataJSON(), { confirmation_key: 'CORE' });
|
||||
await page.getByRole('heading', { name: 'Destination reached' }).waitFor();
|
||||
assert.deepEqual(errors, []);
|
||||
console.log(
|
||||
'Project general settings browser checks passed: setting sources, scoped resets, confirmations, replacements, errors, retries, keyboard, 320/390/1440px and both themes.',
|
||||
);
|
||||
} finally {
|
||||
await browser.close();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import { createApp, h } from 'vue';
|
||||
import { createInertiaApp } from '@inertiajs/vue3';
|
||||
import '../../resources/css/app.css';
|
||||
import General from '../../resources/js/pages/projects/settings/General.vue';
|
||||
import { createAppearance } from '../../resources/js/composables/useAppearance';
|
||||
import { createLocalization } from '../../resources/js/lib/localization';
|
||||
|
||||
createInertiaApp({
|
||||
resolve: (name) =>
|
||||
name === 'General'
|
||||
? General
|
||||
: { render: () => h('h1', 'Destination reached') },
|
||||
setup: ({ el, App, props, plugin }) =>
|
||||
createApp({ render: () => h(App, props) })
|
||||
.use(plugin)
|
||||
.use(createLocalization())
|
||||
.use(createAppearance())
|
||||
.mount(el),
|
||||
});
|
||||
@@ -0,0 +1,307 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import process from 'node:process';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import tailwind from '@tailwindcss/vite';
|
||||
import { createServer } from 'vite';
|
||||
import { createSSRApp, h } from 'vue';
|
||||
import { renderToString } from 'vue/server-renderer';
|
||||
import { createInertiaApp } from '@inertiajs/vue3';
|
||||
|
||||
const serve = process.argv.includes('--serve');
|
||||
const server = await createServer({
|
||||
configFile: false,
|
||||
cacheDir: 'node_modules/.vite/project-general-settings-fixture',
|
||||
plugins: [vue(), ...(serve ? [tailwind()] : [])],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('../../resources/js', import.meta.url)),
|
||||
},
|
||||
},
|
||||
server: serve
|
||||
? { host: '127.0.0.1', port: 4187, strictPort: true, hmr: false }
|
||||
: { middlewareMode: true, hmr: false, watch: null },
|
||||
appType: 'custom',
|
||||
});
|
||||
const area = (value, label) => ({ value, label });
|
||||
const template = {
|
||||
id: 1,
|
||||
name: 'Team baseline',
|
||||
is_published: true,
|
||||
copy_areas: [],
|
||||
};
|
||||
const alternative = { ...template, id: 2, name: 'Delivery baseline' };
|
||||
function initial() {
|
||||
return {
|
||||
project: {
|
||||
id: 1,
|
||||
key: 'CORE',
|
||||
name: 'Core platform',
|
||||
project_template_id: 1,
|
||||
project_template: template,
|
||||
show_author: false,
|
||||
show_story_points: false,
|
||||
},
|
||||
sourceTemplates: [template, alternative],
|
||||
status: null,
|
||||
templateState: {
|
||||
templateId: 1,
|
||||
templateName: 'Team baseline',
|
||||
inheritsFromTemplate: true,
|
||||
inheritedAreas: [area('board_columns', 'Board columns')],
|
||||
overriddenAreas: [
|
||||
area('project_settings', 'Project settings'),
|
||||
area('ticket_statuses', 'Ticket statuses'),
|
||||
],
|
||||
effectiveConfiguration: {},
|
||||
resetRequirements: {
|
||||
ticket_statuses: {
|
||||
removedStatuses: [
|
||||
{ id: 10, name: 'Local review', ticketCount: 3 },
|
||||
],
|
||||
replacementOptions: [{ id: 1, name: 'Ready' }],
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
function makePage(
|
||||
extra = {},
|
||||
url = '/projects/1/settings/general',
|
||||
component = 'General',
|
||||
) {
|
||||
return {
|
||||
component,
|
||||
url,
|
||||
version: null,
|
||||
clearHistory: false,
|
||||
encryptHistory: false,
|
||||
props: {
|
||||
name: 'KanbanGit',
|
||||
errors: {},
|
||||
sidebarOpen: true,
|
||||
appearance: 'system',
|
||||
auth: {
|
||||
user: {
|
||||
id: 1,
|
||||
name: 'Alex Morgan',
|
||||
email: 'alex@example.test',
|
||||
avatar: null,
|
||||
avatar_color: '#10B981',
|
||||
avatar_is_generated: true,
|
||||
},
|
||||
permissions: {
|
||||
globalAdmin: false,
|
||||
projectCreate: false,
|
||||
canManageTeams: false,
|
||||
},
|
||||
},
|
||||
navigation: {
|
||||
project: {
|
||||
id: 1,
|
||||
name: 'Core platform',
|
||||
key: 'CORE',
|
||||
canManage: true,
|
||||
},
|
||||
},
|
||||
...initial(),
|
||||
...extra,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (serve) {
|
||||
let data = initial();
|
||||
server.middlewares.use(async (request, response, next) => {
|
||||
if (!request.url.startsWith('/projects')) {
|
||||
return next();
|
||||
}
|
||||
const url = new URL(request.url, 'http://localhost');
|
||||
const mutation = request.method !== 'GET';
|
||||
const result =
|
||||
request.headers.cookie?.match(/general_test_result=(\w+)/)?.[1] ??
|
||||
'success';
|
||||
if (!mutation && url.searchParams.has('reset')) {
|
||||
data = initial();
|
||||
}
|
||||
let extra = {};
|
||||
let component = 'General';
|
||||
let pageUrl = '/projects/1/settings/general';
|
||||
if (mutation) {
|
||||
if (['server', 'forbidden'].includes(result)) {
|
||||
response.statusCode = result === 'forbidden' ? 403 : 503;
|
||||
response.end('Simulated request failure');
|
||||
return;
|
||||
}
|
||||
let body = '';
|
||||
for await (const chunk of request) {
|
||||
body += chunk;
|
||||
}
|
||||
const submitted = JSON.parse(body || '{}');
|
||||
if (result === 'validation') {
|
||||
extra.errors = url.pathname.endsWith('reset-template')
|
||||
? { 'areas.0': 'This area could not be reset.' }
|
||||
: { confirmation_key: 'Enter the exact project key.' };
|
||||
} else if (request.method === 'DELETE') {
|
||||
component = 'Destination';
|
||||
pageUrl = '/projects';
|
||||
} else if (url.pathname.endsWith('reset-template')) {
|
||||
const reset = data.templateState.overriddenAreas.find(
|
||||
(item) => item.value === submitted.areas[0],
|
||||
);
|
||||
data.templateState.overriddenAreas =
|
||||
data.templateState.overriddenAreas.filter(
|
||||
(item) => item.value !== reset.value,
|
||||
);
|
||||
data.templateState.inheritedAreas.push(reset);
|
||||
if (reset.value === 'project_settings') {
|
||||
data.project.show_author = true;
|
||||
data.project.show_story_points = true;
|
||||
}
|
||||
data.status = 'Project template baseline was reset.';
|
||||
} else {
|
||||
data.project.project_template = alternative;
|
||||
data.project.project_template_id = 2;
|
||||
data.templateState.templateName = alternative.name;
|
||||
data.templateState.templateId = 2;
|
||||
data.status = 'Project template baseline was switched.';
|
||||
}
|
||||
}
|
||||
if (url.searchParams.has('noTemplate')) {
|
||||
extra = {
|
||||
project: {
|
||||
...data.project,
|
||||
project_template: null,
|
||||
project_template_id: null,
|
||||
},
|
||||
templateState: null,
|
||||
};
|
||||
}
|
||||
if (url.searchParams.has('baseline')) {
|
||||
extra.templateState = {
|
||||
...data.templateState,
|
||||
inheritsFromTemplate: false,
|
||||
};
|
||||
}
|
||||
if (url.searchParams.has('noAlternatives')) {
|
||||
extra.sourceTemplates = [template];
|
||||
}
|
||||
const page = makePage({ ...data, ...extra }, pageUrl, component);
|
||||
response.setHeader('Vary', 'X-Inertia');
|
||||
if (request.headers['x-inertia']) {
|
||||
response.setHeader('X-Inertia', 'true');
|
||||
response.setHeader('Content-Type', 'application/json');
|
||||
response.end(JSON.stringify(page));
|
||||
return;
|
||||
}
|
||||
const escaped = JSON.stringify(page)
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll('<', '<');
|
||||
response.setHeader('Content-Type', 'text/html');
|
||||
response.end(
|
||||
await server.transformIndexHtml(
|
||||
request.url,
|
||||
'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"></head><body><div id="app" data-page="' +
|
||||
escaped +
|
||||
'"></div><script type="module" src="/tests/Fixtures/project-general-settings-preview.mjs"></script></body></html>',
|
||||
),
|
||||
);
|
||||
});
|
||||
await server.listen();
|
||||
console.log('Project general settings fixture ready.');
|
||||
} else {
|
||||
try {
|
||||
const { createLocalization } = await server.ssrLoadModule(
|
||||
'/resources/js/lib/localization.ts',
|
||||
);
|
||||
const { createAppearance } = await server.ssrLoadModule(
|
||||
'/resources/js/composables/useAppearance.ts',
|
||||
);
|
||||
const { en } = await server.ssrLoadModule(
|
||||
'/resources/js/locales/en.ts',
|
||||
);
|
||||
const component = (
|
||||
await server.ssrLoadModule(
|
||||
'/resources/js/pages/projects/settings/General.vue',
|
||||
)
|
||||
).default;
|
||||
const render = async (extra = {}, locale = createLocalization()) =>
|
||||
(
|
||||
await createInertiaApp({
|
||||
page: makePage(extra),
|
||||
resolve: () => component,
|
||||
render: renderToString,
|
||||
setup: ({ App, props, plugin }) =>
|
||||
createSSRApp({ render: () => h(App, props) })
|
||||
.use(plugin)
|
||||
.use(locale)
|
||||
.use(createAppearance()),
|
||||
})
|
||||
).body;
|
||||
const html = await render();
|
||||
assert.match(html, /Local override/);
|
||||
assert.match(html, /Inherited/);
|
||||
assert.match(html, /Team baseline/);
|
||||
assert.match(html, /Show author/);
|
||||
assert.match(html, /href="\/projects\/1\/settings\/metadata"/);
|
||||
assert.match(html, /aria-current="page"/);
|
||||
assert.match(html, /Reset Project settings to template/);
|
||||
assert.match(html, /Type CORE exactly/);
|
||||
const buttons = html.match(/<button\b[^>]*>[\s\S]*?<\/button>/g);
|
||||
for (const label of ['Switch template', 'Delete project']) {
|
||||
const button = buttons.find((item) => item.includes(label));
|
||||
assert.match(button, /disabled/);
|
||||
assert.match(button, /type="submit"/);
|
||||
}
|
||||
const standalone = await render({
|
||||
templateState: null,
|
||||
project: { ...initial().project, project_template: null },
|
||||
});
|
||||
assert.match(standalone, /No linked template/);
|
||||
assert.doesNotMatch(standalone, /Reset Project settings to template/);
|
||||
assert.doesNotMatch(
|
||||
await render({
|
||||
templateState: {
|
||||
...initial().templateState,
|
||||
inheritsFromTemplate: false,
|
||||
},
|
||||
}),
|
||||
/Local override/,
|
||||
);
|
||||
assert.match(
|
||||
await render({ sourceTemplates: [template] }),
|
||||
/No other published templates/,
|
||||
);
|
||||
const inherited = await render({
|
||||
templateState: {
|
||||
...initial().templateState,
|
||||
inheritedAreas: [area('project_settings', 'Project settings')],
|
||||
overriddenAreas: [],
|
||||
},
|
||||
});
|
||||
assert.doesNotMatch(
|
||||
inherited,
|
||||
/Local override|Reset Project settings to template/,
|
||||
);
|
||||
assert.match(
|
||||
await render(
|
||||
{},
|
||||
createLocalization(
|
||||
{ locale: 'de' },
|
||||
{
|
||||
de: {
|
||||
...en,
|
||||
'projectSettings.danger': 'Gefahrenbereich',
|
||||
'inheritance.area.projectSettings':
|
||||
'Projekteinstellungen',
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
/Gefahrenbereich/,
|
||||
);
|
||||
console.log('Project general settings rendering checks passed.');
|
||||
} finally {
|
||||
await server.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user