RemoveTorrentsModal: move delete data toggle to the action row

This commit is contained in:
Jesse Chan
2020-11-13 23:54:55 +08:00
parent ee946f4932
commit 96315e4935
3 changed files with 53 additions and 48 deletions
@@ -1,7 +1,7 @@
import {Component} from 'react';
import {FormattedMessage, injectIntl, WrappedComponentProps} from 'react-intl';
import {Checkbox, Form, FormRow} from '../../../ui';
import {Form, FormRow} from '../../../ui';
import Modal from '../Modal';
import {saveDeleteTorrentsUserPreferences} from '../../../util/userPreferences';
import SettingStore from '../../../stores/SettingStore';
@@ -14,63 +14,61 @@ class RemoveTorrentsModal extends Component<WrappedComponentProps> {
formRef?: Form | null;
getActions(torrentCount: number): Array<ModalAction> {
if (torrentCount === 0) {
return [
{
clickHandler: null,
content: 'OK',
triggerDismiss: true,
type: 'primary',
},
];
}
const {intl} = this.props;
return [
{
clickHandler: null,
content: this.props.intl.formatMessage({
id: 'button.no',
}),
triggerDismiss: true,
type: 'tertiary',
},
{
clickHandler: this.handleRemovalConfirmation,
content: this.props.intl.formatMessage({
id: 'button.yes',
}),
triggerDismiss: true,
type: 'primary',
},
];
return torrentCount === 0
? [
{
clickHandler: null,
content: intl.formatMessage({
id: 'button.ok',
}),
triggerDismiss: true,
type: 'primary',
},
]
: [
{
checked: SettingStore.floodSettings.deleteTorrentData,
content: intl.formatMessage({
id: 'torrents.remove.delete.data',
}),
id: 'deleteData',
type: 'checkbox',
},
{
clickHandler: null,
content: intl.formatMessage({
id: 'button.no',
}),
triggerDismiss: true,
type: 'tertiary',
},
{
clickHandler: this.handleRemovalConfirmation,
content: intl.formatMessage({
id: 'button.yes',
}),
triggerDismiss: true,
type: 'primary',
},
];
}
getContent(torrentCount: number) {
let modalContent = null;
let deleteDataContent = null;
if (torrentCount === 0) {
modalContent = <FormattedMessage id="torrents.remove.error.no.torrents.selected" />;
} else {
modalContent = <FormattedMessage id="torrents.remove.are.you.sure" values={{count: torrentCount}} />;
deleteDataContent = (
<FormRow>
<Checkbox id="deleteData" checked={SettingStore.floodSettings.deleteTorrentData}>
<FormattedMessage id="torrents.remove.delete.data" />
</Checkbox>
</FormRow>
);
}
return (
<div className="modal__content inverse">
<Form
ref={(ref) => {
this.formRef = ref;
}}>
<FormRow>{modalContent}</FormRow>
{deleteDataContent}
<FormRow>
{torrentCount === 0 ? (
<FormattedMessage id="torrents.remove.error.no.torrents.selected" />
) : (
<FormattedMessage id="torrents.remove.are.you.sure" values={{count: torrentCount}} />
)}
</FormRow>
</Form>
</div>
);
@@ -407,6 +407,12 @@
"value": "No"
}
],
"button.ok": [
{
"type": 0,
"value": "OK"
}
],
"button.retry": [
{
"type": 0,
+1
View File
@@ -30,6 +30,7 @@
"button.cancel": "Cancel",
"button.download": "Download",
"button.no": "No",
"button.ok": "OK",
"button.retry": "Retry",
"button.save": "Save Settings",
"button.save.feed": "Save",