mirror of
https://github.com/ansible/awx.git
synced 2026-01-18 05:01:19 -03: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:
parent
416951ca86
commit
ff7a7945ca
@ -75,15 +75,21 @@ function ExecutionEnvironmentLookup({
|
||||
const globallyAvailableParams = globallyAvailable
|
||||
? { or__organization__isnull: 'True' }
|
||||
: {};
|
||||
const organizationIdParams =
|
||||
organizationId || project?.organization
|
||||
? { or__organization__id: organizationId }
|
||||
const organizationIdParams = organizationId
|
||||
? { or__organization__id: organizationId }
|
||||
: {};
|
||||
const projectIdParams =
|
||||
projectId && project?.organization
|
||||
? {
|
||||
or__organization__id: project.organization,
|
||||
}
|
||||
: {};
|
||||
const [{ data }, actionsResponse] = await Promise.all([
|
||||
ExecutionEnvironmentsAPI.read(
|
||||
mergeParams(params, {
|
||||
...globallyAvailableParams,
|
||||
...organizationIdParams,
|
||||
...projectIdParams,
|
||||
})
|
||||
),
|
||||
ExecutionEnvironmentsAPI.readOptions(),
|
||||
@ -98,7 +104,7 @@ function ExecutionEnvironmentLookup({
|
||||
actionsResponse.data.actions?.GET || {}
|
||||
).filter(key => actionsResponse.data.actions?.GET[key].filterable),
|
||||
};
|
||||
}, [location, globallyAvailable, organizationId, project]),
|
||||
}, [location, globallyAvailable, organizationId, projectId, project]),
|
||||
{
|
||||
executionEnvironments: [],
|
||||
count: 0,
|
||||
@ -174,7 +180,7 @@ function ExecutionEnvironmentLookup({
|
||||
label={renderLabel(isGlobalDefaultEnvironment, isDefaultEnvironment)}
|
||||
labelIcon={popoverContent && <Popover content={popoverContent} />}
|
||||
>
|
||||
{tooltip ? (
|
||||
{tooltip && isDisabled ? (
|
||||
<Tooltip content={tooltip}>{renderLookup()}</Tooltip>
|
||||
) : (
|
||||
renderLookup()
|
||||
|
||||
@ -32,17 +32,7 @@ describe('ExecutionEnvironmentLookup', () => {
|
||||
ExecutionEnvironmentsAPI.read.mockResolvedValue(
|
||||
mockedExecutionEnvironments
|
||||
);
|
||||
ProjectsAPI.read.mockResolvedValue({
|
||||
data: {
|
||||
count: 1,
|
||||
results: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Fuz',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
ProjectsAPI.readDetail.mockResolvedValue({ data: { organization: 39 } });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@ -97,4 +87,45 @@ describe('ExecutionEnvironmentLookup', () => {
|
||||
wrapper.find('FormGroup[label="Execution Environment"]').length
|
||||
).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.`
|
||||
)}
|
||||
globallyAvailable
|
||||
isDisabled={!projectField.value}
|
||||
isDisabled={!projectField.value?.id}
|
||||
projectId={projectField.value?.id}
|
||||
/>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user