From 7b9bcd048154c3b45f4c6d5b136f70256bfd1054 Mon Sep 17 00:00:00 2001 From: nixocio Date: Wed, 16 Jun 2021 11:52:07 -0400 Subject: [PATCH] Remove EE from WorkflowJobTemplate screens Remove EE from WorkflowJobTemplate screens Related ansible/awx#10443 Related ansible/awx#10399 --- .../TemplateList/TemplateListItem.jsx | 10 +++-- .../WorkflowJobTemplateAdd.jsx | 5 +-- .../WorkflowJobTemplateAdd.test.jsx | 11 ----- .../WorkflowJobTemplateDetail.jsx | 12 ------ .../WorkflowJobTemplateDetail.test.jsx | 11 ----- .../WorkflowJobTemplateEdit.jsx | 2 - .../WorkflowJobTemplateEdit.test.jsx | 40 ------------------- .../shared/WorkflowJobTemplateForm.jsx | 33 +-------------- 8 files changed, 8 insertions(+), 116 deletions(-) diff --git a/awx/ui_next/src/components/TemplateList/TemplateListItem.jsx b/awx/ui_next/src/components/TemplateList/TemplateListItem.jsx index 9ae919a624..1479b1cfa3 100644 --- a/awx/ui_next/src/components/TemplateList/TemplateListItem.jsx +++ b/awx/ui_next/src/components/TemplateList/TemplateListItem.jsx @@ -274,10 +274,12 @@ function TemplateListItem({ dataCy={`template-${template.id}-project`} /> )} - + {template.type === 'job_template' && ( + + )} ', () => { }, }); - ExecutionEnvironmentsAPI.read.mockResolvedValueOnce({ - data: { results: [{ id: 1, name: 'Foo', image: 'localhost.com' }] }, - }); - UsersAPI.readAdminOfOrganizations.mockResolvedValue({ data: { count: 0, results: [] }, }); @@ -94,11 +89,6 @@ describe('', () => { .find('LabelSelect') .find('SelectToggle') .simulate('click'); - - wrapper.find('ExecutionEnvironmentLookup').invoke('onChange')({ - id: 1, - name: 'Foo', - }); }); await act(async () => { @@ -132,7 +122,6 @@ describe('', () => { webhook_credential: undefined, webhook_service: '', webhook_url: '', - execution_environment: 1, }); expect(WorkflowJobTemplatesAPI.associateLabel).toHaveBeenCalledTimes(1); diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.jsx index 89e17ea577..b0b275fcbc 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateDetail/WorkflowJobTemplateDetail.jsx @@ -139,18 +139,6 @@ function WorkflowJobTemplateDetail({ template }) { value={scmBranch} /> )} - {summary_fields?.execution_environment && ( - - {summary_fields.execution_environment.name} - - } - /> - )} {summary_fields.inventory && ( ', () => { created_by: { id: 1, username: 'Athena' }, modified_by: { id: 1, username: 'Apollo' }, 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' }, labels: { results: [ @@ -49,7 +43,6 @@ describe('', () => { }, webhook_service: 'Github', webhook_key: 'Foo webhook key', - execution_environment: 4, scm_branch: 'main', limit: 'servers', }; @@ -169,10 +162,6 @@ describe('', () => { }; 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 () => { diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.jsx index 96a0be82df..3e7d65349e 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.jsx @@ -26,13 +26,11 @@ function WorkflowJobTemplateEdit({ template }) { organization, webhook_credential, webhook_key, - execution_environment, ...templatePayload } = values; templatePayload.inventory = inventory?.id || null; templatePayload.organization = organization?.id || null; templatePayload.webhook_credential = webhook_credential?.id || null; - templatePayload.execution_environment = execution_environment?.id || null; const formOrgId = organization?.id || inventory?.summary_fields?.organization.id || null; diff --git a/awx/ui_next/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.test.jsx b/awx/ui_next/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.test.jsx index 4f099b0f76..dc75090324 100644 --- a/awx/ui_next/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.test.jsx +++ b/awx/ui_next/src/screens/Template/WorkflowJobTemplateEdit/WorkflowJobTemplateEdit.test.jsx @@ -6,7 +6,6 @@ import { WorkflowJobTemplatesAPI, OrganizationsAPI, LabelsAPI, - ExecutionEnvironmentsAPI, UsersAPI, InventoriesAPI, } from '../../../api'; @@ -21,7 +20,6 @@ jest.mock('../../../util/useDebounce'); jest.mock('../../../api/models/WorkflowJobTemplates'); jest.mock('../../../api/models/Organizations'); jest.mock('../../../api/models/Labels'); -jest.mock('../../../api/models/ExecutionEnvironments'); jest.mock('../../../api/models/Users'); jest.mock('../../../api/models/Inventories'); @@ -30,12 +28,6 @@ const mockTemplate = { name: 'Foo', description: 'Foo description', summary_fields: { - execution_environment: { - id: 1, - name: 'Default EE', - description: '', - image: 'quay.io/ansible/awx-ee', - }, inventory: { id: 1, name: 'Inventory 1' }, organization: { id: 1, name: 'Organization 1' }, labels: { @@ -48,18 +40,8 @@ const mockTemplate = { scm_branch: 'devel', limit: '5000', variables: '---', - execution_environment: 1, }; -const mockExecutionEnvironment = [ - { - id: 1, - name: 'Default EE', - description: '', - image: 'quay.io/ansible/awx-ee', - }, -]; - describe('', () => { let wrapper; let history; @@ -92,16 +74,6 @@ describe('', () => { data: { actions: { GET: {}, POST: {} } }, }); - ExecutionEnvironmentsAPI.read.mockResolvedValue({ - data: { - results: mockExecutionEnvironment, - count: 1, - }, - }); - ExecutionEnvironmentsAPI.readOptions.mockResolvedValue({ - data: { actions: { GET: {}, POST: {} } }, - }); - UsersAPI.readAdminOfOrganizations.mockResolvedValue({ data: { count: 1, results: [{ id: 1, name: 'Default' }] }, }); @@ -150,9 +122,6 @@ describe('', () => { .find('SelectToggle') .simulate('click'); wrapper.update(); - wrapper.find('TextInput#execution-environments-input').invoke('onChange')( - '' - ); wrapper.find('input#wfjt-description').simulate('change', { target: { value: 'main', name: 'scm_branch' }, }); @@ -208,7 +177,6 @@ describe('', () => { ask_limit_on_launch: false, ask_scm_branch_on_launch: false, ask_variables_on_launch: false, - execution_environment: null, }); wrapper.update(); await expect(WorkflowJobTemplatesAPI.disassociateLabel).toBeCalledWith(6, { @@ -255,12 +223,6 @@ describe('', () => { name: 'Foo', description: 'Foo description', summary_fields: { - execution_environment: { - id: 1, - name: 'Default EE', - description: '', - image: 'quay.io/ansible/awx-ee', - }, inventory: { id: 1, name: 'Inventory 1' }, labels: { results: [ @@ -272,7 +234,6 @@ describe('', () => { scm_branch: 'devel', limit: '5000', variables: '---', - execution_environment: 1, }; let newWrapper; @@ -319,7 +280,6 @@ describe('', () => { ask_scm_branch_on_launch: false, ask_variables_on_launch: false, description: 'bar', - execution_environment: 1, extra_vars: '---', inventory: 1, limit: '5000', diff --git a/awx/ui_next/src/screens/Template/shared/WorkflowJobTemplateForm.jsx b/awx/ui_next/src/screens/Template/shared/WorkflowJobTemplateForm.jsx index 5a99909625..a89638eecd 100644 --- a/awx/ui_next/src/screens/Template/shared/WorkflowJobTemplateForm.jsx +++ b/awx/ui_next/src/screens/Template/shared/WorkflowJobTemplateForm.jsx @@ -19,10 +19,7 @@ import { SubFormLayout, } from '../../../components/FormLayout'; import OrganizationLookup from '../../../components/Lookup/OrganizationLookup'; -import { - InventoryLookup, - ExecutionEnvironmentLookup, -} from '../../../components/Lookup'; +import { InventoryLookup } from '../../../components/Lookup'; import { VariablesField } from '../../../components/CodeEditor'; import FormActionGroup from '../../../components/FormActionGroup'; import ContentError from '../../../components/ContentError'; @@ -65,12 +62,6 @@ function WorkflowJobTemplateForm({ 'webhook_credential' ); - const [ - executionEnvironmentField, - executionEnvironmentMeta, - executionEnvironmentHelpers, - ] = useField('execution_environment'); - useEffect(() => { if (enableWebhooks) { webhookServiceHelpers.setValue(webhookServiceMeta.initialValue); @@ -102,14 +93,6 @@ function WorkflowJobTemplateForm({ [setFieldValue, setFieldTouched] ); - const handleExecutionEnvironmentUpdate = useCallback( - value => { - setFieldValue('execution_environment', value); - setFieldTouched('execution_environment', true, false); - }, - [setFieldValue, setFieldTouched] - ); - if (hasContentError) { return ; } @@ -206,18 +189,6 @@ function WorkflowJobTemplateForm({ aria-label={t`source control branch`} /> - 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} - /> {