mirror of
https://github.com/ansible/awx.git
synced 2026-03-21 10:57:36 -02:30
Remove eula checkbox from UI
This commit is contained in:
committed by
Christian M. Adams
parent
909cdc2425
commit
ff559a81db
@@ -1,31 +1,17 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { Trans, t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useField } from 'formik';
|
|
||||||
import { Flex, FormGroup, TextArea } from '@patternfly/react-core';
|
import { Flex, FormGroup, TextArea } from '@patternfly/react-core';
|
||||||
import { required } from '../../../../util/validators';
|
|
||||||
import { useConfig } from '../../../../contexts/Config';
|
import { useConfig } from '../../../../contexts/Config';
|
||||||
import { CheckboxField } from '../../../../components/FormField';
|
|
||||||
|
|
||||||
function EulaStep() {
|
function EulaStep() {
|
||||||
const { eula, me } = useConfig();
|
const { eula } = useConfig();
|
||||||
const [, meta] = useField('eula');
|
|
||||||
const isValid = !(meta.touched && meta.error);
|
|
||||||
return (
|
return (
|
||||||
<Flex
|
<Flex
|
||||||
spaceItems={{ default: 'spaceItemsMd' }}
|
spaceItems={{ default: 'spaceItemsMd' }}
|
||||||
direction={{ default: 'column' }}
|
direction={{ default: 'column' }}
|
||||||
>
|
>
|
||||||
<b>
|
<FormGroup fieldId="eula" label={t`End User License Agreement`}>
|
||||||
<Trans>Agree to the end user license agreement and click submit.</Trans>
|
|
||||||
</b>
|
|
||||||
<FormGroup
|
|
||||||
fieldId="eula"
|
|
||||||
label={t`End User License Agreement`}
|
|
||||||
validated={isValid ? 'default' : 'error'}
|
|
||||||
helperTextInvalid={meta.error}
|
|
||||||
isRequired
|
|
||||||
>
|
|
||||||
<TextArea
|
<TextArea
|
||||||
id="eula-container"
|
id="eula-container"
|
||||||
style={{ minHeight: '200px' }}
|
style={{ minHeight: '200px' }}
|
||||||
@@ -34,16 +20,6 @@ function EulaStep() {
|
|||||||
>
|
>
|
||||||
{eula}
|
{eula}
|
||||||
</TextArea>
|
</TextArea>
|
||||||
<CheckboxField
|
|
||||||
name="eula"
|
|
||||||
aria-label={t`Agree to end user license agreement`}
|
|
||||||
label={t`I agree to the End User License Agreement`}
|
|
||||||
id="eula"
|
|
||||||
isDisabled={!me.is_superuser}
|
|
||||||
validate={required(
|
|
||||||
t`Please agree to End User License Agreement before proceeding.`
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React, { useCallback, useEffect } from 'react';
|
import React, { useCallback, useEffect } from 'react';
|
||||||
import { useHistory, Link, useRouteMatch } from 'react-router-dom';
|
import { useHistory, Link, useRouteMatch } from 'react-router-dom';
|
||||||
|
|
||||||
import { t, Trans } from '@lingui/macro';
|
import { t, Trans } from '@lingui/macro';
|
||||||
import { Formik, useFormikContext } from 'formik';
|
import { Formik, useFormikContext } from 'formik';
|
||||||
import {
|
import {
|
||||||
@@ -41,7 +40,6 @@ const CustomFooter = ({ isSubmitLoading }) => {
|
|||||||
isDisabled={
|
isDisabled={
|
||||||
(!values.manifest_file && !values.subscription) ||
|
(!values.manifest_file && !values.subscription) ||
|
||||||
!me?.is_superuser ||
|
!me?.is_superuser ||
|
||||||
!values.eula ||
|
|
||||||
Object.keys(errors).length !== 0
|
Object.keys(errors).length !== 0
|
||||||
}
|
}
|
||||||
type="button"
|
type="button"
|
||||||
@@ -133,13 +131,9 @@ function SubscriptionEdit() {
|
|||||||
if (form.manifest_file) {
|
if (form.manifest_file) {
|
||||||
await ConfigAPI.create({
|
await ConfigAPI.create({
|
||||||
manifest: form.manifest_file,
|
manifest: form.manifest_file,
|
||||||
eula_accepted: form.eula,
|
|
||||||
});
|
});
|
||||||
} else if (form.subscription) {
|
} else if (form.subscription) {
|
||||||
await ConfigAPI.attach({ pool_id: form.subscription.pool_id });
|
await ConfigAPI.attach({ pool_id: form.subscription.pool_id });
|
||||||
await ConfigAPI.create({
|
|
||||||
eula_accepted: form.eula,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasValidKey) {
|
if (!hasValidKey) {
|
||||||
@@ -223,7 +217,6 @@ function SubscriptionEdit() {
|
|||||||
<>
|
<>
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{
|
initialValues={{
|
||||||
eula: false,
|
|
||||||
insights: true,
|
insights: true,
|
||||||
manifest_file: null,
|
manifest_file: null,
|
||||||
manifest_filename: '',
|
manifest_filename: '',
|
||||||
|
|||||||
@@ -186,20 +186,7 @@ describe('<SubscriptionEdit />', () => {
|
|||||||
});
|
});
|
||||||
wrapper.update();
|
wrapper.update();
|
||||||
expect(wrapper.find('EulaStep').length).toBe(1);
|
expect(wrapper.find('EulaStep').length).toBe(1);
|
||||||
expect(wrapper.find('CheckboxField').length).toBe(1);
|
|
||||||
expect(wrapper.find('button#subscription-wizard-submit').length).toBe(1);
|
expect(wrapper.find('button#subscription-wizard-submit').length).toBe(1);
|
||||||
});
|
|
||||||
|
|
||||||
test('checking EULA agreement should enable Submit button', async () => {
|
|
||||||
expect(
|
|
||||||
wrapper.find('button#subscription-wizard-submit').prop('disabled')
|
|
||||||
).toBe(true);
|
|
||||||
await act(async () => {
|
|
||||||
wrapper.find('Checkbox[name="eula"] input').simulate('change', {
|
|
||||||
target: { value: true, name: 'eula' },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
wrapper.update();
|
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('button#subscription-wizard-submit').prop('disabled')
|
wrapper.find('button#subscription-wizard-submit').prop('disabled')
|
||||||
).toBe(false);
|
).toBe(false);
|
||||||
@@ -369,18 +356,6 @@ describe('<SubscriptionEdit />', () => {
|
|||||||
expect(wrapper.find('SubscriptionStep').length).toBe(0);
|
expect(wrapper.find('SubscriptionStep').length).toBe(0);
|
||||||
expect(wrapper.find('AnalyticsStep').length).toBe(0);
|
expect(wrapper.find('AnalyticsStep').length).toBe(0);
|
||||||
expect(wrapper.find('EulaStep').length).toBe(1);
|
expect(wrapper.find('EulaStep').length).toBe(1);
|
||||||
});
|
|
||||||
|
|
||||||
test('submit should be disabled until EULA agreement checked', async () => {
|
|
||||||
expect(
|
|
||||||
wrapper.find('button#subscription-wizard-submit').prop('disabled')
|
|
||||||
).toBe(true);
|
|
||||||
await act(async () => {
|
|
||||||
wrapper.find('Checkbox[name="eula"] input').simulate('change', {
|
|
||||||
target: { value: true, name: 'eula' },
|
|
||||||
});
|
|
||||||
});
|
|
||||||
wrapper.update();
|
|
||||||
expect(
|
expect(
|
||||||
wrapper.find('button#subscription-wizard-submit').prop('disabled')
|
wrapper.find('button#subscription-wizard-submit').prop('disabled')
|
||||||
).toBe(false);
|
).toBe(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user