diff --git a/awx/ui_next/src/screens/Setting/ActivityStream/ActivityStreamEdit/ActivityStreamEdit.test.jsx b/awx/ui_next/src/screens/Setting/ActivityStream/ActivityStreamEdit/ActivityStreamEdit.test.jsx index 845c68886d..a21382774a 100644 --- a/awx/ui_next/src/screens/Setting/ActivityStream/ActivityStreamEdit/ActivityStreamEdit.test.jsx +++ b/awx/ui_next/src/screens/Setting/ActivityStream/ActivityStreamEdit/ActivityStreamEdit.test.jsx @@ -68,12 +68,24 @@ describe('', () => { test('should successfully send request to api on form submission', async () => { expect(SettingsAPI.updateAll).toHaveBeenCalledTimes(0); + expect( + wrapper.find('Switch#ACTIVITY_STREAM_ENABLED').prop('isChecked') + ).toEqual(false); + + await act(async () => { + wrapper.find('Switch#ACTIVITY_STREAM_ENABLED').invoke('onChange')(true); + }); + wrapper.update(); + expect( + wrapper.find('Switch#ACTIVITY_STREAM_ENABLED').prop('isChecked') + ).toEqual(true); + await act(async () => { wrapper.find('Form').invoke('onSubmit')(); }); expect(SettingsAPI.updateAll).toHaveBeenCalledTimes(1); expect(SettingsAPI.updateAll).toHaveBeenCalledWith({ - ACTIVITY_STREAM_ENABLED: false, + ACTIVITY_STREAM_ENABLED: true, ACTIVITY_STREAM_ENABLED_FOR_INVENTORY_SYNC: true, }); }); diff --git a/awx/ui_next/src/screens/Setting/AzureAD/AzureADEdit/AzureADEdit.jsx b/awx/ui_next/src/screens/Setting/AzureAD/AzureADEdit/AzureADEdit.jsx index 2bee3ae277..b6958388ff 100644 --- a/awx/ui_next/src/screens/Setting/AzureAD/AzureADEdit/AzureADEdit.jsx +++ b/awx/ui_next/src/screens/Setting/AzureAD/AzureADEdit/AzureADEdit.jsx @@ -14,6 +14,7 @@ import { InputField, ObjectField, } from '../../shared/SharedFields'; +import { formatJson } from '../../shared/settingUtils'; import useModal from '../../../../util/useModal'; import useRequest from '../../../../util/useRequest'; import { SettingsAPI } from '../../../../api'; @@ -57,10 +58,10 @@ function AzureADEdit() { const handleSubmit = async form => { await submitForm({ ...form, - SOCIAL_AUTH_AZUREAD_OAUTH2_TEAM_MAP: JSON.parse( + SOCIAL_AUTH_AZUREAD_OAUTH2_TEAM_MAP: formatJson( form.SOCIAL_AUTH_AZUREAD_OAUTH2_TEAM_MAP ), - SOCIAL_AUTH_AZUREAD_OAUTH2_ORGANIZATION_MAP: JSON.parse( + SOCIAL_AUTH_AZUREAD_OAUTH2_ORGANIZATION_MAP: formatJson( form.SOCIAL_AUTH_AZUREAD_OAUTH2_ORGANIZATION_MAP ), }); diff --git a/awx/ui_next/src/screens/Setting/Logging/LoggingEdit/LoggingEdit.jsx b/awx/ui_next/src/screens/Setting/Logging/LoggingEdit/LoggingEdit.jsx index d930d4ea27..c59ca0845e 100644 --- a/awx/ui_next/src/screens/Setting/Logging/LoggingEdit/LoggingEdit.jsx +++ b/awx/ui_next/src/screens/Setting/Logging/LoggingEdit/LoggingEdit.jsx @@ -22,6 +22,7 @@ import { } from '../../shared'; import useModal from '../../../../util/useModal'; import useRequest, { useDismissableError } from '../../../../util/useRequest'; +import { formatJson } from '../../shared/settingUtils'; import { SettingsAPI } from '../../../../api'; function LoggingEdit({ i18n }) { @@ -39,6 +40,9 @@ function LoggingEdit({ i18n }) { const { data } = await SettingsAPI.readCategory('logging'); const mergedData = {}; Object.keys(data).forEach(key => { + if (!options[key]) { + return; + } mergedData[key] = options[key]; mergedData[key].value = data[key]; }); @@ -65,7 +69,7 @@ function LoggingEdit({ i18n }) { const handleSubmit = async form => { await submitForm({ ...form, - LOG_AGGREGATOR_LOGGERS: JSON.parse(form.LOG_AGGREGATOR_LOGGERS), + LOG_AGGREGATOR_LOGGERS: formatJson(form.LOG_AGGREGATOR_LOGGERS), LOG_AGGREGATOR_HOST: form.LOG_AGGREGATOR_HOST || null, LOG_AGGREGATOR_TYPE: form.LOG_AGGREGATOR_TYPE || null, }); @@ -127,10 +131,7 @@ function LoggingEdit({ i18n }) { {isLoading && } {!isLoading && error && } {!isLoading && logging && ( - + {formik => { return (
diff --git a/awx/ui_next/src/screens/Setting/MiscSystem/MiscSystemEdit/MiscSystemEdit.jsx b/awx/ui_next/src/screens/Setting/MiscSystem/MiscSystemEdit/MiscSystemEdit.jsx index 94c64f91bb..4698c17b03 100644 --- a/awx/ui_next/src/screens/Setting/MiscSystem/MiscSystemEdit/MiscSystemEdit.jsx +++ b/awx/ui_next/src/screens/Setting/MiscSystem/MiscSystemEdit/MiscSystemEdit.jsx @@ -21,7 +21,7 @@ import { import useModal from '../../../../util/useModal'; import useRequest from '../../../../util/useRequest'; import { SettingsAPI } from '../../../../api'; -import { pluck } from '../../shared/settingUtils'; +import { pluck, formatJson } from '../../shared/settingUtils'; function MiscSystemEdit({ i18n }) { const history = useHistory(); @@ -95,6 +95,9 @@ function MiscSystemEdit({ i18n }) { const mergedData = {}; Object.keys(systemData).forEach(key => { + if (!systemOptions[key]) { + return; + } mergedData[key] = systemOptions[key]; mergedData[key].value = systemData[key]; }); @@ -127,8 +130,8 @@ function MiscSystemEdit({ i18n }) { } = form; await submitForm({ ...formData, - CUSTOM_VENV_PATHS: JSON.parse(formData.CUSTOM_VENV_PATHS), - REMOTE_HOST_HEADERS: JSON.parse(formData.REMOTE_HOST_HEADERS), + CUSTOM_VENV_PATHS: formatJson(formData.CUSTOM_VENV_PATHS), + REMOTE_HOST_HEADERS: formatJson(formData.REMOTE_HOST_HEADERS), OAUTH2_PROVIDER: { ACCESS_TOKEN_EXPIRE_SECONDS, REFRESH_TOKEN_EXPIRE_SECONDS, @@ -181,10 +184,7 @@ function MiscSystemEdit({ i18n }) { {isLoading && } {!isLoading && error && } {!isLoading && system && ( - + {formik => { return ( diff --git a/awx/ui_next/src/screens/Setting/shared/RevertButton.jsx b/awx/ui_next/src/screens/Setting/shared/RevertButton.jsx index c51de0e1c2..b2c4268f2d 100644 --- a/awx/ui_next/src/screens/Setting/shared/RevertButton.jsx +++ b/awx/ui_next/src/screens/Setting/shared/RevertButton.jsx @@ -45,6 +45,7 @@ function RevertButton({ i18n, id, defaultValue, isDisabled = false }) {