import { isKeystorePassRequired } from 'libs/wallet'; import React, { PureComponent } from 'react'; import translate, { translateRaw } from 'translations'; import Spinner from 'components/ui/Spinner'; import { TShowNotification } from 'actions/notifications'; import { Input } from 'components/ui'; export interface KeystoreValue { file: string; password: string; valid: boolean; } function isPassRequired(file: string): boolean { let passReq = false; try { passReq = isKeystorePassRequired(file); } catch (e) { // TODO: communicate invalid file to user } return passReq; } function isValidFile(rawFile: File): boolean { const fileType = rawFile.type; return fileType === '' || fileType === 'application/json'; } export class KeystoreDecrypt extends PureComponent { public props: { value: KeystoreValue; isWalletPending: boolean; isPasswordPending: boolean; onChange(value: KeystoreValue): void; onUnlock(): void; showNotification(level: string, message: string): TShowNotification; }; public render() { const { isWalletPending, value: { file, password } } = this.props; const passReq = isPassRequired(file); const unlockDisabled = !file || (passReq && !password); return (
); } private onKeyDown = (e: any) => { if (e.keyCode === 13) { this.unlock(e); } }; private unlock = (e: React.SyntheticEvent