2018-03-26 23:32:43 +02:00
|
|
|
// @flow
|
2017-12-21 22:08:54 +01:00
|
|
|
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 = {
|
2019-08-15 04:50:41 +02:00
|
|
|
uri: string,
|
2019-05-10 01:26:03 +02:00
|
|
|
claim: StreamClaim,
|
2018-03-26 23:32:43 +02:00
|
|
|
claimIsMine: boolean,
|
|
|
|
closeModal: () => void,
|
|
|
|
deleteFile: (string, boolean, boolean) => void,
|
|
|
|
title: string,
|
2019-03-12 20:15:11 +01:00
|
|
|
fileInfo?: {
|
|
|
|
outpoint: ?string,
|
2018-03-26 23:32:43 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-07-11 04:57:24 +02:00
|
|
|
function ModalRemoveFile(props: Props) {
|
2019-10-17 03:25:58 +02:00
|
|
|
const { uri, claimIsMine, closeModal, deleteFile, title, claim } = props;
|
2019-07-11 04:57:24 +02:00
|
|
|
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
|
|
|
|
2019-07-11 04:57:24 +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>
|
2019-07-11 04:57:24 +02:00
|
|
|
<p>
|
2019-11-17 19:32:31 +01:00
|
|
|
{__("Are you sure you'd like to remove")} <cite>{`"${title}"`}</cite> {__('from LBRY?')}
|
2019-07-11 04:57:24 +02:00
|
|
|
</p>
|
|
|
|
</section>
|
2019-08-15 04:50:41 +02:00
|
|
|
<Form onSubmit={() => deleteFile(uri, deleteChecked, claimIsMine ? abandonChecked : false)}>
|
2019-11-19 22:26:36 +01: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 20:23:38 +02:00
|
|
|
|
2019-07-11 04:57:24 +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>}
|
|
|
|
|
2019-11-19 22:26:36 +01:00
|
|
|
{/* @if TARGET='app' */}
|
|
|
|
{abandonChecked === false && deleteChecked && (
|
2019-11-17 19:32:31 +01:00
|
|
|
<p>This file will be removed from your Library and Downloads folder.</p>
|
|
|
|
)}
|
2019-11-19 23:47:19 +01:00
|
|
|
{!deleteChecked && <p>This file will be removed from your Library but will remain in your Downloads folder.</p>}
|
2019-11-19 22:26:36 +01:00
|
|
|
{/* @endif */}
|
2019-10-17 03:25:58 +02:00
|
|
|
</div>
|
2019-07-11 04:57:24 +02:00
|
|
|
)}
|
2019-07-18 00:22:47 +02:00
|
|
|
<div className="card__actions">
|
2019-08-15 13:36:03 +02:00
|
|
|
<Button type="submit" button="primary" label={__('OK')} />
|
2019-07-18 00:22:47 +02:00
|
|
|
<Button button="link" label={__('Cancel')} onClick={closeModal} />
|
|
|
|
</div>
|
|
|
|
</Form>
|
2019-07-11 04:57:24 +02:00
|
|
|
</Modal>
|
|
|
|
);
|
2017-07-02 20:23:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ModalRemoveFile;
|