@@ -10,7 +10,7 @@ import { IAction, Separator } from 'vs/base/common/actions';
10
10
import { Emitter , Event } from 'vs/base/common/event' ;
11
11
import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
12
12
import { ScrollbarVisibility } from 'vs/base/common/scrollable' ;
13
- import { MenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
13
+ import { MenuEntryActionViewItem , SubmenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem' ;
14
14
import { IMenu , IMenuService , MenuId , MenuItemAction , SubmenuItemAction } from 'vs/platform/actions/common/actions' ;
15
15
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
16
16
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
@@ -21,13 +21,12 @@ import { SELECT_KERNEL_ID } from 'vs/workbench/contrib/notebook/browser/controll
21
21
import { NOTEBOOK_EDITOR_ID , NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
22
22
import { INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
23
23
import { NotebooKernelActionViewItem } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookKernelView' ;
24
- import { ActionViewWithLabel } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView' ;
24
+ import { ActionViewWithLabel , UnifiedSubmenuActionView } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView' ;
25
25
import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
26
26
import { IWorkbenchAssignmentService } from 'vs/workbench/services/assignment/common/assignmentService' ;
27
27
import { NotebookOptions } from 'vs/workbench/contrib/notebook/browser/notebookOptions' ;
28
- import { IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar' ;
28
+ import { IActionViewItem , IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar' ;
29
29
import { disposableTimeout } from 'vs/base/common/async' ;
30
- import { ActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems' ;
31
30
import { HiddenItemStrategy , IWorkbenchToolBarOptions , WorkbenchToolBar } from 'vs/platform/actions/browser/toolbar' ;
32
31
33
32
interface IActionModel {
@@ -73,15 +72,28 @@ class WorkbenchAlwaysLabelStrategy implements IActionLayoutStrategy {
73
72
constructor (
74
73
readonly notebookEditor : INotebookEditorDelegate ,
75
74
readonly editorToolbar : NotebookEditorWorkbenchToolbar ,
75
+ readonly goToMenu : IMenu ,
76
76
readonly instantiationService : IInstantiationService ) { }
77
77
78
- actionProvider ( action : IAction ) : ActionViewItem | undefined {
78
+ actionProvider ( action : IAction ) : IActionViewItem | undefined {
79
79
if ( action . id === SELECT_KERNEL_ID ) {
80
80
// this is being disposed by the consumer
81
81
return this . instantiationService . createInstance ( NotebooKernelActionViewItem , action , this . notebookEditor ) ;
82
82
}
83
83
84
- return action instanceof MenuItemAction ? this . instantiationService . createInstance ( ActionViewWithLabel , action , undefined ) : undefined ;
84
+ if ( action instanceof MenuItemAction ) {
85
+ return this . instantiationService . createInstance ( ActionViewWithLabel , action , undefined ) ;
86
+ }
87
+
88
+ if ( action instanceof SubmenuItemAction && action . item . submenu . id === MenuId . NotebookCellExecuteGoTo . id ) {
89
+ return this . instantiationService . createInstance ( UnifiedSubmenuActionView , action , undefined , true , {
90
+ getActions : ( ) => {
91
+ return this . goToMenu . getActions ( ) . find ( ( [ group ] ) => group === 'navigation/execute' ) ?. [ 1 ] ?? [ ] ;
92
+ }
93
+ } , this . actionProvider . bind ( this ) ) ;
94
+ }
95
+
96
+ return undefined ;
85
97
}
86
98
87
99
calculateActions ( leftToolbarContainerMaxWidth : number ) : { primaryActions : IAction [ ] ; secondaryActions : IAction [ ] } {
@@ -100,15 +112,32 @@ class WorkbenchNeverLabelStrategy implements IActionLayoutStrategy {
100
112
constructor (
101
113
readonly notebookEditor : INotebookEditorDelegate ,
102
114
readonly editorToolbar : NotebookEditorWorkbenchToolbar ,
115
+ readonly goToMenu : IMenu ,
103
116
readonly instantiationService : IInstantiationService ) { }
104
117
105
- actionProvider ( action : IAction ) : ActionViewItem | undefined {
118
+ actionProvider ( action : IAction ) : IActionViewItem | undefined {
106
119
if ( action . id === SELECT_KERNEL_ID ) {
107
120
// this is being disposed by the consumer
108
121
return this . instantiationService . createInstance ( NotebooKernelActionViewItem , action , this . notebookEditor ) ;
109
122
}
110
123
111
- return action instanceof MenuItemAction ? this . instantiationService . createInstance ( MenuEntryActionViewItem , action , undefined ) : undefined ;
124
+ if ( action instanceof MenuItemAction ) {
125
+ return this . instantiationService . createInstance ( MenuEntryActionViewItem , action , undefined ) ;
126
+ }
127
+
128
+ if ( action instanceof SubmenuItemAction ) {
129
+ if ( action . item . submenu . id === MenuId . NotebookCellExecuteGoTo . id ) {
130
+ return this . instantiationService . createInstance ( UnifiedSubmenuActionView , action , undefined , false , {
131
+ getActions : ( ) => {
132
+ return this . goToMenu . getActions ( ) . find ( ( [ group ] ) => group === 'navigation/execute' ) ?. [ 1 ] ?? [ ] ;
133
+ }
134
+ } , this . actionProvider . bind ( this ) ) ;
135
+ } else {
136
+ return this . instantiationService . createInstance ( SubmenuEntryActionViewItem , action , undefined ) ;
137
+ }
138
+ }
139
+
140
+ return undefined ;
112
141
}
113
142
114
143
calculateActions ( leftToolbarContainerMaxWidth : number ) : { primaryActions : IAction [ ] ; secondaryActions : IAction [ ] } {
@@ -127,19 +156,48 @@ class WorkbenchDynamicLabelStrategy implements IActionLayoutStrategy {
127
156
constructor (
128
157
readonly notebookEditor : INotebookEditorDelegate ,
129
158
readonly editorToolbar : NotebookEditorWorkbenchToolbar ,
159
+ readonly goToMenu : IMenu ,
130
160
readonly instantiationService : IInstantiationService ) { }
131
161
132
- actionProvider ( action : IAction ) : ActionViewItem | undefined {
162
+ actionProvider ( action : IAction ) : IActionViewItem | undefined {
133
163
if ( action . id === SELECT_KERNEL_ID ) {
134
164
// this is being disposed by the consumer
135
165
return this . instantiationService . createInstance ( NotebooKernelActionViewItem , action , this . notebookEditor ) ;
136
166
}
137
167
138
168
const a = this . editorToolbar . primaryActions . find ( a => a . action . id === action . id ) ;
139
169
if ( ! a || a . renderLabel ) {
140
- return action instanceof MenuItemAction ? this . instantiationService . createInstance ( ActionViewWithLabel , action , undefined ) : undefined ;
170
+ if ( action instanceof MenuItemAction ) {
171
+ return this . instantiationService . createInstance ( ActionViewWithLabel , action , undefined ) ;
172
+ }
173
+
174
+ if ( action instanceof SubmenuItemAction && action . item . submenu . id === MenuId . NotebookCellExecuteGoTo . id ) {
175
+ return this . instantiationService . createInstance ( UnifiedSubmenuActionView , action , undefined , true , {
176
+ getActions : ( ) => {
177
+ return this . goToMenu . getActions ( ) . find ( ( [ group ] ) => group === 'navigation/execute' ) ?. [ 1 ] ?? [ ] ;
178
+ }
179
+ } , this . actionProvider . bind ( this ) ) ;
180
+ }
181
+
182
+ return undefined ;
141
183
} else {
142
- return action instanceof MenuItemAction ? this . instantiationService . createInstance ( MenuEntryActionViewItem , action , undefined ) : undefined ;
184
+ if ( action instanceof MenuItemAction ) {
185
+ this . instantiationService . createInstance ( MenuEntryActionViewItem , action , undefined ) ;
186
+ }
187
+
188
+ if ( action instanceof SubmenuItemAction ) {
189
+ if ( action . item . submenu . id === MenuId . NotebookCellExecuteGoTo . id ) {
190
+ return this . instantiationService . createInstance ( UnifiedSubmenuActionView , action , undefined , false , {
191
+ getActions : ( ) => {
192
+ return this . goToMenu . getActions ( ) . find ( ( [ group ] ) => group === 'navigation/execute' ) ?. [ 1 ] ?? [ ] ;
193
+ }
194
+ } , this . actionProvider . bind ( this ) ) ;
195
+ } else {
196
+ return this . instantiationService . createInstance ( SubmenuEntryActionViewItem , action , undefined ) ;
197
+ }
198
+ }
199
+
200
+ return undefined ;
143
201
}
144
202
}
145
203
@@ -160,6 +218,7 @@ export class NotebookEditorWorkbenchToolbar extends Disposable {
160
218
private _notebookTopLeftToolbarContainer ! : HTMLElement ;
161
219
private _notebookTopRightToolbarContainer ! : HTMLElement ;
162
220
private _notebookGlobalActionsMenu ! : IMenu ;
221
+ private _executeGoToActionsMenu ! : IMenu ;
163
222
private _notebookLeftToolbar ! : WorkbenchToolBar ;
164
223
private _primaryActions : IActionModel [ ] ;
165
224
get primaryActions ( ) : IActionModel [ ] {
@@ -251,7 +310,7 @@ export class NotebookEditorWorkbenchToolbar extends Disposable {
251
310
252
311
private _registerNotebookActionsToolbar ( ) {
253
312
this . _notebookGlobalActionsMenu = this . _register ( this . menuService . createMenu ( this . notebookEditor . creationOptions . menuIds . notebookToolbar , this . contextKeyService ) ) ;
254
- this . _register ( this . _notebookGlobalActionsMenu ) ;
313
+ this . _executeGoToActionsMenu = this . _register ( this . menuService . createMenu ( MenuId . NotebookCellExecuteGoTo , this . contextKeyService ) ) ;
255
314
256
315
this . _useGlobalToolbar = this . notebookOptions . getDisplayOptions ( ) . globalToolbar ;
257
316
this . _renderLabel = this . _convertConfiguration ( this . configurationService . getValue ( NotebookSetting . globalToolbarShowLabel ) ) ;
@@ -379,13 +438,13 @@ export class NotebookEditorWorkbenchToolbar extends Disposable {
379
438
private _updateStrategy ( ) {
380
439
switch ( this . _renderLabel ) {
381
440
case RenderLabel . Always :
382
- this . _strategy = new WorkbenchAlwaysLabelStrategy ( this . notebookEditor , this , this . instantiationService ) ;
441
+ this . _strategy = new WorkbenchAlwaysLabelStrategy ( this . notebookEditor , this , this . _executeGoToActionsMenu , this . instantiationService ) ;
383
442
break ;
384
443
case RenderLabel . Never :
385
- this . _strategy = new WorkbenchNeverLabelStrategy ( this . notebookEditor , this , this . instantiationService ) ;
444
+ this . _strategy = new WorkbenchNeverLabelStrategy ( this . notebookEditor , this , this . _executeGoToActionsMenu , this . instantiationService ) ;
386
445
break ;
387
446
case RenderLabel . Dynamic :
388
- this . _strategy = new WorkbenchDynamicLabelStrategy ( this . notebookEditor , this , this . instantiationService ) ;
447
+ this . _strategy = new WorkbenchDynamicLabelStrategy ( this . notebookEditor , this , this . _executeGoToActionsMenu , this . instantiationService ) ;
389
448
break ;
390
449
}
391
450
}
0 commit comments