@@ -32,7 +32,8 @@ define(function (require, exports, module) {
3232 Menus = require ( "command/Menus" ) ,
3333 Strings = require ( "strings" ) ,
3434 MainViewManager = require ( "view/MainViewManager" ) ,
35- CommandManager = require ( "command/CommandManager" ) ;
35+ CommandManager = require ( "command/CommandManager" ) ,
36+ WorkingSetView = require ( "project/WorkingSetView" ) ;
3637
3738 /**
3839 * Disables menu items present in items if enabled is true.
@@ -68,6 +69,14 @@ define(function (require, exports, module) {
6869 Commands . NAVIGATE_OPEN_IN_DEFAULT_APP ] ) ;
6970 } ) ;
7071 }
72+
73+ // Pin/Unpin logic: to hide the option when its not applicable
74+ const contextFile = WorkingSetView . getContext ( ) ;
75+ if ( contextFile ) {
76+ const isPinned = MainViewManager . isPathPinned ( MainViewManager . ACTIVE_PANE , contextFile . fullPath ) ;
77+ CommandManager . get ( Commands . FILE_PIN ) . setEnabled ( ! isPinned ) ;
78+ CommandManager . get ( Commands . FILE_UNPIN ) . setEnabled ( isPinned ) ;
79+ }
7180 }
7281
7382 const isBrowser = ! Phoenix . isNativeApp ;
@@ -320,8 +329,8 @@ define(function (require, exports, module) {
320329 subMenu . addMenuItem ( Commands . NAVIGATE_OPEN_IN_DEFAULT_APP ) ;
321330 }
322331 workingset_cmenu . addMenuDivider ( ) ;
323- workingset_cmenu . addMenuItem ( Commands . FILE_PIN ) ;
324- workingset_cmenu . addMenuItem ( Commands . FILE_UNPIN ) ;
332+ workingset_cmenu . addMenuItem ( Commands . FILE_PIN , null , null , null , { hideWhenCommandDisabled : true } ) ;
333+ workingset_cmenu . addMenuItem ( Commands . FILE_UNPIN , null , null , null , { hideWhenCommandDisabled : true } ) ;
325334 workingset_cmenu . addMenuDivider ( ) ;
326335 workingset_cmenu . addMenuItem ( Commands . FILE_COPY ) ;
327336 workingset_cmenu . addMenuItem ( Commands . FILE_COPY_PATH ) ;
0 commit comments