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-12-06 15:57:07 -05:00
|
|
|
import { FormField } from 'component/common/form';
|
2019-07-18 05:22:47 +07:00
|
|
|
import Button from 'component/button';
|
2019-09-27 14:56:15 -04:00
|
|
|
import usePersistedState from 'effects/use-persisted-state';
|
2019-12-06 15:57:07 -05:00
|
|
|
import Card from 'component/common/card';
|
|
|
|
import I18nMessage from 'component/i18nMessage';
|
2020-09-02 16:08:37 -04:00
|
|
|
import LbcSymbol from 'component/common/lbc-symbol';
|
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
|
|
|
},
|
2020-07-24 10:42:56 -04:00
|
|
|
isAbandoning: boolean,
|
2018-03-26 14:32:43 -07:00
|
|
|
};
|
|
|
|
|
2019-07-10 22:57:24 -04:00
|
|
|
function ModalRemoveFile(props: Props) {
|
2020-07-24 10:42:56 -04:00
|
|
|
const { uri, claimIsMine, closeModal, deleteFile, title, claim, isAbandoning } = 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-12-06 15:57:07 -05:00
|
|
|
<Modal isOpen contentLabel={__('Confirm File Remove')} type="card" onAborted={closeModal}>
|
|
|
|
<Card
|
2020-09-09 10:01:52 +08:00
|
|
|
title={__('Remove File')}
|
2019-12-06 15:57:07 -05:00
|
|
|
subtitle={
|
|
|
|
<I18nMessage tokens={{ title: <cite>{`"${title}"`}</cite> }}>
|
2021-07-07 10:21:17 -04:00
|
|
|
Are you sure you'd like to remove %title%?
|
2019-12-06 15:57:07 -05:00
|
|
|
</I18nMessage>
|
|
|
|
}
|
|
|
|
body={
|
|
|
|
<React.Fragment>
|
|
|
|
{/* @if TARGET='app' */}
|
2019-10-16 20:25:58 -05:00
|
|
|
<FormField
|
2019-12-06 15:57:07 -05:00
|
|
|
name="file_delete"
|
|
|
|
label={__('Delete this file from my computer')}
|
2019-10-16 20:25:58 -05:00
|
|
|
type="checkbox"
|
2019-12-06 15:57:07 -05:00
|
|
|
checked={deleteChecked}
|
|
|
|
onChange={() => setDeleteChecked(!deleteChecked)}
|
2019-10-16 20:25:58 -05:00
|
|
|
/>
|
2019-12-06 15:57:07 -05:00
|
|
|
{/* @endif */}
|
2019-11-17 13:32:31 -05:00
|
|
|
|
2019-12-06 15:57:07 -05:00
|
|
|
{claimIsMine && (
|
|
|
|
<React.Fragment>
|
|
|
|
<FormField
|
|
|
|
name="claim_abandon"
|
2020-09-02 16:08:37 -04:00
|
|
|
label={
|
|
|
|
<I18nMessage
|
|
|
|
tokens={{ lbc: <LbcSymbol prefix={__('reclaim %amount%', { amount: claim.amount })} /> }}
|
|
|
|
>
|
2021-07-07 10:21:17 -04:00
|
|
|
Remove from blockchain (%lbc%)
|
2020-09-02 16:08:37 -04:00
|
|
|
</I18nMessage>
|
|
|
|
}
|
2019-12-06 15:57:07 -05:00
|
|
|
type="checkbox"
|
|
|
|
checked={abandonChecked}
|
|
|
|
onChange={() => setAbandonChecked(!abandonChecked)}
|
|
|
|
/>
|
|
|
|
{abandonChecked === true && (
|
2021-07-07 10:21:17 -04:00
|
|
|
<p className="help error__text">{__('This action is permanent and cannot be undone')}</p>
|
2019-12-06 15:57:07 -05:00
|
|
|
)}
|
|
|
|
|
|
|
|
{/* @if TARGET='app' */}
|
|
|
|
{abandonChecked === false && deleteChecked && (
|
2020-05-29 00:14:16 +03:00
|
|
|
<p className="help">{__('This file will be removed from your Library and Downloads folder.')}</p>
|
2019-12-06 15:57:07 -05:00
|
|
|
)}
|
|
|
|
{!deleteChecked && (
|
|
|
|
<p className="help">
|
2020-07-22 21:33:12 -04:00
|
|
|
{__('This file will be removed from your Library but will remain in your Downloads folder.')}
|
2019-12-06 15:57:07 -05:00
|
|
|
</p>
|
|
|
|
)}
|
|
|
|
{/* @endif */}
|
|
|
|
</React.Fragment>
|
2019-11-17 13:32:31 -05:00
|
|
|
)}
|
2019-12-06 15:57:07 -05:00
|
|
|
</React.Fragment>
|
|
|
|
}
|
|
|
|
actions={
|
2020-07-22 21:33:12 -04:00
|
|
|
<>
|
|
|
|
<div className="section__actions">
|
|
|
|
<Button
|
|
|
|
button="primary"
|
2020-07-30 12:58:24 -04:00
|
|
|
label={isAbandoning ? __('Removing...') : __('OK')}
|
2021-07-07 10:21:17 -04:00
|
|
|
disabled={isAbandoning || !(deleteChecked || abandonChecked)}
|
2020-07-22 21:33:12 -04:00
|
|
|
onClick={() => deleteFile(uri, deleteChecked, claimIsMine ? abandonChecked : false)}
|
|
|
|
/>
|
|
|
|
<Button button="link" label={__('Cancel')} onClick={closeModal} />
|
|
|
|
</div>
|
|
|
|
<p className="help">{__('These changes will appear shortly.')}</p>
|
|
|
|
</>
|
2019-12-06 15:57:07 -05:00
|
|
|
}
|
|
|
|
/>
|
2019-07-10 22:57:24 -04:00
|
|
|
</Modal>
|
|
|
|
);
|
2017-07-02 14:23:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ModalRemoveFile;
|