mirror of
https://github.com/ansible/awx.git
synced 2026-03-02 01:08:48 -03:30
Merge pull request #10417 from mabashian/10411-inv-src-sync-details
Fixes bug where source list page would crash if first sync was running SUMMARY link #10411 The ID being passed to the cancel button was incorrect as well. We want to reference current_job not last_job. ISSUE TYPE Bugfix Pull Request COMPONENT NAME UI Reviewed-by: Jake McDermott <yo@jakemcdermott.me> Reviewed-by: Kersom <None> Reviewed-by: Sarah Akus <sarah.akus@gmail.com>
This commit is contained in:
@@ -25,8 +25,7 @@ import InventorySourceListItem from './InventorySourceListItem';
|
|||||||
import useWsInventorySources from './useWsInventorySources';
|
import useWsInventorySources from './useWsInventorySources';
|
||||||
import { relatedResourceDeleteRequests } from '../../../util/getRelatedResourceDeleteDetails';
|
import { relatedResourceDeleteRequests } from '../../../util/getRelatedResourceDeleteDetails';
|
||||||
|
|
||||||
const QS_CONFIG = getQSConfig('inventory', {
|
const QS_CONFIG = getQSConfig('inventory-sources', {
|
||||||
not__source: '',
|
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 20,
|
page_size: 20,
|
||||||
order_by: 'name',
|
order_by: 'name',
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ describe('<InventorySourceList />', () => {
|
|||||||
|
|
||||||
test('api calls should be made on mount', async () => {
|
test('api calls should be made on mount', async () => {
|
||||||
expect(InventoriesAPI.readSources).toHaveBeenCalledWith('1', {
|
expect(InventoriesAPI.readSources).toHaveBeenCalledWith('1', {
|
||||||
not__source: '',
|
|
||||||
order_by: 'name',
|
order_by: 'name',
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 20,
|
page_size: 20,
|
||||||
|
|||||||
@@ -94,16 +94,18 @@ function InventorySourceListItem({
|
|||||||
<ActionsTd dataLabel={t`Actions`}>
|
<ActionsTd dataLabel={t`Actions`}>
|
||||||
{['running', 'pending', 'waiting'].includes(source?.status) ? (
|
{['running', 'pending', 'waiting'].includes(source?.status) ? (
|
||||||
<ActionItem visible={source.summary_fields.user_capabilities.start}>
|
<ActionItem visible={source.summary_fields.user_capabilities.start}>
|
||||||
<JobCancelButton
|
{source.summary_fields?.current_job?.id && (
|
||||||
job={{
|
<JobCancelButton
|
||||||
type: 'inventory_update',
|
job={{
|
||||||
id: source.summary_fields.last_job.id,
|
type: 'inventory_update',
|
||||||
}}
|
id: source.summary_fields.current_job.id,
|
||||||
errorTitle={t`Inventory Source Sync Error`}
|
}}
|
||||||
errorMessage={t`Failed to cancel Inventory Source Sync`}
|
errorTitle={t`Inventory Source Sync Error`}
|
||||||
title={t`Cancel Inventory Source Sync`}
|
errorMessage={t`Failed to cancel Inventory Source Sync`}
|
||||||
showIconButton
|
title={t`Cancel Inventory Source Sync`}
|
||||||
/>
|
showIconButton
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</ActionItem>
|
</ActionItem>
|
||||||
) : (
|
) : (
|
||||||
<ActionItem
|
<ActionItem
|
||||||
|
|||||||
@@ -198,4 +198,33 @@ describe('<InventorySourceListItem />', () => {
|
|||||||
'Custom virtual environment /var/lib/awx/env must be replaced by an execution environment.'
|
'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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user