Skip to content

Commit

Permalink
Make sure we display the correct back button for folder forms
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Rainville committed Jan 18, 2020
1 parent cf715ae commit 94009f9
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_ssembed.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_sslink-file.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/TinyMCE_ssmedia.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/src/containers/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class Editor extends Component {
const schemaUrl = this.getFormSchemaUrl();

let showButton = buttonStates.SWITCH;
if (dialog) {
if (dialog && file && file.type !== 'folder') {
// When editing the details of a file from inside the modal, we always show the back button
// Otherwise, we only show theb ack button in mobile view to allow deselection of file
showButton = showingSubForm ? buttonStates.ALWAYS_BACK : buttonStates.ONLY_BACK;
Expand Down
20 changes: 20 additions & 0 deletions client/src/containers/Editor/tests/Editor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const render = (props) => {
stashFormValues: jest.fn(),
}
},
file: {
type: 'image'
},
...props
};
const component = ReactTestUtils.renderIntoDocument(<Editor {...baseProps} />);
Expand Down Expand Up @@ -121,6 +124,23 @@ describe('Editor', () => {
expect(connectedHeader.props.children.type).toBe('div');
expect(connectedHeader.props.showButton).toBe(buttonStates.ALWAYS_BACK);
});

it('Form for folder', () => {
const { component } =
render({ nextType: 'subform', dialog: true, file: { type: 'folder' } });

component.openModal();
const connectedHeader = component.editorHeader({
SchemaComponent: 'div',
formid: 'myFormName'
});

expect(connectedHeader.type.name).toBe('EditorHeader');
expect(connectedHeader.props.onDetails).toBeFalsy();
expect(connectedHeader.props.onCancel).toBe(component.handleClose);
expect(connectedHeader.props.children.type).toBe('div');
expect(connectedHeader.props.showButton).toBe(buttonStates.SWITCH);
});
});

describe('createFn', () => {
Expand Down

0 comments on commit 94009f9

Please sign in to comment.