feat(sidebar): show welcome view if there are no tokens set
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.
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:
-
the
issuable
data provider (returning results of custom queries) returns[]
if (!extensionState.isValid()) { return []; }
-
the
current_branch
data provider gets hidden thanks to thispackage.json
configuration:"views": { "gitlab-workflow": [ { "id": "currentBranchInfo", "name": "For current branch", "when": "gitlab:validState" } ]
(the
current_branch
data provider also returns[]
for consistency withissuable
, but it shouldn't matter) -
VS Code replaces the content of the sidebar with the welcome view, because the
issuable
data provider returned[]
and because thewhen
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)