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

[vscode] parse view contribution "when" clause context #6068

Merged
merged 1 commit into from
Sep 2, 2019
Merged

Conversation

vinokurig
Copy link
Contributor

@vinokurig vinokurig commented Aug 30, 2019

What it does

There is an affects() function of the ContextKeyChangeEvent: https://github.com/theia-ide/theia/blob/b0d8292226e4ca179ed6cfa8be4e47e354ff9f61/packages/core/src/browser/context-key-service.ts#L34-L36
which evaluates if the given set of context keys has a context key that was changed.
PluginViewRegistry listens to this event and passes when clause context from the view contribution:
https://github.com/theia-ide/theia/blob/b0d8292226e4ca179ed6cfa8be4e47e354ff9f61/packages/plugin-ext/src/main/browser/view/plugin-view-registry.ts#L144
Thewhen clause context from the view contribution is a string which may be a composed expression e.g. "when": "!config.githubPullRequests.showInSCM && config.git.enabled": https://github.com/microsoft/vscode-pull-request-github/blob/d91e778705cd5af0785c5a05184ebc550334b409/package.json#L182

A map with parsed when clauses was introduced to pass separate context keys to the affects() function of the ContextKeyChangeEvent.

fixes #6015

How to test

  1. Remove git from theia/examples/browser/package.json.
  2. Download vscode git extension.
  3. Create plugins folder in Theia's root and paste the plugin to it.
  4. Clone the vscode github extension and compile it.
  5. Start the github plugin as a Hosted Plugin.
  6. Click the GitHub icon.

Without this fix the GitHub panel is empty,

Review checklist

Reminder for reviewers

@vinokurig vinokurig added plug-in system issues related to the plug-in system vscode issues related to VSCode compatibility labels Aug 30, 2019
@vinokurig vinokurig requested review from azatsarynnyy, akosyakov and a team August 30, 2019 07:56
@akosyakov
Copy link
Member

@vinokurig It looks like a proper solution. 👍 I will test a bit later today.

@vinokurig vinokurig requested a review from a team August 30, 2019 09:02
@akosyakov
Copy link
Member

@azatsarynnyy Could you check with vscode github extension please? I never was able to configure it properly. I will check that other extensions are still working.

@azatsarynnyy
Copy link
Member

Sure. I'll check it.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vinokurig
Copy link
Contributor Author

@akosyakov

It does now work for json outline sample extension: https://github.com/microsoft/vscode-extension-samples/tree/master/tree-view-sample

Looks like this controls the json outline in vscode navigator, but is there such view in theia?

@akosyakov
Copy link
Member

@vinokurig it should be contributed by the sample extension, but it only appears when json file is opened and should disappear when it is closed

@azatsarynnyy
Copy link
Member

I've checked it with GitHub Pull Requests extension.

config.git.enabled is true && config.githubPullRequests.showInSCM is true

image

config.git.enabled is true && config.githubPullRequests.showInSCM is false

image

config.git.enabled is false && config.githubPullRequests.showInSCM is false

image

@azatsarynnyy
Copy link
Member

I'm not sure whether it's related to this PR but there's Sign in button on the view in VS Code.

image

I don't see it in Theia.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JSON outline works well now and the solution is better than what was before

I could not test whether it resolves the original issue though with github PR extension. @vinokurig please rely on @azatsarynnyy for it

@azatsarynnyy
Copy link
Member

It fixes the issue with GH PR extension.
Sign in button visibility is not in the scope of this issue.

@vinokurig vinokurig merged commit 144a1fe into master Sep 2, 2019
@vinokurig vinokurig deleted the GH-6015 branch September 2, 2019 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plug-in system issues related to the plug-in system vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vscode][plugin] Respect when condition for vscode plugins
3 participants