Skip to content

Commit d2ea352

Browse files
matejvasekclaude
andcommitted
refactor: move action buttons into toolbar
The refresh and create buttons were placed in separate locations (header and a Content block). This moves both into a PatternFly Toolbar above the table, following the standard pattern used elsewhere in the project. The toolbar only renders when functions are loaded, so the refresh button test now checks the icon after initial load completes rather than during loading. Signed-off-by: Matej Vašek <matejvasek@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f746a7d commit d2ea352

2 files changed

Lines changed: 36 additions & 30 deletions

File tree

src/views/FunctionsListPage.test.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -464,15 +464,8 @@ describe('FunctionsListPage', () => {
464464

465465
it('does not spin the refresh icon on initial page load', async () => {
466466
renderAuthenticated();
467-
let resolveRepos: (value: unknown[]) => void;
468-
const mockListRepos = vi.fn().mockImplementation(
469-
() =>
470-
new Promise((resolve) => {
471-
resolveRepos = resolve;
472-
}),
473-
);
474467
mockUseSourceControl.mockReturnValue({
475-
listFunctionRepos: mockListRepos,
468+
listFunctionRepos: vi.fn().mockResolvedValue([repoFixture('fn-a')]),
476469
fetchFileContent: vi.fn().mockResolvedValue('name: fn-a\nruntime: go\nnamespace: demo\n'),
477470
});
478471
mockUseClusterService.mockReturnValue(clusterData());
@@ -483,11 +476,10 @@ describe('FunctionsListPage', () => {
483476
</MemoryRouter>,
484477
);
485478

479+
await screen.findByTestId('fn-name');
480+
486481
const icon = screen.getByRole('button', { name: 'Refresh' }).querySelector('svg');
487482
expect(icon?.classList.contains('func-console__refresh-spin')).toBe(false);
488-
489-
resolveRepos!([repoFixture('fn-a')]);
490-
await screen.findByTestId('fn-name');
491483
});
492484

493485
it('spins the refresh icon only while a button-triggered refresh is in flight', async () => {

src/views/FunctionsListPage.tsx

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import {
1010
ContentVariants,
1111
PageSection,
1212
Spinner,
13+
Toolbar,
14+
ToolbarContent,
15+
ToolbarGroup,
16+
ToolbarItem,
1317
Tooltip,
1418
} from '@patternfly/react-core';
1519
import { SyncAltIcon } from '@patternfly/react-icons';
@@ -46,11 +50,6 @@ function FunctionsListPageContent() {
4650
<>
4751
<DocumentTitle>{t('Functions')}</DocumentTitle>
4852
<ListPageHeader title={t('Functions')}>
49-
<Tooltip content={t('Refresh')}>
50-
<Button variant="plain" aria-label={t('Refresh')} onClick={onRefresh}>
51-
<SyncAltIcon className={refreshing ? 'func-console__refresh-spin' : undefined} />
52-
</Button>
53-
</Tooltip>
5453
<UserAvatar enableReconnect />
5554
</ListPageHeader>
5655
<PageSection>
@@ -72,20 +71,35 @@ function FunctionsListPageContent() {
7271
'Serverless functions in your repository and deployed to your cluster. Manage lifecycle, monitor status, and scale on demand.',
7372
)}
7473
</Content>
75-
<Content component={ContentVariants.p}>
76-
{!isConnectedToForge ? (
77-
<Button variant="primary" isDisabled>
78-
{t('Create new function')}
79-
</Button>
80-
) : (
81-
<Button
82-
variant="primary"
83-
component={(props) => <Link {...props} to="/faas/create" />}
84-
>
85-
{t('Create new function')}
86-
</Button>
87-
)}
88-
</Content>
74+
<Toolbar>
75+
<ToolbarContent>
76+
<ToolbarItem>
77+
{!isConnectedToForge ? (
78+
<Button variant="primary" isDisabled>
79+
{t('Create new function')}
80+
</Button>
81+
) : (
82+
<Button
83+
variant="primary"
84+
component={(props) => <Link {...props} to="/faas/create" />}
85+
>
86+
{t('Create new function')}
87+
</Button>
88+
)}
89+
</ToolbarItem>
90+
<ToolbarGroup align={{ default: 'alignEnd' }}>
91+
<ToolbarItem>
92+
<Tooltip content={t('Refresh')}>
93+
<Button variant="plain" aria-label={t('Refresh')} onClick={onRefresh}>
94+
<SyncAltIcon
95+
className={refreshing ? 'func-console__refresh-spin' : undefined}
96+
/>
97+
</Button>
98+
</Tooltip>
99+
</ToolbarItem>
100+
</ToolbarGroup>
101+
</ToolbarContent>
102+
</Toolbar>
89103
<FunctionTable functions={functions} onEdit={onEdit} />
90104
</>
91105
)}

0 commit comments

Comments
 (0)