2018-02-06 23:08:36 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import { inputTypes, kinds } from 'Helpers/Props';
|
|
|
|
import Button from 'Components/Link/Button';
|
|
|
|
import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton';
|
|
|
|
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
|
|
|
import ModalContent from 'Components/Modal/ModalContent';
|
|
|
|
import ModalHeader from 'Components/Modal/ModalHeader';
|
|
|
|
import ModalBody from 'Components/Modal/ModalBody';
|
|
|
|
import ModalFooter from 'Components/Modal/ModalFooter';
|
|
|
|
import Form from 'Components/Form/Form';
|
|
|
|
import FormGroup from 'Components/Form/FormGroup';
|
|
|
|
import FormLabel from 'Components/Form/FormLabel';
|
|
|
|
import FormInputGroup from 'Components/Form/FormInputGroup';
|
|
|
|
import ProviderFieldFormGroup from 'Components/Form/ProviderFieldFormGroup';
|
|
|
|
import styles from './EditImportListModalContent.css';
|
|
|
|
|
|
|
|
function EditImportListModalContent(props) {
|
|
|
|
const {
|
|
|
|
advancedSettings,
|
|
|
|
isFetching,
|
|
|
|
error,
|
|
|
|
isSaving,
|
|
|
|
isTesting,
|
|
|
|
saveError,
|
|
|
|
item,
|
|
|
|
onInputChange,
|
|
|
|
onFieldChange,
|
|
|
|
onModalClose,
|
|
|
|
onSavePress,
|
|
|
|
onTestPress,
|
|
|
|
onDeleteImportListPress,
|
|
|
|
showLanguageProfile,
|
|
|
|
showMetadataProfile,
|
|
|
|
...otherProps
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
enableAutomaticAdd,
|
|
|
|
shouldMonitor,
|
|
|
|
rootFolderPath,
|
2018-04-08 02:28:16 +00:00
|
|
|
qualityProfileId,
|
2018-02-06 23:08:36 +00:00
|
|
|
languageProfileId,
|
|
|
|
metadataProfileId,
|
|
|
|
fields
|
|
|
|
} = item;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ModalContent onModalClose={onModalClose}>
|
|
|
|
<ModalHeader>
|
|
|
|
{id ? 'Edit List' : 'Add List'}
|
|
|
|
</ModalHeader>
|
|
|
|
|
|
|
|
<ModalBody>
|
|
|
|
{
|
|
|
|
isFetching &&
|
|
|
|
<LoadingIndicator />
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
!isFetching && !!error &&
|
|
|
|
<div>Unable to add a new list, please try again.</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
!isFetching && !error &&
|
|
|
|
<Form
|
|
|
|
{...otherProps}
|
|
|
|
>
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Name</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.TEXT}
|
|
|
|
name="name"
|
|
|
|
{...name}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Enable Automatic Add</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.CHECK}
|
|
|
|
name="enableAutomaticAdd"
|
|
|
|
helpText={'Add artist/albums to Lidarr when syncs are performed via the UI or by Lidarr'}
|
|
|
|
{...enableAutomaticAdd}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Monitor</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.CHECK}
|
|
|
|
name="shouldMonitor"
|
|
|
|
helpText={'Monitor artists and albums added from this list'}
|
|
|
|
{...shouldMonitor}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Root Folder</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.ROOT_FOLDER_SELECT}
|
|
|
|
name="rootFolderPath"
|
|
|
|
helpText={'Root Folder list items will be added to'}
|
|
|
|
{...rootFolderPath}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Quality Profile</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.QUALITY_PROFILE_SELECT}
|
2018-04-08 02:28:16 +00:00
|
|
|
name="qualityProfileId"
|
2018-02-06 23:08:36 +00:00
|
|
|
helpText={'Quality Profile list items should be added with'}
|
2018-04-08 02:28:16 +00:00
|
|
|
{...qualityProfileId}
|
2018-02-06 23:08:36 +00:00
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup className={showLanguageProfile ? undefined : styles.hideLanguageProfile}>
|
|
|
|
<FormLabel>Language Profile</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.LANGUAGE_PROFILE_SELECT}
|
|
|
|
name="languageProfileId"
|
|
|
|
helpText={'Language Profile list items should be added with'}
|
|
|
|
{...languageProfileId}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup className={showMetadataProfile ? undefined : styles.hideMetadataProfile}>
|
|
|
|
<FormLabel>Metadata Profile</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.METADATA_PROFILE_SELECT}
|
|
|
|
name="metadataProfileId"
|
|
|
|
helpText={'Metadata Profile list items should be added with'}
|
|
|
|
{...metadataProfileId}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
{
|
|
|
|
!!fields && !!fields.length &&
|
|
|
|
<div>
|
|
|
|
{
|
|
|
|
fields.map((field) => {
|
|
|
|
return (
|
|
|
|
<ProviderFieldFormGroup
|
|
|
|
key={field.name}
|
|
|
|
advancedSettings={advancedSettings}
|
|
|
|
provider="importList"
|
|
|
|
providerData={item}
|
|
|
|
{...field}
|
|
|
|
onChange={onFieldChange}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|
|
|
|
</Form>
|
|
|
|
}
|
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
|
|
{
|
|
|
|
id &&
|
|
|
|
<Button
|
|
|
|
className={styles.deleteButton}
|
|
|
|
kind={kinds.DANGER}
|
|
|
|
onPress={onDeleteImportListPress}
|
|
|
|
>
|
|
|
|
Delete
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
|
|
|
|
<SpinnerErrorButton
|
|
|
|
isSpinning={isTesting}
|
|
|
|
error={saveError}
|
|
|
|
onPress={onTestPress}
|
|
|
|
>
|
|
|
|
Test
|
|
|
|
</SpinnerErrorButton>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
onPress={onModalClose}
|
|
|
|
>
|
|
|
|
Cancel
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<SpinnerErrorButton
|
|
|
|
isSpinning={isSaving}
|
|
|
|
error={saveError}
|
|
|
|
onPress={onSavePress}
|
|
|
|
>
|
|
|
|
Save
|
|
|
|
</SpinnerErrorButton>
|
|
|
|
</ModalFooter>
|
|
|
|
</ModalContent>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
EditImportListModalContent.propTypes = {
|
|
|
|
advancedSettings: PropTypes.bool.isRequired,
|
|
|
|
isFetching: PropTypes.bool.isRequired,
|
|
|
|
error: PropTypes.object,
|
|
|
|
isSaving: PropTypes.bool.isRequired,
|
|
|
|
isTesting: PropTypes.bool.isRequired,
|
|
|
|
saveError: PropTypes.object,
|
|
|
|
item: PropTypes.object.isRequired,
|
|
|
|
showLanguageProfile: PropTypes.bool.isRequired,
|
|
|
|
showMetadataProfile: PropTypes.bool.isRequired,
|
|
|
|
onInputChange: PropTypes.func.isRequired,
|
|
|
|
onFieldChange: PropTypes.func.isRequired,
|
|
|
|
onModalClose: PropTypes.func.isRequired,
|
|
|
|
onSavePress: PropTypes.func.isRequired,
|
|
|
|
onTestPress: PropTypes.func.isRequired,
|
|
|
|
onDeleteImportListPress: PropTypes.func
|
|
|
|
};
|
|
|
|
|
|
|
|
export default EditImportListModalContent;
|