mirror of
https://github.com/ansible/awx.git
synced 2026-02-18 11:40:05 -03:30
Merge pull request #10927 from kialam/feature-10853-control-node-read-only
Disable checkbox for instances with node type control.
This commit is contained in:
@@ -89,9 +89,14 @@ function InstanceList() {
|
|||||||
useCallback(
|
useCallback(
|
||||||
() =>
|
() =>
|
||||||
Promise.all(
|
Promise.all(
|
||||||
selected.map((instance) =>
|
selected
|
||||||
InstanceGroupsAPI.disassociateInstance(instanceGroupId, instance.id)
|
.filter((s) => s.node_type !== 'control')
|
||||||
)
|
.map((instance) =>
|
||||||
|
InstanceGroupsAPI.disassociateInstance(
|
||||||
|
instanceGroupId,
|
||||||
|
instance.id
|
||||||
|
)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
[instanceGroupId, selected]
|
[instanceGroupId, selected]
|
||||||
),
|
),
|
||||||
@@ -106,9 +111,11 @@ function InstanceList() {
|
|||||||
useCallback(
|
useCallback(
|
||||||
async (instancesToAssociate) => {
|
async (instancesToAssociate) => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
instancesToAssociate.map((instance) =>
|
instancesToAssociate
|
||||||
InstanceGroupsAPI.associateInstance(instanceGroupId, instance.id)
|
.filter((i) => i.node_type !== 'control')
|
||||||
)
|
.map((instance) =>
|
||||||
|
InstanceGroupsAPI.associateInstance(instanceGroupId, instance.id)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
fetchInstances();
|
fetchInstances();
|
||||||
},
|
},
|
||||||
@@ -186,7 +193,9 @@ function InstanceList() {
|
|||||||
verifyCannotDisassociate={false}
|
verifyCannotDisassociate={false}
|
||||||
key="disassociate"
|
key="disassociate"
|
||||||
onDisassociate={handleDisassociate}
|
onDisassociate={handleDisassociate}
|
||||||
itemsToDisassociate={selected}
|
itemsToDisassociate={selected.filter(
|
||||||
|
(s) => s.node_type !== 'control'
|
||||||
|
)}
|
||||||
modalTitle={t`Disassociate instance from instance group?`}
|
modalTitle={t`Disassociate instance from instance group?`}
|
||||||
/>,
|
/>,
|
||||||
]}
|
]}
|
||||||
|
|||||||
@@ -106,9 +106,9 @@ function InstanceListItem({
|
|||||||
<Td
|
<Td
|
||||||
select={{
|
select={{
|
||||||
rowIndex,
|
rowIndex,
|
||||||
isSelected,
|
isSelected: isSelected && instance.node_type !== 'control',
|
||||||
onSelect,
|
onSelect,
|
||||||
disable: false,
|
disable: instance.node_type === 'control',
|
||||||
}}
|
}}
|
||||||
dataLabel={t`Selected`}
|
dataLabel={t`Selected`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -38,6 +38,33 @@ const instance = [
|
|||||||
managed_by_policy: true,
|
managed_by_policy: true,
|
||||||
node_type: 'hybrid',
|
node_type: 'hybrid',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
type: 'instance',
|
||||||
|
url: '/api/v2/instances/1/',
|
||||||
|
related: {
|
||||||
|
jobs: '/api/v2/instances/1/jobs/',
|
||||||
|
instance_groups: '/api/v2/instances/1/instance_groups/',
|
||||||
|
},
|
||||||
|
uuid: '00000000-0000-0000-0000-000000000001',
|
||||||
|
hostname: 'awx-control',
|
||||||
|
created: '2020-07-14T19:03:49.000054Z',
|
||||||
|
modified: '2020-08-12T20:08:02.836748Z',
|
||||||
|
capacity_adjustment: '0.40',
|
||||||
|
version: '13.0.0',
|
||||||
|
capacity: 10,
|
||||||
|
consumed_capacity: 0,
|
||||||
|
percent_capacity_remaining: 60.0,
|
||||||
|
jobs_running: 0,
|
||||||
|
jobs_total: 68,
|
||||||
|
cpu: 6,
|
||||||
|
memory: 2087469056,
|
||||||
|
cpu_capacity: 24,
|
||||||
|
mem_capacity: 1,
|
||||||
|
enabled: true,
|
||||||
|
managed_by_policy: true,
|
||||||
|
node_type: 'control',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
describe('<InstanceListItem/>', () => {
|
describe('<InstanceListItem/>', () => {
|
||||||
@@ -167,6 +194,24 @@ describe('<InstanceListItem/>', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should disable checkbox', async () => {
|
||||||
|
const onSelect = jest.fn();
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<InstanceListItem
|
||||||
|
instance={instance[1]}
|
||||||
|
onSelect={onSelect}
|
||||||
|
fetchInstances={() => {}}
|
||||||
|
/>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
expect(wrapper.find('Td').first().prop('select').disable).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
test('should display instance toggle', () => {
|
test('should display instance toggle', () => {
|
||||||
expect(wrapper.find('InstanceToggle').length).toBe(1);
|
expect(wrapper.find('InstanceToggle').length).toBe(1);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user