Skip to content

Commit 17e5ae3

Browse files
committed
Fixes #39494 - Fix create report button is enabled when state is 'running'
1 parent 0b331d9 commit 17e5ae3

3 files changed

Lines changed: 43 additions & 5 deletions

File tree

webpack/JobInvocationDetail/JobInvocationConstants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const STATUS = {
3838
SUCCEEDED: 'succeeded',
3939
FAILED: 'failed',
4040
CANCELLED: 'cancelled',
41+
RUNNING: 'running',
4142
};
4243

4344
export const STATUS_UPPERCASE = {

webpack/JobInvocationDetail/JobInvocationToolbarButtons.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ const JobInvocationToolbarButtons = ({ jobId, data }) => {
5858
);
5959
}, [jobId, reportTemplateJobId, templateInputId]);
6060

61+
const isCreateReportDisabled =
62+
!canGenerateReportTemplates ||
63+
task?.state === STATUS.RUNNING ||
64+
task?.state === STATUS.PENDING ||
65+
reportHref === undefined;
66+
6167
const onActionFocus = useCallback(() => {
6268
const element = document.getElementById(
6369
`toggle-split-button-action-primary-${jobId}`
@@ -280,11 +286,7 @@ const JobInvocationToolbarButtons = ({ jobId, data }) => {
280286
className="button-create-report"
281287
href={reportHref}
282288
variant="secondary"
283-
isDisabled={
284-
!canGenerateReportTemplates ||
285-
task?.state === STATUS.PENDING ||
286-
reportHref === undefined
287-
}
289+
isDisabled={isCreateReportDisabled}
288290
>
289291
{__(`Create report`)}
290292
</Button>

webpack/JobInvocationDetail/__tests__/MainInformation.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,41 @@ describe('JobInvocationDetailPage', () => {
234234
expect(screen.getByText('Rerun all')).toBeInTheDocument();
235235
});
236236

237+
it('disables Create report when the job task state is running', async () => {
238+
const jobId = jobInvocationData.id;
239+
const store = mockStore({
240+
...initialState,
241+
JOB_INVOCATION_KEY: {
242+
response: {
243+
...jobInvocationData,
244+
task: { ...jobInvocationData.task, state: 'running' },
245+
},
246+
},
247+
CURRENT_PERMISSIONS: {
248+
response: {
249+
results: [{ name: 'generate_report_templates' }],
250+
},
251+
status: 'RESOLVED',
252+
},
253+
});
254+
255+
render(
256+
<Provider store={store}>
257+
<JobInvocationDetailPage
258+
match={{ params: { id: `${jobId}` } }}
259+
{...props}
260+
/>
261+
</Provider>
262+
);
263+
264+
const createReportButton = screen.getByRole('link', {
265+
name: 'Create report',
266+
});
267+
268+
expect(createReportButton).toHaveAttribute('aria-disabled', 'true');
269+
expect(createReportButton).toHaveClass('pf-m-disabled');
270+
});
271+
237272
it('shows scheduled date', async () => {
238273
const store = mockStore(initialStateScheduled);
239274
render(

0 commit comments

Comments
 (0)