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

153 lines
4.3 KiB
JavaScript
Raw Normal View History

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';
2020-09-07 01:33:10 +00:00
import FormLabel from 'Components/Form/FormLabel';
import { inputTypes, sizes } from 'Helpers/Props';
import titleCase from 'Utilities/String/titleCase';
2021-10-03 15:01:09 +00:00
import translate from 'Utilities/String/translate';
function UpdateSettings(props) {
const {
advancedSettings,
settings,
isWindows,
isDocker,
packageUpdateMechanism,
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' });
if (isDocker) {
return (
2021-10-03 15:01:09 +00:00
<FieldSet legend={translate('Updates')}>
<div>
{translate('UpdatingIsDisabledInsideADockerContainerUpdateTheContainerImageInstead')}
</div>
</FieldSet>
);
}
return (
2021-10-03 15:01:09 +00:00
<FieldSet legend={translate('Updates')}>
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
>
2021-10-03 15:01:09 +00:00
<FormLabel>
{translate('Branch')}
</FormLabel>
<FormInputGroup
type={inputTypes.TEXT}
name="branch"
2021-10-03 15:01:09 +00:00
helpText={usingExternalUpdateMechanism ? translate('UsingExternalUpdateMechanismBranchUsedByExternalUpdateMechanism') : translate('UsingExternalUpdateMechanismBranchToUseToUpdateLidarr')}
2021-08-04 22:47:40 +00:00
helpLink="https://wiki.servarr.com/lidarr/faq#how-do-i-update-lidarr"
{...branch}
onChange={onInputChange}
readOnly={usingExternalUpdateMechanism}
/>
</FormGroup>
{
!isWindows &&
2020-06-27 21:51:59 +00:00
<div>
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
2020-06-27 21:51:59 +00:00
size={sizes.MEDIUM}
>
2021-10-03 15:01:09 +00:00
<FormLabel>
{translate('Automatic')}
</FormLabel>
<FormInputGroup
2020-06-27 21:51:59 +00:00
type={inputTypes.CHECK}
name="updateAutomatically"
2021-10-03 15:01:09 +00:00
helpText={translate('UpdateAutomaticallyHelpText')}
onChange={onInputChange}
2020-06-27 21:51:59 +00:00
{...updateAutomatically}
/>
</FormGroup>
2020-06-27 21:51:59 +00:00
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
>
2021-10-03 15:01:09 +00:00
<FormLabel>
{translate('Mechanism')}
</FormLabel>
2020-06-27 21:51:59 +00:00
<FormInputGroup
type={inputTypes.SELECT}
name="updateMechanism"
values={updateOptions}
2021-10-03 15:01:09 +00:00
helpText={translate('UpdateMechanismHelpText')}
2021-08-04 22:47:40 +00:00
helpLink="https://wiki.servarr.com/lidarr/faq#how-do-i-update-lidarr"
2020-06-27 21:51:59 +00:00
onChange={onInputChange}
{...updateMechanism}
/>
</FormGroup>
{
updateMechanism.value === 'script' &&
<FormGroup
advancedSettings={advancedSettings}
isAdvanced={true}
>
2021-10-03 15:01:09 +00:00
<FormLabel>
{translate('ScriptPath')}
</FormLabel>
2020-06-27 21:51:59 +00:00
<FormInputGroup
type={inputTypes.TEXT}
name="updateScriptPath"
2021-10-03 15:01:09 +00:00
helpText={translate('UpdateScriptPathHelpText')}
2020-06-27 21:51:59 +00:00
onChange={onInputChange}
{...updateScriptPath}
/>
</FormGroup>
}
</div>
}
</FieldSet>
);
}
UpdateSettings.propTypes = {
advancedSettings: PropTypes.bool.isRequired,
settings: PropTypes.object.isRequired,
isWindows: PropTypes.bool.isRequired,
isDocker: PropTypes.bool.isRequired,
packageUpdateMechanism: PropTypes.string.isRequired,
onInputChange: PropTypes.func.isRequired
};
export default UpdateSettings;