Skip to content

Implement conditional visibility for custom views #29436

Closed

Description

Ability to define a condition when a custom view can be visible or not

Activity

  1. sandy081 commented on Jun 26, 2017

    @sandy081
    MemberAuthor

    Implemented as part of #27823

  2. sandy081 commented on Jun 26, 2017

    @sandy081
    MemberAuthor

    To verify:

    • Contribute a custom view using extension point views
    • Implement and register a tree data provider to this contributed view using the API.

    Or you can use our samples here - https://github.com/Microsoft/vscode-extension-samples/tree/master/tree-view-sample

    Verify that views are shown / hidden based on the when context value you provide while contributing the view.

  3. weinand commented on Jun 28, 2017

    @weinand
    Contributor

    Sandeep Somavarapu (@sandy081) I verified with my Loaded Scripts Explorer and it works great!

    "views": {
    	"explorer": [
    		{
    			"id": "extension.node-debug.loadedScriptsExplorer",
    			"name": "Loaded Scripts",
    			"when": "inDebugMode && debugType == 'node'"
    		}
    	]
    },
  4. orta commented on Oct 2, 2017

    @orta
    Contributor

    If like me you're trying to figure out how to make your viewport only show up if when your extension has declared something loaded, the key is using the "setContext" command: vscode.commands.executeCommand("setContext", "is-running-storybooks-vscode", true) which you can then use inside a "when":

        "views": {
          "explorer": [
            {
              "id": "storybook",
              "name": "Storybook",
              "when": "is-running-storybooks-vscode"
            }
          ]
        }

    ( Figure it out by reading this example )

  5. locked and limited conversation to collaborators on Nov 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apitree-viewsverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions