2018-01-13 02:01:27 +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 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 styles from './EditReleaseProfileModalContent.css';
|
|
|
|
|
2019-02-07 03:22:21 +00:00
|
|
|
// Tab, enter, and comma
|
|
|
|
const tagInputDelimiters = [9, 13, 188];
|
|
|
|
|
2018-01-13 02:01:27 +00:00
|
|
|
function EditReleaseProfileModalContent(props) {
|
|
|
|
const {
|
|
|
|
isSaving,
|
|
|
|
saveError,
|
|
|
|
item,
|
|
|
|
onInputChange,
|
|
|
|
onModalClose,
|
|
|
|
onSavePress,
|
|
|
|
onDeleteReleaseProfilePress,
|
|
|
|
...otherProps
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const {
|
|
|
|
id,
|
2019-06-06 01:54:59 +00:00
|
|
|
enabled,
|
2018-01-13 02:01:27 +00:00
|
|
|
required,
|
|
|
|
ignored,
|
|
|
|
preferred,
|
|
|
|
includePreferredWhenRenaming,
|
2019-06-06 01:54:59 +00:00
|
|
|
tags,
|
|
|
|
indexerId
|
2018-01-13 02:01:27 +00:00
|
|
|
} = item;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ModalContent onModalClose={onModalClose}>
|
|
|
|
<ModalHeader>
|
|
|
|
{id ? 'Edit Release Profile' : 'Add Release Profile'}
|
|
|
|
</ModalHeader>
|
|
|
|
|
|
|
|
<ModalBody>
|
2019-01-02 00:13:49 +00:00
|
|
|
<Form {...otherProps}>
|
2019-06-06 01:54:59 +00:00
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Enable Profile</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.CHECK}
|
|
|
|
name="enabled"
|
|
|
|
helpText="Check to enable release profile"
|
|
|
|
{...enabled}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
2018-01-13 02:01:27 +00:00
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Must Contain</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.TEXT_TAG}
|
|
|
|
name="required"
|
|
|
|
helpText="The release must contain at least one of these terms (case insensitive)"
|
|
|
|
kind={kinds.SUCCESS}
|
|
|
|
placeholder="Add new restriction"
|
2019-02-07 03:22:21 +00:00
|
|
|
delimiters={tagInputDelimiters}
|
2018-01-13 02:01:27 +00:00
|
|
|
{...required}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Must Not Contain</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.TEXT_TAG}
|
|
|
|
name="ignored"
|
|
|
|
helpText="The release will be rejected if it contains one or more of terms (case insensitive)"
|
|
|
|
kind={kinds.DANGER}
|
|
|
|
placeholder="Add new restriction"
|
2019-02-07 03:22:21 +00:00
|
|
|
delimiters={tagInputDelimiters}
|
2018-01-13 02:01:27 +00:00
|
|
|
{...ignored}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Preferred</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.KEY_VALUE_LIST}
|
|
|
|
name="preferred"
|
|
|
|
helpTexts={[
|
|
|
|
'The release will be preferred based on the each term\'s score (case insensitive)',
|
|
|
|
'A positive score will be more preferred',
|
|
|
|
'A negative score will be less preferred'
|
|
|
|
]}
|
|
|
|
{...preferred}
|
|
|
|
keyPlaceholder="Term"
|
|
|
|
valuePlaceholder="Score"
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Include Preferred when Renaming</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.CHECK}
|
|
|
|
name="includePreferredWhenRenaming"
|
2019-06-06 01:54:59 +00:00
|
|
|
helpText={indexerId.value === 0 ? 'Include in {Preferred Words} renaming format' : 'Only supported when Indexer is set to (All)'}
|
2018-01-13 02:01:27 +00:00
|
|
|
{...includePreferredWhenRenaming}
|
|
|
|
onChange={onInputChange}
|
2019-06-06 01:54:59 +00:00
|
|
|
isDisabled={indexerId.value !== 0}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Indexer</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.INDEXER_SELECT}
|
|
|
|
name="indexerId"
|
|
|
|
helpText="Specify what indexer the profile applies to"
|
|
|
|
{...indexerId}
|
|
|
|
includeAny={true}
|
|
|
|
onChange={onInputChange}
|
2018-01-13 02:01:27 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
|
|
|
<FormLabel>Tags</FormLabel>
|
|
|
|
|
|
|
|
<FormInputGroup
|
|
|
|
type={inputTypes.TAG}
|
|
|
|
name="tags"
|
|
|
|
helpText="Release profiles will apply to series at least one matching tag. Leave blank to apply to all series"
|
|
|
|
{...tags}
|
|
|
|
onChange={onInputChange}
|
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
</Form>
|
|
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
|
|
{
|
|
|
|
id &&
|
|
|
|
<Button
|
|
|
|
className={styles.deleteButton}
|
|
|
|
kind={kinds.DANGER}
|
|
|
|
onPress={onDeleteReleaseProfilePress}
|
|
|
|
>
|
|
|
|
Delete
|
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
|
|
|
|
<Button
|
|
|
|
onPress={onModalClose}
|
|
|
|
>
|
|
|
|
Cancel
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
<SpinnerErrorButton
|
|
|
|
isSpinning={isSaving}
|
|
|
|
error={saveError}
|
|
|
|
onPress={onSavePress}
|
|
|
|
>
|
|
|
|
Save
|
|
|
|
</SpinnerErrorButton>
|
|
|
|
</ModalFooter>
|
|
|
|
</ModalContent>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
EditReleaseProfileModalContent.propTypes = {
|
|
|
|
isSaving: PropTypes.bool.isRequired,
|
|
|
|
saveError: PropTypes.object,
|
|
|
|
item: PropTypes.object.isRequired,
|
|
|
|
onInputChange: PropTypes.func.isRequired,
|
|
|
|
onModalClose: PropTypes.func.isRequired,
|
|
|
|
onSavePress: PropTypes.func.isRequired,
|
|
|
|
onDeleteReleaseProfilePress: PropTypes.func
|
|
|
|
};
|
|
|
|
|
|
|
|
export default EditReleaseProfileModalContent;
|