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