@@ -40,7 +40,9 @@ import {
4040 TYPE_FILE ,
4141 TYPE_WEBLINK ,
4242 TYPE_FOLDER ,
43- CLIENT_NAME_CONTENT_EXPLORER
43+ CLIENT_NAME_CONTENT_EXPLORER ,
44+ DEFAULT_VIEW_FILES ,
45+ DEFAULT_VIEW_RECENTS
4446} from '../../constants' ;
4547import type {
4648 BoxItem ,
@@ -50,7 +52,8 @@ import type {
5052 SortBy ,
5153 Access ,
5254 BoxItemPermission ,
53- Token
55+ Token ,
56+ DefaultView
5457} from '../../flowTypes' ;
5558import '../fonts.scss' ;
5659import '../base.scss' ;
@@ -85,6 +88,7 @@ type Props = {
8588 onSelect : Function ,
8689 onUpload : Function ,
8790 onNavigate : Function ,
91+ defaultView : DefaultView ,
8892 logoUrl ?: string ,
8993 sharedLink ?: string ,
9094 sharedLinkPassword ?: string
@@ -131,7 +135,8 @@ type DefaultProps = {|
131135 onCreate : Function ,
132136 onSelect : Function ,
133137 onUpload : Function ,
134- onNavigate : Function
138+ onNavigate : Function ,
139+ defaultView : DefaultView
135140| } ;
136141
137142class ContentExplorer extends Component < DefaultProps , Props , State > {
@@ -167,7 +172,8 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
167172 onCreate : noop ,
168173 onSelect : noop ,
169174 onUpload : noop ,
170- onNavigate : noop
175+ onNavigate : noop ,
176+ defaultView : DEFAULT_VIEW_FILES
171177 } ;
172178
173179 /**
@@ -237,11 +243,16 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
237243 * @return {void }
238244 */
239245 componentDidMount ( ) {
240- const { currentFolderId } : Props = this . props ;
246+ const { defaultView , currentFolderId } : Props = this . props ;
241247 this . rootElement = ( ( document . getElementById ( this . id ) : any ) : HTMLElement ) ;
242248 // $FlowFixMe: child will exist
243249 this . appElement = this . rootElement . firstElementChild ;
244- this . fetchFolder ( currentFolderId ) ;
250+
251+ if ( defaultView === DEFAULT_VIEW_RECENTS ) {
252+ this . showRecents ( true ) ;
253+ } else {
254+ this . fetchFolder ( currentFolderId ) ;
255+ }
245256 }
246257
247258 /**
@@ -541,7 +552,7 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
541552 * @param {Boolean|void } [forceFetch] To void cache
542553 * @return {void }
543554 */
544- recents = ( forceFetch : boolean = false ) => {
555+ showRecents = ( forceFetch : boolean = false ) => {
545556 const { rootFolderId } : Props = this . props ;
546557 const { sortBy, sortDirection } : State = this . state ;
547558
@@ -648,7 +659,7 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
648659 if ( view === VIEW_FOLDER ) {
649660 this . fetchFolder ( id , false ) ;
650661 } else if ( view === VIEW_RECENTS ) {
651- this . recents ( ) ;
662+ this . showRecents ( ) ;
652663 } else if ( view === VIEW_SEARCH ) {
653664 this . search ( searchQuery ) ;
654665 } else {
@@ -835,7 +846,7 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
835846 if ( view === VIEW_FOLDER ) {
836847 this . fetchFolder ( parentId , false ) ;
837848 } else if ( view === VIEW_RECENTS ) {
838- this . recents ( ) ;
849+ this . showRecents ( ) ;
839850 } else if ( view === VIEW_SEARCH ) {
840851 this . search ( searchQuery ) ;
841852 } else {
@@ -1100,7 +1111,7 @@ class ContentExplorer extends Component<DefaultProps, Props, State> {
11001111 break ;
11011112 case 'r' :
11021113 if ( this . globalModifier ) {
1103- this . recents ( ) ;
1114+ this . showRecents ( true ) ;
11041115 event . preventDefault ( ) ;
11051116 }
11061117 break ;
0 commit comments