mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
resolve cyclical group association
This commit is contained in:
@@ -48,6 +48,12 @@ class Groups extends Base {
|
|||||||
id: childId,
|
id: childId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readPotentialGroups(id, params) {
|
||||||
|
return this.http.get(`${this.baseUrl}${id}/potential_children/`, {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Groups;
|
export default Groups;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ function InventoryGroup({ i18n, setBreadcrumb, inventory }) {
|
|||||||
{
|
{
|
||||||
name: (
|
name: (
|
||||||
<>
|
<>
|
||||||
<CaretLeftIcon />
|
<CaretLeftIcon aria-label={i18n._(t`Back to Groups`)} />
|
||||||
{i18n._(t`Back to Groups`)}
|
{i18n._(t`Back to Groups`)}
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -73,13 +73,14 @@ function InventoryRelatedGroupList({ i18n }) {
|
|||||||
|
|
||||||
const fetchGroupsToAssociate = useCallback(
|
const fetchGroupsToAssociate = useCallback(
|
||||||
params => {
|
params => {
|
||||||
return InventoriesAPI.readGroups(
|
return GroupsAPI.readPotentialGroups(
|
||||||
inventoryId,
|
groupId,
|
||||||
mergeParams(params, { not__id: inventoryId, not__parents: inventoryId })
|
mergeParams(params, { not__id: groupId, not__parents: groupId })
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
[inventoryId]
|
[groupId]
|
||||||
);
|
);
|
||||||
|
|
||||||
const associateGroup = useCallback(
|
const associateGroup = useCallback(
|
||||||
async selectedGroups => {
|
async selectedGroups => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ describe('<InventoryRelatedGroupList />', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('should associate existing group', async () => {
|
test('should associate existing group', async () => {
|
||||||
InventoriesAPI.readGroups.mockResolvedValue({
|
GroupsAPI.readPotentialGroups.mockResolvedValue({
|
||||||
data: { count: mockGroups.length, results: mockGroups },
|
data: { count: mockGroups.length, results: mockGroups },
|
||||||
});
|
});
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
@@ -204,6 +204,13 @@ describe('<InventoryRelatedGroupList />', () => {
|
|||||||
.find('DropdownItem[aria-label="Add existing group"]')
|
.find('DropdownItem[aria-label="Add existing group"]')
|
||||||
.prop('onClick')()
|
.prop('onClick')()
|
||||||
);
|
);
|
||||||
|
expect(GroupsAPI.readPotentialGroups).toBeCalledWith(2, {
|
||||||
|
not__id: 2,
|
||||||
|
not__parents: 2,
|
||||||
|
order_by: 'name',
|
||||||
|
page: 1,
|
||||||
|
page_size: 5,
|
||||||
|
});
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
act(() =>
|
act(() =>
|
||||||
wrapper.find('CheckboxListItem[name="foo"]').prop('onSelect')({ id: 1 })
|
wrapper.find('CheckboxListItem[name="foo"]').prop('onSelect')({ id: 1 })
|
||||||
|
|||||||
Reference in New Issue
Block a user