Skip to content

feat(sidebar): show welcome view if there are no tokens set

Tomas Vik requested to merge 281-welcome-view into main

Show a welcome screen in the sidebar the extension doesn't have any access tokens set up.

The GIF has got an outdated text, please see comment thread for the latest text.

no-token-welcome

The key idea

When there are not tokens, we'll set the extension context to:

vscode.commands.executeCommand('setContext', 'gitlab:noToken', true);
vscode.commands.executeCommand('setContext', 'gitlab:validState', false);

This context is then used by VS Code to show the welcome view. When the extension state is not valid, the following things happen:

  1. the issuable data provider (returning results of custom queries) returns []

    if (!extensionState.isValid()) {
      return [];
    }
  2. the current_branch data provider gets hidden thanks to this package.json configuration:

    "views": {
      "gitlab-workflow": [
        {
          "id": "currentBranchInfo",
          "name": "For current branch",
          "when": "gitlab:validState"
        }
      ]

    (the current_branch data provider also returns [] for consistency with issuable, but it shouldn't matter)

  3. VS Code replaces the content of the sidebar with the welcome view, because the issuable data provider returned [] and because the when condition on the welcome view is met:

    "viewsWelcome": [
      {
        "view": "issuesAndMrs",
        "contents": "Welcome to the GitLab Workflow extension. It seems ...",
        "when": "gitlab:noToken"
      }
    ],

Related to #281 (closed)

Edited by Tomas Vik

Merge request reports