Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/commands/signIn.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import * as vscode from "vscode";
import {getSession} from "../auth/auth";
import {canReachGitHubAPI} from "../api/canReachGitHubAPI";
import {getGitHubContext} from "../git/repository";

export function registerSignIn(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand("github-actions.sign-in", async () => {
const session = await getSession(true);
if (session) {
const canReachAPI = await canReachGitHubAPI();
const ghContext = await getGitHubContext();
const hasGitHubRepos = ghContext && ghContext.repos.length > 0;

await vscode.commands.executeCommand("setContext", "github-actions.signed-in", true);
await vscode.commands.executeCommand("setContext", "github-actions.internet-access", canReachAPI);
await vscode.commands.executeCommand("setContext", "github-actions.has-repos", hasGitHubRepos);
}
})
);
Expand Down
7 changes: 6 additions & 1 deletion src/treeViews/treeViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ export async function initTreeViews(context: vscode.ExtensionContext, store: Run
vscode.commands.registerCommand("github-actions.explorer.refresh", async () => {
const canReachAPI = await canReachGitHubAPI();
await vscode.commands.executeCommand("setContext", "github-actions.internet-access", canReachAPI);
if (canReachAPI) {

const ghContext = await getGitHubContext();
const hasGitHubRepos = ghContext && ghContext.repos.length > 0;
await vscode.commands.executeCommand("setContext", "github-actions.has-repos", hasGitHubRepos);

if (canReachAPI && hasGitHubRepos) {
await workflowTreeProvider.refresh();
await settingsTreeProvider.refresh();
}
Expand Down