diff --git a/src/renderer/components/commands-editors.tsx b/src/renderer/components/commands-editors.tsx index 6035e7b58f..1217e7bc01 100644 --- a/src/renderer/components/commands-editors.tsx +++ b/src/renderer/components/commands-editors.tsx @@ -1,4 +1,4 @@ -import { Button, Menu, MenuItem, Popover, Position } from '@blueprintjs/core'; +import { Button, Menu, MenuDivider, MenuItem, Popover, Position } from '@blueprintjs/core'; import { observer } from 'mobx-react'; import * as React from 'react'; @@ -82,6 +82,18 @@ export class EditorDropdown extends React.Component + + + + ); + return result; } diff --git a/src/renderer/state.ts b/src/renderer/state.ts index 3bf3cb38ed..f77069802d 100644 --- a/src/renderer/state.ts +++ b/src/renderer/state.ts @@ -139,6 +139,7 @@ export class AppState { this.toggleSettings = this.toggleSettings.bind(this); this.toggleBisectDialog = this.toggleBisectDialog.bind(this); this.updateElectronVersions = this.updateElectronVersions.bind(this); + this.resetEditorLayout = this.resetEditorLayout.bind(this); ipcRendererManager.removeAllListeners(IpcEvents.OPEN_SETTINGS); ipcRendererManager.removeAllListeners(IpcEvents.SHOW_WELCOME_TOUR); @@ -539,7 +540,6 @@ export class AppState { this.outputBuffer += strData; strData = this.outputBuffer; const parts = strData.split('\r\n'); - for (let partIndex = 0; partIndex < parts.length; partIndex += 1) { const part = parts[partIndex]; if (partIndex === parts.length - 1) { @@ -635,6 +635,15 @@ export class AppState { this.setVisibleMosaics([...currentlyVisible, id]); } + /** + * Resets editor view to default layout + * + * + */ + @action public resetEditorLayout() { + this.mosaicArrangement = DEFAULT_MOSAIC_ARRANGEMENT; + } + /** * Resets the view, optionally with certain view flags enabled. * diff --git a/tests/renderer/components/__snapshots__/commands-editors-spec.tsx.snap b/tests/renderer/components/__snapshots__/commands-editors-spec.tsx.snap index 9b76734280..34200d6209 100644 --- a/tests/renderer/components/__snapshots__/commands-editors-spec.tsx.snap +++ b/tests/renderer/components/__snapshots__/commands-editors-spec.tsx.snap @@ -52,6 +52,17 @@ Array [ shouldDismissPopover={true} text="Stylesheet (styles.css)" />, + + + + , ] `; @@ -112,6 +123,17 @@ exports[`EditorDropdown component renders 1`] = ` shouldDismissPopover={true} text="Stylesheet (styles.css)" /> + + + + } defaultIsOpen={false} @@ -203,6 +225,17 @@ exports[`EditorDropdown component renders the extra button if the FIDDLE_DOCS_DE shouldDismissPopover={true} text="Stylesheet (styles.css)" /> + + + + } defaultIsOpen={false} diff --git a/tests/renderer/state-spec.ts b/tests/renderer/state-spec.ts index f627556931..eeffe7a764 100644 --- a/tests/renderer/state-spec.ts +++ b/tests/renderer/state-spec.ts @@ -560,4 +560,20 @@ describe('AppState', () => { }); }); }); + + describe('resetEditorLayout()', () => { + it('Puts editors in default arrangement', () => { + appState.hideAndBackupMosaic(EditorId.main); + + expect(appState.mosaicArrangement).toEqual({ + direction: 'row', + first: EditorId.renderer, + second: EditorId.html + }); + + appState.resetEditorLayout(); + + expect(appState.mosaicArrangement).toEqual(DEFAULT_MOSAIC_ARRANGEMENT); + }); + }); });