Vscode: Review usage/overrides of get.*Actions on ViewPanes

Created on 5 Mar 2020  路  9Comments  路  Source: microsoft/vscode

With the introduction of View Menu Actions its possible for ViewPanes to accidentally override them. We should verify if this is happening and consider if we still want View Menu Actions with DnD for views already introduced.
/cc @eamodio

debt workbench-views

Most helpful comment

Ultimately it turned out not to be a big deal -- I converted Timeline back to using the MenuRegistry via registerAction2

All 9 comments

Looking a little more at this, there may be other uses?

@sbatten @sandy081 I wanted to follow up on a related topic, not sure if it is the same as this issue: today, Composite has methods getActions and getSecondaryActions (even getContextMenuActions?). We probably have other view related pieces with this kind of API.

That API should be deprecated imho and removed in favour of registering commands to Menu locations, as we e.g. do with all editor related actions in the editor tool bar. There should be no reason that any piece of UI is required to return actions upfront from these methods and every location should be capable of receiving actions with proper menu contributions and commands.

Example for the proper way of registering actions:

https://github.com/microsoft/vscode/blob/9f7b10088dbebd0d9f2197f6f98eead3123d3f2f/src/vs/workbench/browser/parts/editor/editor.contribution.ts#L496

@sbatten Not sure if I understand this debt item. Can you please elaborate more?

@bpasero Yes, I completely agree.

Thanks to @jrieken who provided support for contributing menu actions to any view. I discussed with him then and discussed about the future plan of moving away from get*Actions to MenuRegistry.

We can use this item to migrate.

I also quickly looked into this then and figured out that there are some actions which need ActionItem infrastructure. For eg:

  • FilterAction in problems panel
  • `Dropdowns in Terminal and Output panel etc.,

FWIW, When adding commands to the Timeline view -- I first added them through the MenuRegistry and context keys, but I ultimately removed all of that and moved to get*Actions because it was so much easier, especially dealing with internal view state. Also the Timeline has a custom list of "filters" which are the labels of the sources registered, so hooking that into getSecondaryActions was quite trivial, where as to provide that with the MenuRegistry would require a lot more indirection and complexity.

@eamodio Can you please provide an example of the complexity and indirection you mentioned. At the end you need to have a logical condition to show an action in get*Actions or through MenuRegistry. Is not it possible to compute the logical state in your view and set that as context?

Ultimately it turned out not to be a big deal -- I converted Timeline back to using the MenuRegistry via registerAction2

If I understand the desired action from @bpasero and @sandy081, this is the list of usages that should be migrated. Perhaps we can have view owners migrate during upcoming debt week.

https://github.com/microsoft/vscode/blob/15c02dca3a95c1515d112b0f1bc97b3090402fdb/src/vs/workbench/contrib/comments/browser/commentsView.ts#L122-L129

https://github.com/microsoft/vscode/blob/c650757bd48b936987f1be4350a8f359b1a76550/src/vs/workbench/contrib/debug/browser/breakpointsView.ts#L231-L237

https://github.com/microsoft/vscode/blob/7653d836944892f83ce9e1f95c1204bafa1aec31/src/vs/workbench/contrib/debug/browser/callStackView.ts#L182-L188

https://github.com/microsoft/vscode/blob/e3a36fa10c0d3ad278dbdc8cad449c6c79295d01/src/vs/workbench/contrib/debug/browser/repl.ts#L446-L456

https://github.com/microsoft/vscode/blob/9a2062ff5df3cf05c763b7ed6dadff26ddce00c4/src/vs/workbench/contrib/debug/browser/variablesView.ts#L153-L155

https://github.com/microsoft/vscode/blob/de3e5a4bf4beaf404d06d4375f6b5d3cd24c3ef8/src/vs/workbench/contrib/debug/browser/watchExpressionsView.ts#L153-L159

https://github.com/microsoft/vscode/blob/86161ffb9807b29959f40a4dc9c7ba3fe7b526dc/src/vs/workbench/contrib/extensions/browser/extensionsViews.ts#L923-L930

https://github.com/microsoft/vscode/blob/86161ffb9807b29959f40a4dc9c7ba3fe7b526dc/src/vs/workbench/contrib/extensions/browser/extensionsViews.ts#L1020-L1029

https://github.com/microsoft/vscode/blob/187dedbdc33e91b53dff9e3ed0f8278b27d113c7/src/vs/workbench/contrib/files/browser/views/explorerView.ts#L287-L298

https://github.com/microsoft/vscode/blob/7653d836944892f83ce9e1f95c1204bafa1aec31/src/vs/workbench/contrib/files/browser/views/openEditorsView.ts#L308-L314

https://github.com/microsoft/vscode/blob/7bd4ccb711d73e07509c86d6bdacc0070866c803/src/vs/workbench/contrib/outline/browser/outlinePane.ts#L411-L417

https://github.com/microsoft/vscode/blob/25e889af458c2be6b2ba2a3b5510b370586bb5c5/src/vs/workbench/contrib/remote/browser/tunnelView.ts#L575-L577

https://github.com/microsoft/vscode/blob/1a95f3134a8f81487f6680a4463e4b031e1db1ac/src/vs/workbench/contrib/scm/browser/repositoryPane.ts#L1062-L1073

https://github.com/microsoft/vscode/blob/79a1f5a5ca0c6c53db617aa1fa5a2396d2caebe2/src/vs/workbench/contrib/search/browser/searchView.ts#L1779-L1787

https://github.com/microsoft/vscode/blob/8a56212a5b6fde3ceb0e910d8cde74537a432503/src/vs/workbench/contrib/terminal/browser/terminalView.ts#L131-L145

https://github.com/microsoft/vscode/blob/7bd4ccb711d73e07509c86d6bdacc0070866c803/src/vs/workbench/contrib/outline/browser/outlinePane.ts#L419-L436

https://github.com/microsoft/vscode/blob/1a95f3134a8f81487f6680a4463e4b031e1db1ac/src/vs/workbench/contrib/scm/browser/repositoryPane.ts#L1074-L1076

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisdias picture chrisdias  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments

lukehoban picture lukehoban  路  3Comments

shanalikhan picture shanalikhan  路  3Comments

curtw picture curtw  路  3Comments