diff --git a/app/javascript/react/screens/App/Settings/screens/GeneralSettings/GeneralSettings.js b/app/javascript/react/screens/App/Settings/screens/GeneralSettings/GeneralSettings.js index f96a7c47ca..866869544a 100644 --- a/app/javascript/react/screens/App/Settings/screens/GeneralSettings/GeneralSettings.js +++ b/app/javascript/react/screens/App/Settings/screens/GeneralSettings/GeneralSettings.js @@ -5,6 +5,8 @@ import { Form, Button, Icon, OverlayTrigger, Popover, Spinner } from 'patternfly import NumberInput from '../../../common/forms/NumberInput'; import TextInputWithCheckbox from '../../../common/forms/TextInputWithCheckbox'; +const FORM_NAME = 'settings'; + export class GeneralSettings extends React.Component { componentDidMount() { const { fetchServersAction, fetchServersUrl, fetchSettingsAction, fetchSettingsUrl } = this.props; @@ -17,6 +19,20 @@ export class GeneralSettings extends React.Component { patchSettingsAction(servers, settingsForm.values); }; + enforceConstraintsOnChange = (event, newValue, prevValue, fieldChanging) => { + const { + settingsForm: { + values: { max_concurrent_tasks_per_host, max_concurrent_tasks_per_ems } + }, + formChangeAction + } = this.props; + if (fieldChanging === 'max_concurrent_tasks_per_host' && newValue > max_concurrent_tasks_per_ems) { + formChangeAction(FORM_NAME, 'max_concurrent_tasks_per_ems', newValue); + } else if (fieldChanging === 'max_concurrent_tasks_per_ems' && newValue < max_concurrent_tasks_per_host) { + formChangeAction(FORM_NAME, 'max_concurrent_tasks_per_host', newValue); + } + }; + render() { const { isFetchingServers, isFetchingSettings, isSavingSettings, savedSettings, settingsForm } = this.props; @@ -71,6 +87,7 @@ export class GeneralSettings extends React.Component { component={NumberInput} normalize={NumberInput.normalizeStringToInt} min={1} + onChange={this.enforceConstraintsOnChange} /> @@ -85,10 +102,11 @@ export class GeneralSettings extends React.Component { component={NumberInput} normalize={NumberInput.normalizeStringToInt} min={1} + onChange={this.enforceConstraintsOnChange} /> -{/* FIXME: uncomment once backend is ready + {/* FIXME: uncomment once backend is ready