1 import { useState } from 'react';
3 import { c } from 'ttag';
5 import { Button } from '@proton/atoms';
6 import type { ModalStateProps } from '@proton/components';
17 } from '@proton/components';
19 import { TransferSignatureIssueStrategy } from '../../store/_downloads/interface';
20 import type { SignatureIssues } from '../../store/_links/interface';
21 import { SignatureAlertBody } from '../SignatureAlert';
23 interface ConflictModalProps {
27 signatureAddress?: string;
28 signatureIssues: SignatureIssues;
29 apply: (strategy: TransferSignatureIssueStrategy, all: boolean) => void;
30 cancelAll: () => void;
33 export default function SignatureIssueModal({
43 }: ConflictModalProps & ModalStateProps) {
44 const [strategy, setStrategy] = useState(TransferSignatureIssueStrategy.Abort);
45 const [applyAll, setApplyAll] = useState(false);
47 const handleClose = () => {
52 const downloadFileName = (
53 <strong className="text-break" key="downloadFileName">
63 apply(strategy, applyAll);
70 title={isFile ? c('Title').t`Download unverified file?` : c('Title').t`Download unverified folder?`}
75 signatureIssues={signatureIssues}
76 signatureAddress={signatureAddress}
81 <p>{c('Info').t`What do you want to do?`}</p>
84 id={TransferSignatureIssueStrategy.Abort}
85 checked={strategy === TransferSignatureIssueStrategy.Abort}
86 onChange={() => setStrategy(TransferSignatureIssueStrategy.Abort)}
88 className="inline-flex flex-nowrap"
91 <strong>{c('Label').t`Cancel download`}</strong>
93 <span className="color-weak">
94 {c('Info').jt`Download of ${downloadFileName} will be aborted`}
101 id={TransferSignatureIssueStrategy.Continue}
102 checked={strategy === TransferSignatureIssueStrategy.Continue}
103 onChange={() => setStrategy(TransferSignatureIssueStrategy.Continue)}
105 className="inline-flex flex-nowrap"
108 <strong>{c('Label').t`Download anyway`}</strong>
110 <span className="color-weak">{c('Info').t`Signature check will be ignored`}</span>
116 <Checkbox onChange={() => setApplyAll((value) => !value)}>
117 {c('Label').t`Apply to all unverified items`}
122 <Button onClick={handleClose}>{c('Action').t`Cancel all downloads`}</Button>
123 <Button type="submit" color="norm">
124 {c('Action').t`Continue`}
131 export const useSignatureIssueModal = () => {
132 return useModalTwoStatic(SignatureIssueModal);