Remove EE from WorkflowJobTemplate screens

Remove EE from WorkflowJobTemplate screens

Related ansible/awx#10443
Related ansible/awx#10399
This commit is contained in:
nixocio
2021-06-16 11:52:07 -04:00
committed by Shane McDonald
parent 15444bef70
commit 7b9bcd0481
8 changed files with 8 additions and 116 deletions

View File

@@ -274,10 +274,12 @@ function TemplateListItem({
dataCy={`template-${template.id}-project`} dataCy={`template-${template.id}-project`}
/> />
)} )}
<ExecutionEnvironmentDetail {template.type === 'job_template' && (
virtualEnvironment={template.custom_virtualenv} <ExecutionEnvironmentDetail
executionEnvironment={summaryFields?.execution_environment} virtualEnvironment={template.custom_virtualenv}
/> executionEnvironment={summaryFields?.execution_environment}
/>
)}
<Detail <Detail
label={t`Last Modified`} label={t`Last Modified`}
value={formatDateString(template.modified)} value={formatDateString(template.modified)}

View File

@@ -37,10 +37,7 @@ function WorkflowJobTemplateAdd() {
try { try {
const { const {
data: { id }, data: { id },
} = await WorkflowJobTemplatesAPI.create({ } = await WorkflowJobTemplatesAPI.create(templatePayload);
...templatePayload,
execution_environment: values.execution_environment?.id,
});
await Promise.all(await submitLabels(id, labels, organizationId)); await Promise.all(await submitLabels(id, labels, organizationId));
history.push(`/templates/workflow_job_template/${id}/visualizer`); history.push(`/templates/workflow_job_template/${id}/visualizer`);
} catch (err) { } catch (err) {

View File

@@ -6,7 +6,6 @@ import {
WorkflowJobTemplatesAPI, WorkflowJobTemplatesAPI,
OrganizationsAPI, OrganizationsAPI,
LabelsAPI, LabelsAPI,
ExecutionEnvironmentsAPI,
UsersAPI, UsersAPI,
} from '../../../api'; } from '../../../api';
import { import {
@@ -38,10 +37,6 @@ describe('<WorkflowJobTemplateAdd/>', () => {
}, },
}); });
ExecutionEnvironmentsAPI.read.mockResolvedValueOnce({
data: { results: [{ id: 1, name: 'Foo', image: 'localhost.com' }] },
});
UsersAPI.readAdminOfOrganizations.mockResolvedValue({ UsersAPI.readAdminOfOrganizations.mockResolvedValue({
data: { count: 0, results: [] }, data: { count: 0, results: [] },
}); });
@@ -94,11 +89,6 @@ describe('<WorkflowJobTemplateAdd/>', () => {
.find('LabelSelect') .find('LabelSelect')
.find('SelectToggle') .find('SelectToggle')
.simulate('click'); .simulate('click');
wrapper.find('ExecutionEnvironmentLookup').invoke('onChange')({
id: 1,
name: 'Foo',
});
}); });
await act(async () => { await act(async () => {
@@ -132,7 +122,6 @@ describe('<WorkflowJobTemplateAdd/>', () => {
webhook_credential: undefined, webhook_credential: undefined,
webhook_service: '', webhook_service: '',
webhook_url: '', webhook_url: '',
execution_environment: 1,
}); });
expect(WorkflowJobTemplatesAPI.associateLabel).toHaveBeenCalledTimes(1); expect(WorkflowJobTemplatesAPI.associateLabel).toHaveBeenCalledTimes(1);

View File

@@ -139,18 +139,6 @@ function WorkflowJobTemplateDetail({ template }) {
value={scmBranch} value={scmBranch}
/> />
)} )}
{summary_fields?.execution_environment && (
<Detail
label={t`Execution Environment`}
value={
<Link
to={`/execution_environments/${summary_fields.execution_environment.id}/details`}
>
{summary_fields.execution_environment.name}
</Link>
}
/>
)}
<Detail label={t`Job Type`} value={toTitleCase(type)} /> <Detail label={t`Job Type`} value={toTitleCase(type)} />
{summary_fields.inventory && ( {summary_fields.inventory && (
<Detail <Detail

View File

@@ -25,12 +25,6 @@ describe('<WorkflowJobTemplateDetail/>', () => {
created_by: { id: 1, username: 'Athena' }, created_by: { id: 1, username: 'Athena' },
modified_by: { id: 1, username: 'Apollo' }, modified_by: { id: 1, username: 'Apollo' },
organization: { id: 1, name: 'Org' }, organization: { id: 1, name: 'Org' },
execution_environment: {
id: 4,
name: 'Demo EE',
description: '',
image: 'quay.io/ansible/awx-ee',
},
inventory: { kind: 'Foo', id: 1, name: 'Bar' }, inventory: { kind: 'Foo', id: 1, name: 'Bar' },
labels: { labels: {
results: [ results: [
@@ -49,7 +43,6 @@ describe('<WorkflowJobTemplateDetail/>', () => {
}, },
webhook_service: 'Github', webhook_service: 'Github',
webhook_key: 'Foo webhook key', webhook_key: 'Foo webhook key',
execution_environment: 4,
scm_branch: 'main', scm_branch: 'main',
limit: 'servers', limit: 'servers',
}; };
@@ -169,10 +162,6 @@ describe('<WorkflowJobTemplateDetail/>', () => {
}; };
renderedValues.map(value => assertValue(value)); renderedValues.map(value => assertValue(value));
expect(
wrapper.find(`Detail[label="Execution Environment"] dd`).text()
).toBe('Demo EE');
}); });
test('should have proper number of delete detail requests', async () => { test('should have proper number of delete detail requests', async () => {

View File

@@ -26,13 +26,11 @@ function WorkflowJobTemplateEdit({ template }) {
organization, organization,
webhook_credential, webhook_credential,
webhook_key, webhook_key,
execution_environment,
...templatePayload ...templatePayload
} = values; } = values;
templatePayload.inventory = inventory?.id || null; templatePayload.inventory = inventory?.id || null;
templatePayload.organization = organization?.id || null; templatePayload.organization = organization?.id || null;
templatePayload.webhook_credential = webhook_credential?.id || null; templatePayload.webhook_credential = webhook_credential?.id || null;
templatePayload.execution_environment = execution_environment?.id || null;
const formOrgId = const formOrgId =
organization?.id || inventory?.summary_fields?.organization.id || null; organization?.id || inventory?.summary_fields?.organization.id || null;

View File

@@ -6,7 +6,6 @@ import {
WorkflowJobTemplatesAPI, WorkflowJobTemplatesAPI,
OrganizationsAPI, OrganizationsAPI,
LabelsAPI, LabelsAPI,
ExecutionEnvironmentsAPI,
UsersAPI, UsersAPI,
InventoriesAPI, InventoriesAPI,
} from '../../../api'; } from '../../../api';
@@ -21,7 +20,6 @@ jest.mock('../../../util/useDebounce');
jest.mock('../../../api/models/WorkflowJobTemplates'); jest.mock('../../../api/models/WorkflowJobTemplates');
jest.mock('../../../api/models/Organizations'); jest.mock('../../../api/models/Organizations');
jest.mock('../../../api/models/Labels'); jest.mock('../../../api/models/Labels');
jest.mock('../../../api/models/ExecutionEnvironments');
jest.mock('../../../api/models/Users'); jest.mock('../../../api/models/Users');
jest.mock('../../../api/models/Inventories'); jest.mock('../../../api/models/Inventories');
@@ -30,12 +28,6 @@ const mockTemplate = {
name: 'Foo', name: 'Foo',
description: 'Foo description', description: 'Foo description',
summary_fields: { summary_fields: {
execution_environment: {
id: 1,
name: 'Default EE',
description: '',
image: 'quay.io/ansible/awx-ee',
},
inventory: { id: 1, name: 'Inventory 1' }, inventory: { id: 1, name: 'Inventory 1' },
organization: { id: 1, name: 'Organization 1' }, organization: { id: 1, name: 'Organization 1' },
labels: { labels: {
@@ -48,18 +40,8 @@ const mockTemplate = {
scm_branch: 'devel', scm_branch: 'devel',
limit: '5000', limit: '5000',
variables: '---', variables: '---',
execution_environment: 1,
}; };
const mockExecutionEnvironment = [
{
id: 1,
name: 'Default EE',
description: '',
image: 'quay.io/ansible/awx-ee',
},
];
describe('<WorkflowJobTemplateEdit/>', () => { describe('<WorkflowJobTemplateEdit/>', () => {
let wrapper; let wrapper;
let history; let history;
@@ -92,16 +74,6 @@ describe('<WorkflowJobTemplateEdit/>', () => {
data: { actions: { GET: {}, POST: {} } }, data: { actions: { GET: {}, POST: {} } },
}); });
ExecutionEnvironmentsAPI.read.mockResolvedValue({
data: {
results: mockExecutionEnvironment,
count: 1,
},
});
ExecutionEnvironmentsAPI.readOptions.mockResolvedValue({
data: { actions: { GET: {}, POST: {} } },
});
UsersAPI.readAdminOfOrganizations.mockResolvedValue({ UsersAPI.readAdminOfOrganizations.mockResolvedValue({
data: { count: 1, results: [{ id: 1, name: 'Default' }] }, data: { count: 1, results: [{ id: 1, name: 'Default' }] },
}); });
@@ -150,9 +122,6 @@ describe('<WorkflowJobTemplateEdit/>', () => {
.find('SelectToggle') .find('SelectToggle')
.simulate('click'); .simulate('click');
wrapper.update(); wrapper.update();
wrapper.find('TextInput#execution-environments-input').invoke('onChange')(
''
);
wrapper.find('input#wfjt-description').simulate('change', { wrapper.find('input#wfjt-description').simulate('change', {
target: { value: 'main', name: 'scm_branch' }, target: { value: 'main', name: 'scm_branch' },
}); });
@@ -208,7 +177,6 @@ describe('<WorkflowJobTemplateEdit/>', () => {
ask_limit_on_launch: false, ask_limit_on_launch: false,
ask_scm_branch_on_launch: false, ask_scm_branch_on_launch: false,
ask_variables_on_launch: false, ask_variables_on_launch: false,
execution_environment: null,
}); });
wrapper.update(); wrapper.update();
await expect(WorkflowJobTemplatesAPI.disassociateLabel).toBeCalledWith(6, { await expect(WorkflowJobTemplatesAPI.disassociateLabel).toBeCalledWith(6, {
@@ -255,12 +223,6 @@ describe('<WorkflowJobTemplateEdit/>', () => {
name: 'Foo', name: 'Foo',
description: 'Foo description', description: 'Foo description',
summary_fields: { summary_fields: {
execution_environment: {
id: 1,
name: 'Default EE',
description: '',
image: 'quay.io/ansible/awx-ee',
},
inventory: { id: 1, name: 'Inventory 1' }, inventory: { id: 1, name: 'Inventory 1' },
labels: { labels: {
results: [ results: [
@@ -272,7 +234,6 @@ describe('<WorkflowJobTemplateEdit/>', () => {
scm_branch: 'devel', scm_branch: 'devel',
limit: '5000', limit: '5000',
variables: '---', variables: '---',
execution_environment: 1,
}; };
let newWrapper; let newWrapper;
@@ -319,7 +280,6 @@ describe('<WorkflowJobTemplateEdit/>', () => {
ask_scm_branch_on_launch: false, ask_scm_branch_on_launch: false,
ask_variables_on_launch: false, ask_variables_on_launch: false,
description: 'bar', description: 'bar',
execution_environment: 1,
extra_vars: '---', extra_vars: '---',
inventory: 1, inventory: 1,
limit: '5000', limit: '5000',

View File

@@ -19,10 +19,7 @@ import {
SubFormLayout, SubFormLayout,
} from '../../../components/FormLayout'; } from '../../../components/FormLayout';
import OrganizationLookup from '../../../components/Lookup/OrganizationLookup'; import OrganizationLookup from '../../../components/Lookup/OrganizationLookup';
import { import { InventoryLookup } from '../../../components/Lookup';
InventoryLookup,
ExecutionEnvironmentLookup,
} from '../../../components/Lookup';
import { VariablesField } from '../../../components/CodeEditor'; import { VariablesField } from '../../../components/CodeEditor';
import FormActionGroup from '../../../components/FormActionGroup'; import FormActionGroup from '../../../components/FormActionGroup';
import ContentError from '../../../components/ContentError'; import ContentError from '../../../components/ContentError';
@@ -65,12 +62,6 @@ function WorkflowJobTemplateForm({
'webhook_credential' 'webhook_credential'
); );
const [
executionEnvironmentField,
executionEnvironmentMeta,
executionEnvironmentHelpers,
] = useField('execution_environment');
useEffect(() => { useEffect(() => {
if (enableWebhooks) { if (enableWebhooks) {
webhookServiceHelpers.setValue(webhookServiceMeta.initialValue); webhookServiceHelpers.setValue(webhookServiceMeta.initialValue);
@@ -102,14 +93,6 @@ function WorkflowJobTemplateForm({
[setFieldValue, setFieldTouched] [setFieldValue, setFieldTouched]
); );
const handleExecutionEnvironmentUpdate = useCallback(
value => {
setFieldValue('execution_environment', value);
setFieldTouched('execution_environment', true, false);
},
[setFieldValue, setFieldTouched]
);
if (hasContentError) { if (hasContentError) {
return <ContentError error={hasContentError} />; return <ContentError error={hasContentError} />;
} }
@@ -206,18 +189,6 @@ function WorkflowJobTemplateForm({
aria-label={t`source control branch`} aria-label={t`source control branch`}
/> />
</FieldWithPrompt> </FieldWithPrompt>
<ExecutionEnvironmentLookup
helperTextInvalid={executionEnvironmentMeta.error}
isValid={
!executionEnvironmentMeta.touched || !executionEnvironmentMeta.error
}
onBlur={() => executionEnvironmentHelpers.setTouched()}
value={executionEnvironmentField.value}
onChange={handleExecutionEnvironmentUpdate}
tooltip={t`Select the default execution environment for this organization to run on.`}
globallyAvailable
organizationId={organizationField.value?.id}
/>
</FormColumnLayout> </FormColumnLayout>
<FormFullWidthLayout> <FormFullWidthLayout>
<FormGroup <FormGroup
@@ -332,8 +303,6 @@ const FormikApp = withFormik({
? `${urlOrigin}${template.related.webhook_receiver}` ? `${urlOrigin}${template.related.webhook_receiver}`
: '', : '',
webhook_key: template.webhook_key || '', webhook_key: template.webhook_key || '',
execution_environment:
template.summary_fields?.execution_environment || null,
}; };
}, },
handleSubmit: async (values, { props, setErrors }) => { handleSubmit: async (values, { props, setErrors }) => {