@@ -10,12 +10,14 @@ import includes from 'lodash-es/includes';
1010import isNull from 'lodash-es/isNull' ;
1111import get from 'lodash-es/get' ;
1212import partial from 'lodash-es/partial' ;
13+ import some from 'lodash-es/some' ;
1314import { t } from 'i18next' ;
1415import classnames from 'classnames' ;
1516
1617import prefix from '../services/inlineStylePrefixer' ;
1718import { getQueryParameters , setQueryParameters } from '../util/queryParams' ;
1819import { LANGUAGES } from '../util/editor' ;
20+ import { RIGHT_COLUMN_COMPONENTS } from '../util/ui' ;
1921import { dehydrateProject , rehydrateProject } from '../clients/localStorage' ;
2022
2123import { isPristineProject } from '../util/projectUtils' ;
@@ -163,30 +165,42 @@ export default class Workspace extends React.Component {
163165 _renderHiddenRightColumnComponents ( ) {
164166 const {
165167 currentProject,
168+ hasErrors,
166169 onComponentToggle,
167- shouldShowCollapsedConsole ,
170+ title ,
168171 } = this . props ;
169- const rightColumnComponents = [ 'console' ] ;
170- return rightColumnComponents .
172+ // Errors take over the whole right side of the screen
173+ if ( hasErrors ) {
174+ return null ;
175+ }
176+ return RIGHT_COLUMN_COMPONENTS .
171177 filter ( component => (
172178 includes ( currentProject . hiddenUIComponents , component )
173179 ) ) .
174180 map ( ( component ) => {
175181 switch ( component ) {
176182 case 'console' :
177- if ( shouldShowCollapsedConsole ) {
178- return (
179- < CollapsedComponent
180- component = "console"
181- isRightJustified = { false }
182- key = "console"
183- projectKey = { currentProject . projectKey }
184- text = { t ( 'workspace.components.console' ) }
185- onComponentUnhide = { onComponentToggle }
186- />
187- ) ;
188- }
189- return null ;
183+ return (
184+ < CollapsedComponent
185+ component = "console"
186+ isRightJustified = { false }
187+ key = "console"
188+ projectKey = { currentProject . projectKey }
189+ text = { t ( 'workspace.components.console' ) }
190+ onComponentUnhide = { onComponentToggle }
191+ />
192+ ) ;
193+ case 'preview' :
194+ return (
195+ < CollapsedComponent
196+ component = "preview"
197+ isRightJustified = { false }
198+ key = "preview"
199+ projectKey = { currentProject . projectKey }
200+ text = { title }
201+ onComponentUnhide = { onComponentToggle }
202+ />
203+ ) ;
190204 default :
191205 return null ;
192206 }
@@ -197,6 +211,29 @@ export default class Workspace extends React.Component {
197211 return this . props . hiddenLanguages . length !== LANGUAGES . length ;
198212 }
199213
214+ _shouldRenderRightColumn ( ) {
215+ const {
216+ currentProject,
217+ shouldRenderOutput,
218+ } = this . props ;
219+ return shouldRenderOutput || some ( RIGHT_COLUMN_COMPONENTS ,
220+ component => (
221+ ! includes ( currentProject . hiddenUIComponents , component )
222+ ) ) ;
223+ }
224+
225+ _isEverythingHidden ( ) {
226+ return ! this . _shouldRenderLeftColumn ( ) && ! this . _shouldRenderRightColumn ( ) ;
227+ }
228+
229+ _renderEverythingHidden ( ) {
230+ return (
231+ < div className = "environment__column" >
232+ { this . _renderHiddenRightColumnComponents ( ) }
233+ { this . _renderHiddenLanguages ( ) }
234+ </ div >
235+ ) ;
236+ }
200237 _renderEnvironment ( ) {
201238 const {
202239 currentProject,
@@ -208,6 +245,7 @@ export default class Workspace extends React.Component {
208245 onResizableFlexDividerDrag,
209246 onStartDragColumnDivider,
210247 onStopDragColumnDivider,
248+ shouldRenderOutput,
211249 } = this . props ;
212250 if ( isNull ( currentProject ) ) {
213251 return < PopThrobber message = { t ( 'workspace.loading' ) } /> ;
@@ -218,7 +256,7 @@ export default class Workspace extends React.Component {
218256 return (
219257 < div className = "environment" >
220258 { this . _shouldRenderLeftColumn ( ) &&
221- < React . Fragment >
259+ < >
222260 < div
223261 className = "environment__column"
224262 ref = { _handleEditorsRef }
@@ -227,6 +265,8 @@ export default class Workspace extends React.Component {
227265 < div className = "environment__column-contents" >
228266 < div className = "environment__column-contents-inner" >
229267 < EditorsColumn />
268+ { ! this . _shouldRenderRightColumn ( ) &&
269+ this . _renderHiddenRightColumnComponents ( ) }
230270 { this . _renderHiddenLanguages ( ) }
231271 </ div >
232272 </ div >
@@ -246,25 +286,30 @@ export default class Workspace extends React.Component {
246286 ) }
247287 />
248288 </ DraggableCore >
249- </ React . Fragment >
289+ </ >
250290 }
251- < div
252- className = "environment__column"
253- ref = { _handleOutputRef }
254- style = { prefix ( {
255- flexGrow : resizableFlexGrow . get ( 1 ) ,
256- pointerEvents : ignorePointerEvents ? 'none' : 'all' ,
257- } ) }
258- >
259- < div className = "environment__column-contents" >
260- < div className = "environment__column-contents-inner" >
261- < Output />
262- { this . _renderHiddenRightColumnComponents ( ) }
263- { ! this . _shouldRenderLeftColumn ( ) &&
264- this . _renderHiddenLanguages ( ) }
291+ { this . _shouldRenderRightColumn ( ) &&
292+ < >
293+ < div
294+ className = "environment__column"
295+ ref = { _handleOutputRef }
296+ style = { prefix ( {
297+ flexGrow : resizableFlexGrow . get ( 1 ) ,
298+ pointerEvents : ignorePointerEvents ? 'none' : 'all' ,
299+ } ) }
300+ >
301+ < div className = "environment__column-contents" >
302+ < div className = "environment__column-contents-inner" >
303+ { shouldRenderOutput && < Output /> }
304+ { this . _renderHiddenRightColumnComponents ( ) }
305+ { ! this . _shouldRenderLeftColumn ( ) &&
306+ this . _renderHiddenLanguages ( ) }
307+ </ div >
308+ </ div >
265309 </ div >
266- </ div >
267- </ div >
310+ </ >
311+ }
312+ { this . _isEverythingHidden ( ) && this . _renderEverythingHidden ( ) }
268313 </ div >
269314 ) ;
270315 }
@@ -290,14 +335,16 @@ export default class Workspace extends React.Component {
290335
291336Workspace . propTypes = {
292337 currentProject : PropTypes . object ,
338+ hasErrors : PropTypes . bool . isRequired ,
293339 hiddenLanguages : PropTypes . array . isRequired ,
294340 isAnyTopBarMenuOpen : PropTypes . bool . isRequired ,
295341 isDraggingColumnDivider : PropTypes . bool . isRequired ,
296342 isEditingInstructions : PropTypes . bool . isRequired ,
297343 isFlexResizingSupported : PropTypes . bool . isRequired ,
298344 resizableFlexGrow : ImmutablePropTypes . list . isRequired ,
299345 resizableFlexRefs : PropTypes . array . isRequired ,
300- shouldShowCollapsedConsole : PropTypes . bool . isRequired ,
346+ shouldRenderOutput : PropTypes . bool . isRequired ,
347+ title : PropTypes . string . isRequired ,
301348 onApplicationLoaded : PropTypes . func . isRequired ,
302349 onClickInstructionsEditButton : PropTypes . func . isRequired ,
303350 onComponentToggle : PropTypes . func . isRequired ,
0 commit comments