@@ -38,6 +38,15 @@ import "./preview.scss";
3838const MaxFileSize = 1024 * 1024 * 10 ; // 10MB
3939const MaxCSVSize = 1024 * 1024 * 1 ; // 1MB
4040
41+ // TODO drive this using config
42+ const BOOKMARKS : { label : string ; path : string } [ ] = [
43+ { label : "Home" , path : "~" } ,
44+ { label : "Desktop" , path : "~/Desktop" } ,
45+ { label : "Downloads" , path : "~/Downloads" } ,
46+ { label : "Documents" , path : "~/Documents" } ,
47+ { label : "Root" , path : "/" } ,
48+ ] ;
49+
4150type SpecializedViewProps = {
4251 model : PreviewModel ;
4352 parentRef : React . RefObject < HTMLDivElement > ;
@@ -185,27 +194,10 @@ export class PreviewModel implements ViewModel {
185194 elemtype : "iconbutton" ,
186195 icon : "folder-open" ,
187196 longClick : ( e : React . MouseEvent < any > ) => {
188- const menuItems : ContextMenuItem [ ] = [ ] ;
189- menuItems . push ( {
190- label : "Go to Home" ,
191- click : ( ) => this . goHistory ( "~" ) ,
192- } ) ;
193- menuItems . push ( {
194- label : "Go to Desktop" ,
195- click : ( ) => this . goHistory ( "~/Desktop" ) ,
196- } ) ;
197- menuItems . push ( {
198- label : "Go to Downloads" ,
199- click : ( ) => this . goHistory ( "~/Downloads" ) ,
200- } ) ;
201- menuItems . push ( {
202- label : "Go to Documents" ,
203- click : ( ) => this . goHistory ( "~/Documents" ) ,
204- } ) ;
205- menuItems . push ( {
206- label : "Go to Root" ,
207- click : ( ) => this . goHistory ( "/" ) ,
208- } ) ;
197+ const menuItems : ContextMenuItem [ ] = BOOKMARKS . map ( ( bookmark ) => ( {
198+ label : `Go to ${ bookmark . label } (${ bookmark . path } )` ,
199+ click : ( ) => this . goHistory ( bookmark . path ) ,
200+ } ) ) ;
209201 ContextMenuModel . showContextMenu ( menuItems , e ) ;
210202 } ,
211203 } ;
0 commit comments