Update keystore visual indicator (#1355)

* update keystore visual indicator

* Update Keystore.tsx

* visual indication using filename

* updated for visual indication using filename
This commit is contained in:
Michael - Blurpesec 2018-03-22 14:00:55 -04:00 committed by Daniel Ternyak
parent 816ce3180f
commit 68b1447b31
2 changed files with 19 additions and 2 deletions

View File

@ -97,6 +97,14 @@ $speed: 500ms;
max-width: 360px; max-width: 360px;
margin: 0 auto; margin: 0 auto;
} }
&-label{
opacity: 0.8;
font-weight: 300;
white-space: nowrap;
width: 60%;
overflow: hidden;
text-overflow: ellipsis;
}
} }
} }

View File

@ -8,6 +8,7 @@ import { Input } from 'components/ui';
export interface KeystoreValue { export interface KeystoreValue {
file: string; file: string;
password: string; password: string;
filename: string;
valid: boolean; valid: boolean;
} }
@ -37,7 +38,7 @@ export class KeystoreDecrypt extends PureComponent {
}; };
public render() { public render() {
const { isWalletPending, value: { file, password } } = this.props; const { isWalletPending, value: { file, password, filename } } = this.props;
const passReq = isPassRequired(file); const passReq = isPassRequired(file);
const unlockDisabled = !file || (passReq && !password); const unlockDisabled = !file || (passReq && !password);
@ -55,11 +56,17 @@ export class KeystoreDecrypt extends PureComponent {
{translate('ADD_RADIO_2_SHORT')} {translate('ADD_RADIO_2_SHORT')}
</a> </a>
</label> </label>
<label className="WalletDecrypt-decrypt-label" hidden={!file}>
<span>{filename}</span>
</label>
{isWalletPending ? <Spinner /> : ''} {isWalletPending ? <Spinner /> : ''}
<Input <Input
className={`${password.length > 0 ? 'is-valid' : 'is-invalid'} ${ className={`${password.length > 0 ? 'is-valid' : 'is-invalid'} ${
file.length && isWalletPending ? 'hidden' : '' file.length && isWalletPending ? 'hidden' : ''
}`} }`}
disabled={!file}
value={password} value={password}
onChange={this.onPasswordChange} onChange={this.onPasswordChange}
onKeyDown={this.onKeyDown} onKeyDown={this.onKeyDown}
@ -100,6 +107,7 @@ export class KeystoreDecrypt extends PureComponent {
const fileReader = new FileReader(); const fileReader = new FileReader();
const target = e.target; const target = e.target;
const inputFile = target.files[0]; const inputFile = target.files[0];
const fileName = inputFile.name;
fileReader.onload = () => { fileReader.onload = () => {
const keystore = fileReader.result; const keystore = fileReader.result;
@ -109,7 +117,8 @@ export class KeystoreDecrypt extends PureComponent {
...this.props.value, ...this.props.value,
file: keystore, file: keystore,
valid: keystore.length && !passReq, valid: keystore.length && !passReq,
password: '' password: '',
filename: fileName
}); });
this.props.onUnlock(); this.props.onUnlock();
}; };