@@ -34,7 +34,6 @@ type DefaultProps = {|
3434 locale : string ,
3535 version : string ,
3636 hasSidebar : boolean ,
37- showSidebar : boolean ,
3837 hasHeader : boolean ,
3938 className : string ,
4039 onLoad : Function ,
@@ -47,7 +46,6 @@ type Props = {
4746 locale : string ,
4847 version : string ,
4948 hasSidebar : boolean ,
50- showSidebar : boolean ,
5149 hasHeader : boolean ,
5250 apiHost : string ,
5351 appHost : string ,
@@ -68,8 +66,7 @@ type Props = {
6866} ;
6967
7068type State = {
71- file ?: BoxItem ,
72- showSidebar : boolean
69+ file ?: BoxItem
7370} ;
7471
7572class ContentPreview extends PureComponent < DefaultProps , Props , State > {
@@ -88,7 +85,6 @@ class ContentPreview extends PureComponent<DefaultProps, Props, State> {
8885 locale : DEFAULT_PREVIEW_LOCALE ,
8986 version : DEFAULT_PREVIEW_VERSION ,
9087 hasSidebar : false ,
91- showSidebar : true ,
9288 hasHeader : false ,
9389 onLoad : noop ,
9490 onNavigate : noop
@@ -102,9 +98,9 @@ class ContentPreview extends PureComponent<DefaultProps, Props, State> {
10298 */
10399 constructor ( props : Props ) {
104100 super ( props ) ;
105- const { file , cache , token , showSidebar , sharedLink , sharedLinkPassword , apiHost } = props ;
101+ const { file , cache , token , sharedLink , sharedLinkPassword , apiHost } = props ;
106102
107- this . state = { file, showSidebar } ;
103+ this . state = { file } ;
108104 this . id = uniqueid ( 'bcpr_' ) ;
109105 this . api = new API ( {
110106 cache,
@@ -138,19 +134,13 @@ class ContentPreview extends PureComponent<DefaultProps, Props, State> {
138134 */
139135 componentWillReceiveProps ( nextProps : Props ) : void {
140136 const { file, fileId, token } : Props = this . props ;
141- const { showSidebar } : State = this . state ;
142137
143138 const hasTokenChanged = nextProps . token !== token ;
144139 const hasFileIdChanged = nextProps . fileId !== fileId ;
145140 const hasFileChanged = nextProps . file !== file ;
146- const hasSidebarVisibilityChanged = nextProps . showSidebar !== showSidebar ;
147141
148142 const newState = { } ;
149143
150- if ( hasSidebarVisibilityChanged ) {
151- newState . showSidebar = nextProps . showSidebar ;
152- }
153-
154144 if ( hasTokenChanged || hasFileChanged || hasFileIdChanged ) {
155145 if ( hasFileChanged ) {
156146 newState . file = nextProps . file ;
@@ -312,18 +302,6 @@ class ContentPreview extends PureComponent<DefaultProps, Props, State> {
312302 this . fetchFile ( id ) ;
313303 }
314304
315- /**
316- * Handles showing or hiding of hasSidebar
317- *
318- * @private
319- * @return {void }
320- */
321- toggleSidebar = ( ) : void => {
322- this . setState ( ( prevState ) => ( {
323- showSidebar : ! prevState . showSidebar
324- } ) ) ;
325- } ;
326-
327305 /**
328306 * Tells the preview to resize
329307 *
@@ -401,29 +379,26 @@ class ContentPreview extends PureComponent<DefaultProps, Props, State> {
401379 */
402380 render ( ) {
403381 const { className, hasSidebar, hasHeader, onClose, getLocalizedMessage } : Props = this . props ;
404- const { file, showSidebar } : State = this . state ;
382+ const { file } : State = this . state ;
405383 return (
406384 < div id = { this . id } className = { `buik bcpr ${ className } ` } >
407385 { hasHeader &&
408386 < Header
409387 file = { file }
410- showSidebar = { showSidebar }
411388 showSidebarButton = { hasSidebar }
412- toggleSidebar = { this . toggleSidebar }
413389 onClose = { onClose }
414390 getLocalizedMessage = { getLocalizedMessage }
415391 /> }
416392 < div className = 'bcpr-body' >
417- < Measure bounds onResize = { this . onResize } >
418- { ( { measureRef } ) => < div ref = { measureRef } className = 'bcpr-content' /> }
419- </ Measure >
420393 { hasSidebar &&
421- showSidebar &&
422394 < Sidebar
423395 file = { file }
424396 getPreviewer = { this . getPreviewer }
425397 getLocalizedMessage = { getLocalizedMessage }
426398 /> }
399+ < Measure bounds onResize = { this . onResize } >
400+ { ( { measureRef } ) => < div ref = { measureRef } className = 'bcpr-content' /> }
401+ </ Measure >
427402 </ div >
428403 </ div >
429404 ) ;
0 commit comments