lbry-desktop/ui/modal/modalRemoveFile/view.jsx

72 lines
2.5 KiB
React
Raw Normal View History

2018-03-26 23:32:43 +02:00
// @flow
import React from 'react';
import { Modal } from 'modal/modal';
2019-07-18 00:22:47 +02:00
import { Form, FormField } from 'component/common/form';
import Button from 'component/button';
2019-09-27 20:56:15 +02:00
import usePersistedState from 'effects/use-persisted-state';
2017-07-02 20:23:38 +02:00
2018-03-26 23:32:43 +02:00
type Props = {
uri: string,
claim: StreamClaim,
2018-03-26 23:32:43 +02:00
claimIsMine: boolean,
closeModal: () => void,
deleteFile: (string, boolean, boolean) => void,
title: string,
fileInfo?: {
outpoint: ?string,
2018-03-26 23:32:43 +02:00
},
};
function ModalRemoveFile(props: Props) {
2019-10-17 03:25:58 +02:00
const { uri, claimIsMine, closeModal, deleteFile, title, claim } = props;
const [deleteChecked, setDeleteChecked] = usePersistedState('modal-remove-file:delete', true);
const [abandonChecked, setAbandonChecked] = usePersistedState('modal-remove-file:abandon', true);
2017-07-02 20:23:38 +02:00
return (
2019-07-18 00:22:47 +02:00
<Modal isOpen title="Remove File" contentLabel={__('Confirm File Remove')} type="custom" onAborted={closeModal}>
2019-07-21 23:31:22 +02:00
<section>
<p>
2019-11-17 19:32:31 +01:00
{__("Are you sure you'd like to remove")} <cite>{`"${title}"`}</cite> {__('from LBRY?')}
</p>
</section>
<Form onSubmit={() => deleteFile(uri, deleteChecked, claimIsMine ? abandonChecked : false)}>
2019-11-17 19:32:31 +01:00
{!IS_WEB && (
<FormField
name="file_delete"
label={__('Delete this file from my computer')}
type="checkbox"
checked={deleteChecked}
onChange={() => setDeleteChecked(!deleteChecked)}
/>
)}
2017-07-02 20:23:38 +02:00
{claimIsMine && (
2019-10-17 03:25:58 +02:00
<div>
<FormField
name="claim_abandon"
2019-10-23 04:58:07 +02:00
label={__('Abandon on blockchain (reclaim %amount% LBC)', { amount: claim.amount })}
2019-10-17 03:25:58 +02:00
type="checkbox"
checked={abandonChecked}
onChange={() => setAbandonChecked(!abandonChecked)}
/>
2019-11-17 19:32:31 +01:00
{abandonChecked === true && <p className="error-text">This action is permanent and cannot be undone.</p>}
{abandonChecked === false && deleteChecked && !IS_WEB && (
<p>This file will be removed from your Library and Downloads folder.</p>
)}
{!deleteChecked && !IS_WEB && (
<p>This file removed from your Library but will remain in your Downloads folder.</p>
2019-10-17 03:25:58 +02:00
)}
</div>
)}
2019-07-18 00:22:47 +02:00
<div className="card__actions">
<Button type="submit" button="primary" label={__('OK')} />
2019-07-18 00:22:47 +02:00
<Button button="link" label={__('Cancel')} onClick={closeModal} />
</div>
</Form>
</Modal>
);
2017-07-02 20:23:38 +02:00
}
export default ModalRemoveFile;