2018-01-14 22:11:37 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
2020-04-03 02:25:09 +00:00
|
|
|
import titleCase from 'Utilities/String/titleCase';
|
2018-01-14 22:11:37 +00:00
|
|
|
import { inputTypes, sizes } from 'Helpers/Props';
|
|
|
|
import FieldSet from 'Components/FieldSet';
|
|
|
|
import FormGroup from 'Components/Form/FormGroup';
|
|
|
|
import FormLabel from 'Components/Form/FormLabel';
|
|
|
|
import FormInputGroup from 'Components/Form/FormInputGroup';
|
|
|
|
|
|
|
|
function UpdateSettings(props) {
|
|
|
|
const {
|
|
|
|
advancedSettings,
|
|
|
|
settings,
|
2019-10-28 21:30:08 +00:00
|
|
|
isWindows,
|
2019-04-05 15:47:26 +00:00
|
|
|
isDocker,
|
2020-04-03 02:25:09 +00:00
|
|
|
packageUpdateMechanism,
|
2018-01-14 22:11:37 +00:00
|
|
|
onInputChange
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
branch,
|
|
|
|
updateAutomatically,
|
|
|
|
updateMechanism,
|
|
|
|
updateScriptPath
|
|
|
|
} = settings;
|
|
|
|
|
|
|
|
if (!advancedSettings) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-04-03 02:25:09 +00:00
|
|
|
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-01-14 22:11:37 +00:00
|
|
|
|
2019-04-05 15:47:26 +00:00
|
|
|
if (isDocker) {
|
|
|
|
return (
|
|
|
|
<FieldSet legend="Updates">
|
|
|
|
<div>Updating is disabled inside a docker container. Update the container image instead.</div>
|
|
|
|
</FieldSet>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-01-14 22:11:37 +00:00
|
|
|
return (
|
|
|
|
<FieldSet legend="Updates">
|
|
|
|
<FormGroup
|
|
|
|
advancedSettings={advancedSettings}
|
|
|
|
isAdvanced={true}
|
|
|
|
>
|
|
|
|
<FormLabel>Branch</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
2020-04-03 02:25:09 +00:00
|
|
|
type={inputTypes.TEXT}
|
2018-01-14 22:11:37 +00:00
|
|
|
name="branch"
|
2020-04-03 02:25:09 +00:00
|
|
|
helpText={usingExternalUpdateMechanism ? 'Branch used by external update mechanism' : 'Branch to use to update Lidarr'}
|
2018-01-14 22:11:37 +00:00
|
|
|
helpLink="https://github.com/Lidarr/Lidarr/wiki/Release-Branches"
|
|
|
|
{...branch}
|
2019-02-23 22:39:11 +00:00
|
|
|
onChange={onInputChange}
|
2020-04-03 02:25:09 +00:00
|
|
|
readOnly={usingExternalUpdateMechanism}
|
2018-01-14 22:11:37 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
{
|
2019-10-28 21:30:08 +00:00
|
|
|
!isWindows &&
|
2020-06-27 21:51:59 +00:00
|
|
|
<div>
|
2018-01-14 22:11:37 +00:00
|
|
|
<FormGroup
|
|
|
|
advancedSettings={advancedSettings}
|
|
|
|
isAdvanced={true}
|
2020-06-27 21:51:59 +00:00
|
|
|
size={sizes.MEDIUM}
|
2018-01-14 22:11:37 +00:00
|
|
|
>
|
2020-06-27 21:51:59 +00:00
|
|
|
<FormLabel>Automatic</FormLabel>
|
2018-01-14 22:11:37 +00:00
|
|
|
|
|
|
|
<FormInputGroup
|
2020-06-27 21:51:59 +00:00
|
|
|
type={inputTypes.CHECK}
|
|
|
|
name="updateAutomatically"
|
|
|
|
helpText="Automatically download and install updates. You will still be able to install from System: Updates"
|
2018-01-14 22:11:37 +00:00
|
|
|
onChange={onInputChange}
|
2020-06-27 21:51:59 +00:00
|
|
|
{...updateAutomatically}
|
2018-01-14 22:11:37 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
2020-06-27 21:51:59 +00:00
|
|
|
|
|
|
|
<FormGroup
|
|
|
|
advancedSettings={advancedSettings}
|
|
|
|
isAdvanced={true}
|
|
|
|
>
|
|
|
|
<FormLabel>Mechanism</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.SELECT}
|
|
|
|
name="updateMechanism"
|
|
|
|
values={updateOptions}
|
|
|
|
helpText="Use Lidarr's built-in updater or a script"
|
|
|
|
helpLink="https://github.com/Lidarr/Lidarr/wiki/Updating"
|
|
|
|
onChange={onInputChange}
|
|
|
|
{...updateMechanism}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
{
|
|
|
|
updateMechanism.value === 'script' &&
|
|
|
|
<FormGroup
|
|
|
|
advancedSettings={advancedSettings}
|
|
|
|
isAdvanced={true}
|
|
|
|
>
|
|
|
|
<FormLabel>Script Path</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.TEXT}
|
|
|
|
name="updateScriptPath"
|
|
|
|
helpText="Path to a custom script that takes an extracted update package and handle the remainder of the update process"
|
|
|
|
onChange={onInputChange}
|
|
|
|
{...updateScriptPath}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
}
|
|
|
|
</div>
|
2018-01-14 22:11:37 +00:00
|
|
|
}
|
|
|
|
</FieldSet>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
UpdateSettings.propTypes = {
|
|
|
|
advancedSettings: PropTypes.bool.isRequired,
|
|
|
|
settings: PropTypes.object.isRequired,
|
2019-10-28 21:30:08 +00:00
|
|
|
isWindows: PropTypes.bool.isRequired,
|
2019-04-05 15:47:26 +00:00
|
|
|
isDocker: PropTypes.bool.isRequired,
|
2020-04-03 02:25:09 +00:00
|
|
|
packageUpdateMechanism: PropTypes.string.isRequired,
|
2018-01-14 22:11:37 +00:00
|
|
|
onInputChange: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
export default UpdateSettings;
|