-
-
Notifications
You must be signed in to change notification settings - Fork 132
feat(tickets): add a basic (barren) React tickets list page #5181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wescopeland
merged 3 commits into
stack/tickets/3-index-backend
from
stack/tickets/4-tickets2-page
Sep 4, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace App\Platform\Data; | ||
|
|
||
| use App\Data\PaginatedData; | ||
| use App\Data\UserData; | ||
| use App\Platform\Enums\TicketListScope; | ||
| use Spatie\LaravelData\Data; | ||
| use Spatie\TypeScriptTransformer\Attributes\LiteralTypeScriptType; | ||
| use Spatie\TypeScriptTransformer\Attributes\TypeScript; | ||
|
|
||
| #[TypeScript('TicketListPageProps')] | ||
| class TicketListPagePropsData extends Data | ||
| { | ||
| /** | ||
| * @param TicketListFilterData[] $availableFilters | ||
| */ | ||
| public function __construct( | ||
| public TicketListScope $scope, | ||
| #[LiteralTypeScriptType('App.Data.PaginatedData<App.Platform.Data.TicketListEntry>')] | ||
| public PaginatedData $paginatedTickets, | ||
| public TicketListStateCountsData $stateCounts, | ||
| #[LiteralTypeScriptType('App.Platform.Data.TicketListFilter[]')] | ||
| public array $availableFilters, | ||
| public ?GameData $game = null, | ||
| public ?AchievementData $achievement = null, | ||
| public ?UserData $user = null, | ||
| ) { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
resources/js/features/tickets/components/+index/TicketIndexRoot.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| import { render, screen } from '@/test'; | ||
| import { | ||
| createPaginatedData, | ||
| createTicketListEntry, | ||
| createTicketListStateCounts, | ||
| createUser, | ||
| } from '@/test/factories'; | ||
|
|
||
| import { TicketIndexRoot } from './TicketIndexRoot'; | ||
|
|
||
| describe('Component: TicketIndexRoot', () => { | ||
| it('renders without crashing', () => { | ||
| // ARRANGE | ||
| const { container } = render<App.Platform.Data.TicketListPageProps>(<TicketIndexRoot />, { | ||
| pageProps: { | ||
| scope: 'all', | ||
| paginatedTickets: createPaginatedData([createTicketListEntry()], { | ||
| currentPage: 1, | ||
| lastPage: 1, | ||
| perPage: 50, | ||
| total: 1, | ||
| }), | ||
| stateCounts: createTicketListStateCounts(), | ||
| availableFilters: [{ kind: 'type', values: ['0', '1', '2'] }], | ||
| }, | ||
| }); | ||
|
|
||
| // ASSERT | ||
| expect(container).toBeTruthy(); | ||
| expect(screen.getByTestId('ticket-list')).toBeVisible(); | ||
|
|
||
| expect(screen.getByRole('heading', { level: 1, name: 'Ticket Manager' })).toBeVisible(); | ||
| }); | ||
|
|
||
| it('renders every default column and one row per ticket from the page props', () => { | ||
| // ARRANGE | ||
| const tickets = [ | ||
| createTicketListEntry({ | ||
| id: 1001, | ||
| state: 'open', | ||
| ticketableTitle: 'First Blood', | ||
| author: createUser({ displayName: 'Dev' }), | ||
| reporter: createUser({ displayName: 'Scott' }), | ||
| }), | ||
| createTicketListEntry({ id: 1002, ticketableTitle: 'Second Wind', state: 'quarantined' }), | ||
| ]; | ||
|
|
||
| render<App.Platform.Data.TicketListPageProps>(<TicketIndexRoot />, { | ||
| pageProps: { | ||
| scope: 'all', | ||
| paginatedTickets: createPaginatedData(tickets, { | ||
| currentPage: 1, | ||
| lastPage: 1, | ||
| perPage: 50, | ||
| total: tickets.length, | ||
| }), | ||
| stateCounts: createTicketListStateCounts(), | ||
| availableFilters: [{ kind: 'type', values: ['0', '1', '2'] }], | ||
| }, | ||
| }); | ||
|
|
||
| // ASSERT | ||
| expect(screen.getAllByRole('columnheader').map((header) => header.textContent)).toEqual([ | ||
| 'ID', | ||
| 'Issue with', | ||
| 'Game', | ||
| 'Developer', | ||
| 'Reporter', | ||
| 'Age', | ||
| ]); | ||
|
|
||
| expect(screen.getAllByRole('row')).toHaveLength(3); | ||
|
|
||
| expect(screen.getByRole('link', { name: 'Ticket #1001' })).toHaveAttribute( | ||
| 'href', | ||
| expect.stringContaining('ticket.show'), | ||
| ); | ||
| expect(screen.getByRole('link', { name: 'Ticket #1002' })).toBeVisible(); | ||
|
|
||
| expect(screen.getByRole('link', { name: 'First Blood' })).toHaveAttribute( | ||
| 'href', | ||
| expect.stringContaining('achievement.show'), | ||
| ); | ||
| expect(screen.getByRole('link', { name: 'Second Wind' })).toBeVisible(); | ||
|
|
||
| expect(screen.getByRole('link', { name: /dev/i })).toHaveAttribute( | ||
| 'href', | ||
| expect.stringContaining('user.show'), | ||
| ); | ||
| expect(screen.getByRole('link', { name: /scott/i })).toBeVisible(); | ||
|
|
||
| expect(screen.getByRole('img', { name: 'Quarantined' })).toBeVisible(); | ||
| }); | ||
|
|
||
| it('given the page has no tickets, shows the empty state instead of a table', () => { | ||
| // ARRANGE | ||
| render<App.Platform.Data.TicketListPageProps>(<TicketIndexRoot />, { | ||
| pageProps: { | ||
| scope: 'all', | ||
| paginatedTickets: createPaginatedData([], { | ||
| currentPage: 1, | ||
| lastPage: 1, | ||
| perPage: 50, | ||
| total: 0, | ||
| }), | ||
| stateCounts: createTicketListStateCounts(), | ||
| availableFilters: [{ kind: 'type', values: ['0', '1', '2'] }], | ||
| }, | ||
| }); | ||
|
|
||
| // ASSERT | ||
| expect(screen.getByText('No tickets match these filters.')).toBeVisible(); | ||
| expect(screen.queryByRole('table')).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
31 changes: 31 additions & 0 deletions
31
resources/js/features/tickets/components/+index/TicketIndexRoot.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import type { FC } from 'react'; | ||
|
|
||
| import { usePageProps } from '@/common/hooks/usePageProps'; | ||
|
|
||
| import { useTicketListColumnDefinitions } from '../../hooks/useTicketListColumnDefinitions'; | ||
| import { TICKET_LIST_COLUMN_IDS } from '../../utils/ticketListColumnIds'; | ||
| import { TicketListEmptyState } from '../TicketListEmptyState'; | ||
| import { TicketListHeading } from '../TicketListHeading'; | ||
| import { TicketListTable } from '../TicketListTable'; | ||
|
|
||
| // temporary - selectable columns will arrive in a future commit | ||
| const columnVisibility = Object.fromEntries(TICKET_LIST_COLUMN_IDS.map((id) => [id, true])); | ||
|
|
||
| export const TicketIndexRoot: FC = () => { | ||
| const { paginatedTickets } = usePageProps<App.Platform.Data.TicketListPageProps>(); | ||
|
|
||
| const columnDefinitions = useTicketListColumnDefinitions(); | ||
|
|
||
| return ( | ||
| <div data-testid="ticket-list" className="flex flex-col gap-4"> | ||
| <TicketListHeading /> | ||
|
|
||
| <TicketListTable | ||
| columnDefinitions={columnDefinitions} | ||
| columnVisibility={columnVisibility} | ||
| emptyStateNode={<TicketListEmptyState />} | ||
| paginatedTickets={paginatedTickets} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './TicketIndexRoot'; |
21 changes: 21 additions & 0 deletions
21
resources/js/features/tickets/components/TicketListEmptyState/TicketListEmptyState.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { render, screen } from '@/test'; | ||
|
|
||
| import { TicketListEmptyState } from './TicketListEmptyState'; | ||
|
|
||
| describe('Component: TicketListEmptyState', () => { | ||
| it('renders without crashing', () => { | ||
| // ARRANGE | ||
| const { container } = render(<TicketListEmptyState />); | ||
|
|
||
| // ASSERT | ||
| expect(container).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('shows the empty copy', () => { | ||
| // ARRANGE | ||
| render(<TicketListEmptyState />); | ||
|
|
||
| // ASSERT | ||
| expect(screen.getByText('No tickets match these filters.')).toBeVisible(); | ||
| }); | ||
| }); |
12 changes: 12 additions & 0 deletions
12
resources/js/features/tickets/components/TicketListEmptyState/TicketListEmptyState.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type { FC } from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| export const TicketListEmptyState: FC = () => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| return ( | ||
| <p className="py-[0.4em] pb-[1.2em] text-neutral-400 light:text-neutral-600"> | ||
| {t('No tickets match these filters.')} | ||
| </p> | ||
| ); | ||
| }; |
1 change: 1 addition & 0 deletions
1
resources/js/features/tickets/components/TicketListEmptyState/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './TicketListEmptyState'; |
25 changes: 25 additions & 0 deletions
25
resources/js/features/tickets/components/TicketListHeading/TicketListHeading.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { render, screen } from '@/test'; | ||
|
|
||
| import { TicketListHeading } from './TicketListHeading'; | ||
|
|
||
| describe('Component: TicketListHeading', () => { | ||
| it('renders without crashing', () => { | ||
| // ARRANGE | ||
| const { container } = render<App.Platform.Data.TicketListPageProps>(<TicketListHeading />, { | ||
| pageProps: { scope: 'all' }, | ||
| }); | ||
|
|
||
| // ASSERT | ||
| expect(container).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('shows the Ticket Manager heading copy', () => { | ||
| // ARRANGE | ||
| render<App.Platform.Data.TicketListPageProps>(<TicketListHeading />, { | ||
| pageProps: { scope: 'all' }, | ||
| }); | ||
|
|
||
| // ASSERT | ||
| expect(screen.getByRole('heading', { level: 1, name: /ticket manager/i })).toBeVisible(); | ||
| }); | ||
| }); |
12 changes: 12 additions & 0 deletions
12
resources/js/features/tickets/components/TicketListHeading/TicketListHeading.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type { FC } from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| export const TicketListHeading: FC = () => { | ||
| const { t } = useTranslation(); | ||
|
|
||
| return ( | ||
| <div className="mb-1 flex w-full"> | ||
| <h1 className="text-h3 w-full sm:text-[2.0em]!">{t('Ticket Manager')}</h1> | ||
| </div> | ||
| ); | ||
| }; |
1 change: 1 addition & 0 deletions
1
resources/js/features/tickets/components/TicketListHeading/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './TicketListHeading'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.