mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Fixes bug where source list page would crash if first sync was running
This commit is contained in:
parent
e610b77f8d
commit
25aae9abc6
@ -25,8 +25,7 @@ import InventorySourceListItem from './InventorySourceListItem';
|
||||
import useWsInventorySources from './useWsInventorySources';
|
||||
import { relatedResourceDeleteRequests } from '../../../util/getRelatedResourceDeleteDetails';
|
||||
|
||||
const QS_CONFIG = getQSConfig('inventory', {
|
||||
not__source: '',
|
||||
const QS_CONFIG = getQSConfig('inventory_sources', {
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
order_by: 'name',
|
||||
|
||||
@ -115,7 +115,6 @@ describe('<InventorySourceList />', () => {
|
||||
|
||||
test('api calls should be made on mount', async () => {
|
||||
expect(InventoriesAPI.readSources).toHaveBeenCalledWith('1', {
|
||||
not__source: '',
|
||||
order_by: 'name',
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
|
||||
@ -94,16 +94,18 @@ function InventorySourceListItem({
|
||||
<ActionsTd dataLabel={t`Actions`}>
|
||||
{['running', 'pending', 'waiting'].includes(source?.status) ? (
|
||||
<ActionItem visible={source.summary_fields.user_capabilities.start}>
|
||||
<JobCancelButton
|
||||
job={{
|
||||
type: 'inventory_update',
|
||||
id: source.summary_fields.last_job.id,
|
||||
}}
|
||||
errorTitle={t`Inventory Source Sync Error`}
|
||||
errorMessage={t`Failed to cancel Inventory Source Sync`}
|
||||
title={t`Cancel Inventory Source Sync`}
|
||||
showIconButton
|
||||
/>
|
||||
{source.summary_fields?.current_job?.id && (
|
||||
<JobCancelButton
|
||||
job={{
|
||||
type: 'inventory_update',
|
||||
id: source.summary_fields.current_job.id,
|
||||
}}
|
||||
errorTitle={t`Inventory Source Sync Error`}
|
||||
errorMessage={t`Failed to cancel Inventory Source Sync`}
|
||||
title={t`Cancel Inventory Source Sync`}
|
||||
showIconButton
|
||||
/>
|
||||
)}
|
||||
</ActionItem>
|
||||
) : (
|
||||
<ActionItem
|
||||
|
||||
@ -198,4 +198,33 @@ describe('<InventorySourceListItem />', () => {
|
||||
'Custom virtual environment /var/lib/awx/env must be replaced by an execution environment.'
|
||||
);
|
||||
});
|
||||
|
||||
test('should render cancel button while job is running', () => {
|
||||
const onSelect = jest.fn();
|
||||
wrapper = mountWithContexts(
|
||||
<table>
|
||||
<tbody>
|
||||
<InventorySourceListItem
|
||||
source={{
|
||||
...source,
|
||||
status: 'running',
|
||||
summary_fields: {
|
||||
...source.summary_fields,
|
||||
current_job: {
|
||||
id: 1000,
|
||||
status: 'running',
|
||||
},
|
||||
},
|
||||
custom_virtualenv: '/var/lib/awx/env',
|
||||
execution_environment: null,
|
||||
}}
|
||||
isSelected={false}
|
||||
onSelect={onSelect}
|
||||
label="Source Bar"
|
||||
/>
|
||||
</tbody>
|
||||
</table>
|
||||
);
|
||||
expect(wrapper.find('JobCancelButton').length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user