Sonarr/frontend/src/Settings/DownloadClients/DownloadClients/DownloadClient.js

137 lines
3.4 KiB
JavaScript
Raw Normal View History

2018-01-13 02:01:27 +00:00
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import Card from 'Components/Card';
import Label from 'Components/Label';
import ConfirmModal from 'Components/Modal/ConfirmModal';
2023-07-11 03:51:14 +00:00
import TagList from 'Components/TagList';
2022-05-20 04:15:43 +00:00
import { kinds } from 'Helpers/Props';
2023-07-22 19:14:33 +00:00
import translate from 'Utilities/String/translate';
2018-01-13 02:01:27 +00:00
import EditDownloadClientModalConnector from './EditDownloadClientModalConnector';
import styles from './DownloadClient.css';
class DownloadClient extends Component {
//
// Lifecycle
constructor(props, context) {
super(props, context);
this.state = {
isEditDownloadClientModalOpen: false,
isDeleteDownloadClientModalOpen: false
};
}
//
// Listeners
onEditDownloadClientPress = () => {
this.setState({ isEditDownloadClientModalOpen: true });
2022-05-20 04:15:43 +00:00
};
2018-01-13 02:01:27 +00:00
onEditDownloadClientModalClose = () => {
this.setState({ isEditDownloadClientModalOpen: false });
2022-05-20 04:15:43 +00:00
};
2018-01-13 02:01:27 +00:00
onDeleteDownloadClientPress = () => {
this.setState({
isEditDownloadClientModalOpen: false,
isDeleteDownloadClientModalOpen: true
});
2022-05-20 04:15:43 +00:00
};
2018-01-13 02:01:27 +00:00
onDeleteDownloadClientModalClose= () => {
this.setState({ isDeleteDownloadClientModalOpen: false });
2022-05-20 04:15:43 +00:00
};
2018-01-13 02:01:27 +00:00
onConfirmDeleteDownloadClient = () => {
this.props.onConfirmDeleteDownloadClient(this.props.id);
2022-05-20 04:15:43 +00:00
};
2018-01-13 02:01:27 +00:00
//
// Render
render() {
const {
id,
name,
enable,
2023-07-11 03:51:14 +00:00
priority,
tags,
tagList
2018-01-13 02:01:27 +00:00
} = this.props;
return (
<Card
className={styles.downloadClient}
overlayContent={true}
onPress={this.onEditDownloadClientPress}
>
<div className={styles.name}>
{name}
</div>
<div className={styles.enabled}>
{
enable ?
<Label kind={kinds.SUCCESS}>
2023-07-22 19:14:33 +00:00
{translate('Enabled')}
2018-01-13 02:01:27 +00:00
</Label> :
<Label
kind={kinds.DISABLED}
outline={true}
>
2023-07-22 19:14:33 +00:00
{translate('Disabled')}
2018-01-13 02:01:27 +00:00
</Label>
}
{
priority > 1 &&
<Label
kind={kinds.DISABLED}
outline={true}
>
2023-07-22 19:14:33 +00:00
{translate('PrioritySettings', { priority })}
</Label>
}
2018-01-13 02:01:27 +00:00
</div>
2023-07-11 03:51:14 +00:00
<TagList
tags={tags}
tagList={tagList}
/>
2018-01-13 02:01:27 +00:00
<EditDownloadClientModalConnector
id={id}
isOpen={this.state.isEditDownloadClientModalOpen}
onModalClose={this.onEditDownloadClientModalClose}
onDeleteDownloadClientPress={this.onDeleteDownloadClientPress}
/>
<ConfirmModal
isOpen={this.state.isDeleteDownloadClientModalOpen}
kind={kinds.DANGER}
2023-07-22 19:14:33 +00:00
title={translate('DeleteDownloadClient')}
message={translate('DeleteDownloadClientMessageText', { name })}
confirmLabel={translate('Delete')}
2018-01-13 02:01:27 +00:00
onConfirm={this.onConfirmDeleteDownloadClient}
onCancel={this.onDeleteDownloadClientModalClose}
/>
</Card>
);
}
}
DownloadClient.propTypes = {
id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
enable: PropTypes.bool.isRequired,
priority: PropTypes.number.isRequired,
2023-07-11 03:51:14 +00:00
tags: PropTypes.arrayOf(PropTypes.number).isRequired,
tagList: PropTypes.arrayOf(PropTypes.object).isRequired,
2018-01-13 02:01:27 +00:00
onConfirmDeleteDownloadClient: PropTypes.func.isRequired
};
export default DownloadClient;