Compare commits
36
Commits
802294d6a2
...
v0.2.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fed0b657c0 | ||
|
|
1fe0c0b2d9 | ||
|
|
463cb7fe36 | ||
|
|
3bf5a0c508 | ||
|
|
32de1f425a | ||
|
|
1af98cd56e | ||
|
|
aadf159ac5 | ||
|
|
5c47453d4d | ||
|
|
ba7e174e82 | ||
|
|
d646f8b537 | ||
|
|
509d7abf82 | ||
|
|
5cc1840592 | ||
|
|
11b06d9b8c | ||
|
|
b76b4adaec | ||
|
|
c8fa76e08a | ||
|
|
87ae19f972 | ||
|
|
a97451edfa | ||
|
|
17b3e02bd8 | ||
|
|
d58fbd21ad | ||
|
|
002de1b293 | ||
|
|
707ebe6e48 | ||
|
|
4e29fc4526 | ||
|
|
fab1e9c7a8 | ||
|
|
ccd199a695 | ||
|
|
f7b50e8715 | ||
|
|
5147c8ed8d | ||
|
|
3914fd5432 | ||
|
|
4d6da2c5f5 | ||
|
|
313e2d2396 | ||
|
|
810d1850ae | ||
|
|
cd7fae3841 | ||
|
|
32e3496248 | ||
|
|
0e78be0eae | ||
|
|
17caabbb3e | ||
|
|
3f4945c20d | ||
|
|
65bf75ed77 |
@@ -33,9 +33,6 @@
|
|||||||
vendor
|
vendor
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
.editorconfig
|
.editorconfig
|
||||||
.env.example
|
|
||||||
.env.mariadb
|
|
||||||
.env.mariadb.example
|
|
||||||
.env.production
|
.env.production
|
||||||
LICENSE
|
LICENSE
|
||||||
README.md
|
README.md
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
MARIADB_DATABASE=kanbangit
|
|
||||||
MARIADB_USER=kanbangit
|
|
||||||
MARIADB_PASSWORD=
|
|
||||||
MARIADB_ROOT_PASSWORD=
|
|
||||||
@@ -2,7 +2,13 @@ name: CI/CD
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -11,9 +17,19 @@ env:
|
|||||||
REGISTRY: git.twyco.de
|
REGISTRY: git.twyco.de
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test_and_check_app:
|
preconditions:
|
||||||
name: test_and_check_app
|
if: >
|
||||||
|
!(contains(github.event.head_commit.message, '[no-ci]') || contains(github.event.head_commit.message, '[skip-ci]'))
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Conditions met
|
||||||
|
run: |
|
||||||
|
echo "Conditions for CI/CD are met. Proceeding with the workflow."
|
||||||
|
|
||||||
|
test_and_check_app:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs:
|
||||||
|
- preconditions
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository
|
- name: Check out repository
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
|
||||||
@@ -27,6 +43,7 @@ jobs:
|
|||||||
github.event_name == 'push' &&
|
github.event_name == 'push' &&
|
||||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
|
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
|
||||||
needs:
|
needs:
|
||||||
|
- preconditions
|
||||||
- test_and_check_app
|
- test_and_check_app
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
+5
-3
@@ -55,12 +55,14 @@ COPY --from=node_binary /usr/local/ /usr/local/
|
|||||||
COPY . /var/www
|
COPY . /var/www
|
||||||
|
|
||||||
RUN composer install --prefer-dist --no-interaction --no-progress \
|
RUN composer install --prefer-dist --no-interaction --no-progress \
|
||||||
&& npm ci \
|
&& corepack enable pnpm \
|
||||||
&& npm run build
|
&& pnpm install --frozen-lockfile \
|
||||||
|
&& pnpm run build
|
||||||
|
|
||||||
FROM build AS test
|
FROM build AS test
|
||||||
|
|
||||||
RUN touch .env \
|
RUN cp .env.example .env \
|
||||||
|
&& php artisan key:generate\
|
||||||
&& composer audit --locked --no-interaction \
|
&& composer audit --locked --no-interaction \
|
||||||
&& COMPOSER_ALLOW_SUPERUSER=1 composer ci:check
|
&& COMPOSER_ALLOW_SUPERUSER=1 composer ci:check
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ class BuildProjectBacklogPayload
|
|||||||
'tickets' => TicketResource::collection(
|
'tickets' => TicketResource::collection(
|
||||||
Ticket::query()
|
Ticket::query()
|
||||||
->with([
|
->with([
|
||||||
|
'assignee',
|
||||||
'ticketPriority',
|
'ticketPriority',
|
||||||
'ticketStatus.allowedTargetStatuses.boardColumn',
|
'ticketStatus.allowedTargetStatuses.boardColumn',
|
||||||
'ticketStatus.boardColumn',
|
'ticketStatus.boardColumn',
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class BuildProjectBoardPayload
|
|||||||
'ticketStatuses',
|
'ticketStatuses',
|
||||||
'tickets' => fn ($query) => $query
|
'tickets' => fn ($query) => $query
|
||||||
->with([
|
->with([
|
||||||
|
'assignee',
|
||||||
'ticketPriority',
|
'ticketPriority',
|
||||||
'ticketStatus.allowedTargetStatuses.boardColumn',
|
'ticketStatus.allowedTargetStatuses.boardColumn',
|
||||||
'ticketStatus.boardColumn',
|
'ticketStatus.boardColumn',
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ class ListAssignedTicketsByVisibleProject
|
|||||||
->where('assignee_user_id', $assignee->id)
|
->where('assignee_user_id', $assignee->id)
|
||||||
->whereIn('project_id', $visibleProjectIds)
|
->whereIn('project_id', $visibleProjectIds)
|
||||||
->with([
|
->with([
|
||||||
|
'acceptanceCriteria',
|
||||||
'assignee',
|
'assignee',
|
||||||
'project',
|
|
||||||
'ticketPriority',
|
'ticketPriority',
|
||||||
'ticketStatus.boardColumn',
|
'ticketStatus.boardColumn',
|
||||||
'ticketType',
|
'ticketType',
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Actions\Tickets\ListAssignedTicketsByVisibleProject;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Inertia\Inertia;
|
||||||
|
use Inertia\Response;
|
||||||
|
|
||||||
|
class DashboardController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly ListAssignedTicketsByVisibleProject $listAssignedTicketsByVisibleProject,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function __invoke(Request $request): Response
|
||||||
|
{
|
||||||
|
$user = $request->user();
|
||||||
|
|
||||||
|
return Inertia::render('Dashboard', [
|
||||||
|
'assignedTicketsByProject' => $this->listAssignedTicketsByVisibleProject->handle($user, $user),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
-6
@@ -47,15 +47,15 @@
|
|||||||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
|
||||||
"@php artisan key:generate",
|
"@php artisan key:generate",
|
||||||
"@php artisan migrate --force",
|
"@php artisan migrate --force",
|
||||||
"npm install",
|
"pnpm install",
|
||||||
"npm run build"
|
"pnpm run build"
|
||||||
],
|
],
|
||||||
"dev": [
|
"dev": [
|
||||||
"Composer\\Config::disableProcessTimeout",
|
"Composer\\Config::disableProcessTimeout",
|
||||||
"@php artisan dev"
|
"@php artisan dev"
|
||||||
],
|
],
|
||||||
"dev:ssr": [
|
"dev:ssr": [
|
||||||
"npm run build:ssr",
|
"pnpm run build:ssr",
|
||||||
"Composer\\Config::disableProcessTimeout",
|
"Composer\\Config::disableProcessTimeout",
|
||||||
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"php artisan inertia:start-ssr\" --names=server,queue,logs,ssr --kill-others"
|
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"php artisan inertia:start-ssr\" --names=server,queue,logs,ssr --kill-others"
|
||||||
],
|
],
|
||||||
@@ -67,9 +67,9 @@
|
|||||||
],
|
],
|
||||||
"ci:check": [
|
"ci:check": [
|
||||||
"Composer\\Config::disableProcessTimeout",
|
"Composer\\Config::disableProcessTimeout",
|
||||||
"npm audit --audit-level=high",
|
"pnpm audit --audit-level=high",
|
||||||
"npm run lint:check",
|
"pnpm run lint:check",
|
||||||
"npm run types:check",
|
"pnpm run types:check",
|
||||||
"@test"
|
"@test"
|
||||||
],
|
],
|
||||||
"test": [
|
"test": [
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const prettierOptions = {
|
|||||||
const eslintConfig = [
|
const eslintConfig = [
|
||||||
{
|
{
|
||||||
ignores: [
|
ignores: [
|
||||||
|
'bootstrap/ssr/**',
|
||||||
'**/dist/**',
|
'**/dist/**',
|
||||||
'node_modules/**',
|
'node_modules/**',
|
||||||
'.github/**',
|
'.github/**',
|
||||||
|
|||||||
Generated
-7269
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,13 @@
|
|||||||
"$schema": "https://www.schemastore.org/package.json",
|
"$schema": "https://www.schemastore.org/package.json",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"devEngines": {
|
||||||
|
"packageManager": {
|
||||||
|
"name": "pnpm",
|
||||||
|
"version": "11.26.0+sha512.fc0e2bf890b9f983611f1ab68c0637bce914390653699f83c1a78b005ed25f2c81e77920c8fd8eee2ecf0b58b28cdcb00a84d97f69bcf7c56b2f344710238664",
|
||||||
|
"onFail": "error"
|
||||||
|
}
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"build:ssr": "vite build && vite build --ssr",
|
"build:ssr": "vite build && vite build --ssr",
|
||||||
@@ -39,6 +46,7 @@
|
|||||||
"vue-tsc": "^2.2.4"
|
"vue-tsc": "^2.2.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@inertiajs/core": "2.3.18",
|
||||||
"@inertiajs/vue3": "^2.3.7",
|
"@inertiajs/vue3": "^2.3.7",
|
||||||
"@vueuse/core": "^12.8.2",
|
"@vueuse/core": "^12.8.2",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
</source>
|
</source>
|
||||||
<php>
|
<php>
|
||||||
<env name="APP_ENV" value="testing"/>
|
<env name="APP_ENV" value="testing"/>
|
||||||
<env name="APP_KEY" value="base64:11ujGYe5vzbwqcdFDVQC6PuDgd7c8PKD9kWt9HH9Bvs="/>
|
|
||||||
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
<env name="APP_MAINTENANCE_DRIVER" value="file"/>
|
||||||
<env name="AVATAR_FILESYSTEM_DISK" value="public"/>
|
<env name="AVATAR_FILESYSTEM_DISK" value="public"/>
|
||||||
<env name="AVATAR_URLS_TEMPORARY" value="false"/>
|
<env name="AVATAR_URLS_TEMPORARY" value="false"/>
|
||||||
|
|||||||
Generated
+4832
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
|||||||
|
minimumReleaseAge: 10080
|
||||||
|
allowBuilds:
|
||||||
|
unrs-resolver: true
|
||||||
|
vue-demi: true
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Form } from '@inertiajs/vue3';
|
||||||
|
import { ChevronDown, ChevronRight } from 'lucide-vue-next';
|
||||||
|
import { move } from '@/actions/App/Http/Controllers/ProjectBoardController';
|
||||||
|
import InputError from '@/components/InputError.vue';
|
||||||
|
import { TicketCard } from '@/components/tickets';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { ticketStatusLabel } from '@/lib/tickets';
|
||||||
|
import type {
|
||||||
|
BacklogTicketTreeEmits,
|
||||||
|
BacklogTicketTreeProps,
|
||||||
|
} from '@/types/backlog';
|
||||||
|
import type { TicketModel } from '@/types/models/ticket-model';
|
||||||
|
|
||||||
|
const props = defineProps<BacklogTicketTreeProps>();
|
||||||
|
const emit = defineEmits<BacklogTicketTreeEmits>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
|
||||||
|
const allowedTargetStatuses = (ticket: TicketModel) =>
|
||||||
|
(ticket.ticket_status?.allowed_target_statuses ?? []).filter(
|
||||||
|
(status) => status.id !== ticket.ticket_status_id,
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ul class="grid min-w-0 gap-3">
|
||||||
|
<li v-for="node in nodes" :key="node.ticket.id" class="min-w-0">
|
||||||
|
<div class="grid min-w-0 grid-cols-[2.75rem_minmax(0,1fr)] gap-2">
|
||||||
|
<div class="flex justify-center pt-1">
|
||||||
|
<button
|
||||||
|
v-if="node.children.length > 0"
|
||||||
|
type="button"
|
||||||
|
class="border-border bg-card text-muted-foreground hover:border-primary hover:text-primary focus-visible:ring-ring/35 flex size-10 items-center justify-center rounded-md border transition-colors focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
:aria-expanded="!collapsedTicketIds.has(node.ticket.id)"
|
||||||
|
:aria-controls="`backlog-children-${node.ticket.id}`"
|
||||||
|
:aria-label="
|
||||||
|
t(
|
||||||
|
collapsedTicketIds.has(node.ticket.id)
|
||||||
|
? 'backlog.tree.expand'
|
||||||
|
: 'backlog.tree.collapse',
|
||||||
|
{ key: node.ticket.ticket_key },
|
||||||
|
)
|
||||||
|
"
|
||||||
|
@click="emit('toggle', node.ticket.id)"
|
||||||
|
>
|
||||||
|
<ChevronRight
|
||||||
|
v-if="collapsedTicketIds.has(node.ticket.id)"
|
||||||
|
class="size-4"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<ChevronDown v-else class="size-4" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="bg-border mt-4 size-1.5 rounded-full"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid min-w-0 gap-2">
|
||||||
|
<Badge
|
||||||
|
v-if="!node.matchesFilters"
|
||||||
|
variant="secondary"
|
||||||
|
class="w-fit"
|
||||||
|
>
|
||||||
|
{{ t('backlog.filters.parentContext') }}
|
||||||
|
</Badge>
|
||||||
|
|
||||||
|
<TicketCard
|
||||||
|
:project-id="projectId"
|
||||||
|
:ticket="node.ticket"
|
||||||
|
layout="list"
|
||||||
|
:class="{ 'opacity-80': !node.matchesFilters }"
|
||||||
|
>
|
||||||
|
<template v-if="canEditTickets" #actions>
|
||||||
|
<Form
|
||||||
|
v-bind="
|
||||||
|
move.form({
|
||||||
|
project: projectId,
|
||||||
|
ticket: node.ticket.id,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
v-slot="{ processing, errors }"
|
||||||
|
:error-bag="`backlog-ticket-${node.ticket.id}`"
|
||||||
|
:options="{ preserveScroll: true }"
|
||||||
|
:on-before="() => pendingTicketId === null"
|
||||||
|
class="grid min-w-0 gap-2"
|
||||||
|
@start="emit('moveStart', node.ticket.id)"
|
||||||
|
@finish="emit('moveFinish', node.ticket.id)"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="redirect_to"
|
||||||
|
value="backlog"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
:for="`backlog-ticket-status-${node.ticket.id}`"
|
||||||
|
class="text-caption text-muted-foreground font-semibold"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
t('backlog.moveTicket', {
|
||||||
|
key: node.ticket.ticket_key,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
:id="`backlog-ticket-status-${node.ticket.id}`"
|
||||||
|
name="ticket_status_id"
|
||||||
|
:disabled="
|
||||||
|
pendingTicketId !== null ||
|
||||||
|
processing ||
|
||||||
|
allowedTargetStatuses(node.ticket)
|
||||||
|
.length === 0
|
||||||
|
"
|
||||||
|
:aria-invalid="
|
||||||
|
!!errors.ticket_status_id || undefined
|
||||||
|
"
|
||||||
|
:aria-describedby="
|
||||||
|
errors.ticket_status_id
|
||||||
|
? `backlog-ticket-status-error-${node.ticket.id}`
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full min-w-0 rounded-md border px-3 py-2 focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-if="
|
||||||
|
allowedTargetStatuses(node.ticket)
|
||||||
|
.length === 0
|
||||||
|
"
|
||||||
|
value=""
|
||||||
|
>
|
||||||
|
{{ t('board.noMoves') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="target in allowedTargetStatuses(
|
||||||
|
node.ticket,
|
||||||
|
)"
|
||||||
|
:key="target.id"
|
||||||
|
:value="target.id"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
ticketStatusLabel(
|
||||||
|
target,
|
||||||
|
t('tickets.noStatus'),
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<InputError
|
||||||
|
:id="`backlog-ticket-status-error-${node.ticket.id}`"
|
||||||
|
:message="errors.ticket_status_id"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
variant="outline"
|
||||||
|
:disabled="
|
||||||
|
pendingTicketId !== null ||
|
||||||
|
processing ||
|
||||||
|
allowedTargetStatuses(node.ticket)
|
||||||
|
.length === 0
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
t(
|
||||||
|
processing
|
||||||
|
? 'board.updatingStatus'
|
||||||
|
: 'board.updateStatus',
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</Button>
|
||||||
|
<p
|
||||||
|
v-if="
|
||||||
|
allowedTargetStatuses(node.ticket)
|
||||||
|
.length === 0
|
||||||
|
"
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ t('board.noMovesDescription') }}
|
||||||
|
</p>
|
||||||
|
</Form>
|
||||||
|
</template>
|
||||||
|
</TicketCard>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
node.children.length > 0 &&
|
||||||
|
!collapsedTicketIds.has(node.ticket.id)
|
||||||
|
"
|
||||||
|
:id="`backlog-children-${node.ticket.id}`"
|
||||||
|
class="border-border ml-[1.375rem] mt-3 border-l pl-2 sm:pl-4"
|
||||||
|
>
|
||||||
|
<BacklogTicketTree
|
||||||
|
:nodes="node.children"
|
||||||
|
:project-id="projectId"
|
||||||
|
:can-edit-tickets="canEditTickets"
|
||||||
|
:collapsed-ticket-ids="collapsedTicketIds"
|
||||||
|
:pending-ticket-id="pendingTicketId"
|
||||||
|
@toggle="emit('toggle', $event)"
|
||||||
|
@move-start="emit('moveStart', $event)"
|
||||||
|
@move-finish="emit('moveFinish', $event)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
@@ -1,45 +1,93 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Link } from '@inertiajs/vue3';
|
import { Link } from '@inertiajs/vue3';
|
||||||
|
import { ChevronDown, ChevronRight } from 'lucide-vue-next';
|
||||||
|
import { reactive } from 'vue';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
import { show as showTicket } from '@/routes/projects/tickets';
|
import { show as showTicket } from '@/routes/projects/tickets';
|
||||||
import type { TicketTreeNodeModel } from '@/types/models/ticket-tree-node-model';
|
import type { TicketTreeListProps } from '@/types/ticket-tree';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<TicketTreeListProps>();
|
||||||
nodes: TicketTreeNodeModel[];
|
|
||||||
projectId: number;
|
const { t } = useLocalization();
|
||||||
}>();
|
const collapsedTicketIds = reactive(new Set<number>());
|
||||||
|
|
||||||
|
function toggleTicket(ticketId: number): void {
|
||||||
|
if (collapsedTicketIds.has(ticketId)) {
|
||||||
|
collapsedTicketIds.delete(ticketId);
|
||||||
|
} else {
|
||||||
|
collapsedTicketIds.add(ticketId);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ul class="space-y-3">
|
<ul class="grid min-w-0 gap-3">
|
||||||
<li v-for="node in nodes" :key="node.id">
|
<li v-for="node in nodes" :key="node.id" class="min-w-0">
|
||||||
<div class="border-border rounded-xl border px-4 py-4">
|
<div class="grid min-w-0 grid-cols-[2.75rem_minmax(0,1fr)] gap-2">
|
||||||
<div class="flex flex-wrap items-center gap-2">
|
<div class="flex justify-center pt-1">
|
||||||
<Link
|
<button
|
||||||
:href="
|
v-if="node.children.length > 0"
|
||||||
showTicket({
|
type="button"
|
||||||
project: projectId,
|
class="border-border bg-card text-muted-foreground hover:border-primary hover:text-primary focus-visible:ring-ring/35 flex size-10 items-center justify-center rounded-md border transition-colors focus-visible:outline-none focus-visible:ring-2"
|
||||||
ticket: node.id,
|
:aria-expanded="!collapsedTicketIds.has(node.id)"
|
||||||
})
|
:aria-controls="`ticket-tree-children-${node.id}`"
|
||||||
|
:aria-label="
|
||||||
|
t(
|
||||||
|
collapsedTicketIds.has(node.id)
|
||||||
|
? 'tickets.tree.expand'
|
||||||
|
: 'tickets.tree.collapse',
|
||||||
|
{ key: node.ticket_key },
|
||||||
|
)
|
||||||
"
|
"
|
||||||
class="text-foreground hover:text-primary font-medium transition"
|
@click="toggleTicket(node.id)"
|
||||||
>
|
>
|
||||||
{{ node.ticket_key }}
|
<ChevronRight
|
||||||
</Link>
|
v-if="collapsedTicketIds.has(node.id)"
|
||||||
|
class="size-4"
|
||||||
<Badge v-if="node.ticket_type_name" variant="secondary">
|
aria-hidden="true"
|
||||||
{{ node.ticket_type_name }}
|
/>
|
||||||
</Badge>
|
<ChevronDown v-else class="size-4" aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="bg-border mt-4 size-1.5 rounded-full"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="text-foreground mt-2 text-sm">
|
<Link
|
||||||
{{ node.title }}
|
:href="
|
||||||
</div>
|
showTicket({
|
||||||
|
project: projectId,
|
||||||
|
ticket: node.id,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
class="bg-card text-card-foreground hover:border-primary focus-visible:ring-ring/35 gap-stack group grid min-w-0 rounded-md border p-4 transition-[border-color,box-shadow] focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<div class="flex min-w-0 flex-wrap items-center gap-2">
|
||||||
|
<Badge variant="outline">
|
||||||
|
{{ node.ticket_key }}
|
||||||
|
</Badge>
|
||||||
|
<Badge v-if="node.ticket_type_name" variant="secondary">
|
||||||
|
{{ node.ticket_type_name }}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span
|
||||||
|
class="text-body group-hover:text-primary wrap-anywhere min-w-0 font-semibold"
|
||||||
|
>
|
||||||
|
{{ node.title }}
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="node.children.length > 0"
|
v-if="
|
||||||
class="border-border mt-3 border-l pl-4"
|
node.children.length > 0 && !collapsedTicketIds.has(node.id)
|
||||||
|
"
|
||||||
|
:id="`ticket-tree-children-${node.id}`"
|
||||||
|
class="border-border ml-[1.375rem] mt-3 border-l pl-2 sm:pl-4"
|
||||||
>
|
>
|
||||||
<TicketTreeList
|
<TicketTreeList
|
||||||
:nodes="node.children"
|
:nodes="node.children"
|
||||||
|
|||||||
@@ -0,0 +1,320 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {
|
||||||
|
ClipboardCheck,
|
||||||
|
IndentDecrease,
|
||||||
|
IndentIncrease,
|
||||||
|
Plus,
|
||||||
|
Trash2,
|
||||||
|
} from 'lucide-vue-next';
|
||||||
|
import { computed, nextTick, ref, useId, watch } from 'vue';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import InputError from '@/components/InputError.vue';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import {
|
||||||
|
canIndentAcceptanceCriterion,
|
||||||
|
indentAcceptanceCriterion,
|
||||||
|
removeAcceptanceCriterion,
|
||||||
|
syncAcceptanceCriteriaDescendantCheckedState,
|
||||||
|
} from '@/lib/acceptance-criteria';
|
||||||
|
import type { AcceptanceCriteriaModel } from '@/types/models/acceptance-criteria-model';
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
modelValue: AcceptanceCriteriaModel;
|
||||||
|
readonly?: boolean;
|
||||||
|
disabled?: boolean;
|
||||||
|
persistToggles?: boolean;
|
||||||
|
allowEditing?: boolean;
|
||||||
|
saving?: boolean;
|
||||||
|
dirty?: boolean;
|
||||||
|
error?: string;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
readonly: false,
|
||||||
|
disabled: false,
|
||||||
|
persistToggles: false,
|
||||||
|
allowEditing: true,
|
||||||
|
saving: undefined,
|
||||||
|
dirty: false,
|
||||||
|
error: '',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const emit = defineEmits<{
|
||||||
|
'update:modelValue': [items: AcceptanceCriteriaModel];
|
||||||
|
toggle: [index: number, checked: boolean];
|
||||||
|
}>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const id = useId();
|
||||||
|
const root = ref<HTMLElement>();
|
||||||
|
const editing = ref(!props.persistToggles);
|
||||||
|
const completed = computed(
|
||||||
|
() => props.modelValue.filter((item) => item.checked).length,
|
||||||
|
);
|
||||||
|
const locked = computed(() => props.readonly || props.disabled);
|
||||||
|
const update = (items: AcceptanceCriteriaModel): void => {
|
||||||
|
if (!locked.value) {
|
||||||
|
emit('update:modelValue', items);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const focusRow = async (index: number): Promise<void> => {
|
||||||
|
await nextTick();
|
||||||
|
const inputs =
|
||||||
|
root.value?.querySelectorAll<HTMLTextAreaElement>('textarea');
|
||||||
|
if (inputs?.[index]) {
|
||||||
|
inputs[index].focus();
|
||||||
|
} else {
|
||||||
|
root.value
|
||||||
|
?.querySelector<HTMLButtonElement>('[data-add-criterion]')
|
||||||
|
?.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const add = (): void => {
|
||||||
|
update([...props.modelValue, { text: '', checked: false, indent: 0 }]);
|
||||||
|
void focusRow(props.modelValue.length);
|
||||||
|
};
|
||||||
|
const remove = (index: number): void => {
|
||||||
|
update(removeAcceptanceCriterion(props.modelValue, index));
|
||||||
|
void focusRow(Math.max(0, index - 1));
|
||||||
|
};
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
async () => {
|
||||||
|
await nextTick();
|
||||||
|
root.value
|
||||||
|
?.querySelectorAll<HTMLTextAreaElement>('textarea')
|
||||||
|
.forEach((input) => {
|
||||||
|
input.setCustomValidity(
|
||||||
|
input.value.trim() === '' ? t('criteria.required') : '',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
const changeText = (index: number, event: Event): void => {
|
||||||
|
const text = (event.target as HTMLTextAreaElement).value;
|
||||||
|
update(
|
||||||
|
props.modelValue.map((item, position) =>
|
||||||
|
position === index ? { ...item, text } : item,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const toggle = (index: number, event: Event): void => {
|
||||||
|
const target = event.target as HTMLInputElement;
|
||||||
|
const checked = target.checked;
|
||||||
|
target.checked = props.modelValue[index].checked;
|
||||||
|
if (locked.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (props.persistToggles && !editing.value && !props.dirty) {
|
||||||
|
emit('toggle', index, checked);
|
||||||
|
} else {
|
||||||
|
update(
|
||||||
|
syncAcceptanceCriteriaDescendantCheckedState(
|
||||||
|
props.modelValue,
|
||||||
|
index,
|
||||||
|
checked,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const onKeydown = (index: number, event: KeyboardEvent): void => {
|
||||||
|
if (!event.altKey || !['ArrowLeft', 'ArrowRight'].includes(event.key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
update(
|
||||||
|
indentAcceptanceCriterion(
|
||||||
|
props.modelValue,
|
||||||
|
index,
|
||||||
|
event.key === 'ArrowRight' ? 1 : -1,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section
|
||||||
|
ref="root"
|
||||||
|
class="border-border bg-card min-w-0 space-y-4 rounded-xl border p-4 sm:p-5"
|
||||||
|
:aria-labelledby="`${id}-title`"
|
||||||
|
:aria-busy="disabled"
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
|
<h3
|
||||||
|
:id="`${id}-title`"
|
||||||
|
class="flex items-center gap-2 font-semibold"
|
||||||
|
>
|
||||||
|
<ClipboardCheck
|
||||||
|
class="text-primary size-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{{ t('criteria.title') }}
|
||||||
|
</h3>
|
||||||
|
<span class="text-muted-foreground text-sm" aria-live="polite">{{
|
||||||
|
t('criteria.progress', { completed, total: modelValue.length })
|
||||||
|
}}</span>
|
||||||
|
<Button
|
||||||
|
v-if="persistToggles && allowEditing && !readonly"
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
:disabled="
|
||||||
|
disabled ||
|
||||||
|
(editing &&
|
||||||
|
modelValue.some((item) => item.text.trim() === ''))
|
||||||
|
"
|
||||||
|
:aria-pressed="editing"
|
||||||
|
@click="editing = !editing"
|
||||||
|
>
|
||||||
|
{{ t(editing ? 'criteria.preview' : 'criteria.edit') }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<p v-if="!modelValue.length" class="text-muted-foreground text-sm">
|
||||||
|
{{ t('criteria.empty') }}
|
||||||
|
</p>
|
||||||
|
<ol v-else class="space-y-3">
|
||||||
|
<li
|
||||||
|
v-for="(item, index) in modelValue"
|
||||||
|
:key="item.id ?? `new-${index}`"
|
||||||
|
:data-indent="item.indent"
|
||||||
|
class="border-border min-w-0"
|
||||||
|
:class="{ 'border-s-2 ps-2': item.indent > 0 }"
|
||||||
|
:style="{ marginInlineStart: `${item.indent * 0.5}rem` }"
|
||||||
|
>
|
||||||
|
<div class="flex min-w-0 items-start gap-2">
|
||||||
|
<label
|
||||||
|
class="focus-within:ring-ring flex min-h-11 w-11 shrink-0 cursor-pointer items-center justify-center rounded-md focus-within:ring-2"
|
||||||
|
:class="{ 'cursor-not-allowed opacity-60': locked }"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
:checked="item.checked"
|
||||||
|
type="checkbox"
|
||||||
|
:disabled="locked"
|
||||||
|
:aria-label="
|
||||||
|
t('criteria.complete', {
|
||||||
|
number: index + 1,
|
||||||
|
text: item.text,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
class="border-input accent-primary size-5 rounded"
|
||||||
|
@change="toggle(index, $event)"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<div class="min-w-0 flex-1">
|
||||||
|
<textarea
|
||||||
|
v-if="editing && !readonly"
|
||||||
|
:value="item.text"
|
||||||
|
:aria-label="
|
||||||
|
t('criteria.item', { number: index + 1 })
|
||||||
|
"
|
||||||
|
:aria-describedby="`${id}-hint ${id}-error`"
|
||||||
|
:disabled="disabled"
|
||||||
|
:aria-invalid="Boolean(error)"
|
||||||
|
required
|
||||||
|
rows="2"
|
||||||
|
class="border-input bg-background focus-visible:ring-ring min-h-11 w-full rounded-md border px-3 py-2 text-sm outline-none focus-visible:ring-2 disabled:opacity-60"
|
||||||
|
@input="changeText(index, $event)"
|
||||||
|
@keydown="onKeydown(index, $event)"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
v-else
|
||||||
|
class="wrap-anywhere min-h-11 whitespace-pre-wrap py-2.5 text-sm"
|
||||||
|
:class="{
|
||||||
|
'text-muted-foreground line-through':
|
||||||
|
item.checked,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ item.text }}
|
||||||
|
</p>
|
||||||
|
<div
|
||||||
|
v-if="editing && !readonly"
|
||||||
|
class="flex flex-wrap gap-1"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
:disabled="disabled || item.indent === 0"
|
||||||
|
:aria-label="
|
||||||
|
t('criteria.outdent', { number: index + 1 })
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
update(
|
||||||
|
indentAcceptanceCriterion(
|
||||||
|
modelValue,
|
||||||
|
index,
|
||||||
|
-1,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
"
|
||||||
|
><IndentDecrease aria-hidden="true"
|
||||||
|
/></Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
:disabled="
|
||||||
|
disabled ||
|
||||||
|
!canIndentAcceptanceCriterion(
|
||||||
|
modelValue,
|
||||||
|
index,
|
||||||
|
)
|
||||||
|
"
|
||||||
|
:aria-label="
|
||||||
|
t('criteria.indent', { number: index + 1 })
|
||||||
|
"
|
||||||
|
@click="
|
||||||
|
update(
|
||||||
|
indentAcceptanceCriterion(
|
||||||
|
modelValue,
|
||||||
|
index,
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
"
|
||||||
|
><IndentIncrease aria-hidden="true"
|
||||||
|
/></Button>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
:disabled="disabled"
|
||||||
|
:aria-label="
|
||||||
|
t('criteria.remove', { number: index + 1 })
|
||||||
|
"
|
||||||
|
@click="remove(index)"
|
||||||
|
><Trash2 aria-hidden="true"
|
||||||
|
/></Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
<template v-if="editing && !readonly">
|
||||||
|
<Button
|
||||||
|
data-add-criterion
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
:disabled="disabled"
|
||||||
|
@click="add"
|
||||||
|
><Plus aria-hidden="true" />{{ t('criteria.add') }}</Button
|
||||||
|
>
|
||||||
|
<p :id="`${id}-hint`" class="text-muted-foreground text-xs">
|
||||||
|
{{ t('criteria.hint') }}
|
||||||
|
</p>
|
||||||
|
</template>
|
||||||
|
<p
|
||||||
|
v-if="persistToggles && dirty"
|
||||||
|
class="text-muted-foreground text-sm"
|
||||||
|
role="status"
|
||||||
|
>
|
||||||
|
{{ t('criteria.unsaved') }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-if="saving ?? disabled"
|
||||||
|
class="text-muted-foreground text-sm"
|
||||||
|
role="status"
|
||||||
|
>
|
||||||
|
{{ t('criteria.saving') }}
|
||||||
|
</p>
|
||||||
|
<InputError :id="`${id}-error`" :message="error" role="alert" />
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Link } from '@inertiajs/vue3';
|
||||||
|
import { ArrowUpRight } from 'lucide-vue-next';
|
||||||
|
import TicketMetadata from '@/components/tickets/TicketMetadata.vue';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { show as showTicket } from '@/routes/projects/tickets';
|
||||||
|
import type {
|
||||||
|
TicketPresentationEmits,
|
||||||
|
TicketPresentationProps,
|
||||||
|
} from '@/types/ticket-presentation';
|
||||||
|
|
||||||
|
withDefaults(defineProps<TicketPresentationProps>(), {
|
||||||
|
layout: 'card',
|
||||||
|
showDescription: true,
|
||||||
|
showStatus: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<TicketPresentationEmits>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<article
|
||||||
|
:class="[
|
||||||
|
'bg-card text-card-foreground min-w-0 rounded-md border',
|
||||||
|
layout === 'card' ? 'shadow-sm' : '',
|
||||||
|
ticket.is_blocked ? 'border-warning' : 'border-border',
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
:class="
|
||||||
|
layout === 'list'
|
||||||
|
? 'flex min-w-0 flex-col lg:flex-row lg:items-stretch'
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
:href="showTicket({ project: projectId, ticket: ticket.id })"
|
||||||
|
:aria-label="
|
||||||
|
t('tickets.open', {
|
||||||
|
key: ticket.ticket_key,
|
||||||
|
title: ticket.title,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
:class="[
|
||||||
|
'focus-visible:ring-ring/35 gap-card min-h-control hover:bg-accent/35 group flex min-w-0 flex-1 flex-col p-4 transition-[background-color,box-shadow] focus-visible:outline-none focus-visible:ring-2',
|
||||||
|
layout === 'list'
|
||||||
|
? 'rounded-t-md lg:rounded-l-md lg:rounded-tr-none'
|
||||||
|
: 'rounded-t-md',
|
||||||
|
]"
|
||||||
|
@click="emit('open', ticket.id)"
|
||||||
|
>
|
||||||
|
<div class="flex min-w-0 items-start justify-between gap-3">
|
||||||
|
<Badge
|
||||||
|
variant="outline"
|
||||||
|
class="wrap-anywhere max-w-full whitespace-normal"
|
||||||
|
>
|
||||||
|
{{ ticket.ticket_key }}
|
||||||
|
</Badge>
|
||||||
|
<ArrowUpRight
|
||||||
|
class="text-muted-foreground group-hover:text-primary size-4 shrink-0"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3
|
||||||
|
class="text-body group-hover:text-primary wrap-anywhere min-w-0 font-semibold"
|
||||||
|
>
|
||||||
|
{{ ticket.title }}
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<TicketMetadata :ticket="ticket" :show-status="showStatus" />
|
||||||
|
|
||||||
|
<p
|
||||||
|
v-if="showDescription && ticket.description"
|
||||||
|
class="text-caption text-muted-foreground wrap-anywhere line-clamp-3"
|
||||||
|
>
|
||||||
|
{{ ticket.description }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p
|
||||||
|
v-if="ticket.is_blocked && ticket.blocked_comment"
|
||||||
|
class="text-caption text-warning-foreground bg-warning wrap-anywhere rounded-sm px-3 py-2"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
t('tickets.blockerComment', {
|
||||||
|
comment: ticket.blocked_comment,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="$slots.actions"
|
||||||
|
:class="[
|
||||||
|
'border-t p-4',
|
||||||
|
layout === 'list'
|
||||||
|
? 'lg:flex lg:w-80 lg:items-center lg:border-l lg:border-t-0'
|
||||||
|
: '',
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<slot name="actions" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import InputError from '@/components/InputError.vue';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
|
||||||
|
withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
kind?: 'text' | 'number' | 'textarea' | 'select';
|
||||||
|
options?: { value: string | number; label: string }[];
|
||||||
|
error?: string;
|
||||||
|
hint?: string;
|
||||||
|
disabled?: boolean;
|
||||||
|
required?: boolean;
|
||||||
|
autofocus?: boolean;
|
||||||
|
placeholder?: string;
|
||||||
|
rows?: number;
|
||||||
|
min?: number;
|
||||||
|
step?: string;
|
||||||
|
}>(),
|
||||||
|
{ kind: 'text', rows: 5 },
|
||||||
|
);
|
||||||
|
|
||||||
|
const model = defineModel<string | number | null>({ required: true });
|
||||||
|
const controlClass =
|
||||||
|
'min-h-control border-input bg-card focus-visible:border-ring focus-visible:ring-ring/35 w-full min-w-0 rounded-md border px-3 py-2 text-base shadow-xs outline-none transition-[border-color,box-shadow] hover:border-primary/45 focus-visible:ring-2 disabled:cursor-not-allowed disabled:bg-muted disabled:opacity-60 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/25 md:text-body';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="grid min-w-0 content-start gap-2">
|
||||||
|
<Label :for="id">{{ label }}</Label>
|
||||||
|
<select
|
||||||
|
v-if="kind === 'select'"
|
||||||
|
:id="id"
|
||||||
|
v-model="model"
|
||||||
|
:name="id"
|
||||||
|
:disabled="disabled"
|
||||||
|
:required="required"
|
||||||
|
:aria-invalid="Boolean(error)"
|
||||||
|
:aria-describedby="`${id}-hint ${id}-error`"
|
||||||
|
:class="controlClass"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="option in options"
|
||||||
|
:key="option.value"
|
||||||
|
:value="option.value"
|
||||||
|
>
|
||||||
|
{{ option.label }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<textarea
|
||||||
|
v-else-if="kind === 'textarea'"
|
||||||
|
:id="id"
|
||||||
|
v-model="model"
|
||||||
|
:name="id"
|
||||||
|
:rows="rows"
|
||||||
|
:disabled="disabled"
|
||||||
|
:required="required"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
:aria-invalid="Boolean(error)"
|
||||||
|
:aria-describedby="`${id}-hint ${id}-error`"
|
||||||
|
:class="controlClass"
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
v-else
|
||||||
|
:id="id"
|
||||||
|
v-model="model"
|
||||||
|
:name="id"
|
||||||
|
:type="kind"
|
||||||
|
:disabled="disabled"
|
||||||
|
:required="required"
|
||||||
|
:autofocus="autofocus"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
:min="min"
|
||||||
|
:step="step"
|
||||||
|
:maxlength="kind === 'text' ? 255 : undefined"
|
||||||
|
:invalid="Boolean(error)"
|
||||||
|
:aria-describedby="`${id}-hint ${id}-error`"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
:id="`${id}-hint`"
|
||||||
|
class="text-muted-foreground text-xs empty:hidden"
|
||||||
|
>
|
||||||
|
{{ hint }}
|
||||||
|
</p>
|
||||||
|
<InputError :id="`${id}-error`" :message="error" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import TicketFormField from '@/components/tickets/TicketFormField.vue';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { ticketStatusLabel } from '@/lib/tickets';
|
||||||
|
import type { ProjectTicketCreatePageProps } from '@/types';
|
||||||
|
|
||||||
|
const props = defineProps<
|
||||||
|
Pick<
|
||||||
|
ProjectTicketCreatePageProps,
|
||||||
|
| 'project'
|
||||||
|
| 'ticketTypes'
|
||||||
|
| 'ticketPriorities'
|
||||||
|
| 'users'
|
||||||
|
| 'parentTicketOptions'
|
||||||
|
> & {
|
||||||
|
errors: Record<string, string>;
|
||||||
|
disabled?: boolean;
|
||||||
|
autofocus?: boolean;
|
||||||
|
ticketStatusOptions?: ProjectTicketCreatePageProps['ticketStatusOptions'];
|
||||||
|
}
|
||||||
|
>();
|
||||||
|
const title = defineModel<string>('title', { required: true });
|
||||||
|
const description = defineModel<string>('description', { required: true });
|
||||||
|
const type = defineModel<string | number>('type', { required: true });
|
||||||
|
const priority = defineModel<string | number>('priority', { required: true });
|
||||||
|
const assignee = defineModel<string | number>('assignee', { required: true });
|
||||||
|
const parent = defineModel<string | number>('parent', { required: true });
|
||||||
|
const points = defineModel<string | number | null>('points', {
|
||||||
|
required: true,
|
||||||
|
});
|
||||||
|
const status = defineModel<string | number>('status');
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const typeOptions = computed(() =>
|
||||||
|
props.ticketTypes.map((item) => ({ value: item.id, label: item.name })),
|
||||||
|
);
|
||||||
|
const priorityOptions = computed(() =>
|
||||||
|
props.ticketPriorities.map((item) => ({
|
||||||
|
value: item.id,
|
||||||
|
label: item.name,
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
const userOptions = computed(() => [
|
||||||
|
{ value: '', label: t('tickets.unassigned') },
|
||||||
|
...props.users.map((item) => ({ value: item.id, label: item.name })),
|
||||||
|
]);
|
||||||
|
const parentOptions = computed(() => [
|
||||||
|
{ value: '', label: t('ticketDetail.noParent') },
|
||||||
|
...props.parentTicketOptions.map((item) => ({
|
||||||
|
value: item.id,
|
||||||
|
label: `${item.ticket_key} - ${item.title}`,
|
||||||
|
})),
|
||||||
|
]);
|
||||||
|
const statusOptions = computed(
|
||||||
|
() =>
|
||||||
|
props.ticketStatusOptions?.map((item) => ({
|
||||||
|
value: item.id,
|
||||||
|
label: ticketStatusLabel(item, t('ticketDetail.notSet')),
|
||||||
|
})) ?? [],
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="grid min-w-0 gap-6">
|
||||||
|
<TicketFormField
|
||||||
|
id="title"
|
||||||
|
v-model="title"
|
||||||
|
:label="t('ticketDetail.title')"
|
||||||
|
:error="errors.title"
|
||||||
|
:disabled="disabled"
|
||||||
|
:autofocus="autofocus"
|
||||||
|
:placeholder="t('ticketForm.titlePlaceholder')"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
id="description"
|
||||||
|
v-model="description"
|
||||||
|
kind="textarea"
|
||||||
|
:label="t('ticketDetail.description')"
|
||||||
|
:error="errors.description"
|
||||||
|
:disabled="disabled"
|
||||||
|
:placeholder="t('ticketForm.descriptionPlaceholder')"
|
||||||
|
/>
|
||||||
|
<slot name="content" />
|
||||||
|
<fieldset
|
||||||
|
class="bg-muted/20 grid min-w-0 gap-5 rounded-xl border p-4 sm:p-5"
|
||||||
|
:disabled="disabled"
|
||||||
|
>
|
||||||
|
<legend class="px-2 text-sm font-semibold">
|
||||||
|
{{ t('ticketDetail.metadata') }}
|
||||||
|
</legend>
|
||||||
|
<div class="grid min-w-0 gap-5 sm:grid-cols-2">
|
||||||
|
<TicketFormField
|
||||||
|
id="ticket_type_id"
|
||||||
|
v-model="type"
|
||||||
|
kind="select"
|
||||||
|
:label="t('ticketDetail.type')"
|
||||||
|
:options="typeOptions"
|
||||||
|
:error="errors.ticket_type_id"
|
||||||
|
:disabled="disabled"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
id="ticket_priority_id"
|
||||||
|
v-model="priority"
|
||||||
|
kind="select"
|
||||||
|
:label="t('ticketDetail.priority')"
|
||||||
|
:options="priorityOptions"
|
||||||
|
:error="errors.ticket_priority_id"
|
||||||
|
:disabled="disabled"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
v-if="ticketStatusOptions && status !== undefined"
|
||||||
|
id="ticket_status_id"
|
||||||
|
v-model="status"
|
||||||
|
kind="select"
|
||||||
|
:label="t('ticketDetail.status')"
|
||||||
|
:options="statusOptions"
|
||||||
|
:error="errors.ticket_status_id"
|
||||||
|
:disabled="disabled"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
id="assignee_user_id"
|
||||||
|
v-model="assignee"
|
||||||
|
kind="select"
|
||||||
|
:label="t('ticketDetail.assignee')"
|
||||||
|
:options="userOptions"
|
||||||
|
:error="errors.assignee_user_id"
|
||||||
|
:disabled="disabled"
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
id="parent_ticket_id"
|
||||||
|
v-model="parent"
|
||||||
|
kind="select"
|
||||||
|
:label="t('ticketDetail.parent')"
|
||||||
|
:options="parentOptions"
|
||||||
|
:error="errors.parent_ticket_id"
|
||||||
|
:disabled="disabled"
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
v-if="project.show_story_points"
|
||||||
|
id="story_points"
|
||||||
|
v-model="points"
|
||||||
|
kind="number"
|
||||||
|
:label="t('ticketDetail.storyPoints')"
|
||||||
|
:error="errors.story_points"
|
||||||
|
:disabled="disabled"
|
||||||
|
:min="0"
|
||||||
|
step="1"
|
||||||
|
/>
|
||||||
|
<slot name="metadata" />
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Link } from '@inertiajs/vue3';
|
||||||
|
import { ArrowUpRight } from 'lucide-vue-next';
|
||||||
|
import TicketMetadata from '@/components/tickets/TicketMetadata.vue';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { show as showTicket } from '@/routes/projects/tickets';
|
||||||
|
import type {
|
||||||
|
TicketPresentationEmits,
|
||||||
|
TicketPresentationProps,
|
||||||
|
} from '@/types/ticket-presentation';
|
||||||
|
|
||||||
|
withDefaults(defineProps<TicketPresentationProps>(), {
|
||||||
|
showDescription: true,
|
||||||
|
showStatus: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<TicketPresentationEmits>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<li
|
||||||
|
:class="[
|
||||||
|
'bg-card text-card-foreground min-w-0 rounded-md border',
|
||||||
|
ticket.is_blocked ? 'border-warning' : 'border-border',
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<div class="flex min-w-0 flex-col lg:flex-row lg:items-stretch">
|
||||||
|
<Link
|
||||||
|
:href="showTicket({ project: projectId, ticket: ticket.id })"
|
||||||
|
:aria-label="
|
||||||
|
t('tickets.open', {
|
||||||
|
key: ticket.ticket_key,
|
||||||
|
title: ticket.title,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
class="focus-visible:ring-ring/35 gap-card min-h-control hover:bg-accent/35 group flex min-w-0 flex-1 flex-col rounded-t-md p-4 transition-[background-color,box-shadow] focus-visible:outline-none focus-visible:ring-2 lg:rounded-l-md lg:rounded-tr-none"
|
||||||
|
@click="emit('open', ticket.id)"
|
||||||
|
>
|
||||||
|
<div class="flex min-w-0 items-start gap-3">
|
||||||
|
<Badge
|
||||||
|
variant="outline"
|
||||||
|
class="wrap-anywhere max-w-full whitespace-normal"
|
||||||
|
>
|
||||||
|
{{ ticket.ticket_key }}
|
||||||
|
</Badge>
|
||||||
|
<h3
|
||||||
|
class="text-body group-hover:text-primary wrap-anywhere min-w-0 flex-1 font-semibold"
|
||||||
|
>
|
||||||
|
{{ ticket.title }}
|
||||||
|
</h3>
|
||||||
|
<ArrowUpRight
|
||||||
|
class="text-muted-foreground group-hover:text-primary size-4 shrink-0"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TicketMetadata :ticket="ticket" :show-status="showStatus" />
|
||||||
|
|
||||||
|
<p
|
||||||
|
v-if="showDescription && ticket.description"
|
||||||
|
class="text-caption text-muted-foreground wrap-anywhere line-clamp-2"
|
||||||
|
>
|
||||||
|
{{ ticket.description }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p
|
||||||
|
v-if="ticket.is_blocked && ticket.blocked_comment"
|
||||||
|
class="text-caption text-warning-foreground bg-warning wrap-anywhere rounded-sm px-3 py-2"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
t('tickets.blockerComment', {
|
||||||
|
comment: ticket.blocked_comment,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="$slots.actions"
|
||||||
|
class="border-t p-4 lg:flex lg:w-80 lg:items-center lg:border-l lg:border-t-0"
|
||||||
|
>
|
||||||
|
<slot name="actions" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { CircleUserRound, OctagonAlert } from 'lucide-vue-next';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { UserAvatar } from '@/components/ui/avatar';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { ticketStatusLabel } from '@/lib/tickets';
|
||||||
|
import type { TicketModel } from '@/types/models/ticket-model';
|
||||||
|
|
||||||
|
const props = withDefaults(
|
||||||
|
defineProps<{
|
||||||
|
showStatus?: boolean;
|
||||||
|
ticket: TicketModel;
|
||||||
|
}>(),
|
||||||
|
{
|
||||||
|
showStatus: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const statusLabel = computed(() =>
|
||||||
|
ticketStatusLabel(props.ticket.ticket_status, t('tickets.noStatus')),
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="gap-stack flex min-w-0 flex-wrap items-center">
|
||||||
|
<Badge
|
||||||
|
v-if="ticket.is_blocked"
|
||||||
|
variant="warning"
|
||||||
|
:aria-label="t('tickets.blocked')"
|
||||||
|
>
|
||||||
|
<OctagonAlert aria-hidden="true" />
|
||||||
|
{{ t('tickets.blocked') }}
|
||||||
|
</Badge>
|
||||||
|
|
||||||
|
<Badge
|
||||||
|
variant="secondary"
|
||||||
|
:aria-label="
|
||||||
|
t('tickets.typeLabel', { name: ticket.ticket_type.name })
|
||||||
|
"
|
||||||
|
:data-ticket-type-id="ticket.ticket_type.id"
|
||||||
|
>
|
||||||
|
{{ ticket.ticket_type.name }}
|
||||||
|
</Badge>
|
||||||
|
|
||||||
|
<Badge
|
||||||
|
variant="outline"
|
||||||
|
:aria-label="
|
||||||
|
t('tickets.priorityLabel', {
|
||||||
|
name: ticket.ticket_priority.name,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
:data-ticket-priority-id="ticket.ticket_priority.id"
|
||||||
|
>
|
||||||
|
{{ ticket.ticket_priority.name }}
|
||||||
|
</Badge>
|
||||||
|
|
||||||
|
<Badge
|
||||||
|
v-if="showStatus"
|
||||||
|
variant="outline"
|
||||||
|
:aria-label="t('tickets.statusLabel', { name: statusLabel })"
|
||||||
|
:data-ticket-status-id="ticket.ticket_status?.id"
|
||||||
|
>
|
||||||
|
{{ statusLabel }}
|
||||||
|
</Badge>
|
||||||
|
|
||||||
|
<span
|
||||||
|
v-if="ticket.assignee"
|
||||||
|
class="text-caption text-muted-foreground flex min-w-0 items-center gap-1.5"
|
||||||
|
:aria-label="
|
||||||
|
t('tickets.assignedTo', { name: ticket.assignee.name })
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<UserAvatar
|
||||||
|
:user="ticket.assignee"
|
||||||
|
size="sm"
|
||||||
|
:label="ticket.assignee.name"
|
||||||
|
/>
|
||||||
|
<span class="max-w-40 truncate">{{ ticket.assignee.name }}</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="text-caption text-muted-foreground flex items-center gap-1.5"
|
||||||
|
>
|
||||||
|
<CircleUserRound class="size-4" aria-hidden="true" />
|
||||||
|
{{ t('tickets.unassigned') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,518 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { useForm, useRemember } from '@inertiajs/vue3';
|
||||||
|
import { computed, ref, toRef, unref, useTemplateRef, nextTick } from 'vue';
|
||||||
|
import ProjectTicketController from '@/actions/App/Http/Controllers/ProjectTicketController';
|
||||||
|
import InputError from '@/components/InputError.vue';
|
||||||
|
import AcceptanceCriteriaChecklist from '@/components/tickets/AcceptanceCriteriaChecklist.vue';
|
||||||
|
import FormFeedback from '@/components/FormFeedback.vue';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import TicketFormField from '@/components/tickets/TicketFormField.vue';
|
||||||
|
import TicketFormFields from '@/components/tickets/TicketFormFields.vue';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
|
import {
|
||||||
|
normalizeAcceptanceCriteria,
|
||||||
|
syncAcceptanceCriteriaDescendantCheckedState,
|
||||||
|
} from '@/lib/acceptance-criteria';
|
||||||
|
import type { TicketDetailContentProps } from '@/types/ticket-detail';
|
||||||
|
const props = defineProps<TicketDetailContentProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const editor = useTemplateRef<HTMLDetailsElement>('editor');
|
||||||
|
async function editParent(): Promise<void> {
|
||||||
|
if (!props.canEditTicket || !editor.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
editor.value.open = true;
|
||||||
|
await nextTick();
|
||||||
|
editor.value
|
||||||
|
?.querySelector<HTMLSelectElement>('#parent_ticket_id')
|
||||||
|
?.focus();
|
||||||
|
}
|
||||||
|
defineExpose({ editParent });
|
||||||
|
const canEditAuthor = computed(
|
||||||
|
() => props.canEditTicket && props.canManageProject,
|
||||||
|
);
|
||||||
|
const canViewAuthor = computed(
|
||||||
|
() => props.project.show_author || props.canManageProject,
|
||||||
|
);
|
||||||
|
const draftKey = `projects:${props.project.id}:tickets:${props.ticket.id}:edit`;
|
||||||
|
const acceptanceCriteriaDraft = useRemember(
|
||||||
|
{ items: normalizeAcceptanceCriteria(props.ticket.acceptance_criteria) },
|
||||||
|
`${draftKey}:criteria`,
|
||||||
|
);
|
||||||
|
const acceptanceCriteriaItems = toRef(unref(acceptanceCriteriaDraft), 'items');
|
||||||
|
const savedAcceptanceCriteria = ref(
|
||||||
|
normalizeAcceptanceCriteria(props.ticket.acceptance_criteria),
|
||||||
|
);
|
||||||
|
const isPersistingAcceptanceCriteriaToggle = ref(false);
|
||||||
|
const acceptanceCriteriaToggleError = ref('');
|
||||||
|
|
||||||
|
const savedFormData = () => ({
|
||||||
|
acceptance_criteria: normalizeAcceptanceCriteria(
|
||||||
|
savedAcceptanceCriteria.value,
|
||||||
|
),
|
||||||
|
assignee_user_id: props.ticket.assignee_user_id ?? '',
|
||||||
|
author_user_id: props.ticket.author_user_id ?? '',
|
||||||
|
blocked_comment: props.ticket.blocked_comment ?? '',
|
||||||
|
description: props.ticket.description ?? '',
|
||||||
|
field_values: props.ticketFieldDefinitions.map((ticketFieldDefinition) => {
|
||||||
|
const currentFieldValue = props.ticket.field_values?.find(
|
||||||
|
(fieldValue) =>
|
||||||
|
fieldValue.ticket_field_definition_id ===
|
||||||
|
ticketFieldDefinition.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
ticket_field_definition_id: ticketFieldDefinition.id,
|
||||||
|
value_number: currentFieldValue?.value_number ?? '',
|
||||||
|
value_user_id: currentFieldValue?.value_user_id ?? '',
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
is_blocked: props.ticket.is_blocked,
|
||||||
|
parent_ticket_id: props.ticket.parent_ticket_id ?? '',
|
||||||
|
ticket_priority_id: props.ticket.ticket_priority_id,
|
||||||
|
ticket_type_id: props.ticket.ticket_type_id,
|
||||||
|
title: props.ticket.title,
|
||||||
|
story_points: props.ticket.story_points,
|
||||||
|
});
|
||||||
|
|
||||||
|
const form = useForm(draftKey, savedFormData());
|
||||||
|
|
||||||
|
const hasUnsavedAcceptanceCriteriaDraft = computed(
|
||||||
|
() =>
|
||||||
|
JSON.stringify(acceptanceCriteriaItems.value) !==
|
||||||
|
JSON.stringify(savedAcceptanceCriteria.value),
|
||||||
|
);
|
||||||
|
|
||||||
|
const isDirty = computed(
|
||||||
|
() =>
|
||||||
|
props.canEditTicket &&
|
||||||
|
(form.isDirty || hasUnsavedAcceptanceCriteriaDraft.value),
|
||||||
|
);
|
||||||
|
const protection = useFormProtection(form, { isDirty: () => isDirty.value });
|
||||||
|
const reset = (): void => {
|
||||||
|
if (
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle.value ||
|
||||||
|
!protection.confirmLeave()
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
form.reset();
|
||||||
|
form.clearErrors();
|
||||||
|
acceptanceCriteriaItems.value = normalizeAcceptanceCriteria(
|
||||||
|
savedAcceptanceCriteria.value,
|
||||||
|
);
|
||||||
|
acceptanceCriteriaToggleError.value = '';
|
||||||
|
protection.clearFeedback();
|
||||||
|
};
|
||||||
|
|
||||||
|
const acceptanceCriteriaError = computed(() => {
|
||||||
|
return (
|
||||||
|
form.errors.acceptance_criteria ??
|
||||||
|
Object.entries(form.errors).find(([key]) =>
|
||||||
|
key.startsWith('acceptance_criteria.'),
|
||||||
|
)?.[1] ??
|
||||||
|
''
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const buildSavedTicketPayload = (
|
||||||
|
acceptanceCriteria = savedAcceptanceCriteria.value,
|
||||||
|
) => ({
|
||||||
|
acceptance_criteria: acceptanceCriteria,
|
||||||
|
assignee_user_id: props.ticket.assignee_user_id,
|
||||||
|
author_user_id: props.ticket.author_user_id,
|
||||||
|
blocked_comment: props.ticket.blocked_comment,
|
||||||
|
description: props.ticket.description,
|
||||||
|
field_values: (props.ticket.field_values ?? []).map((fieldValue) => ({
|
||||||
|
ticket_field_definition_id: fieldValue.ticket_field_definition_id,
|
||||||
|
value_number: fieldValue.value_number,
|
||||||
|
value_user_id: fieldValue.value_user_id,
|
||||||
|
})),
|
||||||
|
is_blocked: props.ticket.is_blocked,
|
||||||
|
parent_ticket_id: props.ticket.parent_ticket_id,
|
||||||
|
story_points: props.ticket.story_points,
|
||||||
|
ticket_priority_id: props.ticket.ticket_priority_id,
|
||||||
|
ticket_type_id: props.ticket.ticket_type_id,
|
||||||
|
title: props.ticket.title,
|
||||||
|
});
|
||||||
|
|
||||||
|
const persistAcceptanceCriteriaToggle = async (
|
||||||
|
index: number,
|
||||||
|
checked: boolean,
|
||||||
|
): Promise<void> => {
|
||||||
|
if (
|
||||||
|
!props.canEditTicket ||
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle.value ||
|
||||||
|
hasUnsavedAcceptanceCriteriaDraft.value
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextAcceptanceCriteria = syncAcceptanceCriteriaDescendantCheckedState(
|
||||||
|
savedAcceptanceCriteria.value,
|
||||||
|
index,
|
||||||
|
checked,
|
||||||
|
);
|
||||||
|
const csrfToken = document
|
||||||
|
.querySelector('meta[name="csrf-token"]')
|
||||||
|
?.getAttribute('content');
|
||||||
|
|
||||||
|
isPersistingAcceptanceCriteriaToggle.value = true;
|
||||||
|
acceptanceCriteriaToggleError.value = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
ProjectTicketController.update.url({
|
||||||
|
project: props.project.id,
|
||||||
|
ticket: props.ticket.id,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
method: 'PATCH',
|
||||||
|
credentials: 'same-origin',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': csrfToken ?? '',
|
||||||
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
},
|
||||||
|
body: JSON.stringify(
|
||||||
|
buildSavedTicketPayload(nextAcceptanceCriteria),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Checklist toggle update failed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
savedAcceptanceCriteria.value = nextAcceptanceCriteria;
|
||||||
|
|
||||||
|
acceptanceCriteriaItems.value = normalizeAcceptanceCriteria(
|
||||||
|
nextAcceptanceCriteria,
|
||||||
|
);
|
||||||
|
form.acceptance_criteria = nextAcceptanceCriteria;
|
||||||
|
form.defaults('acceptance_criteria', nextAcceptanceCriteria);
|
||||||
|
} catch (_error) {
|
||||||
|
acceptanceCriteriaToggleError.value = t('criteria.saveError');
|
||||||
|
} finally {
|
||||||
|
isPersistingAcceptanceCriteriaToggle.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const submit = (): void => {
|
||||||
|
if (
|
||||||
|
!props.canEditTicket ||
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle.value
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
form.acceptance_criteria = acceptanceCriteriaItems.value;
|
||||||
|
|
||||||
|
protection.submit(
|
||||||
|
ProjectTicketController.update({
|
||||||
|
project: props.project.id,
|
||||||
|
ticket: props.ticket.id,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
preserveScroll: true,
|
||||||
|
onSuccess: () => {
|
||||||
|
savedAcceptanceCriteria.value = normalizeAcceptanceCriteria(
|
||||||
|
props.ticket.acceptance_criteria,
|
||||||
|
);
|
||||||
|
acceptanceCriteriaItems.value = normalizeAcceptanceCriteria(
|
||||||
|
savedAcceptanceCriteria.value,
|
||||||
|
);
|
||||||
|
Object.assign(form, savedFormData());
|
||||||
|
form.defaults();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="flex min-w-0 flex-col gap-6">
|
||||||
|
<section
|
||||||
|
id="ticket-description"
|
||||||
|
aria-labelledby="ticket-description-title"
|
||||||
|
class="scroll-mt-6"
|
||||||
|
>
|
||||||
|
<Card>
|
||||||
|
<CardHeader
|
||||||
|
><h2
|
||||||
|
id="ticket-description-title"
|
||||||
|
class="text-lg font-semibold"
|
||||||
|
>
|
||||||
|
{{ t('ticketDetail.description') }}
|
||||||
|
</h2></CardHeader
|
||||||
|
>
|
||||||
|
<CardContent>
|
||||||
|
<p
|
||||||
|
class="wrap-anywhere whitespace-pre-wrap text-sm leading-7"
|
||||||
|
:class="{
|
||||||
|
'text-muted-foreground': !ticket.description,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
ticket.description ||
|
||||||
|
t('ticketDetail.noDescription')
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</section>
|
||||||
|
<div id="ticket-checklist" class="scroll-mt-6">
|
||||||
|
<AcceptanceCriteriaChecklist
|
||||||
|
:model-value="savedAcceptanceCriteria"
|
||||||
|
:readonly="!canEditTicket"
|
||||||
|
:disabled="
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle ||
|
||||||
|
hasUnsavedAcceptanceCriteriaDraft
|
||||||
|
"
|
||||||
|
:saving="
|
||||||
|
form.processing || isPersistingAcceptanceCriteriaToggle
|
||||||
|
"
|
||||||
|
:allow-editing="false"
|
||||||
|
persist-toggles
|
||||||
|
:dirty="hasUnsavedAcceptanceCriteriaDraft"
|
||||||
|
:error="acceptanceCriteriaToggleError"
|
||||||
|
@toggle="persistAcceptanceCriteriaToggle"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<details
|
||||||
|
v-if="canEditTicket"
|
||||||
|
id="ticket-edit"
|
||||||
|
ref="editor"
|
||||||
|
class="bg-card group rounded-xl border shadow-sm"
|
||||||
|
>
|
||||||
|
<summary
|
||||||
|
class="min-h-control focus-visible:ring-ring cursor-pointer rounded-xl px-6 py-4 font-semibold focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
{{ t('ticketDetail.edit') }}
|
||||||
|
</summary>
|
||||||
|
<div class="border-t p-4 sm:p-6">
|
||||||
|
<p class="text-muted-foreground mb-6 text-sm">
|
||||||
|
{{ t('ticketDetail.editDescription') }}
|
||||||
|
</p>
|
||||||
|
<form class="grid min-w-0 gap-6" @submit.prevent="submit">
|
||||||
|
<FormFeedback
|
||||||
|
:state="protection.state.value"
|
||||||
|
@retry="submit"
|
||||||
|
/>
|
||||||
|
<TicketFormFields
|
||||||
|
v-model:title="form.title"
|
||||||
|
v-model:description="form.description"
|
||||||
|
v-model:type="form.ticket_type_id"
|
||||||
|
v-model:priority="form.ticket_priority_id"
|
||||||
|
v-model:assignee="form.assignee_user_id"
|
||||||
|
v-model:parent="form.parent_ticket_id"
|
||||||
|
v-model:points="form.story_points"
|
||||||
|
:project="project"
|
||||||
|
:ticket-types="ticketTypes"
|
||||||
|
:ticket-priorities="ticketPriorities"
|
||||||
|
:users="users"
|
||||||
|
:parent-ticket-options="parentTicketOptions"
|
||||||
|
:errors="form.errors"
|
||||||
|
:disabled="
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<template #content>
|
||||||
|
<AcceptanceCriteriaChecklist
|
||||||
|
v-model="acceptanceCriteriaItems"
|
||||||
|
:disabled="
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle
|
||||||
|
"
|
||||||
|
:error="acceptanceCriteriaError"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template #metadata>
|
||||||
|
<TicketFormField
|
||||||
|
v-if="canViewAuthor"
|
||||||
|
id="author_user_id"
|
||||||
|
v-model="form.author_user_id"
|
||||||
|
kind="select"
|
||||||
|
:label="t('ticketDetail.author')"
|
||||||
|
:hint="
|
||||||
|
!canEditAuthor
|
||||||
|
? t('ticketForm.authorRestricted')
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
:options="[
|
||||||
|
{
|
||||||
|
value: '',
|
||||||
|
label: t('ticketDetail.noAuthor'),
|
||||||
|
},
|
||||||
|
...users.map((user) => ({
|
||||||
|
value: user.id,
|
||||||
|
label: user.name,
|
||||||
|
})),
|
||||||
|
]"
|
||||||
|
:error="form.errors.author_user_id"
|
||||||
|
:disabled="!canEditAuthor || form.processing"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</TicketFormFields>
|
||||||
|
<fieldset
|
||||||
|
class="grid min-w-0 gap-4 rounded-xl border p-4 sm:p-5"
|
||||||
|
:disabled="
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<legend class="px-2 text-sm font-semibold">
|
||||||
|
{{ t('ticketForm.blocker') }}
|
||||||
|
</legend>
|
||||||
|
<div class="min-h-control flex items-center gap-3">
|
||||||
|
<input
|
||||||
|
id="is_blocked"
|
||||||
|
v-model="form.is_blocked"
|
||||||
|
type="checkbox"
|
||||||
|
:aria-invalid="Boolean(form.errors.is_blocked)"
|
||||||
|
aria-describedby="is_blocked-error"
|
||||||
|
class="border-input text-primary focus-visible:ring-ring size-4 rounded focus-visible:ring-2"
|
||||||
|
/>
|
||||||
|
<Label for="is_blocked">{{
|
||||||
|
t('ticketDetail.blocked')
|
||||||
|
}}</Label>
|
||||||
|
</div>
|
||||||
|
<InputError
|
||||||
|
id="is_blocked-error"
|
||||||
|
:message="form.errors.is_blocked"
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
id="blocked_comment"
|
||||||
|
v-model="form.blocked_comment"
|
||||||
|
kind="textarea"
|
||||||
|
:rows="3"
|
||||||
|
:label="t('ticketDetail.blockerComment')"
|
||||||
|
:placeholder="t('ticketDetail.blockerPlaceholder')"
|
||||||
|
:error="form.errors.blocked_comment"
|
||||||
|
:required="form.is_blocked"
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset
|
||||||
|
class="grid min-w-0 gap-4 rounded-xl border p-4 sm:p-5"
|
||||||
|
:disabled="
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<legend class="px-2 text-sm font-semibold">
|
||||||
|
{{ t('ticketDetail.customFields') }}
|
||||||
|
</legend>
|
||||||
|
<p class="text-muted-foreground text-sm">
|
||||||
|
{{ t('ticketDetail.customFieldsDescription') }}
|
||||||
|
</p>
|
||||||
|
<InputError :message="form.errors.field_values" />
|
||||||
|
<p
|
||||||
|
v-if="!ticketFieldDefinitions.length"
|
||||||
|
class="text-muted-foreground text-sm"
|
||||||
|
>
|
||||||
|
{{ t('ticketDetail.noCustomFields') }}
|
||||||
|
</p>
|
||||||
|
<div v-else class="grid min-w-0 gap-5 sm:grid-cols-2">
|
||||||
|
<template
|
||||||
|
v-for="(
|
||||||
|
definition, index
|
||||||
|
) in ticketFieldDefinitions"
|
||||||
|
:key="definition.id"
|
||||||
|
>
|
||||||
|
<TicketFormField
|
||||||
|
v-if="definition.field_type === 'user'"
|
||||||
|
:id="`field-${definition.id}`"
|
||||||
|
v-model="
|
||||||
|
form.field_values[index].value_user_id
|
||||||
|
"
|
||||||
|
kind="select"
|
||||||
|
:label="definition.label"
|
||||||
|
:options="[
|
||||||
|
{
|
||||||
|
value: '',
|
||||||
|
label: t('tickets.unassigned'),
|
||||||
|
},
|
||||||
|
...users.map((user) => ({
|
||||||
|
value: user.id,
|
||||||
|
label: user.name,
|
||||||
|
})),
|
||||||
|
]"
|
||||||
|
:error="
|
||||||
|
form.errors[
|
||||||
|
`field_values.${index}.value_user_id`
|
||||||
|
] ??
|
||||||
|
form.errors[
|
||||||
|
`field_values.${index}.ticket_field_definition_id`
|
||||||
|
]
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
v-else
|
||||||
|
:id="`field-${definition.id}`"
|
||||||
|
v-model="
|
||||||
|
form.field_values[index].value_number
|
||||||
|
"
|
||||||
|
kind="number"
|
||||||
|
step="0.1"
|
||||||
|
:label="definition.label"
|
||||||
|
:error="
|
||||||
|
form.errors[
|
||||||
|
`field_values.${index}.value_number`
|
||||||
|
] ??
|
||||||
|
form.errors[
|
||||||
|
`field_values.${index}.ticket_field_definition_id`
|
||||||
|
]
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<div
|
||||||
|
class="flex flex-wrap items-center gap-3 border-t pt-5"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
:disabled="
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle
|
||||||
|
"
|
||||||
|
>{{
|
||||||
|
form.processing
|
||||||
|
? t('ticketForm.saving')
|
||||||
|
: t('ticketDetail.saveChanges')
|
||||||
|
}}</Button
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
:disabled="
|
||||||
|
form.processing ||
|
||||||
|
isPersistingAcceptanceCriteriaToggle ||
|
||||||
|
!isDirty
|
||||||
|
"
|
||||||
|
@click="reset"
|
||||||
|
>{{ t('ticketForm.reset') }}</Button
|
||||||
|
>
|
||||||
|
<p role="status" class="text-muted-foreground text-sm">
|
||||||
|
{{
|
||||||
|
isDirty
|
||||||
|
? t('ticketForm.unsaved')
|
||||||
|
: t('ticketForm.saved')
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,658 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardDescription,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { Link, useForm, usePage } from '@inertiajs/vue3';
|
||||||
|
import { CheckCircle2, GitBranchPlus, XCircle } from 'lucide-vue-next';
|
||||||
|
import { computed, ref, watch } from 'vue';
|
||||||
|
import ProjectTicketBranchController from '@/actions/App/Http/Controllers/ProjectTicketBranchController';
|
||||||
|
import FormFeedback from '@/components/FormFeedback.vue';
|
||||||
|
import FeedbackState from '@/components/FeedbackState.vue';
|
||||||
|
import InputError from '@/components/InputError.vue';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import {
|
||||||
|
Dialog,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogTitle,
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
|
import { edit as editGitConnections } from '@/routes/git-connections';
|
||||||
|
import type { BranchNameValidationModel } from '@/types/models/branch-name-validation-model';
|
||||||
|
import type { RepositoryConnectionModel } from '@/types/models/repository-connection-model';
|
||||||
|
import type {
|
||||||
|
TicketDetailGitProps,
|
||||||
|
TicketBranchFormData,
|
||||||
|
} from '@/types/ticket-detail';
|
||||||
|
const props = defineProps<TicketDetailGitProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const appName = String(usePage().props.name);
|
||||||
|
const draftKey = `projects:${props.project.id}:tickets:${props.ticket.id}:edit`;
|
||||||
|
const visibleRepositoryBranches = computed(() =>
|
||||||
|
props.repositoryBranches.filter(
|
||||||
|
(repositoryBranch) =>
|
||||||
|
repositoryBranch.branches.length > 0 ||
|
||||||
|
repositoryBranch.error !== null ||
|
||||||
|
!repositoryBranch.repository_connection.has_personal_access,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const visibleRepositoryPullRequests = computed(() =>
|
||||||
|
props.repositoryPullRequests.filter(
|
||||||
|
(repositoryPullRequest) =>
|
||||||
|
repositoryPullRequest.pull_requests.length > 0 ||
|
||||||
|
repositoryPullRequest.error !== null ||
|
||||||
|
!repositoryPullRequest.repository_connection.has_personal_access,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const linkedRepositoryConnections = computed<RepositoryConnectionModel[]>(() =>
|
||||||
|
props.repositoryBranches.map(
|
||||||
|
(repositoryBranch) => repositoryBranch.repository_connection,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const canCreateBranches = computed(
|
||||||
|
() => props.canEditTicket && linkedRepositoryConnections.value.length > 0,
|
||||||
|
);
|
||||||
|
const defaultBranchRepositoryConnectionId = computed(() =>
|
||||||
|
String(
|
||||||
|
linkedRepositoryConnections.value.find(
|
||||||
|
(repositoryConnection) => repositoryConnection.has_personal_access,
|
||||||
|
)?.id ??
|
||||||
|
linkedRepositoryConnections.value[0]?.id ??
|
||||||
|
'',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const isCreateBranchDialogOpen = ref(false);
|
||||||
|
const isCheckingBranchName = ref(false);
|
||||||
|
const branchNameValidation = ref<BranchNameValidationModel | null>(null);
|
||||||
|
|
||||||
|
const branchCreationForm = useForm<TicketBranchFormData>(`${draftKey}:branch`, {
|
||||||
|
branch_name: props.suggestedBranchName,
|
||||||
|
repository_connection_id: defaultBranchRepositoryConnectionId.value,
|
||||||
|
});
|
||||||
|
const branchProtection = useFormProtection(branchCreationForm, {
|
||||||
|
isDirty: () => isCreateBranchDialogOpen.value && branchCreationForm.isDirty,
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateBranchDialogOpen = (open: boolean): void => {
|
||||||
|
if (!open && !branchProtection.confirmLeave()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isCreateBranchDialogOpen.value = open;
|
||||||
|
};
|
||||||
|
|
||||||
|
const selectedBranchRepositoryConnection = computed(
|
||||||
|
(): RepositoryConnectionModel | null =>
|
||||||
|
linkedRepositoryConnections.value.find(
|
||||||
|
(repositoryConnection) =>
|
||||||
|
String(repositoryConnection.id) ===
|
||||||
|
branchCreationForm.repository_connection_id,
|
||||||
|
) ?? null,
|
||||||
|
);
|
||||||
|
|
||||||
|
const selectedBranchRepositoryHasPersonalAccess = computed(
|
||||||
|
() =>
|
||||||
|
selectedBranchRepositoryConnection.value?.has_personal_access ?? false,
|
||||||
|
);
|
||||||
|
|
||||||
|
const initializeBranchCreationForm = (): void => {
|
||||||
|
if (branchCreationForm.isDirty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
branchCreationForm.clearErrors();
|
||||||
|
branchCreationForm.branch_name = props.suggestedBranchName;
|
||||||
|
branchCreationForm.repository_connection_id =
|
||||||
|
defaultBranchRepositoryConnectionId.value;
|
||||||
|
branchNameValidation.value = null;
|
||||||
|
isCheckingBranchName.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => isCreateBranchDialogOpen.value,
|
||||||
|
(isOpen) => {
|
||||||
|
if (!isOpen) {
|
||||||
|
branchCreationForm.clearErrors();
|
||||||
|
branchNameValidation.value = null;
|
||||||
|
isCheckingBranchName.value = false;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
initializeBranchCreationForm();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[
|
||||||
|
() => isCreateBranchDialogOpen.value,
|
||||||
|
() => branchCreationForm.repository_connection_id,
|
||||||
|
() => branchCreationForm.branch_name,
|
||||||
|
],
|
||||||
|
(
|
||||||
|
[isOpen, repositoryConnectionId, branchName],
|
||||||
|
_previousValues,
|
||||||
|
onCleanup,
|
||||||
|
) => {
|
||||||
|
if (!isOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const repositoryConnection = selectedBranchRepositoryConnection.value;
|
||||||
|
|
||||||
|
if (repositoryConnection === null || repositoryConnectionId === '') {
|
||||||
|
branchNameValidation.value = null;
|
||||||
|
isCheckingBranchName.value = false;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!repositoryConnection.has_personal_access) {
|
||||||
|
branchNameValidation.value = {
|
||||||
|
is_valid: false,
|
||||||
|
message: t('ticketDetail.connectGitFirst'),
|
||||||
|
};
|
||||||
|
isCheckingBranchName.value = false;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (branchName.trim() === '') {
|
||||||
|
branchNameValidation.value = {
|
||||||
|
is_valid: false,
|
||||||
|
message: t('ticketDetail.branchRequired'),
|
||||||
|
};
|
||||||
|
isCheckingBranchName.value = false;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const abortController = new AbortController();
|
||||||
|
const timeoutId = window.setTimeout(async () => {
|
||||||
|
isCheckingBranchName.value = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
ProjectTicketBranchController.validate.url(
|
||||||
|
{
|
||||||
|
project: props.project.id,
|
||||||
|
ticket: props.ticket.id,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: {
|
||||||
|
branch_name: branchName,
|
||||||
|
repository_connection_id:
|
||||||
|
repositoryConnectionId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
{
|
||||||
|
credentials: 'same-origin',
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json',
|
||||||
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
|
},
|
||||||
|
method: 'GET',
|
||||||
|
signal: abortController.signal,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Branch validation failed.');
|
||||||
|
}
|
||||||
|
|
||||||
|
branchNameValidation.value =
|
||||||
|
(await response.json()) as BranchNameValidationModel;
|
||||||
|
} catch (error) {
|
||||||
|
if (
|
||||||
|
error instanceof DOMException &&
|
||||||
|
error.name === 'AbortError'
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
branchNameValidation.value = {
|
||||||
|
is_valid: false,
|
||||||
|
message: t('ticketDetail.branchValidationFailed', {
|
||||||
|
app: appName,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
} finally {
|
||||||
|
if (!abortController.signal.aborted) {
|
||||||
|
isCheckingBranchName.value = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
|
||||||
|
onCleanup(() => {
|
||||||
|
abortController.abort();
|
||||||
|
window.clearTimeout(timeoutId);
|
||||||
|
isCheckingBranchName.value = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
const submitBranchCreation = (): void => {
|
||||||
|
if (
|
||||||
|
!canCreateBranches.value ||
|
||||||
|
!selectedBranchRepositoryHasPersonalAccess.value ||
|
||||||
|
branchNameValidation.value?.is_valid !== true
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
branchProtection.submit(
|
||||||
|
ProjectTicketBranchController.store({
|
||||||
|
project: props.project.id,
|
||||||
|
ticket: props.ticket.id,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
onSuccess: () => {
|
||||||
|
isCreateBranchDialogOpen.value = false;
|
||||||
|
},
|
||||||
|
preserveScroll: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section
|
||||||
|
id="ticket-git"
|
||||||
|
aria-labelledby="ticket-git-title"
|
||||||
|
class="wrap-anywhere flex min-w-0 scroll-mt-6 flex-col gap-4"
|
||||||
|
>
|
||||||
|
<h2 id="ticket-git-title" class="text-lg font-semibold">
|
||||||
|
{{ t('ticketDetail.git') }}
|
||||||
|
</h2>
|
||||||
|
<div class="grid min-w-0 gap-6">
|
||||||
|
<Card class="h-fit">
|
||||||
|
<CardHeader
|
||||||
|
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
||||||
|
>
|
||||||
|
<div class="space-y-1.5">
|
||||||
|
<CardTitle>{{ t('ticketDetail.branches') }}</CardTitle>
|
||||||
|
<CardDescription>{{
|
||||||
|
t('ticketDetail.branchesDescription')
|
||||||
|
}}</CardDescription>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
:open="isCreateBranchDialogOpen"
|
||||||
|
@update:open="updateBranchDialogOpen"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
v-if="canCreateBranches"
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
class="gap-2"
|
||||||
|
@click="isCreateBranchDialogOpen = true"
|
||||||
|
>
|
||||||
|
<GitBranchPlus class="size-4" />{{
|
||||||
|
t('ticketDetail.createBranch')
|
||||||
|
}}</Button
|
||||||
|
>
|
||||||
|
|
||||||
|
<DialogContent class="sm:max-w-lg">
|
||||||
|
<DialogHeader class="space-y-3">
|
||||||
|
<DialogTitle>{{
|
||||||
|
t('ticketDetail.createBranchTitle')
|
||||||
|
}}</DialogTitle>
|
||||||
|
<DialogDescription>{{
|
||||||
|
t('ticketDetail.createBranchDescription')
|
||||||
|
}}</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
|
||||||
|
<form
|
||||||
|
class="grid gap-4"
|
||||||
|
@submit.prevent="submitBranchCreation"
|
||||||
|
>
|
||||||
|
<FormFeedback
|
||||||
|
:state="branchProtection.state.value"
|
||||||
|
@retry="submitBranchCreation"
|
||||||
|
/>
|
||||||
|
<div class="grid min-w-0 gap-2">
|
||||||
|
<Label for="repository_connection_id">{{
|
||||||
|
t('ticketDetail.repository')
|
||||||
|
}}</Label>
|
||||||
|
<select
|
||||||
|
id="repository_connection_id"
|
||||||
|
v-model="
|
||||||
|
branchCreationForm.repository_connection_id
|
||||||
|
"
|
||||||
|
:disabled="
|
||||||
|
branchCreationForm.processing
|
||||||
|
"
|
||||||
|
class="min-h-control border-input bg-background shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 w-full min-w-0 rounded-md border px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-60"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="repositoryConnection in linkedRepositoryConnections"
|
||||||
|
:key="repositoryConnection.id"
|
||||||
|
:value="
|
||||||
|
String(repositoryConnection.id)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
`${repositoryConnection.repository_full_name}${repositoryConnection.has_personal_access ? '' : ' (connect personal Git access)'}`
|
||||||
|
}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<InputError
|
||||||
|
:message="
|
||||||
|
branchCreationForm.errors
|
||||||
|
.repository_connection_id
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid min-w-0 gap-2">
|
||||||
|
<Label for="branch_name">{{
|
||||||
|
t('ticketDetail.branchName')
|
||||||
|
}}</Label>
|
||||||
|
<Input
|
||||||
|
id="branch_name"
|
||||||
|
v-model="branchCreationForm.branch_name"
|
||||||
|
:disabled="
|
||||||
|
branchCreationForm.processing ||
|
||||||
|
!selectedBranchRepositoryHasPersonalAccess
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<InputError
|
||||||
|
:message="
|
||||||
|
branchCreationForm.errors
|
||||||
|
.branch_name
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="rounded-xl border px-4 py-3"
|
||||||
|
:class="
|
||||||
|
branchNameValidation?.is_valid
|
||||||
|
? 'border-emerald-200 bg-emerald-50 text-emerald-900 dark:border-emerald-900/70 dark:bg-emerald-950/40 dark:text-emerald-100'
|
||||||
|
: 'border-amber-200 bg-amber-50 text-amber-900 dark:border-amber-900/70 dark:bg-amber-950/40 dark:text-amber-100'
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div class="flex items-start gap-3">
|
||||||
|
<CheckCircle2
|
||||||
|
v-if="
|
||||||
|
branchNameValidation?.is_valid
|
||||||
|
"
|
||||||
|
class="mt-0.5 size-4 shrink-0"
|
||||||
|
/>
|
||||||
|
<XCircle
|
||||||
|
v-else-if="
|
||||||
|
branchNameValidation !== null
|
||||||
|
"
|
||||||
|
class="mt-0.5 size-4 shrink-0"
|
||||||
|
/>
|
||||||
|
<p class="text-sm">
|
||||||
|
{{
|
||||||
|
isCheckingBranchName
|
||||||
|
? t(
|
||||||
|
'ticketDetail.checkingBranch',
|
||||||
|
)
|
||||||
|
: (branchNameValidation?.message ??
|
||||||
|
t(
|
||||||
|
'ticketDetail.selectRepository',
|
||||||
|
))
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
!selectedBranchRepositoryHasPersonalAccess &&
|
||||||
|
selectedBranchRepositoryConnection !==
|
||||||
|
null
|
||||||
|
"
|
||||||
|
class="border-border rounded-xl border border-dashed px-4 py-4"
|
||||||
|
>
|
||||||
|
<p class="text-muted-foreground text-sm">
|
||||||
|
{{ t('ticketDetail.branchAccess') }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
as-child
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
class="mt-3"
|
||||||
|
>
|
||||||
|
<Link :href="editGitConnections()">{{
|
||||||
|
t('ticketDetail.openGitConnections')
|
||||||
|
}}</Link>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DialogFooter class="gap-2">
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="secondary"
|
||||||
|
@click="updateBranchDialogOpen(false)"
|
||||||
|
>{{ t('common.cancel') }}</Button
|
||||||
|
>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
:disabled="
|
||||||
|
branchCreationForm.processing ||
|
||||||
|
isCheckingBranchName ||
|
||||||
|
branchNameValidation?.is_valid !==
|
||||||
|
true
|
||||||
|
"
|
||||||
|
>{{
|
||||||
|
t('ticketDetail.createNow')
|
||||||
|
}}</Button
|
||||||
|
>
|
||||||
|
</DialogFooter>
|
||||||
|
</form>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<CardContent class="space-y-4">
|
||||||
|
<FeedbackState
|
||||||
|
v-if="visibleRepositoryBranches.length === 0"
|
||||||
|
state="empty"
|
||||||
|
:title="t('tickets.noBranches')"
|
||||||
|
:description="t('tickets.noBranchesDescription')"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div v-else class="space-y-3">
|
||||||
|
<div
|
||||||
|
v-for="repositoryBranch in visibleRepositoryBranches"
|
||||||
|
:key="repositoryBranch.repository_connection.id"
|
||||||
|
class="border-border rounded-xl border px-4 py-4"
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<Badge variant="secondary">
|
||||||
|
{{
|
||||||
|
repositoryBranch.repository_connection
|
||||||
|
.provider_label
|
||||||
|
}}
|
||||||
|
</Badge>
|
||||||
|
<span class="font-medium">
|
||||||
|
{{
|
||||||
|
repositoryBranch.repository_connection
|
||||||
|
.repository_full_name
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-muted-foreground mt-2 text-sm">
|
||||||
|
{{
|
||||||
|
repositoryBranch.repository_connection
|
||||||
|
.base_url
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
!repositoryBranch.repository_connection
|
||||||
|
.has_personal_access
|
||||||
|
"
|
||||||
|
class="mt-3 space-y-3"
|
||||||
|
>
|
||||||
|
<p class="text-muted-foreground text-sm">
|
||||||
|
{{ t('ticketDetail.inspectBranches') }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<Button as-child variant="outline" size="sm">
|
||||||
|
<Link :href="editGitConnections()">{{
|
||||||
|
t('ticketDetail.openGitConnections')
|
||||||
|
}}</Link>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="repositoryBranch.error"
|
||||||
|
class="mt-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-900/70 dark:bg-amber-950/40 dark:text-amber-100"
|
||||||
|
>
|
||||||
|
{{ repositoryBranch.error }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="mt-3 flex flex-wrap gap-2">
|
||||||
|
<Badge
|
||||||
|
v-for="branch in repositoryBranch.branches"
|
||||||
|
:key="branch.name"
|
||||||
|
variant="outline"
|
||||||
|
class="px-3 py-1"
|
||||||
|
>
|
||||||
|
{{ branch.name }}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card class="h-fit">
|
||||||
|
<CardHeader>
|
||||||
|
<CardTitle>{{ t('ticketDetail.pullRequests') }}</CardTitle>
|
||||||
|
<CardDescription>{{
|
||||||
|
t('ticketDetail.pullRequestsDescription')
|
||||||
|
}}</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<CardContent class="space-y-4">
|
||||||
|
<FeedbackState
|
||||||
|
v-if="visibleRepositoryPullRequests.length === 0"
|
||||||
|
state="empty"
|
||||||
|
:title="t('tickets.noPullRequests')"
|
||||||
|
:description="t('tickets.noPullRequestsDescription')"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div v-else class="space-y-3">
|
||||||
|
<div
|
||||||
|
v-for="repositoryPullRequest in visibleRepositoryPullRequests"
|
||||||
|
:key="
|
||||||
|
repositoryPullRequest.repository_connection.id
|
||||||
|
"
|
||||||
|
class="border-border rounded-xl border px-4 py-4"
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<Badge variant="secondary">
|
||||||
|
{{
|
||||||
|
repositoryPullRequest
|
||||||
|
.repository_connection
|
||||||
|
.provider_label
|
||||||
|
}}
|
||||||
|
</Badge>
|
||||||
|
<span class="font-medium">
|
||||||
|
{{
|
||||||
|
repositoryPullRequest
|
||||||
|
.repository_connection
|
||||||
|
.repository_full_name
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-muted-foreground mt-2 text-sm">
|
||||||
|
{{
|
||||||
|
repositoryPullRequest.repository_connection
|
||||||
|
.base_url
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
!repositoryPullRequest.repository_connection
|
||||||
|
.has_personal_access
|
||||||
|
"
|
||||||
|
class="mt-3 space-y-3"
|
||||||
|
>
|
||||||
|
<p class="text-muted-foreground text-sm">
|
||||||
|
{{ t('ticketDetail.inspectPullRequests') }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<Button as-child variant="outline" size="sm">
|
||||||
|
<Link :href="editGitConnections()">{{
|
||||||
|
t('ticketDetail.openGitConnections')
|
||||||
|
}}</Link>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-else-if="repositoryPullRequest.error"
|
||||||
|
class="mt-3 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-900/70 dark:bg-amber-950/40 dark:text-amber-100"
|
||||||
|
>
|
||||||
|
{{ repositoryPullRequest.error }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="mt-3 space-y-3">
|
||||||
|
<div
|
||||||
|
v-for="pullRequest in repositoryPullRequest.pull_requests"
|
||||||
|
:key="pullRequest.html_url"
|
||||||
|
class="border-border/70 rounded-xl border px-4 py-3"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex flex-wrap items-center gap-2"
|
||||||
|
>
|
||||||
|
<Badge variant="outline">
|
||||||
|
#{{ pullRequest.number }}
|
||||||
|
</Badge>
|
||||||
|
<Badge variant="secondary">
|
||||||
|
{{ pullRequest.status }}
|
||||||
|
</Badge>
|
||||||
|
<a
|
||||||
|
:href="pullRequest.html_url"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
class="text-foreground hover:text-primary font-medium transition"
|
||||||
|
>
|
||||||
|
{{ pullRequest.title }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
class="text-muted-foreground mt-2 text-sm"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
t('ticketDetail.sourceBranch', {
|
||||||
|
name: pullRequest.source_branch,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Link } from '@inertiajs/vue3';
|
||||||
|
import { ArrowLeft, Columns3, ListTree } from 'lucide-vue-next';
|
||||||
|
import TicketMetadata from '@/components/tickets/TicketMetadata.vue';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { index as backlogIndex } from '@/routes/projects/backlog';
|
||||||
|
import { index as boardIndex } from '@/routes/projects/board';
|
||||||
|
import { show } from '@/routes/projects';
|
||||||
|
import type { TicketDetailHeaderProps } from '@/types/ticket-detail';
|
||||||
|
defineProps<TicketDetailHeaderProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const sections = [
|
||||||
|
'description',
|
||||||
|
'checklist',
|
||||||
|
'metadata',
|
||||||
|
'relationships',
|
||||||
|
'history',
|
||||||
|
'git',
|
||||||
|
] as const;
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<header class="flex min-w-0 flex-col gap-5">
|
||||||
|
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||||
|
<Button as-child variant="ghost" class="max-w-full"
|
||||||
|
><Link :href="show(project.id)"
|
||||||
|
><ArrowLeft aria-hidden="true" />{{
|
||||||
|
t('ticketDetail.backToProject')
|
||||||
|
}}</Link
|
||||||
|
></Button
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
|
<Button as-child variant="outline"
|
||||||
|
><Link :href="backlogIndex(project.id)"
|
||||||
|
><ListTree aria-hidden="true" />{{
|
||||||
|
t('ticketDetail.openBacklog')
|
||||||
|
}}</Link
|
||||||
|
></Button
|
||||||
|
>
|
||||||
|
<Button as-child variant="outline"
|
||||||
|
><Link :href="boardIndex(project.id)"
|
||||||
|
><Columns3 aria-hidden="true" />{{
|
||||||
|
t('ticketDetail.openBoard')
|
||||||
|
}}</Link
|
||||||
|
></Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex min-w-0 flex-col gap-3">
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<span class="text-primary font-mono text-sm font-semibold">{{
|
||||||
|
ticket.ticket_key
|
||||||
|
}}</span
|
||||||
|
><Badge v-if="!canEditTicket" variant="outline">{{
|
||||||
|
t('ticketDetail.readOnly')
|
||||||
|
}}</Badge>
|
||||||
|
</div>
|
||||||
|
<h1
|
||||||
|
class="wrap-anywhere text-2xl font-semibold leading-tight tracking-tight sm:text-3xl"
|
||||||
|
>
|
||||||
|
{{ ticket.title }}
|
||||||
|
</h1>
|
||||||
|
<TicketMetadata :ticket="ticket" />
|
||||||
|
</div>
|
||||||
|
<nav
|
||||||
|
:aria-label="t('ticketDetail.sections')"
|
||||||
|
class="flex flex-wrap gap-1 border-b pb-3"
|
||||||
|
>
|
||||||
|
<a
|
||||||
|
v-for="section in sections"
|
||||||
|
:key="section"
|
||||||
|
:href="`#ticket-${section}`"
|
||||||
|
class="min-h-control text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:ring-ring inline-flex items-center rounded-lg px-3 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
>{{ t(`ticketDetail.${section}`) }}</a
|
||||||
|
>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardDescription,
|
||||||
|
CardHeader,
|
||||||
|
} from '@/components/ui/card';
|
||||||
|
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import type { TicketDetailHistoryProps } from '@/types/ticket-detail';
|
||||||
|
defineProps<TicketDetailHistoryProps>();
|
||||||
|
const { t, date } = useLocalization();
|
||||||
|
const formatDateTime = (value: string): string =>
|
||||||
|
date(new Date(value), { dateStyle: 'medium', timeStyle: 'short' });
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section
|
||||||
|
id="ticket-history"
|
||||||
|
aria-labelledby="ticket-history-title"
|
||||||
|
class="wrap-anywhere min-w-0 scroll-mt-6"
|
||||||
|
>
|
||||||
|
<Card class="h-fit">
|
||||||
|
<CardHeader>
|
||||||
|
<h2 id="ticket-history-title" class="text-lg font-semibold">
|
||||||
|
{{ t('ticketDetail.history') }}
|
||||||
|
</h2>
|
||||||
|
<CardDescription>{{
|
||||||
|
t('ticketDetail.historyDescription')
|
||||||
|
}}</CardDescription>
|
||||||
|
</CardHeader>
|
||||||
|
|
||||||
|
<CardContent class="space-y-4">
|
||||||
|
<div
|
||||||
|
v-if="(ticket.worklog_entries?.length ?? 0) === 0"
|
||||||
|
class="border-border text-muted-foreground rounded-xl border border-dashed px-4 py-6 text-sm"
|
||||||
|
>
|
||||||
|
{{ t('ticketDetail.noHistory') }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else class="flex flex-col gap-4">
|
||||||
|
<div
|
||||||
|
v-for="worklogEntry in ticket.worklog_entries"
|
||||||
|
:key="worklogEntry.id"
|
||||||
|
class="border-border rounded-xl border px-4 py-4"
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<Badge variant="outline">
|
||||||
|
{{ worklogEntry.entry_type }}
|
||||||
|
</Badge>
|
||||||
|
<span class="text-foreground text-sm font-medium">
|
||||||
|
{{
|
||||||
|
worklogEntry.actor?.name ??
|
||||||
|
t('ticketDetail.system')
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p class="text-foreground mt-3 text-sm">
|
||||||
|
{{ worklogEntry.summary }}
|
||||||
|
</p>
|
||||||
|
<p class="text-muted-foreground mt-2 text-xs">
|
||||||
|
{{ formatDateTime(worklogEntry.created_at) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,165 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { UserAvatar } from '@/components/ui/avatar';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { ticketStatusLabel } from '@/lib/tickets';
|
||||||
|
import type { TicketDetailMetadataProps } from '@/types/ticket-detail';
|
||||||
|
const props = defineProps<TicketDetailMetadataProps>();
|
||||||
|
const { t, date, number } = useLocalization();
|
||||||
|
const fields = computed(() =>
|
||||||
|
props.ticketFieldDefinitions.map((definition) => {
|
||||||
|
const value = props.ticket.field_values?.find(
|
||||||
|
(field) => field.ticket_field_definition_id === definition.id,
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
id: definition.id,
|
||||||
|
label: definition.label,
|
||||||
|
value:
|
||||||
|
definition.field_type === 'user'
|
||||||
|
? (value?.user_value?.name ?? t('tickets.unassigned'))
|
||||||
|
: value?.value_number != null
|
||||||
|
? number(value.value_number)
|
||||||
|
: t('ticketDetail.notSet'),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<section
|
||||||
|
id="ticket-metadata"
|
||||||
|
aria-labelledby="ticket-metadata-title"
|
||||||
|
class="min-w-0 scroll-mt-6"
|
||||||
|
>
|
||||||
|
<Card class="bg-muted/30">
|
||||||
|
<CardHeader
|
||||||
|
><h2 id="ticket-metadata-title" class="text-lg font-semibold">
|
||||||
|
{{ t('ticketDetail.metadata') }}
|
||||||
|
</h2></CardHeader
|
||||||
|
>
|
||||||
|
<CardContent class="wrap-anywhere flex min-w-0 flex-col gap-6">
|
||||||
|
<dl
|
||||||
|
class="grid min-w-0 gap-5 text-sm sm:grid-cols-2 xl:grid-cols-1"
|
||||||
|
>
|
||||||
|
<div class="space-y-2">
|
||||||
|
<dt class="text-muted-foreground">
|
||||||
|
{{ t('ticketDetail.status') }}
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
{{
|
||||||
|
ticketStatusLabel(
|
||||||
|
ticket.ticket_status,
|
||||||
|
t('tickets.noStatus'),
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-2">
|
||||||
|
<dt class="text-muted-foreground">
|
||||||
|
{{ t('ticketDetail.type') }}
|
||||||
|
</dt>
|
||||||
|
<dd>{{ ticket.ticket_type.name }}</dd>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-2">
|
||||||
|
<dt class="text-muted-foreground">
|
||||||
|
{{ t('ticketDetail.priority') }}
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<Badge variant="outline">{{
|
||||||
|
ticket.ticket_priority.name
|
||||||
|
}}</Badge>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-2">
|
||||||
|
<dt class="text-muted-foreground">
|
||||||
|
{{ t('ticketDetail.assignee') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="flex items-center gap-2">
|
||||||
|
<UserAvatar
|
||||||
|
v-if="ticket.assignee"
|
||||||
|
:user="ticket.assignee"
|
||||||
|
size="sm"
|
||||||
|
/>{{
|
||||||
|
ticket.assignee?.name ?? t('tickets.unassigned')
|
||||||
|
}}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="project.show_author || canManageProject"
|
||||||
|
class="space-y-2"
|
||||||
|
>
|
||||||
|
<dt class="text-muted-foreground">
|
||||||
|
{{ t('ticketDetail.author') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="flex items-center gap-2">
|
||||||
|
<UserAvatar
|
||||||
|
v-if="ticket.author"
|
||||||
|
:user="ticket.author"
|
||||||
|
size="sm"
|
||||||
|
/>{{
|
||||||
|
ticket.author?.name ??
|
||||||
|
t('ticketDetail.noAuthor')
|
||||||
|
}}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div v-if="project.show_story_points" class="space-y-2">
|
||||||
|
<dt class="text-muted-foreground">
|
||||||
|
{{ t('ticketDetail.storyPoints') }}
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
{{
|
||||||
|
ticket.story_points != null
|
||||||
|
? number(ticket.story_points)
|
||||||
|
: t('ticketDetail.notSet')
|
||||||
|
}}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-for="field in fields"
|
||||||
|
:key="field.id"
|
||||||
|
class="space-y-2"
|
||||||
|
>
|
||||||
|
<dt class="text-muted-foreground">{{ field.label }}</dt>
|
||||||
|
<dd>{{ field.value }}</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
<div
|
||||||
|
v-if="ticket.is_blocked"
|
||||||
|
class="border-warning/30 bg-warning/10 space-y-2 rounded-lg border p-4 text-sm"
|
||||||
|
>
|
||||||
|
<p class="font-semibold">{{ t('tickets.blocked') }}</p>
|
||||||
|
<p class="whitespace-pre-wrap">
|
||||||
|
{{ ticket.blocked_comment }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<dl
|
||||||
|
class="text-muted-foreground grid gap-4 border-t pt-5 text-xs"
|
||||||
|
>
|
||||||
|
<div class="space-y-1">
|
||||||
|
<dt>{{ t('ticketDetail.created') }}</dt>
|
||||||
|
<dd>
|
||||||
|
<time :datetime="ticket.created_at">{{
|
||||||
|
date(new Date(ticket.created_at), {
|
||||||
|
dateStyle: 'medium',
|
||||||
|
timeStyle: 'short',
|
||||||
|
})
|
||||||
|
}}</time>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="space-y-1">
|
||||||
|
<dt>{{ t('ticketDetail.updated') }}</dt>
|
||||||
|
<dd>
|
||||||
|
<time :datetime="ticket.updated_at">{{
|
||||||
|
date(new Date(ticket.updated_at), {
|
||||||
|
dateStyle: 'medium',
|
||||||
|
timeStyle: 'short',
|
||||||
|
})
|
||||||
|
}}</time>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,305 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Link, useForm } from '@inertiajs/vue3';
|
||||||
|
import { ArrowRight, GitFork, Link2, Plus } from 'lucide-vue-next';
|
||||||
|
import { computed, nextTick, useTemplateRef } from 'vue';
|
||||||
|
import { store } from '@/actions/App/Http/Controllers/ProjectTicketLinkController';
|
||||||
|
import FormFeedback from '@/components/FormFeedback.vue';
|
||||||
|
import TicketTreeList from '@/components/TicketTreeList.vue';
|
||||||
|
import TicketFormField from '@/components/tickets/TicketFormField.vue';
|
||||||
|
import TicketRelationshipLink from '@/components/tickets/detail/TicketRelationshipLink.vue';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||||
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { show as showTicket } from '@/routes/projects/tickets';
|
||||||
|
import type { TicketDetailRelationshipsProps } from '@/types/ticket-detail';
|
||||||
|
|
||||||
|
const props = defineProps<TicketDetailRelationshipsProps>();
|
||||||
|
defineEmits<{ editParent: [] }>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const linksHeading = useTemplateRef<HTMLHeadingElement>('linksHeading');
|
||||||
|
const currentParentTicket = computed(
|
||||||
|
() =>
|
||||||
|
props.ticket.parent_ticket ??
|
||||||
|
props.parentTicketOptions.find(
|
||||||
|
(parent) => parent.id === props.ticket.parent_ticket_id,
|
||||||
|
) ??
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
const canAddLink = computed(
|
||||||
|
() =>
|
||||||
|
props.canEditTicket &&
|
||||||
|
props.ticketLinkTypes.length > 0 &&
|
||||||
|
props.ticketLinkOptions.length > 0,
|
||||||
|
);
|
||||||
|
const form = useForm({
|
||||||
|
ticket_link_type_id: props.ticketLinkTypes[0]?.id ?? '',
|
||||||
|
linked_ticket_id: '',
|
||||||
|
});
|
||||||
|
const protection = useFormProtection(form, {
|
||||||
|
isDirty: () => props.canEditTicket && form.isDirty,
|
||||||
|
});
|
||||||
|
const selectedType = computed(() =>
|
||||||
|
props.ticketLinkTypes.find(
|
||||||
|
(type) => String(type.id) === String(form.ticket_link_type_id),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const selectedTicket = computed(() =>
|
||||||
|
props.ticketLinkOptions.find(
|
||||||
|
(ticket) => String(ticket.id) === String(form.linked_ticket_id),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
async function focusLinks(): Promise<void> {
|
||||||
|
await nextTick();
|
||||||
|
linksHeading.value?.focus();
|
||||||
|
}
|
||||||
|
function submit(): void {
|
||||||
|
if (!canAddLink.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
protection.submit(
|
||||||
|
store({ project: props.project.id, ticket: props.ticket.id }),
|
||||||
|
{
|
||||||
|
preserveScroll: true,
|
||||||
|
onSuccess: () => {
|
||||||
|
form.linked_ticket_id = '';
|
||||||
|
form.clearErrors();
|
||||||
|
void focusLinks();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<section
|
||||||
|
id="ticket-relationships"
|
||||||
|
aria-labelledby="ticket-relationships-title"
|
||||||
|
class="wrap-anywhere flex min-w-0 scroll-mt-6 flex-col gap-4"
|
||||||
|
>
|
||||||
|
<h2 id="ticket-relationships-title" class="text-lg font-semibold">
|
||||||
|
{{ t('ticketDetail.relationships') }}
|
||||||
|
</h2>
|
||||||
|
<Card class="min-w-0 gap-5 overflow-hidden">
|
||||||
|
<CardHeader
|
||||||
|
class="flex flex-wrap items-center justify-between gap-3"
|
||||||
|
>
|
||||||
|
<h3 class="flex items-center gap-2 font-semibold">
|
||||||
|
<GitFork class="text-primary size-5" aria-hidden="true" />{{
|
||||||
|
t('ticketRelationships.hierarchy')
|
||||||
|
}}
|
||||||
|
</h3>
|
||||||
|
<Button
|
||||||
|
v-if="canEditTicket"
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
@click="$emit('editParent')"
|
||||||
|
>{{ t('ticketRelationships.editParent') }}</Button
|
||||||
|
>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent class="grid min-w-0 gap-5">
|
||||||
|
<div class="grid min-w-0 gap-2">
|
||||||
|
<h4
|
||||||
|
class="text-muted-foreground text-xs font-semibold uppercase tracking-wide"
|
||||||
|
>
|
||||||
|
{{ t('ticketDetail.parent') }}
|
||||||
|
</h4>
|
||||||
|
<Link
|
||||||
|
v-if="currentParentTicket"
|
||||||
|
:href="
|
||||||
|
showTicket({
|
||||||
|
project: project.id,
|
||||||
|
ticket: currentParentTicket.id,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
class="border-primary/20 bg-primary/5 hover:border-primary focus-visible:ring-ring/35 group grid min-w-0 gap-2 rounded-xl border p-4 outline-none transition-colors focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="text-primary font-mono text-xs font-semibold"
|
||||||
|
>{{ currentParentTicket.ticket_key }}</span
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="group-hover:text-primary text-sm font-medium"
|
||||||
|
>{{ currentParentTicket.title }}</span
|
||||||
|
>
|
||||||
|
</Link>
|
||||||
|
<p
|
||||||
|
v-else
|
||||||
|
class="text-muted-foreground rounded-xl border border-dashed p-4 text-sm"
|
||||||
|
>
|
||||||
|
{{ t('ticketDetail.noParent') }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-if="canEditTicket"
|
||||||
|
class="text-muted-foreground text-xs"
|
||||||
|
>
|
||||||
|
{{ t('ticketRelationships.parentHelp') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="ticket.ticket_type?.is_parent"
|
||||||
|
class="grid min-w-0 gap-3 border-t pt-5"
|
||||||
|
>
|
||||||
|
<div class="flex flex-wrap items-center gap-2">
|
||||||
|
<h4 class="text-sm font-semibold">
|
||||||
|
{{ t('ticketDetail.children') }}
|
||||||
|
</h4>
|
||||||
|
<Badge variant="secondary">{{
|
||||||
|
childTicketTree.length
|
||||||
|
}}</Badge>
|
||||||
|
</div>
|
||||||
|
<p class="text-muted-foreground text-xs">
|
||||||
|
{{ t('ticketRelationships.childrenHelp') }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-if="childTicketTree.length === 0"
|
||||||
|
class="text-muted-foreground rounded-xl border border-dashed p-4 text-sm"
|
||||||
|
>
|
||||||
|
{{ t('ticketDetail.noChildren') }}
|
||||||
|
</p>
|
||||||
|
<TicketTreeList
|
||||||
|
v-else
|
||||||
|
:nodes="childTicketTree"
|
||||||
|
:project-id="project.id"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
<Card class="min-w-0 gap-5 overflow-hidden">
|
||||||
|
<CardHeader>
|
||||||
|
<h3
|
||||||
|
ref="linksHeading"
|
||||||
|
tabindex="-1"
|
||||||
|
class="focus-visible:ring-ring/35 flex flex-wrap items-center gap-2 rounded-md font-semibold outline-none focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<Link2 class="text-primary size-5" aria-hidden="true" />{{
|
||||||
|
t('ticketDetail.linkedTickets')
|
||||||
|
}}<Badge variant="secondary">{{
|
||||||
|
linkedTickets.length
|
||||||
|
}}</Badge>
|
||||||
|
</h3>
|
||||||
|
<p class="text-muted-foreground text-sm">
|
||||||
|
{{ t('ticketDetail.linkedTicketsDescription') }}
|
||||||
|
</p>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent class="grid min-w-0 gap-5">
|
||||||
|
<p
|
||||||
|
v-if="linkedTickets.length === 0"
|
||||||
|
class="text-muted-foreground rounded-xl border border-dashed p-4 text-sm"
|
||||||
|
>
|
||||||
|
{{ t('ticketDetail.noLinks') }}
|
||||||
|
</p>
|
||||||
|
<ul v-else class="grid min-w-0 gap-3">
|
||||||
|
<TicketRelationshipLink
|
||||||
|
v-for="link in linkedTickets"
|
||||||
|
:key="link.id"
|
||||||
|
:link="link"
|
||||||
|
:project-id="project.id"
|
||||||
|
:ticket-id="ticket.id"
|
||||||
|
:ticket-key="ticket.ticket_key"
|
||||||
|
:can-edit="canEditTicket"
|
||||||
|
@removed="focusLinks"
|
||||||
|
/>
|
||||||
|
</ul>
|
||||||
|
<form
|
||||||
|
v-if="canAddLink"
|
||||||
|
class="bg-muted/30 grid min-w-0 gap-4 rounded-xl border p-4"
|
||||||
|
@submit.prevent="submit"
|
||||||
|
>
|
||||||
|
<h4 class="flex items-center gap-2 text-sm font-semibold">
|
||||||
|
<Plus class="size-4" aria-hidden="true" />{{
|
||||||
|
t('ticketRelationships.addLink')
|
||||||
|
}}
|
||||||
|
</h4>
|
||||||
|
<FormFeedback
|
||||||
|
:state="protection.state.value"
|
||||||
|
@retry="submit"
|
||||||
|
/>
|
||||||
|
<fieldset
|
||||||
|
:disabled="form.processing"
|
||||||
|
class="grid min-w-0 gap-4 sm:grid-cols-[minmax(0,1fr)_minmax(0,2fr)]"
|
||||||
|
>
|
||||||
|
<TicketFormField
|
||||||
|
id="ticket_link_type_id"
|
||||||
|
v-model="form.ticket_link_type_id"
|
||||||
|
kind="select"
|
||||||
|
:label="t('ticketDetail.linkType')"
|
||||||
|
:options="
|
||||||
|
ticketLinkTypes.map((type) => ({
|
||||||
|
value: type.id,
|
||||||
|
label: type.label,
|
||||||
|
}))
|
||||||
|
"
|
||||||
|
:error="form.errors.ticket_link_type_id"
|
||||||
|
:disabled="form.processing"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<TicketFormField
|
||||||
|
id="linked_ticket_id"
|
||||||
|
v-model="form.linked_ticket_id"
|
||||||
|
kind="select"
|
||||||
|
:label="t('ticketDetail.linkedTicket')"
|
||||||
|
:options="[
|
||||||
|
{
|
||||||
|
value: '',
|
||||||
|
label: t(
|
||||||
|
'ticketRelationships.selectTicket',
|
||||||
|
),
|
||||||
|
},
|
||||||
|
...ticketLinkOptions.map((ticket) => ({
|
||||||
|
value: ticket.id,
|
||||||
|
label: `${ticket.ticket_key} — ${ticket.title}`,
|
||||||
|
})),
|
||||||
|
]"
|
||||||
|
:error="form.errors.linked_ticket_id"
|
||||||
|
:disabled="form.processing"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
|
<p
|
||||||
|
v-if="selectedType && selectedTicket"
|
||||||
|
aria-live="polite"
|
||||||
|
class="text-muted-foreground flex flex-wrap items-center gap-2 text-sm"
|
||||||
|
>
|
||||||
|
<span class="font-mono text-xs">{{
|
||||||
|
ticket.ticket_key
|
||||||
|
}}</span
|
||||||
|
><span>{{ selectedType.label }}</span
|
||||||
|
><ArrowRight class="size-4" aria-hidden="true" /><span
|
||||||
|
class="font-mono text-xs"
|
||||||
|
>{{ selectedTicket.ticket_key }}</span
|
||||||
|
>
|
||||||
|
</p>
|
||||||
|
<p class="text-muted-foreground text-xs">
|
||||||
|
{{ t('ticketRelationships.directionHelp') }}
|
||||||
|
</p>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
:disabled="form.processing || !selectedTicket"
|
||||||
|
class="sm:justify-self-start"
|
||||||
|
>{{
|
||||||
|
form.processing
|
||||||
|
? t('forms.saving')
|
||||||
|
: t('ticketDetail.saveLink')
|
||||||
|
}}</Button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<p
|
||||||
|
v-else-if="canEditTicket"
|
||||||
|
class="text-muted-foreground text-sm"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
t(
|
||||||
|
ticketLinkTypes.length === 0
|
||||||
|
? 'ticketRelationships.noTypes'
|
||||||
|
: 'ticketRelationships.noTargets',
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { Link, useForm } from '@inertiajs/vue3';
|
||||||
|
import { ArrowDownLeft, ArrowUpRight, Unlink } from 'lucide-vue-next';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import { destroy } from '@/actions/App/Http/Controllers/ProjectTicketLinkController';
|
||||||
|
import FormFeedback from '@/components/FormFeedback.vue';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import { show } from '@/routes/projects/tickets';
|
||||||
|
import type { TicketLinkModel } from '@/types/models/ticket-link-model';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
link: TicketLinkModel;
|
||||||
|
projectId: number;
|
||||||
|
ticketId: number;
|
||||||
|
ticketKey: string;
|
||||||
|
canEdit: boolean;
|
||||||
|
}>();
|
||||||
|
const emit = defineEmits<{ removed: [] }>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const outgoing = computed(() => props.link.source_ticket_id === props.ticketId);
|
||||||
|
const form = useForm({});
|
||||||
|
const protection = useFormProtection(form);
|
||||||
|
function remove(): void {
|
||||||
|
if (!props.canEdit) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
protection.submit(
|
||||||
|
destroy({
|
||||||
|
project: props.projectId,
|
||||||
|
ticket: props.ticketId,
|
||||||
|
ticketLink: props.link.id,
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
preserveScroll: true,
|
||||||
|
onSuccess: () => emit('removed'),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<li
|
||||||
|
class="grid min-w-0 gap-3 rounded-xl border p-4"
|
||||||
|
:data-ticket-link="link.id"
|
||||||
|
>
|
||||||
|
<div class="flex min-w-0 flex-wrap items-center gap-2">
|
||||||
|
<Badge
|
||||||
|
variant="outline"
|
||||||
|
class="text-muted-foreground max-w-full whitespace-normal"
|
||||||
|
>
|
||||||
|
<ArrowUpRight
|
||||||
|
v-if="outgoing"
|
||||||
|
class="size-3.5 shrink-0"
|
||||||
|
aria-hidden="true"
|
||||||
|
/><ArrowDownLeft
|
||||||
|
v-else
|
||||||
|
class="size-3.5 shrink-0"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
{{
|
||||||
|
t(
|
||||||
|
outgoing
|
||||||
|
? 'ticketRelationships.outgoing'
|
||||||
|
: 'ticketRelationships.incoming',
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</Badge>
|
||||||
|
<span class="text-muted-foreground font-mono text-xs">{{
|
||||||
|
ticketKey
|
||||||
|
}}</span>
|
||||||
|
<span class="text-sm font-medium">{{
|
||||||
|
link.ticket_link_type.label
|
||||||
|
}}</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex min-w-0 flex-wrap items-start justify-between gap-3">
|
||||||
|
<Link
|
||||||
|
:href="
|
||||||
|
show({ project: projectId, ticket: link.linked_ticket.id })
|
||||||
|
"
|
||||||
|
class="hover:text-primary focus-visible:ring-ring/35 grid min-w-0 flex-1 basis-40 gap-1 rounded-md outline-none transition-colors focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<span class="text-primary font-mono text-xs font-semibold">{{
|
||||||
|
link.linked_ticket.ticket_key
|
||||||
|
}}</span>
|
||||||
|
<span class="wrap-anywhere text-sm font-medium">{{
|
||||||
|
link.linked_ticket.title
|
||||||
|
}}</span>
|
||||||
|
</Link>
|
||||||
|
<form v-if="canEdit" @submit.prevent="remove">
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
class="text-muted-foreground hover:text-destructive"
|
||||||
|
:aria-label="
|
||||||
|
t('ticketRelationships.removeLink', {
|
||||||
|
key: link.linked_ticket.ticket_key,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
:disabled="form.processing"
|
||||||
|
><Unlink class="size-4" aria-hidden="true" />{{
|
||||||
|
t('ticketDetail.removeLink')
|
||||||
|
}}</Button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<FormFeedback
|
||||||
|
v-if="canEdit"
|
||||||
|
:state="protection.state.value"
|
||||||
|
@retry="remove"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export { default as TicketCard } from './TicketCard.vue';
|
||||||
|
export { default as TicketListItem } from './TicketListItem.vue';
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
import { computed, onMounted, onUnmounted, ref, shallowRef } from 'vue';
|
||||||
|
import type { TicketModel } from '@/types/models/ticket-model';
|
||||||
|
|
||||||
|
/** Pointer capture keeps mouse, pen and touch drags on the same code path. */
|
||||||
|
export function useBoardDrag(options: {
|
||||||
|
canStart: (ticket: TicketModel) => boolean;
|
||||||
|
drop: (ticket: TicketModel, columnId: number) => void;
|
||||||
|
}) {
|
||||||
|
const ticket = shallowRef<TicketModel | null>(null);
|
||||||
|
const active = ref(false);
|
||||||
|
const x = ref(0);
|
||||||
|
const y = ref(0);
|
||||||
|
const columnId = ref<number | null>(null);
|
||||||
|
let pointerId: number | null = null;
|
||||||
|
let handle: HTMLElement | null = null;
|
||||||
|
let startX = 0;
|
||||||
|
let startY = 0;
|
||||||
|
let frame = 0;
|
||||||
|
|
||||||
|
const draggedTicket = computed(() => (active.value ? ticket.value : null));
|
||||||
|
|
||||||
|
function locateTarget(): void {
|
||||||
|
const target = document
|
||||||
|
.elementFromPoint(x.value, y.value)
|
||||||
|
?.closest<HTMLElement>('[data-board-drop-column]');
|
||||||
|
columnId.value = target ? Number(target.dataset.boardDropColumn) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function scroll(): void {
|
||||||
|
if (!active.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const element = document.elementFromPoint(x.value, y.value);
|
||||||
|
const region = element?.closest<HTMLElement>(
|
||||||
|
'[data-board-drag-scroll]',
|
||||||
|
);
|
||||||
|
if (region) {
|
||||||
|
const bounds = region.getBoundingClientRect();
|
||||||
|
const left = Math.max(0, bounds.left);
|
||||||
|
const right = Math.min(window.innerWidth, bounds.right);
|
||||||
|
const delta =
|
||||||
|
x.value < left + 44 ? -10 : x.value > right - 44 ? 10 : 0;
|
||||||
|
region.scrollLeft += delta;
|
||||||
|
}
|
||||||
|
if (!element?.closest('[data-board-mobile-targets]')) {
|
||||||
|
const delta =
|
||||||
|
y.value < 64 ? -10 : y.value > window.innerHeight - 64 ? 10 : 0;
|
||||||
|
window.scrollBy(0, delta);
|
||||||
|
}
|
||||||
|
locateTarget();
|
||||||
|
frame = requestAnimationFrame(scroll);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancel(): void {
|
||||||
|
const previousPointer = pointerId;
|
||||||
|
pointerId = null;
|
||||||
|
active.value = false;
|
||||||
|
ticket.value = null;
|
||||||
|
columnId.value = null;
|
||||||
|
cancelAnimationFrame(frame);
|
||||||
|
if (
|
||||||
|
previousPointer !== null &&
|
||||||
|
handle?.hasPointerCapture(previousPointer)
|
||||||
|
) {
|
||||||
|
handle.releasePointerCapture(previousPointer);
|
||||||
|
}
|
||||||
|
handle = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function start(event: PointerEvent, source: TicketModel): void {
|
||||||
|
if (
|
||||||
|
pointerId !== null ||
|
||||||
|
!event.isPrimary ||
|
||||||
|
event.button !== 0 ||
|
||||||
|
!options.canStart(source)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handle = event.currentTarget as HTMLElement;
|
||||||
|
handle.focus({ preventScroll: true });
|
||||||
|
handle.setPointerCapture(event.pointerId);
|
||||||
|
pointerId = event.pointerId;
|
||||||
|
ticket.value = source;
|
||||||
|
startX = x.value = event.clientX;
|
||||||
|
startY = y.value = event.clientY;
|
||||||
|
}
|
||||||
|
|
||||||
|
function move(event: PointerEvent): void {
|
||||||
|
if (event.pointerId !== pointerId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
x.value = event.clientX;
|
||||||
|
y.value = event.clientY;
|
||||||
|
if (
|
||||||
|
!active.value &&
|
||||||
|
Math.hypot(x.value - startX, y.value - startY) >= 6
|
||||||
|
) {
|
||||||
|
active.value = true;
|
||||||
|
frame = requestAnimationFrame(scroll);
|
||||||
|
}
|
||||||
|
if (active.value) {
|
||||||
|
event.preventDefault();
|
||||||
|
locateTarget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function finish(event: PointerEvent): void {
|
||||||
|
if (event.pointerId !== pointerId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
x.value = event.clientX;
|
||||||
|
y.value = event.clientY;
|
||||||
|
locateTarget();
|
||||||
|
const source = draggedTicket.value;
|
||||||
|
const target = columnId.value;
|
||||||
|
cancel();
|
||||||
|
if (source && target !== null) {
|
||||||
|
options.drop(source, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelPointer(event: PointerEvent): void {
|
||||||
|
if (event.pointerId === pointerId) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function keydown(event: KeyboardEvent): void {
|
||||||
|
if (event.key === 'Escape' && pointerId !== null) {
|
||||||
|
event.preventDefault();
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
document.addEventListener('pointermove', move, { passive: false });
|
||||||
|
document.addEventListener('pointerup', finish);
|
||||||
|
document.addEventListener('pointercancel', cancelPointer);
|
||||||
|
document.addEventListener('lostpointercapture', cancelPointer);
|
||||||
|
document.addEventListener('keydown', keydown);
|
||||||
|
window.addEventListener('blur', cancel);
|
||||||
|
});
|
||||||
|
onUnmounted(() => {
|
||||||
|
cancel();
|
||||||
|
document.removeEventListener('pointermove', move);
|
||||||
|
document.removeEventListener('pointerup', finish);
|
||||||
|
document.removeEventListener('pointercancel', cancelPointer);
|
||||||
|
document.removeEventListener('lostpointercapture', cancelPointer);
|
||||||
|
document.removeEventListener('keydown', keydown);
|
||||||
|
window.removeEventListener('blur', cancel);
|
||||||
|
});
|
||||||
|
|
||||||
|
return { draggedTicket, columnId, x, y, start, cancel };
|
||||||
|
}
|
||||||
@@ -5,6 +5,76 @@ import type {
|
|||||||
|
|
||||||
const MAX_INDENT_LEVEL = 8;
|
const MAX_INDENT_LEVEL = 8;
|
||||||
|
|
||||||
|
export const canIndentAcceptanceCriterion = (
|
||||||
|
items: AcceptanceCriteriaModel,
|
||||||
|
index: number,
|
||||||
|
): boolean => {
|
||||||
|
const item = items[index];
|
||||||
|
const previous = items[index - 1];
|
||||||
|
if (!item || !previous || item.indent > previous.indent) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return items
|
||||||
|
.slice(index, acceptanceCriteriaSubtreeEnd(items, index))
|
||||||
|
.every((descendant) => descendant.indent < MAX_INDENT_LEVEL);
|
||||||
|
};
|
||||||
|
|
||||||
|
const acceptanceCriteriaSubtreeEnd = (
|
||||||
|
items: AcceptanceCriteriaModel,
|
||||||
|
index: number,
|
||||||
|
): number => {
|
||||||
|
let end = index + 1;
|
||||||
|
while (end < items.length && items[end].indent > items[index].indent) {
|
||||||
|
end++;
|
||||||
|
}
|
||||||
|
return end;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const indentAcceptanceCriterion = (
|
||||||
|
items: AcceptanceCriteriaModel,
|
||||||
|
index: number,
|
||||||
|
direction: 1 | -1,
|
||||||
|
): AcceptanceCriteriaModel => {
|
||||||
|
if (
|
||||||
|
!items[index] ||
|
||||||
|
(direction === 1
|
||||||
|
? !canIndentAcceptanceCriterion(items, index)
|
||||||
|
: items[index].indent === 0)
|
||||||
|
) {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
const end = acceptanceCriteriaSubtreeEnd(items, index);
|
||||||
|
return items.map((item, position) =>
|
||||||
|
position >= index && position < end
|
||||||
|
? { ...item, indent: item.indent + direction }
|
||||||
|
: item,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Remove only the selected criterion, promoting its children without losing them. */
|
||||||
|
export const removeAcceptanceCriterion = (
|
||||||
|
items: AcceptanceCriteriaModel,
|
||||||
|
index: number,
|
||||||
|
): AcceptanceCriteriaModel => {
|
||||||
|
if (!items[index]) {
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
const end = acceptanceCriteriaSubtreeEnd(items, index);
|
||||||
|
return items.flatMap((item, position) =>
|
||||||
|
position === index
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
...item,
|
||||||
|
indent:
|
||||||
|
position > index && position < end
|
||||||
|
? item.indent - 1
|
||||||
|
: item.indent,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export type AcceptanceCriteriaEditorState = {
|
export type AcceptanceCriteriaEditorState = {
|
||||||
checklist: string;
|
checklist: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
import type {
|
||||||
|
BacklogFilterState,
|
||||||
|
BacklogTicketTreeNode,
|
||||||
|
} from '@/types/backlog';
|
||||||
|
import type { TicketModel } from '@/types/models/ticket-model';
|
||||||
|
|
||||||
|
export function buildBacklogTicketTree(
|
||||||
|
tickets: TicketModel[],
|
||||||
|
): BacklogTicketTreeNode[] {
|
||||||
|
const nodesByTicketId = new Map<number, BacklogTicketTreeNode>();
|
||||||
|
|
||||||
|
for (const ticket of tickets) {
|
||||||
|
nodesByTicketId.set(ticket.id, {
|
||||||
|
children: [],
|
||||||
|
matchesFilters: true,
|
||||||
|
ticket,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const roots: BacklogTicketTreeNode[] = [];
|
||||||
|
|
||||||
|
for (const ticket of tickets) {
|
||||||
|
const node = nodesByTicketId.get(ticket.id);
|
||||||
|
|
||||||
|
if (!node) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const parentNode =
|
||||||
|
ticket.parent_ticket_id === null
|
||||||
|
? undefined
|
||||||
|
: nodesByTicketId.get(ticket.parent_ticket_id);
|
||||||
|
|
||||||
|
if (parentNode) {
|
||||||
|
parentNode.children.push(node);
|
||||||
|
} else {
|
||||||
|
roots.push(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return roots;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function filterBacklogTicketTree(
|
||||||
|
nodes: BacklogTicketTreeNode[],
|
||||||
|
filters: BacklogFilterState,
|
||||||
|
): BacklogTicketTreeNode[] {
|
||||||
|
return nodes.flatMap((node) => {
|
||||||
|
const children = filterBacklogTicketTree(node.children, filters);
|
||||||
|
const matchesFilters = ticketMatchesFilters(node.ticket, filters);
|
||||||
|
|
||||||
|
if (!matchesFilters && children.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
...node,
|
||||||
|
children,
|
||||||
|
matchesFilters,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function countBacklogTreeTickets(
|
||||||
|
nodes: BacklogTicketTreeNode[],
|
||||||
|
): number {
|
||||||
|
return nodes.reduce(
|
||||||
|
(count, node) => count + 1 + countBacklogTreeTickets(node.children),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function expandableBacklogTicketIds(
|
||||||
|
nodes: BacklogTicketTreeNode[],
|
||||||
|
): number[] {
|
||||||
|
return nodes.flatMap((node) => [
|
||||||
|
...(node.children.length > 0 ? [node.ticket.id] : []),
|
||||||
|
...expandableBacklogTicketIds(node.children),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ticketMatchesFilters(
|
||||||
|
ticket: TicketModel,
|
||||||
|
filters: BacklogFilterState,
|
||||||
|
): boolean {
|
||||||
|
const query = filters.query.trim().toLocaleLowerCase();
|
||||||
|
const searchableText = [
|
||||||
|
ticket.ticket_key,
|
||||||
|
ticket.title,
|
||||||
|
ticket.description,
|
||||||
|
ticket.ticket_type.name,
|
||||||
|
ticket.ticket_priority.name,
|
||||||
|
ticket.ticket_status?.name,
|
||||||
|
ticket.assignee?.name,
|
||||||
|
]
|
||||||
|
.filter((value): value is string => Boolean(value))
|
||||||
|
.join(' ')
|
||||||
|
.toLocaleLowerCase();
|
||||||
|
|
||||||
|
return (
|
||||||
|
(query === '' || searchableText.includes(query)) &&
|
||||||
|
(filters.typeId === '' || ticket.ticket_type_id === filters.typeId) &&
|
||||||
|
(filters.priorityId === '' ||
|
||||||
|
ticket.ticket_priority_id === filters.priorityId) &&
|
||||||
|
(filters.statusId === '' ||
|
||||||
|
ticket.ticket_status_id === filters.statusId) &&
|
||||||
|
(filters.assigneeId === '' ||
|
||||||
|
(filters.assigneeId === 'unassigned'
|
||||||
|
? ticket.assignee_user_id === null
|
||||||
|
: ticket.assignee_user_id === filters.assigneeId))
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import type { TicketStatusModel } from '@/types/models/ticket-status-model';
|
||||||
|
|
||||||
|
export function ticketStatusLabel(
|
||||||
|
ticketStatus: TicketStatusModel | null,
|
||||||
|
fallback: string,
|
||||||
|
): string {
|
||||||
|
if (ticketStatus === null) {
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
ticketStatus.board_column === null ||
|
||||||
|
ticketStatus.board_column === undefined ||
|
||||||
|
ticketStatus.board_column.name === ticketStatus.name
|
||||||
|
) {
|
||||||
|
return ticketStatus.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${ticketStatus.board_column.name} / ${ticketStatus.name}`;
|
||||||
|
}
|
||||||
@@ -1,4 +1,226 @@
|
|||||||
export const en = {
|
export const en = {
|
||||||
|
'criteria.title': 'Acceptance criteria',
|
||||||
|
'criteria.progress': '{completed} of {total} complete',
|
||||||
|
'criteria.empty': 'No acceptance criteria yet.',
|
||||||
|
'criteria.required': 'Enter a criterion or remove this row.',
|
||||||
|
'criteria.edit': 'Edit checklist',
|
||||||
|
'criteria.preview': 'Preview checklist',
|
||||||
|
'criteria.item': 'Criterion {number}',
|
||||||
|
'criteria.complete': 'Complete criterion {number}: {text}',
|
||||||
|
'criteria.indent': 'Indent criterion {number}',
|
||||||
|
'criteria.outdent': 'Outdent criterion {number}',
|
||||||
|
'criteria.remove': 'Remove criterion {number}',
|
||||||
|
'criteria.add': 'Add criterion',
|
||||||
|
'criteria.hint':
|
||||||
|
'Use the indent buttons or Alt + Left/Right in a text field to nest criteria. Checking a parent also checks its children. Removing a parent keeps its children.',
|
||||||
|
'criteria.unsaved': 'Checklist changes will be saved with the ticket.',
|
||||||
|
'criteria.saving': 'Saving checklist…',
|
||||||
|
'criteria.saveError':
|
||||||
|
'Checklist status could not be saved. Please try again.',
|
||||||
|
|
||||||
|
'board.title': '{name} board',
|
||||||
|
'board.description':
|
||||||
|
'Work in your configured workflow. Tickets without a board column stay in the backlog.',
|
||||||
|
'board.columns': 'Workflow columns',
|
||||||
|
'board.selectColumn': 'Choose a column',
|
||||||
|
'board.columnOption': '{name} ({count})',
|
||||||
|
'board.scrollHint': 'Scroll horizontally to explore all columns.',
|
||||||
|
'board.openBacklog': 'Open backlog',
|
||||||
|
'board.backToProject': 'Project overview',
|
||||||
|
'board.empty.title': 'No workflow columns yet',
|
||||||
|
'board.empty.description':
|
||||||
|
'Set up columns to start tracking work on this board.',
|
||||||
|
'board.emptyColumn': 'No tickets in this column.',
|
||||||
|
'board.emptyStatus': 'No tickets in this status.',
|
||||||
|
'board.noStatuses': 'No statuses configured for this column.',
|
||||||
|
'board.moveTicket': 'Move {key}',
|
||||||
|
'board.updateStatus': 'Update status',
|
||||||
|
'board.updatingStatus': 'Updating…',
|
||||||
|
'board.noMoves': 'No allowed moves',
|
||||||
|
'board.drag': 'Drag to move',
|
||||||
|
'board.dragTicket': 'Drag {key} to change status',
|
||||||
|
'board.dragHint':
|
||||||
|
'Drag a handle to a highlighted column, or use the status controls. Press Escape to cancel.',
|
||||||
|
'board.dropHint': 'Drop on a column. Hold near an edge to scroll.',
|
||||||
|
'board.dragging':
|
||||||
|
'Dragging {key}. Drop on an allowed column or press Escape to cancel.',
|
||||||
|
'board.chooseStatus': 'Choose a destination status',
|
||||||
|
'board.chooseStatusDescription':
|
||||||
|
'More than one status is available for {key} in this column.',
|
||||||
|
'board.targetStatus': 'Destination status',
|
||||||
|
'board.noMovesDescription':
|
||||||
|
'This status does not allow moving anywhere else.',
|
||||||
|
'backlog.title': '{name} backlog',
|
||||||
|
'backlog.description':
|
||||||
|
'Shape incoming work without losing sight of parent and child tickets.',
|
||||||
|
'backlog.openBoard': 'Open board',
|
||||||
|
'backlog.backToProject': 'Project overview',
|
||||||
|
'backlog.moveTicket': 'Move {key}',
|
||||||
|
'backlog.filters.title': 'Find backlog tickets',
|
||||||
|
'backlog.filters.description':
|
||||||
|
'Filter this view locally. Matching child tickets keep their parent context visible.',
|
||||||
|
'backlog.filters.search': 'Search',
|
||||||
|
'backlog.filters.searchPlaceholder': 'Key, title, description, or metadata',
|
||||||
|
'backlog.filters.type': 'Type',
|
||||||
|
'backlog.filters.allTypes': 'All types',
|
||||||
|
'backlog.filters.priority': 'Priority',
|
||||||
|
'backlog.filters.allPriorities': 'All priorities',
|
||||||
|
'backlog.filters.status': 'Status',
|
||||||
|
'backlog.filters.allStatuses': 'All backlog statuses',
|
||||||
|
'backlog.filters.assignee': 'Assignee',
|
||||||
|
'backlog.filters.allAssignees': 'All assignees',
|
||||||
|
'backlog.filters.clear': 'Clear filters',
|
||||||
|
'backlog.filters.parentContext': 'Parent context',
|
||||||
|
'backlog.filters.empty.title': 'No tickets match these filters',
|
||||||
|
'backlog.filters.empty.description':
|
||||||
|
'Try a broader search or clear the filters to see the complete backlog.',
|
||||||
|
'backlog.results.title': 'Backlog tickets',
|
||||||
|
'backlog.results.count': 'Showing {count} of {total} tickets',
|
||||||
|
'backlog.empty.title': 'Your backlog is clear',
|
||||||
|
'backlog.empty.description':
|
||||||
|
'New tickets without a workflow column will appear here.',
|
||||||
|
'backlog.empty.action': 'Create the first ticket',
|
||||||
|
'backlog.tree.expand': 'Expand children of {key}',
|
||||||
|
'backlog.tree.collapse': 'Collapse children of {key}',
|
||||||
|
'backlog.tree.expandAll': 'Expand all',
|
||||||
|
'backlog.tree.collapseAll': 'Collapse all',
|
||||||
|
'projectCreation.title': 'Create a project',
|
||||||
|
'projectCreation.description':
|
||||||
|
'Give your work a home. Start fresh or reuse a setup that already works for your team.',
|
||||||
|
'projectCreation.start': 'How would you like to start?',
|
||||||
|
'projectCreation.scratch': 'Start from scratch',
|
||||||
|
'projectCreation.scratchDescription':
|
||||||
|
'Create an empty project with the default setup.',
|
||||||
|
'projectCreation.duplicate': 'Duplicate a project',
|
||||||
|
'projectCreation.duplicateDescription':
|
||||||
|
'Choose an existing project and copy selected settings.',
|
||||||
|
'projectCreation.template': 'Use a template',
|
||||||
|
'projectCreation.templateDescription':
|
||||||
|
'Start with a saved, reusable project configuration.',
|
||||||
|
'projectCreation.noProjects':
|
||||||
|
'No accessible projects are available to copy yet.',
|
||||||
|
'projectCreation.noTemplates': 'No published templates are available yet.',
|
||||||
|
'projectCreation.details': 'Project details',
|
||||||
|
'projectCreation.name': 'Project name',
|
||||||
|
'projectCreation.namePlaceholder': 'Platform engineering',
|
||||||
|
'projectCreation.key': 'Project key',
|
||||||
|
'projectCreation.keyPlaceholder': 'CORE',
|
||||||
|
'projectCreation.keyHelp':
|
||||||
|
'Use up to 5 letters or numbers. Keys are unique and converted to uppercase.',
|
||||||
|
'projectCreation.copyTitle': 'Choose what to copy',
|
||||||
|
'projectCreation.copyHelp':
|
||||||
|
'Copy configuration into an independent project. Select only what you need.',
|
||||||
|
'projectCreation.sourceProject': 'Source project',
|
||||||
|
'projectCreation.selectProject': 'Select a source project',
|
||||||
|
'projectCreation.copyOptions': 'Configuration areas',
|
||||||
|
'projectCreation.copyDefaults':
|
||||||
|
'Unselected areas keep the default setup. You can also continue without copying any settings.',
|
||||||
|
'projectCreation.chooseTemplate': 'Choose a template',
|
||||||
|
'projectCreation.templateLabel': 'Template',
|
||||||
|
'projectCreation.selectTemplate': 'Select a template',
|
||||||
|
'projectCreation.templateHelp':
|
||||||
|
'The project stays linked to this template. Inherited areas follow its configuration; you can override them in project settings.',
|
||||||
|
'projectCreation.includedAreas': 'Included configuration',
|
||||||
|
'projectCreation.templateDefaults':
|
||||||
|
'This template uses the default project setup.',
|
||||||
|
'projectCreation.summary': 'Your new project',
|
||||||
|
'projectCreation.untitled': 'Add a project name',
|
||||||
|
'projectCreation.ticketPreview': 'First ticket key',
|
||||||
|
'projectCreation.setup': 'Starting point',
|
||||||
|
'projectCreation.cleanStart':
|
||||||
|
'Every project starts with an empty backlog and its own ticket numbering. Tickets and their history are never copied.',
|
||||||
|
'projectCreation.submit': 'Create project',
|
||||||
|
'projectCreation.creating': 'Creating project…',
|
||||||
|
'projectCreation.areas.projectSettings.label': 'Project settings',
|
||||||
|
'projectCreation.areas.projectSettings.description':
|
||||||
|
'Story points and author visibility.',
|
||||||
|
'projectCreation.areas.boardColumns.label': 'Board columns',
|
||||||
|
'projectCreation.areas.boardColumns.description':
|
||||||
|
'Columns and their order on the board.',
|
||||||
|
'projectCreation.areas.ticketStatuses.label': 'Ticket statuses',
|
||||||
|
'projectCreation.areas.ticketStatuses.description':
|
||||||
|
'Statuses and their board columns.',
|
||||||
|
'projectCreation.areas.statusTransitions.label': 'Status transitions',
|
||||||
|
'projectCreation.areas.statusTransitions.description':
|
||||||
|
'Allowed moves between statuses.',
|
||||||
|
'projectCreation.areas.ticketTypes.label': 'Ticket types',
|
||||||
|
'projectCreation.areas.ticketTypes.description':
|
||||||
|
'Available types, including parent types.',
|
||||||
|
'projectCreation.areas.ticketPriorities.label': 'Ticket priorities',
|
||||||
|
'projectCreation.areas.ticketPriorities.description':
|
||||||
|
'Available priority levels.',
|
||||||
|
'projectCreation.areas.ticketFields.label': 'Custom ticket fields',
|
||||||
|
'projectCreation.areas.ticketFields.description':
|
||||||
|
'Field definitions without ticket values.',
|
||||||
|
'projectCreation.areas.ticketLinkTypes.label': 'Ticket link types',
|
||||||
|
'projectCreation.areas.ticketLinkTypes.description':
|
||||||
|
'Relationship labels between tickets.',
|
||||||
|
'projectCreation.areas.repositories.label': 'Repository connections',
|
||||||
|
'projectCreation.areas.repositories.description':
|
||||||
|
'Repositories linked to the project.',
|
||||||
|
'projectCreation.areas.notifications.label': 'Notification actions',
|
||||||
|
'projectCreation.areas.notifications.description':
|
||||||
|
'Notification rules and delivery settings.',
|
||||||
|
'projectCreation.selectedCount': {
|
||||||
|
one: '{count} area selected',
|
||||||
|
other: '{count} areas selected',
|
||||||
|
},
|
||||||
|
|
||||||
|
'projects.workspace': 'Workspace',
|
||||||
|
'projects.description':
|
||||||
|
'Your project spaces, ready to work in. Open a project or jump straight to its board and backlog.',
|
||||||
|
'projects.create': 'New project',
|
||||||
|
'projects.updated': 'Project update',
|
||||||
|
'projects.available': {
|
||||||
|
one: '{count} project available',
|
||||||
|
other: '{count} projects available',
|
||||||
|
},
|
||||||
|
'projects.open': 'Open {name} overview',
|
||||||
|
'projects.openBoard': 'Open {name} board',
|
||||||
|
'projects.openBacklog': 'Open {name} backlog',
|
||||||
|
'projects.overview': 'Project overview',
|
||||||
|
'projects.empty.title': 'No projects to show',
|
||||||
|
'projects.empty.createDescription':
|
||||||
|
'Create a project to give your team a place to plan and track work.',
|
||||||
|
'projects.empty.accessDescription':
|
||||||
|
'Projects appear here when you have access. Ask a workspace or project administrator to add you.',
|
||||||
|
'projects.empty.create': 'Create your first project',
|
||||||
|
'projects.back': 'All projects',
|
||||||
|
'projects.hubDescription':
|
||||||
|
'Follow work on the board or explore tickets in the backlog.',
|
||||||
|
'projects.workAreas': 'Project work areas',
|
||||||
|
'projects.boardDescription':
|
||||||
|
'See work across the project’s workflow and open tickets in their current status.',
|
||||||
|
'projects.backlogDescription':
|
||||||
|
'Explore incoming work, review ticket details, and plan what comes next.',
|
||||||
|
'projects.boardAction': 'Open board',
|
||||||
|
'projects.backlogAction': 'Open backlog',
|
||||||
|
'projects.settingsDescription':
|
||||||
|
'Manage this project’s configuration, integrations, and access.',
|
||||||
|
'projects.saveTemplate': 'Save as new template',
|
||||||
|
'projects.templateTitle': 'Based on {name}',
|
||||||
|
'projects.templateDescription':
|
||||||
|
'Inherited areas follow the linked template. Overridden areas use this project’s own configuration.',
|
||||||
|
'projects.inheritedArea': '{name} · inherited',
|
||||||
|
'projects.overriddenArea': '{name} · overridden',
|
||||||
|
'dashboard.eyebrow': 'Personal workspace',
|
||||||
|
'dashboard.greeting': 'Welcome back, {name}',
|
||||||
|
'dashboard.description':
|
||||||
|
'A current view of tickets assigned to you in projects you can access.',
|
||||||
|
'dashboard.summary': 'Work summary',
|
||||||
|
'dashboard.summary.assignedTickets': 'Assigned tickets',
|
||||||
|
'dashboard.summary.projects': 'Projects with assigned work',
|
||||||
|
'dashboard.summary.blockedTickets': 'Blocked tickets',
|
||||||
|
'dashboard.assignedWork': 'My assigned tickets',
|
||||||
|
'dashboard.assignedWorkDescription':
|
||||||
|
'Your work is grouped by project and ordered with the newest tickets first.',
|
||||||
|
'dashboard.projectTickets': 'Tickets assigned to you in {name}',
|
||||||
|
'dashboard.openProject': 'Open {name}',
|
||||||
|
'dashboard.openProjectAction': 'Open project',
|
||||||
|
'dashboard.empty.title': 'No tickets assigned to you',
|
||||||
|
'dashboard.empty.description':
|
||||||
|
'Tickets assigned to you in projects you can access will appear here.',
|
||||||
|
'dashboard.empty.action': 'Browse projects',
|
||||||
'auth.home': 'KanbanGit home',
|
'auth.home': 'KanbanGit home',
|
||||||
'auth.accountAccess': 'Account access',
|
'auth.accountAccess': 'Account access',
|
||||||
'auth.backToLogin': 'Return to sign in',
|
'auth.backToLogin': 'Return to sign in',
|
||||||
@@ -17,6 +239,54 @@ export const en = {
|
|||||||
'auth.login.pending': 'Signing in…',
|
'auth.login.pending': 'Signing in…',
|
||||||
'auth.login.help': 'Need an account? Contact your workspace administrator.',
|
'auth.login.help': 'Need an account? Contact your workspace administrator.',
|
||||||
'auth.login.statusTitle': 'Account update',
|
'auth.login.statusTitle': 'Account update',
|
||||||
|
'auth.forgot.title': 'Reset your password',
|
||||||
|
'auth.forgot.description':
|
||||||
|
'Enter your account email and we will send you a secure reset link.',
|
||||||
|
'auth.forgot.email': 'Email address',
|
||||||
|
'auth.forgot.emailPlaceholder': 'you@example.com',
|
||||||
|
'auth.forgot.emailHint':
|
||||||
|
'Use the email address associated with your KanbanGit account.',
|
||||||
|
'auth.forgot.submit': 'Send reset link',
|
||||||
|
'auth.forgot.pending': 'Sending reset link…',
|
||||||
|
'auth.forgot.sentTitle': 'Reset link sent',
|
||||||
|
'auth.reset.title': 'Choose a new password',
|
||||||
|
'auth.reset.description':
|
||||||
|
'Create a new password for the account linked below.',
|
||||||
|
'auth.reset.email': 'Account email',
|
||||||
|
'auth.reset.password': 'New password',
|
||||||
|
'auth.reset.passwordHint':
|
||||||
|
'Use a password you do not use for another account.',
|
||||||
|
'auth.reset.passwordConfirmation': 'Confirm new password',
|
||||||
|
'auth.reset.submit': 'Save new password',
|
||||||
|
'auth.reset.pending': 'Updating your password…',
|
||||||
|
'auth.reset.invalidTitle': 'This reset link is no longer valid',
|
||||||
|
'auth.reset.requestNew': 'Request a new reset link',
|
||||||
|
'auth.reset.footer':
|
||||||
|
'For your security, reset links expire and can only be used once.',
|
||||||
|
'auth.confirm.title': 'Confirm it is you',
|
||||||
|
'auth.confirm.description':
|
||||||
|
'This action affects sensitive account information. Enter your password to continue.',
|
||||||
|
'auth.confirm.password': 'Current password',
|
||||||
|
'auth.confirm.passwordHint':
|
||||||
|
'Your password is checked securely and is never saved in a draft.',
|
||||||
|
'auth.confirm.submit': 'Confirm and continue',
|
||||||
|
'auth.confirm.pending': 'Confirming your password…',
|
||||||
|
'auth.confirm.footer':
|
||||||
|
'Password confirmation expires automatically after a short time.',
|
||||||
|
'auth.forceChange.title': 'Secure your account',
|
||||||
|
'auth.forceChange.description':
|
||||||
|
'You need to replace your temporary password before continuing to KanbanGit.',
|
||||||
|
'auth.forceChange.currentPassword': 'Temporary password',
|
||||||
|
'auth.forceChange.password': 'New password',
|
||||||
|
'auth.forceChange.passwordHint':
|
||||||
|
'Choose a password that differs from your temporary password.',
|
||||||
|
'auth.forceChange.passwordConfirmation': 'Confirm new password',
|
||||||
|
'auth.forceChange.submit': 'Save password and continue',
|
||||||
|
'auth.forceChange.pending': 'Securing your account…',
|
||||||
|
'auth.forceChange.statusTitle': 'Password update',
|
||||||
|
'auth.forceChange.wrongAccount': 'Not the account you expected?',
|
||||||
|
'auth.forceChange.footer':
|
||||||
|
'Your password entries are kept in memory only and are cleared when you leave.',
|
||||||
'auth.verify.title': 'Check your inbox',
|
'auth.verify.title': 'Check your inbox',
|
||||||
'auth.verify.description':
|
'auth.verify.description':
|
||||||
'Open the verification link in your email to finish confirming your account.',
|
'Open the verification link in your email to finish confirming your account.',
|
||||||
@@ -130,6 +400,17 @@ export const en = {
|
|||||||
'tickets.noPullRequests': 'No matching pull requests',
|
'tickets.noPullRequests': 'No matching pull requests',
|
||||||
'tickets.noPullRequestsDescription':
|
'tickets.noPullRequestsDescription':
|
||||||
'No matching pull requests were found across the linked repositories.',
|
'No matching pull requests were found across the linked repositories.',
|
||||||
|
'tickets.open': 'Open {key}: {title}',
|
||||||
|
'tickets.blocked': 'Blocked',
|
||||||
|
'tickets.blockerComment': 'Blocker: {comment}',
|
||||||
|
'tickets.typeLabel': 'Type: {name}',
|
||||||
|
'tickets.priorityLabel': 'Priority: {name}',
|
||||||
|
'tickets.statusLabel': 'Status: {name}',
|
||||||
|
'tickets.noStatus': 'No status',
|
||||||
|
'tickets.assignedTo': 'Assigned to {name}',
|
||||||
|
'tickets.unassigned': 'Unassigned',
|
||||||
|
'tickets.tree.expand': 'Expand children of {key}',
|
||||||
|
'tickets.tree.collapse': 'Collapse children of {key}',
|
||||||
'common.save': 'Save',
|
'common.save': 'Save',
|
||||||
'common.loading': 'Loading…',
|
'common.loading': 'Loading…',
|
||||||
'common.error': 'Something went wrong.',
|
'common.error': 'Something went wrong.',
|
||||||
@@ -138,4 +419,143 @@ export const en = {
|
|||||||
one: '{count} ticket',
|
one: '{count} ticket',
|
||||||
other: '{count} tickets',
|
other: '{count} tickets',
|
||||||
},
|
},
|
||||||
|
'ticketDetail.description': 'Description',
|
||||||
|
'ticketDetail.noDescription': 'No description has been added yet.',
|
||||||
|
'ticketDetail.checklist': 'Acceptance criteria',
|
||||||
|
'ticketDetail.noChecklist': 'No acceptance criteria have been added yet.',
|
||||||
|
'ticketDetail.saveChecklistFirst':
|
||||||
|
'Save checklist text changes before toggling completion directly.',
|
||||||
|
'ticketDetail.edit': 'Edit ticket',
|
||||||
|
'ticketDetail.editDescription':
|
||||||
|
'Tracked ticket changes create worklog entries automatically.',
|
||||||
|
'ticketDetail.git': 'Git',
|
||||||
|
'ticketDetail.relationships': 'Relationships',
|
||||||
|
'ticketDetail.history': 'Worklog',
|
||||||
|
'ticketDetail.metadata': 'Ticket information',
|
||||||
|
'ticketDetail.sections': 'Ticket sections',
|
||||||
|
'ticketDetail.status': 'Status',
|
||||||
|
'ticketDetail.type': 'Type',
|
||||||
|
'ticketDetail.priority': 'Priority',
|
||||||
|
'ticketDetail.assignee': 'Assignee',
|
||||||
|
'ticketDetail.author': 'Author',
|
||||||
|
'ticketDetail.noAuthor': 'No author',
|
||||||
|
'ticketDetail.storyPoints': 'Estimated story points',
|
||||||
|
'ticketDetail.notSet': 'Not set',
|
||||||
|
'ticketDetail.created': 'Created',
|
||||||
|
'ticketDetail.updated': 'Last updated',
|
||||||
|
'ticketDetail.backToProject': 'Back to project',
|
||||||
|
'ticketDetail.openBacklog': 'Open backlog',
|
||||||
|
'ticketDetail.openBoard': 'Open board',
|
||||||
|
'ticketDetail.readOnly': 'Read only',
|
||||||
|
'ticketDetail.title': 'Title',
|
||||||
|
'ticketDetail.parent': 'Parent ticket',
|
||||||
|
'ticketDetail.noParent': 'No parent ticket',
|
||||||
|
'ticketDetail.checklistEditor': 'Acceptance criteria checklist',
|
||||||
|
'ticketDetail.checklistHelp':
|
||||||
|
'Use [ ] / [x] for checklist items. Indent with two spaces for nested steps. Text changes are saved with the main ticket update.',
|
||||||
|
'ticketDetail.checklistPlaceholder':
|
||||||
|
'[ ] User can sign in\n [x] Validation is shown for invalid credentials',
|
||||||
|
'ticketDetail.blocked': 'Mark ticket as blocked',
|
||||||
|
'ticketDetail.blockerComment': 'Blocker comment',
|
||||||
|
'ticketDetail.blockerPlaceholder':
|
||||||
|
'Describe what currently blocks progress on this ticket.',
|
||||||
|
'ticketDetail.customFields': 'Custom fields',
|
||||||
|
'ticketDetail.customFieldsDescription':
|
||||||
|
'Project-configured fields can be tracked directly on the ticket.',
|
||||||
|
'ticketDetail.noCustomFields':
|
||||||
|
'No custom fields are configured for this project yet.',
|
||||||
|
'ticketDetail.saveChanges': 'Save changes',
|
||||||
|
'ticketDetail.branches': 'Branches',
|
||||||
|
'ticketDetail.branchesDescription':
|
||||||
|
'Matching branches are discovered from linked repositories when the branch name starts with this ticket key.',
|
||||||
|
'ticketDetail.createBranch': 'Create branch',
|
||||||
|
'ticketDetail.createBranchTitle': 'Create branch from ticket',
|
||||||
|
'ticketDetail.createBranchDescription':
|
||||||
|
'Pick a linked repository, confirm the suggested branch name, and create it directly in Gitea.',
|
||||||
|
'ticketDetail.repository': 'Repository',
|
||||||
|
'ticketDetail.branchName': 'Branch name',
|
||||||
|
'ticketDetail.branchAccess':
|
||||||
|
'You can only create branches in repositories that match one of your personal Git connections.',
|
||||||
|
'ticketDetail.openGitConnections': 'Open Git connections',
|
||||||
|
'ticketDetail.createNow': 'Create now',
|
||||||
|
'ticketDetail.inspectBranches':
|
||||||
|
'Connect a matching Git account in your user settings to inspect branches for this repository.',
|
||||||
|
'ticketDetail.pullRequests': 'Pull requests',
|
||||||
|
'ticketDetail.pullRequestsDescription':
|
||||||
|
'Matching pull requests are detected from linked repositories by checking whether the source branch starts with this ticket key.',
|
||||||
|
'ticketDetail.inspectPullRequests':
|
||||||
|
'Connect a matching Git account in your user settings to inspect pull requests for this repository.',
|
||||||
|
'ticketDetail.checkingBranch':
|
||||||
|
'Checking whether this branch name is valid and still available...',
|
||||||
|
'ticketDetail.selectRepository':
|
||||||
|
'Select a linked repository to validate the branch name.',
|
||||||
|
'ticketDetail.connectGitFirst':
|
||||||
|
'Connect a matching Git connection in your user settings first.',
|
||||||
|
'ticketDetail.branchRequired': 'Branch name is required.',
|
||||||
|
'ticketDetail.branchValidationFailed':
|
||||||
|
'{app} could not validate this branch name right now.',
|
||||||
|
'ticketDetail.checklistSaveFailed':
|
||||||
|
'Checklist status could not be saved right now.',
|
||||||
|
'ticketDetail.children': 'Child tickets',
|
||||||
|
'ticketDetail.childrenDescription':
|
||||||
|
'Parent tickets expose their full child tree here, including nested parent chains.',
|
||||||
|
'ticketDetail.noChildren':
|
||||||
|
'No child tickets are assigned to this ticket yet.',
|
||||||
|
'ticketDetail.parentDescription':
|
||||||
|
'This ticket belongs to the parent shown here.',
|
||||||
|
'ticketDetail.linkedTickets': 'Linked tickets',
|
||||||
|
'ticketDetail.linkedTicketsDescription':
|
||||||
|
'Track cross-ticket relationships with project-defined link labels.',
|
||||||
|
'ticketDetail.linkType': 'Link type',
|
||||||
|
'ticketDetail.linkedTicket': 'Linked ticket',
|
||||||
|
'ticketDetail.saveLink': 'Save link',
|
||||||
|
'ticketDetail.noLinks':
|
||||||
|
'No ticket links are configured for this ticket yet.',
|
||||||
|
'ticketDetail.removeLink': 'Remove',
|
||||||
|
'ticketRelationships.hierarchy': 'Hierarchy',
|
||||||
|
'ticketRelationships.editParent': 'Change parent',
|
||||||
|
'ticketRelationships.parentHelp':
|
||||||
|
'Change parent to assign this ticket or choose “No parent ticket” to detach it.',
|
||||||
|
'ticketRelationships.childrenHelp':
|
||||||
|
'Open a child ticket to change its parent. Expand a group to see its descendants.',
|
||||||
|
'ticketRelationships.addLink': 'Add or update a link',
|
||||||
|
'ticketRelationships.selectTicket': 'Select a ticket',
|
||||||
|
'ticketRelationships.directionHelp':
|
||||||
|
'The selected relationship points from this ticket to the linked ticket. Saving an existing pair updates its type and direction.',
|
||||||
|
'ticketRelationships.outgoing': 'Outgoing',
|
||||||
|
'ticketRelationships.incoming': 'Incoming',
|
||||||
|
'ticketRelationships.removeLink': 'Remove link to {key}',
|
||||||
|
'ticketRelationships.noTypes':
|
||||||
|
'No link types are configured for this project.',
|
||||||
|
'ticketRelationships.noTargets':
|
||||||
|
'No other tickets are available to link in this project.',
|
||||||
|
'ticketDetail.historyDescription':
|
||||||
|
'Every tracked ticket change is recorded with actor and timestamp.',
|
||||||
|
'ticketDetail.noHistory': 'No worklog entries exist for this ticket yet.',
|
||||||
|
'ticketDetail.system': 'System',
|
||||||
|
'ticketDetail.sourceBranch': 'Source branch: {name}',
|
||||||
|
'ticketForm.create': 'Create ticket',
|
||||||
|
'ticketForm.pageTitle': 'Create {project} ticket',
|
||||||
|
'ticketForm.createDescription': 'Add a ticket to {project}.',
|
||||||
|
'ticketForm.backToBoard': 'Back to board',
|
||||||
|
'ticketForm.backToBacklog': 'Back to backlog',
|
||||||
|
'ticketForm.details': 'Ticket details',
|
||||||
|
'ticketForm.keyAssigned': 'The ticket key is assigned after creation.',
|
||||||
|
'ticketForm.titlePlaceholder': 'Implement repository sync',
|
||||||
|
'ticketForm.descriptionPlaceholder':
|
||||||
|
'Describe the expected behavior and relevant context.',
|
||||||
|
'ticketForm.checklistHelp':
|
||||||
|
'Use [ ] / [x] for checklist items. Indent with two spaces for nested steps.',
|
||||||
|
'ticketForm.checklistPreview': 'Checklist preview',
|
||||||
|
'ticketForm.metadataRequired':
|
||||||
|
'Ticket creation needs at least one type, one priority, and one status.',
|
||||||
|
'ticketForm.openSettings': 'Open ticket settings',
|
||||||
|
'ticketForm.creating': 'Creating ticket…',
|
||||||
|
'ticketForm.saving': 'Saving changes…',
|
||||||
|
'ticketForm.reset': 'Discard changes',
|
||||||
|
'ticketForm.unsaved': 'Unsaved changes',
|
||||||
|
'ticketForm.ready': 'Ready for a new ticket',
|
||||||
|
'ticketForm.saved': 'All changes saved',
|
||||||
|
'ticketForm.authorRestricted': 'Only project admins can change the author.',
|
||||||
|
'ticketForm.blocker': 'Blocker',
|
||||||
} as const;
|
} as const;
|
||||||
|
|||||||
@@ -1,47 +1,211 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Head } from '@inertiajs/vue3';
|
import { Head, Link } from '@inertiajs/vue3';
|
||||||
import PlaceholderPattern from '@/components/PlaceholderPattern.vue';
|
import {
|
||||||
|
ArrowUpRight,
|
||||||
|
FolderGit2,
|
||||||
|
ListTodo,
|
||||||
|
OctagonAlert,
|
||||||
|
} from 'lucide-vue-next';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import FeedbackState from '@/components/FeedbackState.vue';
|
||||||
|
import { TicketCard } from '@/components/tickets';
|
||||||
|
import { Badge } from '@/components/ui/badge';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
import AppLayout from '@/layouts/AppLayout.vue';
|
import AppLayout from '@/layouts/AppLayout.vue';
|
||||||
import { dashboard } from '@/routes/index';
|
import { dashboard } from '@/routes/index';
|
||||||
import type { BreadcrumbItem } from '@/types';
|
import { index as projectsIndex, show as showProject } from '@/routes/projects';
|
||||||
|
import type { BreadcrumbItem, DashboardPageProps } from '@/types';
|
||||||
|
|
||||||
const breadcrumbs: BreadcrumbItem[] = [
|
const props = defineProps<DashboardPageProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const breadcrumbs = computed<BreadcrumbItem[]>(() => [
|
||||||
|
{ title: t('navigation.dashboard'), href: dashboard() },
|
||||||
|
]);
|
||||||
|
const assignedTickets = computed(() =>
|
||||||
|
props.assignedTicketsByProject.flatMap((group) => group.tickets),
|
||||||
|
);
|
||||||
|
const summaryItems = computed(() => [
|
||||||
{
|
{
|
||||||
title: 'Dashboard',
|
label: t('dashboard.summary.assignedTickets'),
|
||||||
href: dashboard(),
|
value: assignedTickets.value.length,
|
||||||
|
icon: ListTodo,
|
||||||
},
|
},
|
||||||
];
|
{
|
||||||
|
label: t('dashboard.summary.projects'),
|
||||||
|
value: props.assignedTicketsByProject.length,
|
||||||
|
icon: FolderGit2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('dashboard.summary.blockedTickets'),
|
||||||
|
value: assignedTickets.value.filter((ticket) => ticket.is_blocked)
|
||||||
|
.length,
|
||||||
|
icon: OctagonAlert,
|
||||||
|
},
|
||||||
|
]);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Head title="Dashboard" />
|
|
||||||
|
|
||||||
<AppLayout :breadcrumbs="breadcrumbs">
|
<AppLayout :breadcrumbs="breadcrumbs">
|
||||||
<div
|
<Head :title="t('navigation.dashboard')" />
|
||||||
class="flex h-full flex-1 flex-col gap-4 overflow-x-auto rounded-xl p-4"
|
|
||||||
>
|
<div class="gap-page md:p-page flex min-w-0 flex-1 flex-col p-4">
|
||||||
<div class="grid auto-rows-min gap-4 md:grid-cols-3">
|
<header class="gap-stack grid min-w-0">
|
||||||
<div
|
<p class="text-label text-muted-foreground uppercase">
|
||||||
class="border-sidebar-border/70 dark:border-sidebar-border relative aspect-video overflow-hidden rounded-xl border"
|
{{ t('dashboard.eyebrow') }}
|
||||||
>
|
</p>
|
||||||
<PlaceholderPattern />
|
<h1 class="text-headline-mobile md:text-headline break-words">
|
||||||
</div>
|
{{
|
||||||
<div
|
t('dashboard.greeting', {
|
||||||
class="border-sidebar-border/70 dark:border-sidebar-border relative aspect-video overflow-hidden rounded-xl border"
|
name: $page.props.auth.user.name,
|
||||||
>
|
})
|
||||||
<PlaceholderPattern />
|
}}
|
||||||
</div>
|
</h1>
|
||||||
<div
|
<p class="text-muted-foreground max-w-2xl">
|
||||||
class="border-sidebar-border/70 dark:border-sidebar-border relative aspect-video overflow-hidden rounded-xl border"
|
{{ t('dashboard.description') }}
|
||||||
>
|
</p>
|
||||||
<PlaceholderPattern />
|
</header>
|
||||||
</div>
|
|
||||||
</div>
|
<section :aria-label="t('dashboard.summary')">
|
||||||
<div
|
<ul class="grid gap-3 sm:grid-cols-3">
|
||||||
class="border-sidebar-border/70 dark:border-sidebar-border relative min-h-[100vh] flex-1 rounded-xl border md:min-h-min"
|
<li
|
||||||
|
v-for="item in summaryItems"
|
||||||
|
:key="item.label"
|
||||||
|
class="min-w-0"
|
||||||
|
>
|
||||||
|
<Card class="h-full gap-0 rounded-md py-0">
|
||||||
|
<CardContent
|
||||||
|
class="flex min-w-0 items-center justify-between gap-4 p-4"
|
||||||
|
>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<p
|
||||||
|
class="text-caption text-muted-foreground break-words"
|
||||||
|
>
|
||||||
|
{{ item.label }}
|
||||||
|
</p>
|
||||||
|
<p class="text-title mt-1 tabular-nums">
|
||||||
|
{{ item.value }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
class="bg-accent text-primary flex size-10 shrink-0 items-center justify-center rounded-md"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="item.icon"
|
||||||
|
class="size-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section
|
||||||
|
aria-labelledby="assigned-work-title"
|
||||||
|
class="gap-column grid min-w-0"
|
||||||
>
|
>
|
||||||
<PlaceholderPattern />
|
<header class="gap-stack grid min-w-0">
|
||||||
</div>
|
<h2 id="assigned-work-title" class="text-title">
|
||||||
|
{{ t('dashboard.assignedWork') }}
|
||||||
|
</h2>
|
||||||
|
<p class="text-muted-foreground max-w-2xl">
|
||||||
|
{{ t('dashboard.assignedWorkDescription') }}
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<FeedbackState
|
||||||
|
v-if="assignedTicketsByProject.length === 0"
|
||||||
|
state="empty"
|
||||||
|
:title="t('dashboard.empty.title')"
|
||||||
|
:description="t('dashboard.empty.description')"
|
||||||
|
>
|
||||||
|
<Button as-child variant="outline">
|
||||||
|
<Link :href="projectsIndex()">
|
||||||
|
<FolderGit2 aria-hidden="true" />
|
||||||
|
{{ t('dashboard.empty.action') }}
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
</FeedbackState>
|
||||||
|
|
||||||
|
<div v-else class="gap-page grid min-w-0">
|
||||||
|
<section
|
||||||
|
v-for="group in assignedTicketsByProject"
|
||||||
|
:key="group.project.id"
|
||||||
|
:aria-labelledby="`dashboard-project-${group.project.id}`"
|
||||||
|
class="gap-column grid min-w-0"
|
||||||
|
>
|
||||||
|
<header
|
||||||
|
class="flex min-w-0 flex-col gap-3 border-b pb-3 sm:flex-row sm:items-center sm:justify-between"
|
||||||
|
>
|
||||||
|
<div class="flex min-w-0 items-center gap-3">
|
||||||
|
<Badge
|
||||||
|
variant="outline"
|
||||||
|
class="max-w-full shrink-0 whitespace-normal break-all"
|
||||||
|
>
|
||||||
|
{{ group.project.key }}
|
||||||
|
</Badge>
|
||||||
|
<div class="min-w-0">
|
||||||
|
<h3
|
||||||
|
:id="`dashboard-project-${group.project.id}`"
|
||||||
|
class="text-body break-words font-semibold"
|
||||||
|
>
|
||||||
|
{{ group.project.name }}
|
||||||
|
</h3>
|
||||||
|
<p
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
t('tickets.count', {
|
||||||
|
count: group.tickets.length,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
as-child
|
||||||
|
variant="link"
|
||||||
|
class="self-start sm:self-auto"
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
:href="showProject(group.project.id)"
|
||||||
|
:aria-label="
|
||||||
|
t('dashboard.openProject', {
|
||||||
|
name: group.project.name,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ t('dashboard.openProjectAction') }}
|
||||||
|
<ArrowUpRight aria-hidden="true" />
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<ul
|
||||||
|
:aria-label="
|
||||||
|
t('dashboard.projectTickets', {
|
||||||
|
name: group.project.name,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
class="gap-column grid min-w-0 md:grid-cols-2 2xl:grid-cols-3"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
v-for="ticket in group.tickets"
|
||||||
|
:key="ticket.id"
|
||||||
|
class="min-w-0"
|
||||||
|
>
|
||||||
|
<TicketCard
|
||||||
|
:project-id="group.project.id"
|
||||||
|
:ticket="ticket"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,52 +1,77 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Form, Head } from '@inertiajs/vue3';
|
import { Head, useForm } from '@inertiajs/vue3';
|
||||||
|
import { ShieldCheck } from 'lucide-vue-next';
|
||||||
|
import { onUnmounted } from 'vue';
|
||||||
|
import AuthFormFeedback from '@/components/AuthFormFeedback.vue';
|
||||||
import InputError from '@/components/InputError.vue';
|
import InputError from '@/components/InputError.vue';
|
||||||
import PasswordInput from '@/components/PasswordInput.vue';
|
import PasswordInput from '@/components/PasswordInput.vue';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { Spinner } from '@/components/ui/spinner';
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
import AuthLayout from '@/layouts/AuthLayout.vue';
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import AuthFlowLayout from '@/layouts/auth/AuthFlowLayout.vue';
|
||||||
import { store } from '@/routes/password/confirm';
|
import { store } from '@/routes/password/confirm';
|
||||||
|
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const form = useForm({ password: '' }).dontRemember('password');
|
||||||
|
const protection = useFormProtection(form, { isDirty: () => false });
|
||||||
|
const submit = (): void =>
|
||||||
|
protection.submit(store(), { onSuccess: () => form.reset() });
|
||||||
|
onUnmounted(() => form.reset());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AuthLayout
|
<AuthFlowLayout
|
||||||
title="Confirm your password"
|
:title="t('auth.confirm.title')"
|
||||||
description="This is a secure area of the application. Please confirm your password before continuing."
|
:description="t('auth.confirm.description')"
|
||||||
|
:icon="ShieldCheck"
|
||||||
>
|
>
|
||||||
<Head title="Confirm password" />
|
<Head :title="t('auth.confirm.title')" />
|
||||||
|
<form
|
||||||
<Form
|
:action="store.url()"
|
||||||
v-bind="store.form()"
|
method="post"
|
||||||
reset-on-success
|
class="grid gap-5"
|
||||||
v-slot="{ errors, processing }"
|
@submit.prevent="submit"
|
||||||
>
|
>
|
||||||
<div class="space-y-6">
|
<AuthFormFeedback
|
||||||
<div class="grid gap-2">
|
:state="protection.state.value"
|
||||||
<Label htmlFor="password">Password</Label>
|
:response-status="protection.responseStatus.value"
|
||||||
<PasswordInput
|
:loading-title="t('auth.confirm.pending')"
|
||||||
id="password"
|
@retry="submit"
|
||||||
name="password"
|
/>
|
||||||
class="mt-1 block w-full"
|
<div class="gap-stack grid">
|
||||||
required
|
<Label for="password">{{ t('auth.confirm.password') }}</Label>
|
||||||
autocomplete="current-password"
|
<PasswordInput
|
||||||
autofocus
|
id="password"
|
||||||
/>
|
v-model="form.password"
|
||||||
|
name="password"
|
||||||
<InputError :message="errors.password" />
|
required
|
||||||
</div>
|
autocomplete="current-password"
|
||||||
|
autofocus
|
||||||
<div class="flex items-center">
|
:disabled="form.processing"
|
||||||
<Button
|
:invalid="Boolean(form.errors.password)"
|
||||||
class="w-full"
|
aria-describedby="password-hint password-error"
|
||||||
:disabled="processing"
|
/>
|
||||||
data-test="confirm-password-button"
|
<p
|
||||||
>
|
id="password-hint"
|
||||||
<Spinner v-if="processing" />
|
class="text-caption text-muted-foreground"
|
||||||
Confirm password
|
>
|
||||||
</Button>
|
{{ t('auth.confirm.passwordHint') }}
|
||||||
</div>
|
</p>
|
||||||
|
<InputError
|
||||||
|
id="password-error"
|
||||||
|
:message="form.errors.password"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
<Button
|
||||||
</AuthLayout>
|
type="submit"
|
||||||
|
class="w-full"
|
||||||
|
:loading="form.processing"
|
||||||
|
:loading-label="t('auth.confirm.pending')"
|
||||||
|
data-test="confirm-password-button"
|
||||||
|
>{{ t('auth.confirm.submit') }}</Button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<template #footer>{{ t('auth.confirm.footer') }}</template>
|
||||||
|
</AuthFlowLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,115 +1,170 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Form, Head, Link } from '@inertiajs/vue3';
|
import { Head, useForm } from '@inertiajs/vue3';
|
||||||
import { LogOut } from 'lucide-vue-next';
|
import { KeyRound } from 'lucide-vue-next';
|
||||||
|
import { computed, onUnmounted } from 'vue';
|
||||||
import SecurityController from '@/actions/App/Http/Controllers/Settings/SecurityController';
|
import SecurityController from '@/actions/App/Http/Controllers/Settings/SecurityController';
|
||||||
|
import AuthFormFeedback from '@/components/AuthFormFeedback.vue';
|
||||||
|
import FeedbackState from '@/components/FeedbackState.vue';
|
||||||
import InputError from '@/components/InputError.vue';
|
import InputError from '@/components/InputError.vue';
|
||||||
import PasswordInput from '@/components/PasswordInput.vue';
|
import PasswordInput from '@/components/PasswordInput.vue';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { Spinner } from '@/components/ui/spinner';
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
import AuthLayout from '@/layouts/AuthLayout.vue';
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
import { logout } from '@/routes';
|
import AuthFlowLayout from '@/layouts/auth/AuthFlowLayout.vue';
|
||||||
|
import { logout } from '@/routes/index';
|
||||||
|
|
||||||
withDefaults(
|
withDefaults(defineProps<{ status?: string | null }>(), { status: null });
|
||||||
defineProps<{
|
const { t } = useLocalization();
|
||||||
status?: string | null;
|
const form = useForm({
|
||||||
}>(),
|
current_password: '',
|
||||||
{
|
password: '',
|
||||||
status: null,
|
password_confirmation: '',
|
||||||
},
|
}).dontRemember('current_password', 'password', 'password_confirmation');
|
||||||
);
|
const logoutForm = useForm({});
|
||||||
|
const protection = useFormProtection(form, { isDirty: () => false });
|
||||||
|
const logoutProtection = useFormProtection(logoutForm);
|
||||||
|
const busy = computed(() => form.processing || logoutForm.processing);
|
||||||
|
const submit = (): void =>
|
||||||
|
protection.submit(SecurityController.update(), {
|
||||||
|
onSuccess: () => form.reset(),
|
||||||
|
});
|
||||||
|
const signOut = (): void => {
|
||||||
|
if (busy.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
form.reset();
|
||||||
|
logoutProtection.submit(logout());
|
||||||
|
};
|
||||||
|
onUnmounted(() => form.reset());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AuthLayout
|
<AuthFlowLayout
|
||||||
title="Change your password"
|
:title="t('auth.forceChange.title')"
|
||||||
description="You must update your password before you can continue using the application."
|
:description="t('auth.forceChange.description')"
|
||||||
|
:icon="KeyRound"
|
||||||
>
|
>
|
||||||
<Head title="Change your password" />
|
<Head :title="t('auth.forceChange.title')" />
|
||||||
|
<FeedbackState
|
||||||
<div class="mb-6 flex justify-end">
|
|
||||||
<Button as-child variant="ghost" size="sm">
|
|
||||||
<Link :href="logout()" as="button">
|
|
||||||
<LogOut class="size-4" />
|
|
||||||
Log out
|
|
||||||
</Link>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="status"
|
v-if="status"
|
||||||
class="mb-6 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900"
|
state="success"
|
||||||
|
:title="t('auth.forceChange.statusTitle')"
|
||||||
|
:description="status"
|
||||||
|
/>
|
||||||
|
<form
|
||||||
|
:action="SecurityController.update.url()"
|
||||||
|
method="post"
|
||||||
|
class="grid gap-5"
|
||||||
|
@submit.prevent="submit"
|
||||||
>
|
>
|
||||||
{{ status }}
|
<AuthFormFeedback
|
||||||
</div>
|
:state="protection.state.value"
|
||||||
|
:response-status="protection.responseStatus.value"
|
||||||
<Form
|
:loading-title="t('auth.forceChange.pending')"
|
||||||
v-bind="SecurityController.update.form()"
|
@retry="submit"
|
||||||
reset-on-success
|
/>
|
||||||
:reset-on-error="[
|
<div class="gap-stack grid">
|
||||||
'password',
|
<Label for="current_password">{{
|
||||||
'password_confirmation',
|
t('auth.forceChange.currentPassword')
|
||||||
'current_password',
|
}}</Label>
|
||||||
]"
|
<PasswordInput
|
||||||
v-slot="{ errors, processing }"
|
id="current_password"
|
||||||
>
|
v-model="form.current_password"
|
||||||
<div class="space-y-6">
|
name="current_password"
|
||||||
<div class="grid gap-2">
|
required
|
||||||
<Label htmlFor="current_password">Current password</Label>
|
autocomplete="current-password"
|
||||||
<PasswordInput
|
autofocus
|
||||||
id="current_password"
|
:disabled="busy"
|
||||||
name="current_password"
|
:invalid="Boolean(form.errors.current_password)"
|
||||||
class="mt-1 block w-full"
|
aria-describedby="current-password-error"
|
||||||
required
|
/>
|
||||||
autocomplete="current-password"
|
<InputError
|
||||||
autofocus
|
id="current-password-error"
|
||||||
placeholder="Current password"
|
:message="form.errors.current_password"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<InputError :message="errors.current_password" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label htmlFor="password">New password</Label>
|
|
||||||
<PasswordInput
|
|
||||||
id="password"
|
|
||||||
name="password"
|
|
||||||
class="mt-1 block w-full"
|
|
||||||
required
|
|
||||||
autocomplete="new-password"
|
|
||||||
placeholder="New password"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<InputError :message="errors.password" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label htmlFor="password_confirmation">
|
|
||||||
Confirm new password
|
|
||||||
</Label>
|
|
||||||
<PasswordInput
|
|
||||||
id="password_confirmation"
|
|
||||||
name="password_confirmation"
|
|
||||||
class="mt-1 block w-full"
|
|
||||||
required
|
|
||||||
autocomplete="new-password"
|
|
||||||
placeholder="Confirm new password"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<InputError :message="errors.password_confirmation" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex items-center">
|
|
||||||
<Button
|
|
||||||
class="w-full"
|
|
||||||
:disabled="processing"
|
|
||||||
data-test="force-password-change-button"
|
|
||||||
>
|
|
||||||
<Spinner v-if="processing" />
|
|
||||||
Save new password
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
<div class="gap-stack grid">
|
||||||
</AuthLayout>
|
<Label for="password">{{
|
||||||
|
t('auth.forceChange.password')
|
||||||
|
}}</Label>
|
||||||
|
<PasswordInput
|
||||||
|
id="password"
|
||||||
|
v-model="form.password"
|
||||||
|
name="password"
|
||||||
|
required
|
||||||
|
autocomplete="new-password"
|
||||||
|
:disabled="busy"
|
||||||
|
:invalid="Boolean(form.errors.password)"
|
||||||
|
aria-describedby="new-password-hint new-password-error"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
id="new-password-hint"
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ t('auth.forceChange.passwordHint') }}
|
||||||
|
</p>
|
||||||
|
<InputError
|
||||||
|
id="new-password-error"
|
||||||
|
:message="form.errors.password"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<Label for="password_confirmation">{{
|
||||||
|
t('auth.forceChange.passwordConfirmation')
|
||||||
|
}}</Label>
|
||||||
|
<PasswordInput
|
||||||
|
id="password_confirmation"
|
||||||
|
v-model="form.password_confirmation"
|
||||||
|
name="password_confirmation"
|
||||||
|
required
|
||||||
|
autocomplete="new-password"
|
||||||
|
:disabled="busy"
|
||||||
|
:invalid="Boolean(form.errors.password_confirmation)"
|
||||||
|
aria-describedby="new-password-confirmation-error"
|
||||||
|
/>
|
||||||
|
<InputError
|
||||||
|
id="new-password-confirmation-error"
|
||||||
|
:message="form.errors.password_confirmation"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
class="w-full"
|
||||||
|
:disabled="logoutForm.processing"
|
||||||
|
:loading="form.processing"
|
||||||
|
:loading-label="t('auth.forceChange.pending')"
|
||||||
|
data-test="force-password-change-button"
|
||||||
|
>{{ t('auth.forceChange.submit') }}</Button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<div class="gap-stack pt-column grid border-t">
|
||||||
|
<p class="text-body text-muted-foreground">
|
||||||
|
{{ t('auth.forceChange.wrongAccount') }}
|
||||||
|
</p>
|
||||||
|
<form
|
||||||
|
:action="logout.url()"
|
||||||
|
method="post"
|
||||||
|
class="gap-card grid"
|
||||||
|
@submit.prevent="signOut"
|
||||||
|
>
|
||||||
|
<AuthFormFeedback
|
||||||
|
:state="logoutProtection.state.value"
|
||||||
|
:response-status="logoutProtection.responseStatus.value"
|
||||||
|
:loading-title="t('auth.signingOut')"
|
||||||
|
@retry="signOut"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
variant="outline"
|
||||||
|
class="w-full"
|
||||||
|
:disabled="form.processing"
|
||||||
|
:loading="logoutForm.processing"
|
||||||
|
:loading-label="t('auth.signingOut')"
|
||||||
|
>{{ t('auth.signOut') }}</Button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<template #footer>{{ t('auth.forceChange.footer') }}</template>
|
||||||
|
</AuthFlowLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,65 +1,89 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Form, Head } from '@inertiajs/vue3';
|
import { Head, useForm } from '@inertiajs/vue3';
|
||||||
|
import { Mail } from 'lucide-vue-next';
|
||||||
|
import { onUnmounted } from 'vue';
|
||||||
|
import AuthFormFeedback from '@/components/AuthFormFeedback.vue';
|
||||||
|
import FeedbackState from '@/components/FeedbackState.vue';
|
||||||
import InputError from '@/components/InputError.vue';
|
import InputError from '@/components/InputError.vue';
|
||||||
import TextLink from '@/components/TextLink.vue';
|
import TextLink from '@/components/TextLink.vue';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { Spinner } from '@/components/ui/spinner';
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
import AuthLayout from '@/layouts/AuthLayout.vue';
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
|
import AuthFlowLayout from '@/layouts/auth/AuthFlowLayout.vue';
|
||||||
import { login } from '@/routes/index';
|
import { login } from '@/routes/index';
|
||||||
import { email } from '@/routes/password';
|
import { email } from '@/routes/password';
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{ status?: string }>();
|
||||||
status?: string;
|
const { t } = useLocalization();
|
||||||
}>();
|
const form = useForm({ email: '' }).dontRemember('email');
|
||||||
|
const protection = useFormProtection(form, { isDirty: () => false });
|
||||||
|
const submit = (): void => protection.submit(email());
|
||||||
|
onUnmounted(() => form.reset());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AuthLayout
|
<AuthFlowLayout
|
||||||
title="Forgot password"
|
:title="t('auth.forgot.title')"
|
||||||
description="Enter your email to receive a password reset link"
|
:description="t('auth.forgot.description')"
|
||||||
|
:icon="Mail"
|
||||||
>
|
>
|
||||||
<Head title="Forgot password" />
|
<Head :title="t('auth.forgot.title')" />
|
||||||
|
<FeedbackState
|
||||||
<div
|
|
||||||
v-if="status"
|
v-if="status"
|
||||||
class="mb-4 text-center text-sm font-medium text-green-600"
|
state="success"
|
||||||
|
:title="t('auth.forgot.sentTitle')"
|
||||||
|
:description="status"
|
||||||
|
/>
|
||||||
|
<form
|
||||||
|
:action="email.url()"
|
||||||
|
method="post"
|
||||||
|
class="grid gap-5"
|
||||||
|
@submit.prevent="submit"
|
||||||
>
|
>
|
||||||
{{ status }}
|
<AuthFormFeedback
|
||||||
</div>
|
:state="protection.state.value"
|
||||||
|
:response-status="protection.responseStatus.value"
|
||||||
<div class="space-y-6">
|
:loading-title="t('auth.forgot.pending')"
|
||||||
<Form v-bind="email.form()" v-slot="{ errors, processing }">
|
@retry="submit"
|
||||||
<div class="grid gap-2">
|
/>
|
||||||
<Label for="email">Email address</Label>
|
<div class="gap-stack grid">
|
||||||
<Input
|
<Label for="email">{{ t('auth.forgot.email') }}</Label>
|
||||||
id="email"
|
<Input
|
||||||
type="email"
|
id="email"
|
||||||
name="email"
|
v-model="form.email"
|
||||||
autocomplete="off"
|
name="email"
|
||||||
autofocus
|
type="email"
|
||||||
placeholder="email@example.com"
|
inputmode="email"
|
||||||
/>
|
autocomplete="email"
|
||||||
<InputError :message="errors.email" />
|
autocapitalize="none"
|
||||||
</div>
|
:spellcheck="false"
|
||||||
|
required
|
||||||
<div class="my-6 flex items-center justify-start">
|
autofocus
|
||||||
<Button
|
:disabled="form.processing"
|
||||||
class="w-full"
|
:placeholder="t('auth.forgot.emailPlaceholder')"
|
||||||
:disabled="processing"
|
:invalid="Boolean(form.errors.email)"
|
||||||
data-test="email-password-reset-link-button"
|
aria-describedby="email-hint email-error"
|
||||||
>
|
/>
|
||||||
<Spinner v-if="processing" />
|
<p id="email-hint" class="text-caption text-muted-foreground">
|
||||||
Email password reset link
|
{{ t('auth.forgot.emailHint') }}
|
||||||
</Button>
|
</p>
|
||||||
</div>
|
<InputError id="email-error" :message="form.errors.email" />
|
||||||
</Form>
|
|
||||||
|
|
||||||
<div class="text-muted-foreground space-x-1 text-center text-sm">
|
|
||||||
<span>Or, return to</span>
|
|
||||||
<TextLink :href="login()">log in</TextLink>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<Button
|
||||||
</AuthLayout>
|
type="submit"
|
||||||
|
class="w-full"
|
||||||
|
:loading="form.processing"
|
||||||
|
:loading-label="t('auth.forgot.pending')"
|
||||||
|
data-test="email-password-reset-link-button"
|
||||||
|
>{{ t('auth.forgot.submit') }}</Button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<template #footer
|
||||||
|
><TextLink :href="login()">{{
|
||||||
|
t('auth.backToLogin')
|
||||||
|
}}</TextLink></template
|
||||||
|
>
|
||||||
|
</AuthFlowLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,88 +1,136 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Form, Head } from '@inertiajs/vue3';
|
import { Head, Link, useForm } from '@inertiajs/vue3';
|
||||||
import { ref } from 'vue';
|
import { KeyRound } from 'lucide-vue-next';
|
||||||
|
import { computed, onUnmounted } from 'vue';
|
||||||
|
import AuthFormFeedback from '@/components/AuthFormFeedback.vue';
|
||||||
|
import FeedbackState from '@/components/FeedbackState.vue';
|
||||||
import InputError from '@/components/InputError.vue';
|
import InputError from '@/components/InputError.vue';
|
||||||
import PasswordInput from '@/components/PasswordInput.vue';
|
import PasswordInput from '@/components/PasswordInput.vue';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
import { Spinner } from '@/components/ui/spinner';
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
import AuthLayout from '@/layouts/AuthLayout.vue';
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
import { update } from '@/routes/password';
|
import AuthFlowLayout from '@/layouts/auth/AuthFlowLayout.vue';
|
||||||
|
import { request, update } from '@/routes/password';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{ token: string; email: string }>();
|
||||||
token: string;
|
const { t } = useLocalization();
|
||||||
email: string;
|
const form = useForm({
|
||||||
}>();
|
token: props.token,
|
||||||
|
email: props.email,
|
||||||
const inputEmail = ref(props.email);
|
password: '',
|
||||||
|
password_confirmation: '',
|
||||||
|
}).dontRemember('token', 'email', 'password', 'password_confirmation');
|
||||||
|
const protection = useFormProtection(form, { isDirty: () => false });
|
||||||
|
const invalidLink = computed(() => Boolean(form.errors.email));
|
||||||
|
const feedbackState = computed(() =>
|
||||||
|
invalidLink.value ? 'idle' : protection.state.value,
|
||||||
|
);
|
||||||
|
const submit = (): void =>
|
||||||
|
protection.submit(update(), {
|
||||||
|
onSuccess: () => form.reset('password', 'password_confirmation'),
|
||||||
|
});
|
||||||
|
onUnmounted(() => form.reset());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AuthLayout
|
<AuthFlowLayout
|
||||||
title="Reset password"
|
:title="t('auth.reset.title')"
|
||||||
description="Please enter your new password below"
|
:description="t('auth.reset.description')"
|
||||||
|
:icon="KeyRound"
|
||||||
>
|
>
|
||||||
<Head title="Reset password" />
|
<Head :title="t('auth.reset.title')" />
|
||||||
|
<FeedbackState
|
||||||
<Form
|
v-if="invalidLink"
|
||||||
v-bind="update.form()"
|
state="error"
|
||||||
:transform="(data) => ({ ...data, token, email })"
|
:title="t('auth.reset.invalidTitle')"
|
||||||
:reset-on-success="['password', 'password_confirmation']"
|
:description="form.errors.email"
|
||||||
v-slot="{ errors, processing }"
|
|
||||||
>
|
>
|
||||||
<div class="grid gap-6">
|
<Button as-child variant="outline" class="w-full">
|
||||||
<div class="grid gap-2">
|
<Link :href="request()">{{ t('auth.reset.requestNew') }}</Link>
|
||||||
<Label for="email">Email</Label>
|
</Button>
|
||||||
<Input
|
</FeedbackState>
|
||||||
id="email"
|
<form
|
||||||
type="email"
|
:action="update.url()"
|
||||||
name="email"
|
method="post"
|
||||||
autocomplete="email"
|
class="grid gap-5"
|
||||||
v-model="inputEmail"
|
@submit.prevent="submit"
|
||||||
class="mt-1 block w-full"
|
>
|
||||||
readonly
|
<AuthFormFeedback
|
||||||
/>
|
:state="feedbackState"
|
||||||
<InputError :message="errors.email" class="mt-2" />
|
:response-status="protection.responseStatus.value"
|
||||||
</div>
|
:loading-title="t('auth.reset.pending')"
|
||||||
|
@retry="submit"
|
||||||
<div class="grid gap-2">
|
/>
|
||||||
<Label for="password">Password</Label>
|
<input type="hidden" name="token" :value="form.token" />
|
||||||
<PasswordInput
|
<div class="gap-stack grid">
|
||||||
id="password"
|
<Label for="email">{{ t('auth.reset.email') }}</Label>
|
||||||
name="password"
|
<Input
|
||||||
autocomplete="new-password"
|
id="email"
|
||||||
class="mt-1 block w-full"
|
v-model="form.email"
|
||||||
autofocus
|
name="email"
|
||||||
placeholder="Password"
|
type="email"
|
||||||
/>
|
autocomplete="username"
|
||||||
<InputError :message="errors.password" />
|
readonly
|
||||||
</div>
|
:disabled="form.processing"
|
||||||
|
:invalid="Boolean(form.errors.email)"
|
||||||
<div class="grid gap-2">
|
aria-describedby="email-error"
|
||||||
<Label for="password_confirmation">
|
/>
|
||||||
Confirm password
|
<InputError id="email-error" :message="form.errors.email" />
|
||||||
</Label>
|
|
||||||
<PasswordInput
|
|
||||||
id="password_confirmation"
|
|
||||||
name="password_confirmation"
|
|
||||||
autocomplete="new-password"
|
|
||||||
class="mt-1 block w-full"
|
|
||||||
placeholder="Confirm password"
|
|
||||||
/>
|
|
||||||
<InputError :message="errors.password_confirmation" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
class="mt-4 w-full"
|
|
||||||
:disabled="processing"
|
|
||||||
data-test="reset-password-button"
|
|
||||||
>
|
|
||||||
<Spinner v-if="processing" />
|
|
||||||
Reset password
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
<div class="gap-stack grid">
|
||||||
</AuthLayout>
|
<Label for="password">{{ t('auth.reset.password') }}</Label>
|
||||||
|
<PasswordInput
|
||||||
|
id="password"
|
||||||
|
v-model="form.password"
|
||||||
|
name="password"
|
||||||
|
autocomplete="new-password"
|
||||||
|
required
|
||||||
|
autofocus
|
||||||
|
:disabled="form.processing"
|
||||||
|
:invalid="Boolean(form.errors.password)"
|
||||||
|
aria-describedby="password-hint password-error"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
id="password-hint"
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ t('auth.reset.passwordHint') }}
|
||||||
|
</p>
|
||||||
|
<InputError
|
||||||
|
id="password-error"
|
||||||
|
:message="form.errors.password"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<Label for="password_confirmation">{{
|
||||||
|
t('auth.reset.passwordConfirmation')
|
||||||
|
}}</Label>
|
||||||
|
<PasswordInput
|
||||||
|
id="password_confirmation"
|
||||||
|
v-model="form.password_confirmation"
|
||||||
|
name="password_confirmation"
|
||||||
|
autocomplete="new-password"
|
||||||
|
required
|
||||||
|
:disabled="form.processing"
|
||||||
|
:invalid="Boolean(form.errors.password_confirmation)"
|
||||||
|
aria-describedby="password-confirmation-error"
|
||||||
|
/>
|
||||||
|
<InputError
|
||||||
|
id="password-confirmation-error"
|
||||||
|
:message="form.errors.password_confirmation"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
class="w-full"
|
||||||
|
:loading="form.processing"
|
||||||
|
:loading-label="t('auth.reset.pending')"
|
||||||
|
data-test="reset-password-button"
|
||||||
|
>{{ t('auth.reset.submit') }}</Button
|
||||||
|
>
|
||||||
|
</form>
|
||||||
|
<template #footer>{{ t('auth.reset.footer') }}</template>
|
||||||
|
</AuthFlowLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,90 +1,155 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Form, Head, Link } from '@inertiajs/vue3';
|
import { Head, Link } from '@inertiajs/vue3';
|
||||||
import ProjectBoardController from '@/actions/App/Http/Controllers/ProjectBoardController';
|
import {
|
||||||
import Heading from '@/components/Heading.vue';
|
ArrowLeft,
|
||||||
|
ChevronsDownUp,
|
||||||
|
ChevronsUpDown,
|
||||||
|
Columns3,
|
||||||
|
Plus,
|
||||||
|
RotateCcw,
|
||||||
|
Search,
|
||||||
|
} from 'lucide-vue-next';
|
||||||
|
import { computed, reactive, ref, watch } from 'vue';
|
||||||
|
import BacklogTicketTree from '@/components/BacklogTicketTree.vue';
|
||||||
|
import FeedbackState from '@/components/FeedbackState.vue';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from '@/components/ui/card';
|
|
||||||
import AppLayout from '@/layouts/AppLayout.vue';
|
import AppLayout from '@/layouts/AppLayout.vue';
|
||||||
|
import {
|
||||||
|
buildBacklogTicketTree,
|
||||||
|
countBacklogTreeTickets,
|
||||||
|
expandableBacklogTicketIds,
|
||||||
|
filterBacklogTicketTree,
|
||||||
|
} from '@/lib/backlog';
|
||||||
import { index as boardIndex } from '@/routes/projects/board';
|
import { index as boardIndex } from '@/routes/projects/board';
|
||||||
import { index as backlogIndex } from '@/routes/projects/backlog';
|
import { index as backlogIndex } from '@/routes/projects/backlog';
|
||||||
import { index, show } from '@/routes/projects/index';
|
import { index as projectIndex, show } from '@/routes/projects/index';
|
||||||
import {
|
import { create as createTicket } from '@/routes/projects/tickets';
|
||||||
create as createTicket,
|
import type {
|
||||||
show as showTicket,
|
BacklogFilterState,
|
||||||
} from '@/routes/projects/tickets';
|
BreadcrumbItem,
|
||||||
import type { BreadcrumbItem, ProjectBacklogPageProps } from '@/types';
|
ProjectBacklogPageProps,
|
||||||
import type { TicketModel } from '@/types/models/ticket-model';
|
} from '@/types';
|
||||||
import type { TicketStatusModel } from '@/types/models/ticket-status-model';
|
|
||||||
|
|
||||||
const props = defineProps<ProjectBacklogPageProps>();
|
const props = defineProps<ProjectBacklogPageProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
const breadcrumbs = computed<BreadcrumbItem[]>(() => [
|
||||||
|
{ title: t('navigation.projects'), href: projectIndex() },
|
||||||
|
{ title: props.project.name, href: show(props.project.id) },
|
||||||
|
{ title: t('navigation.backlog'), href: backlogIndex(props.project.id) },
|
||||||
|
]);
|
||||||
|
|
||||||
const breadcrumbs: BreadcrumbItem[] = [
|
const filters = reactive<BacklogFilterState>({
|
||||||
{
|
assigneeId: '',
|
||||||
title: 'Projects',
|
priorityId: '',
|
||||||
href: index(),
|
query: '',
|
||||||
},
|
statusId: '',
|
||||||
{
|
typeId: '',
|
||||||
title: props.project.name,
|
});
|
||||||
href: show(props.project.id),
|
const collapsedTicketIds = reactive(new Set<number>());
|
||||||
},
|
const pendingTicketId = ref<number | null>(null);
|
||||||
{
|
const ticketTree = computed(() => buildBacklogTicketTree(props.tickets));
|
||||||
title: 'Backlog',
|
const filteredTicketTree = computed(() =>
|
||||||
href: backlogIndex(props.project.id),
|
filterBacklogTicketTree(ticketTree.value, filters),
|
||||||
},
|
);
|
||||||
];
|
const visibleTicketCount = computed(() =>
|
||||||
|
countBacklogTreeTickets(filteredTicketTree.value),
|
||||||
|
);
|
||||||
|
const expandableTicketIds = computed(() =>
|
||||||
|
expandableBacklogTicketIds(filteredTicketTree.value),
|
||||||
|
);
|
||||||
|
const hasActiveFilters = computed(
|
||||||
|
() =>
|
||||||
|
filters.query.trim() !== '' ||
|
||||||
|
filters.typeId !== '' ||
|
||||||
|
filters.priorityId !== '' ||
|
||||||
|
filters.statusId !== '' ||
|
||||||
|
filters.assigneeId !== '',
|
||||||
|
);
|
||||||
|
const allVisibleBranchesCollapsed = computed(
|
||||||
|
() =>
|
||||||
|
expandableTicketIds.value.length > 0 &&
|
||||||
|
expandableTicketIds.value.every((ticketId) =>
|
||||||
|
collapsedTicketIds.has(ticketId),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
const ticketStatusLabel = (ticketStatus: TicketStatusModel | null): string => {
|
function clearFilters(): void {
|
||||||
if (ticketStatus === null) {
|
filters.query = '';
|
||||||
return 'Unknown status';
|
filters.typeId = '';
|
||||||
|
filters.priorityId = '';
|
||||||
|
filters.statusId = '';
|
||||||
|
filters.assigneeId = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleTicket(ticketId: number): void {
|
||||||
|
if (collapsedTicketIds.has(ticketId)) {
|
||||||
|
collapsedTicketIds.delete(ticketId);
|
||||||
|
} else {
|
||||||
|
collapsedTicketIds.add(ticketId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleAllBranches(): void {
|
||||||
|
if (allVisibleBranchesCollapsed.value) {
|
||||||
|
collapsedTicketIds.clear();
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
for (const ticketId of expandableTicketIds.value) {
|
||||||
ticketStatus.board_column === null ||
|
collapsedTicketIds.add(ticketId);
|
||||||
ticketStatus.board_column === undefined
|
|
||||||
) {
|
|
||||||
return ticketStatus.name;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ticketStatus.board_column.name === ticketStatus.name) {
|
function finishMove(ticketId: number): void {
|
||||||
return ticketStatus.name;
|
if (pendingTicketId.value === ticketId) {
|
||||||
|
pendingTicketId.value = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return `${ticketStatus.board_column.name} / ${ticketStatus.name}`;
|
watch(
|
||||||
};
|
() => props.project.id,
|
||||||
|
() => {
|
||||||
const allowedTargetStatuses = (ticket: TicketModel): TicketStatusModel[] => {
|
clearFilters();
|
||||||
return (ticket.ticket_status?.allowed_target_statuses ?? []).filter(
|
collapsedTicketIds.clear();
|
||||||
(ticketStatus) => ticketStatus.id !== ticket.ticket_status_id,
|
pendingTicketId.value = null;
|
||||||
);
|
},
|
||||||
};
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout :breadcrumbs="breadcrumbs">
|
<AppLayout :breadcrumbs="breadcrumbs">
|
||||||
<Head :title="`${project.name} backlog`" />
|
<Head :title="t('backlog.title', { name: project.name })" />
|
||||||
|
|
||||||
<div class="flex flex-1 flex-col gap-6 p-4">
|
<div class="gap-page md:p-page flex min-w-0 flex-1 flex-col p-4">
|
||||||
<div
|
<header
|
||||||
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
class="flex min-w-0 flex-col gap-4 xl:flex-row xl:items-start xl:justify-between"
|
||||||
>
|
>
|
||||||
<div class="space-y-3">
|
<div class="grid min-w-0 gap-2">
|
||||||
<Badge variant="outline" class="px-3 py-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3">
|
||||||
{{ project.key }}
|
<Badge
|
||||||
</Badge>
|
variant="outline"
|
||||||
<Heading
|
class="wrap-anywhere max-w-full whitespace-normal"
|
||||||
:title="`${project.name} backlog`"
|
>
|
||||||
description="All newly created tickets start here before they move onto the board."
|
{{ project.key }}
|
||||||
/>
|
</Badge>
|
||||||
|
<p class="text-caption text-muted-foreground">
|
||||||
|
{{ t('tickets.count', { count: tickets.length }) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<h1
|
||||||
|
class="text-headline-mobile md:text-headline wrap-anywhere"
|
||||||
|
>
|
||||||
|
{{ t('backlog.title', { name: project.name }) }}
|
||||||
|
</h1>
|
||||||
|
<p class="text-caption text-muted-foreground max-w-2xl">
|
||||||
|
{{ t('backlog.description') }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-wrap gap-3">
|
<div class="flex flex-wrap gap-2">
|
||||||
<Button v-if="canCreateTickets" as-child>
|
<Button v-if="canCreateTickets" as-child>
|
||||||
<Link
|
<Link
|
||||||
:href="
|
:href="
|
||||||
@@ -94,203 +159,286 @@ const allowedTargetStatuses = (ticket: TicketModel): TicketStatusModel[] => {
|
|||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
Create ticket
|
<Plus aria-hidden="true" />
|
||||||
|
{{ t('navigation.createTicket') }}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button as-child variant="outline">
|
<Button as-child variant="outline">
|
||||||
<Link :href="boardIndex(project.id)">Open board</Link>
|
<Link :href="boardIndex(project.id)">
|
||||||
|
<Columns3 aria-hidden="true" />
|
||||||
|
{{ t('backlog.openBoard') }}
|
||||||
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button as-child variant="ghost">
|
||||||
<Button as-child variant="outline">
|
<Link :href="show(project.id)">
|
||||||
<Link :href="show(project.id)">Back to project</Link>
|
<ArrowLeft aria-hidden="true" />
|
||||||
|
{{ t('backlog.backToProject') }}
|
||||||
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<FeedbackState v-if="status" state="success" :title="status" />
|
||||||
|
|
||||||
|
<section
|
||||||
|
aria-labelledby="backlog-filter-title"
|
||||||
|
class="bg-card gap-card p-card grid min-w-0 rounded-md border"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="flex min-w-0 flex-col gap-3 sm:flex-row sm:items-start sm:justify-between"
|
||||||
|
>
|
||||||
|
<div class="grid min-w-0 gap-1">
|
||||||
|
<h2 id="backlog-filter-title" class="text-title">
|
||||||
|
{{ t('backlog.filters.title') }}
|
||||||
|
</h2>
|
||||||
|
<p class="text-caption text-muted-foreground">
|
||||||
|
{{ t('backlog.filters.description') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
:disabled="!hasActiveFilters"
|
||||||
|
@click="clearFilters"
|
||||||
|
>
|
||||||
|
<RotateCcw aria-hidden="true" />
|
||||||
|
{{ t('backlog.filters.clear') }}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="grid min-w-0 gap-3 sm:grid-cols-2 xl:grid-cols-[minmax(14rem,2fr)_repeat(4,minmax(9rem,1fr))]"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="grid min-w-0 gap-1.5 sm:col-span-2 xl:col-span-1"
|
||||||
|
>
|
||||||
|
<label
|
||||||
|
for="backlog-query"
|
||||||
|
class="text-caption font-semibold"
|
||||||
|
>
|
||||||
|
{{ t('backlog.filters.search') }}
|
||||||
|
</label>
|
||||||
|
<div class="relative min-w-0">
|
||||||
|
<Search
|
||||||
|
class="text-muted-foreground pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
id="backlog-query"
|
||||||
|
v-model="filters.query"
|
||||||
|
type="search"
|
||||||
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full min-w-0 rounded-md border py-2 pl-9 pr-3 focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
:placeholder="
|
||||||
|
t('backlog.filters.searchPlaceholder')
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid min-w-0 gap-1.5">
|
||||||
|
<label
|
||||||
|
for="backlog-type"
|
||||||
|
class="text-caption font-semibold"
|
||||||
|
>
|
||||||
|
{{ t('backlog.filters.type') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="backlog-type"
|
||||||
|
v-model="filters.typeId"
|
||||||
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full min-w-0 rounded-md border px-3 py-2 focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ t('backlog.filters.allTypes') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="ticketType in ticketTypes"
|
||||||
|
:key="ticketType.id"
|
||||||
|
:value="ticketType.id"
|
||||||
|
>
|
||||||
|
{{ ticketType.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid min-w-0 gap-1.5">
|
||||||
|
<label
|
||||||
|
for="backlog-priority"
|
||||||
|
class="text-caption font-semibold"
|
||||||
|
>
|
||||||
|
{{ t('backlog.filters.priority') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="backlog-priority"
|
||||||
|
v-model="filters.priorityId"
|
||||||
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full min-w-0 rounded-md border px-3 py-2 focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ t('backlog.filters.allPriorities') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="priority in ticketPriorities"
|
||||||
|
:key="priority.id"
|
||||||
|
:value="priority.id"
|
||||||
|
>
|
||||||
|
{{ priority.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid min-w-0 gap-1.5">
|
||||||
|
<label
|
||||||
|
for="backlog-status"
|
||||||
|
class="text-caption font-semibold"
|
||||||
|
>
|
||||||
|
{{ t('backlog.filters.status') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="backlog-status"
|
||||||
|
v-model="filters.statusId"
|
||||||
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full min-w-0 rounded-md border px-3 py-2 focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ t('backlog.filters.allStatuses') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="ticketStatus in backlogTicketStatuses"
|
||||||
|
:key="ticketStatus.id"
|
||||||
|
:value="ticketStatus.id"
|
||||||
|
>
|
||||||
|
{{ ticketStatus.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid min-w-0 gap-1.5">
|
||||||
|
<label
|
||||||
|
for="backlog-assignee"
|
||||||
|
class="text-caption font-semibold"
|
||||||
|
>
|
||||||
|
{{ t('backlog.filters.assignee') }}
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="backlog-assignee"
|
||||||
|
v-model="filters.assigneeId"
|
||||||
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full min-w-0 rounded-md border px-3 py-2 focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{{ t('backlog.filters.allAssignees') }}
|
||||||
|
</option>
|
||||||
|
<option value="unassigned">
|
||||||
|
{{ t('tickets.unassigned') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="user in users"
|
||||||
|
:key="user.id"
|
||||||
|
:value="user.id"
|
||||||
|
>
|
||||||
|
{{ user.name }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="tickets.length === 0"
|
||||||
|
class="grid justify-items-start gap-3"
|
||||||
|
>
|
||||||
|
<FeedbackState
|
||||||
|
state="empty"
|
||||||
|
:title="t('backlog.empty.title')"
|
||||||
|
:description="t('backlog.empty.description')"
|
||||||
|
/>
|
||||||
|
<Button v-if="canCreateTickets" as-child size="sm">
|
||||||
|
<Link
|
||||||
|
:href="
|
||||||
|
createTicket(
|
||||||
|
{ project: project.id },
|
||||||
|
{ query: { source: 'backlog' } },
|
||||||
|
)
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<Plus aria-hidden="true" />
|
||||||
|
{{ t('backlog.empty.action') }}
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="status"
|
v-else-if="visibleTicketCount === 0"
|
||||||
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"
|
class="grid justify-items-start gap-3"
|
||||||
>
|
>
|
||||||
{{ status }}
|
<FeedbackState
|
||||||
|
state="empty"
|
||||||
|
:title="t('backlog.filters.empty.title')"
|
||||||
|
:description="t('backlog.filters.empty.description')"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
@click="clearFilters"
|
||||||
|
>
|
||||||
|
<RotateCcw aria-hidden="true" />
|
||||||
|
{{ t('backlog.filters.clear') }}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card class="gap-0 overflow-hidden">
|
<section
|
||||||
<CardHeader class="border-b">
|
v-else
|
||||||
<CardTitle>Backlog tickets</CardTitle>
|
aria-labelledby="backlog-results-title"
|
||||||
<CardDescription>
|
class="grid min-w-0 gap-3"
|
||||||
Tickets remain here while their status belongs to
|
>
|
||||||
backlog.
|
<div
|
||||||
</CardDescription>
|
class="flex min-w-0 flex-col gap-3 sm:flex-row sm:items-center sm:justify-between"
|
||||||
</CardHeader>
|
>
|
||||||
|
<div class="grid min-w-0 gap-1">
|
||||||
<CardContent class="p-0">
|
<h2 id="backlog-results-title" class="text-title">
|
||||||
<div
|
{{ t('backlog.results.title') }}
|
||||||
v-if="tickets.length === 0"
|
</h2>
|
||||||
class="text-muted-foreground p-6 text-sm"
|
<p class="text-caption text-muted-foreground">
|
||||||
|
{{
|
||||||
|
t('backlog.results.count', {
|
||||||
|
count: visibleTicketCount,
|
||||||
|
total: tickets.length,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
v-if="expandableTicketIds.length > 0"
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
@click="toggleAllBranches"
|
||||||
>
|
>
|
||||||
No backlog tickets exist yet.
|
<ChevronsUpDown
|
||||||
</div>
|
v-if="allVisibleBranchesCollapsed"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<ChevronsDownUp v-else aria-hidden="true" />
|
||||||
|
{{
|
||||||
|
t(
|
||||||
|
allVisibleBranchesCollapsed
|
||||||
|
? 'backlog.tree.expandAll'
|
||||||
|
: 'backlog.tree.collapseAll',
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-else class="overflow-x-auto">
|
<BacklogTicketTree
|
||||||
<table
|
:nodes="filteredTicketTree"
|
||||||
class="divide-border min-w-full divide-y text-sm"
|
:project-id="project.id"
|
||||||
>
|
:can-edit-tickets="canEditTickets"
|
||||||
<thead
|
:collapsed-ticket-ids="collapsedTicketIds"
|
||||||
class="bg-muted/40 text-muted-foreground text-left"
|
:pending-ticket-id="pendingTicketId"
|
||||||
>
|
@toggle="toggleTicket"
|
||||||
<tr>
|
@move-start="pendingTicketId = $event"
|
||||||
<th class="px-4 py-3 font-medium">Key</th>
|
@move-finish="finishMove"
|
||||||
<th class="px-4 py-3 font-medium">Title</th>
|
/>
|
||||||
<th class="px-4 py-3 font-medium">Type</th>
|
</section>
|
||||||
<th class="px-4 py-3 font-medium">
|
|
||||||
Status
|
|
||||||
</th>
|
|
||||||
<th class="px-4 py-3 font-medium">
|
|
||||||
Priority
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
v-if="canEditTickets"
|
|
||||||
class="px-4 py-3 font-medium"
|
|
||||||
>
|
|
||||||
Move to status
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="divide-border divide-y">
|
|
||||||
<tr
|
|
||||||
v-for="ticket in tickets"
|
|
||||||
:key="ticket.id"
|
|
||||||
class="bg-background"
|
|
||||||
>
|
|
||||||
<td class="px-4 py-4">
|
|
||||||
<Link
|
|
||||||
:href="
|
|
||||||
showTicket({
|
|
||||||
project: project.id,
|
|
||||||
ticket: ticket.id,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<Badge variant="outline">
|
|
||||||
{{ ticket.ticket_key }}
|
|
||||||
</Badge>
|
|
||||||
</Link>
|
|
||||||
</td>
|
|
||||||
<td class="px-4 py-4">
|
|
||||||
<Link
|
|
||||||
:href="
|
|
||||||
showTicket({
|
|
||||||
project: project.id,
|
|
||||||
ticket: ticket.id,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
class="text-foreground hover:text-primary font-medium transition"
|
|
||||||
>
|
|
||||||
{{ ticket.title }}
|
|
||||||
</Link>
|
|
||||||
<div
|
|
||||||
v-if="ticket.description"
|
|
||||||
class="text-muted-foreground mt-1 line-clamp-2"
|
|
||||||
>
|
|
||||||
{{ ticket.description }}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td class="text-muted-foreground px-4 py-4">
|
|
||||||
{{ ticket.ticket_type.name }}
|
|
||||||
</td>
|
|
||||||
<td class="text-muted-foreground px-4 py-4">
|
|
||||||
{{
|
|
||||||
ticketStatusLabel(
|
|
||||||
ticket.ticket_status,
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
</td>
|
|
||||||
<td class="text-muted-foreground px-4 py-4">
|
|
||||||
{{ ticket.ticket_priority.name }}
|
|
||||||
</td>
|
|
||||||
<td v-if="canEditTickets" class="px-4 py-4">
|
|
||||||
<Form
|
|
||||||
v-bind="
|
|
||||||
ProjectBoardController.move.form(
|
|
||||||
{
|
|
||||||
project: project.id,
|
|
||||||
ticket: ticket.id,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
"
|
|
||||||
class="flex flex-col gap-2 sm:flex-row"
|
|
||||||
v-slot="{ processing }"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="hidden"
|
|
||||||
name="redirect_to"
|
|
||||||
value="backlog"
|
|
||||||
/>
|
|
||||||
<select
|
|
||||||
name="ticket_status_id"
|
|
||||||
:disabled="
|
|
||||||
allowedTargetStatuses(
|
|
||||||
ticket,
|
|
||||||
).length === 0 || processing
|
|
||||||
"
|
|
||||||
class="border-input bg-background shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 min-w-44 rounded-md border px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-60"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-if="
|
|
||||||
allowedTargetStatuses(
|
|
||||||
ticket,
|
|
||||||
).length === 0
|
|
||||||
"
|
|
||||||
value=""
|
|
||||||
>
|
|
||||||
No allowed moves
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="ticketStatus in allowedTargetStatuses(
|
|
||||||
ticket,
|
|
||||||
)"
|
|
||||||
:key="ticketStatus.id"
|
|
||||||
:value="ticketStatus.id"
|
|
||||||
>
|
|
||||||
{{
|
|
||||||
ticketStatusLabel(
|
|
||||||
ticketStatus,
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<Button
|
|
||||||
type="submit"
|
|
||||||
size="sm"
|
|
||||||
:disabled="
|
|
||||||
processing ||
|
|
||||||
allowedTargetStatuses(
|
|
||||||
ticket,
|
|
||||||
).length === 0
|
|
||||||
"
|
|
||||||
>
|
|
||||||
Move
|
|
||||||
</Button>
|
|
||||||
<p
|
|
||||||
v-if="
|
|
||||||
allowedTargetStatuses(
|
|
||||||
ticket,
|
|
||||||
).length === 0
|
|
||||||
"
|
|
||||||
class="text-muted-foreground text-xs sm:basis-full"
|
|
||||||
>
|
|
||||||
This status does not allow
|
|
||||||
moving anywhere else.
|
|
||||||
</p>
|
|
||||||
</Form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,91 +1,248 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Form, Head, Link } from '@inertiajs/vue3';
|
import { Form, Head, Link, useForm } from '@inertiajs/vue3';
|
||||||
import ProjectBoardController from '@/actions/App/Http/Controllers/ProjectBoardController';
|
import { ArrowLeft, GripVertical, ListTodo, Plus } from 'lucide-vue-next';
|
||||||
import Heading from '@/components/Heading.vue';
|
import { computed, nextTick, ref, watch } from 'vue';
|
||||||
|
import { move } from '@/actions/App/Http/Controllers/ProjectBoardController';
|
||||||
|
import FeedbackState from '@/components/FeedbackState.vue';
|
||||||
|
import FormFeedback from '@/components/FormFeedback.vue';
|
||||||
|
import InputError from '@/components/InputError.vue';
|
||||||
|
import { TicketCard } from '@/components/tickets';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import {
|
||||||
Card,
|
Dialog,
|
||||||
CardContent,
|
DialogContent,
|
||||||
CardDescription,
|
DialogDescription,
|
||||||
CardHeader,
|
DialogFooter,
|
||||||
CardTitle,
|
DialogHeader,
|
||||||
} from '@/components/ui/card';
|
DialogTitle,
|
||||||
|
} from '@/components/ui/dialog';
|
||||||
|
import { useBoardDrag } from '@/composables/useBoardDrag';
|
||||||
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
import AppLayout from '@/layouts/AppLayout.vue';
|
import AppLayout from '@/layouts/AppLayout.vue';
|
||||||
|
import { ticketStatusLabel } from '@/lib/tickets';
|
||||||
import { index as backlogIndex } from '@/routes/projects/backlog';
|
import { index as backlogIndex } from '@/routes/projects/backlog';
|
||||||
import { index as projectIndex, show } from '@/routes/projects/index';
|
|
||||||
import { board as boardSettings } from '@/routes/projects/settings';
|
|
||||||
import { index as boardIndex } from '@/routes/projects/board';
|
import { index as boardIndex } from '@/routes/projects/board';
|
||||||
import {
|
import { index as projectIndex, show } from '@/routes/projects/index';
|
||||||
create as createTicket,
|
import { create as createTicket } from '@/routes/projects/tickets';
|
||||||
show as showTicket,
|
|
||||||
} from '@/routes/projects/tickets';
|
|
||||||
import type { BreadcrumbItem, ProjectBoardPageProps } from '@/types';
|
import type { BreadcrumbItem, ProjectBoardPageProps } from '@/types';
|
||||||
import type { TicketModel } from '@/types/models/ticket-model';
|
import type { TicketModel } from '@/types/models/ticket-model';
|
||||||
import type { TicketStatusModel } from '@/types/models/ticket-status-model';
|
|
||||||
|
|
||||||
const props = defineProps<ProjectBoardPageProps>();
|
const props = defineProps<ProjectBoardPageProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
const breadcrumbs: BreadcrumbItem[] = [
|
const breadcrumbs = computed<BreadcrumbItem[]>(() => [
|
||||||
{
|
{ title: t('navigation.projects'), href: projectIndex() },
|
||||||
title: 'Projects',
|
{ title: props.project.name, href: show(props.project.id) },
|
||||||
href: projectIndex(),
|
{ title: t('navigation.board'), href: boardIndex(props.project.id) },
|
||||||
|
]);
|
||||||
|
const selectedColumnId = ref<number>();
|
||||||
|
watch(
|
||||||
|
() =>
|
||||||
|
[
|
||||||
|
props.project.id,
|
||||||
|
props.boardColumns.map((column) => column.id),
|
||||||
|
] as const,
|
||||||
|
([projectId, columnIds], previous) => {
|
||||||
|
if (
|
||||||
|
projectId !== previous?.[0] ||
|
||||||
|
!columnIds.includes(selectedColumnId.value ?? -1)
|
||||||
|
) {
|
||||||
|
selectedColumnId.value = columnIds[0];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{ immediate: true },
|
||||||
title: props.project.name,
|
);
|
||||||
href: show(props.project.id),
|
const columns = computed(() =>
|
||||||
},
|
props.boardColumns.map((column) => {
|
||||||
{
|
const ticketsByStatus = new Map<number | null, TicketModel[]>();
|
||||||
title: 'Board',
|
for (const ticket of column.tickets ?? []) {
|
||||||
href: boardIndex(props.project.id),
|
const tickets = ticketsByStatus.get(ticket.ticket_status_id) ?? [];
|
||||||
},
|
tickets.push(ticket);
|
||||||
];
|
ticketsByStatus.set(ticket.ticket_status_id, tickets);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...column,
|
||||||
|
count: column.tickets?.length ?? 0,
|
||||||
|
groups: (column.ticket_statuses ?? []).map((status) => ({
|
||||||
|
status,
|
||||||
|
tickets: ticketsByStatus.get(status.id) ?? [],
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const ticketCount = computed(() =>
|
||||||
|
columns.value.reduce((count, column) => count + column.count, 0),
|
||||||
|
);
|
||||||
|
const allowedTargetStatuses = (ticket: TicketModel) =>
|
||||||
|
(ticket.ticket_status?.allowed_target_statuses ?? []).filter(
|
||||||
|
(status) => status.id !== ticket.ticket_status_id,
|
||||||
|
);
|
||||||
|
|
||||||
const ticketStatusLabel = (ticketStatus: TicketStatusModel | null): string => {
|
const moveForm = useForm({ ticket_status_id: 0, redirect_to: 'board' });
|
||||||
if (ticketStatus === null) {
|
const feedback = useFormProtection(moveForm, { isDirty: () => false });
|
||||||
return 'Unknown status';
|
const menuPending = ref<number | null>(null);
|
||||||
}
|
const busy = computed(() => moveForm.processing || menuPending.value !== null);
|
||||||
|
const choice = ref<{ ticketId: number; columnId: number } | null>(null);
|
||||||
if (
|
const lastMove = ref<{ ticketId: number; statusId: number } | null>(null);
|
||||||
ticketStatus.board_column === null ||
|
const findTicket = (id: number) =>
|
||||||
ticketStatus.board_column === undefined
|
props.boardColumns
|
||||||
) {
|
.flatMap((column) => column.tickets ?? [])
|
||||||
return ticketStatus.name;
|
.find((ticket) => ticket.id === id);
|
||||||
}
|
const targetsForColumn = (ticket: TicketModel, columnId: number) => {
|
||||||
|
const statusIds =
|
||||||
if (ticketStatus.board_column.name === ticketStatus.name) {
|
props.boardColumns
|
||||||
return ticketStatus.name;
|
.find((column) => column.id === columnId)
|
||||||
}
|
?.ticket_statuses?.map((status) => status.id) ?? [];
|
||||||
|
return allowedTargetStatuses(ticket).filter((status) =>
|
||||||
return `${ticketStatus.board_column.name} / ${ticketStatus.name}`;
|
statusIds.includes(status.id),
|
||||||
};
|
|
||||||
|
|
||||||
const allowedTargetStatuses = (ticket: TicketModel): TicketStatusModel[] => {
|
|
||||||
return (ticket.ticket_status?.allowed_target_statuses ?? []).filter(
|
|
||||||
(ticketStatus) => ticketStatus.id !== ticket.ticket_status_id,
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const choiceTicket = computed(() =>
|
||||||
|
choice.value ? findTicket(choice.value.ticketId) : undefined,
|
||||||
|
);
|
||||||
|
const choiceTargets = computed(() =>
|
||||||
|
choice.value && choiceTicket.value
|
||||||
|
? targetsForColumn(choiceTicket.value, choice.value.columnId)
|
||||||
|
: [],
|
||||||
|
);
|
||||||
|
const choiceOpen = computed({
|
||||||
|
get: () => choice.value !== null,
|
||||||
|
set: (open: boolean) => {
|
||||||
|
if (!open) {
|
||||||
|
choice.value = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function submitMove(ticketId: number, statusId: number): void {
|
||||||
|
const ticket = findTicket(ticketId);
|
||||||
|
if (
|
||||||
|
busy.value ||
|
||||||
|
!props.canEditTickets ||
|
||||||
|
!ticket ||
|
||||||
|
!allowedTargetStatuses(ticket).some((status) => status.id === statusId)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastMove.value = { ticketId, statusId };
|
||||||
|
moveForm.ticket_status_id = statusId;
|
||||||
|
moveForm.clearErrors();
|
||||||
|
feedback.submit(move({ project: props.project.id, ticket: ticketId }), {
|
||||||
|
errorBag: `board-ticket-${ticketId}`,
|
||||||
|
preserveScroll: true,
|
||||||
|
onSuccess: async () => {
|
||||||
|
const destination = props.boardColumns.find((column) =>
|
||||||
|
column.ticket_statuses?.some(
|
||||||
|
(status) => status.id === statusId,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if (destination) {
|
||||||
|
selectedColumnId.value = destination.id;
|
||||||
|
}
|
||||||
|
await nextTick();
|
||||||
|
document
|
||||||
|
.getElementById(`ticket-status-${ticketId}`)
|
||||||
|
?.focus({ preventScroll: true });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropTicket(ticket: TicketModel, columnId: number): void {
|
||||||
|
const current = findTicket(ticket.id);
|
||||||
|
if (!current || busy.value || !props.canEditTickets) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const targets = targetsForColumn(current, columnId);
|
||||||
|
if (targets.length === 1) {
|
||||||
|
submitMove(current.id, targets[0].id);
|
||||||
|
} else if (targets.length > 1) {
|
||||||
|
moveForm.ticket_status_id = targets[0].id;
|
||||||
|
choice.value = { ticketId: current.id, columnId };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
draggedTicket,
|
||||||
|
columnId: dropColumnId,
|
||||||
|
x: dragX,
|
||||||
|
y: dragY,
|
||||||
|
start: startDrag,
|
||||||
|
cancel: cancelDrag,
|
||||||
|
} = useBoardDrag({
|
||||||
|
canStart: (ticket) =>
|
||||||
|
props.canEditTickets &&
|
||||||
|
!busy.value &&
|
||||||
|
!choice.value &&
|
||||||
|
allowedTargetStatuses(ticket).length > 0,
|
||||||
|
drop: dropTicket,
|
||||||
|
});
|
||||||
|
const canDrop = (columnId: number) =>
|
||||||
|
!!draggedTicket.value &&
|
||||||
|
targetsForColumn(draggedTicket.value, columnId).length > 0;
|
||||||
|
const dropClasses = (columnId: number) =>
|
||||||
|
!draggedTicket.value
|
||||||
|
? {}
|
||||||
|
: {
|
||||||
|
'border-primary border-dashed': canDrop(columnId),
|
||||||
|
'ring-2 ring-primary bg-primary/10':
|
||||||
|
canDrop(columnId) && dropColumnId.value === columnId,
|
||||||
|
'opacity-40': !canDrop(columnId),
|
||||||
|
};
|
||||||
|
function confirmMove(): void {
|
||||||
|
if (
|
||||||
|
!choice.value ||
|
||||||
|
!choiceTargets.value.some(
|
||||||
|
(status) => status.id === moveForm.ticket_status_id,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ticketId = choice.value.ticketId;
|
||||||
|
choice.value = null;
|
||||||
|
submitMove(ticketId, moveForm.ticket_status_id);
|
||||||
|
}
|
||||||
|
function focusStatus(ticketId: number): void {
|
||||||
|
document.getElementById(`ticket-status-${ticketId}`)?.focus();
|
||||||
|
}
|
||||||
|
watch(
|
||||||
|
() => [props.project.id, props.boardColumns, props.canEditTickets],
|
||||||
|
() => {
|
||||||
|
cancelDrag();
|
||||||
|
choice.value = null;
|
||||||
|
},
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout :breadcrumbs="breadcrumbs">
|
<AppLayout :breadcrumbs="breadcrumbs">
|
||||||
<Head :title="`${project.name} board`" />
|
<Head :title="t('board.title', { name: project.name })" />
|
||||||
|
|
||||||
<div class="flex flex-1 flex-col gap-6 p-4">
|
<div class="gap-column md:p-page flex min-w-0 flex-1 flex-col p-4">
|
||||||
<div
|
<header
|
||||||
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
class="flex min-w-0 flex-col gap-4 xl:flex-row xl:items-start xl:justify-between"
|
||||||
>
|
>
|
||||||
<div class="space-y-3">
|
<div class="grid min-w-0 gap-2">
|
||||||
<Badge variant="outline" class="px-3 py-1">
|
<div class="flex min-w-0 flex-wrap items-center gap-3">
|
||||||
{{ project.key }}
|
<Badge
|
||||||
</Badge>
|
variant="outline"
|
||||||
<Heading
|
class="wrap-anywhere max-w-full whitespace-normal"
|
||||||
:title="`${project.name} board`"
|
>{{ project.key }}</Badge
|
||||||
description="Tickets only appear here once they are assigned to one of the project's workflow columns."
|
>
|
||||||
/>
|
<p class="text-caption text-muted-foreground">
|
||||||
|
{{ t('tickets.count', { count: ticketCount }) }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<h1
|
||||||
|
class="text-headline-mobile md:text-headline wrap-anywhere"
|
||||||
|
>
|
||||||
|
{{ t('board.title', { name: project.name }) }}
|
||||||
|
</h1>
|
||||||
|
<p class="text-caption text-muted-foreground max-w-2xl">
|
||||||
|
{{ t('board.description') }}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-wrap gap-2">
|
||||||
<div class="flex flex-wrap gap-3">
|
|
||||||
<Button v-if="canCreateTickets" as-child>
|
<Button v-if="canCreateTickets" as-child>
|
||||||
<Link
|
<Link
|
||||||
:href="
|
:href="
|
||||||
@@ -95,245 +252,427 @@ const allowedTargetStatuses = (ticket: TicketModel): TicketStatusModel[] => {
|
|||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
Create ticket
|
<Plus aria-hidden="true" />{{
|
||||||
|
t('navigation.createTicket')
|
||||||
|
}}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Button as-child variant="outline">
|
<Button as-child variant="outline">
|
||||||
<Link :href="backlogIndex(project.id)"
|
<Link :href="backlogIndex(project.id)"
|
||||||
>Open backlog</Link
|
><ListTodo aria-hidden="true" />{{
|
||||||
|
t('board.openBacklog')
|
||||||
|
}}</Link
|
||||||
>
|
>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button as-child variant="ghost">
|
||||||
<Button as-child variant="outline">
|
<Link :href="show(project.id)"
|
||||||
<Link :href="show(project.id)">Back to project</Link>
|
><ArrowLeft aria-hidden="true" />{{
|
||||||
|
t('board.backToProject')
|
||||||
|
}}</Link
|
||||||
|
>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</header>
|
||||||
|
|
||||||
<div
|
<FeedbackState v-if="status" state="success" :title="status" />
|
||||||
v-if="status"
|
<FormFeedback
|
||||||
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="feedback.state.value"
|
||||||
>
|
:description="moveForm.errors.ticket_status_id"
|
||||||
{{ status }}
|
@retry="
|
||||||
</div>
|
lastMove && submitMove(lastMove.ticketId, lastMove.statusId)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<FeedbackState
|
||||||
|
v-if="columns.length === 0"
|
||||||
|
state="empty"
|
||||||
|
:title="t('board.empty.title')"
|
||||||
|
:description="t('board.empty.description')"
|
||||||
|
/>
|
||||||
|
|
||||||
<Card v-if="boardColumns.length === 0">
|
<template v-else>
|
||||||
<CardContent class="flex flex-col gap-4 p-6 text-sm">
|
<div class="grid min-w-0 gap-2 md:hidden">
|
||||||
<p class="text-muted-foreground">
|
<label for="board-column" class="text-body font-semibold">{{
|
||||||
The board has no workflow columns yet, so no tickets can
|
t('board.selectColumn')
|
||||||
appear here.
|
}}</label>
|
||||||
</p>
|
<select
|
||||||
<div v-if="canEditTickets">
|
id="board-column"
|
||||||
<Button as-child variant="outline">
|
v-model="selectedColumnId"
|
||||||
<Link :href="boardSettings(project.id)">
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full min-w-0 rounded-md border px-3 py-2 focus-visible:outline-none focus-visible:ring-2"
|
||||||
Open board settings
|
:aria-controls="`board-column-${selectedColumnId}`"
|
||||||
</Link>
|
>
|
||||||
</Button>
|
<option
|
||||||
</div>
|
v-for="column in columns"
|
||||||
</CardContent>
|
:key="column.id"
|
||||||
</Card>
|
:value="column.id"
|
||||||
|
|
||||||
<div v-else class="grid gap-4 xl:grid-cols-3">
|
|
||||||
<Card
|
|
||||||
v-for="boardColumn in boardColumns"
|
|
||||||
:key="boardColumn.id"
|
|
||||||
class="flex h-full flex-col gap-0 overflow-hidden"
|
|
||||||
>
|
|
||||||
<CardHeader class="bg-muted/20 border-b">
|
|
||||||
<div class="flex items-start justify-between gap-3">
|
|
||||||
<div>
|
|
||||||
<CardTitle>{{ boardColumn.name }}</CardTitle>
|
|
||||||
<CardDescription>
|
|
||||||
{{ boardColumn.tickets?.length ?? 0 }}
|
|
||||||
active ticket(s)
|
|
||||||
</CardDescription>
|
|
||||||
<div
|
|
||||||
v-if="
|
|
||||||
(boardColumn.ticket_statuses?.length ??
|
|
||||||
0) > 0
|
|
||||||
"
|
|
||||||
class="mt-3 flex flex-wrap gap-2"
|
|
||||||
>
|
|
||||||
<Badge
|
|
||||||
v-for="ticketStatus in boardColumn.ticket_statuses"
|
|
||||||
:key="ticketStatus.id"
|
|
||||||
variant="outline"
|
|
||||||
>
|
|
||||||
{{ ticketStatus.name }}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Badge variant="secondary">
|
|
||||||
#{{ boardColumn.position }}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
</CardHeader>
|
|
||||||
|
|
||||||
<CardContent class="flex flex-1 flex-col gap-4 p-4">
|
|
||||||
<div
|
|
||||||
v-if="(boardColumn.tickets?.length ?? 0) === 0"
|
|
||||||
class="border-border text-muted-foreground rounded-xl border border-dashed px-4 py-6 text-sm"
|
|
||||||
>
|
>
|
||||||
No tickets are currently in this column.
|
{{
|
||||||
</div>
|
t('board.columnOption', {
|
||||||
|
name: column.name,
|
||||||
<div v-else class="flex flex-col gap-4">
|
count: column.count,
|
||||||
<Card
|
})
|
||||||
v-for="ticket in boardColumn.tickets"
|
}}
|
||||||
:key="ticket.id"
|
</option>
|
||||||
:class="[
|
</select>
|
||||||
'gap-0',
|
</div>
|
||||||
ticket.is_blocked
|
<p
|
||||||
? 'border-amber-300 bg-amber-50/70 dark:border-amber-700/60 dark:bg-amber-950/30'
|
id="board-scroll-hint"
|
||||||
: '',
|
class="text-caption text-muted-foreground hidden md:block"
|
||||||
]"
|
>
|
||||||
|
{{ t('board.scrollHint') }}
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
v-if="canEditTickets"
|
||||||
|
id="board-drag-hint"
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ t('board.dragHint') }}
|
||||||
|
</p>
|
||||||
|
<section
|
||||||
|
:aria-label="t('board.columns')"
|
||||||
|
aria-describedby="board-scroll-hint"
|
||||||
|
tabindex="0"
|
||||||
|
data-board-drag-scroll
|
||||||
|
class="gap-column focus-visible:ring-ring/35 flex min-w-0 rounded-md pb-2 focus-visible:outline-none focus-visible:ring-2 md:overflow-x-auto md:overscroll-x-contain"
|
||||||
|
>
|
||||||
|
<section
|
||||||
|
v-for="column in columns"
|
||||||
|
:id="`board-column-${column.id}`"
|
||||||
|
:key="`${project.id}-${column.id}`"
|
||||||
|
:aria-labelledby="`board-column-title-${column.id}`"
|
||||||
|
:data-board-drop-column="column.id"
|
||||||
|
:class="[
|
||||||
|
'bg-muted/40 gap-column w-full min-w-0 shrink-0 flex-col self-stretch rounded-md border p-3 md:flex md:w-80',
|
||||||
|
selectedColumnId === column.id ? 'flex' : 'hidden',
|
||||||
|
dropClasses(column.id),
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<header
|
||||||
|
class="border-primary/25 flex min-w-0 items-start justify-between gap-3 border-b-2 pb-3"
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
:id="`board-column-title-${column.id}`"
|
||||||
|
class="text-title wrap-anywhere"
|
||||||
>
|
>
|
||||||
<CardHeader class="pb-4">
|
{{ column.name }}
|
||||||
<div class="flex flex-wrap gap-2">
|
</h2>
|
||||||
<Badge variant="outline">
|
<Badge
|
||||||
{{ ticket.ticket_key }}
|
variant="secondary"
|
||||||
</Badge>
|
class="shrink-0 tabular-nums"
|
||||||
<Badge
|
:aria-label="
|
||||||
v-if="ticket.is_blocked"
|
t('tickets.count', { count: column.count })
|
||||||
variant="destructive"
|
"
|
||||||
>
|
>{{ column.count }}</Badge
|
||||||
Blocked
|
>
|
||||||
</Badge>
|
</header>
|
||||||
<Badge variant="secondary">
|
<p
|
||||||
{{ ticket.ticket_type.name }}
|
v-if="column.count === 0"
|
||||||
</Badge>
|
class="text-caption text-muted-foreground rounded-md border border-dashed p-3"
|
||||||
<Badge variant="secondary">
|
>
|
||||||
{{ ticket.ticket_priority.name }}
|
{{ t('board.emptyColumn') }}
|
||||||
</Badge>
|
</p>
|
||||||
<Badge variant="outline">
|
<p
|
||||||
{{
|
v-if="column.groups.length === 0"
|
||||||
ticketStatusLabel(
|
class="text-caption text-muted-foreground"
|
||||||
ticket.ticket_status,
|
>
|
||||||
)
|
{{ t('board.noStatuses') }}
|
||||||
}}
|
</p>
|
||||||
</Badge>
|
<section
|
||||||
</div>
|
v-for="group in column.groups"
|
||||||
<CardTitle class="text-base">
|
:key="group.status.id"
|
||||||
<Link
|
:aria-labelledby="`board-status-${group.status.id}`"
|
||||||
:href="
|
class="grid min-w-0 gap-3"
|
||||||
showTicket({
|
>
|
||||||
project: project.id,
|
<div
|
||||||
ticket: ticket.id,
|
class="text-caption text-muted-foreground flex min-w-0 items-center justify-between gap-2"
|
||||||
})
|
>
|
||||||
"
|
<h3
|
||||||
class="hover:text-primary transition"
|
:id="`board-status-${group.status.id}`"
|
||||||
>
|
class="wrap-anywhere font-semibold"
|
||||||
{{ ticket.title }}
|
>
|
||||||
</Link>
|
{{ group.status.name }}
|
||||||
</CardTitle>
|
</h3>
|
||||||
<CardDescription
|
<span
|
||||||
v-if="ticket.description"
|
class="shrink-0 tabular-nums"
|
||||||
class="line-clamp-3"
|
:aria-label="
|
||||||
|
t('tickets.count', {
|
||||||
|
count: group.tickets.length,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
>{{ group.tickets.length }}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<p
|
||||||
|
v-if="group.tickets.length === 0"
|
||||||
|
class="text-caption text-muted-foreground border-border rounded-md border border-dashed p-3"
|
||||||
|
>
|
||||||
|
{{ t('board.emptyStatus') }}
|
||||||
|
</p>
|
||||||
|
<ul v-else class="grid min-w-0 gap-3">
|
||||||
|
<li
|
||||||
|
v-for="ticket in group.tickets"
|
||||||
|
:key="ticket.id"
|
||||||
|
class="min-w-0"
|
||||||
|
:class="{
|
||||||
|
'opacity-50':
|
||||||
|
draggedTicket?.id === ticket.id,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<TicketCard
|
||||||
|
:project-id="project.id"
|
||||||
|
:ticket="ticket"
|
||||||
|
:show-status="false"
|
||||||
>
|
>
|
||||||
{{ ticket.description }}
|
<template
|
||||||
</CardDescription>
|
v-if="canEditTickets"
|
||||||
<CardDescription
|
#actions
|
||||||
v-if="
|
|
||||||
ticket.is_blocked &&
|
|
||||||
ticket.blocked_comment
|
|
||||||
"
|
|
||||||
class="mt-2 text-amber-900 dark:text-amber-200"
|
|
||||||
>
|
|
||||||
{{ ticket.blocked_comment }}
|
|
||||||
</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
|
|
||||||
<CardContent v-if="canEditTickets" class="pt-0">
|
|
||||||
<Form
|
|
||||||
v-bind="
|
|
||||||
ProjectBoardController.move.form({
|
|
||||||
project: project.id,
|
|
||||||
ticket: ticket.id,
|
|
||||||
})
|
|
||||||
"
|
|
||||||
class="flex flex-col gap-2"
|
|
||||||
v-slot="{ processing }"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
type="hidden"
|
|
||||||
name="redirect_to"
|
|
||||||
value="board"
|
|
||||||
/>
|
|
||||||
<label
|
|
||||||
:for="`ticket-status-${ticket.id}`"
|
|
||||||
class="text-muted-foreground text-xs font-medium uppercase tracking-wide"
|
|
||||||
>
|
>
|
||||||
Move ticket
|
<Button
|
||||||
</label>
|
type="button"
|
||||||
<div
|
variant="ghost"
|
||||||
class="flex flex-col gap-2 sm:flex-row"
|
class="mb-2 w-full cursor-grab touch-none select-none active:cursor-grabbing"
|
||||||
>
|
|
||||||
<select
|
|
||||||
:id="`ticket-status-${ticket.id}`"
|
|
||||||
name="ticket_status_id"
|
|
||||||
:disabled="
|
:disabled="
|
||||||
|
busy ||
|
||||||
allowedTargetStatuses(
|
allowedTargetStatuses(
|
||||||
ticket,
|
ticket,
|
||||||
).length === 0 || processing
|
).length === 0
|
||||||
"
|
"
|
||||||
class="border-input bg-background shadow-xs focus-visible:border-ring focus-visible:ring-ring/50 min-w-44 rounded-md border px-3 py-2 text-sm outline-none transition-[color,box-shadow] focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-60"
|
:aria-label="
|
||||||
|
t('board.dragTicket', {
|
||||||
|
key: ticket.ticket_key,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
aria-describedby="board-drag-hint"
|
||||||
|
@pointerdown="
|
||||||
|
startDrag($event, ticket)
|
||||||
|
"
|
||||||
|
@click.prevent
|
||||||
|
@keydown.enter.prevent="
|
||||||
|
focusStatus(ticket.id)
|
||||||
|
"
|
||||||
|
@keydown.space.prevent="
|
||||||
|
focusStatus(ticket.id)
|
||||||
|
"
|
||||||
|
><GripVertical
|
||||||
|
aria-hidden="true"
|
||||||
|
/>{{ t('board.drag') }}</Button
|
||||||
>
|
>
|
||||||
<option
|
<Form
|
||||||
|
v-bind="
|
||||||
|
move.form({
|
||||||
|
project: project.id,
|
||||||
|
ticket: ticket.id,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
v-slot="{ processing, errors }"
|
||||||
|
:error-bag="`board-ticket-${ticket.id}`"
|
||||||
|
:options="{
|
||||||
|
preserveScroll: true,
|
||||||
|
}"
|
||||||
|
:on-before="
|
||||||
|
() =>
|
||||||
|
!busy && !draggedTicket
|
||||||
|
"
|
||||||
|
@start="menuPending = ticket.id"
|
||||||
|
@finish="menuPending = null"
|
||||||
|
class="grid min-w-0 gap-2"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="hidden"
|
||||||
|
name="redirect_to"
|
||||||
|
value="board"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
:for="`ticket-status-${ticket.id}`"
|
||||||
|
class="text-caption text-muted-foreground font-semibold"
|
||||||
|
>{{
|
||||||
|
t('board.moveTicket', {
|
||||||
|
key: ticket.ticket_key,
|
||||||
|
})
|
||||||
|
}}</label
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
:id="`ticket-status-${ticket.id}`"
|
||||||
|
name="ticket_status_id"
|
||||||
|
:disabled="
|
||||||
|
busy ||
|
||||||
|
processing ||
|
||||||
|
allowedTargetStatuses(
|
||||||
|
ticket,
|
||||||
|
).length === 0
|
||||||
|
"
|
||||||
|
:aria-invalid="
|
||||||
|
!!errors.ticket_status_id ||
|
||||||
|
undefined
|
||||||
|
"
|
||||||
|
:aria-describedby="
|
||||||
|
errors.ticket_status_id
|
||||||
|
? `ticket-status-error-${ticket.id}`
|
||||||
|
: undefined
|
||||||
|
"
|
||||||
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full min-w-0 rounded-md border px-3 py-2 focus-visible:outline-none focus-visible:ring-2 disabled:cursor-not-allowed disabled:opacity-60"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-if="
|
||||||
|
allowedTargetStatuses(
|
||||||
|
ticket,
|
||||||
|
).length === 0
|
||||||
|
"
|
||||||
|
value=""
|
||||||
|
>
|
||||||
|
{{ t('board.noMoves') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="target in allowedTargetStatuses(
|
||||||
|
ticket,
|
||||||
|
)"
|
||||||
|
:key="target.id"
|
||||||
|
:value="target.id"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
ticketStatusLabel(
|
||||||
|
target,
|
||||||
|
t(
|
||||||
|
'tickets.noStatus',
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<InputError
|
||||||
|
:id="`ticket-status-error-${ticket.id}`"
|
||||||
|
:message="
|
||||||
|
errors.ticket_status_id
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
variant="outline"
|
||||||
|
:disabled="
|
||||||
|
busy ||
|
||||||
|
processing ||
|
||||||
|
allowedTargetStatuses(
|
||||||
|
ticket,
|
||||||
|
).length === 0
|
||||||
|
"
|
||||||
|
>{{
|
||||||
|
t(
|
||||||
|
processing
|
||||||
|
? 'board.updatingStatus'
|
||||||
|
: 'board.updateStatus',
|
||||||
|
)
|
||||||
|
}}</Button
|
||||||
|
>
|
||||||
|
<p
|
||||||
v-if="
|
v-if="
|
||||||
allowedTargetStatuses(
|
allowedTargetStatuses(
|
||||||
ticket,
|
ticket,
|
||||||
).length === 0
|
).length === 0
|
||||||
"
|
"
|
||||||
value=""
|
class="text-caption text-muted-foreground"
|
||||||
>
|
|
||||||
No allowed moves
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="ticketStatus in allowedTargetStatuses(
|
|
||||||
ticket,
|
|
||||||
)"
|
|
||||||
:key="ticketStatus.id"
|
|
||||||
:value="ticketStatus.id"
|
|
||||||
>
|
>
|
||||||
{{
|
{{
|
||||||
ticketStatusLabel(
|
t(
|
||||||
ticketStatus,
|
'board.noMovesDescription',
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
</option>
|
</p>
|
||||||
</select>
|
</Form>
|
||||||
<Button
|
</template>
|
||||||
type="submit"
|
</TicketCard>
|
||||||
size="sm"
|
</li>
|
||||||
:disabled="
|
</ul>
|
||||||
processing ||
|
</section>
|
||||||
allowedTargetStatuses(
|
</section>
|
||||||
ticket,
|
</section>
|
||||||
).length === 0
|
</template>
|
||||||
"
|
<div
|
||||||
>
|
v-if="draggedTicket"
|
||||||
Update status
|
class="bg-card fixed inset-x-0 bottom-0 z-40 border-t p-3 shadow-lg md:hidden"
|
||||||
</Button>
|
data-board-mobile-targets
|
||||||
</div>
|
>
|
||||||
<p
|
<p class="text-caption mb-2 font-semibold">
|
||||||
v-if="
|
{{ t('board.dropHint') }}
|
||||||
allowedTargetStatuses(ticket)
|
</p>
|
||||||
.length === 0
|
<div class="flex gap-2 overflow-x-auto" data-board-drag-scroll>
|
||||||
"
|
<div
|
||||||
class="text-muted-foreground text-xs"
|
v-for="column in columns"
|
||||||
>
|
:key="column.id"
|
||||||
This status does not allow moving
|
:data-board-drop-column="column.id"
|
||||||
anywhere else.
|
:class="dropClasses(column.id)"
|
||||||
</p>
|
class="text-body flex min-h-20 w-36 shrink-0 items-center rounded-md border p-3"
|
||||||
</Form>
|
>
|
||||||
</CardContent>
|
{{ column.name }}
|
||||||
</Card>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="draggedTicket"
|
||||||
|
aria-hidden="true"
|
||||||
|
class="bg-primary text-primary-foreground pointer-events-none fixed z-50 max-w-48 rounded-md px-3 py-2 shadow-lg"
|
||||||
|
:style="{
|
||||||
|
left: `${Math.max(0, dragX - 80)}px`,
|
||||||
|
top: `${Math.max(0, dragY - 56)}px`,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
{{ draggedTicket.ticket_key }}
|
||||||
|
</div>
|
||||||
|
<p class="sr-only" aria-live="polite">
|
||||||
|
{{
|
||||||
|
draggedTicket
|
||||||
|
? t('board.dragging', { key: draggedTicket.ticket_key })
|
||||||
|
: ''
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
<Dialog v-model:open="choiceOpen">
|
||||||
|
<DialogContent>
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{{ t('board.chooseStatus') }}</DialogTitle>
|
||||||
|
<DialogDescription>{{
|
||||||
|
t('board.chooseStatusDescription', {
|
||||||
|
key: choiceTicket?.ticket_key ?? '',
|
||||||
|
})
|
||||||
|
}}</DialogDescription>
|
||||||
|
</DialogHeader>
|
||||||
|
<form class="grid gap-4" @submit.prevent="confirmMove">
|
||||||
|
<label
|
||||||
|
for="board-drop-status"
|
||||||
|
class="text-body font-semibold"
|
||||||
|
>{{ t('board.targetStatus') }}</label
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
id="board-drop-status"
|
||||||
|
v-model="moveForm.ticket_status_id"
|
||||||
|
class="border-input bg-card text-body min-h-control focus-visible:ring-ring/35 w-full rounded-md border px-3 py-2 focus-visible:outline-none focus-visible:ring-2"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="target in choiceTargets"
|
||||||
|
:key="target.id"
|
||||||
|
:value="target.id"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
ticketStatusLabel(
|
||||||
|
target,
|
||||||
|
t('tickets.noStatus'),
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<DialogFooter>
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
@click="choiceOpen = false"
|
||||||
|
>{{ t('common.cancel') }}</Button
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
:disabled="busy || choiceTargets.length === 0"
|
||||||
|
>{{ t('board.updateStatus') }}</Button
|
||||||
|
>
|
||||||
|
</DialogFooter>
|
||||||
|
</form>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,349 +1,633 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Head, Link, useForm } from '@inertiajs/vue3';
|
import { Head, Link, useForm } from '@inertiajs/vue3';
|
||||||
import { computed } from 'vue';
|
|
||||||
import ProjectController from '@/actions/App/Http/Controllers/ProjectController';
|
|
||||||
import Heading from '@/components/Heading.vue';
|
|
||||||
import InputError from '@/components/InputError.vue';
|
|
||||||
import { Button } from '@/components/ui/button';
|
|
||||||
import {
|
import {
|
||||||
Card,
|
ArrowLeft,
|
||||||
CardContent,
|
Check,
|
||||||
CardDescription,
|
Copy,
|
||||||
CardHeader,
|
FolderPlus,
|
||||||
CardTitle,
|
LayoutTemplate,
|
||||||
} from '@/components/ui/card';
|
} from 'lucide-vue-next';
|
||||||
|
import { computed, watch } from 'vue';
|
||||||
|
import { store } 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 { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
import AppLayout from '@/layouts/AppLayout.vue';
|
import AppLayout from '@/layouts/AppLayout.vue';
|
||||||
import { create, index } from '@/routes/projects/index';
|
import { create, index } from '@/routes/projects';
|
||||||
import type { BreadcrumbItem, ProjectsCreatePageProps } from '@/types';
|
import type { BreadcrumbItem, ProjectsCreatePageProps } from '@/types';
|
||||||
|
|
||||||
const props = defineProps<ProjectsCreatePageProps>();
|
const props = defineProps<ProjectsCreatePageProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
const breadcrumbs: BreadcrumbItem[] = [
|
const breadcrumbs = computed<BreadcrumbItem[]>(() => [
|
||||||
{
|
{ title: t('navigation.projects'), href: index() },
|
||||||
title: 'Projects',
|
{ title: t('projects.create'), href: create() },
|
||||||
href: index(),
|
]);
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'New project',
|
|
||||||
href: create(),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const defaultTemplateId =
|
const defaultTemplateId =
|
||||||
props.selectedSourceTemplateId ?? props.sourceTemplates[0]?.id ?? null;
|
props.selectedSourceTemplateId ?? props.sourceTemplates[0]?.id ?? null;
|
||||||
|
const form = useForm(
|
||||||
const form = useForm({
|
`ProjectsCreate:${props.selectedSourceTemplateId ?? 'default'}`,
|
||||||
copy_areas: [] as string[],
|
{
|
||||||
creation_mode: defaultTemplateId !== null ? 'template' : 'scratch',
|
creation_mode: defaultTemplateId !== null ? 'template' : 'scratch',
|
||||||
key: '',
|
name: '',
|
||||||
name: '',
|
key: '',
|
||||||
source_project_id: props.sourceProjects[0]?.id
|
source_project_id: props.sourceProjects[0]?.id
|
||||||
? String(props.sourceProjects[0].id)
|
? String(props.sourceProjects[0].id)
|
||||||
: '',
|
: '',
|
||||||
source_template_id:
|
source_template_id:
|
||||||
defaultTemplateId !== null ? String(defaultTemplateId) : '',
|
defaultTemplateId !== null ? String(defaultTemplateId) : '',
|
||||||
});
|
copy_areas: [] as string[],
|
||||||
|
},
|
||||||
const hasSourceProjects = computed(() => props.sourceProjects.length > 0);
|
);
|
||||||
const hasSourceTemplates = computed(() => props.sourceTemplates.length > 0);
|
const protection = useFormProtection(form);
|
||||||
|
const modes = computed(() => [
|
||||||
const copyAreasError = computed(() => {
|
{
|
||||||
return (
|
value: 'scratch',
|
||||||
|
icon: FolderPlus,
|
||||||
|
title: t('projectCreation.scratch'),
|
||||||
|
description: t('projectCreation.scratchDescription'),
|
||||||
|
disabled: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'duplicate',
|
||||||
|
icon: Copy,
|
||||||
|
title: t('projectCreation.duplicate'),
|
||||||
|
description: t(
|
||||||
|
props.sourceProjects.length
|
||||||
|
? 'projectCreation.duplicateDescription'
|
||||||
|
: 'projectCreation.noProjects',
|
||||||
|
),
|
||||||
|
disabled: props.sourceProjects.length === 0,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'template',
|
||||||
|
icon: LayoutTemplate,
|
||||||
|
title: t('projectCreation.template'),
|
||||||
|
description: t(
|
||||||
|
props.sourceTemplates.length
|
||||||
|
? 'projectCreation.templateDescription'
|
||||||
|
: 'projectCreation.noTemplates',
|
||||||
|
),
|
||||||
|
disabled: props.sourceTemplates.length === 0,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
const areaKeys = {
|
||||||
|
project_settings: 'projectCreation.areas.projectSettings',
|
||||||
|
board_columns: 'projectCreation.areas.boardColumns',
|
||||||
|
ticket_statuses: 'projectCreation.areas.ticketStatuses',
|
||||||
|
status_transitions: 'projectCreation.areas.statusTransitions',
|
||||||
|
ticket_types: 'projectCreation.areas.ticketTypes',
|
||||||
|
ticket_priorities: 'projectCreation.areas.ticketPriorities',
|
||||||
|
ticket_fields: 'projectCreation.areas.ticketFields',
|
||||||
|
ticket_link_types: 'projectCreation.areas.ticketLinkTypes',
|
||||||
|
repository_connections: 'projectCreation.areas.repositories',
|
||||||
|
notification_actions: 'projectCreation.areas.notifications',
|
||||||
|
} as const;
|
||||||
|
function areaText(value: string, part: 'label' | 'description'): string {
|
||||||
|
const key = areaKeys[value as keyof typeof areaKeys];
|
||||||
|
return key
|
||||||
|
? t(`${key}.${part}`)
|
||||||
|
: (props.copyAreaOptions.find((area) => area.value === value)?.[part] ??
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
const selectedProject = computed(() =>
|
||||||
|
props.sourceProjects.find(
|
||||||
|
(project) => String(project.id) === form.source_project_id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const selectedTemplate = computed(() =>
|
||||||
|
props.sourceTemplates.find(
|
||||||
|
(template) => String(template.id) === form.source_template_id,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const selectedMode = computed(() =>
|
||||||
|
modes.value.find((mode) => mode.value === form.creation_mode),
|
||||||
|
);
|
||||||
|
const ticketKey = computed(
|
||||||
|
() => `${form.key.trim().toUpperCase() || 'CORE'}-1`,
|
||||||
|
);
|
||||||
|
const copyAreasError = computed(
|
||||||
|
() =>
|
||||||
form.errors.copy_areas ??
|
form.errors.copy_areas ??
|
||||||
Object.entries(form.errors).find(([key]) =>
|
Object.entries(form.errors).find(([key]) =>
|
||||||
key.startsWith('copy_areas.'),
|
key.startsWith('copy_areas.'),
|
||||||
)?.[1] ??
|
)?.[1],
|
||||||
''
|
);
|
||||||
);
|
const selectClass =
|
||||||
});
|
'border-input bg-card min-h-control w-full min-w-0 rounded-md border px-3 py-2 text-base shadow-xs outline-none hover:border-primary/45 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/35 disabled:opacity-60 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/25 md:text-body';
|
||||||
|
|
||||||
const submit = (): void => {
|
watch(
|
||||||
if (form.creation_mode !== 'duplicate') {
|
() => form.creation_mode,
|
||||||
form.source_project_id = '';
|
() => {
|
||||||
form.copy_areas = [];
|
form.clearErrors(
|
||||||
}
|
'creation_mode',
|
||||||
|
'source_project_id',
|
||||||
|
'source_template_id',
|
||||||
|
'copy_areas',
|
||||||
|
);
|
||||||
|
for (const key of Object.keys(form.errors)) {
|
||||||
|
if (key.startsWith('copy_areas.')) {
|
||||||
|
form.clearErrors(key as 'copy_areas');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protection.clearFeedback();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
if (form.creation_mode !== 'template') {
|
function submit(): void {
|
||||||
form.source_template_id = '';
|
form.transform((data) => ({
|
||||||
}
|
...data,
|
||||||
|
source_project_id:
|
||||||
form.post(ProjectController.store.url(), {
|
data.creation_mode === 'duplicate' ? data.source_project_id : '',
|
||||||
preserveScroll: true,
|
source_template_id:
|
||||||
});
|
data.creation_mode === 'template' ? data.source_template_id : '',
|
||||||
};
|
copy_areas: data.creation_mode === 'duplicate' ? data.copy_areas : [],
|
||||||
|
}));
|
||||||
|
protection.submit(store(), { preserveScroll: true });
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout :breadcrumbs="breadcrumbs">
|
<AppLayout :breadcrumbs="breadcrumbs">
|
||||||
<Head title="New project" />
|
<Head :title="t('projects.create')" />
|
||||||
|
<div
|
||||||
|
class="gap-page md:p-page mx-auto flex w-full min-w-0 max-w-6xl flex-1 flex-col p-4"
|
||||||
|
>
|
||||||
|
<header class="gap-stack grid">
|
||||||
|
<Link
|
||||||
|
:href="index()"
|
||||||
|
class="text-caption text-muted-foreground hover:text-primary mb-2 inline-flex min-h-10 items-center gap-2 justify-self-start"
|
||||||
|
>
|
||||||
|
<ArrowLeft class="size-4" aria-hidden="true" />{{
|
||||||
|
t('projects.back')
|
||||||
|
}}
|
||||||
|
</Link>
|
||||||
|
<p class="text-label text-muted-foreground uppercase">
|
||||||
|
{{ t('projects.workspace') }}
|
||||||
|
</p>
|
||||||
|
<h1 class="text-headline-mobile md:text-headline">
|
||||||
|
{{ t('projectCreation.title') }}
|
||||||
|
</h1>
|
||||||
|
<p class="text-muted-foreground max-w-2xl">
|
||||||
|
{{ t('projectCreation.description') }}
|
||||||
|
</p>
|
||||||
|
</header>
|
||||||
|
|
||||||
<div class="mx-auto flex w-full max-w-3xl flex-1 flex-col gap-6 p-4">
|
<form
|
||||||
<Heading
|
class="gap-page grid min-w-0"
|
||||||
title="Create project"
|
:aria-busy="form.processing"
|
||||||
description="Create a fresh project, duplicate selected settings from an existing project, or start from a saved template."
|
@submit.prevent="submit"
|
||||||
/>
|
>
|
||||||
|
<FormFeedback
|
||||||
<Card>
|
:state="protection.state.value"
|
||||||
<CardHeader>
|
:title="
|
||||||
<CardTitle>Project details</CardTitle>
|
form.processing
|
||||||
<CardDescription>
|
? t('projectCreation.creating')
|
||||||
The key is uppercased automatically, must be unique, and
|
: undefined
|
||||||
can contain up to 5 characters.
|
"
|
||||||
</CardDescription>
|
@retry="submit"
|
||||||
</CardHeader>
|
/>
|
||||||
|
<fieldset
|
||||||
<CardContent>
|
class="gap-column grid min-w-0"
|
||||||
<form class="space-y-6" @submit.prevent="submit">
|
:disabled="form.processing"
|
||||||
<div class="grid gap-3">
|
aria-describedby="creation-mode-error"
|
||||||
<Label>How do you want to start?</Label>
|
>
|
||||||
<div class="grid gap-3 sm:grid-cols-3">
|
<legend class="text-title mb-3">
|
||||||
<Label
|
{{ t('projectCreation.start') }}
|
||||||
class="flex cursor-pointer items-start gap-3 rounded-xl border p-4"
|
</legend>
|
||||||
>
|
<div class="gap-column grid md:grid-cols-3">
|
||||||
<input
|
<label
|
||||||
v-model="form.creation_mode"
|
v-for="mode in modes"
|
||||||
type="radio"
|
:key="mode.value"
|
||||||
value="scratch"
|
class="relative min-w-0"
|
||||||
class="mt-1"
|
|
||||||
/>
|
|
||||||
<div class="space-y-1">
|
|
||||||
<div class="font-medium">
|
|
||||||
Create from scratch
|
|
||||||
</div>
|
|
||||||
<p
|
|
||||||
class="text-muted-foreground text-sm"
|
|
||||||
>
|
|
||||||
Start with the default project
|
|
||||||
setup.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</Label>
|
|
||||||
|
|
||||||
<Label
|
|
||||||
class="flex items-start gap-3 rounded-xl border p-4"
|
|
||||||
:class="
|
|
||||||
hasSourceProjects
|
|
||||||
? 'cursor-pointer'
|
|
||||||
: 'cursor-not-allowed opacity-60'
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
v-model="form.creation_mode"
|
|
||||||
type="radio"
|
|
||||||
value="duplicate"
|
|
||||||
class="mt-1"
|
|
||||||
:disabled="!hasSourceProjects"
|
|
||||||
/>
|
|
||||||
<div class="space-y-1">
|
|
||||||
<div class="font-medium">
|
|
||||||
Create from existing project
|
|
||||||
</div>
|
|
||||||
<p
|
|
||||||
class="text-muted-foreground text-sm"
|
|
||||||
>
|
|
||||||
Copy only the settings you
|
|
||||||
explicitly select. Tickets are never
|
|
||||||
duplicated.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</Label>
|
|
||||||
|
|
||||||
<Label
|
|
||||||
class="flex items-start gap-3 rounded-xl border p-4"
|
|
||||||
:class="
|
|
||||||
hasSourceTemplates
|
|
||||||
? 'cursor-pointer'
|
|
||||||
: 'cursor-not-allowed opacity-60'
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
v-model="form.creation_mode"
|
|
||||||
type="radio"
|
|
||||||
value="template"
|
|
||||||
class="mt-1"
|
|
||||||
:disabled="!hasSourceTemplates"
|
|
||||||
/>
|
|
||||||
<div class="space-y-1">
|
|
||||||
<div class="font-medium">
|
|
||||||
Create from template
|
|
||||||
</div>
|
|
||||||
<p
|
|
||||||
class="text-muted-foreground text-sm"
|
|
||||||
>
|
|
||||||
Reuse a saved configuration
|
|
||||||
template.
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</Label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label for="name">Project name</Label>
|
|
||||||
<Input
|
|
||||||
id="name"
|
|
||||||
v-model="form.name"
|
|
||||||
required
|
|
||||||
autofocus
|
|
||||||
placeholder="Kanban foundation"
|
|
||||||
/>
|
|
||||||
<InputError :message="form.errors.name" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label for="key">Project key</Label>
|
|
||||||
<Input
|
|
||||||
id="key"
|
|
||||||
v-model="form.key"
|
|
||||||
required
|
|
||||||
maxlength="5"
|
|
||||||
placeholder="CORE"
|
|
||||||
class="uppercase"
|
|
||||||
/>
|
|
||||||
<p class="text-muted-foreground text-sm">
|
|
||||||
Example ticket keys will look like
|
|
||||||
<span class="text-foreground font-medium"
|
|
||||||
>CORE-1</span
|
|
||||||
>.
|
|
||||||
</p>
|
|
||||||
<InputError :message="form.errors.key" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="form.creation_mode === 'duplicate'"
|
|
||||||
class="space-y-6 rounded-xl border border-dashed p-4"
|
|
||||||
>
|
>
|
||||||
<div class="grid gap-2">
|
<input
|
||||||
<Label for="source_project_id"
|
v-model="form.creation_mode"
|
||||||
>Source project</Label
|
type="radio"
|
||||||
|
name="creation_mode"
|
||||||
|
:value="mode.value"
|
||||||
|
:disabled="mode.disabled"
|
||||||
|
:aria-invalid="!!form.errors.creation_mode"
|
||||||
|
:aria-labelledby="`mode-${mode.value}-title`"
|
||||||
|
:aria-describedby="`mode-${mode.value}-description`"
|
||||||
|
class="peer sr-only"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
class="bg-card peer-checked:border-primary peer-checked:bg-accent/50 peer-focus-visible:ring-ring/40 gap-stack flex h-full cursor-pointer flex-col rounded-md border p-4 transition-colors peer-focus-visible:ring-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-60"
|
||||||
|
:class="
|
||||||
|
!mode.disabled
|
||||||
|
? 'hover:border-primary/50'
|
||||||
|
: ''
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="flex items-center justify-between gap-3"
|
||||||
>
|
>
|
||||||
|
<component
|
||||||
|
:is="mode.icon"
|
||||||
|
class="text-primary size-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<Check
|
||||||
|
v-if="form.creation_mode === mode.value"
|
||||||
|
class="text-primary size-4"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
:id="`mode-${mode.value}-title`"
|
||||||
|
class="font-semibold"
|
||||||
|
>{{ mode.title }}</span
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
:id="`mode-${mode.value}-description`"
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>{{ mode.description }}</span
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<InputError
|
||||||
|
id="creation-mode-error"
|
||||||
|
:message="form.errors.creation_mode"
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="gap-page grid min-w-0 lg:grid-cols-[minmax(0,2fr)_minmax(0,1fr)] lg:items-start"
|
||||||
|
>
|
||||||
|
<div class="gap-page grid min-w-0">
|
||||||
|
<section
|
||||||
|
class="bg-card gap-column grid min-w-0 rounded-md border p-5"
|
||||||
|
aria-labelledby="project-details-title"
|
||||||
|
>
|
||||||
|
<h2 id="project-details-title" class="text-title">
|
||||||
|
{{ t('projectCreation.details') }}
|
||||||
|
</h2>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<Label for="name">{{
|
||||||
|
t('projectCreation.name')
|
||||||
|
}}</Label>
|
||||||
|
<Input
|
||||||
|
id="name"
|
||||||
|
v-model="form.name"
|
||||||
|
name="name"
|
||||||
|
required
|
||||||
|
maxlength="255"
|
||||||
|
:disabled="form.processing"
|
||||||
|
:placeholder="
|
||||||
|
t('projectCreation.namePlaceholder')
|
||||||
|
"
|
||||||
|
:invalid="!!form.errors.name"
|
||||||
|
aria-describedby="name-error"
|
||||||
|
/>
|
||||||
|
<InputError
|
||||||
|
id="name-error"
|
||||||
|
:message="form.errors.name"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<Label for="key">{{
|
||||||
|
t('projectCreation.key')
|
||||||
|
}}</Label>
|
||||||
|
<Input
|
||||||
|
id="key"
|
||||||
|
v-model="form.key"
|
||||||
|
name="key"
|
||||||
|
required
|
||||||
|
maxlength="5"
|
||||||
|
:disabled="form.processing"
|
||||||
|
:placeholder="
|
||||||
|
t('projectCreation.keyPlaceholder')
|
||||||
|
"
|
||||||
|
class="uppercase sm:max-w-48"
|
||||||
|
:invalid="!!form.errors.key"
|
||||||
|
aria-describedby="key-help key-error"
|
||||||
|
autocapitalize="characters"
|
||||||
|
:spellcheck="false"
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
id="key-help"
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ t('projectCreation.keyHelp') }}
|
||||||
|
</p>
|
||||||
|
<InputError
|
||||||
|
id="key-error"
|
||||||
|
:message="form.errors.key"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section
|
||||||
|
v-if="form.creation_mode === 'duplicate'"
|
||||||
|
class="bg-card gap-column grid min-w-0 rounded-md border p-5"
|
||||||
|
aria-labelledby="copy-title"
|
||||||
|
>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<h2 id="copy-title" class="text-title">
|
||||||
|
{{ t('projectCreation.copyTitle') }}
|
||||||
|
</h2>
|
||||||
|
<p class="text-caption text-muted-foreground">
|
||||||
|
{{ t('projectCreation.copyHelp') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="gap-stack grid min-w-0">
|
||||||
|
<Label for="source_project_id">{{
|
||||||
|
t('projectCreation.sourceProject')
|
||||||
|
}}</Label>
|
||||||
<select
|
<select
|
||||||
id="source_project_id"
|
id="source_project_id"
|
||||||
v-model="form.source_project_id"
|
v-model="form.source_project_id"
|
||||||
class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
required
|
||||||
:disabled="!hasSourceProjects"
|
:class="selectClass"
|
||||||
|
:disabled="form.processing"
|
||||||
|
:aria-invalid="
|
||||||
|
!!form.errors.source_project_id
|
||||||
|
"
|
||||||
|
aria-describedby="source-project-error"
|
||||||
>
|
>
|
||||||
<option value="">
|
<option value="">
|
||||||
Select a source project
|
{{ t('projectCreation.selectProject') }}
|
||||||
</option>
|
</option>
|
||||||
<option
|
<option
|
||||||
v-for="sourceProject in sourceProjects"
|
v-for="project in sourceProjects"
|
||||||
:key="sourceProject.id"
|
:key="project.id"
|
||||||
:value="String(sourceProject.id)"
|
:value="String(project.id)"
|
||||||
>
|
>
|
||||||
{{ sourceProject.name }} ({{
|
{{ project.name }} ({{ project.key }})
|
||||||
sourceProject.key
|
|
||||||
}})
|
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<p class="text-muted-foreground text-sm">
|
|
||||||
The new project keeps its own identity, key,
|
|
||||||
and future ticket numbering.
|
|
||||||
</p>
|
|
||||||
<InputError
|
<InputError
|
||||||
|
id="source-project-error"
|
||||||
:message="form.errors.source_project_id"
|
:message="form.errors.source_project_id"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<fieldset
|
||||||
<div class="grid gap-3">
|
class="min-w-0"
|
||||||
<div>
|
:disabled="form.processing"
|
||||||
<Label>Copy options</Label>
|
aria-describedby="copy-help copy-areas-error"
|
||||||
<p class="text-muted-foreground text-sm">
|
>
|
||||||
Choose which settings should be copied
|
<legend class="mb-2 font-semibold">
|
||||||
into the new project.
|
{{ t('projectCreation.copyOptions') }}
|
||||||
</p>
|
</legend>
|
||||||
</div>
|
<p
|
||||||
|
id="copy-help"
|
||||||
<div class="grid gap-3">
|
class="text-caption text-muted-foreground mb-3"
|
||||||
<Label
|
>
|
||||||
v-for="copyAreaOption in copyAreaOptions"
|
{{ t('projectCreation.copyDefaults') }}
|
||||||
:key="copyAreaOption.value"
|
</p>
|
||||||
class="flex cursor-pointer items-start gap-3 rounded-xl border p-4"
|
<div class="gap-stack grid sm:grid-cols-2">
|
||||||
|
<label
|
||||||
|
v-for="area in copyAreaOptions"
|
||||||
|
:key="area.value"
|
||||||
|
class="hover:border-primary/45 has-checked:border-primary has-checked:bg-accent/50 flex min-h-11 cursor-pointer items-start gap-3 rounded-md border p-3 transition-colors"
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
v-model="form.copy_areas"
|
v-model="form.copy_areas"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
:value="copyAreaOption.value"
|
:value="area.value"
|
||||||
class="mt-1"
|
:aria-labelledby="`copy-${area.value}-label`"
|
||||||
|
:aria-describedby="`copy-${area.value}-description copy-areas-error`"
|
||||||
|
:aria-invalid="!!copyAreasError"
|
||||||
|
class="accent-primary mt-0.5 size-5 shrink-0"
|
||||||
/>
|
/>
|
||||||
<div class="space-y-1">
|
<span class="gap-stack grid min-w-0">
|
||||||
<div class="font-medium">
|
<span
|
||||||
{{ copyAreaOption.label }}
|
:id="`copy-${area.value}-label`"
|
||||||
</div>
|
class="text-body font-semibold"
|
||||||
<p
|
>{{
|
||||||
class="text-muted-foreground text-sm"
|
areaText(
|
||||||
|
area.value,
|
||||||
|
'label',
|
||||||
|
)
|
||||||
|
}}</span
|
||||||
>
|
>
|
||||||
{{ copyAreaOption.description }}
|
<span
|
||||||
</p>
|
:id="`copy-${area.value}-description`"
|
||||||
</div>
|
class="text-caption text-muted-foreground"
|
||||||
</Label>
|
>{{
|
||||||
|
areaText(
|
||||||
|
area.value,
|
||||||
|
'description',
|
||||||
|
)
|
||||||
|
}}</span
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<InputError
|
||||||
|
id="copy-areas-error"
|
||||||
|
class="mt-3"
|
||||||
|
:message="copyAreasError"
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
|
</section>
|
||||||
|
|
||||||
<p class="text-muted-foreground text-sm">
|
<section
|
||||||
Operational ticket data is always left
|
|
||||||
behind so the new project starts clean.
|
|
||||||
</p>
|
|
||||||
<InputError :message="copyAreasError" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-else-if="form.creation_mode === 'template'"
|
v-else-if="form.creation_mode === 'template'"
|
||||||
class="space-y-4 rounded-xl border border-dashed p-4"
|
class="bg-card gap-column grid min-w-0 rounded-md border p-5"
|
||||||
|
aria-labelledby="template-title"
|
||||||
>
|
>
|
||||||
<div class="grid gap-2">
|
<h2 id="template-title" class="text-title">
|
||||||
<Label for="source_template_id">Template</Label>
|
{{ t('projectCreation.chooseTemplate') }}
|
||||||
|
</h2>
|
||||||
|
<div class="gap-stack grid min-w-0">
|
||||||
|
<Label for="source_template_id">{{
|
||||||
|
t('projectCreation.templateLabel')
|
||||||
|
}}</Label>
|
||||||
<select
|
<select
|
||||||
id="source_template_id"
|
id="source_template_id"
|
||||||
v-model="form.source_template_id"
|
v-model="form.source_template_id"
|
||||||
class="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
required
|
||||||
:disabled="!hasSourceTemplates"
|
:class="selectClass"
|
||||||
|
:disabled="form.processing"
|
||||||
|
:aria-invalid="
|
||||||
|
!!form.errors.source_template_id
|
||||||
|
"
|
||||||
|
aria-describedby="template-help source-template-error"
|
||||||
>
|
>
|
||||||
<option value="">Select a template</option>
|
<option value="">
|
||||||
|
{{
|
||||||
|
t('projectCreation.selectTemplate')
|
||||||
|
}}
|
||||||
|
</option>
|
||||||
<option
|
<option
|
||||||
v-for="sourceTemplate in sourceTemplates"
|
v-for="template in sourceTemplates"
|
||||||
:key="sourceTemplate.id"
|
:key="template.id"
|
||||||
:value="String(sourceTemplate.id)"
|
:value="String(template.id)"
|
||||||
>
|
>
|
||||||
{{ sourceTemplate.name }} ({{
|
{{ template.name }} ({{
|
||||||
sourceTemplate.slug
|
template.slug
|
||||||
}})
|
}})
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<p class="text-muted-foreground text-sm">
|
<p
|
||||||
Templates apply their saved configuration
|
id="template-help"
|
||||||
groups to the new project.
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ t('projectCreation.templateHelp') }}
|
||||||
</p>
|
</p>
|
||||||
<InputError
|
<InputError
|
||||||
|
id="source-template-error"
|
||||||
:message="form.errors.source_template_id"
|
:message="form.errors.source_template_id"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div
|
||||||
|
v-if="selectedTemplate"
|
||||||
|
class="gap-stack grid"
|
||||||
|
aria-live="polite"
|
||||||
|
>
|
||||||
|
<h3 class="text-body font-semibold">
|
||||||
|
{{ t('projectCreation.includedAreas') }}
|
||||||
|
</h3>
|
||||||
|
<ul
|
||||||
|
v-if="selectedTemplate.copy_areas.length"
|
||||||
|
class="flex flex-wrap gap-2"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
v-for="area in selectedTemplate.copy_areas"
|
||||||
|
:key="area"
|
||||||
|
>
|
||||||
|
<Badge
|
||||||
|
variant="secondary"
|
||||||
|
class="whitespace-normal"
|
||||||
|
>{{
|
||||||
|
areaText(area, 'label')
|
||||||
|
}}</Badge
|
||||||
|
>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p
|
||||||
|
v-else
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ t('projectCreation.templateDefaults') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div
|
<aside
|
||||||
v-else-if="
|
class="bg-card gap-column grid min-w-0 rounded-md border p-5"
|
||||||
!hasSourceProjects && !hasSourceTemplates
|
aria-labelledby="summary-title"
|
||||||
"
|
>
|
||||||
class="text-muted-foreground text-sm"
|
<h2 id="summary-title" class="text-title">
|
||||||
|
{{ t('projectCreation.summary') }}
|
||||||
|
</h2>
|
||||||
|
<dl class="gap-column grid min-w-0">
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<dt class="text-caption text-muted-foreground">
|
||||||
|
{{ t('projectCreation.name') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="break-words font-semibold">
|
||||||
|
{{
|
||||||
|
form.name.trim() ||
|
||||||
|
t('projectCreation.untitled')
|
||||||
|
}}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<dt class="text-caption text-muted-foreground">
|
||||||
|
{{ t('projectCreation.ticketPreview') }}
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<Badge variant="outline">{{
|
||||||
|
ticketKey
|
||||||
|
}}</Badge>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<dt class="text-caption text-muted-foreground">
|
||||||
|
{{ t('projectCreation.setup') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="break-words">
|
||||||
|
{{ selectedMode?.title }}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="form.creation_mode === 'duplicate'"
|
||||||
|
class="gap-stack grid"
|
||||||
|
>
|
||||||
|
<dt class="text-caption text-muted-foreground">
|
||||||
|
{{ t('projectCreation.sourceProject') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="break-words">
|
||||||
|
{{
|
||||||
|
selectedProject?.name ||
|
||||||
|
t('projectCreation.selectProject')
|
||||||
|
}}
|
||||||
|
</dd>
|
||||||
|
<dd class="text-caption text-muted-foreground">
|
||||||
|
{{
|
||||||
|
t('projectCreation.selectedCount', {
|
||||||
|
count: form.copy_areas.length,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else-if="form.creation_mode === 'template'"
|
||||||
|
class="gap-stack grid"
|
||||||
|
>
|
||||||
|
<dt class="text-caption text-muted-foreground">
|
||||||
|
{{ t('projectCreation.templateLabel') }}
|
||||||
|
</dt>
|
||||||
|
<dd class="break-words">
|
||||||
|
{{
|
||||||
|
selectedTemplate?.name ||
|
||||||
|
t('projectCreation.selectTemplate')
|
||||||
|
}}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
<p
|
||||||
|
class="text-caption text-muted-foreground border-t pt-4"
|
||||||
>
|
>
|
||||||
No accessible source projects or saved templates are
|
{{ t('projectCreation.cleanStart') }}
|
||||||
available yet.
|
</p>
|
||||||
</div>
|
</aside>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-3">
|
<footer
|
||||||
<Button type="submit" :disabled="form.processing">
|
class="flex flex-col-reverse gap-3 border-t pt-5 sm:flex-row sm:items-center sm:justify-end"
|
||||||
Create project
|
>
|
||||||
</Button>
|
<Button
|
||||||
|
as-child
|
||||||
<Button as-child variant="outline">
|
variant="outline"
|
||||||
<Link :href="index()">Cancel</Link>
|
:disabled="form.processing"
|
||||||
</Button>
|
><Link :href="index()">{{
|
||||||
</div>
|
t('common.cancel')
|
||||||
</form>
|
}}</Link></Button
|
||||||
</CardContent>
|
>
|
||||||
</Card>
|
<Button
|
||||||
|
type="submit"
|
||||||
|
:loading="form.processing"
|
||||||
|
:aria-label="
|
||||||
|
t(
|
||||||
|
form.processing
|
||||||
|
? 'projectCreation.creating'
|
||||||
|
: 'projectCreation.submit',
|
||||||
|
)
|
||||||
|
"
|
||||||
|
:loading-label="t('projectCreation.creating')"
|
||||||
|
><FolderPlus
|
||||||
|
v-if="!form.processing"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>{{
|
||||||
|
t(
|
||||||
|
form.processing
|
||||||
|
? 'projectCreation.creating'
|
||||||
|
: 'projectCreation.submit',
|
||||||
|
)
|
||||||
|
}}</Button
|
||||||
|
>
|
||||||
|
</footer>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,103 +1,184 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Head, Link } from '@inertiajs/vue3';
|
import { Head, Link } from '@inertiajs/vue3';
|
||||||
import { Folder, Plus } from 'lucide-vue-next';
|
import {
|
||||||
import Heading from '@/components/Heading.vue';
|
ArrowUpRight,
|
||||||
|
Columns3,
|
||||||
|
FolderGit2,
|
||||||
|
ListTodo,
|
||||||
|
Plus,
|
||||||
|
} from 'lucide-vue-next';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
import FeedbackState from '@/components/FeedbackState.vue';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from '@/components/ui/card';
|
|
||||||
import AppLayout from '@/layouts/AppLayout.vue';
|
import AppLayout from '@/layouts/AppLayout.vue';
|
||||||
import { create, index, show } from '@/routes/projects/index';
|
import { create, index, show } from '@/routes/projects';
|
||||||
|
import { index as backlogIndex } from '@/routes/projects/backlog';
|
||||||
|
import { index as boardIndex } from '@/routes/projects/board';
|
||||||
import type { BreadcrumbItem, ProjectsIndexPageProps } from '@/types';
|
import type { BreadcrumbItem, ProjectsIndexPageProps } from '@/types';
|
||||||
|
|
||||||
defineProps<ProjectsIndexPageProps>();
|
defineProps<ProjectsIndexPageProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
const breadcrumbs: BreadcrumbItem[] = [
|
const breadcrumbs = computed<BreadcrumbItem[]>(() => [
|
||||||
{
|
{ title: t('navigation.projects'), href: index() },
|
||||||
title: 'Projects',
|
]);
|
||||||
href: index(),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout :breadcrumbs="breadcrumbs">
|
<AppLayout :breadcrumbs="breadcrumbs">
|
||||||
<Head title="Projects" />
|
<Head :title="t('navigation.projects')" />
|
||||||
|
|
||||||
<div class="flex flex-1 flex-col gap-6 p-4">
|
<div class="gap-page md:p-page flex min-w-0 flex-1 flex-col p-4">
|
||||||
<div
|
<header
|
||||||
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
||||||
>
|
>
|
||||||
<Heading
|
<div class="gap-stack grid min-w-0">
|
||||||
title="Projects"
|
<p class="text-label text-muted-foreground uppercase">
|
||||||
description="Create and browse project spaces that will later host boards, backlog, and settings."
|
{{ t('projects.workspace') }}
|
||||||
/>
|
</p>
|
||||||
|
<h1 class="text-headline-mobile md:text-headline">
|
||||||
|
{{ t('navigation.projects') }}
|
||||||
|
</h1>
|
||||||
|
<p class="text-muted-foreground max-w-2xl">
|
||||||
|
{{ t('projects.description') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<Button
|
<Button
|
||||||
v-if="$page.props.auth.permissions.projectCreate"
|
v-if="$page.props.auth.permissions.projectCreate"
|
||||||
as-child
|
as-child
|
||||||
|
class="self-start"
|
||||||
>
|
>
|
||||||
<Link :href="create()">
|
<Link :href="create()"
|
||||||
<Plus class="size-4" />
|
><Plus aria-hidden="true" />{{
|
||||||
New project
|
t('projects.create')
|
||||||
</Link>
|
}}</Link
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
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"
|
|
||||||
>
|
|
||||||
{{ status }}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="projects.length === 0"
|
|
||||||
class="text-muted-foreground rounded-xl border border-dashed px-6 py-10 text-center text-sm"
|
|
||||||
>
|
|
||||||
No projects exist yet. Create the first one to start building
|
|
||||||
out board, backlog, and settings areas.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div v-else class="grid gap-4 md:grid-cols-2 xl:grid-cols-3">
|
|
||||||
<Link
|
|
||||||
v-for="project in projects"
|
|
||||||
:key="project.id"
|
|
||||||
:href="show(project.id)"
|
|
||||||
class="group block"
|
|
||||||
>
|
|
||||||
<Card
|
|
||||||
class="border-border/80 group-hover:border-primary/40 h-full transition-colors"
|
|
||||||
>
|
>
|
||||||
<CardHeader class="gap-3">
|
</Button>
|
||||||
<div class="flex items-start justify-between gap-3">
|
</header>
|
||||||
<div class="space-y-1">
|
|
||||||
<CardTitle>{{ project.name }}</CardTitle>
|
|
||||||
<CardDescription>
|
|
||||||
Project workspace entry point
|
|
||||||
</CardDescription>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Badge variant="outline" class="px-2.5 py-1">
|
<FeedbackState
|
||||||
{{ project.key }}
|
v-if="status"
|
||||||
</Badge>
|
state="success"
|
||||||
</div>
|
:title="t('projects.updated')"
|
||||||
</CardHeader>
|
:description="status"
|
||||||
|
/>
|
||||||
|
|
||||||
<CardContent
|
<FeedbackState
|
||||||
class="text-muted-foreground flex items-center gap-2 text-sm"
|
v-if="projects.length === 0"
|
||||||
|
state="empty"
|
||||||
|
:title="t('projects.empty.title')"
|
||||||
|
:description="
|
||||||
|
$page.props.auth.permissions.projectCreate
|
||||||
|
? t('projects.empty.createDescription')
|
||||||
|
: t('projects.empty.accessDescription')
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
v-if="$page.props.auth.permissions.projectCreate"
|
||||||
|
as-child
|
||||||
|
variant="outline"
|
||||||
|
>
|
||||||
|
<Link :href="create()"
|
||||||
|
><Plus aria-hidden="true" />{{
|
||||||
|
t('projects.empty.create')
|
||||||
|
}}</Link
|
||||||
|
>
|
||||||
|
</Button>
|
||||||
|
</FeedbackState>
|
||||||
|
|
||||||
|
<section
|
||||||
|
v-else
|
||||||
|
aria-labelledby="project-list-title"
|
||||||
|
class="gap-column grid"
|
||||||
|
>
|
||||||
|
<h2
|
||||||
|
id="project-list-title"
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>
|
||||||
|
{{ t('projects.available', { count: projects.length }) }}
|
||||||
|
</h2>
|
||||||
|
<ul class="gap-column grid md:grid-cols-2 xl:grid-cols-3">
|
||||||
|
<li
|
||||||
|
v-for="project in projects"
|
||||||
|
:key="project.id"
|
||||||
|
class="min-w-0"
|
||||||
|
>
|
||||||
|
<article
|
||||||
|
class="bg-card text-card-foreground flex h-full min-w-0 flex-col rounded-md border"
|
||||||
>
|
>
|
||||||
<Folder class="size-4" />
|
<Link
|
||||||
Open board, backlog, and settings hub
|
:href="show(project.id)"
|
||||||
</CardContent>
|
:aria-label="
|
||||||
</Card>
|
t('projects.open', { name: project.name })
|
||||||
</Link>
|
"
|
||||||
</div>
|
class="gap-column hover:bg-accent/50 group flex min-w-0 flex-1 items-start rounded-t-md p-5 transition-colors"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="bg-accent text-primary flex size-11 shrink-0 items-center justify-center rounded-md"
|
||||||
|
>
|
||||||
|
<FolderGit2
|
||||||
|
class="size-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<div class="gap-stack grid min-w-0 flex-1">
|
||||||
|
<Badge
|
||||||
|
variant="outline"
|
||||||
|
class="max-w-full justify-self-start whitespace-normal break-all"
|
||||||
|
>{{ project.key }}</Badge
|
||||||
|
>
|
||||||
|
<h3
|
||||||
|
class="text-title group-hover:text-primary break-words"
|
||||||
|
>
|
||||||
|
{{ project.name }}
|
||||||
|
</h3>
|
||||||
|
<span
|
||||||
|
class="text-caption text-muted-foreground"
|
||||||
|
>{{ t('projects.overview') }}</span
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<ArrowUpRight
|
||||||
|
class="text-muted-foreground mt-1 size-4 shrink-0"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
<div
|
||||||
|
class="gap-stack p-card grid grid-cols-2 border-t"
|
||||||
|
>
|
||||||
|
<Button as-child variant="secondary">
|
||||||
|
<Link
|
||||||
|
:href="boardIndex(project.id)"
|
||||||
|
:aria-label="
|
||||||
|
t('projects.openBoard', {
|
||||||
|
name: project.name,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<Columns3 aria-hidden="true" />{{
|
||||||
|
t('navigation.board')
|
||||||
|
}}
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
<Button as-child variant="ghost">
|
||||||
|
<Link
|
||||||
|
:href="backlogIndex(project.id)"
|
||||||
|
:aria-label="
|
||||||
|
t('projects.openBacklog', {
|
||||||
|
name: project.name,
|
||||||
|
})
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<ListTodo aria-hidden="true" />{{
|
||||||
|
t('navigation.backlog')
|
||||||
|
}}
|
||||||
|
</Link>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,206 +1,227 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Head, Link } from '@inertiajs/vue3';
|
import { Head, Link } from '@inertiajs/vue3';
|
||||||
import { FolderGit2, LayoutGrid, ListTodo, Settings2 } from 'lucide-vue-next';
|
import {
|
||||||
import Heading from '@/components/Heading.vue';
|
ArrowLeft,
|
||||||
|
ArrowRight,
|
||||||
|
Columns3,
|
||||||
|
Layers3,
|
||||||
|
ListTodo,
|
||||||
|
} from 'lucide-vue-next';
|
||||||
|
import { computed } from 'vue';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import {
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle,
|
|
||||||
} from '@/components/ui/card';
|
|
||||||
import AppLayout from '@/layouts/AppLayout.vue';
|
import AppLayout from '@/layouts/AppLayout.vue';
|
||||||
import { access, index, show } from '@/routes/projects/index';
|
import { projectSettingsNavigation } from '@/lib/navigation';
|
||||||
import { index as boardIndex } from '@/routes/projects/board';
|
import { index, show } from '@/routes/projects';
|
||||||
import { index as backlogIndex } from '@/routes/projects/backlog';
|
import { index as backlogIndex } from '@/routes/projects/backlog';
|
||||||
import {
|
import { index as boardIndex } from '@/routes/projects/board';
|
||||||
board as boardSettings,
|
|
||||||
general as generalSettings,
|
|
||||||
metadata as metadataSettings,
|
|
||||||
notifications as notificationSettings,
|
|
||||||
repositories as repositorySettings,
|
|
||||||
} from '@/routes/projects/settings';
|
|
||||||
import { create as projectTemplateCreate } from '@/routes/projects/templates';
|
import { create as projectTemplateCreate } from '@/routes/projects/templates';
|
||||||
import type { BreadcrumbItem, ProjectShowPageProps } from '@/types';
|
import type { BreadcrumbItem, ProjectShowPageProps } from '@/types';
|
||||||
|
|
||||||
const props = defineProps<ProjectShowPageProps>();
|
const props = defineProps<ProjectShowPageProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
const breadcrumbs: BreadcrumbItem[] = [
|
const breadcrumbs = computed<BreadcrumbItem[]>(() => [
|
||||||
|
{ title: t('navigation.projects'), href: index() },
|
||||||
|
{ title: props.project.name, href: show(props.project.id) },
|
||||||
|
]);
|
||||||
|
const projectAreas = computed(() => [
|
||||||
{
|
{
|
||||||
title: 'Projects',
|
title: t('navigation.board'),
|
||||||
href: index(),
|
description: t('projects.boardDescription'),
|
||||||
|
action: t('projects.boardAction'),
|
||||||
|
href: boardIndex(props.project.id),
|
||||||
|
icon: Columns3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: props.project.name,
|
title: t('navigation.backlog'),
|
||||||
href: show(props.project.id),
|
description: t('projects.backlogDescription'),
|
||||||
},
|
action: t('projects.backlogAction'),
|
||||||
];
|
href: backlogIndex(props.project.id),
|
||||||
|
|
||||||
const projectAreas = [
|
|
||||||
{
|
|
||||||
title: 'Backlog',
|
|
||||||
description:
|
|
||||||
'Create tickets, review incoming work, and move ready items into the board workflow.',
|
|
||||||
icon: ListTodo,
|
icon: ListTodo,
|
||||||
},
|
},
|
||||||
{
|
]);
|
||||||
title: 'Board',
|
const settingsItems = computed(() =>
|
||||||
description:
|
projectSettingsNavigation(
|
||||||
'Track active work across the project-defined Kanban columns and update ticket status.',
|
{
|
||||||
icon: LayoutGrid,
|
id: props.project.id,
|
||||||
},
|
name: props.project.name,
|
||||||
{
|
key: props.project.key,
|
||||||
title: 'Project settings',
|
canManage: props.canManageAccess,
|
||||||
description:
|
canCreateTickets: false,
|
||||||
'Manage board columns, ticket metadata, and the project-specific workflow configuration.',
|
},
|
||||||
icon: Settings2,
|
t,
|
||||||
},
|
),
|
||||||
{
|
);
|
||||||
title: 'Repositories',
|
|
||||||
description:
|
|
||||||
'Link project repositories so tickets can later discover related branches and pull requests.',
|
|
||||||
icon: FolderGit2,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout :breadcrumbs="breadcrumbs">
|
<AppLayout :breadcrumbs="breadcrumbs">
|
||||||
<Head :title="project.name" />
|
<Head :title="project.name" />
|
||||||
|
|
||||||
<div class="flex flex-1 flex-col gap-6 p-4">
|
<div class="gap-page md:p-page flex min-w-0 flex-1 flex-col p-4">
|
||||||
<div
|
<Link
|
||||||
|
:href="index()"
|
||||||
|
class="text-caption text-muted-foreground hover:text-primary min-h-control inline-flex items-center gap-2 self-start rounded-md"
|
||||||
|
>
|
||||||
|
<ArrowLeft class="size-4" aria-hidden="true" />{{
|
||||||
|
t('projects.back')
|
||||||
|
}}
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<header
|
||||||
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
||||||
>
|
>
|
||||||
<div class="space-y-3">
|
<div class="gap-stack grid min-w-0">
|
||||||
<Badge variant="outline" class="px-3 py-1">
|
<Badge
|
||||||
{{ project.key }}
|
|
||||||
</Badge>
|
|
||||||
<Heading
|
|
||||||
:title="project.name"
|
|
||||||
description="Project hub for the upcoming backlog, board, and settings work."
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex flex-wrap gap-3">
|
|
||||||
<Button as-child variant="outline">
|
|
||||||
<Link :href="boardIndex(project.id)">Open board</Link>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button as-child variant="outline">
|
|
||||||
<Link :href="backlogIndex(project.id)">
|
|
||||||
Open backlog
|
|
||||||
</Link>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
v-if="$page.props.auth.permissions.projectCreate"
|
|
||||||
as-child
|
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
class="max-w-full justify-self-start whitespace-normal break-all"
|
||||||
|
>{{ project.key }}</Badge
|
||||||
>
|
>
|
||||||
<Link :href="projectTemplateCreate(project.id)">
|
<h1
|
||||||
Save as new template
|
class="text-headline-mobile md:text-headline break-words"
|
||||||
</Link>
|
>
|
||||||
</Button>
|
{{ project.name }}
|
||||||
|
</h1>
|
||||||
<Button as-child variant="outline">
|
<p class="text-muted-foreground max-w-2xl">
|
||||||
<Link :href="index()">Back to projects</Link>
|
{{ t('projects.hubDescription') }}
|
||||||
</Button>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<Button
|
||||||
|
v-if="$page.props.auth.permissions.projectCreate"
|
||||||
|
as-child
|
||||||
|
variant="outline"
|
||||||
|
class="self-start"
|
||||||
|
>
|
||||||
|
<Link :href="projectTemplateCreate(project.id)"
|
||||||
|
><Layers3 aria-hidden="true" />{{
|
||||||
|
t('projects.saveTemplate')
|
||||||
|
}}</Link
|
||||||
|
>
|
||||||
|
</Button>
|
||||||
|
</header>
|
||||||
|
|
||||||
<Card v-if="templateState?.inheritsFromTemplate">
|
<section
|
||||||
<CardHeader>
|
:aria-label="t('projects.workAreas')"
|
||||||
<CardTitle>
|
class="gap-column grid md:grid-cols-2"
|
||||||
Built from template {{ templateState.templateName }}
|
>
|
||||||
</CardTitle>
|
<Link
|
||||||
<CardDescription>
|
v-for="area in projectAreas"
|
||||||
This project keeps its template link. Inherited areas
|
:key="area.href.url"
|
||||||
follow the template baseline; overridden areas were
|
:href="area.href"
|
||||||
customized locally.
|
:aria-label="area.action"
|
||||||
</CardDescription>
|
class="gap-column bg-card hover:border-primary/50 hover:shadow-card-hover group flex min-w-0 flex-col rounded-md border p-5 transition-[border-color,box-shadow]"
|
||||||
</CardHeader>
|
>
|
||||||
<CardContent class="flex flex-wrap gap-2">
|
<span
|
||||||
|
class="bg-accent text-primary flex size-11 items-center justify-center rounded-md"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="area.icon"
|
||||||
|
class="size-5"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<h2 class="text-title">{{ area.title }}</h2>
|
||||||
|
<p class="text-muted-foreground">
|
||||||
|
{{ area.description }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
class="text-primary mt-auto flex items-center gap-2 pt-2 font-semibold"
|
||||||
|
>
|
||||||
|
{{ area.action
|
||||||
|
}}<ArrowRight class="size-4" aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
</Link>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section
|
||||||
|
v-if="settingsItems.length"
|
||||||
|
aria-labelledby="project-settings-title"
|
||||||
|
class="gap-column grid"
|
||||||
|
>
|
||||||
|
<div class="gap-stack grid">
|
||||||
|
<h2 id="project-settings-title" class="text-title">
|
||||||
|
{{ t('navigation.projectSettings') }}
|
||||||
|
</h2>
|
||||||
|
<p class="text-muted-foreground">
|
||||||
|
{{ t('projects.settingsDescription') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<ul class="gap-stack grid sm:grid-cols-2 xl:grid-cols-3">
|
||||||
|
<li
|
||||||
|
v-for="item in settingsItems"
|
||||||
|
:key="item.title"
|
||||||
|
class="min-w-0"
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
:href="item.href"
|
||||||
|
class="gap-card bg-card hover:bg-accent hover:text-accent-foreground min-h-control flex h-full items-center rounded-md border p-4 transition-colors"
|
||||||
|
>
|
||||||
|
<component
|
||||||
|
:is="item.icon"
|
||||||
|
class="text-muted-foreground size-4 shrink-0"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
class="min-w-0 flex-1 break-words font-medium"
|
||||||
|
>{{ item.title }}</span
|
||||||
|
>
|
||||||
|
<ArrowRight
|
||||||
|
class="text-muted-foreground size-4 shrink-0"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section
|
||||||
|
v-if="templateState?.inheritsFromTemplate"
|
||||||
|
aria-labelledby="project-template-title"
|
||||||
|
class="gap-column bg-card flex min-w-0 flex-col rounded-md border p-5"
|
||||||
|
>
|
||||||
|
<div class="gap-card flex items-start">
|
||||||
|
<Layers3
|
||||||
|
class="text-muted-foreground mt-0.5 size-5 shrink-0"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<div class="gap-stack grid min-w-0">
|
||||||
|
<h2
|
||||||
|
id="project-template-title"
|
||||||
|
class="text-title break-words"
|
||||||
|
>
|
||||||
|
{{
|
||||||
|
t('projects.templateTitle', {
|
||||||
|
name: templateState.templateName,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</h2>
|
||||||
|
<p class="text-muted-foreground">
|
||||||
|
{{ t('projects.templateDescription') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="gap-stack flex flex-wrap">
|
||||||
<Badge
|
<Badge
|
||||||
v-for="area in templateState.inheritedAreas"
|
v-for="area in templateState.inheritedAreas"
|
||||||
:key="`inherited-${area.value}`"
|
:key="`inherited-${area.value}`"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
|
class="max-w-full whitespace-normal break-words"
|
||||||
>
|
>
|
||||||
{{ area.label }} · inherited
|
{{ t('projects.inheritedArea', { name: area.label }) }}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Badge
|
<Badge
|
||||||
v-for="area in templateState.overriddenAreas"
|
v-for="area in templateState.overriddenAreas"
|
||||||
:key="`overridden-${area.value}`"
|
:key="`overridden-${area.value}`"
|
||||||
|
variant="secondary"
|
||||||
|
class="max-w-full whitespace-normal break-words"
|
||||||
>
|
>
|
||||||
{{ area.label }} · overridden
|
{{ t('projects.overriddenArea', { name: area.label }) }}
|
||||||
</Badge>
|
</Badge>
|
||||||
</CardContent>
|
</div>
|
||||||
</Card>
|
</section>
|
||||||
|
|
||||||
<div v-if="canManageAccess" class="flex flex-wrap gap-3">
|
|
||||||
<Button as-child>
|
|
||||||
<Link :href="boardSettings(project.id)">
|
|
||||||
Board settings
|
|
||||||
</Link>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<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="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="access(project.id)">Manage access</Link>
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-4 md:grid-cols-3">
|
|
||||||
<Card
|
|
||||||
v-for="area in projectAreas"
|
|
||||||
:key="area.title"
|
|
||||||
class="h-full"
|
|
||||||
>
|
|
||||||
<CardHeader>
|
|
||||||
<div
|
|
||||||
class="bg-muted text-foreground mb-3 flex size-10 items-center justify-center rounded-full"
|
|
||||||
>
|
|
||||||
<component :is="area.icon" class="size-5" />
|
|
||||||
</div>
|
|
||||||
<CardTitle>{{ area.title }}</CardTitle>
|
|
||||||
<CardDescription>{{
|
|
||||||
area.description
|
|
||||||
}}</CardDescription>
|
|
||||||
</CardHeader>
|
|
||||||
<CardContent class="text-muted-foreground text-sm">
|
|
||||||
Use the project shortcuts above to open this area.
|
|
||||||
</CardContent>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { Head, Link, useForm, useRemember } from '@inertiajs/vue3';
|
import { Head, Link, useForm } from '@inertiajs/vue3';
|
||||||
import { computed, toRef, unref } from 'vue';
|
import { useSessionStorage } from '@vueuse/core';
|
||||||
|
import { computed } from 'vue';
|
||||||
import ProjectTicketController from '@/actions/App/Http/Controllers/ProjectTicketController';
|
import ProjectTicketController from '@/actions/App/Http/Controllers/ProjectTicketController';
|
||||||
import Heading from '@/components/Heading.vue';
|
import TicketFormFields from '@/components/tickets/TicketFormFields.vue';
|
||||||
import InputError from '@/components/InputError.vue';
|
import { useLocalization } from '@/composables/useLocalization';
|
||||||
import FormFeedback from '@/components/FormFeedback.vue';
|
import FormFeedback from '@/components/FormFeedback.vue';
|
||||||
import { useFormProtection } from '@/composables/useFormProtection';
|
import { useFormProtection } from '@/composables/useFormProtection';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
@@ -15,32 +16,30 @@ import {
|
|||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from '@/components/ui/card';
|
} from '@/components/ui/card';
|
||||||
import { Input } from '@/components/ui/input';
|
|
||||||
import { Label } from '@/components/ui/label';
|
|
||||||
import AppLayout from '@/layouts/AppLayout.vue';
|
import AppLayout from '@/layouts/AppLayout.vue';
|
||||||
import {
|
import AcceptanceCriteriaChecklist from '@/components/tickets/AcceptanceCriteriaChecklist.vue';
|
||||||
buildAcceptanceCriteria,
|
import type { AcceptanceCriteriaModel } from '@/types/models/acceptance-criteria-model';
|
||||||
parseChecklistLines,
|
|
||||||
} from '@/lib/acceptance-criteria';
|
|
||||||
import { index as backlogIndex } from '@/routes/projects/backlog';
|
import { index as backlogIndex } from '@/routes/projects/backlog';
|
||||||
import { index as boardIndex } from '@/routes/projects/board';
|
import { index as boardIndex } from '@/routes/projects/board';
|
||||||
import { index, show } from '@/routes/projects/index';
|
import { index, show } from '@/routes/projects/index';
|
||||||
import { metadata as metadataSettings } from '@/routes/projects/settings';
|
import { metadata as metadataSettings } from '@/routes/projects/settings';
|
||||||
import type { BreadcrumbItem, ProjectTicketCreatePageProps } from '@/types';
|
import type { BreadcrumbItem, ProjectTicketCreatePageProps } from '@/types';
|
||||||
import type { TicketStatusModel } from '@/types/models/ticket-status-model';
|
|
||||||
|
|
||||||
const props = defineProps<ProjectTicketCreatePageProps>();
|
const props = defineProps<ProjectTicketCreatePageProps>();
|
||||||
|
const { t } = useLocalization();
|
||||||
|
|
||||||
const returnHref =
|
const returnHref =
|
||||||
props.source === 'board'
|
props.source === 'board'
|
||||||
? boardIndex(props.project.id)
|
? boardIndex(props.project.id)
|
||||||
: backlogIndex(props.project.id);
|
: backlogIndex(props.project.id);
|
||||||
const returnLabel =
|
const returnLabel =
|
||||||
props.source === 'board' ? 'Back to board' : 'Back to backlog';
|
props.source === 'board'
|
||||||
|
? t('ticketForm.backToBoard')
|
||||||
|
: t('ticketForm.backToBacklog');
|
||||||
|
|
||||||
const breadcrumbs: BreadcrumbItem[] = [
|
const breadcrumbs: BreadcrumbItem[] = [
|
||||||
{
|
{
|
||||||
title: 'Projects',
|
title: t('navigation.projects'),
|
||||||
href: index(),
|
href: index(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -48,36 +47,31 @@ const breadcrumbs: BreadcrumbItem[] = [
|
|||||||
href: show(props.project.id),
|
href: show(props.project.id),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: props.source === 'board' ? 'Board' : 'Backlog',
|
title:
|
||||||
|
props.source === 'board'
|
||||||
|
? t('navigation.board')
|
||||||
|
: t('navigation.backlog'),
|
||||||
href: returnHref,
|
href: returnHref,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Create ticket',
|
title: t('ticketForm.create'),
|
||||||
href: ProjectTicketController.create({
|
href: ProjectTicketController.create({
|
||||||
project: props.project.id,
|
project: props.project.id,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const hasTicketMetadata =
|
const hasTicketMetadata = computed(
|
||||||
props.ticketTypes.length > 0 &&
|
() =>
|
||||||
props.ticketPriorities.length > 0 &&
|
props.ticketTypes.length > 0 &&
|
||||||
props.ticketStatusOptions.length > 0;
|
props.ticketPriorities.length > 0 &&
|
||||||
|
props.ticketStatusOptions.length > 0,
|
||||||
|
);
|
||||||
|
|
||||||
const draftKey = `projects:${props.project.id}:tickets:create`;
|
const draftKey = `projects:${props.project.id}:tickets:create`;
|
||||||
const acceptanceCriteriaDraft = useRemember(
|
const draftGeneration = useSessionStorage(`${draftKey}:generation`, 0);
|
||||||
{ checklist: '' },
|
const form = useForm(`${draftKey}:${draftGeneration.value}`, {
|
||||||
`${draftKey}:checklist`,
|
acceptance_criteria: [] as AcceptanceCriteriaModel,
|
||||||
);
|
|
||||||
const acceptanceCriteriaChecklist = toRef(
|
|
||||||
unref(acceptanceCriteriaDraft),
|
|
||||||
'checklist',
|
|
||||||
);
|
|
||||||
|
|
||||||
const form = useForm(draftKey, {
|
|
||||||
acceptance_criteria: buildAcceptanceCriteria(
|
|
||||||
acceptanceCriteriaChecklist.value,
|
|
||||||
),
|
|
||||||
assignee_user_id: '',
|
assignee_user_id: '',
|
||||||
description: '',
|
description: '',
|
||||||
parent_ticket_id: '',
|
parent_ticket_id: '',
|
||||||
@@ -90,13 +84,16 @@ const form = useForm(draftKey, {
|
|||||||
title: '',
|
title: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const protection = useFormProtection(form, {
|
const isDirty = computed(() => form.isDirty);
|
||||||
isDirty: () => form.isDirty || acceptanceCriteriaChecklist.value !== '',
|
const protection = useFormProtection(form);
|
||||||
});
|
const reset = (): void => {
|
||||||
|
if (form.processing || !protection.confirmLeave()) {
|
||||||
const acceptanceCriteriaPreviewItems = computed(() =>
|
return;
|
||||||
parseChecklistLines(acceptanceCriteriaChecklist.value),
|
}
|
||||||
);
|
form.reset();
|
||||||
|
form.clearErrors();
|
||||||
|
protection.clearFeedback();
|
||||||
|
};
|
||||||
|
|
||||||
const acceptanceCriteriaError = computed(() => {
|
const acceptanceCriteriaError = computed(() => {
|
||||||
return (
|
return (
|
||||||
@@ -109,39 +106,35 @@ const acceptanceCriteriaError = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const submit = (): void => {
|
const submit = (): void => {
|
||||||
form.acceptance_criteria = buildAcceptanceCriteria(
|
if (!hasTicketMetadata.value || form.processing) {
|
||||||
acceptanceCriteriaChecklist.value,
|
return;
|
||||||
);
|
}
|
||||||
|
|
||||||
protection.submit(
|
protection.submit(
|
||||||
ProjectTicketController.store({ project: props.project.id }),
|
ProjectTicketController.store({ project: props.project.id }),
|
||||||
{
|
{
|
||||||
preserveScroll: true,
|
preserveScroll: true,
|
||||||
|
onSuccess: () => {
|
||||||
|
// The source page is unmounted before this callback, so its storage watcher has stopped.
|
||||||
|
window.sessionStorage.setItem(
|
||||||
|
`${draftKey}:generation`,
|
||||||
|
String(draftGeneration.value + 1),
|
||||||
|
);
|
||||||
|
draftGeneration.value++;
|
||||||
|
form.reset();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ticketStatusLabel = (ticketStatus: TicketStatusModel): string => {
|
|
||||||
if (
|
|
||||||
ticketStatus.board_column === null ||
|
|
||||||
ticketStatus.board_column === undefined
|
|
||||||
) {
|
|
||||||
return ticketStatus.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ticketStatus.board_column.name === ticketStatus.name) {
|
|
||||||
return ticketStatus.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return `${ticketStatus.board_column.name} / ${ticketStatus.name}`;
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<AppLayout :breadcrumbs="breadcrumbs">
|
<AppLayout :breadcrumbs="breadcrumbs">
|
||||||
<Head :title="`Create ${project.name} ticket`" />
|
<Head :title="t('ticketForm.pageTitle', { project: project.name })" />
|
||||||
|
|
||||||
<div class="flex flex-1 flex-col gap-6 p-4">
|
<div
|
||||||
|
class="mx-auto flex w-full min-w-0 max-w-5xl flex-1 flex-col gap-6 p-4 sm:p-6 lg:p-8"
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between"
|
||||||
>
|
>
|
||||||
@@ -149,10 +142,16 @@ const ticketStatusLabel = (ticketStatus: TicketStatusModel): string => {
|
|||||||
<Badge variant="outline" class="px-3 py-1">
|
<Badge variant="outline" class="px-3 py-1">
|
||||||
{{ project.key }}
|
{{ project.key }}
|
||||||
</Badge>
|
</Badge>
|
||||||
<Heading
|
<h1 class="text-headline font-semibold tracking-tight">
|
||||||
title="Create ticket"
|
{{ t('ticketForm.create') }}
|
||||||
:description="`Add a ticket to ${project.name}.`"
|
</h1>
|
||||||
/>
|
<p class="text-muted-foreground text-sm">
|
||||||
|
{{
|
||||||
|
t('ticketForm.createDescription', {
|
||||||
|
project: project.name,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-wrap gap-3">
|
<div class="flex flex-wrap gap-3">
|
||||||
@@ -160,7 +159,9 @@ const ticketStatusLabel = (ticketStatus: TicketStatusModel): string => {
|
|||||||
<Link :href="returnHref">{{ returnLabel }}</Link>
|
<Link :href="returnHref">{{ returnLabel }}</Link>
|
||||||
</Button>
|
</Button>
|
||||||
<Button as-child variant="outline">
|
<Button as-child variant="outline">
|
||||||
<Link :href="show(project.id)">Back to project</Link>
|
<Link :href="show(project.id)">{{
|
||||||
|
t('ticketDetail.backToProject')
|
||||||
|
}}</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -174,9 +175,9 @@ const ticketStatusLabel = (ticketStatus: TicketStatusModel): string => {
|
|||||||
|
|
||||||
<Card v-if="hasTicketMetadata">
|
<Card v-if="hasTicketMetadata">
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>Ticket details</CardTitle>
|
<CardTitle>{{ t('ticketForm.details') }}</CardTitle>
|
||||||
<CardDescription>
|
<CardDescription>
|
||||||
The ticket key is assigned after creation.
|
{{ t('ticketForm.keyAssigned') }}
|
||||||
</CardDescription>
|
</CardDescription>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
|
|
||||||
@@ -186,258 +187,58 @@ const ticketStatusLabel = (ticketStatus: TicketStatusModel): string => {
|
|||||||
:state="protection.state.value"
|
:state="protection.state.value"
|
||||||
@retry="submit"
|
@retry="submit"
|
||||||
/>
|
/>
|
||||||
<div class="grid gap-2">
|
<TicketFormFields
|
||||||
<Label for="title">Title</Label>
|
v-model:title="form.title"
|
||||||
<Input
|
v-model:description="form.description"
|
||||||
id="title"
|
v-model:type="form.ticket_type_id"
|
||||||
v-model="form.title"
|
v-model:priority="form.ticket_priority_id"
|
||||||
:invalid="Boolean(form.errors.title)"
|
v-model:status="form.ticket_status_id"
|
||||||
aria-describedby="title-error"
|
v-model:assignee="form.assignee_user_id"
|
||||||
required
|
v-model:parent="form.parent_ticket_id"
|
||||||
autofocus
|
v-model:points="form.story_points"
|
||||||
:disabled="form.processing"
|
:project="project"
|
||||||
placeholder="Implement repository sync"
|
:ticket-types="ticketTypes"
|
||||||
/>
|
:ticket-priorities="ticketPriorities"
|
||||||
<InputError
|
:ticket-status-options="ticketStatusOptions"
|
||||||
id="title-error"
|
:users="users"
|
||||||
:message="form.errors.title"
|
:parent-ticket-options="parentTicketOptions"
|
||||||
/>
|
:errors="form.errors"
|
||||||
</div>
|
:disabled="form.processing"
|
||||||
|
autofocus
|
||||||
<div
|
|
||||||
class="grid gap-6 lg:grid-cols-[minmax(0,1fr)_20rem]"
|
|
||||||
>
|
>
|
||||||
<div class="grid gap-6">
|
<template #content>
|
||||||
<div class="grid gap-2">
|
<AcceptanceCriteriaChecklist
|
||||||
<Label for="description">Description</Label>
|
v-model="form.acceptance_criteria"
|
||||||
<textarea
|
:disabled="form.processing"
|
||||||
id="description"
|
:error="acceptanceCriteriaError"
|
||||||
v-model="form.description"
|
/>
|
||||||
rows="4"
|
</template>
|
||||||
:disabled="form.processing"
|
</TicketFormFields>
|
||||||
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] disabled:cursor-not-allowed disabled:opacity-60"
|
<div
|
||||||
placeholder="Describe the expected behavior and relevant context."
|
class="flex flex-wrap items-center gap-3 border-t pt-5"
|
||||||
/>
|
>
|
||||||
<InputError
|
<Button type="submit" :disabled="form.processing">{{
|
||||||
:message="form.errors.description"
|
form.processing
|
||||||
/>
|
? t('ticketForm.creating')
|
||||||
</div>
|
: t('ticketForm.create')
|
||||||
|
}}</Button>
|
||||||
<div class="grid gap-4">
|
<Button
|
||||||
<div class="grid gap-2">
|
type="button"
|
||||||
<Label
|
variant="outline"
|
||||||
for="acceptance_criteria_checklist"
|
:disabled="form.processing || !isDirty"
|
||||||
>
|
@click="reset"
|
||||||
Acceptance criteria checklist
|
>{{ t('ticketForm.reset') }}</Button
|
||||||
</Label>
|
>
|
||||||
<textarea
|
<p
|
||||||
id="acceptance_criteria_checklist"
|
role="status"
|
||||||
v-model="
|
class="text-muted-foreground text-sm"
|
||||||
acceptanceCriteriaChecklist
|
>
|
||||||
"
|
{{
|
||||||
rows="6"
|
isDirty
|
||||||
:disabled="form.processing"
|
? t('ticketForm.unsaved')
|
||||||
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] disabled:cursor-not-allowed disabled:opacity-60"
|
: t('ticketForm.ready')
|
||||||
placeholder="[ ] User can sign in [x] Validation is shown for invalid credentials"
|
}}
|
||||||
/>
|
</p>
|
||||||
<p
|
|
||||||
class="text-muted-foreground text-xs"
|
|
||||||
>
|
|
||||||
Use <code>[ ]</code> /
|
|
||||||
<code>[x]</code> for checklist
|
|
||||||
items. Indent with two spaces for
|
|
||||||
nested steps.
|
|
||||||
</p>
|
|
||||||
<InputError
|
|
||||||
:message="acceptanceCriteriaError"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="
|
|
||||||
acceptanceCriteriaPreviewItems.length >
|
|
||||||
0
|
|
||||||
"
|
|
||||||
class="border-border rounded-xl border p-4 text-sm"
|
|
||||||
>
|
|
||||||
<p class="mb-3 font-medium">
|
|
||||||
Checklist preview
|
|
||||||
</p>
|
|
||||||
<ul class="space-y-2">
|
|
||||||
<li
|
|
||||||
v-for="(
|
|
||||||
item, index
|
|
||||||
) in acceptanceCriteriaPreviewItems"
|
|
||||||
:key="index"
|
|
||||||
:style="{
|
|
||||||
marginLeft: `${item.indent * 1.25}rem`,
|
|
||||||
}"
|
|
||||||
class="flex items-start gap-2"
|
|
||||||
>
|
|
||||||
<span class="mt-0.5">{{
|
|
||||||
item.checked ? '☑' : '☐'
|
|
||||||
}}</span>
|
|
||||||
<span>{{ item.text }}</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid h-fit gap-6">
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label for="ticket_type_id">Type</Label>
|
|
||||||
<select
|
|
||||||
id="ticket_type_id"
|
|
||||||
v-model="form.ticket_type_id"
|
|
||||||
:disabled="form.processing"
|
|
||||||
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] disabled:cursor-not-allowed disabled:opacity-60"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="ticketType in ticketTypes"
|
|
||||||
:key="ticketType.id"
|
|
||||||
:value="String(ticketType.id)"
|
|
||||||
>
|
|
||||||
{{ ticketType.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<InputError
|
|
||||||
:message="form.errors.ticket_type_id"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label for="ticket_priority_id">
|
|
||||||
Priority
|
|
||||||
</Label>
|
|
||||||
<select
|
|
||||||
id="ticket_priority_id"
|
|
||||||
v-model="form.ticket_priority_id"
|
|
||||||
:disabled="form.processing"
|
|
||||||
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] disabled:cursor-not-allowed disabled:opacity-60"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="ticketPriority in ticketPriorities"
|
|
||||||
:key="ticketPriority.id"
|
|
||||||
:value="String(ticketPriority.id)"
|
|
||||||
>
|
|
||||||
{{ ticketPriority.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<InputError
|
|
||||||
:message="
|
|
||||||
form.errors.ticket_priority_id
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label for="ticket_status_id">Status</Label>
|
|
||||||
<select
|
|
||||||
id="ticket_status_id"
|
|
||||||
v-model="form.ticket_status_id"
|
|
||||||
:disabled="form.processing"
|
|
||||||
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] disabled:cursor-not-allowed disabled:opacity-60"
|
|
||||||
>
|
|
||||||
<option
|
|
||||||
v-for="ticketStatus in ticketStatusOptions"
|
|
||||||
:key="ticketStatus.id"
|
|
||||||
:value="String(ticketStatus.id)"
|
|
||||||
>
|
|
||||||
{{
|
|
||||||
ticketStatusLabel(ticketStatus)
|
|
||||||
}}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<InputError
|
|
||||||
:message="form.errors.ticket_status_id"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label for="assignee_user_id">
|
|
||||||
Assignee
|
|
||||||
</Label>
|
|
||||||
<select
|
|
||||||
id="assignee_user_id"
|
|
||||||
v-model="form.assignee_user_id"
|
|
||||||
:disabled="form.processing"
|
|
||||||
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] disabled:cursor-not-allowed disabled:opacity-60"
|
|
||||||
>
|
|
||||||
<option value="">Unassigned</option>
|
|
||||||
<option
|
|
||||||
v-for="user in users"
|
|
||||||
:key="user.id"
|
|
||||||
:value="String(user.id)"
|
|
||||||
>
|
|
||||||
{{ user.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<InputError
|
|
||||||
:message="form.errors.assignee_user_id"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid gap-2">
|
|
||||||
<Label for="parent_ticket_id">
|
|
||||||
Parent ticket
|
|
||||||
</Label>
|
|
||||||
<select
|
|
||||||
id="parent_ticket_id"
|
|
||||||
v-model="form.parent_ticket_id"
|
|
||||||
:disabled="form.processing"
|
|
||||||
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] disabled:cursor-not-allowed disabled:opacity-60"
|
|
||||||
>
|
|
||||||
<option value="">
|
|
||||||
No parent ticket
|
|
||||||
</option>
|
|
||||||
<option
|
|
||||||
v-for="parentTicketOption in parentTicketOptions"
|
|
||||||
:key="parentTicketOption.id"
|
|
||||||
:value="
|
|
||||||
String(parentTicketOption.id)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{{
|
|
||||||
`${parentTicketOption.ticket_key} - ${parentTicketOption.title}`
|
|
||||||
}}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
<InputError
|
|
||||||
:message="form.errors.parent_ticket_id"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="project.show_story_points"
|
|
||||||
class="grid gap-2"
|
|
||||||
>
|
|
||||||
<Label for="story_points">
|
|
||||||
Estimated story points
|
|
||||||
</Label>
|
|
||||||
<Input
|
|
||||||
id="story_points"
|
|
||||||
v-model="form.story_points"
|
|
||||||
type="number"
|
|
||||||
step="1"
|
|
||||||
:disabled="form.processing"
|
|
||||||
/>
|
|
||||||
<InputError
|
|
||||||
:message="form.errors.story_points"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="flex flex-wrap items-center gap-3">
|
|
||||||
<Button type="submit" :disabled="form.processing">
|
|
||||||
Create ticket
|
|
||||||
</Button>
|
|
||||||
<Button as-child variant="outline">
|
|
||||||
<Link :href="returnHref">
|
|
||||||
{{ returnLabel }}
|
|
||||||
</Link>
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
@@ -446,13 +247,12 @@ const ticketStatusLabel = (ticketStatus: TicketStatusModel): string => {
|
|||||||
<Card v-else>
|
<Card v-else>
|
||||||
<CardContent class="flex flex-col gap-4 p-6 text-sm">
|
<CardContent class="flex flex-col gap-4 p-6 text-sm">
|
||||||
<p class="text-muted-foreground">
|
<p class="text-muted-foreground">
|
||||||
Ticket creation needs at least one type, one priority,
|
{{ t('ticketForm.metadataRequired') }}
|
||||||
and one status.
|
|
||||||
</p>
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<Button as-child variant="outline">
|
<Button as-child variant="outline">
|
||||||
<Link :href="metadataSettings(project.id)">
|
<Link :href="metadataSettings(project.id)">
|
||||||
Open ticket settings
|
{{ t('ticketForm.openSettings') }}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import type { TicketModel } from '@/types/models/ticket-model';
|
||||||
|
|
||||||
|
export type BacklogAssigneeFilter = '' | 'unassigned' | number;
|
||||||
|
|
||||||
|
export type BacklogFilterState = {
|
||||||
|
assigneeId: BacklogAssigneeFilter;
|
||||||
|
priorityId: '' | number;
|
||||||
|
query: string;
|
||||||
|
statusId: '' | number;
|
||||||
|
typeId: '' | number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BacklogTicketTreeNode = {
|
||||||
|
children: BacklogTicketTreeNode[];
|
||||||
|
matchesFilters: boolean;
|
||||||
|
ticket: TicketModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BacklogTicketTreeProps = {
|
||||||
|
canEditTickets: boolean;
|
||||||
|
collapsedTicketIds: Set<number>;
|
||||||
|
nodes: BacklogTicketTreeNode[];
|
||||||
|
pendingTicketId: number | null;
|
||||||
|
projectId: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type BacklogTicketTreeEmits = {
|
||||||
|
moveFinish: [ticketId: number];
|
||||||
|
moveStart: [ticketId: number];
|
||||||
|
toggle: [ticketId: number];
|
||||||
|
};
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
export * from './auth';
|
export * from './auth';
|
||||||
|
export * from './backlog';
|
||||||
export * from './navigation';
|
export * from './navigation';
|
||||||
export * from './page-props';
|
export * from './page-props';
|
||||||
|
export * from './ticket-tree';
|
||||||
export * from './ui';
|
export * from './ui';
|
||||||
|
|||||||
@@ -39,6 +39,15 @@ export type ProjectDuplicateCopyAreaOption = {
|
|||||||
value: string;
|
value: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type AssignedTicketsProjectGroup = {
|
||||||
|
project: ProjectModel;
|
||||||
|
tickets: TicketModel[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type DashboardPageProps = {
|
||||||
|
assignedTicketsByProject: AssignedTicketsProjectGroup[];
|
||||||
|
};
|
||||||
|
|
||||||
export type ProjectsIndexPageProps = {
|
export type ProjectsIndexPageProps = {
|
||||||
projects: ProjectModel[];
|
projects: ProjectModel[];
|
||||||
status?: string | null;
|
status?: string | null;
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import type { ProjectTicketPageProps } from '@/types/page-props';
|
||||||
|
export type TicketDetailHeaderProps = Pick<
|
||||||
|
ProjectTicketPageProps,
|
||||||
|
'ticket' | 'project' | 'canEditTicket'
|
||||||
|
>;
|
||||||
|
export type TicketDetailContentProps = Pick<
|
||||||
|
ProjectTicketPageProps,
|
||||||
|
| 'ticket'
|
||||||
|
| 'project'
|
||||||
|
| 'canEditTicket'
|
||||||
|
| 'canManageProject'
|
||||||
|
| 'parentTicketOptions'
|
||||||
|
| 'ticketFieldDefinitions'
|
||||||
|
| 'ticketPriorities'
|
||||||
|
| 'ticketTypes'
|
||||||
|
| 'users'
|
||||||
|
>;
|
||||||
|
export type TicketDetailMetadataProps = Pick<
|
||||||
|
ProjectTicketPageProps,
|
||||||
|
'ticket' | 'project' | 'canManageProject' | 'ticketFieldDefinitions'
|
||||||
|
>;
|
||||||
|
export type TicketDetailGitProps = Pick<
|
||||||
|
ProjectTicketPageProps,
|
||||||
|
| 'ticket'
|
||||||
|
| 'project'
|
||||||
|
| 'canEditTicket'
|
||||||
|
| 'repositoryBranches'
|
||||||
|
| 'repositoryPullRequests'
|
||||||
|
| 'suggestedBranchName'
|
||||||
|
>;
|
||||||
|
export type TicketDetailRelationshipsProps = Pick<
|
||||||
|
ProjectTicketPageProps,
|
||||||
|
| 'ticket'
|
||||||
|
| 'project'
|
||||||
|
| 'canEditTicket'
|
||||||
|
| 'parentTicketOptions'
|
||||||
|
| 'childTicketTree'
|
||||||
|
| 'linkedTickets'
|
||||||
|
| 'ticketLinkTypes'
|
||||||
|
| 'ticketLinkOptions'
|
||||||
|
>;
|
||||||
|
export type TicketDetailHistoryProps = Pick<ProjectTicketPageProps, 'ticket'>;
|
||||||
|
export type TicketBranchFormData = {
|
||||||
|
branch_name: string;
|
||||||
|
repository_connection_id: string;
|
||||||
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import type { TicketModel } from '@/types/models/ticket-model';
|
||||||
|
|
||||||
|
export type TicketPresentationProps = {
|
||||||
|
layout?: 'card' | 'list';
|
||||||
|
projectId: number;
|
||||||
|
showDescription?: boolean;
|
||||||
|
showStatus?: boolean;
|
||||||
|
ticket: TicketModel;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type TicketPresentationEmits = {
|
||||||
|
open: [ticketId: number];
|
||||||
|
};
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import type { TicketTreeNodeModel } from '@/types/models/ticket-tree-node-model';
|
||||||
|
|
||||||
|
export type TicketTreeListProps = {
|
||||||
|
nodes: TicketTreeNodeModel[];
|
||||||
|
projectId: number;
|
||||||
|
};
|
||||||
+2
-1
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Controllers\DashboardController;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\File;
|
use Illuminate\Support\Facades\File;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
@@ -17,7 +18,7 @@ Route::get('api/docs/openapi.json', function (): Response {
|
|||||||
})->name('api.docs.openapi');
|
})->name('api.docs.openapi');
|
||||||
|
|
||||||
Route::middleware(['auth', 'verified'])->group(function () {
|
Route::middleware(['auth', 'verified'])->group(function () {
|
||||||
Route::inertia('dashboard', 'Dashboard')->name('dashboard');
|
Route::get('dashboard', DashboardController::class)->name('dashboard');
|
||||||
|
|
||||||
require __DIR__.'/web/admin.php';
|
require __DIR__.'/web/admin.php';
|
||||||
require __DIR__.'/web/project-templates.php';
|
require __DIR__.'/web/project-templates.php';
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AcceptanceCriteriaChecklistTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_checklist_preserves_hierarchy_identity_and_accessible_controls(): void
|
||||||
|
{
|
||||||
|
$process = new Process(['node', 'tests/Fixtures/acceptance-criteria.mjs'], base_path());
|
||||||
|
$process->setTimeout(60);
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||||
|
$this->assertStringContainsString('Acceptance criteria behavior checks passed.', $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ class PasswordConfirmationTest extends TestCase
|
|||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
public function test_confirm_password_screen_can_be_rendered()
|
public function test_confirm_password_screen_can_be_rendered(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
@@ -24,10 +24,32 @@ class PasswordConfirmationTest extends TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_password_confirmation_requires_authentication()
|
public function test_password_confirmation_requires_authentication(): void
|
||||||
{
|
{
|
||||||
$response = $this->get(route('password.confirm'));
|
$response = $this->get(route('password.confirm'));
|
||||||
|
|
||||||
$response->assertRedirect(route('login'));
|
$response->assertRedirect(route('login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_password_can_be_confirmed(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->post(route('password.confirm'), ['password' => 'password'])
|
||||||
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
|
$this->assertNotNull(session('auth.password_confirmed_at'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_password_confirmation_rejects_an_invalid_password(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->post(route('password.confirm'), ['password' => 'incorrect'])
|
||||||
|
->assertSessionHasErrors('password');
|
||||||
|
|
||||||
|
$this->assertNull(session('auth.password_confirmed_at'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use App\Models\User;
|
|||||||
use Illuminate\Auth\Notifications\ResetPassword;
|
use Illuminate\Auth\Notifications\ResetPassword;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
|
use Inertia\Testing\AssertableInertia as Assert;
|
||||||
use Laravel\Fortify\Features;
|
use Laravel\Fortify\Features;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
@@ -20,11 +21,16 @@ class PasswordResetTest extends TestCase
|
|||||||
$this->skipUnlessFortifyFeature(Features::resetPasswords());
|
$this->skipUnlessFortifyFeature(Features::resetPasswords());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_reset_password_link_screen_can_be_rendered()
|
public function test_reset_password_link_screen_can_be_rendered(): void
|
||||||
{
|
{
|
||||||
$response = $this->get(route('password.request'));
|
$response = $this->get(route('password.request'));
|
||||||
|
|
||||||
$response->assertOk();
|
$response
|
||||||
|
->assertOk()
|
||||||
|
->assertInertia(fn (Assert $page) => $page
|
||||||
|
->component('auth/ForgotPassword')
|
||||||
|
->where('status', null),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_reset_password_link_can_be_requested()
|
public function test_reset_password_link_can_be_requested()
|
||||||
@@ -38,7 +44,7 @@ class PasswordResetTest extends TestCase
|
|||||||
Notification::assertSentTo($user, ResetPassword::class);
|
Notification::assertSentTo($user, ResetPassword::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_reset_password_screen_can_be_rendered()
|
public function test_reset_password_screen_can_be_rendered(): void
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Notification::fake();
|
||||||
|
|
||||||
@@ -46,10 +52,19 @@ class PasswordResetTest extends TestCase
|
|||||||
|
|
||||||
$this->post(route('password.email'), ['email' => $user->email]);
|
$this->post(route('password.email'), ['email' => $user->email]);
|
||||||
|
|
||||||
Notification::assertSentTo($user, ResetPassword::class, function ($notification) {
|
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) {
|
||||||
$response = $this->get(route('password.reset', $notification->token));
|
$response = $this->get(route('password.reset', [
|
||||||
|
'token' => $notification->token,
|
||||||
|
'email' => $user->email,
|
||||||
|
]));
|
||||||
|
|
||||||
$response->assertOk();
|
$response
|
||||||
|
->assertOk()
|
||||||
|
->assertInertia(fn (Assert $page) => $page
|
||||||
|
->component('auth/ResetPassword')
|
||||||
|
->where('email', $user->email)
|
||||||
|
->where('token', $notification->token),
|
||||||
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,26 +2,117 @@
|
|||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Team;
|
||||||
|
use App\Models\Ticket;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Inertia\Testing\AssertableInertia as Assert;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class DashboardTest extends TestCase
|
class DashboardTest extends TestCase
|
||||||
{
|
{
|
||||||
use RefreshDatabase;
|
use RefreshDatabase;
|
||||||
|
|
||||||
public function test_guests_are_redirected_to_the_login_page()
|
public function test_guests_are_redirected_to_the_login_page(): void
|
||||||
{
|
{
|
||||||
$response = $this->get(route('dashboard'));
|
$response = $this->get(route('dashboard'));
|
||||||
$response->assertRedirect(route('login'));
|
$response->assertRedirect(route('login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_authenticated_users_can_visit_the_dashboard()
|
public function test_authenticated_users_see_an_empty_dashboard_without_assigned_tickets(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
$this->actingAs($user);
|
$this->actingAs($user);
|
||||||
|
|
||||||
$response = $this->get(route('dashboard'));
|
$this->get(route('dashboard'))
|
||||||
$response->assertOk();
|
->assertOk()
|
||||||
|
->assertInertia(fn (Assert $page) => $page
|
||||||
|
->component('Dashboard')
|
||||||
|
->has('assignedTicketsByProject', 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_dashboard_only_contains_the_users_tickets_from_visible_projects(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$otherUser = User::factory()->create();
|
||||||
|
$directProject = Project::factory()->create([
|
||||||
|
'key' => 'WEB',
|
||||||
|
'name' => 'Web platform',
|
||||||
|
]);
|
||||||
|
$teamProject = Project::factory()->create([
|
||||||
|
'key' => 'OPS',
|
||||||
|
'name' => 'Operations',
|
||||||
|
]);
|
||||||
|
$hiddenProject = Project::factory()->create([
|
||||||
|
'key' => 'SEC',
|
||||||
|
'name' => 'Private security',
|
||||||
|
]);
|
||||||
|
$team = Team::factory()->create();
|
||||||
|
|
||||||
|
$team->users()->attach($user);
|
||||||
|
$this->syncProjectPermissions($directProject, $user, ['view']);
|
||||||
|
$this->syncProjectPermissions($teamProject, $team, ['view']);
|
||||||
|
|
||||||
|
Ticket::factory()->create([
|
||||||
|
'assignee_user_id' => $user->id,
|
||||||
|
'project_id' => $directProject->id,
|
||||||
|
'sequence_number' => 1,
|
||||||
|
'ticket_key' => 'WEB-1',
|
||||||
|
'title' => 'Older assigned ticket',
|
||||||
|
]);
|
||||||
|
Ticket::factory()->create([
|
||||||
|
'assignee_user_id' => $user->id,
|
||||||
|
'project_id' => $directProject->id,
|
||||||
|
'sequence_number' => 2,
|
||||||
|
'ticket_key' => 'WEB-2',
|
||||||
|
'title' => 'Newest assigned ticket',
|
||||||
|
]);
|
||||||
|
Ticket::factory()->create([
|
||||||
|
'assignee_user_id' => $user->id,
|
||||||
|
'project_id' => $teamProject->id,
|
||||||
|
'sequence_number' => 1,
|
||||||
|
'ticket_key' => 'OPS-1',
|
||||||
|
'title' => 'Team-visible assigned ticket',
|
||||||
|
]);
|
||||||
|
Ticket::factory()->create([
|
||||||
|
'assignee_user_id' => $otherUser->id,
|
||||||
|
'project_id' => $directProject->id,
|
||||||
|
'sequence_number' => 3,
|
||||||
|
'ticket_key' => 'WEB-3',
|
||||||
|
'title' => 'Another users ticket',
|
||||||
|
]);
|
||||||
|
Ticket::factory()->create([
|
||||||
|
'assignee_user_id' => $user->id,
|
||||||
|
'project_id' => $hiddenProject->id,
|
||||||
|
'sequence_number' => 1,
|
||||||
|
'ticket_key' => 'SEC-1',
|
||||||
|
'title' => 'Hidden project ticket',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->get(route('dashboard'))
|
||||||
|
->assertOk()
|
||||||
|
->assertInertia(fn (Assert $page) => $page
|
||||||
|
->component('Dashboard')
|
||||||
|
->has('assignedTicketsByProject', 2)
|
||||||
|
->where('assignedTicketsByProject.0.project.id', $teamProject->id)
|
||||||
|
->has('assignedTicketsByProject.0.tickets', 1)
|
||||||
|
->where('assignedTicketsByProject.0.tickets.0.ticket_key', 'OPS-1')
|
||||||
|
->where('assignedTicketsByProject.1.project.id', $directProject->id)
|
||||||
|
->has('assignedTicketsByProject.1.tickets', 2)
|
||||||
|
->where('assignedTicketsByProject.1.tickets.0.ticket_key', 'WEB-2')
|
||||||
|
->where('assignedTicketsByProject.1.tickets.1.ticket_key', 'WEB-1'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_dashboard_presentation_uses_real_data_and_handles_empty_state(): void
|
||||||
|
{
|
||||||
|
$process = new Process(['node', 'tests/Fixtures/dashboard.mjs'], base_path());
|
||||||
|
$process->setTimeout(60);
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||||
|
$this->assertStringContainsString('Dashboard behavior checks passed.', $process->getOutput());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ class ProjectBacklogTest extends TestCase
|
|||||||
public function test_users_with_view_permission_can_view_a_projects_backlog(): void
|
public function test_users_with_view_permission_can_view_a_projects_backlog(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
$assignee = User::factory()->create([
|
||||||
|
'name' => 'Taylor Reed',
|
||||||
|
]);
|
||||||
$project = Project::factory()->create([
|
$project = Project::factory()->create([
|
||||||
'key' => 'AUTH',
|
'key' => 'AUTH',
|
||||||
]);
|
]);
|
||||||
@@ -39,6 +42,7 @@ class ProjectBacklogTest extends TestCase
|
|||||||
->firstOrFail();
|
->firstOrFail();
|
||||||
|
|
||||||
$ticket = Ticket::factory()->create([
|
$ticket = Ticket::factory()->create([
|
||||||
|
'assignee_user_id' => $assignee->id,
|
||||||
'project_id' => $project->id,
|
'project_id' => $project->id,
|
||||||
'ticket_priority_id' => $priority->id,
|
'ticket_priority_id' => $priority->id,
|
||||||
'ticket_status_id' => $backlogStatus->id,
|
'ticket_status_id' => $backlogStatus->id,
|
||||||
@@ -59,10 +63,118 @@ class ProjectBacklogTest extends TestCase
|
|||||||
->where('canEditTickets', false)
|
->where('canEditTickets', false)
|
||||||
->where('project.id', $project->id)
|
->where('project.id', $project->id)
|
||||||
->where('tickets.0.ticket_key', $ticket->ticket_key)
|
->where('tickets.0.ticket_key', $ticket->ticket_key)
|
||||||
|
->where('tickets.0.assignee.id', $assignee->id)
|
||||||
|
->where('tickets.0.assignee.name', $assignee->name)
|
||||||
|
->where('tickets.0.ticket_priority.name', $priority->name)
|
||||||
|
->where('tickets.0.ticket_status.name', $backlogStatus->name)
|
||||||
->where('canCreateTickets', false),
|
->where('canCreateTickets', false),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the backlog payload supports nested tickets and their allowed status moves.
|
||||||
|
*/
|
||||||
|
public function test_backlog_includes_nested_tickets_and_allowed_status_moves(): void
|
||||||
|
{
|
||||||
|
$editor = User::factory()->create();
|
||||||
|
$project = Project::factory()->create([
|
||||||
|
'key' => 'TREE',
|
||||||
|
]);
|
||||||
|
|
||||||
|
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||||
|
|
||||||
|
$backlogStatus = $project->ticketStatuses()
|
||||||
|
->whereNull('board_column_id')
|
||||||
|
->firstOrFail();
|
||||||
|
$boardColumn = BoardColumn::factory()->for($project)->create([
|
||||||
|
'name' => 'Todo',
|
||||||
|
'position' => 1,
|
||||||
|
]);
|
||||||
|
$boardStatus = TicketStatus::factory()
|
||||||
|
->for($project)
|
||||||
|
->for($boardColumn)
|
||||||
|
->create([
|
||||||
|
'name' => 'Ready',
|
||||||
|
'position' => 1,
|
||||||
|
]);
|
||||||
|
$backlogStatus->allowedTargetStatuses()->sync([$boardStatus->id]);
|
||||||
|
|
||||||
|
$parentType = $project->ticketTypes()
|
||||||
|
->where('is_parent', true)
|
||||||
|
->firstOrFail();
|
||||||
|
$taskType = $project->ticketTypes()
|
||||||
|
->where('is_parent', false)
|
||||||
|
->firstOrFail();
|
||||||
|
$priority = $project->ticketPriorities()->firstOrFail();
|
||||||
|
|
||||||
|
$parentTicket = Ticket::factory()->create([
|
||||||
|
'project_id' => $project->id,
|
||||||
|
'sequence_number' => 1,
|
||||||
|
'ticket_key' => 'TREE-1',
|
||||||
|
'ticket_priority_id' => $priority->id,
|
||||||
|
'ticket_status_id' => $backlogStatus->id,
|
||||||
|
'ticket_type_id' => $parentType->id,
|
||||||
|
'title' => 'Parent ticket',
|
||||||
|
]);
|
||||||
|
$childTicket = Ticket::factory()->create([
|
||||||
|
'parent_ticket_id' => $parentTicket->id,
|
||||||
|
'project_id' => $project->id,
|
||||||
|
'sequence_number' => 2,
|
||||||
|
'ticket_key' => 'TREE-2',
|
||||||
|
'ticket_priority_id' => $priority->id,
|
||||||
|
'ticket_status_id' => $backlogStatus->id,
|
||||||
|
'ticket_type_id' => $taskType->id,
|
||||||
|
'title' => 'Child ticket',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->syncProjectPermissions($project, $editor, ['edit', 'view']);
|
||||||
|
|
||||||
|
$this->actingAs($editor)
|
||||||
|
->get(route('projects.backlog.index', $project))
|
||||||
|
->assertOk()
|
||||||
|
->assertInertia(fn (Assert $page) => $page
|
||||||
|
->component('projects/Backlog')
|
||||||
|
->where('canEditTickets', true)
|
||||||
|
->has('tickets', 2)
|
||||||
|
->where('tickets.0.id', $childTicket->id)
|
||||||
|
->where('tickets.0.parent_ticket_id', $parentTicket->id)
|
||||||
|
->where('tickets.0.ticket_status.allowed_target_statuses.0.id', $boardStatus->id)
|
||||||
|
->where('tickets.1.id', $parentTicket->id)
|
||||||
|
->where('tickets.1.parent_ticket_id', null)
|
||||||
|
->where('tickets.1.ticket_status.allowed_target_statuses.0.id', $boardStatus->id),
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('tickets', [
|
||||||
|
'id' => $parentTicket->id,
|
||||||
|
'ticket_status_id' => $backlogStatus->id,
|
||||||
|
]);
|
||||||
|
$this->assertDatabaseHas('tickets', [
|
||||||
|
'id' => $childTicket->id,
|
||||||
|
'parent_ticket_id' => $parentTicket->id,
|
||||||
|
'ticket_status_id' => $backlogStatus->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure projects without backlog tickets receive an empty collection.
|
||||||
|
*/
|
||||||
|
public function test_projects_without_backlog_tickets_receive_an_empty_collection(): void
|
||||||
|
{
|
||||||
|
$viewer = User::factory()->create();
|
||||||
|
$project = Project::factory()->create();
|
||||||
|
|
||||||
|
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||||
|
$this->syncProjectPermissions($project, $viewer, ['view']);
|
||||||
|
|
||||||
|
$this->actingAs($viewer)
|
||||||
|
->get(route('projects.backlog.index', $project))
|
||||||
|
->assertOk()
|
||||||
|
->assertInertia(fn (Assert $page) => $page
|
||||||
|
->component('projects/Backlog')
|
||||||
|
->where('tickets', []),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensure creating tickets requires the project write permission.
|
* Ensure creating tickets requires the project write permission.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ class ProjectBoardControllerTest extends TestCase
|
|||||||
public function test_users_with_view_permission_can_view_a_projects_board(): void
|
public function test_users_with_view_permission_can_view_a_projects_board(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
$assignee = User::factory()->create([
|
||||||
|
'name' => 'Taylor Reed',
|
||||||
|
]);
|
||||||
$project = Project::factory()->create([
|
$project = Project::factory()->create([
|
||||||
'key' => 'CORE',
|
'key' => 'CORE',
|
||||||
]);
|
]);
|
||||||
@@ -58,6 +61,7 @@ class ProjectBoardControllerTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$boardTicket = Ticket::factory()->create([
|
$boardTicket = Ticket::factory()->create([
|
||||||
|
'assignee_user_id' => $assignee->id,
|
||||||
'project_id' => $project->id,
|
'project_id' => $project->id,
|
||||||
'sequence_number' => 2,
|
'sequence_number' => 2,
|
||||||
'ticket_key' => 'CORE-2',
|
'ticket_key' => 'CORE-2',
|
||||||
@@ -81,6 +85,10 @@ class ProjectBoardControllerTest extends TestCase
|
|||||||
->has('boardColumns.1.tickets', 1)
|
->has('boardColumns.1.tickets', 1)
|
||||||
->where('boardColumns.1.tickets.0.ticket_key', $boardTicket->ticket_key)
|
->where('boardColumns.1.tickets.0.ticket_key', $boardTicket->ticket_key)
|
||||||
->where('boardColumns.1.tickets.0.title', $boardTicket->title)
|
->where('boardColumns.1.tickets.0.title', $boardTicket->title)
|
||||||
|
->where('boardColumns.1.tickets.0.assignee.id', $assignee->id)
|
||||||
|
->where('boardColumns.1.tickets.0.assignee.name', $assignee->name)
|
||||||
|
->where('boardColumns.1.tickets.0.ticket_priority.name', $priority->name)
|
||||||
|
->where('boardColumns.1.tickets.0.ticket_status.name', $doingStatus->name)
|
||||||
->where('canCreateTickets', false)
|
->where('canCreateTickets', false)
|
||||||
->where('canEditTickets', false),
|
->where('canEditTickets', false),
|
||||||
);
|
);
|
||||||
@@ -204,6 +212,19 @@ class ProjectBoardControllerTest extends TestCase
|
|||||||
'entry_type' => 'status_changed',
|
'entry_type' => 'status_changed',
|
||||||
'summary' => 'Moved from Todo to Done.',
|
'summary' => 'Moved from Todo to Done.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->assertSame(1, $ticket->worklogEntries()->count());
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->patch(route('projects.tickets.status.update', [$project, $ticket]), [
|
||||||
|
'redirect_to' => 'board',
|
||||||
|
'ticket_status_id' => $doneStatus->id,
|
||||||
|
])
|
||||||
|
->assertRedirect(route('projects.board.index', $project))
|
||||||
|
->assertSessionHasNoErrors();
|
||||||
|
|
||||||
|
$this->assertSame($doneStatus->id, $ticket->fresh()->ticket_status_id);
|
||||||
|
$this->assertSame(1, $ticket->worklogEntries()->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Projects;
|
||||||
|
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ProjectBoardPresentationTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_board_renders_configured_status_groups_counts_and_permission_aware_actions(): void
|
||||||
|
{
|
||||||
|
$process = new Process(['node', 'tests/Fixtures/board.mjs'], base_path());
|
||||||
|
$process->setTimeout(60);
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||||
|
$this->assertStringContainsString('Board behavior checks passed.', $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Projects;
|
||||||
|
|
||||||
|
use App\Models\ProjectTemplate;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ProjectCreationTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
#[DataProvider('missingSources')]
|
||||||
|
public function test_creation_requires_the_selected_source(string $mode, string $field): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->admin()->create();
|
||||||
|
$this->actingAs($user)->from(route('projects.create'))
|
||||||
|
->post(route('projects.store'), ['creation_mode' => $mode, 'name' => 'New project', 'key' => 'NEW'])
|
||||||
|
->assertRedirect(route('projects.create'))->assertSessionHasErrors($field);
|
||||||
|
$this->assertDatabaseMissing('projects', ['key' => 'NEW']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string, array{string, string}> */
|
||||||
|
public static function missingSources(): array
|
||||||
|
{
|
||||||
|
return ['duplicate' => ['duplicate', 'source_project_id'], 'template' => ['template', 'source_template_id']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unpublished_template_cannot_be_used_to_create_a_project(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->admin()->create();
|
||||||
|
$template = ProjectTemplate::factory()->create(['is_published' => false]);
|
||||||
|
$this->actingAs($user)->post(route('projects.store'), [
|
||||||
|
'creation_mode' => 'template', 'source_template_id' => $template->id, 'name' => 'New project', 'key' => 'NEW',
|
||||||
|
])->assertSessionHasErrors('source_template_id');
|
||||||
|
$this->assertDatabaseMissing('projects', ['key' => 'NEW']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_creation_page_rendering_and_localization(): void
|
||||||
|
{
|
||||||
|
$process = new Process(['node', 'tests/Fixtures/project-creation.mjs'], base_path());
|
||||||
|
$process->setTimeout(60);
|
||||||
|
$process->run();
|
||||||
|
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||||
|
$this->assertStringContainsString('Project creation rendering checks passed.', $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\Projects;
|
||||||
|
|
||||||
|
use App\Models\Project;
|
||||||
|
use App\Models\Team;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Inertia\Testing\AssertableInertia as Assert;
|
||||||
|
use PHPUnit\Framework\Attributes\DataProvider;
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class ProjectOverviewTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
public function test_projects_without_access_do_not_appear_in_the_empty_overview(): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
Project::factory()->create(['name' => 'Private workspace']);
|
||||||
|
|
||||||
|
$this->actingAs($user)->get(route('projects.index'))
|
||||||
|
->assertOk()->assertInertia(fn (Assert $page) => $page
|
||||||
|
->component('projects/Index')
|
||||||
|
->has('projects', 0)
|
||||||
|
->where('auth.permissions.projectCreate', false));
|
||||||
|
|
||||||
|
$this->syncGlobalPermissions($user, ['project:create']);
|
||||||
|
$this->get(route('projects.index'))
|
||||||
|
->assertOk()->assertInertia(fn (Assert $page) => $page
|
||||||
|
->has('projects', 0)
|
||||||
|
->where('auth.permissions.projectCreate', true));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[DataProvider('projectRoles')]
|
||||||
|
public function test_project_entry_actions_follow_effective_permissions(string $role, bool $teamAccess, bool $canManage): void
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$project = Project::factory()->create();
|
||||||
|
$assignee = $user;
|
||||||
|
if ($teamAccess) {
|
||||||
|
$assignee = Team::factory()->create();
|
||||||
|
$assignee->users()->attach($user);
|
||||||
|
}
|
||||||
|
$this->syncProjectPermissions($project, $assignee, [$role]);
|
||||||
|
|
||||||
|
$this->actingAs($user)->get(route('projects.show', $project))
|
||||||
|
->assertOk()->assertInertia(fn (Assert $page) => $page
|
||||||
|
->component('projects/Show')
|
||||||
|
->where('project.id', $project->id)
|
||||||
|
->where('canManageAccess', $canManage)
|
||||||
|
->where('auth.permissions.projectCreate', false));
|
||||||
|
|
||||||
|
foreach (['projects.board.index', 'projects.backlog.index'] as $route) {
|
||||||
|
$this->get(route($route, $project))->assertOk();
|
||||||
|
}
|
||||||
|
foreach (['projects.settings.general', 'projects.settings.board', 'projects.settings.metadata', 'projects.settings.repositories', 'projects.settings.notifications', 'projects.access'] as $route) {
|
||||||
|
$this->get(route($route, $project))->assertStatus($canManage ? 200 : 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return array<string, array{string, bool, bool}> */
|
||||||
|
public static function projectRoles(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'reader' => ['read', false, false],
|
||||||
|
'writer' => ['write', false, false],
|
||||||
|
'project admin' => ['admin', false, true],
|
||||||
|
'team reader' => ['read', true, false],
|
||||||
|
'team admin' => ['admin', true, true],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_project_overview_rendering_and_actions(): void
|
||||||
|
{
|
||||||
|
$process = new Process(['node', 'tests/Fixtures/project-overview.mjs'], base_path());
|
||||||
|
$process->setTimeout(60);
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||||
|
$this->assertStringContainsString('Project overview behavior checks passed.', $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1511,6 +1511,74 @@ class ProjectTicketControllerTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_read_only_users_cannot_open_or_submit_the_ticket_create_form(): void
|
||||||
|
{
|
||||||
|
$viewer = User::factory()->create();
|
||||||
|
$project = Project::factory()->create();
|
||||||
|
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||||
|
$this->syncProjectPermissions($project, $viewer, ['view']);
|
||||||
|
|
||||||
|
$this->actingAs($viewer)
|
||||||
|
->get(route('projects.tickets.create', $project))
|
||||||
|
->assertForbidden();
|
||||||
|
|
||||||
|
$this->post(route('projects.tickets.store', $project), [
|
||||||
|
'title' => 'Unauthorized ticket',
|
||||||
|
'ticket_type_id' => $this->nonParentType($project)->id,
|
||||||
|
'ticket_priority_id' => $project->ticketPriorities()->firstOrFail()->id,
|
||||||
|
'ticket_status_id' => $project->ticketStatuses()->firstOrFail()->id,
|
||||||
|
])->assertForbidden();
|
||||||
|
|
||||||
|
$this->assertDatabaseCount('tickets', 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_ticket_forms_reject_metadata_from_another_project(): void
|
||||||
|
{
|
||||||
|
$editor = User::factory()->create();
|
||||||
|
$project = Project::factory()->create();
|
||||||
|
$otherProject = Project::factory()->create();
|
||||||
|
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||||
|
app(InitializeProjectTicketMetadata::class)->handle($otherProject);
|
||||||
|
$this->syncProjectPermissions($project, $editor, ['write', 'view']);
|
||||||
|
$parent = Ticket::factory()->create([
|
||||||
|
'project_id' => $otherProject->id,
|
||||||
|
'ticket_key' => 'OTHER-1',
|
||||||
|
'ticket_type_id' => $this->parentType($otherProject)->id,
|
||||||
|
'ticket_priority_id' => $otherProject->ticketPriorities()->firstOrFail()->id,
|
||||||
|
]);
|
||||||
|
$invalidMetadata = [
|
||||||
|
'parent_ticket_id' => $parent->id,
|
||||||
|
'ticket_type_id' => $this->nonParentType($otherProject)->id,
|
||||||
|
'ticket_priority_id' => $otherProject->ticketPriorities()->firstOrFail()->id,
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->actingAs($editor)
|
||||||
|
->post(route('projects.tickets.store', $project), [
|
||||||
|
...$invalidMetadata,
|
||||||
|
'title' => 'Rejected creation',
|
||||||
|
'ticket_status_id' => $otherProject->ticketStatuses()->firstOrFail()->id,
|
||||||
|
])
|
||||||
|
->assertSessionHasErrors([...array_keys($invalidMetadata), 'ticket_status_id']);
|
||||||
|
|
||||||
|
$this->assertSame(0, $project->tickets()->count());
|
||||||
|
|
||||||
|
$ticket = Ticket::factory()->create([
|
||||||
|
'project_id' => $project->id,
|
||||||
|
'ticket_key' => 'LOCAL-1',
|
||||||
|
'ticket_type_id' => $this->nonParentType($project)->id,
|
||||||
|
'ticket_priority_id' => $project->ticketPriorities()->firstOrFail()->id,
|
||||||
|
'title' => 'Original title',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->patch(route('projects.tickets.update', [$project, $ticket]), $this->updatePayload($ticket, [
|
||||||
|
...$invalidMetadata,
|
||||||
|
'title' => 'Rejected update',
|
||||||
|
]))->assertSessionHasErrors(array_keys($invalidMetadata));
|
||||||
|
|
||||||
|
$this->assertSame('Original title', $ticket->fresh()->title);
|
||||||
|
$this->assertNull($ticket->fresh()->parent_ticket_id);
|
||||||
|
}
|
||||||
|
|
||||||
private function nonParentType(Project $project): TicketType
|
private function nonParentType(Project $project): TicketType
|
||||||
{
|
{
|
||||||
return $project->ticketTypes()
|
return $project->ticketTypes()
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class TicketDetailPresentationTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_ticket_detail_sections_preserve_information_actions_and_permissions(): void
|
||||||
|
{
|
||||||
|
$process = new Process(['node', 'tests/Fixtures/ticket-detail.mjs'], base_path());
|
||||||
|
$process->setTimeout(60);
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||||
|
$this->assertStringContainsString('Ticket detail behavior checks passed.', $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Symfony\Component\Process\Process;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class TicketPresentationsTest extends TestCase
|
||||||
|
{
|
||||||
|
public function test_ticket_cards_and_list_items_share_accessible_data_driven_behavior(): void
|
||||||
|
{
|
||||||
|
$process = new Process(['node', 'tests/Fixtures/ticket-presentations.mjs'], base_path());
|
||||||
|
$process->setTimeout(60);
|
||||||
|
$process->run();
|
||||||
|
|
||||||
|
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||||
|
$this->assertStringContainsString('Ticket presentation behavior checks passed.', $process->getOutput());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<script setup>
|
||||||
|
import { TicketCard, TicketListItem } from '@/components/tickets';
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
fullTicket: Object,
|
||||||
|
optionalTicket: Object,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<main class="mx-auto grid max-w-5xl gap-8 p-4 sm:p-8">
|
||||||
|
<section class="grid gap-4" aria-labelledby="cards-title">
|
||||||
|
<h1 id="cards-title" class="text-headline-mobile md:text-headline">
|
||||||
|
Ticket cards
|
||||||
|
</h1>
|
||||||
|
<div class="grid gap-4 sm:grid-cols-2">
|
||||||
|
<TicketCard :project-id="7" :ticket="fullTicket" />
|
||||||
|
<TicketCard :project-id="7" :ticket="optionalTicket" />
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="grid gap-4" aria-labelledby="rows-title">
|
||||||
|
<h2 id="rows-title" class="text-title">Ticket list items</h2>
|
||||||
|
<ul class="grid gap-4">
|
||||||
|
<TicketListItem :project-id="7" :ticket="fullTicket" />
|
||||||
|
<TicketListItem :project-id="7" :ticket="optionalTicket" />
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
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:4176';
|
||||||
|
const context = await browser.newContext({
|
||||||
|
viewport: { width: 1280, height: 900 },
|
||||||
|
hasTouch: true,
|
||||||
|
});
|
||||||
|
const page = await context.newPage();
|
||||||
|
page.setDefaultTimeout(10000);
|
||||||
|
page.on('dialog', (dialog) => dialog.accept());
|
||||||
|
const errors = [];
|
||||||
|
page.on('pageerror', (error) => errors.push(error.message));
|
||||||
|
const checklist = () =>
|
||||||
|
page
|
||||||
|
.locator('form')
|
||||||
|
.first()
|
||||||
|
.getByRole('region', { name: 'Acceptance criteria' });
|
||||||
|
const savedChecklist = () => page.locator('#ticket-checklist');
|
||||||
|
const field = (number) =>
|
||||||
|
page.getByRole('textbox', { name: `Criterion ${number}`, exact: true });
|
||||||
|
const button = (name) => page.getByRole('button', { name, exact: true });
|
||||||
|
const setResult = (value) =>
|
||||||
|
context.addCookies([{ name: 'feedback_test_result', value, url: base }]);
|
||||||
|
const waitState = (value) =>
|
||||||
|
page.locator(`[data-form-state="${value}"]`).first().waitFor();
|
||||||
|
const save = async () => {
|
||||||
|
await button('Save changes').click();
|
||||||
|
await waitState('success');
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
await page.goto(`${base}/projects/7/tickets/31`);
|
||||||
|
await savedChecklist().waitFor();
|
||||||
|
const boxes = savedChecklist().getByRole('checkbox');
|
||||||
|
await setResult('server');
|
||||||
|
await boxes.first().focus();
|
||||||
|
await page.keyboard.press('Space');
|
||||||
|
await page
|
||||||
|
.getByText('Checklist status could not be saved. Please try again.')
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await boxes.first().isChecked(),
|
||||||
|
false,
|
||||||
|
'Failure must restore saved checkbox',
|
||||||
|
);
|
||||||
|
await setResult('success');
|
||||||
|
let payload;
|
||||||
|
page.on('request', (request) => {
|
||||||
|
if (request.method() === 'PATCH') {
|
||||||
|
payload = request.postDataJSON();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
await boxes.first().tap();
|
||||||
|
await page.waitForFunction(
|
||||||
|
() =>
|
||||||
|
document.querySelectorAll('section[aria-busy="true"]').length === 0,
|
||||||
|
);
|
||||||
|
await savedChecklist().getByText('3 of 4 complete').waitFor();
|
||||||
|
assert.deepEqual(
|
||||||
|
payload.acceptance_criteria.map((item) => item.checked),
|
||||||
|
[true, true, true, false],
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
payload.acceptance_criteria.map((item) => item.id),
|
||||||
|
[11, 12, 13, 14],
|
||||||
|
);
|
||||||
|
await page.locator('#ticket-edit > summary').click();
|
||||||
|
await field(2).fill('Edited child');
|
||||||
|
await field(2).press('Alt+ArrowLeft');
|
||||||
|
assert.deepEqual(
|
||||||
|
await checklist()
|
||||||
|
.locator('li')
|
||||||
|
.evaluateAll((items) =>
|
||||||
|
items.map((item) => Number(item.dataset.indent)),
|
||||||
|
),
|
||||||
|
[0, 0, 1, 0],
|
||||||
|
);
|
||||||
|
await button('Indent criterion 2').tap();
|
||||||
|
await button('Remove criterion 1').tap();
|
||||||
|
assert.equal(await field(1).inputValue(), 'Edited child');
|
||||||
|
assert.equal(
|
||||||
|
await field(1).evaluate((el) => el === document.activeElement),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await button('Add criterion').focus();
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
assert.equal(
|
||||||
|
await field(4).evaluate((el) => el === document.activeElement),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await field(4).fill('New criterion');
|
||||||
|
await button('Indent criterion 4').click();
|
||||||
|
await setResult('validation');
|
||||||
|
await button('Save changes').click();
|
||||||
|
await waitState('validation');
|
||||||
|
assert.equal(await field(1).inputValue(), 'Edited child');
|
||||||
|
await setResult('success');
|
||||||
|
await save();
|
||||||
|
assert.deepEqual(
|
||||||
|
payload.acceptance_criteria.map((item) => item.id),
|
||||||
|
[12, 13, 14, undefined],
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
payload.acceptance_criteria.map((item) => item.indent),
|
||||||
|
[0, 1, 0, 1],
|
||||||
|
);
|
||||||
|
await page.reload();
|
||||||
|
await page.locator('#ticket-edit > summary').click();
|
||||||
|
assert.equal(await field(1).inputValue(), 'Edited child');
|
||||||
|
assert.equal(await field(4).inputValue(), 'New criterion');
|
||||||
|
// Blank/whitespace text cannot silently delete a persisted criterion.
|
||||||
|
await field(1).fill(' ');
|
||||||
|
assert.equal(await field(1).evaluate((el) => el.checkValidity()), false);
|
||||||
|
const beforeInvalidSave = payload;
|
||||||
|
await button('Save changes').click();
|
||||||
|
assert.equal(payload, beforeInvalidSave);
|
||||||
|
await button('Discard changes').click();
|
||||||
|
assert.equal(await field(1).inputValue(), 'Edited child');
|
||||||
|
assert.equal(await field(1).evaluate((el) => el.checkValidity()), true);
|
||||||
|
for (const width of [1280, 390, 320]) {
|
||||||
|
await page.setViewportSize({ width, height: 900 });
|
||||||
|
for (const theme of ['light', 'dark']) {
|
||||||
|
await page.emulateMedia({ colorScheme: theme });
|
||||||
|
await page.evaluate(
|
||||||
|
(theme) =>
|
||||||
|
document.documentElement.classList.toggle(
|
||||||
|
'dark',
|
||||||
|
theme === 'dark',
|
||||||
|
),
|
||||||
|
theme,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await checklist().evaluate(
|
||||||
|
(el) => el.scrollWidth <= el.clientWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await checklist().screenshot({
|
||||||
|
path: `/private/tmp/kan32-checklist-${width}-${theme}.png`,
|
||||||
|
});
|
||||||
|
await button('Outdent criterion 4').tap();
|
||||||
|
await button('Indent criterion 4').tap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await page.goto(`${base}/projects/7/tickets/31?readonly=1`);
|
||||||
|
await savedChecklist().waitFor();
|
||||||
|
assert.equal(await savedChecklist().getByRole('textbox').count(), 0);
|
||||||
|
assert.equal(await savedChecklist().getByRole('button').count(), 0);
|
||||||
|
assert.equal(
|
||||||
|
await savedChecklist().getByRole('checkbox').first().isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await page.goto(`${base}/projects/7/tickets/create`);
|
||||||
|
await page.locator('#title').fill('Created with criteria');
|
||||||
|
for (const text of ['First', 'Second']) {
|
||||||
|
await button('Add criterion').click();
|
||||||
|
await page.locator('textarea').last().fill(text);
|
||||||
|
}
|
||||||
|
await button('Indent criterion 2').tap();
|
||||||
|
await checklist().getByRole('checkbox').first().focus();
|
||||||
|
await page.keyboard.press('Space');
|
||||||
|
const request = page.waitForRequest(
|
||||||
|
(request) =>
|
||||||
|
request.method() === 'POST' && request.url().endsWith('/tickets'),
|
||||||
|
);
|
||||||
|
await button('Create ticket').click();
|
||||||
|
const created = (await request).postDataJSON();
|
||||||
|
assert.deepEqual(created.acceptance_criteria, [
|
||||||
|
{ text: 'First', checked: true, indent: 0 },
|
||||||
|
{ text: 'Second', checked: true, indent: 1 },
|
||||||
|
]);
|
||||||
|
await page.getByRole('heading', { name: 'Destination' }).waitFor();
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
console.log(
|
||||||
|
'Acceptance criteria browser checks passed: persistence, errors, keyboard, touch, readonly, creation, mobile and themes.',
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import vue from '@vitejs/plugin-vue';
|
||||||
|
import { createServer } from 'vite';
|
||||||
|
import { createSSRApp, h } from 'vue';
|
||||||
|
import { renderToString } from 'vue/server-renderer';
|
||||||
|
|
||||||
|
const server = await createServer({
|
||||||
|
configFile: false,
|
||||||
|
cacheDir: 'node_modules/.vite/acceptance-criteria-fixture',
|
||||||
|
plugins: [vue()],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('../../resources/js', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: { middlewareMode: true, hmr: false, watch: null },
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
canIndentAcceptanceCriterion: canIndent,
|
||||||
|
indentAcceptanceCriterion: indent,
|
||||||
|
removeAcceptanceCriterion: remove,
|
||||||
|
syncAcceptanceCriteriaDescendantCheckedState: toggle,
|
||||||
|
normalizeAcceptanceCriteria: normalize,
|
||||||
|
} = await server.ssrLoadModule('/resources/js/lib/acceptance-criteria.ts');
|
||||||
|
const items = [
|
||||||
|
{ id: 11, text: 'Parent', indent: 0, checked: false },
|
||||||
|
{ id: 12, text: 'Child', indent: 1, checked: true },
|
||||||
|
{ id: 13, text: 'Grandchild', indent: 2, checked: false },
|
||||||
|
{ id: 14, text: 'Next', indent: 0, checked: false },
|
||||||
|
];
|
||||||
|
const original = structuredClone(items);
|
||||||
|
assert.equal(canIndent(items, 0), false);
|
||||||
|
assert.equal(canIndent(items, 1), false);
|
||||||
|
assert.equal(canIndent(items, 3), true);
|
||||||
|
assert.deepEqual(
|
||||||
|
indent(items, 1, -1).map((item) => item.indent),
|
||||||
|
[0, 0, 1, 0],
|
||||||
|
);
|
||||||
|
assert.deepEqual(indent(indent(items, 1, -1), 1, 1), items);
|
||||||
|
assert.deepEqual(indent(items, 0, -1), items);
|
||||||
|
assert.deepEqual(indent(items, -1, 1), items);
|
||||||
|
assert.deepEqual(remove(items, 0), [
|
||||||
|
{ ...items[1], indent: 0 },
|
||||||
|
{ ...items[2], indent: 1 },
|
||||||
|
items[3],
|
||||||
|
]);
|
||||||
|
assert.deepEqual(remove(items, 1), [
|
||||||
|
items[0],
|
||||||
|
{ ...items[2], indent: 1 },
|
||||||
|
items[3],
|
||||||
|
]);
|
||||||
|
assert.deepEqual(remove(items, 99), items);
|
||||||
|
assert.deepEqual(
|
||||||
|
toggle(items, 0, true).map((item) => item.checked),
|
||||||
|
[true, true, true, false],
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
toggle(items, 1, false).map((item) => item.checked),
|
||||||
|
[false, false, false, false],
|
||||||
|
);
|
||||||
|
const deep = Array.from({ length: 9 }, (_, indent) => ({
|
||||||
|
text: 'Deep',
|
||||||
|
checked: false,
|
||||||
|
indent,
|
||||||
|
}));
|
||||||
|
assert.equal(
|
||||||
|
canIndent([{ text: 'Before', indent: 0, checked: false }, ...deep], 1),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
assert.deepEqual(
|
||||||
|
normalize(remove(items, 0)).map((item) => item.id),
|
||||||
|
[12, 13, 14],
|
||||||
|
);
|
||||||
|
assert.deepEqual(items, original, 'Editing must not mutate saved criteria');
|
||||||
|
const { default: Checklist } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/components/tickets/AcceptanceCriteriaChecklist.vue',
|
||||||
|
);
|
||||||
|
const { createLocalization } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/lib/localization.ts',
|
||||||
|
);
|
||||||
|
const render = (props) =>
|
||||||
|
renderToString(
|
||||||
|
createSSRApp({ render: () => h(Checklist, props) }).use(
|
||||||
|
createLocalization(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const editable = await render({ modelValue: items });
|
||||||
|
assert.equal((editable.match(/<textarea/g) ?? []).length, 4);
|
||||||
|
assert.match(editable, /Indent criterion 4/);
|
||||||
|
assert.match(editable, /1 of 4 complete/);
|
||||||
|
const readonly = await render({ modelValue: items, readonly: true });
|
||||||
|
assert.doesNotMatch(readonly, /<textarea|Add criterion|Edit checklist/);
|
||||||
|
assert.equal((readonly.match(/type="checkbox" disabled/g) ?? []).length, 4);
|
||||||
|
assert.match(
|
||||||
|
await render({ modelValue: [], error: 'Server validation' }),
|
||||||
|
/Server validation/,
|
||||||
|
);
|
||||||
|
console.log('Acceptance criteria behavior checks passed.');
|
||||||
|
} finally {
|
||||||
|
await server.close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,239 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import process from 'node:process';
|
||||||
|
|
||||||
|
const playwright = await import(process.env.PLAYWRIGHT_MODULE ?? 'playwright');
|
||||||
|
const { chromium } = playwright.default ?? playwright;
|
||||||
|
const browser = await chromium.launch({ channel: 'chrome', headless: true });
|
||||||
|
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||||
|
page.setDefaultTimeout(10000);
|
||||||
|
const errors = [];
|
||||||
|
page.on('pageerror', (error) => errors.push(error.message));
|
||||||
|
const base = 'http://127.0.0.1:4181/projects/7/board';
|
||||||
|
const content = () => page.locator('#main-content');
|
||||||
|
const visibleColumns = () =>
|
||||||
|
content().locator('[id^="board-column-title-"]:visible');
|
||||||
|
const visit = async (query = '') => {
|
||||||
|
await page.goto(base + query);
|
||||||
|
await page.getByRole('heading', { level: 1 }).waitFor();
|
||||||
|
await page.evaluate(() => document.fonts.ready);
|
||||||
|
};
|
||||||
|
const tabTo = async (locator) => {
|
||||||
|
await content().focus();
|
||||||
|
for (let step = 0; step < 40; step++) {
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
if (
|
||||||
|
await locator.evaluate(
|
||||||
|
(element) => element === document.activeElement,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
assert.equal(
|
||||||
|
await locator.evaluate((element) =>
|
||||||
|
element.matches(':focus-visible'),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.fail('Board control is unreachable by keyboard');
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
for (const width of [1440, 768, 390, 320]) {
|
||||||
|
await page.setViewportSize({ width, height: 1000 });
|
||||||
|
for (const theme of ['light', 'dark']) {
|
||||||
|
await page.emulateMedia({
|
||||||
|
colorScheme: theme,
|
||||||
|
reducedMotion: 'reduce',
|
||||||
|
});
|
||||||
|
for (const [query, state] of [
|
||||||
|
['', 'filled'],
|
||||||
|
['?empty', 'empty'],
|
||||||
|
['?one&noTickets', 'one-empty'],
|
||||||
|
]) {
|
||||||
|
await visit(query);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('html')
|
||||||
|
.evaluate((el) => el.classList.contains('dark')),
|
||||||
|
theme === 'dark',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
document.documentElement.scrollWidth <=
|
||||||
|
window.innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
`${state} overflow at ${width}/${theme}`,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await visibleColumns().count(),
|
||||||
|
state === 'empty'
|
||||||
|
? 0
|
||||||
|
: width < 768 || state === 'one-empty'
|
||||||
|
? 1
|
||||||
|
: 8,
|
||||||
|
);
|
||||||
|
if (width < 768 && state !== 'empty') {
|
||||||
|
assert.ok(
|
||||||
|
(await page.getByLabel('Choose a column').boundingBox())
|
||||||
|
.height >= 44,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (state === 'filled' && width >= 768) {
|
||||||
|
const region = content().getByRole('region', {
|
||||||
|
name: 'Workflow columns',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
assert.equal(
|
||||||
|
await region.evaluate(
|
||||||
|
(el) => el.scrollWidth > el.clientWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await region.focus();
|
||||||
|
await page.keyboard.press('End');
|
||||||
|
await content()
|
||||||
|
.locator('#board-column-8')
|
||||||
|
.scrollIntoViewIfNeeded();
|
||||||
|
assert.ok(await region.evaluate((el) => el.scrollLeft > 0));
|
||||||
|
await region.evaluate((el) => {
|
||||||
|
el.scrollLeft = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await page.evaluate(() => window.scrollTo(0, 0));
|
||||||
|
await page.screenshot({
|
||||||
|
path: `/private/tmp/kan27-board-${state}-${width}-${theme}.png`,
|
||||||
|
fullPage: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await page.setViewportSize({ width: 390, height: 1000 });
|
||||||
|
await visit();
|
||||||
|
const chooseColumn = page.getByLabel('Choose a column');
|
||||||
|
await tabTo(chooseColumn);
|
||||||
|
// Native popup selection is handled by macOS outside the browser DOM.
|
||||||
|
await chooseColumn.selectOption('2');
|
||||||
|
assert.equal(await chooseColumn.inputValue(), '2');
|
||||||
|
assert.equal(await visibleColumns().innerText(), 'In development');
|
||||||
|
await chooseColumn.selectOption('8');
|
||||||
|
assert.equal(await visibleColumns().innerText(), 'Column without statuses');
|
||||||
|
await content()
|
||||||
|
.getByText('No statuses configured for this column.')
|
||||||
|
.waitFor();
|
||||||
|
await chooseColumn.selectOption('1');
|
||||||
|
await content()
|
||||||
|
.getByRole('heading', { name: 'Ready · Planned', exact: true })
|
||||||
|
.waitFor();
|
||||||
|
await content()
|
||||||
|
.getByRole('heading', { name: 'Ready · Active', exact: true })
|
||||||
|
.waitFor();
|
||||||
|
const terminalSelect = page.getByLabel('Move ENG-43', { exact: true });
|
||||||
|
assert.equal(await terminalSelect.isDisabled(), true);
|
||||||
|
const moveSelect = page.getByLabel('Move ENG-42', { exact: true });
|
||||||
|
assert.deepEqual(
|
||||||
|
await moveSelect
|
||||||
|
.locator('option')
|
||||||
|
.evaluateAll((options) => options.map((option) => option.value)),
|
||||||
|
['20', '11', '99'],
|
||||||
|
);
|
||||||
|
await tabTo(moveSelect);
|
||||||
|
await moveSelect.selectOption('20');
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
assert.equal(await page.locator(':focus').innerText(), 'Update status');
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page
|
||||||
|
.getByText('ENG-42 moved successfully.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(await chooseColumn.inputValue(), '1');
|
||||||
|
assert.match(
|
||||||
|
await chooseColumn.locator('option').first().innerText(),
|
||||||
|
/\(1\)/,
|
||||||
|
);
|
||||||
|
await chooseColumn.selectOption('2');
|
||||||
|
await content()
|
||||||
|
.getByRole('link', {
|
||||||
|
name: 'Open ENG-42: Ship accessible board navigation',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.waitFor();
|
||||||
|
|
||||||
|
await visit();
|
||||||
|
await page.getByLabel('Move ENG-42', { exact: true }).selectOption('99');
|
||||||
|
await content()
|
||||||
|
.locator('article')
|
||||||
|
.filter({ hasText: 'ENG-42' })
|
||||||
|
.getByRole('button', { name: 'Update status' })
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByText('ENG-42 moved successfully.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await content()
|
||||||
|
.getByRole('link', {
|
||||||
|
name: 'Open ENG-42: Ship accessible board navigation',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
assert.match(
|
||||||
|
await chooseColumn.locator('option').first().innerText(),
|
||||||
|
/\(1\)/,
|
||||||
|
);
|
||||||
|
|
||||||
|
await visit('?reject');
|
||||||
|
await page.getByLabel('Move ENG-42', { exact: true }).selectOption('20');
|
||||||
|
await content()
|
||||||
|
.locator('article')
|
||||||
|
.filter({ hasText: 'ENG-42' })
|
||||||
|
.getByRole('button', { name: 'Update status' })
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByText('This transition is no longer allowed.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByLabel('Move ENG-42', { exact: true })
|
||||||
|
.getAttribute('aria-invalid'),
|
||||||
|
'true',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await content()
|
||||||
|
.getByText('This transition is no longer allowed.', { exact: true })
|
||||||
|
.count(),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByLabel('Move ENG-43', { exact: true })
|
||||||
|
.getAttribute('aria-invalid'),
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
|
await visit('?readonly');
|
||||||
|
assert.equal(await content().locator('form').count(), 0);
|
||||||
|
const ticketLink = content().getByRole('link', {
|
||||||
|
name: 'Open ENG-42: Ship accessible board navigation',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await tabTo(ticketLink);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/projects/7/tickets/42');
|
||||||
|
await page
|
||||||
|
.getByRole('heading', { name: 'Destination reached', exact: true })
|
||||||
|
.waitFor();
|
||||||
|
await visit('?empty');
|
||||||
|
await tabTo(
|
||||||
|
content().getByRole('link', { name: 'Open backlog', exact: true }),
|
||||||
|
);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/projects/7/backlog');
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
console.log(
|
||||||
|
'Board browser checks passed: responsive columns, keyboard, status changes and validation, permissions, empty states and both themes.',
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,288 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import process from 'node:process';
|
||||||
|
|
||||||
|
const playwright = await import(process.env.PLAYWRIGHT_MODULE ?? 'playwright');
|
||||||
|
const { chromium } = playwright.default ?? playwright;
|
||||||
|
const browser = await chromium.launch({ channel: 'chrome', headless: true });
|
||||||
|
const page = await browser.newPage({
|
||||||
|
viewport: { width: 1440, height: 1200 },
|
||||||
|
hasTouch: true,
|
||||||
|
});
|
||||||
|
page.setDefaultTimeout(10000);
|
||||||
|
const failures = [];
|
||||||
|
const requests = [];
|
||||||
|
page.on('pageerror', (error) => failures.push(error.message));
|
||||||
|
page.on('request', (request) => {
|
||||||
|
if (['POST', 'PATCH'].includes(request.method())) {
|
||||||
|
requests.push(request);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const base = 'http://127.0.0.1:4181/projects/7/board';
|
||||||
|
const handle = () =>
|
||||||
|
page.getByRole('button', {
|
||||||
|
name: 'Drag ENG-42 to change status',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
const card = () => page.locator('article').filter({ hasText: 'ENG-42' });
|
||||||
|
const visit = async (query = '') => {
|
||||||
|
await page.goto(base + query);
|
||||||
|
await page.getByRole('heading', { level: 1 }).waitFor();
|
||||||
|
requests.length = 0;
|
||||||
|
};
|
||||||
|
const center = async (locator) => {
|
||||||
|
const box = await locator.boundingBox();
|
||||||
|
assert.ok(box);
|
||||||
|
return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
|
||||||
|
};
|
||||||
|
const begin = async () => {
|
||||||
|
await handle().scrollIntoViewIfNeeded();
|
||||||
|
const from = await center(handle());
|
||||||
|
await page.mouse.move(from.x, from.y);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(from.x + 12, from.y, { steps: 3 });
|
||||||
|
};
|
||||||
|
const moveToColumn = async (id) => {
|
||||||
|
const to = await center(page.locator(`#board-column-title-${id}`));
|
||||||
|
await page.mouse.move(to.x, to.y, { steps: 10 });
|
||||||
|
};
|
||||||
|
const dragToColumn = async (id) => {
|
||||||
|
await begin();
|
||||||
|
await moveToColumn(id);
|
||||||
|
await page.mouse.up();
|
||||||
|
};
|
||||||
|
const originalCard = async () => {
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('#board-column-1 article')
|
||||||
|
.filter({ hasText: 'ENG-42' })
|
||||||
|
.count(),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
for (const theme of ['light', 'dark']) {
|
||||||
|
await page.emulateMedia({
|
||||||
|
colorScheme: theme,
|
||||||
|
reducedMotion: 'reduce',
|
||||||
|
});
|
||||||
|
await visit();
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Drag ENG-43 to change status' })
|
||||||
|
.isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await begin();
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('#board-column-2')
|
||||||
|
.evaluate((el) => el.classList.contains('border-primary')),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('#board-column-3')
|
||||||
|
.evaluate((el) => el.classList.contains('opacity-40')),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await moveToColumn(3);
|
||||||
|
await page.mouse.up();
|
||||||
|
await originalCard();
|
||||||
|
assert.equal(requests.length, 0);
|
||||||
|
|
||||||
|
await begin();
|
||||||
|
await moveToColumn(2);
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await page.mouse.up();
|
||||||
|
assert.equal(requests.length, 0);
|
||||||
|
await originalCard();
|
||||||
|
|
||||||
|
// Pointer capture cancellation must never become a drop.
|
||||||
|
await begin();
|
||||||
|
await handle().dispatchEvent('pointercancel', { pointerId: 1 });
|
||||||
|
await page.mouse.up();
|
||||||
|
assert.equal(requests.length, 0);
|
||||||
|
|
||||||
|
await visit('?multiple');
|
||||||
|
await dragToColumn(2);
|
||||||
|
const dialog = page.getByRole('dialog');
|
||||||
|
await dialog.waitFor();
|
||||||
|
assert.equal(requests.length, 0);
|
||||||
|
assert.deepEqual(
|
||||||
|
await dialog
|
||||||
|
.locator('option')
|
||||||
|
.evaluateAll((options) =>
|
||||||
|
options.map((option) => option.value),
|
||||||
|
),
|
||||||
|
['20', '21'],
|
||||||
|
);
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await dialog.waitFor({ state: 'hidden' });
|
||||||
|
assert.equal(
|
||||||
|
await handle().evaluate((el) => el === document.activeElement),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(requests.length, 0);
|
||||||
|
await originalCard();
|
||||||
|
await dragToColumn(2);
|
||||||
|
const select = dialog.getByLabel('Destination status');
|
||||||
|
await select.focus();
|
||||||
|
await select.selectOption('21');
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
assert.equal(await page.locator(':focus').innerText(), 'Update status');
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page
|
||||||
|
.getByText('ENG-42 moved successfully.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(requests.length, 1);
|
||||||
|
assert.deepEqual(requests[0].postDataJSON(), {
|
||||||
|
ticket_status_id: 21,
|
||||||
|
redirect_to: 'board',
|
||||||
|
});
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('#board-column-2 article')
|
||||||
|
.filter({ hasText: 'ENG-42' })
|
||||||
|
.count(),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
|
||||||
|
await visit('?reject');
|
||||||
|
await dragToColumn(2);
|
||||||
|
await page
|
||||||
|
.getByText('This transition is no longer allowed.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
await originalCard();
|
||||||
|
assert.equal(requests.length, 1);
|
||||||
|
|
||||||
|
await visit('?slow');
|
||||||
|
await dragToColumn(2);
|
||||||
|
await page.locator('[data-form-state="loading"]').waitFor();
|
||||||
|
assert.equal(await handle().isDisabled(), true);
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Move ENG-42', { exact: true }).isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
// Attempt a competing form submit even though its controls are disabled.
|
||||||
|
await card()
|
||||||
|
.locator('form')
|
||||||
|
.evaluate((form) => form.requestSubmit());
|
||||||
|
await page
|
||||||
|
.getByText('ENG-42 moved successfully.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(requests.length, 1);
|
||||||
|
|
||||||
|
await visit('?slow');
|
||||||
|
await card()
|
||||||
|
.getByRole('button', { name: 'Update status', exact: true })
|
||||||
|
.click();
|
||||||
|
assert.equal(await handle().isDisabled(), true);
|
||||||
|
await page
|
||||||
|
.getByText('ENG-42 moved successfully.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(requests.length, 1);
|
||||||
|
|
||||||
|
await visit();
|
||||||
|
await page.route('**/tickets/42/status', (route) =>
|
||||||
|
route.abort('failed'),
|
||||||
|
);
|
||||||
|
await dragToColumn(2);
|
||||||
|
await page.locator('[data-form-state="network"]').waitFor();
|
||||||
|
await originalCard();
|
||||||
|
assert.equal(await handle().isEnabled(), true);
|
||||||
|
await page.unroute('**/tickets/42/status');
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Try again', exact: true })
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByText('ENG-42 moved successfully.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(requests.length, 2);
|
||||||
|
|
||||||
|
await visit();
|
||||||
|
await page.route('**/tickets/42/status', (route) =>
|
||||||
|
route.fulfill({ status: 500, body: 'Unavailable' }),
|
||||||
|
);
|
||||||
|
await dragToColumn(2);
|
||||||
|
await page.locator('[data-form-state="server"]').waitFor();
|
||||||
|
await originalCard();
|
||||||
|
await page.unroute('**/tickets/42/status');
|
||||||
|
|
||||||
|
// Normal touch gestures still scroll; only the explicit handle captures a drag.
|
||||||
|
await page.setViewportSize({ width: 390, height: 1000 });
|
||||||
|
await visit('?multiple');
|
||||||
|
await handle().scrollIntoViewIfNeeded();
|
||||||
|
assert.equal(
|
||||||
|
await handle().evaluate((el) => getComputedStyle(el).touchAction),
|
||||||
|
'none',
|
||||||
|
);
|
||||||
|
assert.notEqual(
|
||||||
|
await card().evaluate((el) => getComputedStyle(el).touchAction),
|
||||||
|
'none',
|
||||||
|
);
|
||||||
|
const cdp = await page.context().newCDPSession(page);
|
||||||
|
const from = await center(handle());
|
||||||
|
await cdp.send('Input.dispatchTouchEvent', {
|
||||||
|
type: 'touchStart',
|
||||||
|
touchPoints: [{ ...from, id: 1 }],
|
||||||
|
});
|
||||||
|
await cdp.send('Input.dispatchTouchEvent', {
|
||||||
|
type: 'touchMove',
|
||||||
|
touchPoints: [{ x: from.x + 16, y: from.y, id: 1 }],
|
||||||
|
});
|
||||||
|
const tray = page.locator('[data-board-mobile-targets]');
|
||||||
|
await tray.waitFor();
|
||||||
|
const to = await center(tray.locator('[data-board-drop-column="2"]'));
|
||||||
|
await cdp.send('Input.dispatchTouchEvent', {
|
||||||
|
type: 'touchMove',
|
||||||
|
touchPoints: [{ ...to, id: 1 }],
|
||||||
|
});
|
||||||
|
await page.screenshot({
|
||||||
|
path: `/private/tmp/kan28-mobile-drag-${theme}.png`,
|
||||||
|
fullPage: true,
|
||||||
|
});
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() => document.documentElement.scrollWidth <= innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await cdp.send('Input.dispatchTouchEvent', {
|
||||||
|
type: 'touchEnd',
|
||||||
|
touchPoints: [],
|
||||||
|
});
|
||||||
|
await page.getByRole('dialog').waitFor();
|
||||||
|
await page.getByLabel('Destination status').selectOption('20');
|
||||||
|
await page
|
||||||
|
.getByRole('dialog')
|
||||||
|
.getByRole('button', { name: 'Update status' })
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByText('ENG-42 moved successfully.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Choose a column').inputValue(),
|
||||||
|
'2',
|
||||||
|
);
|
||||||
|
assert.equal(requests.length, 1);
|
||||||
|
await cdp.detach();
|
||||||
|
await page.screenshot({
|
||||||
|
path: `/private/tmp/kan28-mobile-result-${theme}.png`,
|
||||||
|
fullPage: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await visit('?readonly');
|
||||||
|
assert.equal(
|
||||||
|
await page.getByRole('button', { name: /Drag ENG/ }).count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
await page.setViewportSize({ width: 1440, height: 1200 });
|
||||||
|
}
|
||||||
|
assert.deepEqual(failures, []);
|
||||||
|
console.log(
|
||||||
|
'Board drag checks passed: mouse, touch, workflow restrictions, selection, cancellation, focus, request guards and recovery in 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 Board from '../../resources/js/pages/projects/Board.vue';
|
||||||
|
import { createAppearance } from '../../resources/js/composables/useAppearance';
|
||||||
|
import { createLocalization } from '../../resources/js/lib/localization';
|
||||||
|
|
||||||
|
createInertiaApp({
|
||||||
|
resolve: (name) =>
|
||||||
|
name === 'Board'
|
||||||
|
? Board
|
||||||
|
: { 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,287 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import process from 'node:process';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import tailwind from '@tailwindcss/vite';
|
||||||
|
import vue from '@vitejs/plugin-vue';
|
||||||
|
import { createInertiaApp } from '@inertiajs/vue3';
|
||||||
|
import { createServer } from 'vite';
|
||||||
|
import { createSSRApp, h } from 'vue';
|
||||||
|
import { renderToString } from 'vue/server-renderer';
|
||||||
|
|
||||||
|
const serve = process.argv.includes('--serve');
|
||||||
|
const server = await createServer({
|
||||||
|
configFile: false,
|
||||||
|
cacheDir: 'node_modules/.vite/board-fixture',
|
||||||
|
plugins: [vue(), ...(serve ? [tailwind()] : [])],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('../../resources/js', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: serve
|
||||||
|
? { host: '127.0.0.1', port: 4181, strictPort: true, hmr: false }
|
||||||
|
: { middlewareMode: true, hmr: false, watch: null },
|
||||||
|
appType: 'custom',
|
||||||
|
});
|
||||||
|
const project = {
|
||||||
|
id: 7,
|
||||||
|
key: 'ENG',
|
||||||
|
name: 'Engineering · Platform and developer experience',
|
||||||
|
};
|
||||||
|
const columnNames = [
|
||||||
|
'Ready',
|
||||||
|
'In development',
|
||||||
|
'Review',
|
||||||
|
'Testing',
|
||||||
|
'Release',
|
||||||
|
'Done',
|
||||||
|
'Archived',
|
||||||
|
'Column without statuses',
|
||||||
|
];
|
||||||
|
const columns = columnNames.map((name, index) => ({
|
||||||
|
id: index + 1,
|
||||||
|
name,
|
||||||
|
position: index + 1,
|
||||||
|
project_id: 7,
|
||||||
|
tickets: [],
|
||||||
|
ticket_statuses: [],
|
||||||
|
}));
|
||||||
|
const statuses = columns.slice(0, -1).flatMap((column) =>
|
||||||
|
['Planned', 'Active'].map((name, index) => ({
|
||||||
|
id: column.id * 10 + index,
|
||||||
|
name: `${column.name} · ${name}`,
|
||||||
|
position: index + 1,
|
||||||
|
project_id: 7,
|
||||||
|
board_column_id: column.id,
|
||||||
|
board_column: { ...column },
|
||||||
|
})),
|
||||||
|
);
|
||||||
|
const backlog = {
|
||||||
|
id: 99,
|
||||||
|
name: 'Backlog',
|
||||||
|
board_column_id: null,
|
||||||
|
board_column: null,
|
||||||
|
};
|
||||||
|
for (const column of columns) {
|
||||||
|
column.ticket_statuses = statuses.filter(
|
||||||
|
(status) => status.board_column_id === column.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function ticket(id, status, title) {
|
||||||
|
return {
|
||||||
|
id,
|
||||||
|
title,
|
||||||
|
ticket_key: `ENG-${id}`,
|
||||||
|
project_id: 7,
|
||||||
|
sequence_number: id,
|
||||||
|
description:
|
||||||
|
'A real ticket card in the isolated board behavior fixture.',
|
||||||
|
ticket_status_id: status.id,
|
||||||
|
ticket_status: {
|
||||||
|
...status,
|
||||||
|
allowed_target_statuses:
|
||||||
|
id === 42 ? [status, statuses[2], statuses[1], backlog] : [],
|
||||||
|
},
|
||||||
|
ticket_priority: { id: 1, name: 'Urgent custom priority', position: 1 },
|
||||||
|
ticket_type: { id: 1, name: 'Development', is_parent: false },
|
||||||
|
assignee: null,
|
||||||
|
assignee_user_id: null,
|
||||||
|
is_blocked: id === 43,
|
||||||
|
blocked_comment: id === 43 ? 'Awaiting the external review.' : null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function makePage(url) {
|
||||||
|
const parsed = new URL(url, 'http://localhost');
|
||||||
|
const params = parsed.searchParams;
|
||||||
|
const isBoard = parsed.pathname === '/projects/7/board';
|
||||||
|
const boardColumns = structuredClone(
|
||||||
|
params.has('empty')
|
||||||
|
? []
|
||||||
|
: params.has('one')
|
||||||
|
? columns.slice(0, 1)
|
||||||
|
: columns,
|
||||||
|
);
|
||||||
|
if (!params.has('noTickets')) {
|
||||||
|
const target =
|
||||||
|
[...statuses, backlog].find(
|
||||||
|
(status) => status.id === Number(params.get('target')),
|
||||||
|
) ?? statuses[0];
|
||||||
|
const tickets = [
|
||||||
|
ticket(42, target, 'Ship accessible board navigation'),
|
||||||
|
ticket(
|
||||||
|
43,
|
||||||
|
statuses[1],
|
||||||
|
'InvestigateALongUnbrokenTicketTitleThatMustWrapEvenOnTheSmallestMobileScreenWithoutClipping',
|
||||||
|
),
|
||||||
|
];
|
||||||
|
if (params.has('multiple')) {
|
||||||
|
tickets[0].ticket_status.allowed_target_statuses.push(statuses[3]);
|
||||||
|
}
|
||||||
|
for (const column of boardColumns) {
|
||||||
|
column.tickets = tickets.filter(
|
||||||
|
(item) => item.ticket_status.board_column_id === column.id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
component: isBoard ? 'Board' : 'Destination',
|
||||||
|
url,
|
||||||
|
version: null,
|
||||||
|
clearHistory: false,
|
||||||
|
encryptHistory: false,
|
||||||
|
props: {
|
||||||
|
name: 'KanbanGit',
|
||||||
|
errors: params.has('rejected')
|
||||||
|
? {
|
||||||
|
'board-ticket-42': {
|
||||||
|
ticket_status_id:
|
||||||
|
'This transition is no longer allowed.',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
: {},
|
||||||
|
sidebarOpen: true,
|
||||||
|
auth: {
|
||||||
|
user: {
|
||||||
|
id: 1,
|
||||||
|
name: 'Alex Morgan',
|
||||||
|
email: 'alex@example.test',
|
||||||
|
avatar: null,
|
||||||
|
},
|
||||||
|
permissions: {
|
||||||
|
globalAdmin: false,
|
||||||
|
projectCreate: false,
|
||||||
|
canManageTeams: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
navigation: {
|
||||||
|
project: {
|
||||||
|
...project,
|
||||||
|
canManage: false,
|
||||||
|
canCreateTickets: !params.has('readonly'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
project,
|
||||||
|
boardColumns,
|
||||||
|
canCreateTickets: !params.has('readonly'),
|
||||||
|
canEditTickets: !params.has('readonly'),
|
||||||
|
status: params.has('target') ? 'ENG-42 moved successfully.' : null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (serve) {
|
||||||
|
server.middlewares.use(async (request, response) => {
|
||||||
|
if (request.method === 'POST' || request.method === 'PATCH') {
|
||||||
|
let body = '';
|
||||||
|
for await (const chunk of request) {
|
||||||
|
body += chunk;
|
||||||
|
}
|
||||||
|
const data = JSON.parse(body);
|
||||||
|
assert.equal(
|
||||||
|
request.url,
|
||||||
|
request.method === 'POST'
|
||||||
|
? '/projects/7/tickets/42/status?_method=PATCH'
|
||||||
|
: '/projects/7/tickets/42/status',
|
||||||
|
);
|
||||||
|
assert.deepEqual(Object.keys(data).sort(), [
|
||||||
|
'redirect_to',
|
||||||
|
'ticket_status_id',
|
||||||
|
]);
|
||||||
|
assert.equal(data.redirect_to, 'board');
|
||||||
|
assert.ok([11, 20, 21, 99].includes(Number(data.ticket_status_id)));
|
||||||
|
const previous = new URL(request.headers.referer);
|
||||||
|
const reject = previous.searchParams.has('reject');
|
||||||
|
if (previous.searchParams.has('slow')) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
|
}
|
||||||
|
response.writeHead(303, {
|
||||||
|
Location: `/projects/7/board?${reject ? 'reject&rejected' : `target=${data.ticket_status_id}`}`,
|
||||||
|
});
|
||||||
|
response.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const page = makePage(request.url);
|
||||||
|
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/board-preview.mjs"></script></body></html>',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await server.listen();
|
||||||
|
console.log(
|
||||||
|
'Board fixture ready at http://127.0.0.1:4181/projects/7/board',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const { createLocalization } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/lib/localization.ts',
|
||||||
|
);
|
||||||
|
const { createAppearance } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/composables/useAppearance.ts',
|
||||||
|
);
|
||||||
|
const { default: Board } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/pages/projects/Board.vue',
|
||||||
|
);
|
||||||
|
const render = async (query = '') => {
|
||||||
|
const result = await createInertiaApp({
|
||||||
|
page: makePage(`/projects/7/board${query}`),
|
||||||
|
resolve: () => Board,
|
||||||
|
render: renderToString,
|
||||||
|
setup: ({ App, props, plugin }) =>
|
||||||
|
createSSRApp({ render: () => h(App, props) })
|
||||||
|
.use(plugin)
|
||||||
|
.use(createLocalization())
|
||||||
|
.use(createAppearance('light')),
|
||||||
|
});
|
||||||
|
return result.body.split('id="main-content"')[1];
|
||||||
|
};
|
||||||
|
const board = await render();
|
||||||
|
assert.equal((board.match(/id="board-column-title-/g) ?? []).length, 8);
|
||||||
|
assert.equal((board.match(/id="board-status-/g) ?? []).length, 14);
|
||||||
|
assert.match(board, /Ready · Planned/);
|
||||||
|
assert.match(board, /Ready · Active/);
|
||||||
|
assert.match(board, /No statuses configured for this column/);
|
||||||
|
assert.match(board, /No tickets in this column/);
|
||||||
|
assert.match(board, /No tickets in this status/);
|
||||||
|
assert.match(board, /2 tickets/);
|
||||||
|
assert.match(board, /Urgent custom priority/);
|
||||||
|
assert.match(board, /href="\/projects\/7\/tickets\/42"/);
|
||||||
|
assert.match(
|
||||||
|
board,
|
||||||
|
/action="\/projects\/7\/tickets\/42\/status\?_method=PATCH"/,
|
||||||
|
);
|
||||||
|
assert.match(
|
||||||
|
board,
|
||||||
|
/href="\/projects\/7\/tickets\/create\?source=board"/,
|
||||||
|
);
|
||||||
|
assert.match(board, /href="\/projects\/7\/backlog"/);
|
||||||
|
assert.match(board, /No allowed moves/);
|
||||||
|
assert.equal((board.match(/<article/g) ?? []).length, 2);
|
||||||
|
const readonly = await render('?readonly');
|
||||||
|
assert.doesNotMatch(readonly, /<form|Move ENG-|New ticket/);
|
||||||
|
const empty = await render('?empty');
|
||||||
|
assert.match(empty, /No workflow columns yet/);
|
||||||
|
assert.doesNotMatch(empty, /id="board-column"|<article/);
|
||||||
|
const one = await render('?one&noTickets');
|
||||||
|
assert.equal((one.match(/id="board-column-title-/g) ?? []).length, 1);
|
||||||
|
assert.match(one, /0 tickets/);
|
||||||
|
assert.doesNotMatch(one, /<article/);
|
||||||
|
console.log('Board behavior checks passed.');
|
||||||
|
} finally {
|
||||||
|
await server.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import process from 'node:process';
|
||||||
|
|
||||||
|
const playwright = await import(process.env.PLAYWRIGHT_MODULE ?? 'playwright');
|
||||||
|
const { chromium } = playwright.default ?? playwright;
|
||||||
|
const browser = await chromium.launch({ channel: 'chrome', headless: true });
|
||||||
|
const base = 'http://127.0.0.1:4180';
|
||||||
|
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 content = () => page.locator('#main-content');
|
||||||
|
const focusWithTab = async (link) => {
|
||||||
|
await content().focus();
|
||||||
|
for (let step = 0; step < 40; step++) {
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
if (
|
||||||
|
await link.evaluate((element) => element === document.activeElement)
|
||||||
|
) {
|
||||||
|
assert.equal(
|
||||||
|
await link.evaluate((element) =>
|
||||||
|
element.matches(':focus-visible'),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.fail('Dashboard action was not reachable by keyboard');
|
||||||
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
reducedMotion: 'reduce',
|
||||||
|
});
|
||||||
|
for (const [path, state] of [
|
||||||
|
['/dashboard', 'filled'],
|
||||||
|
['/dashboard?empty', 'empty'],
|
||||||
|
]) {
|
||||||
|
await page.goto(base + path);
|
||||||
|
await page
|
||||||
|
.getByRole('heading', {
|
||||||
|
name: 'Welcome back, Alex Morgan',
|
||||||
|
exact: true,
|
||||||
|
level: 1,
|
||||||
|
})
|
||||||
|
.waitFor();
|
||||||
|
await page.evaluate(() => document.fonts.ready);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('html')
|
||||||
|
.evaluate((element) =>
|
||||||
|
element.classList.contains('dark'),
|
||||||
|
),
|
||||||
|
theme === 'dark',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
document.documentElement.scrollWidth <=
|
||||||
|
window.innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
`${state} dashboard overflows at ${width} in ${theme}`,
|
||||||
|
);
|
||||||
|
await page.screenshot({
|
||||||
|
path: `/private/tmp/kan25-dashboard-${state}-${width}-${theme}.png`,
|
||||||
|
fullPage: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.setViewportSize({ width: 390, height: 1000 });
|
||||||
|
await page.goto(`${base}/dashboard`);
|
||||||
|
const ticket = content().getByRole('link', {
|
||||||
|
name: 'Open ENG-42: Ship the dashboard with real assigned work',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await focusWithTab(ticket);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/projects/7/tickets/42');
|
||||||
|
await page
|
||||||
|
.getByRole('heading', { name: 'Destination reached', exact: true })
|
||||||
|
.waitFor();
|
||||||
|
|
||||||
|
await page.goto(`${base}/dashboard?empty`);
|
||||||
|
const projects = content().getByRole('link', {
|
||||||
|
name: 'Browse projects',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await focusWithTab(projects);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/projects');
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
console.log(
|
||||||
|
'Dashboard browser checks passed: keyboard, empty and filled states, 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 Dashboard from '../../resources/js/pages/Dashboard.vue';
|
||||||
|
import { createAppearance } from '../../resources/js/composables/useAppearance';
|
||||||
|
import { createLocalization } from '../../resources/js/lib/localization';
|
||||||
|
|
||||||
|
createInertiaApp({
|
||||||
|
resolve: (name) =>
|
||||||
|
({ Dashboard })[name] ?? {
|
||||||
|
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,248 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import process from 'node:process';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import tailwind from '@tailwindcss/vite';
|
||||||
|
import vue from '@vitejs/plugin-vue';
|
||||||
|
import { createInertiaApp } from '@inertiajs/vue3';
|
||||||
|
import { createServer } from 'vite';
|
||||||
|
import { createSSRApp, h } from 'vue';
|
||||||
|
import { renderToString } from 'vue/server-renderer';
|
||||||
|
|
||||||
|
const serve = process.argv.includes('--serve');
|
||||||
|
const server = await createServer({
|
||||||
|
configFile: false,
|
||||||
|
cacheDir: 'node_modules/.vite/dashboard-fixture',
|
||||||
|
plugins: [vue(), ...(serve ? [tailwind()] : [])],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('../../resources/js', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: serve
|
||||||
|
? { host: '127.0.0.1', port: 4180, strictPort: true, hmr: false }
|
||||||
|
: { middlewareMode: true, hmr: false, watch: null },
|
||||||
|
appType: 'custom',
|
||||||
|
});
|
||||||
|
|
||||||
|
const user = {
|
||||||
|
id: 8,
|
||||||
|
name: 'Alex Morgan',
|
||||||
|
email: 'alex@example.test',
|
||||||
|
avatar: null,
|
||||||
|
avatar_color: '#22c55e',
|
||||||
|
avatar_is_generated: true,
|
||||||
|
email_verified_at: '2026-09-11T00:00:00Z',
|
||||||
|
must_change_password_on_next_login: false,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
};
|
||||||
|
const project = {
|
||||||
|
id: 7,
|
||||||
|
key: 'ENG',
|
||||||
|
name: 'Engineering · Platform and developer experience',
|
||||||
|
show_author: true,
|
||||||
|
show_story_points: true,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
};
|
||||||
|
const secondProject = {
|
||||||
|
...project,
|
||||||
|
id: 9,
|
||||||
|
key: 'OPS',
|
||||||
|
name: 'Operations',
|
||||||
|
};
|
||||||
|
const ticketDefaults = {
|
||||||
|
acceptance_criteria: [],
|
||||||
|
assignee: user,
|
||||||
|
assignee_user_id: user.id,
|
||||||
|
author: null,
|
||||||
|
author_user_id: null,
|
||||||
|
blocked_comment: null,
|
||||||
|
description: 'Real work loaded from the server.',
|
||||||
|
is_blocked: false,
|
||||||
|
parent_ticket_id: null,
|
||||||
|
story_points: 3,
|
||||||
|
ticket_priority: {
|
||||||
|
id: 1,
|
||||||
|
name: 'Medium',
|
||||||
|
position: 3,
|
||||||
|
project_id: 7,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
},
|
||||||
|
ticket_priority_id: 1,
|
||||||
|
ticket_status: {
|
||||||
|
id: 3,
|
||||||
|
board_column_id: 2,
|
||||||
|
name: 'In Progress',
|
||||||
|
position: 1,
|
||||||
|
project_id: 7,
|
||||||
|
slug: 'in-progress',
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
board_column: {
|
||||||
|
id: 2,
|
||||||
|
name: 'In Progress',
|
||||||
|
position: 2,
|
||||||
|
project_id: 7,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ticket_status_id: 3,
|
||||||
|
ticket_type: {
|
||||||
|
id: 1,
|
||||||
|
is_parent: false,
|
||||||
|
name: 'Dev task',
|
||||||
|
position: 1,
|
||||||
|
project_id: 7,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
},
|
||||||
|
ticket_type_id: 1,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
};
|
||||||
|
const tickets = [
|
||||||
|
{
|
||||||
|
...ticketDefaults,
|
||||||
|
id: 42,
|
||||||
|
project_id: project.id,
|
||||||
|
sequence_number: 42,
|
||||||
|
ticket_key: 'ENG-42',
|
||||||
|
title: 'Ship the dashboard with real assigned work',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
...ticketDefaults,
|
||||||
|
id: 41,
|
||||||
|
project_id: project.id,
|
||||||
|
sequence_number: 41,
|
||||||
|
ticket_key: 'ENG-41',
|
||||||
|
title: 'Verify keyboard navigation',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const blockedTicket = {
|
||||||
|
...ticketDefaults,
|
||||||
|
id: 12,
|
||||||
|
blocked_comment: 'Waiting for review.',
|
||||||
|
is_blocked: true,
|
||||||
|
project_id: secondProject.id,
|
||||||
|
sequence_number: 12,
|
||||||
|
ticket_key: 'OPS-12',
|
||||||
|
title: 'Resolve the deployment blocker',
|
||||||
|
};
|
||||||
|
const assignedTicketsByProject = [
|
||||||
|
{ project: secondProject, tickets: [blockedTicket] },
|
||||||
|
{ project, tickets },
|
||||||
|
];
|
||||||
|
|
||||||
|
function makePage(url) {
|
||||||
|
const parsedUrl = new URL(url, 'http://localhost');
|
||||||
|
const isDashboard = parsedUrl.pathname === '/dashboard';
|
||||||
|
return {
|
||||||
|
component: isDashboard ? 'Dashboard' : 'Destination',
|
||||||
|
url,
|
||||||
|
version: null,
|
||||||
|
clearHistory: false,
|
||||||
|
encryptHistory: false,
|
||||||
|
props: {
|
||||||
|
name: 'KanbanGit',
|
||||||
|
errors: {},
|
||||||
|
sidebarOpen: true,
|
||||||
|
auth: {
|
||||||
|
user,
|
||||||
|
permissions: {
|
||||||
|
globalAdmin: false,
|
||||||
|
projectCreate: false,
|
||||||
|
canManageTeams: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
navigation: { project: null },
|
||||||
|
...(isDashboard
|
||||||
|
? {
|
||||||
|
assignedTicketsByProject: parsedUrl.searchParams.has(
|
||||||
|
'empty',
|
||||||
|
)
|
||||||
|
? []
|
||||||
|
: assignedTicketsByProject,
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serve) {
|
||||||
|
server.middlewares.use(async (request, response) => {
|
||||||
|
const page = makePage(request.url);
|
||||||
|
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/dashboard-preview.mjs"></script></body></html>',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await server.listen();
|
||||||
|
console.log('Dashboard fixture ready at http://127.0.0.1:4180/dashboard');
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const { createLocalization } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/lib/localization.ts',
|
||||||
|
);
|
||||||
|
const { createAppearance } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/composables/useAppearance.ts',
|
||||||
|
);
|
||||||
|
const { default: Dashboard } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/pages/Dashboard.vue',
|
||||||
|
);
|
||||||
|
const render = async (url) => {
|
||||||
|
const response = await createInertiaApp({
|
||||||
|
page: makePage(url),
|
||||||
|
resolve: () => Dashboard,
|
||||||
|
render: renderToString,
|
||||||
|
setup: ({ App, props, plugin }) =>
|
||||||
|
createSSRApp({ render: () => h(App, props) })
|
||||||
|
.use(plugin)
|
||||||
|
.use(createLocalization())
|
||||||
|
.use(createAppearance('light')),
|
||||||
|
});
|
||||||
|
return response.body.split('<main')[1].split('</main>')[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
const dashboard = await render('/dashboard');
|
||||||
|
assert.match(dashboard, /Welcome back, Alex Morgan/);
|
||||||
|
assert.match(dashboard, /Assigned tickets/);
|
||||||
|
assert.match(dashboard, /Projects with assigned work/);
|
||||||
|
assert.match(dashboard, /Blocked tickets/);
|
||||||
|
assert.match(dashboard, /Ship the dashboard with real assigned work/);
|
||||||
|
assert.match(dashboard, /Resolve the deployment blocker/);
|
||||||
|
assert.match(dashboard, /href="\/projects\/7\/tickets\/42"/);
|
||||||
|
assert.match(dashboard, /href="\/projects\/9"/);
|
||||||
|
assert.doesNotMatch(
|
||||||
|
dashboard,
|
||||||
|
/API-integration|Finished this week|Recent activity|PlaceholderPattern/,
|
||||||
|
);
|
||||||
|
|
||||||
|
const empty = await render('/dashboard?empty');
|
||||||
|
assert.match(empty, /No tickets assigned to you/);
|
||||||
|
assert.match(empty, /href="\/projects"/);
|
||||||
|
assert.doesNotMatch(empty, /ENG-42|OPS-12|<article/);
|
||||||
|
|
||||||
|
console.log('Dashboard behavior checks passed.');
|
||||||
|
} finally {
|
||||||
|
await server.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -320,15 +320,18 @@ try {
|
|||||||
await page.goto(`${base}/projects/7/tickets/create`);
|
await page.goto(`${base}/projects/7/tickets/create`);
|
||||||
await page.locator('#title').fill('New ticket draft');
|
await page.locator('#title').fill('New ticket draft');
|
||||||
await page.locator('#description').fill('Keep this description');
|
await page.locator('#description').fill('Keep this description');
|
||||||
|
await page.getByRole('button', { name: 'Add criterion' }).click();
|
||||||
await page
|
await page
|
||||||
.locator('#acceptance_criteria_checklist')
|
.getByRole('textbox', { name: 'Criterion 1', exact: true })
|
||||||
.fill('[ ] Keep this checklist');
|
.fill('Keep this checklist');
|
||||||
await setResult('validation');
|
await setResult('validation');
|
||||||
await page.locator('form button[type="submit"]').first().click();
|
await page.locator('form button[type="submit"]').first().click();
|
||||||
await state('validation');
|
await state('validation');
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await page.locator('#acceptance_criteria_checklist').inputValue(),
|
await page
|
||||||
'[ ] Keep this checklist',
|
.getByRole('textbox', { name: 'Criterion 1', exact: true })
|
||||||
|
.inputValue(),
|
||||||
|
'Keep this checklist',
|
||||||
);
|
);
|
||||||
await page.route('**/projects/7/tickets', (route) => route.abort('failed'));
|
await page.route('**/projects/7/tickets', (route) => route.abort('failed'));
|
||||||
await page.locator('form button[type="submit"]').first().click();
|
await page.locator('form button[type="submit"]').first().click();
|
||||||
@@ -349,18 +352,22 @@ try {
|
|||||||
await page.locator('#title').waitFor();
|
await page.locator('#title').waitFor();
|
||||||
assert.equal(await page.locator('#title').inputValue(), 'New ticket draft');
|
assert.equal(await page.locator('#title').inputValue(), 'New ticket draft');
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await page.locator('#acceptance_criteria_checklist').inputValue(),
|
await page
|
||||||
'[ ] Keep this checklist',
|
.getByRole('textbox', { name: 'Criterion 1', exact: true })
|
||||||
|
.inputValue(),
|
||||||
|
'Keep this checklist',
|
||||||
);
|
);
|
||||||
await setResult('success');
|
await setResult('success');
|
||||||
await page.locator('form button[type="submit"]').first().click();
|
await page.locator('form button[type="submit"]').first().click();
|
||||||
await page.getByRole('heading', { name: 'Destination' }).waitFor();
|
await page.getByRole('heading', { name: 'Destination' }).waitFor();
|
||||||
|
|
||||||
await page.goto(`${base}/projects/7/tickets/31`);
|
await page.goto(`${base}/projects/7/tickets/31`);
|
||||||
|
await page.locator('#ticket-edit > summary').click();
|
||||||
await page.locator('#title').fill('Updated ticket draft');
|
await page.locator('#title').fill('Updated ticket draft');
|
||||||
|
await page.getByRole('button', { name: 'Add criterion' }).click();
|
||||||
await page
|
await page
|
||||||
.locator('#acceptance_criteria_checklist')
|
.getByRole('textbox', { name: 'Criterion 1', exact: true })
|
||||||
.fill('[ ] Edited checklist');
|
.fill('Edited checklist');
|
||||||
await setResult('server');
|
await setResult('server');
|
||||||
await page.locator('form button[type="submit"]').first().click();
|
await page.locator('form button[type="submit"]').first().click();
|
||||||
await state('server');
|
await state('server');
|
||||||
@@ -369,8 +376,10 @@ try {
|
|||||||
'Updated ticket draft',
|
'Updated ticket draft',
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await page.locator('#acceptance_criteria_checklist').inputValue(),
|
await page
|
||||||
'[ ] Edited checklist',
|
.getByRole('textbox', { name: 'Criterion 1', exact: true })
|
||||||
|
.inputValue(),
|
||||||
|
'Edited checklist',
|
||||||
);
|
);
|
||||||
await setResult('success');
|
await setResult('success');
|
||||||
await page.getByRole('button', { name: 'Try again' }).click();
|
await page.getByRole('button', { name: 'Try again' }).click();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import process from 'node:process';
|
||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import tailwind from '@tailwindcss/vite';
|
import tailwind from '@tailwindcss/vite';
|
||||||
import { createServer } from 'vite';
|
import { createServer } from 'vite';
|
||||||
@@ -36,9 +37,23 @@ let ticket = {
|
|||||||
ticket_status: status,
|
ticket_status: status,
|
||||||
is_blocked: false,
|
is_blocked: false,
|
||||||
story_points: 0,
|
story_points: 0,
|
||||||
acceptance_criteria: [],
|
acceptance_criteria: process.env.CRITERIA_FIXTURE
|
||||||
|
? [
|
||||||
|
{ id: 11, text: 'Parent criterion', indent: 0, checked: false },
|
||||||
|
{ id: 12, text: 'Nested criterion', indent: 1, checked: true },
|
||||||
|
{ id: 13, text: 'Deep criterion', indent: 2, checked: false },
|
||||||
|
{
|
||||||
|
id: 14,
|
||||||
|
text: 'Independent criterion',
|
||||||
|
indent: 0,
|
||||||
|
checked: false,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [],
|
||||||
field_values: [],
|
field_values: [],
|
||||||
worklog_entries: [],
|
worklog_entries: [],
|
||||||
|
created_at: '2026-09-10T12:00:00Z',
|
||||||
|
updated_at: '2026-09-11T12:00:00Z',
|
||||||
};
|
};
|
||||||
|
|
||||||
server.middlewares.use(async (request, response, next) => {
|
server.middlewares.use(async (request, response, next) => {
|
||||||
@@ -123,7 +138,7 @@ server.middlewares.use(async (request, response, next) => {
|
|||||||
ticketStatusOptions: [status],
|
ticketStatusOptions: [status],
|
||||||
users: [],
|
users: [],
|
||||||
parentTicketOptions: [],
|
parentTicketOptions: [],
|
||||||
canEditTicket: true,
|
canEditTicket: !url.searchParams.has('readonly'),
|
||||||
canManageProject: true,
|
canManageProject: true,
|
||||||
childTicketTree: [],
|
childTicketTree: [],
|
||||||
linkedTickets: [],
|
linkedTickets: [],
|
||||||
|
|||||||
@@ -0,0 +1,334 @@
|
|||||||
|
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:4179';
|
||||||
|
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));
|
||||||
|
page.on('dialog', (dialog) => dialog.accept());
|
||||||
|
const setResult = (value) =>
|
||||||
|
context.addCookies([{ name: 'creation_test_result', value, url: base }]);
|
||||||
|
const content = () => page.locator('#main-content');
|
||||||
|
const state = (value) =>
|
||||||
|
page.locator(`[data-form-state="${value}"]`).waitFor({ state: 'visible' });
|
||||||
|
const choose = async (value) => {
|
||||||
|
await page.locator(`input[name="creation_mode"][value="${value}"]`).focus();
|
||||||
|
await page.keyboard.press('Space');
|
||||||
|
};
|
||||||
|
const fillDetails = async () => {
|
||||||
|
await page
|
||||||
|
.getByLabel('Project name', { exact: true })
|
||||||
|
.fill('Frontend workspace');
|
||||||
|
await page.getByLabel('Project key', { exact: true }).fill('web');
|
||||||
|
};
|
||||||
|
const submit = () =>
|
||||||
|
page.getByRole('button', { name: 'Create project', exact: true }).click();
|
||||||
|
const focusWithTab = async (target) => {
|
||||||
|
await content().focus();
|
||||||
|
for (let step = 0; step < 40; step++) {
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
if (
|
||||||
|
await target.evaluate(
|
||||||
|
(element) => element === document.activeElement,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
assert.equal(
|
||||||
|
await target.evaluate((element) =>
|
||||||
|
element.matches(':focus-visible'),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.fail('Form control was not reachable by keyboard');
|
||||||
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
reducedMotion: 'reduce',
|
||||||
|
});
|
||||||
|
await page.goto(
|
||||||
|
`${base}/projects/create?viewport=${width}&theme=${theme}`,
|
||||||
|
);
|
||||||
|
await page
|
||||||
|
.getByRole('heading', { name: 'Create a project' })
|
||||||
|
.waitFor();
|
||||||
|
for (const mode of ['scratch', 'duplicate', 'template']) {
|
||||||
|
await choose(mode);
|
||||||
|
await page.evaluate(() => document.fonts.ready);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('html')
|
||||||
|
.evaluate((element) =>
|
||||||
|
element.classList.contains('dark'),
|
||||||
|
),
|
||||||
|
theme === 'dark',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
document.documentElement.scrollWidth <=
|
||||||
|
window.innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
`${mode} overflows at ${width} in ${theme}`,
|
||||||
|
);
|
||||||
|
await page.screenshot({
|
||||||
|
path: `/private/tmp/kan24-${mode}-${width}-${theme}.png`,
|
||||||
|
fullPage: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await choose('scratch');
|
||||||
|
const scratch = page.getByRole('radio', {
|
||||||
|
name: 'Start from scratch',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await focusWithTab(scratch);
|
||||||
|
await page.keyboard.press('ArrowRight');
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('radio', {
|
||||||
|
name: 'Duplicate a project',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.isChecked(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
const board = page.getByRole('checkbox', {
|
||||||
|
name: 'Board columns',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await focusWithTab(board);
|
||||||
|
await page.keyboard.press('Space');
|
||||||
|
assert.equal(await board.isChecked(), true);
|
||||||
|
const source = page.getByLabel('Source project', { exact: true });
|
||||||
|
await focusWithTab(source);
|
||||||
|
await page.keyboard.press('o');
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
await page.waitForFunction(
|
||||||
|
() =>
|
||||||
|
document.querySelector('#source_project_id').value === '8',
|
||||||
|
);
|
||||||
|
assert.equal(await source.inputValue(), '8');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.goto(`${base}/projects/create?empty`);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('radio', { name: 'Start from scratch', exact: true })
|
||||||
|
.isChecked(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('radio', { name: 'Duplicate a project', exact: true })
|
||||||
|
.isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('radio', { name: 'Use a template', exact: true })
|
||||||
|
.isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await fillDetails();
|
||||||
|
const scratchRequest = page.waitForRequest(
|
||||||
|
(request) => request.method() === 'POST',
|
||||||
|
);
|
||||||
|
await submit();
|
||||||
|
assert.deepEqual((await scratchRequest).postDataJSON(), {
|
||||||
|
name: 'Frontend workspace',
|
||||||
|
key: 'web',
|
||||||
|
creation_mode: 'scratch',
|
||||||
|
source_project_id: '',
|
||||||
|
source_template_id: '',
|
||||||
|
copy_areas: [],
|
||||||
|
});
|
||||||
|
await page.waitForURL('**/projects/99');
|
||||||
|
|
||||||
|
await page.goto(`${base}/projects/create?template=4`);
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Template', { exact: true }).inputValue(),
|
||||||
|
'4',
|
||||||
|
);
|
||||||
|
await page
|
||||||
|
.getByText('This template uses the default project setup.', {
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.waitFor();
|
||||||
|
await fillDetails();
|
||||||
|
const templateRequest = page.waitForRequest(
|
||||||
|
(request) => request.method() === 'POST',
|
||||||
|
);
|
||||||
|
await submit();
|
||||||
|
const templateData = (await templateRequest).postDataJSON();
|
||||||
|
assert.equal(templateData.creation_mode, 'template');
|
||||||
|
assert.equal(templateData.source_template_id, '4');
|
||||||
|
assert.equal(templateData.source_project_id, '');
|
||||||
|
assert.deepEqual(templateData.copy_areas, []);
|
||||||
|
await page.waitForURL('**/projects/99');
|
||||||
|
|
||||||
|
await page.goto(`${base}/projects/create`);
|
||||||
|
await choose('duplicate');
|
||||||
|
await fillDetails();
|
||||||
|
await page.getByLabel('Source project', { exact: true }).selectOption('8');
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', { name: 'Board columns', exact: true })
|
||||||
|
.check();
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', { name: 'Custom ticket fields', exact: true })
|
||||||
|
.check();
|
||||||
|
await page.getByText('2 areas selected', { exact: true }).waitFor();
|
||||||
|
await page.getByText('WEB-1', { exact: true }).waitFor();
|
||||||
|
await choose('template');
|
||||||
|
await choose('scratch');
|
||||||
|
await choose('duplicate');
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Source project', { exact: true }).inputValue(),
|
||||||
|
'8',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', { name: 'Board columns', exact: true })
|
||||||
|
.isChecked(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', {
|
||||||
|
name: 'Custom ticket fields',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.isChecked(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
|
await setResult('validation');
|
||||||
|
const duplicateRequest = page.waitForRequest(
|
||||||
|
(request) => request.method() === 'POST',
|
||||||
|
);
|
||||||
|
await submit();
|
||||||
|
const duplicateData = (await duplicateRequest).postDataJSON();
|
||||||
|
assert.equal(duplicateData.source_project_id, '8');
|
||||||
|
assert.equal(duplicateData.source_template_id, '');
|
||||||
|
assert.deepEqual(duplicateData.copy_areas, [
|
||||||
|
'board_columns',
|
||||||
|
'ticket_fields',
|
||||||
|
]);
|
||||||
|
await state('validation');
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Project name', { exact: true }).inputValue(),
|
||||||
|
'Frontend workspace',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByLabel('Project key', { exact: true })
|
||||||
|
.getAttribute('aria-invalid'),
|
||||||
|
'true',
|
||||||
|
);
|
||||||
|
await page
|
||||||
|
.getByText('The key has already been taken.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
await page
|
||||||
|
.getByText('Select a valid configuration area.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', { name: 'Board columns', exact: true })
|
||||||
|
.getAttribute('aria-invalid'),
|
||||||
|
'true',
|
||||||
|
);
|
||||||
|
|
||||||
|
await choose('scratch');
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByText('Select a valid configuration area.', { exact: true })
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByLabel('Project key', { exact: true })
|
||||||
|
.getAttribute('aria-invalid'),
|
||||||
|
'true',
|
||||||
|
);
|
||||||
|
await choose('duplicate');
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', { name: 'Board columns', exact: true })
|
||||||
|
.isChecked(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('checkbox', { name: 'Board columns', exact: true })
|
||||||
|
.getAttribute('aria-invalid'),
|
||||||
|
'false',
|
||||||
|
);
|
||||||
|
|
||||||
|
await page.route('**/projects', (route) => route.abort('failed'));
|
||||||
|
await submit();
|
||||||
|
await state('network');
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Project name', { exact: true }).inputValue(),
|
||||||
|
'Frontend workspace',
|
||||||
|
);
|
||||||
|
await page.unroute('**/projects');
|
||||||
|
await setResult('server');
|
||||||
|
await page.getByRole('button', { name: 'Try again' }).click();
|
||||||
|
await state('server');
|
||||||
|
await setResult('success');
|
||||||
|
let pending;
|
||||||
|
let submissions = 0;
|
||||||
|
await page.route('**/projects', (route) => {
|
||||||
|
submissions++;
|
||||||
|
pending = route;
|
||||||
|
});
|
||||||
|
await page.getByRole('button', { name: 'Try again' }).click();
|
||||||
|
await state('loading');
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Creating project…', exact: true })
|
||||||
|
.isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Project name', { exact: true }).isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await page.locator('form').evaluate((form) => form.requestSubmit());
|
||||||
|
assert.equal(submissions, 1);
|
||||||
|
await pending.continue();
|
||||||
|
await page.waitForURL('**/projects/99');
|
||||||
|
await page.unroute('**/projects');
|
||||||
|
|
||||||
|
await page.goto(`${base}/projects/create`);
|
||||||
|
await choose('duplicate');
|
||||||
|
await fillDetails();
|
||||||
|
const emptyCopyRequest = page.waitForRequest(
|
||||||
|
(request) => request.method() === 'POST',
|
||||||
|
);
|
||||||
|
await submit();
|
||||||
|
assert.deepEqual((await emptyCopyRequest).postDataJSON().copy_areas, []);
|
||||||
|
await page.waitForURL('**/projects/99');
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
console.log(
|
||||||
|
'Project creation browser checks passed: all modes, preselection, payloads, retained input, validation, retry, duplicate submission protection, 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 Create from '../../resources/js/pages/projects/Create.vue';
|
||||||
|
import { createAppearance } from '../../resources/js/composables/useAppearance';
|
||||||
|
import { createLocalization } from '../../resources/js/lib/localization';
|
||||||
|
|
||||||
|
createInertiaApp({
|
||||||
|
resolve: (name) =>
|
||||||
|
name === 'Create'
|
||||||
|
? Create
|
||||||
|
: { render: () => h('h1', 'Project created') },
|
||||||
|
setup: ({ el, App, props, plugin }) =>
|
||||||
|
createApp({ render: () => h(App, props) })
|
||||||
|
.use(plugin)
|
||||||
|
.use(createLocalization())
|
||||||
|
.use(createAppearance())
|
||||||
|
.mount(el),
|
||||||
|
});
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
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-creation-fixture',
|
||||||
|
plugins: [vue(), ...(serve ? [tailwind()] : [])],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('../../resources/js', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: serve
|
||||||
|
? { host: '127.0.0.1', port: 4179, strictPort: true, hmr: false }
|
||||||
|
: { middlewareMode: true, hmr: false, watch: null },
|
||||||
|
appType: 'custom',
|
||||||
|
});
|
||||||
|
const areas = [
|
||||||
|
'project_settings',
|
||||||
|
'board_columns',
|
||||||
|
'ticket_statuses',
|
||||||
|
'status_transitions',
|
||||||
|
'ticket_types',
|
||||||
|
'ticket_priorities',
|
||||||
|
'ticket_fields',
|
||||||
|
'ticket_link_types',
|
||||||
|
'repository_connections',
|
||||||
|
'notification_actions',
|
||||||
|
];
|
||||||
|
function makePage(url, errors = {}) {
|
||||||
|
const query = new URL(url, 'http://localhost').searchParams;
|
||||||
|
return {
|
||||||
|
component: url.startsWith('/projects/create')
|
||||||
|
? 'Create'
|
||||||
|
: 'Destination',
|
||||||
|
url,
|
||||||
|
version: null,
|
||||||
|
clearHistory: false,
|
||||||
|
encryptHistory: false,
|
||||||
|
props: {
|
||||||
|
name: 'KanbanGit',
|
||||||
|
errors,
|
||||||
|
sidebarOpen: true,
|
||||||
|
auth: {
|
||||||
|
user: {
|
||||||
|
id: 1,
|
||||||
|
name: 'Alex Morgan',
|
||||||
|
email: 'alex@example.test',
|
||||||
|
avatar: null,
|
||||||
|
},
|
||||||
|
permissions: {
|
||||||
|
globalAdmin: false,
|
||||||
|
projectCreate: true,
|
||||||
|
canManageTeams: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
navigation: { project: null },
|
||||||
|
copyAreaOptions: areas.map((value) => ({
|
||||||
|
value,
|
||||||
|
label: value,
|
||||||
|
description: 'Server description',
|
||||||
|
})),
|
||||||
|
sourceProjects: query.has('empty')
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
id: 7,
|
||||||
|
key: 'ENG',
|
||||||
|
name: 'Engineering · Platform and developer experience',
|
||||||
|
},
|
||||||
|
{ id: 8, key: 'OPS', name: 'Operations' },
|
||||||
|
],
|
||||||
|
sourceTemplates:
|
||||||
|
query.has('empty') || query.has('no-templates')
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
name: 'Team baseline',
|
||||||
|
slug: 'team-baseline',
|
||||||
|
copy_areas: ['board_columns', 'ticket_types'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 4,
|
||||||
|
name: 'Minimal setup',
|
||||||
|
slug: 'minimal',
|
||||||
|
copy_areas: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
selectedSourceTemplateId: query.has('template')
|
||||||
|
? Number(query.get('template'))
|
||||||
|
: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (serve) {
|
||||||
|
// Real Vue/Inertia form with isolated transport; PHPUnit covers persisted projects.
|
||||||
|
server.middlewares.use(async (request, response, next) => {
|
||||||
|
if (!request.url.startsWith('/projects')) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
let url = request.url;
|
||||||
|
let errors = {};
|
||||||
|
if (request.method === 'POST') {
|
||||||
|
const result =
|
||||||
|
request.headers.cookie?.match(
|
||||||
|
/creation_test_result=(\w+)/,
|
||||||
|
)?.[1] ?? 'success';
|
||||||
|
let body = '';
|
||||||
|
for await (const chunk of request) {
|
||||||
|
body += chunk;
|
||||||
|
}
|
||||||
|
const data = JSON.parse(body);
|
||||||
|
if (result === 'server') {
|
||||||
|
response.statusCode = 503;
|
||||||
|
response.end('Simulated server failure');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
url = result === 'validation' ? '/projects/create' : '/projects/99';
|
||||||
|
if (result === 'validation') {
|
||||||
|
errors = {
|
||||||
|
key: 'The key has already been taken.',
|
||||||
|
...(data.creation_mode === 'duplicate'
|
||||||
|
? {
|
||||||
|
'copy_areas.0':
|
||||||
|
'Select a valid configuration area.',
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const page = makePage(url, errors);
|
||||||
|
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-creation-preview.mjs"></script></body></html>',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await server.listen();
|
||||||
|
console.log(
|
||||||
|
'Project creation fixture ready at http://127.0.0.1:4179/projects/create',
|
||||||
|
);
|
||||||
|
} 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 Create = (
|
||||||
|
await server.ssrLoadModule(
|
||||||
|
'/resources/js/pages/projects/Create.vue',
|
||||||
|
)
|
||||||
|
).default;
|
||||||
|
const render = async (
|
||||||
|
url,
|
||||||
|
errors = {},
|
||||||
|
locale = createLocalization(),
|
||||||
|
) => {
|
||||||
|
const response = await createInertiaApp({
|
||||||
|
page: makePage(url, errors),
|
||||||
|
resolve: () => Create,
|
||||||
|
render: renderToString,
|
||||||
|
setup: ({ App, props, plugin }) =>
|
||||||
|
createSSRApp({ render: () => h(App, props) })
|
||||||
|
.use(plugin)
|
||||||
|
.use(locale)
|
||||||
|
.use(createAppearance('light')),
|
||||||
|
});
|
||||||
|
return response.body.split('<main')[1].split('</main>')[0];
|
||||||
|
};
|
||||||
|
const empty = await render('/projects/create?empty');
|
||||||
|
assert.match(empty, /value="scratch"[^>]*checked/);
|
||||||
|
assert.match(empty, /value="duplicate"[^>]*disabled/);
|
||||||
|
assert.match(empty, /value="template"[^>]*disabled/);
|
||||||
|
assert.match(empty, /No accessible projects/);
|
||||||
|
assert.match(empty, /No published templates/);
|
||||||
|
assert.doesNotMatch(empty, /<select/);
|
||||||
|
const scratch = await render('/projects/create?no-templates');
|
||||||
|
assert.match(scratch, /value="duplicate"[^>]*aria-invalid="false"/);
|
||||||
|
assert.doesNotMatch(scratch, /value="duplicate"[^>]*disabled/);
|
||||||
|
const template = await render('/projects/create');
|
||||||
|
assert.match(template, /value="template"[^>]*checked/);
|
||||||
|
assert.match(template, /Team baseline/);
|
||||||
|
assert.match(template, /Board columns/);
|
||||||
|
assert.match(template, /Ticket types/);
|
||||||
|
assert.match(template, /The project stays linked to this template/);
|
||||||
|
assert.doesNotMatch(template, /Server description/);
|
||||||
|
const preselected = await render('/projects/create?template=4');
|
||||||
|
assert.match(preselected, /Minimal setup/);
|
||||||
|
assert.match(
|
||||||
|
preselected,
|
||||||
|
/This template uses the default project setup/,
|
||||||
|
);
|
||||||
|
for (const id of [
|
||||||
|
'name-error',
|
||||||
|
'key-help',
|
||||||
|
'key-error',
|
||||||
|
'template-help',
|
||||||
|
'source-template-error',
|
||||||
|
'creation-mode-error',
|
||||||
|
]) {
|
||||||
|
assert.ok(
|
||||||
|
template.includes(`id="${id}"`),
|
||||||
|
`Missing accessible feedback target: ${id}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const translated = await render(
|
||||||
|
'/projects/create',
|
||||||
|
{},
|
||||||
|
createLocalization(
|
||||||
|
{ locale: 'de' },
|
||||||
|
{
|
||||||
|
de: {
|
||||||
|
...en,
|
||||||
|
'projectCreation.title': 'Projekt anlegen',
|
||||||
|
'projectCreation.areas.boardColumns.label':
|
||||||
|
'Boardspalten',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
assert.match(translated, /Projekt anlegen/);
|
||||||
|
assert.match(translated, /Boardspalten/);
|
||||||
|
console.log('Project creation rendering checks passed.');
|
||||||
|
} finally {
|
||||||
|
await server.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
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:4178';
|
||||||
|
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 setRole = (value) =>
|
||||||
|
context.addCookies([{ name: 'project_test_role', value, url: base }]);
|
||||||
|
const content = () => page.locator('#main-content');
|
||||||
|
const focusWithTab = async (link) => {
|
||||||
|
await content().focus();
|
||||||
|
for (let step = 0; step < 30; step++) {
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
if (
|
||||||
|
await link.evaluate((element) => element === document.activeElement)
|
||||||
|
) {
|
||||||
|
assert.equal(
|
||||||
|
await link.evaluate((element) =>
|
||||||
|
element.matches(':focus-visible'),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.fail('Project action was not reachable by keyboard');
|
||||||
|
};
|
||||||
|
|
||||||
|
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,
|
||||||
|
reducedMotion: 'reduce',
|
||||||
|
});
|
||||||
|
await setRole('admin');
|
||||||
|
for (const [path, title, label] of [
|
||||||
|
['/projects', 'Projects', 'index'],
|
||||||
|
[
|
||||||
|
'/projects/7?template',
|
||||||
|
'Engineering · Platform and developer experience',
|
||||||
|
'hub',
|
||||||
|
],
|
||||||
|
['/projects?empty', 'Projects', 'empty'],
|
||||||
|
]) {
|
||||||
|
await page.goto(base + path);
|
||||||
|
await page
|
||||||
|
.getByRole('heading', {
|
||||||
|
name: title,
|
||||||
|
exact: true,
|
||||||
|
level: 1,
|
||||||
|
})
|
||||||
|
.waitFor();
|
||||||
|
await page.evaluate(() => document.fonts.ready);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('html')
|
||||||
|
.evaluate((element) =>
|
||||||
|
element.classList.contains('dark'),
|
||||||
|
),
|
||||||
|
theme === 'dark',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
document.documentElement.scrollWidth <=
|
||||||
|
window.innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
`${label} overflows at ${width} in ${theme}`,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await content().locator('a a, a button').count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
await page.screenshot({
|
||||||
|
path: `/private/tmp/kan23-${label}-${width}-${theme}.png`,
|
||||||
|
fullPage: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await page.goto(`${base}/projects/7`);
|
||||||
|
const board = content().getByRole('link', {
|
||||||
|
name: 'Open board',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await focusWithTab(board);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/projects/7/board');
|
||||||
|
await page
|
||||||
|
.getByRole('heading', { name: 'Destination reached' })
|
||||||
|
.waitFor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await setRole('reader');
|
||||||
|
await page.goto(`${base}/projects`);
|
||||||
|
assert.equal(
|
||||||
|
await content()
|
||||||
|
.getByRole('link', { name: 'New project', exact: true })
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
const overview = content().getByRole('link', {
|
||||||
|
name: 'Open Engineering · Platform and developer experience overview',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await focusWithTab(overview);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/projects/7');
|
||||||
|
assert.equal(
|
||||||
|
await content()
|
||||||
|
.locator(
|
||||||
|
'a[href*="/settings/"], a[href$="/access"], a[href*="/templates/"]',
|
||||||
|
)
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
await content()
|
||||||
|
.getByRole('link', { name: 'Open backlog', exact: true })
|
||||||
|
.click();
|
||||||
|
await page.waitForURL('**/projects/7/backlog');
|
||||||
|
|
||||||
|
await setRole('admin');
|
||||||
|
await page.goto(`${base}/projects/7`);
|
||||||
|
const settings = content().getByRole('region', {
|
||||||
|
name: 'Project settings',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
assert.equal(await settings.getByRole('link').count(), 6);
|
||||||
|
const general = settings.getByRole('link', {
|
||||||
|
name: 'General',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await focusWithTab(general);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/projects/7/settings/general');
|
||||||
|
|
||||||
|
await setRole('creator');
|
||||||
|
await page.goto(`${base}/projects?empty`);
|
||||||
|
const create = content().getByRole('link', {
|
||||||
|
name: 'Create your first project',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await focusWithTab(create);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/projects/create');
|
||||||
|
await page.goto(`${base}/projects/7`);
|
||||||
|
await content()
|
||||||
|
.getByRole('link', { name: 'Save as new template', exact: true })
|
||||||
|
.click();
|
||||||
|
await page.waitForURL('**/projects/7/templates/create');
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
console.log(
|
||||||
|
'Project overview browser checks passed: keyboard, navigation, permissions, empty states, 320/390/1440px and both themes.',
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { createApp, h } from 'vue';
|
||||||
|
import { createInertiaApp } from '@inertiajs/vue3';
|
||||||
|
import '../../resources/css/app.css';
|
||||||
|
import Index from '../../resources/js/pages/projects/Index.vue';
|
||||||
|
import Show from '../../resources/js/pages/projects/Show.vue';
|
||||||
|
import { createAppearance } from '../../resources/js/composables/useAppearance';
|
||||||
|
import { createLocalization } from '../../resources/js/lib/localization';
|
||||||
|
|
||||||
|
createInertiaApp({
|
||||||
|
resolve: (name) =>
|
||||||
|
({ Index, Show })[name] ?? {
|
||||||
|
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,263 @@
|
|||||||
|
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-overview-fixture',
|
||||||
|
plugins: [vue(), ...(serve ? [tailwind()] : [])],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('../../resources/js', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: serve
|
||||||
|
? { host: '127.0.0.1', port: 4178, strictPort: true, hmr: false }
|
||||||
|
: { middlewareMode: true, hmr: false, watch: null },
|
||||||
|
appType: 'custom',
|
||||||
|
});
|
||||||
|
const project = {
|
||||||
|
id: 7,
|
||||||
|
key: 'ENG',
|
||||||
|
name: 'Engineering · Platform and developer experience',
|
||||||
|
};
|
||||||
|
const secondProject = { id: 8, key: 'OPS', name: 'Operations' };
|
||||||
|
const templateState = {
|
||||||
|
inheritsFromTemplate: true,
|
||||||
|
templateName: 'Team baseline',
|
||||||
|
inheritedAreas: [{ value: 'board_columns', label: 'Board columns' }],
|
||||||
|
overriddenAreas: [{ value: 'ticket_types', label: 'Ticket types' }],
|
||||||
|
};
|
||||||
|
function makePage(
|
||||||
|
url,
|
||||||
|
{
|
||||||
|
manage = false,
|
||||||
|
create = false,
|
||||||
|
empty = false,
|
||||||
|
template = false,
|
||||||
|
status = null,
|
||||||
|
} = {},
|
||||||
|
) {
|
||||||
|
const path = new URL(url, 'http://localhost').pathname;
|
||||||
|
const isIndex = path === '/projects';
|
||||||
|
const isShow = path === '/projects/7';
|
||||||
|
return {
|
||||||
|
component: isIndex ? 'Index' : isShow ? 'Show' : 'Destination',
|
||||||
|
url,
|
||||||
|
version: null,
|
||||||
|
clearHistory: false,
|
||||||
|
encryptHistory: false,
|
||||||
|
props: {
|
||||||
|
name: 'KanbanGit',
|
||||||
|
errors: {},
|
||||||
|
sidebarOpen: true,
|
||||||
|
auth: {
|
||||||
|
user: {
|
||||||
|
id: 1,
|
||||||
|
name: 'Alex Morgan',
|
||||||
|
email: 'alex@example.test',
|
||||||
|
avatar: null,
|
||||||
|
},
|
||||||
|
permissions: {
|
||||||
|
globalAdmin: false,
|
||||||
|
projectCreate: create,
|
||||||
|
canManageTeams: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
navigation: {
|
||||||
|
project: isIndex
|
||||||
|
? null
|
||||||
|
: {
|
||||||
|
...project,
|
||||||
|
canManage: manage,
|
||||||
|
canCreateTickets: manage,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...(isIndex
|
||||||
|
? { projects: empty ? [] : [project, secondProject], status }
|
||||||
|
: {
|
||||||
|
project,
|
||||||
|
canManageAccess: manage,
|
||||||
|
templateState: template ? templateState : null,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (serve) {
|
||||||
|
// Isolated transport for real Vue pages. PHPUnit covers actual permissions and resources.
|
||||||
|
server.middlewares.use(async (request, response, next) => {
|
||||||
|
const url = new URL(request.url, 'http://localhost');
|
||||||
|
if (!url.pathname.startsWith('/projects')) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
const role = request.headers.cookie?.match(
|
||||||
|
/project_test_role=(\w+)/,
|
||||||
|
)?.[1];
|
||||||
|
const page = makePage(request.url, {
|
||||||
|
manage: role === 'admin',
|
||||||
|
create: role === 'creator',
|
||||||
|
empty: url.searchParams.has('empty'),
|
||||||
|
template: url.searchParams.has('template'),
|
||||||
|
});
|
||||||
|
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-overview-preview.mjs"></script></body></html>',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await server.listen();
|
||||||
|
console.log(
|
||||||
|
'Project overview fixture ready at http://127.0.0.1:4178/projects',
|
||||||
|
);
|
||||||
|
} 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 pages = Object.fromEntries(
|
||||||
|
await Promise.all(
|
||||||
|
['Index', 'Show'].map(async (name) => [
|
||||||
|
name,
|
||||||
|
(
|
||||||
|
await server.ssrLoadModule(
|
||||||
|
`/resources/js/pages/projects/${name}.vue`,
|
||||||
|
)
|
||||||
|
).default,
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const render = async (
|
||||||
|
url,
|
||||||
|
options = {},
|
||||||
|
locale = createLocalization(),
|
||||||
|
) => {
|
||||||
|
const response = await createInertiaApp({
|
||||||
|
page: makePage(url, options),
|
||||||
|
resolve: (name) => pages[name],
|
||||||
|
render: renderToString,
|
||||||
|
setup: ({ App, props, plugin }) =>
|
||||||
|
createSSRApp({ render: () => h(App, props) })
|
||||||
|
.use(plugin)
|
||||||
|
.use(locale)
|
||||||
|
.use(createAppearance('light')),
|
||||||
|
});
|
||||||
|
return response.body.split('<main')[1].split('</main>')[0];
|
||||||
|
};
|
||||||
|
const index = await render('/projects');
|
||||||
|
assert.match(index, /2 projects available/);
|
||||||
|
for (const id of [7, 8]) {
|
||||||
|
for (const suffix of ['', '/board', '/backlog']) {
|
||||||
|
assert.ok(index.includes(`href="/projects/${id}${suffix}"`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.doesNotMatch(
|
||||||
|
index,
|
||||||
|
/href="\/projects\/create"|upcoming|will later/,
|
||||||
|
);
|
||||||
|
const empty = await render('/projects', { empty: true });
|
||||||
|
assert.match(empty, /No projects to show/);
|
||||||
|
assert.match(empty, /Ask a workspace or project administrator/);
|
||||||
|
assert.doesNotMatch(empty, /href="\/projects\/create"|<article/);
|
||||||
|
const creator = await render('/projects', {
|
||||||
|
empty: true,
|
||||||
|
create: true,
|
||||||
|
status: 'Project deleted.',
|
||||||
|
});
|
||||||
|
assert.match(creator, /href="\/projects\/create"/);
|
||||||
|
assert.match(creator, /Create your first project/);
|
||||||
|
assert.match(creator, /role="status"[^>]*data-feedback="success"/);
|
||||||
|
assert.match(creator, /Project deleted\./);
|
||||||
|
const reader = await render('/projects/7');
|
||||||
|
assert.match(reader, /aria-label="Open board"/);
|
||||||
|
assert.match(reader, /aria-label="Open backlog"/);
|
||||||
|
assert.doesNotMatch(
|
||||||
|
reader,
|
||||||
|
/href="\/projects\/7\/(settings|access|templates)/,
|
||||||
|
);
|
||||||
|
const admin = await render('/projects/7', {
|
||||||
|
manage: true,
|
||||||
|
template: true,
|
||||||
|
});
|
||||||
|
for (const suffix of [
|
||||||
|
'settings/general',
|
||||||
|
'settings/board',
|
||||||
|
'settings/metadata',
|
||||||
|
'settings/repositories',
|
||||||
|
'settings/notifications',
|
||||||
|
'access',
|
||||||
|
]) {
|
||||||
|
assert.ok(admin.includes(`href="/projects/7/${suffix}"`));
|
||||||
|
}
|
||||||
|
assert.doesNotMatch(admin, /href="\/projects\/7\/templates/);
|
||||||
|
assert.match(admin, /Based on Team baseline/);
|
||||||
|
assert.match(admin, /Board columns · inherited/);
|
||||||
|
assert.match(admin, /Ticket types · overridden/);
|
||||||
|
assert.match(
|
||||||
|
await render('/projects/7', { create: true }),
|
||||||
|
/href="\/projects\/7\/templates\/create"/,
|
||||||
|
);
|
||||||
|
const translated = await render(
|
||||||
|
'/projects',
|
||||||
|
{},
|
||||||
|
createLocalization(
|
||||||
|
{ locale: 'de' },
|
||||||
|
{
|
||||||
|
de: {
|
||||||
|
...en,
|
||||||
|
'navigation.projects': 'Projekte',
|
||||||
|
'projects.overview': 'Projektübersicht',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
assert.match(translated, /Projekte/);
|
||||||
|
assert.match(translated, /Projektübersicht/);
|
||||||
|
assert.doesNotMatch(
|
||||||
|
index + reader + admin,
|
||||||
|
/upcoming|will later|Use the project shortcuts/,
|
||||||
|
);
|
||||||
|
let insideLink = false;
|
||||||
|
for (const [tag] of (index + reader + admin).matchAll(
|
||||||
|
/<\/?a\b[^>]*>/g,
|
||||||
|
)) {
|
||||||
|
if (tag.startsWith('</')) {
|
||||||
|
insideLink = false;
|
||||||
|
} else {
|
||||||
|
assert.equal(insideLink, false, 'Links must not be nested');
|
||||||
|
insideLink = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('Project overview behavior checks passed.');
|
||||||
|
} finally {
|
||||||
|
await server.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,302 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import process from 'node:process';
|
||||||
|
const playwright = await import(process.env.PLAYWRIGHT_MODULE ?? 'playwright');
|
||||||
|
const { chromium } = playwright.default ?? playwright;
|
||||||
|
const browser = await chromium.launch({ channel: 'chrome', headless: true });
|
||||||
|
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||||
|
page.setDefaultTimeout(10000);
|
||||||
|
const errors = [];
|
||||||
|
page.on('pageerror', (error) => errors.push(error.message));
|
||||||
|
const base = 'http://127.0.0.1:4185/projects/7/tickets/42';
|
||||||
|
const content = () => page.locator('#main-content');
|
||||||
|
const visit = async (query = '') => {
|
||||||
|
await page.goto(base + query);
|
||||||
|
await page.getByRole('heading', { level: 1 }).waitFor();
|
||||||
|
};
|
||||||
|
const edit = () => page.locator('#ticket-edit > summary');
|
||||||
|
const tabTo = async (locator) => {
|
||||||
|
await content().focus();
|
||||||
|
for (let step = 0; step < 45; step++) {
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
if (
|
||||||
|
await locator.evaluate(
|
||||||
|
(element) => element === document.activeElement,
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
assert.equal(
|
||||||
|
await locator.evaluate((element) =>
|
||||||
|
element.matches(':focus-visible'),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.fail('Ticket control is unreachable by keyboard');
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
for (const width of [1440, 768, 390, 320]) {
|
||||||
|
await page.setViewportSize({ width, height: 1000 });
|
||||||
|
for (const theme of ['light', 'dark']) {
|
||||||
|
await page.emulateMedia({
|
||||||
|
colorScheme: theme,
|
||||||
|
reducedMotion: 'reduce',
|
||||||
|
});
|
||||||
|
for (const query of ['', '?empty', '?long']) {
|
||||||
|
await visit(query);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('html')
|
||||||
|
.evaluate((el) => el.classList.contains('dark')),
|
||||||
|
theme === 'dark',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
document.documentElement.scrollWidth <=
|
||||||
|
window.innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
`Page overflow at ${width}/${theme}/${query}`,
|
||||||
|
);
|
||||||
|
const description = await page
|
||||||
|
.locator('#ticket-description')
|
||||||
|
.boundingBox();
|
||||||
|
const metadata = await page
|
||||||
|
.locator('#ticket-metadata')
|
||||||
|
.boundingBox();
|
||||||
|
if (width >= 1280) {
|
||||||
|
assert.ok(
|
||||||
|
metadata.x > description.x + description.width,
|
||||||
|
'Desktop metadata must be beside the content.',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
assert.ok(
|
||||||
|
metadata.y > description.y + description.height,
|
||||||
|
'Mobile metadata must be stacked.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await edit().click();
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Title', { exact: true }).isVisible(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
document.documentElement.scrollWidth <=
|
||||||
|
window.innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
`Editor overflow at ${width}/${theme}/${query}`,
|
||||||
|
);
|
||||||
|
await edit().click();
|
||||||
|
}
|
||||||
|
await visit();
|
||||||
|
await page.screenshot({
|
||||||
|
path: `/private/tmp/kan30-detail-${width}-${theme}.png`,
|
||||||
|
fullPage: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await page.setViewportSize({ width: 390, height: 1000 });
|
||||||
|
await visit();
|
||||||
|
await tabTo(edit());
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.getByLabel('Title', { exact: true }).fill('Unsaved title draft');
|
||||||
|
await page
|
||||||
|
.locator('#ticket-checklist')
|
||||||
|
.getByRole('checkbox', {
|
||||||
|
name: 'Complete criterion 1: Cache requests safely',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.click();
|
||||||
|
await page.waitForFunction(
|
||||||
|
() =>
|
||||||
|
document.querySelectorAll(
|
||||||
|
'#ticket-checklist input[type=checkbox]',
|
||||||
|
)[1].checked,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Title', { exact: true }).inputValue(),
|
||||||
|
'Unsaved title draft',
|
||||||
|
);
|
||||||
|
await page
|
||||||
|
.getByLabel('Criterion 1', { exact: true })
|
||||||
|
.fill('A draft checklist item');
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('#ticket-checklist')
|
||||||
|
.getByRole('checkbox', {
|
||||||
|
name: 'Complete criterion 1: Cache requests safely',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await edit().click();
|
||||||
|
await edit().click();
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Title', { exact: true }).inputValue(),
|
||||||
|
'Unsaved title draft',
|
||||||
|
);
|
||||||
|
page.once('dialog', (dialog) => dialog.dismiss());
|
||||||
|
await content()
|
||||||
|
.getByRole('link', { name: 'Open board', exact: true })
|
||||||
|
.click();
|
||||||
|
assert.match(page.url(), /\/tickets\/42/);
|
||||||
|
page.once('dialog', (dialog) => dialog.accept());
|
||||||
|
await content()
|
||||||
|
.getByRole('link', { name: 'Open board', exact: true })
|
||||||
|
.click();
|
||||||
|
await page.waitForURL('**/projects/7/board');
|
||||||
|
await page.goBack();
|
||||||
|
await edit().waitFor();
|
||||||
|
if (!(await page.locator('#ticket-edit').getAttribute('open'))) {
|
||||||
|
await edit().click();
|
||||||
|
}
|
||||||
|
if (!(await page.getByLabel('Title', { exact: true }).isVisible())) {
|
||||||
|
await edit().click();
|
||||||
|
}
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Title', { exact: true }).inputValue(),
|
||||||
|
'Unsaved title draft',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Criterion 1', { exact: true }).inputValue(),
|
||||||
|
'A draft checklist item',
|
||||||
|
);
|
||||||
|
await visit('?reject');
|
||||||
|
await edit().click();
|
||||||
|
await page.getByLabel('Title', { exact: true }).fill('Rejected draft');
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Save changes', exact: true })
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByText('This title is not allowed.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Title', { exact: true }).inputValue(),
|
||||||
|
'Rejected draft',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.getByLabel('Title', { exact: true })
|
||||||
|
.getAttribute('aria-invalid'),
|
||||||
|
'true',
|
||||||
|
);
|
||||||
|
await visit();
|
||||||
|
await edit().click();
|
||||||
|
await page
|
||||||
|
.getByLabel('Title', { exact: true })
|
||||||
|
.fill('Saved updated ticket title');
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Save changes', exact: true })
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByRole('heading', {
|
||||||
|
name: 'Saved updated ticket title',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.waitFor();
|
||||||
|
await page.getByText('Ticket updated.', { exact: true }).waitFor();
|
||||||
|
await visit('?rejectToggle');
|
||||||
|
await page
|
||||||
|
.locator('#ticket-checklist')
|
||||||
|
.getByRole('checkbox', {
|
||||||
|
name: 'Complete criterion 1: Cache requests safely',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.click();
|
||||||
|
await page
|
||||||
|
.getByRole('alert')
|
||||||
|
.filter({ hasText: 'Checklist status could not be saved' })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('#ticket-checklist')
|
||||||
|
.getByRole('checkbox', {
|
||||||
|
name: 'Complete criterion 1: Cache requests safely',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.isChecked(),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
await visit();
|
||||||
|
const createBranch = page.getByRole('button', {
|
||||||
|
name: 'Create branch',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
await tabTo(createBranch);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
const dialog = page.getByRole('dialog');
|
||||||
|
await dialog.waitFor();
|
||||||
|
await page
|
||||||
|
.getByText('Branch name is available.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await dialog.waitFor({ state: 'hidden' });
|
||||||
|
assert.equal(
|
||||||
|
await createBranch.evaluate((el) => el === document.activeElement),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await createBranch.click();
|
||||||
|
await page
|
||||||
|
.getByText('Branch name is available.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
await page.getByRole('button', { name: 'Create now', exact: true }).click();
|
||||||
|
await dialog.waitFor({ state: 'hidden' });
|
||||||
|
const linkSaved = page.waitForResponse(
|
||||||
|
(response) =>
|
||||||
|
response.url().includes('/tickets/42/links') &&
|
||||||
|
response.request().method() === 'POST',
|
||||||
|
);
|
||||||
|
await page.getByLabel('Linked ticket', { exact: true }).selectOption('41');
|
||||||
|
await page.getByRole('button', { name: 'Save link', exact: true }).click();
|
||||||
|
assert.equal((await linkSaved).status(), 303);
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Remove link to ENG-41', exact: true })
|
||||||
|
.waitFor();
|
||||||
|
const linkRemoved = page.waitForResponse(
|
||||||
|
(response) =>
|
||||||
|
response.url().includes('/tickets/42/links/3') &&
|
||||||
|
response.request().method() === 'DELETE',
|
||||||
|
);
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Remove link to ENG-41', exact: true })
|
||||||
|
.click();
|
||||||
|
assert.equal((await linkRemoved).status(), 303);
|
||||||
|
await visit('?readonly&hideAuthor&hidePoints');
|
||||||
|
assert.equal(await content().locator('form').count(), 0);
|
||||||
|
assert.equal(
|
||||||
|
await content().getByText('Sam Chen', { exact: true }).count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await content()
|
||||||
|
.getByText('Estimated story points', { exact: true })
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
await tabTo(
|
||||||
|
content().getByRole('link', {
|
||||||
|
name: 'ENG-41 Related infrastructure',
|
||||||
|
exact: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await page.waitForURL('**/tickets/41');
|
||||||
|
await page
|
||||||
|
.getByRole('heading', { name: 'Related infrastructure', exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await page.getByLabel('Title', { exact: true }).inputValue(),
|
||||||
|
'Related infrastructure',
|
||||||
|
);
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
console.log(
|
||||||
|
'Ticket detail browser checks passed: desktop/mobile, both themes, keyboard, drafts, saves, checklist rollback, links, Git dialog and direct navigation.',
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import { createApp, h } from 'vue';
|
||||||
|
import { createInertiaApp } from '@inertiajs/vue3';
|
||||||
|
import '../../resources/css/app.css';
|
||||||
|
import Ticket from '../../resources/js/pages/projects/Ticket.vue';
|
||||||
|
import TicketCreate from '../../resources/js/pages/projects/TicketCreate.vue';
|
||||||
|
import { createAppearance } from '../../resources/js/composables/useAppearance';
|
||||||
|
import { createLocalization } from '../../resources/js/lib/localization';
|
||||||
|
|
||||||
|
createInertiaApp({
|
||||||
|
resolve: (name) =>
|
||||||
|
name === 'TicketCreate'
|
||||||
|
? TicketCreate
|
||||||
|
: name === 'Ticket'
|
||||||
|
? Ticket
|
||||||
|
: { 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,611 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import process from 'node:process';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import tailwind from '@tailwindcss/vite';
|
||||||
|
import vue from '@vitejs/plugin-vue';
|
||||||
|
import { createInertiaApp } from '@inertiajs/vue3';
|
||||||
|
import { createServer } from 'vite';
|
||||||
|
import { createSSRApp, h } from 'vue';
|
||||||
|
import { renderToString } from 'vue/server-renderer';
|
||||||
|
|
||||||
|
const serve = process.argv.includes('--serve');
|
||||||
|
const server = await createServer({
|
||||||
|
configFile: false,
|
||||||
|
cacheDir: 'node_modules/.vite/ticket-detail-fixture',
|
||||||
|
plugins: [vue(), ...(serve ? [tailwind()] : [])],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('../../resources/js', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: serve
|
||||||
|
? { host: '127.0.0.1', port: 4185, strictPort: true, hmr: false }
|
||||||
|
: { middlewareMode: true, hmr: false, watch: null },
|
||||||
|
appType: 'custom',
|
||||||
|
});
|
||||||
|
const user = {
|
||||||
|
id: 1,
|
||||||
|
name: 'Alex Morgan',
|
||||||
|
email: 'alex@example.test',
|
||||||
|
avatar: null,
|
||||||
|
};
|
||||||
|
const project = {
|
||||||
|
id: 7,
|
||||||
|
key: 'ENG',
|
||||||
|
name: 'Engineering',
|
||||||
|
show_author: true,
|
||||||
|
show_story_points: true,
|
||||||
|
};
|
||||||
|
const repository = {
|
||||||
|
id: 9,
|
||||||
|
provider: 'gitea',
|
||||||
|
provider_label: 'Gitea',
|
||||||
|
base_url: 'https://git.example.test',
|
||||||
|
repository_full_name: 'Engineering/platform',
|
||||||
|
has_personal_access: true,
|
||||||
|
};
|
||||||
|
const parent = {
|
||||||
|
id: 40,
|
||||||
|
ticket_key: 'ENG-40',
|
||||||
|
title: 'Platform delivery',
|
||||||
|
project_id: 7,
|
||||||
|
};
|
||||||
|
const linked = {
|
||||||
|
id: 41,
|
||||||
|
ticket_key: 'ENG-41',
|
||||||
|
title: 'Related infrastructure',
|
||||||
|
project_id: 7,
|
||||||
|
};
|
||||||
|
const ticket = {
|
||||||
|
id: 42,
|
||||||
|
project_id: 7,
|
||||||
|
sequence_number: 42,
|
||||||
|
ticket_key: 'ENG-42',
|
||||||
|
title: 'Implement a resilient caching layer for the project API',
|
||||||
|
description:
|
||||||
|
'Keep every existing ticket action available.\nLongUnbrokenDescriptionThatMustWrapWithoutCausingHorizontalScrollingOnTheSmallestSupportedMobileViewport.',
|
||||||
|
acceptance_criteria: [
|
||||||
|
{ id: 10, text: 'Cache requests safely', checked: false, indent: 0 },
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
text: 'Invalidate when records change',
|
||||||
|
checked: false,
|
||||||
|
indent: 1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
assignee_user_id: 1,
|
||||||
|
assignee: user,
|
||||||
|
author_user_id: 2,
|
||||||
|
author: { ...user, id: 2, name: 'Sam Chen' },
|
||||||
|
parent_ticket_id: 40,
|
||||||
|
parent_ticket: parent,
|
||||||
|
is_blocked: true,
|
||||||
|
blocked_comment: 'Waiting for infrastructure approval.',
|
||||||
|
story_points: 0,
|
||||||
|
ticket_type_id: 1,
|
||||||
|
ticket_type: { id: 1, name: 'Custom development task', is_parent: false },
|
||||||
|
ticket_priority_id: 2,
|
||||||
|
ticket_priority: { id: 2, name: 'Urgent project priority' },
|
||||||
|
ticket_status_id: 3,
|
||||||
|
ticket_status: {
|
||||||
|
id: 3,
|
||||||
|
name: 'In progress',
|
||||||
|
board_column: { id: 1, name: 'Delivery' },
|
||||||
|
},
|
||||||
|
field_values: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
ticket_field_definition_id: 1,
|
||||||
|
value_number: 0,
|
||||||
|
value_user_id: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
ticket_field_definition_id: 2,
|
||||||
|
value_number: null,
|
||||||
|
value_user_id: 1,
|
||||||
|
user_value: user,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
worklog_entries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
actor: user,
|
||||||
|
entry_type: 'created',
|
||||||
|
summary: 'Ticket created in the project backlog.',
|
||||||
|
created_at: '2026-09-11T12:00:00Z',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
created_at: '2026-09-10T12:00:00Z',
|
||||||
|
updated_at: '2026-09-11T12:00:00Z',
|
||||||
|
};
|
||||||
|
const fieldDefinitions = [
|
||||||
|
{ id: 1, label: 'Impact score', field_type: 'number' },
|
||||||
|
{ id: 2, label: 'Reviewer', field_type: 'user' },
|
||||||
|
];
|
||||||
|
let savedForm = {};
|
||||||
|
function makePage(url) {
|
||||||
|
const parsed = new URL(url, 'http://localhost');
|
||||||
|
const params = parsed.searchParams;
|
||||||
|
const creating = parsed.pathname.endsWith('/create');
|
||||||
|
const detail =
|
||||||
|
!creating && parsed.pathname.startsWith('/projects/7/tickets/');
|
||||||
|
const data = structuredClone(ticket);
|
||||||
|
if (parsed.pathname.endsWith('/41')) {
|
||||||
|
Object.assign(data, linked, {
|
||||||
|
parent_ticket_id: null,
|
||||||
|
parent_ticket: null,
|
||||||
|
title: 'Related infrastructure',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (params.has('saved')) {
|
||||||
|
Object.assign(data, savedForm, { title: params.get('saved') });
|
||||||
|
}
|
||||||
|
if (params.has('long')) {
|
||||||
|
data.title = 'LongUnbrokenTicketTitle'.repeat(10);
|
||||||
|
}
|
||||||
|
if (params.has('parent')) {
|
||||||
|
data.ticket_type.is_parent = true;
|
||||||
|
}
|
||||||
|
if (params.has('empty')) {
|
||||||
|
Object.assign(data, {
|
||||||
|
description: null,
|
||||||
|
acceptance_criteria: [],
|
||||||
|
assignee: null,
|
||||||
|
assignee_user_id: null,
|
||||||
|
author: null,
|
||||||
|
author_user_id: null,
|
||||||
|
parent_ticket: null,
|
||||||
|
parent_ticket_id: null,
|
||||||
|
is_blocked: false,
|
||||||
|
blocked_comment: null,
|
||||||
|
story_points: null,
|
||||||
|
ticket_status: null,
|
||||||
|
field_values: [],
|
||||||
|
worklog_entries: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const noAccess = params.has('noAccess');
|
||||||
|
const repo = { ...repository, has_personal_access: !noAccess };
|
||||||
|
const repositoryError = params.has('gitError')
|
||||||
|
? 'Repository temporarily unavailable.'
|
||||||
|
: null;
|
||||||
|
return {
|
||||||
|
component: creating
|
||||||
|
? 'TicketCreate'
|
||||||
|
: detail
|
||||||
|
? 'Ticket'
|
||||||
|
: 'Destination',
|
||||||
|
url,
|
||||||
|
version: null,
|
||||||
|
clearHistory: false,
|
||||||
|
encryptHistory: false,
|
||||||
|
props: {
|
||||||
|
name: 'KanbanGit',
|
||||||
|
errors: params.has('linkRejected')
|
||||||
|
? {
|
||||||
|
ticket_link_type_id: 'Invalid relationship type.',
|
||||||
|
linked_ticket_id: 'Choose another ticket.',
|
||||||
|
}
|
||||||
|
: params.has('rejected')
|
||||||
|
? {
|
||||||
|
title: 'This title is not allowed.',
|
||||||
|
...(params.has('allErrors')
|
||||||
|
? {
|
||||||
|
description: 'Invalid description.',
|
||||||
|
ticket_type_id: 'Invalid type.',
|
||||||
|
ticket_priority_id: 'Invalid priority.',
|
||||||
|
ticket_status_id: 'Invalid status.',
|
||||||
|
assignee_user_id: 'Invalid assignee.',
|
||||||
|
author_user_id: 'Invalid author.',
|
||||||
|
parent_ticket_id: 'Invalid parent.',
|
||||||
|
story_points: 'Invalid points.',
|
||||||
|
'acceptance_criteria.0.text':
|
||||||
|
'Invalid checklist.',
|
||||||
|
blocked_comment: 'Invalid blocker.',
|
||||||
|
'field_values.0.value_number':
|
||||||
|
'Invalid number.',
|
||||||
|
'field_values.1.value_user_id':
|
||||||
|
'Invalid reviewer.',
|
||||||
|
}
|
||||||
|
: {}),
|
||||||
|
}
|
||||||
|
: {},
|
||||||
|
sidebarOpen: true,
|
||||||
|
auth: {
|
||||||
|
user,
|
||||||
|
permissions: {
|
||||||
|
globalAdmin: false,
|
||||||
|
projectCreate: false,
|
||||||
|
canManageTeams: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
navigation: {
|
||||||
|
project: {
|
||||||
|
...project,
|
||||||
|
canManage: false,
|
||||||
|
canCreateTickets: !params.has('readonly'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
project: {
|
||||||
|
...project,
|
||||||
|
show_author: !params.has('hideAuthor'),
|
||||||
|
show_story_points: !params.has('hidePoints'),
|
||||||
|
},
|
||||||
|
ticket: data,
|
||||||
|
canEditTicket: !params.has('readonly'),
|
||||||
|
canManageProject: params.has('admin'),
|
||||||
|
status: params.has('saved') ? 'Ticket updated.' : null,
|
||||||
|
users: [user, ticket.author],
|
||||||
|
ticketTypes: params.has('noMetadata') ? [] : [data.ticket_type],
|
||||||
|
source: params.get('source') === 'board' ? 'board' : 'backlog',
|
||||||
|
defaultTicketStatusId: 3,
|
||||||
|
ticketStatusOptions: [
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
name: 'In progress',
|
||||||
|
board_column: { name: 'Delivery' },
|
||||||
|
},
|
||||||
|
{ id: 4, name: 'Backlog', board_column: null },
|
||||||
|
],
|
||||||
|
ticketPriorities: [data.ticket_priority],
|
||||||
|
ticketFieldDefinitions: params.has('empty') ? [] : fieldDefinitions,
|
||||||
|
parentTicketOptions: [parent],
|
||||||
|
childTicketTree: params.has('parent')
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
...linked,
|
||||||
|
ticket_type_name: 'Epic',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
id: 43,
|
||||||
|
ticket_key: 'ENG-43',
|
||||||
|
title: 'Nested child with a long title that must wrap on mobile',
|
||||||
|
ticket_type_name: 'Task',
|
||||||
|
children: [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
children_count: 0,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [],
|
||||||
|
linkedTickets:
|
||||||
|
params.has('empty') || params.has('noLinks')
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
source_ticket_id: params.has('incoming')
|
||||||
|
? 41
|
||||||
|
: 42,
|
||||||
|
target_ticket_id: params.has('incoming')
|
||||||
|
? 42
|
||||||
|
: 41,
|
||||||
|
ticket_link_type: {
|
||||||
|
id: 1,
|
||||||
|
label: params.has('incoming')
|
||||||
|
? 'Blocked by'
|
||||||
|
: 'Blocks',
|
||||||
|
},
|
||||||
|
linked_ticket: linked,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
ticketLinkOptions: params.has('noTargets') ? [] : [linked],
|
||||||
|
ticketLinkTypes: params.has('noTypes')
|
||||||
|
? []
|
||||||
|
: [{ id: 1, label: 'Blocks', counterpart_label: 'Blocked by' }],
|
||||||
|
repositoryBranches: params.has('empty')
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
repository_connection: repo,
|
||||||
|
branches: [{ name: 'feature/ENG-42-cache' }],
|
||||||
|
error: repositoryError,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
repositoryPullRequests: params.has('empty')
|
||||||
|
? []
|
||||||
|
: [
|
||||||
|
{
|
||||||
|
repository_connection: repo,
|
||||||
|
pull_requests: [
|
||||||
|
{
|
||||||
|
number: 12,
|
||||||
|
status: 'open',
|
||||||
|
title: 'Cache implementation',
|
||||||
|
source_branch: 'feature/ENG-42-cache',
|
||||||
|
html_url:
|
||||||
|
'https://git.example.test/Engineering/platform/pulls/12',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
error: repositoryError,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
suggestedBranchName: `${data.ticket_key.toLowerCase()}-cache`,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (serve) {
|
||||||
|
server.middlewares.use(async (request, response) => {
|
||||||
|
if (request.url.includes('/branches/validate')) {
|
||||||
|
response.setHeader('Content-Type', 'application/json');
|
||||||
|
response.end(
|
||||||
|
JSON.stringify({
|
||||||
|
is_valid: true,
|
||||||
|
message: 'Branch name is available.',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (request.method !== 'GET') {
|
||||||
|
let body = '';
|
||||||
|
for await (const chunk of request) {
|
||||||
|
body += chunk;
|
||||||
|
}
|
||||||
|
const data = body ? JSON.parse(body) : {};
|
||||||
|
const previous = new URL(request.headers.referer);
|
||||||
|
const params = previous.searchParams;
|
||||||
|
if (params.has('serverError')) {
|
||||||
|
response.writeHead(503);
|
||||||
|
response.end('Simulated failure');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!request.headers['x-inertia']) {
|
||||||
|
assert.equal(request.method, 'PATCH');
|
||||||
|
assert.equal(request.url, '/projects/7/tickets/42');
|
||||||
|
assert.equal(
|
||||||
|
data.title,
|
||||||
|
ticket.title,
|
||||||
|
'Checklist toggle must not save the title draft.',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
data.acceptance_criteria[0].checked,
|
||||||
|
data.acceptance_criteria[1].checked,
|
||||||
|
'Toggling a parent must update its descendants.',
|
||||||
|
);
|
||||||
|
response.writeHead(params.has('rejectToggle') ? 422 : 200, {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
});
|
||||||
|
response.end('{}');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (request.url.includes('/branches')) {
|
||||||
|
assert.equal(data.branch_name, 'eng-42-cache');
|
||||||
|
assert.equal(Number(data.repository_connection_id), 9);
|
||||||
|
} else if (request.url.includes('/links')) {
|
||||||
|
assert.ok(
|
||||||
|
request.url.endsWith('/links/3?_method=DELETE') ||
|
||||||
|
request.method === 'DELETE' ||
|
||||||
|
Number(data.linked_ticket_id) === 41,
|
||||||
|
);
|
||||||
|
if (params.has('rejectLink')) {
|
||||||
|
params.set('linkRejected', '1');
|
||||||
|
} else if (request.method === 'DELETE') {
|
||||||
|
params.set('noLinks', '1');
|
||||||
|
} else {
|
||||||
|
params.delete('noLinks');
|
||||||
|
params.delete('linkRejected');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
assert.ok(
|
||||||
|
(request.method === 'POST' || 'field_values' in data) &&
|
||||||
|
'acceptance_criteria' in data &&
|
||||||
|
'parent_ticket_id' in data,
|
||||||
|
);
|
||||||
|
if (params.has('reject')) {
|
||||||
|
params.set('rejected', '1');
|
||||||
|
} else {
|
||||||
|
savedForm = data;
|
||||||
|
params.set('saved', data.title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.writeHead(303, {
|
||||||
|
Location: `${params.has('rejected') && previous.pathname.endsWith('/create') ? previous.pathname : '/projects/7/tickets/42'}?${params}`,
|
||||||
|
});
|
||||||
|
response.end();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const page = makePage(request.url);
|
||||||
|
response.setHeader('Vary', 'X-Inertia');
|
||||||
|
if (request.headers['x-inertia']) {
|
||||||
|
response.writeHead(200, {
|
||||||
|
'X-Inertia': 'true',
|
||||||
|
'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/ticket-detail-preview.mjs"></script></body></html>`,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await server.listen();
|
||||||
|
console.log(
|
||||||
|
'Ticket detail fixture ready at http://127.0.0.1:4185/projects/7/tickets/42',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const { createLocalization } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/lib/localization.ts',
|
||||||
|
);
|
||||||
|
const { createAppearance } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/composables/useAppearance.ts',
|
||||||
|
);
|
||||||
|
const { default: Ticket } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/pages/projects/Ticket.vue',
|
||||||
|
);
|
||||||
|
const { default: TicketCreate } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/pages/projects/TicketCreate.vue',
|
||||||
|
);
|
||||||
|
const render = async (query = '', creating = false) => {
|
||||||
|
const result = await createInertiaApp({
|
||||||
|
page: makePage(
|
||||||
|
`/projects/7/tickets/${creating ? 'create' : '42'}${query}`,
|
||||||
|
),
|
||||||
|
resolve: () => (creating ? TicketCreate : Ticket),
|
||||||
|
render: renderToString,
|
||||||
|
setup: ({ App, props, plugin }) =>
|
||||||
|
createSSRApp({ render: () => h(App, props) })
|
||||||
|
.use(plugin)
|
||||||
|
.use(createLocalization())
|
||||||
|
.use(createAppearance('light')),
|
||||||
|
});
|
||||||
|
return result.body.split('id="main-content"')[1];
|
||||||
|
};
|
||||||
|
const html = await render();
|
||||||
|
for (const text of [
|
||||||
|
ticket.title,
|
||||||
|
'Keep every existing ticket action available.',
|
||||||
|
'Cache requests safely',
|
||||||
|
'Invalidate when records change',
|
||||||
|
'Urgent project priority',
|
||||||
|
'Delivery / In progress',
|
||||||
|
'Alex Morgan',
|
||||||
|
'Sam Chen',
|
||||||
|
'Impact score',
|
||||||
|
'Reviewer',
|
||||||
|
'Waiting for infrastructure approval.',
|
||||||
|
'feature/ENG-42-cache',
|
||||||
|
'Cache implementation',
|
||||||
|
'Ticket created in the project backlog.',
|
||||||
|
]) {
|
||||||
|
assert.ok(
|
||||||
|
html.includes(text),
|
||||||
|
`Missing ticket information: ${text}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
for (const section of [
|
||||||
|
'description',
|
||||||
|
'checklist',
|
||||||
|
'metadata',
|
||||||
|
'relationships',
|
||||||
|
'history',
|
||||||
|
'git',
|
||||||
|
]) {
|
||||||
|
assert.ok(html.includes(`href="#ticket-${section}"`));
|
||||||
|
assert.ok(html.includes(`id="ticket-${section}"`));
|
||||||
|
}
|
||||||
|
for (const route of [
|
||||||
|
'/projects/7',
|
||||||
|
'/projects/7/backlog',
|
||||||
|
'/projects/7/board',
|
||||||
|
'/projects/7/tickets/40',
|
||||||
|
'/projects/7/tickets/41',
|
||||||
|
]) {
|
||||||
|
assert.ok(html.includes(`href="${route}"`));
|
||||||
|
}
|
||||||
|
assert.match(html, /<details[^>]+id="ticket-edit"/);
|
||||||
|
for (const field of [
|
||||||
|
'title',
|
||||||
|
'ticket_type_id',
|
||||||
|
'ticket_priority_id',
|
||||||
|
'assignee_user_id',
|
||||||
|
'author_user_id',
|
||||||
|
'story_points',
|
||||||
|
'parent_ticket_id',
|
||||||
|
'description',
|
||||||
|
'is_blocked',
|
||||||
|
'blocked_comment',
|
||||||
|
'field-1',
|
||||||
|
'field-2',
|
||||||
|
]) {
|
||||||
|
assert.ok(
|
||||||
|
html.includes(`id="${field}"`),
|
||||||
|
`Missing editor: ${field}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert.match(html, /aria-label="Criterion 1"/);
|
||||||
|
assert.match(html, /Add criterion/);
|
||||||
|
assert.match(html, /Create branch/);
|
||||||
|
assert.match(html, /Save link/);
|
||||||
|
assert.match(html, /Outgoing/);
|
||||||
|
const incoming = await render('?incoming');
|
||||||
|
assert.match(incoming, /Incoming/);
|
||||||
|
assert.match(incoming, /Blocked by/);
|
||||||
|
assert.match(await render('?noTypes'), /No link types are configured/);
|
||||||
|
assert.match(
|
||||||
|
await render('?noTargets'),
|
||||||
|
/No other tickets are available/,
|
||||||
|
);
|
||||||
|
assert.match(html, /Remove/);
|
||||||
|
const readOnly = await render('?readonly');
|
||||||
|
assert.doesNotMatch(
|
||||||
|
readOnly,
|
||||||
|
/<form|<details|Create branch|Save changes|Save link/,
|
||||||
|
);
|
||||||
|
assert.match(readOnly, /type="checkbox" disabled/);
|
||||||
|
assert.match(readOnly, /Read only/);
|
||||||
|
const hidden = await render('?readonly&hideAuthor&hidePoints');
|
||||||
|
assert.doesNotMatch(hidden, /Sam Chen|Estimated story points/);
|
||||||
|
assert.match(await render('?readonly&hideAuthor&admin'), /Sam Chen/);
|
||||||
|
const empty = await render('?empty');
|
||||||
|
for (const text of [
|
||||||
|
'No description has been added yet.',
|
||||||
|
'No acceptance criteria yet.',
|
||||||
|
'No status',
|
||||||
|
'Unassigned',
|
||||||
|
'No author',
|
||||||
|
'Not set',
|
||||||
|
'No matching branches',
|
||||||
|
'No matching pull requests',
|
||||||
|
'No worklog entries exist',
|
||||||
|
]) {
|
||||||
|
assert.ok(empty.includes(text), `Missing empty state: ${text}`);
|
||||||
|
}
|
||||||
|
const hierarchy = await render('?parent');
|
||||||
|
assert.match(hierarchy, /Child tickets/);
|
||||||
|
assert.match(hierarchy, /Platform delivery/);
|
||||||
|
assert.match(hierarchy, /Nested child/);
|
||||||
|
assert.match(hierarchy, /Change parent/);
|
||||||
|
assert.match(await render('?noAccess'), /Open Git connections/);
|
||||||
|
assert.match(
|
||||||
|
await render('?gitError'),
|
||||||
|
/Repository temporarily unavailable/,
|
||||||
|
);
|
||||||
|
const create = await render('?source=board', true);
|
||||||
|
assert.match(create, /Create ticket/);
|
||||||
|
assert.match(create, /Delivery \/ In progress/);
|
||||||
|
assert.match(create, /Back to board/);
|
||||||
|
assert.match(create, /id="ticket_status_id"/);
|
||||||
|
assert.doesNotMatch(
|
||||||
|
create,
|
||||||
|
/id="author_user_id"|id="blocked_comment"|id="field-1"/,
|
||||||
|
);
|
||||||
|
assert.doesNotMatch(
|
||||||
|
await render('?hidePoints', true),
|
||||||
|
/id="story_points"/,
|
||||||
|
);
|
||||||
|
const unavailable = await render('?noMetadata', true);
|
||||||
|
assert.doesNotMatch(unavailable, /<form/);
|
||||||
|
assert.match(unavailable, /Ticket creation needs at least one type/);
|
||||||
|
for (const creating of [false, true]) {
|
||||||
|
const invalid = await render('?rejected&allErrors', creating);
|
||||||
|
assert.match(
|
||||||
|
invalid,
|
||||||
|
/aria-describedby="[^"]+-hint [^"]+-error"|No acceptance criteria yet/,
|
||||||
|
);
|
||||||
|
for (const id of [
|
||||||
|
'title',
|
||||||
|
'description',
|
||||||
|
'ticket_type_id',
|
||||||
|
'ticket_priority_id',
|
||||||
|
'assignee_user_id',
|
||||||
|
'parent_ticket_id',
|
||||||
|
'story_points',
|
||||||
|
]) {
|
||||||
|
assert.ok(invalid.includes(`id="${id}-error"`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log('Ticket detail behavior checks passed.');
|
||||||
|
} finally {
|
||||||
|
await server.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,279 @@
|
|||||||
|
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 page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
|
||||||
|
page.setDefaultTimeout(10000);
|
||||||
|
const base = 'http://127.0.0.1:4185/projects/7/tickets';
|
||||||
|
const errors = [];
|
||||||
|
page.on('pageerror', (error) => errors.push(error.message));
|
||||||
|
const field = (label) => form().getByLabel(label, { exact: true });
|
||||||
|
const form = () => page.locator('form').first();
|
||||||
|
const state = (value) =>
|
||||||
|
form().locator(`[data-form-state="${value}"]`).waitFor();
|
||||||
|
const button = (label) =>
|
||||||
|
form().getByRole('button', { name: label, exact: true });
|
||||||
|
async function visit(create, query = '') {
|
||||||
|
await page.goto(`${base}/${create ? 'create' : '42'}${query}`);
|
||||||
|
await page.getByRole('heading', { level: 1 }).waitFor();
|
||||||
|
if (!create) {
|
||||||
|
await page.locator('#ticket-edit > summary').click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function fill(create) {
|
||||||
|
await field('Title').fill('A complete ticket');
|
||||||
|
await field('Description').fill('Description with context.');
|
||||||
|
await field('Assignee').selectOption('2');
|
||||||
|
await field('Parent ticket').selectOption('40');
|
||||||
|
await field('Estimated story points').fill('0');
|
||||||
|
if (create) {
|
||||||
|
await button('Add criterion').click();
|
||||||
|
await button('Add criterion').click();
|
||||||
|
await button('Indent criterion 2').click();
|
||||||
|
}
|
||||||
|
await field('Criterion 1').fill('Main criterion');
|
||||||
|
await field('Criterion 2').fill('Nested criterion');
|
||||||
|
await form()
|
||||||
|
.getByRole('checkbox', {
|
||||||
|
name: 'Complete criterion 2: Nested criterion',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.check();
|
||||||
|
if (create) {
|
||||||
|
await field('Status').selectOption('4');
|
||||||
|
} else {
|
||||||
|
await field('Author').selectOption('1');
|
||||||
|
await field('Blocker comment').fill('Waiting for review');
|
||||||
|
await field('Impact score').fill('2.5');
|
||||||
|
await field('Reviewer').selectOption('2');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function submit(create) {
|
||||||
|
const request = page.waitForRequest(
|
||||||
|
(r) =>
|
||||||
|
r.method() === (create ? 'POST' : 'PATCH') &&
|
||||||
|
r.url().split('?')[0] === (create ? base : `${base}/42`),
|
||||||
|
);
|
||||||
|
await button(create ? 'Create ticket' : 'Save changes').click();
|
||||||
|
return (await request).postDataJSON();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (const create of [true, false]) {
|
||||||
|
for (const width of [1440, 390, 320]) {
|
||||||
|
await page.setViewportSize({ width, height: 1000 });
|
||||||
|
for (const theme of ['light', 'dark']) {
|
||||||
|
await page.emulateMedia({
|
||||||
|
colorScheme: theme,
|
||||||
|
reducedMotion: 'reduce',
|
||||||
|
});
|
||||||
|
await visit(create, '?admin');
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('html')
|
||||||
|
.evaluate((el) => el.classList.contains('dark')),
|
||||||
|
theme === 'dark',
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() =>
|
||||||
|
document.documentElement.scrollWidth <= innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
`Overflow ${create}/${width}/${theme}`,
|
||||||
|
);
|
||||||
|
await field('Title').focus();
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
assert.equal(
|
||||||
|
await field('Description').evaluate(
|
||||||
|
(el) =>
|
||||||
|
el === document.activeElement &&
|
||||||
|
el.matches(':focus-visible'),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await fill(create);
|
||||||
|
await page.screenshot({
|
||||||
|
path: `/private/tmp/kan31-${create ? 'create' : 'edit'}-${width}-${theme}.png`,
|
||||||
|
fullPage: true,
|
||||||
|
});
|
||||||
|
page.once('dialog', (dialog) => dialog.dismiss());
|
||||||
|
await button('Discard changes').click();
|
||||||
|
assert.equal(
|
||||||
|
await field('Title').inputValue(),
|
||||||
|
'A complete ticket',
|
||||||
|
);
|
||||||
|
page.once('dialog', (dialog) => dialog.accept());
|
||||||
|
await button('Discard changes').click();
|
||||||
|
assert.equal(
|
||||||
|
await button('Discard changes').isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await field('Title').inputValue(),
|
||||||
|
create
|
||||||
|
? ''
|
||||||
|
: 'Implement a resilient caching layer for the project API',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await visit(create, '?admin&reject&allErrors');
|
||||||
|
await fill(create);
|
||||||
|
const data = await submit(create);
|
||||||
|
assert.equal(data.title, 'A complete ticket');
|
||||||
|
assert.equal(data.description, 'Description with context.');
|
||||||
|
assert.equal(Number(data.ticket_type_id), 1);
|
||||||
|
assert.equal(Number(data.ticket_priority_id), 2);
|
||||||
|
assert.equal(Number(data.assignee_user_id), 2);
|
||||||
|
assert.equal(Number(data.parent_ticket_id), 40);
|
||||||
|
assert.equal(Number(data.story_points), 0);
|
||||||
|
assert.deepEqual(
|
||||||
|
data.acceptance_criteria.map(({ text, checked, indent }) => ({
|
||||||
|
text,
|
||||||
|
checked,
|
||||||
|
indent,
|
||||||
|
})),
|
||||||
|
[
|
||||||
|
{ text: 'Main criterion', checked: false, indent: 0 },
|
||||||
|
{ text: 'Nested criterion', checked: true, indent: 1 },
|
||||||
|
],
|
||||||
|
);
|
||||||
|
if (create) {
|
||||||
|
assert.equal(Number(data.ticket_status_id), 4);
|
||||||
|
assert.equal('author_user_id' in data, false);
|
||||||
|
} else {
|
||||||
|
assert.equal(Number(data.author_user_id), 1);
|
||||||
|
assert.equal(data.is_blocked, true);
|
||||||
|
assert.equal(data.blocked_comment, 'Waiting for review');
|
||||||
|
assert.equal(Number(data.field_values[0].value_number), 2.5);
|
||||||
|
assert.equal(Number(data.field_values[1].value_user_id), 2);
|
||||||
|
assert.deepEqual(
|
||||||
|
data.acceptance_criteria.map((item) => item.id),
|
||||||
|
[10, 11],
|
||||||
|
);
|
||||||
|
assert.equal('ticket_status_id' in data, false);
|
||||||
|
}
|
||||||
|
await state('validation');
|
||||||
|
const fields = [
|
||||||
|
'Title',
|
||||||
|
'Description',
|
||||||
|
'Type',
|
||||||
|
'Priority',
|
||||||
|
'Assignee',
|
||||||
|
'Parent ticket',
|
||||||
|
'Estimated story points',
|
||||||
|
'Criterion 1',
|
||||||
|
...(create
|
||||||
|
? ['Status']
|
||||||
|
: ['Author', 'Blocker comment', 'Impact score', 'Reviewer']),
|
||||||
|
];
|
||||||
|
for (const label of fields) {
|
||||||
|
const control = field(label);
|
||||||
|
assert.equal(
|
||||||
|
await control.getAttribute('aria-invalid'),
|
||||||
|
'true',
|
||||||
|
label,
|
||||||
|
);
|
||||||
|
const errorId = (await control.getAttribute('aria-describedby'))
|
||||||
|
.split(' ')
|
||||||
|
.at(-1);
|
||||||
|
assert.ok(
|
||||||
|
(await page.locator(`[id="${errorId}"]`).innerText()).length,
|
||||||
|
`Missing associated error: ${label}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
assert.equal(await field('Title').inputValue(), 'A complete ticket');
|
||||||
|
await page.route(create ? `${base}` : `${base}/42`, (route) =>
|
||||||
|
route.abort('failed'),
|
||||||
|
);
|
||||||
|
await button(create ? 'Create ticket' : 'Save changes').click();
|
||||||
|
await state('network');
|
||||||
|
assert.equal(
|
||||||
|
await field('Description').inputValue(),
|
||||||
|
'Description with context.',
|
||||||
|
);
|
||||||
|
await page.unrouteAll();
|
||||||
|
await visit(create, '?admin&serverError');
|
||||||
|
await fill(create);
|
||||||
|
await submit(create);
|
||||||
|
await state('server');
|
||||||
|
assert.equal(await field('Title').inputValue(), 'A complete ticket');
|
||||||
|
let pending;
|
||||||
|
let requests = 0;
|
||||||
|
await page.route(create ? `${base}` : `${base}/42`, (route) => {
|
||||||
|
requests++;
|
||||||
|
pending = route;
|
||||||
|
});
|
||||||
|
await button('Try again').click();
|
||||||
|
await state('loading');
|
||||||
|
assert.equal(await field('Title').isDisabled(), true);
|
||||||
|
assert.equal(
|
||||||
|
await button(
|
||||||
|
create ? 'Creating ticket…' : 'Saving changes…',
|
||||||
|
).isDisabled(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await form().evaluate((el) =>
|
||||||
|
el.dispatchEvent(
|
||||||
|
new Event('submit', { bubbles: true, cancelable: true }),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
assert.equal(requests, 1);
|
||||||
|
await pending.abort();
|
||||||
|
await state('network');
|
||||||
|
await page.unrouteAll();
|
||||||
|
await visit(create, '?admin');
|
||||||
|
await fill(create);
|
||||||
|
page.once('dialog', (dialog) => dialog.dismiss());
|
||||||
|
await page
|
||||||
|
.locator('#main-content')
|
||||||
|
.getByRole('link', {
|
||||||
|
name: create ? 'Back to backlog' : 'Open backlog',
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.click();
|
||||||
|
assert.ok(page.url().includes('/tickets/'));
|
||||||
|
const successData = await submit(create);
|
||||||
|
await page
|
||||||
|
.getByRole('heading', { name: successData.title, exact: true })
|
||||||
|
.waitFor();
|
||||||
|
if (create) {
|
||||||
|
await page.goBack();
|
||||||
|
await page
|
||||||
|
.getByRole('heading', { name: 'Create ticket', exact: true })
|
||||||
|
.waitFor();
|
||||||
|
await field('Title').waitFor();
|
||||||
|
assert.equal(await field('Title').inputValue(), '');
|
||||||
|
assert.equal(await field('Criterion 1').count(), 0);
|
||||||
|
} else {
|
||||||
|
await form()
|
||||||
|
.getByText('All changes saved', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
await field('Title').fill('Another draft');
|
||||||
|
page.once('dialog', (dialog) => dialog.accept());
|
||||||
|
await button('Discard changes').click();
|
||||||
|
assert.equal(
|
||||||
|
await field('Title').inputValue(),
|
||||||
|
'A complete ticket',
|
||||||
|
);
|
||||||
|
assert.equal(await field('Impact score').inputValue(), '2.5');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await visit(false, '?hideAuthor&hidePoints');
|
||||||
|
assert.equal(await field('Author').count(), 0);
|
||||||
|
assert.equal(await field('Estimated story points').count(), 0);
|
||||||
|
await visit(false);
|
||||||
|
assert.equal(await field('Author').isDisabled(), true);
|
||||||
|
await visit(true, '?hidePoints');
|
||||||
|
assert.equal(await field('Estimated story points').count(), 0);
|
||||||
|
await visit(true, '?noMetadata');
|
||||||
|
assert.equal(await page.locator('form').count(), 0);
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
console.log(
|
||||||
|
'Ticket form browser checks passed: create/edit payloads, nested validation, retries, drafts, resets, permissions, keyboard, mobile and both themes.',
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { createApp } from 'vue';
|
||||||
|
import { createInertiaApp } from '@inertiajs/vue3';
|
||||||
|
import '../../resources/css/app.css';
|
||||||
|
import TicketPresentationsPreview from './TicketPresentationsPreview.vue';
|
||||||
|
import { createLocalization } from '../../resources/js/lib/localization';
|
||||||
|
|
||||||
|
createInertiaApp({
|
||||||
|
resolve: () => TicketPresentationsPreview,
|
||||||
|
setup: ({ el, App, props, plugin }) =>
|
||||||
|
createApp(App, props).use(plugin).use(createLocalization()).mount(el),
|
||||||
|
});
|
||||||
@@ -0,0 +1,228 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import process from 'node:process';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
import tailwind from '@tailwindcss/vite';
|
||||||
|
import vue from '@vitejs/plugin-vue';
|
||||||
|
import { createInertiaApp } from '@inertiajs/vue3';
|
||||||
|
import { createServer } from 'vite';
|
||||||
|
import { createSSRApp, h } from 'vue';
|
||||||
|
import { renderToString } from 'vue/server-renderer';
|
||||||
|
|
||||||
|
const serve = process.argv.includes('--serve');
|
||||||
|
const server = await createServer({
|
||||||
|
configFile: false,
|
||||||
|
cacheDir: 'node_modules/.vite/ticket-presentations-fixture',
|
||||||
|
plugins: [vue(), ...(serve ? [tailwind()] : [])],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('../../resources/js', import.meta.url)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: serve
|
||||||
|
? { host: '127.0.0.1', port: 4179, strictPort: true, hmr: false }
|
||||||
|
: { middlewareMode: true, hmr: false, watch: null },
|
||||||
|
appType: 'custom',
|
||||||
|
});
|
||||||
|
|
||||||
|
const user = {
|
||||||
|
id: 8,
|
||||||
|
name: 'Taylor Reed',
|
||||||
|
email: 'taylor@example.test',
|
||||||
|
avatar: null,
|
||||||
|
avatar_color: '#22c55e',
|
||||||
|
avatar_is_generated: true,
|
||||||
|
email_verified_at: null,
|
||||||
|
must_change_password_on_next_login: false,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
};
|
||||||
|
|
||||||
|
const fullTicket = {
|
||||||
|
id: 42,
|
||||||
|
acceptance_criteria: [],
|
||||||
|
assignee: user,
|
||||||
|
assignee_user_id: user.id,
|
||||||
|
author: null,
|
||||||
|
author_user_id: null,
|
||||||
|
blocked_comment: 'Waiting for the security review.',
|
||||||
|
description: 'Keep the complete summary available on every surface.',
|
||||||
|
is_blocked: true,
|
||||||
|
parent_ticket_id: null,
|
||||||
|
project_id: 7,
|
||||||
|
sequence_number: 42,
|
||||||
|
story_points: 5,
|
||||||
|
ticket_key: 'ENG-42',
|
||||||
|
ticket_priority: {
|
||||||
|
id: 502,
|
||||||
|
name: 'Critical from project',
|
||||||
|
position: 4,
|
||||||
|
project_id: 7,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
},
|
||||||
|
ticket_priority_id: 502,
|
||||||
|
ticket_status: {
|
||||||
|
id: 602,
|
||||||
|
board_column_id: 12,
|
||||||
|
name: 'Review from project',
|
||||||
|
position: 2,
|
||||||
|
project_id: 7,
|
||||||
|
slug: 'review',
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
board_column: {
|
||||||
|
id: 12,
|
||||||
|
name: 'Delivery',
|
||||||
|
position: 2,
|
||||||
|
project_id: 7,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ticket_status_id: 602,
|
||||||
|
ticket_type: {
|
||||||
|
id: 702,
|
||||||
|
is_parent: false,
|
||||||
|
name: 'Incident from project',
|
||||||
|
position: 1,
|
||||||
|
project_id: 7,
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
},
|
||||||
|
ticket_type_id: 702,
|
||||||
|
title: 'A very long ticket title with an_uninterrupted_identifier_that_must_remain_readable_and_actionable_on_small_screens',
|
||||||
|
created_at: '2026-09-11T00:00:00Z',
|
||||||
|
updated_at: '2026-09-11T00:00:00Z',
|
||||||
|
};
|
||||||
|
|
||||||
|
const optionalTicket = {
|
||||||
|
...fullTicket,
|
||||||
|
id: 43,
|
||||||
|
assignee: null,
|
||||||
|
assignee_user_id: null,
|
||||||
|
blocked_comment: null,
|
||||||
|
description: null,
|
||||||
|
is_blocked: false,
|
||||||
|
ticket_key: 'ENG-43',
|
||||||
|
ticket_status: null,
|
||||||
|
ticket_status_id: null,
|
||||||
|
title: 'Ticket without optional data',
|
||||||
|
};
|
||||||
|
|
||||||
|
if (serve) {
|
||||||
|
server.middlewares.use(async (request, response, next) => {
|
||||||
|
const url = new URL(request.url, 'http://localhost');
|
||||||
|
if (url.pathname !== '/ticket-presentations') {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
|
||||||
|
const page = {
|
||||||
|
component: 'TicketPresentationsPreview',
|
||||||
|
url: request.url,
|
||||||
|
version: null,
|
||||||
|
clearHistory: false,
|
||||||
|
encryptHistory: false,
|
||||||
|
props: {
|
||||||
|
auth: { user },
|
||||||
|
errors: {},
|
||||||
|
fullTicket,
|
||||||
|
optionalTicket,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
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"${url.searchParams.has('dark') ? ' class="dark"' : ''}><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/ticket-presentations-preview.mjs"></script></body></html>`,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
await server.listen();
|
||||||
|
console.log(
|
||||||
|
'Ticket presentation fixture ready at http://127.0.0.1:4179/ticket-presentations',
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
const { createLocalization } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/lib/localization.ts',
|
||||||
|
);
|
||||||
|
const { default: TicketCard } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/components/tickets/TicketCard.vue',
|
||||||
|
);
|
||||||
|
const { default: TicketListItem } = await server.ssrLoadModule(
|
||||||
|
'/resources/js/components/tickets/TicketListItem.vue',
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(TicketCard.emits, ['open']);
|
||||||
|
assert.deepEqual(TicketListItem.emits, ['open']);
|
||||||
|
for (const component of [TicketCard, TicketListItem]) {
|
||||||
|
assert.ok(component.props.projectId);
|
||||||
|
assert.ok(component.props.ticket);
|
||||||
|
assert.ok(component.props.showDescription);
|
||||||
|
assert.ok(component.props.showStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
const render = async (component, ticket) => {
|
||||||
|
const Page = {
|
||||||
|
render: () =>
|
||||||
|
component === TicketListItem
|
||||||
|
? h('ul', {}, [h(component, { projectId: 7, ticket })])
|
||||||
|
: h(component, { projectId: 7, ticket }),
|
||||||
|
};
|
||||||
|
const response = await createInertiaApp({
|
||||||
|
page: {
|
||||||
|
component: 'TicketPresentation',
|
||||||
|
url: '/projects/7/board',
|
||||||
|
version: null,
|
||||||
|
clearHistory: false,
|
||||||
|
encryptHistory: false,
|
||||||
|
props: {
|
||||||
|
auth: { user },
|
||||||
|
errors: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
resolve: () => Page,
|
||||||
|
render: renderToString,
|
||||||
|
setup: ({ App, props, plugin }) =>
|
||||||
|
createSSRApp({ render: () => h(App, props) })
|
||||||
|
.use(plugin)
|
||||||
|
.use(createLocalization()),
|
||||||
|
});
|
||||||
|
return response.body;
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const component of [TicketCard, TicketListItem]) {
|
||||||
|
const html = await render(component, fullTicket);
|
||||||
|
assert.match(html, /href="\/projects\/7\/tickets\/42"/);
|
||||||
|
assert.match(html, /aria-label="Open ENG-42:/);
|
||||||
|
assert.match(html, /min-h-control/);
|
||||||
|
assert.match(html, /focus-visible:ring-2/);
|
||||||
|
assert.match(html, /wrap-anywhere/);
|
||||||
|
assert.match(html, new RegExp(fullTicket.title));
|
||||||
|
assert.match(html, /data-ticket-type-id="702"/);
|
||||||
|
assert.match(html, /Incident from project/);
|
||||||
|
assert.match(html, /data-ticket-priority-id="502"/);
|
||||||
|
assert.match(html, /Critical from project/);
|
||||||
|
assert.match(html, /data-ticket-status-id="602"/);
|
||||||
|
assert.match(html, /Delivery \/ Review from project/);
|
||||||
|
assert.match(html, /Assigned to Taylor Reed/);
|
||||||
|
assert.match(html, /Blocked/);
|
||||||
|
assert.match(html, /Blocker: Waiting for the security review\./);
|
||||||
|
|
||||||
|
const optionalHtml = await render(component, optionalTicket);
|
||||||
|
assert.match(optionalHtml, /href="\/projects\/7\/tickets\/43"/);
|
||||||
|
assert.match(optionalHtml, /Ticket without optional data/);
|
||||||
|
assert.match(optionalHtml, /No status/);
|
||||||
|
assert.match(optionalHtml, /Unassigned/);
|
||||||
|
assert.doesNotMatch(optionalHtml, /Blocked|Blocker:/);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Ticket presentation behavior checks passed.');
|
||||||
|
} finally {
|
||||||
|
await server.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
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 page = await browser.newPage();
|
||||||
|
page.setDefaultTimeout(10000);
|
||||||
|
const base = 'http://127.0.0.1:4185/projects/7/tickets/42';
|
||||||
|
const section = () => page.locator('#ticket-relationships');
|
||||||
|
const errors = [];
|
||||||
|
page.on('pageerror', (error) => errors.push(error.message));
|
||||||
|
async function visit(query = '') {
|
||||||
|
await page.goto(base + query);
|
||||||
|
await section().waitFor();
|
||||||
|
}
|
||||||
|
const control = (label) => section().getByLabel(label, { exact: true });
|
||||||
|
const save = () =>
|
||||||
|
section().getByRole('button', { name: 'Save link', exact: true });
|
||||||
|
const remove = () =>
|
||||||
|
section().getByRole('button', {
|
||||||
|
name: 'Remove link to ENG-41',
|
||||||
|
exact: true,
|
||||||
|
});
|
||||||
|
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,
|
||||||
|
reducedMotion: 'reduce',
|
||||||
|
});
|
||||||
|
await visit('?parent&incoming');
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('html')
|
||||||
|
.evaluate((el) => el.classList.contains('dark')),
|
||||||
|
theme === 'dark',
|
||||||
|
);
|
||||||
|
for (const text of [
|
||||||
|
'Platform delivery',
|
||||||
|
'Child tickets',
|
||||||
|
'Nested child with a long title that must wrap on mobile',
|
||||||
|
'Incoming',
|
||||||
|
'Blocked by',
|
||||||
|
]) {
|
||||||
|
assert.equal(
|
||||||
|
await section()
|
||||||
|
.getByText(text, { exact: true })
|
||||||
|
.isVisible(),
|
||||||
|
true,
|
||||||
|
text,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const collapse = section().getByRole('button', {
|
||||||
|
name: 'Collapse children of ENG-41',
|
||||||
|
});
|
||||||
|
await collapse.focus();
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
assert.equal(
|
||||||
|
await section()
|
||||||
|
.getByText(
|
||||||
|
'Nested child with a long title that must wrap on mobile',
|
||||||
|
{ exact: true },
|
||||||
|
)
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
await page.keyboard.press('Space');
|
||||||
|
assert.equal(await collapse.getAttribute('aria-expanded'), 'true');
|
||||||
|
await control('Link type').focus();
|
||||||
|
await page.keyboard.press('Tab');
|
||||||
|
assert.equal(
|
||||||
|
await control('Linked ticket').evaluate(
|
||||||
|
(el) =>
|
||||||
|
el === document.activeElement &&
|
||||||
|
el.matches(':focus-visible'),
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
await control('Linked ticket').selectOption('41');
|
||||||
|
await section()
|
||||||
|
.locator('form')
|
||||||
|
.last()
|
||||||
|
.getByText('ENG-42', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(
|
||||||
|
await page.evaluate(
|
||||||
|
() => document.documentElement.scrollWidth <= innerWidth,
|
||||||
|
),
|
||||||
|
true,
|
||||||
|
`Overflow ${width}/${theme}`,
|
||||||
|
);
|
||||||
|
await section().screenshot({
|
||||||
|
path: `/private/tmp/kan33-relationships-${width}-${theme}.png`,
|
||||||
|
});
|
||||||
|
await section()
|
||||||
|
.getByRole('button', { name: 'Change parent', exact: true })
|
||||||
|
.click();
|
||||||
|
assert.equal(
|
||||||
|
await page
|
||||||
|
.locator('#parent_ticket_id')
|
||||||
|
.evaluate((el) => el === document.activeElement),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await page.locator('#ticket-edit').evaluate((el) => el.open),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await visit('?noLinks');
|
||||||
|
assert.equal(await save().isDisabled(), true);
|
||||||
|
await control('Linked ticket').selectOption('41');
|
||||||
|
let request = page.waitForRequest(
|
||||||
|
(r) => r.method() === 'POST' && r.url().endsWith('/links'),
|
||||||
|
);
|
||||||
|
await save().click();
|
||||||
|
assert.deepEqual((await request).postDataJSON(), {
|
||||||
|
ticket_link_type_id: 1,
|
||||||
|
linked_ticket_id: 41,
|
||||||
|
});
|
||||||
|
await section().getByText('Outgoing', { exact: true }).waitFor();
|
||||||
|
await page.waitForFunction(
|
||||||
|
() => document.querySelector('#linked_ticket_id')?.value === '',
|
||||||
|
);
|
||||||
|
await page.waitForFunction(() =>
|
||||||
|
document.activeElement?.textContent.includes('Linked tickets'),
|
||||||
|
);
|
||||||
|
request = page.waitForRequest(
|
||||||
|
(r) => r.method() === 'DELETE' && r.url().endsWith('/links/3'),
|
||||||
|
);
|
||||||
|
await remove().click();
|
||||||
|
await request;
|
||||||
|
await section()
|
||||||
|
.getByText('No ticket links are configured for this ticket yet.', {
|
||||||
|
exact: true,
|
||||||
|
})
|
||||||
|
.waitFor();
|
||||||
|
await page.waitForFunction(() =>
|
||||||
|
document.activeElement?.textContent.includes('Linked tickets'),
|
||||||
|
);
|
||||||
|
|
||||||
|
await visit('?rejectLink');
|
||||||
|
await control('Linked ticket').selectOption('41');
|
||||||
|
await save().click();
|
||||||
|
await section()
|
||||||
|
.getByText('Choose another ticket.', { exact: true })
|
||||||
|
.waitFor();
|
||||||
|
assert.equal(await control('Linked ticket').inputValue(), '41');
|
||||||
|
for (const label of ['Link type', 'Linked ticket']) {
|
||||||
|
assert.equal(await control(label).getAttribute('aria-invalid'), 'true');
|
||||||
|
}
|
||||||
|
await page.route('**/tickets/42/links', (route) => route.abort('failed'));
|
||||||
|
await save().click();
|
||||||
|
await section().locator('[data-form-state="network"]').waitFor();
|
||||||
|
assert.equal(await control('Linked ticket').inputValue(), '41');
|
||||||
|
await page.unrouteAll();
|
||||||
|
|
||||||
|
await visit('?serverError');
|
||||||
|
await remove().click();
|
||||||
|
await section().locator('[data-form-state="server"]').waitFor();
|
||||||
|
assert.equal(await section().locator('[data-ticket-link]').count(), 1);
|
||||||
|
let pending;
|
||||||
|
await page.route('**/tickets/42/links/3', (route) => {
|
||||||
|
pending = route;
|
||||||
|
});
|
||||||
|
await section()
|
||||||
|
.getByRole('button', { name: 'Try again', exact: true })
|
||||||
|
.click();
|
||||||
|
await section().locator('[data-form-state="loading"]').waitFor();
|
||||||
|
assert.equal(await remove().isDisabled(), true);
|
||||||
|
await pending.abort();
|
||||||
|
await section().locator('[data-form-state="network"]').waitFor();
|
||||||
|
await page.unrouteAll();
|
||||||
|
|
||||||
|
await visit();
|
||||||
|
await section()
|
||||||
|
.getByRole('button', { name: 'Change parent', exact: true })
|
||||||
|
.click();
|
||||||
|
await page.getByLabel('Parent ticket', { exact: true }).selectOption('');
|
||||||
|
request = page.waitForRequest(
|
||||||
|
(r) => r.method() === 'PATCH' && r.url().endsWith('/tickets/42'),
|
||||||
|
);
|
||||||
|
await page
|
||||||
|
.getByRole('button', { name: 'Save changes', exact: true })
|
||||||
|
.click();
|
||||||
|
assert.equal((await request).postDataJSON().parent_ticket_id, '');
|
||||||
|
await page.getByText('Ticket updated.', { exact: true }).waitFor();
|
||||||
|
|
||||||
|
await visit('?readonly&parent&incoming');
|
||||||
|
assert.equal(await section().locator('form').count(), 0);
|
||||||
|
assert.equal(
|
||||||
|
await section()
|
||||||
|
.getByRole('button', { name: 'Change parent', exact: true })
|
||||||
|
.count(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
await section().getByText('Blocked by', { exact: true }).isVisible(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
for (const [query, message] of [
|
||||||
|
['?noTypes', 'No link types are configured for this project.'],
|
||||||
|
[
|
||||||
|
'?noTargets',
|
||||||
|
'No other tickets are available to link in this project.',
|
||||||
|
],
|
||||||
|
]) {
|
||||||
|
await visit(query);
|
||||||
|
assert.equal(
|
||||||
|
await section().getByText(message, { exact: true }).isVisible(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
assert.equal(await save().count(), 0);
|
||||||
|
}
|
||||||
|
assert.deepEqual(errors, []);
|
||||||
|
console.log(
|
||||||
|
'Ticket relationships browser checks passed: hierarchy, direction, add/remove, validation, retries, permissions, keyboard, mobile and themes.',
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
await browser.close();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user