Skip to content

Commit

Permalink
feat(client/error-tab): allow to save latest xml when error occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac committed Mar 5, 2019
1 parent 06e4083 commit 2509bd5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
19 changes: 11 additions & 8 deletions client/src/app/tabs/EditorTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ export function createTab(tabName, providers) {
...otherProps
} = this.props;

const props = {
id: tab.id,
tab,
...otherProps,
xml: tab.file.contents,
ref: this.tabRef,
providers
};

return (
this.state.hasError ?
<ErrorTab ref={ this.tabRef } /> :
<MultiSheetTab
id={ tab.id }
tab={ tab }
{ ...otherProps }
xml={ tab.file.contents }
ref={ this.tabRef }
providers={ providers } />
<ErrorTab { ...props } /> :
<MultiSheetTab { ...props } />
);
}

Expand Down
6 changes: 5 additions & 1 deletion client/src/app/tabs/ErrorTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ import {

export default class ErrorTab extends PureComponent {

triggerAction() {}
triggerAction(action) {
if (action === 'save') {
return this.props.xml;
}
}

render() {
return (
Expand Down
17 changes: 17 additions & 0 deletions client/src/app/tabs/__tests__/EditorTabSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ describe('<EditorTab>', function() {
verifyChildIsPresent(wrapper, ErrorTab);
});


it('should allow to save latest known xml when editor fails', function() {

// given
sinon.stub(MockEditor.prototype, 'render').throwsException();

const {
instance
} = renderEditorTab();

// when
const result = instance.triggerAction('save');

// then
expect(result).to.be.eql(defaultTab.file.contents);
});

});

});
Expand Down

0 comments on commit 2509bd5

Please sign in to comment.