You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
4.7 KiB
178 lines
4.7 KiB
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import { inputTypes, kinds } from 'Helpers/Props';
|
|
import Alert from 'Components/Alert';
|
|
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 './EditDownloadClientModalContent.css';
|
|
|
|
class EditDownloadClientModalContent extends Component {
|
|
|
|
//
|
|
// Render
|
|
|
|
render() {
|
|
const {
|
|
advancedSettings,
|
|
isFetching,
|
|
error,
|
|
isSaving,
|
|
isTesting,
|
|
saveError,
|
|
item,
|
|
onInputChange,
|
|
onFieldChange,
|
|
onModalClose,
|
|
onSavePress,
|
|
onTestPress,
|
|
onDeleteDownloadClientPress,
|
|
...otherProps
|
|
} = this.props;
|
|
|
|
const {
|
|
id,
|
|
name,
|
|
enable,
|
|
fields,
|
|
message
|
|
} = item;
|
|
|
|
return (
|
|
<ModalContent onModalClose={onModalClose}>
|
|
<ModalHeader>
|
|
{id ? 'Edit DownloadClient' : 'Add DownloadClient'}
|
|
</ModalHeader>
|
|
|
|
<ModalBody>
|
|
{
|
|
isFetching &&
|
|
<LoadingIndicator />
|
|
}
|
|
|
|
{
|
|
!isFetching && !!error &&
|
|
<div>Unable to add a new downloadClient, please try again.</div>
|
|
}
|
|
|
|
{
|
|
!isFetching && !error &&
|
|
<Form
|
|
{...otherProps}
|
|
>
|
|
{
|
|
!!message &&
|
|
<Alert
|
|
className={styles.message}
|
|
kind={message.value.type}
|
|
>
|
|
{message.value.message}
|
|
</Alert>
|
|
}
|
|
|
|
<FormGroup>
|
|
<FormLabel>Name</FormLabel>
|
|
|
|
<FormInputGroup
|
|
type={inputTypes.TEXT}
|
|
name="name"
|
|
{...name}
|
|
onChange={onInputChange}
|
|
/>
|
|
</FormGroup>
|
|
|
|
<FormGroup>
|
|
<FormLabel>Enable</FormLabel>
|
|
|
|
<FormInputGroup
|
|
type={inputTypes.CHECK}
|
|
name="enable"
|
|
{...enable}
|
|
onChange={onInputChange}
|
|
/>
|
|
</FormGroup>
|
|
|
|
{
|
|
fields.map((field) => {
|
|
return (
|
|
<ProviderFieldFormGroup
|
|
key={field.name}
|
|
advancedSettings={advancedSettings}
|
|
provider="downloadClient"
|
|
providerData={item}
|
|
{...field}
|
|
onChange={onFieldChange}
|
|
/>
|
|
);
|
|
})
|
|
}
|
|
|
|
</Form>
|
|
}
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
{
|
|
id &&
|
|
<Button
|
|
className={styles.deleteButton}
|
|
kind={kinds.DANGER}
|
|
onPress={onDeleteDownloadClientPress}
|
|
>
|
|
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>
|
|
);
|
|
}
|
|
}
|
|
|
|
EditDownloadClientModalContent.propTypes = {
|
|
advancedSettings: PropTypes.bool.isRequired,
|
|
isFetching: PropTypes.bool.isRequired,
|
|
error: PropTypes.object,
|
|
isSaving: PropTypes.bool.isRequired,
|
|
saveError: PropTypes.object,
|
|
isTesting: PropTypes.bool.isRequired,
|
|
item: PropTypes.object.isRequired,
|
|
onInputChange: PropTypes.func.isRequired,
|
|
onFieldChange: PropTypes.func.isRequired,
|
|
onModalClose: PropTypes.func.isRequired,
|
|
onSavePress: PropTypes.func.isRequired,
|
|
onTestPress: PropTypes.func.isRequired,
|
|
onDeleteDownloadClientPress: PropTypes.func
|
|
};
|
|
|
|
export default EditDownloadClientModalContent;
|