Radarr/frontend/src/Settings/General/UpdateSettings.js

133 lines
3.8 KiB
JavaScript
Raw Normal View History

2018-11-23 07:04:42 +00:00
import PropTypes from 'prop-types';
import React from 'react';
import FieldSet from 'Components/FieldSet';
import FormGroup from 'Components/Form/FormGroup';
import FormInputGroup from 'Components/Form/FormInputGroup';
import FormLabel from 'Components/Form/FormLabel';
import { inputTypes, sizes } from 'Helpers/Props';
import titleCase from 'Utilities/String/titleCase';
import translate from 'Utilities/String/translate';
2018-11-23 07:04:42 +00:00
function UpdateSettings(props) {
const {
advancedSettings,
settings,
isWindows,
packageUpdateMechanism,
2018-11-23 07:04:42 +00:00
onInputChange
} = props;
const {
branch,
updateAutomatically,
updateMechanism,
updateScriptPath
} = settings;
if (!advancedSettings) {
return null;
}
const usingExternalUpdateMechanism = packageUpdateMechanism !== 'builtIn';
const updateOptions = [];
if (usingExternalUpdateMechanism) {
updateOptions.push({
key: packageUpdateMechanism,
value: titleCase(packageUpdateMechanism)
});
} else {
updateOptions.push({ key: 'builtIn', value: 'Built-In' });
}
updateOptions.push({ key: 'script', value: 'Script' });
2018-11-23 07:04:42 +00:00
return (
<FieldSet legend={translate('Updates')}>
2018-11-23 07:04:42 +00:00
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
>
2020-08-29 03:56:13 +00:00
<FormLabel>{translate('Branch')}</FormLabel>
2018-11-23 07:04:42 +00:00
<FormInputGroup
type={inputTypes.TEXT}
name="branch"
2020-09-01 03:41:20 +00:00
helpText={usingExternalUpdateMechanism ? translate('BranchUpdateMechanism') : translate('BranchUpdate')}
helpLink="https://wiki.servarr.com/Radarr_Settings#Updates"
2018-11-23 07:04:42 +00:00
{...branch}
onChange={onInputChange}
readOnly={usingExternalUpdateMechanism}
2018-11-23 07:04:42 +00:00
/>
</FormGroup>
{
!isWindows &&
<div>
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
size={sizes.MEDIUM}
>
2020-08-29 03:56:13 +00:00
<FormLabel>{translate('Automatic')}</FormLabel>
2018-11-23 07:04:42 +00:00
<FormInputGroup
type={inputTypes.CHECK}
name="updateAutomatically"
2020-08-29 03:56:13 +00:00
helpText={translate('UpdateAutomaticallyHelpText')}
onChange={onInputChange}
{...updateAutomatically}
/>
</FormGroup>
2018-11-23 07:04:42 +00:00
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
>
2020-08-29 03:56:13 +00:00
<FormLabel>{translate('Mechanism')}</FormLabel>
2018-11-23 07:04:42 +00:00
<FormInputGroup
type={inputTypes.SELECT}
name="updateMechanism"
values={updateOptions}
2020-08-29 03:56:13 +00:00
helpText={translate('UpdateMechanismHelpText')}
helpLink="https://wiki.servarr.com/Radarr_Settings#Updates"
2018-11-23 07:04:42 +00:00
onChange={onInputChange}
{...updateMechanism}
2018-11-23 07:04:42 +00:00
/>
</FormGroup>
{
updateMechanism.value === 'script' &&
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
>
2020-08-29 03:56:13 +00:00
<FormLabel>{translate('ScriptPath')}</FormLabel>
<FormInputGroup
type={inputTypes.TEXT}
name="updateScriptPath"
2020-08-29 03:56:13 +00:00
helpText={translate('UpdateScriptPathHelpText')}
onChange={onInputChange}
{...updateScriptPath}
/>
</FormGroup>
}
</div>
2018-11-23 07:04:42 +00:00
}
</FieldSet>
);
}
UpdateSettings.propTypes = {
advancedSettings: PropTypes.bool.isRequired,
settings: PropTypes.object.isRequired,
isWindows: PropTypes.bool.isRequired,
packageUpdateMechanism: PropTypes.string.isRequired,
2018-11-23 07:04:42 +00:00
onInputChange: PropTypes.func.isRequired
};
export default UpdateSettings;