Skip to content

Commit 7082c65

Browse files
authored
feat: New Cron Tab (#1078)
Signed-off-by: Tim Chan <[email protected]>
1 parent beba3e7 commit 7082c65

File tree

5 files changed

+66
-15
lines changed

5 files changed

+66
-15
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { styled as createStyled, type Theme } from 'baseui';
2+
3+
export const styled = {
4+
DomainCronListContainer: createStyled(
5+
'div',
6+
({ $theme }: { $theme: Theme }) => ({
7+
marginTop: $theme.sizing.scale950,
8+
marginBottom: $theme.sizing.scale900,
9+
})
10+
),
11+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
3+
import { styled } from './domain-cron-list.styles';
4+
5+
export default function DomainCronList() {
6+
return (
7+
<styled.DomainCronListContainer>
8+
Cron List, Coming Soon!
9+
</styled.DomainCronListContainer>
10+
);
11+
}

src/views/domain-page/config/domain-page-tabs.config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import {
44
MdSettings,
55
MdSort,
66
MdSyncAlt,
7+
MdSchedule,
78
} from 'react-icons/md';
89

10+
import DomainCronList from '@/views/domain-cron-list/domain-cron-list';
911
import DomainWorkflows from '@/views/domain-workflows/domain-workflows';
1012
import DomainWorkflowsArchival from '@/views/domain-workflows-archival/domain-workflows-archival';
1113

@@ -15,7 +17,7 @@ import DomainPageSettings from '../domain-page-settings/domain-page-settings';
1517
import type { DomainPageTabsConfig } from '../domain-page-tabs/domain-page-tabs.types';
1618

1719
const domainPageTabsConfig: DomainPageTabsConfig<
18-
'workflows' | 'metadata' | 'failovers' | 'settings' | 'archival'
20+
'workflows' | 'cron-list' | 'metadata' | 'failovers' | 'settings' | 'archival'
1921
> = {
2022
workflows: {
2123
title: 'Workflows',
@@ -26,6 +28,15 @@ const domainPageTabsConfig: DomainPageTabsConfig<
2628
actions: [{ kind: 'retry', label: 'Retry' }],
2729
}),
2830
},
31+
'cron-list': {
32+
title: 'Cron',
33+
artwork: MdSchedule,
34+
content: DomainCronList,
35+
getErrorConfig: () => ({
36+
message: 'Failed to load cron list',
37+
actions: [{ kind: 'retry', label: 'Retry' }],
38+
}),
39+
},
2940
metadata: {
3041
title: 'Metadata',
3142
artwork: MdListAlt,

src/views/domain-page/domain-page-tabs/__tests__/domain-page-tabs.test.tsx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ jest.mock('../../config/domain-page-tabs.config', () => ({
4040
title: 'Workflows',
4141
artwork: () => <div data-testid="workflows-artwork" />,
4242
},
43+
'cron-list': {
44+
title: 'Cron',
45+
artwork: () => <div data-testid="cron-list-artwork" />,
46+
},
4347
metadata: {
4448
title: 'Metadata',
4549
artwork: () => <div data-testid="metadata-artwork" />,
@@ -67,28 +71,34 @@ describe(DomainPageTabs.name, () => {
6771
jest.clearAllMocks();
6872
});
6973

70-
it('renders tabs titles correctly with failover history disabled', async () => {
71-
await setup({ enableFailoverHistory: false });
74+
it('renders tabs titles correctly', async () => {
75+
await setup();
7276

7377
expect(screen.getByText('Workflows')).toBeInTheDocument();
7478
expect(screen.getByText('Metadata')).toBeInTheDocument();
7579
expect(screen.getByText('Settings')).toBeInTheDocument();
7680
expect(screen.getByText('Archival')).toBeInTheDocument();
81+
82+
expect(screen.queryByText('Cron')).toBeNull();
7783
expect(screen.queryByText('Failovers')).toBeNull();
7884
});
7985

80-
it('renders tabs with failover history enabled', async () => {
81-
await setup({ enableFailoverHistory: true });
86+
it('renders tabs with cron and failover history enabled', async () => {
87+
await setup({
88+
enableFailoverHistory: true,
89+
enableCronList: true,
90+
});
8291

8392
expect(screen.getByText('Workflows')).toBeInTheDocument();
93+
expect(screen.getByText('Cron')).toBeInTheDocument();
8494
expect(screen.getByText('Metadata')).toBeInTheDocument();
8595
expect(screen.getByText('Failovers')).toBeInTheDocument();
8696
expect(screen.getByText('Settings')).toBeInTheDocument();
8797
expect(screen.getByText('Archival')).toBeInTheDocument();
8898
});
8999

90100
it('reroutes when new tab is clicked', async () => {
91-
const { user } = await setup({ enableFailoverHistory: false });
101+
const { user } = await setup();
92102

93103
const metadataTab = await screen.findByText('Metadata');
94104
await user.click(metadataTab);
@@ -108,7 +118,7 @@ describe(DomainPageTabs.name, () => {
108118
writable: true,
109119
});
110120

111-
const { user } = await setup({ enableFailoverHistory: false });
121+
const { user } = await setup();
112122

113123
const metadataTab = await screen.findByText('Metadata');
114124
await user.click(metadataTab);
@@ -121,7 +131,7 @@ describe(DomainPageTabs.name, () => {
121131
});
122132

123133
it('renders tabs artworks correctly', async () => {
124-
await setup({ enableFailoverHistory: false });
134+
await setup();
125135

126136
expect(screen.getByTestId('workflows-artwork')).toBeInTheDocument();
127137
expect(screen.getByTestId('metadata-artwork')).toBeInTheDocument();
@@ -152,13 +162,12 @@ describe(DomainPageTabs.name, () => {
152162
});
153163
});
154164

155-
async function setup({
156-
error,
157-
enableFailoverHistory,
158-
}: {
165+
async function setup(opts?: {
159166
error?: boolean;
160167
enableFailoverHistory?: boolean;
168+
enableCronList?: boolean;
161169
}) {
170+
const { error, enableFailoverHistory, enableCronList } = opts ?? {};
162171
const user = userEvent.setup();
163172

164173
render(
@@ -183,8 +192,10 @@ async function setup({
183192
);
184193
} else {
185194
return HttpResponse.json(
186-
(enableFailoverHistory ??
187-
false) satisfies GetConfigResponse<'FAILOVER_HISTORY_ENABLED'>
195+
((enableFailoverHistory ??
196+
false) satisfies GetConfigResponse<'FAILOVER_HISTORY_ENABLED'>) ||
197+
((enableCronList ??
198+
false) satisfies GetConfigResponse<'CRON_LIST_ENABLED'>)
188199
);
189200
}
190201
},

src/views/domain-page/domain-page-tabs/domain-page-tabs.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,22 @@ export default function DomainPageTabs() {
2727
'FAILOVER_HISTORY_ENABLED'
2828
);
2929

30+
const { data: isCronListEnabled } =
31+
useSuspenseConfigValue('CRON_LIST_ENABLED');
32+
3033
const tabsConfig = useMemo<Partial<typeof domainPageTabsConfig>>(() => {
3134
const tabsToHide: Array<DomainPageTabName> = [];
3235

3336
if (!isFailoverHistoryEnabled) {
3437
tabsToHide.push('failovers');
3538
}
3639

40+
if (!isCronListEnabled) {
41+
tabsToHide.push('cron-list');
42+
}
43+
3744
return omit(domainPageTabsConfig, tabsToHide);
38-
}, [isFailoverHistoryEnabled]);
45+
}, [isFailoverHistoryEnabled, isCronListEnabled]);
3946

4047
const tabList = useMemo(
4148
() =>

0 commit comments

Comments
 (0)