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-07-11 04:57:24 +02:00
|
|
|
import usePersistedState from 'util/use-persisted-state';
|
2017-07-02 20:23:38 +02:00
|
|
|
|
2018-03-26 23:32:43 +02:00
|
|
|
type Props = {
|
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) {
|
|
|
|
const { claim, claimIsMine, closeModal, deleteFile, fileInfo, title } = props;
|
|
|
|
const [deleteChecked, setDeleteChecked] = usePersistedState('modal-remove-file:delete', true);
|
|
|
|
const [abandonChecked, setAbandonChecked] = usePersistedState('modal-remove-file:abandon', true);
|
|
|
|
const { txid, nout } = claim;
|
|
|
|
const outpoint = fileInfo ? fileInfo.outpoint : `${txid}:${nout}`;
|
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>
|
|
|
|
{__("Are you sure you'd like to remove")} <cite>{`"${title}"`}</cite> {__('from the LBRY app?')}
|
|
|
|
</p>
|
|
|
|
</section>
|
2019-07-21 23:31:22 +02:00
|
|
|
<Form onSubmit={() => deleteFile(outpoint || '', deleteChecked, abandonChecked)}>
|
2019-07-11 04:57:24 +02:00
|
|
|
<FormField
|
2019-07-21 23:31:22 +02:00
|
|
|
name="claim_abandon"
|
|
|
|
label={__('Abandon the claim for this URI')}
|
2019-07-11 04:57:24 +02:00
|
|
|
type="checkbox"
|
2019-07-21 23:31:22 +02:00
|
|
|
checked={abandonChecked}
|
|
|
|
onChange={() => setAbandonChecked(!abandonChecked)}
|
2019-07-11 04:57:24 +02:00
|
|
|
/>
|
2017-07-02 20:23:38 +02:00
|
|
|
|
2019-07-11 04:57:24 +02:00
|
|
|
{claimIsMine && (
|
2019-02-13 17:27:20 +01:00
|
|
|
<FormField
|
2019-07-11 04:57:24 +02:00
|
|
|
name="claim_abandon"
|
|
|
|
label={__('Abandon the claim for this URI')}
|
2019-02-13 17:27:20 +01:00
|
|
|
type="checkbox"
|
2019-07-11 04:57:24 +02:00
|
|
|
checked={abandonChecked}
|
|
|
|
onChange={() => setAbandonChecked(!abandonChecked)}
|
2019-02-13 17:27:20 +01:00
|
|
|
/>
|
2019-07-11 04:57:24 +02:00
|
|
|
)}
|
2019-07-18 00:22:47 +02:00
|
|
|
<div className="card__actions">
|
|
|
|
<Button
|
|
|
|
autoFocus
|
|
|
|
button="primary"
|
|
|
|
label={__('OK')}
|
|
|
|
disabled={!deleteChecked && !abandonChecked}
|
|
|
|
onClick={() => deleteFile(outpoint || '', deleteChecked, abandonChecked)}
|
|
|
|
/>
|
|
|
|
<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;
|