mirror of
https://github.com/ansible/awx.git
synced 2026-05-09 18:37:36 -02:30
Filter EE also by Organization for JT
Filter EE also by Organization for JT. See: https://github.com/ansible/awx/issues/9770
This commit is contained in:
@@ -75,15 +75,21 @@ function ExecutionEnvironmentLookup({
|
|||||||
const globallyAvailableParams = globallyAvailable
|
const globallyAvailableParams = globallyAvailable
|
||||||
? { or__organization__isnull: 'True' }
|
? { or__organization__isnull: 'True' }
|
||||||
: {};
|
: {};
|
||||||
const organizationIdParams =
|
const organizationIdParams = organizationId
|
||||||
organizationId || project?.organization
|
? { or__organization__id: organizationId }
|
||||||
? { or__organization__id: organizationId }
|
: {};
|
||||||
|
const projectIdParams =
|
||||||
|
projectId && project?.organization
|
||||||
|
? {
|
||||||
|
or__organization__id: project.organization,
|
||||||
|
}
|
||||||
: {};
|
: {};
|
||||||
const [{ data }, actionsResponse] = await Promise.all([
|
const [{ data }, actionsResponse] = await Promise.all([
|
||||||
ExecutionEnvironmentsAPI.read(
|
ExecutionEnvironmentsAPI.read(
|
||||||
mergeParams(params, {
|
mergeParams(params, {
|
||||||
...globallyAvailableParams,
|
...globallyAvailableParams,
|
||||||
...organizationIdParams,
|
...organizationIdParams,
|
||||||
|
...projectIdParams,
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
ExecutionEnvironmentsAPI.readOptions(),
|
ExecutionEnvironmentsAPI.readOptions(),
|
||||||
@@ -98,7 +104,7 @@ function ExecutionEnvironmentLookup({
|
|||||||
actionsResponse.data.actions?.GET || {}
|
actionsResponse.data.actions?.GET || {}
|
||||||
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
|
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
|
||||||
};
|
};
|
||||||
}, [location, globallyAvailable, organizationId, project]),
|
}, [location, globallyAvailable, organizationId, projectId, project]),
|
||||||
{
|
{
|
||||||
executionEnvironments: [],
|
executionEnvironments: [],
|
||||||
count: 0,
|
count: 0,
|
||||||
@@ -174,7 +180,7 @@ function ExecutionEnvironmentLookup({
|
|||||||
label={renderLabel(isGlobalDefaultEnvironment, isDefaultEnvironment)}
|
label={renderLabel(isGlobalDefaultEnvironment, isDefaultEnvironment)}
|
||||||
labelIcon={popoverContent && <Popover content={popoverContent} />}
|
labelIcon={popoverContent && <Popover content={popoverContent} />}
|
||||||
>
|
>
|
||||||
{tooltip ? (
|
{tooltip && isDisabled ? (
|
||||||
<Tooltip content={tooltip}>{renderLookup()}</Tooltip>
|
<Tooltip content={tooltip}>{renderLookup()}</Tooltip>
|
||||||
) : (
|
) : (
|
||||||
renderLookup()
|
renderLookup()
|
||||||
|
|||||||
@@ -32,17 +32,7 @@ describe('ExecutionEnvironmentLookup', () => {
|
|||||||
ExecutionEnvironmentsAPI.read.mockResolvedValue(
|
ExecutionEnvironmentsAPI.read.mockResolvedValue(
|
||||||
mockedExecutionEnvironments
|
mockedExecutionEnvironments
|
||||||
);
|
);
|
||||||
ProjectsAPI.read.mockResolvedValue({
|
ProjectsAPI.readDetail.mockResolvedValue({ data: { organization: 39 } });
|
||||||
data: {
|
|
||||||
count: 1,
|
|
||||||
results: [
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'Fuz',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@@ -97,4 +87,45 @@ describe('ExecutionEnvironmentLookup', () => {
|
|||||||
wrapper.find('FormGroup[label="Execution Environment"]').length
|
wrapper.find('FormGroup[label="Execution Environment"]').length
|
||||||
).toBe(1);
|
).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should call api with organization id', async () => {
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<ExecutionEnvironmentLookup
|
||||||
|
value={executionEnvironment}
|
||||||
|
onChange={() => {}}
|
||||||
|
organizationId={1}
|
||||||
|
globallyAvailable
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
expect(ExecutionEnvironmentsAPI.read).toHaveBeenCalledWith({
|
||||||
|
or__organization__id: 1,
|
||||||
|
or__organization__isnull: 'True',
|
||||||
|
order_by: 'name',
|
||||||
|
page: 1,
|
||||||
|
page_size: 5,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should call api with organization id from the related project', async () => {
|
||||||
|
await act(async () => {
|
||||||
|
wrapper = mountWithContexts(
|
||||||
|
<ExecutionEnvironmentLookup
|
||||||
|
value={executionEnvironment}
|
||||||
|
onChange={() => {}}
|
||||||
|
projectId={12}
|
||||||
|
globallyAvailable
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
expect(ProjectsAPI.readDetail).toHaveBeenCalledWith(12);
|
||||||
|
expect(ExecutionEnvironmentsAPI.read).toHaveBeenCalledWith({
|
||||||
|
or__organization__id: 39,
|
||||||
|
or__organization__isnull: 'True',
|
||||||
|
order_by: 'name',
|
||||||
|
page: 1,
|
||||||
|
page_size: 5,
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ function JobTemplateForm({
|
|||||||
t`Select a project before editing the execution environment.`
|
t`Select a project before editing the execution environment.`
|
||||||
)}
|
)}
|
||||||
globallyAvailable
|
globallyAvailable
|
||||||
isDisabled={!projectField.value}
|
isDisabled={!projectField.value?.id}
|
||||||
projectId={projectField.value?.id}
|
projectId={projectField.value?.id}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user