Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support scmResourceState in when clauses #90952

Merged
merged 11 commits into from Aug 9, 2020

Conversation

mjcrouch
Copy link
Contributor

@mjcrouch mjcrouch commented Feb 19, 2020

  • Adds contextValue?: string to the SourceControlResourceState
  • Allows when clause in scm/resourceState/context menus to use scmResourceState

Example - I have hidden the "revert" item from the inline and context menu using a context clause like scmResourceState == opened

Peek 2020-02-19 08-32

This PR fixes #86180

fixes microsoft#86180

* Adds `contextValue?: string` to the SourceControlResourceState
* Allows when clause in scm/resourceState/context menus to use scmResourceState
@mjcrouch mjcrouch marked this pull request as ready for review February 19, 2020 09:23
@joaomoreno joaomoreno added the scm General SCM compound issues label Feb 19, 2020
@joaomoreno
Copy link
Member

It's actually a perf issue if we create menus for each element. So... could we share them between elements if they have the same context key?

@mjcrouch
Copy link
Contributor Author

mjcrouch commented Feb 19, 2020

I'll have a look at that - my initial implementation was caching the resource menu by resource using a map in ISCMResourceGroup and disposing them with the group (but I realised this was pointless as the menu was ultimately only generated once per resource anyway).

I could make that a map based on contextValue instead so there is one menu per context per group. That way git for example would have exactly the same number of menus created as it does now

@mjcrouch
Copy link
Contributor Author

mjcrouch commented Feb 19, 2020

@joaomoreno - updated with one menu per context

@mjcrouch
Copy link
Contributor Author

mjcrouch commented Apr 9, 2020

@joaomoreno now the endgame is done, could we look at merging this if the approach is ok?

(I wasn't 100% sure if the the proposed API was the right place for this)

@mjcrouch
Copy link
Contributor Author

@joaomoreno any chance of getting this moved on please?

@mjcrouch
Copy link
Contributor Author

mjcrouch commented May 13, 2020

Is there anything blocking this? is it because I didn't write to santa claus this year? I knew I should have put this on my wishlist

@gjsjohnmurray
Copy link
Contributor

@joaomoreno I'd like to add my voice to the request to get this merged. Or is there a reason it can't go in?

@eamodio
Copy link
Contributor

eamodio commented Aug 4, 2020

@mjcrouch I haven't looked at this too deeply (so take this with a grain of salt) -- but is there a need for the createResourceMenu/ISCMResourceMenu work? Since the menus are currently already loaded per-group for an individual resource, I would think that just by adding the new contextKeyService.createKey('scmResourceState', resource.contextValue) calls would be enough.

Is that not the case?

@mjcrouch
Copy link
Contributor Author

mjcrouch commented Aug 4, 2020

@eamodio thanks for reviewing - it's been quite a while since I wrote the code so I'm stretching my memory, but iirc there is currently just one menu instance for each group, and getResourceMenu returned the group menu - ( called from here )

So in order to render different context items for different resource objects, we need to create a menu per contextValue in the group and then return the correct menu according to the contextValue on the object we've clicked / hovered on

@eamodio
Copy link
Contributor

eamodio commented Aug 4, 2020

@mjcrouch You might be right, but I would recommend giving it a shot to see if it works properly without it.

@mjcrouch
Copy link
Contributor Author

mjcrouch commented Aug 4, 2020

@eamodio I gave it a try (I think this may have been what I tried originally) - it does seem to work for the right click context menu, but does not work for the inline icons; they all end up with the same set of icons even if they have different contextValues.

At a total guess I wonder if there is some work done to update the items on right click that maybe is not done on hover for performance reasons

@eamodio
Copy link
Contributor

eamodio commented Aug 4, 2020

Hrm, I think it has to do with the connectPrimaryMenuToInlineActionBar calls in scmViewPane.ts -- @joaomoreno will no better as to why that is special.

@joaomoreno joaomoreno added this to the August 2020 milestone Aug 4, 2020
@joaomoreno
Copy link
Member

Assigning for August so I get a good look at this next week. 👍

@mjcrouch
Copy link
Contributor Author

mjcrouch commented Aug 6, 2020

just happened to notice #104089 - suspect there may pretty sure there will be a conflict when that gets merged :)

@joaomoreno
Copy link
Member

Yeah, for sure. No worries, I'll handle the conflicts. 👍

@joaomoreno
Copy link
Member

joaomoreno commented Aug 9, 2020

Thanks for the PR, @mjcrouch, it was really polished!👏 I merged it into the latest master and resolved all conflicts. There was a lot of refactorings on menus.ts for perf reasons.

@joaomoreno joaomoreno merged commit c466365 into microsoft:master Aug 9, 2020
@mjcrouch
Copy link
Contributor Author

mjcrouch commented Aug 9, 2020

thank you - this will really help to make my menus more usable :)

@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scm General SCM compound issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SCM: Support scmResourceState in when clauses
4 participants