Merge pull request #654 from matrix-org/rav/fix_e2e_dialog_cancel

Fix cancel button on e2e import/export dialogs
This commit is contained in:
David Baker 2017-01-26 11:41:30 +00:00 committed by GitHub
commit f06de1f129
2 changed files with 18 additions and 10 deletions

View file

@ -71,7 +71,7 @@ export default React.createClass({
return this.props.matrixClient.exportRoomKeys(); return this.props.matrixClient.exportRoomKeys();
}).then((k) => { }).then((k) => {
return MegolmExportEncryption.encryptMegolmKeyFile( return MegolmExportEncryption.encryptMegolmKeyFile(
JSON.stringify(k), passphrase JSON.stringify(k), passphrase,
); );
}).then((f) => { }).then((f) => {
const blob = new Blob([f], { const blob = new Blob([f], {
@ -95,9 +95,14 @@ export default React.createClass({
}); });
}, },
_onCancelClick: function(ev) {
ev.preventDefault();
this.props.onFinished(false);
return false;
},
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const AccessibleButton = sdk.getComponent('views.elements.AccessibleButton');
const disableForm = (this.state.phase === PHASE_EXPORTING); const disableForm = (this.state.phase === PHASE_EXPORTING);
@ -159,10 +164,9 @@ export default React.createClass({
<input className='mx_Dialog_primary' type='submit' value='Export' <input className='mx_Dialog_primary' type='submit' value='Export'
disabled={disableForm} disabled={disableForm}
/> />
<AccessibleButton element='button' onClick={this.props.onFinished} <button onClick={this._onCancelClick} disabled={disableForm}>
disabled={disableForm}>
Cancel Cancel
</AccessibleButton> </button>
</div> </div>
</form> </form>
</BaseDialog> </BaseDialog>

View file

@ -80,7 +80,7 @@ export default React.createClass({
return readFileAsArrayBuffer(file).then((arrayBuffer) => { return readFileAsArrayBuffer(file).then((arrayBuffer) => {
return MegolmExportEncryption.decryptMegolmKeyFile( return MegolmExportEncryption.decryptMegolmKeyFile(
arrayBuffer, passphrase arrayBuffer, passphrase,
); );
}).then((keys) => { }).then((keys) => {
return this.props.matrixClient.importRoomKeys(JSON.parse(keys)); return this.props.matrixClient.importRoomKeys(JSON.parse(keys));
@ -98,9 +98,14 @@ export default React.createClass({
}); });
}, },
_onCancelClick: function(ev) {
ev.preventDefault();
this.props.onFinished(false);
return false;
},
render: function() { render: function() {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const AccessibleButton = sdk.getComponent('views.elements.AccessibleButton');
const disableForm = (this.state.phase !== PHASE_EDIT); const disableForm = (this.state.phase !== PHASE_EDIT);
@ -158,10 +163,9 @@ export default React.createClass({
<input className='mx_Dialog_primary' type='submit' value='Import' <input className='mx_Dialog_primary' type='submit' value='Import'
disabled={!this.state.enableSubmit || disableForm} disabled={!this.state.enableSubmit || disableForm}
/> />
<AccessibleButton element='button' onClick={this.props.onFinished} <button onClick={this._onCancelClick} disabled={disableForm}>
disabled={disableForm}>
Cancel Cancel
</AccessibleButton> </button>
</div> </div>
</form> </form>
</BaseDialog> </BaseDialog>