mirror of https://github.com/lidarr/Lidarr
143 lines
3.9 KiB
JavaScript
143 lines
3.9 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
import Form from 'Components/Form/Form';
|
|
import FormGroup from 'Components/Form/FormGroup';
|
|
import FormInputGroup from 'Components/Form/FormInputGroup';
|
|
import FormLabel from 'Components/Form/FormLabel';
|
|
import Button from 'Components/Link/Button';
|
|
import SpinnerErrorButton from 'Components/Link/SpinnerErrorButton';
|
|
import LoadingIndicator from 'Components/Loading/LoadingIndicator';
|
|
import ModalBody from 'Components/Modal/ModalBody';
|
|
import ModalContent from 'Components/Modal/ModalContent';
|
|
import ModalFooter from 'Components/Modal/ModalFooter';
|
|
import ModalHeader from 'Components/Modal/ModalHeader';
|
|
import { inputTypes, kinds } from 'Helpers/Props';
|
|
import { stringSettingShape } from 'Helpers/Props/Shapes/settingShape';
|
|
import translate from 'Utilities/String/translate';
|
|
import styles from './EditImportListExclusionModalContent.css';
|
|
|
|
function EditImportListExclusionModalContent(props) {
|
|
const {
|
|
id,
|
|
isFetching,
|
|
error,
|
|
isSaving,
|
|
saveError,
|
|
item,
|
|
onInputChange,
|
|
onSavePress,
|
|
onModalClose,
|
|
onDeleteImportListExclusionPress,
|
|
...otherProps
|
|
} = props;
|
|
|
|
const {
|
|
artistName,
|
|
foreignId
|
|
} = item;
|
|
|
|
return (
|
|
<ModalContent onModalClose={onModalClose}>
|
|
<ModalHeader>
|
|
{id ? 'Edit Import List Exclusion' : 'Add Import List Exclusion'}
|
|
</ModalHeader>
|
|
|
|
<ModalBody className={styles.body}>
|
|
{
|
|
isFetching &&
|
|
<LoadingIndicator />
|
|
}
|
|
|
|
{
|
|
!isFetching && !!error &&
|
|
<div>
|
|
{translate('UnableToAddANewImportListExclusionPleaseTryAgain')}
|
|
</div>
|
|
}
|
|
|
|
{
|
|
!isFetching && !error &&
|
|
<Form
|
|
{...otherProps}
|
|
>
|
|
<FormGroup>
|
|
<FormLabel>
|
|
{translate('EntityName')}
|
|
</FormLabel>
|
|
|
|
<FormInputGroup
|
|
type={inputTypes.TEXT}
|
|
name="artistName"
|
|
helpText={translate('ArtistNameHelpText')}
|
|
{...artistName}
|
|
onChange={onInputChange}
|
|
/>
|
|
</FormGroup>
|
|
|
|
<FormGroup>
|
|
<FormLabel>
|
|
{translate('MusicbrainzId')}
|
|
</FormLabel>
|
|
|
|
<FormInputGroup
|
|
type={inputTypes.TEXT}
|
|
name="foreignId"
|
|
helpText={translate('ForeignIdHelpText')}
|
|
{...foreignId}
|
|
onChange={onInputChange}
|
|
/>
|
|
</FormGroup>
|
|
</Form>
|
|
}
|
|
</ModalBody>
|
|
|
|
<ModalFooter>
|
|
{
|
|
id &&
|
|
<Button
|
|
className={styles.deleteButton}
|
|
kind={kinds.DANGER}
|
|
onPress={onDeleteImportListExclusionPress}
|
|
>
|
|
Delete
|
|
</Button>
|
|
}
|
|
|
|
<Button
|
|
onPress={onModalClose}
|
|
>
|
|
Cancel
|
|
</Button>
|
|
|
|
<SpinnerErrorButton
|
|
isSpinning={isSaving}
|
|
error={saveError}
|
|
onPress={onSavePress}
|
|
>
|
|
Save
|
|
</SpinnerErrorButton>
|
|
</ModalFooter>
|
|
</ModalContent>
|
|
);
|
|
}
|
|
|
|
const ImportListExclusionShape = {
|
|
artistName: PropTypes.shape(stringSettingShape).isRequired,
|
|
foreignId: PropTypes.shape(stringSettingShape).isRequired
|
|
};
|
|
|
|
EditImportListExclusionModalContent.propTypes = {
|
|
id: PropTypes.number,
|
|
isFetching: PropTypes.bool.isRequired,
|
|
error: PropTypes.object,
|
|
isSaving: PropTypes.bool.isRequired,
|
|
saveError: PropTypes.object,
|
|
item: PropTypes.shape(ImportListExclusionShape).isRequired,
|
|
onInputChange: PropTypes.func.isRequired,
|
|
onSavePress: PropTypes.func.isRequired,
|
|
onModalClose: PropTypes.func.isRequired,
|
|
onDeleteImportListExclusionPress: PropTypes.func
|
|
};
|
|
|
|
export default EditImportListExclusionModalContent;
|