|
1 | 1 | import * as vscode from "vscode"; |
| 2 | +import {deactivateLanguageServer} from "../workflow/languageServer"; |
2 | 3 |
|
3 | 4 | const settingsKey = "github-actions"; |
| 5 | +const DEFAULT_GITHUB_API = "https://api.github.com"; |
4 | 6 |
|
5 | 7 | export function initConfiguration(context: vscode.ExtensionContext) { |
6 | 8 | context.subscriptions.push( |
7 | 9 | vscode.workspace.onDidChangeConfiguration(e => { |
8 | 10 | if (e.affectsConfiguration(getSettingsKey("workflows.pinned"))) { |
9 | 11 | pinnedWorkflowsChangeHandlers.forEach(h => h()); |
| 12 | + } else if (e.affectsConfiguration(getSettingsKey("use-enterprise"))) { |
| 13 | + updateLanguageServerApiUrl(); |
10 | 14 | } |
11 | 15 | }) |
12 | 16 | ); |
@@ -52,3 +56,19 @@ export function pinnedWorkflowsRefreshInterval(): number { |
52 | 56 | export function getRemoteName(): string { |
53 | 57 | return getConfiguration().get<string>(getSettingsKey("remote-name"), "origin"); |
54 | 58 | } |
| 59 | + |
| 60 | +export function isUseEnterprise(): boolean { |
| 61 | + return getConfiguration().get<boolean>(getSettingsKey("use-enterprise"), false); |
| 62 | +} |
| 63 | + |
| 64 | +export function getGitHubApiUri(): string { |
| 65 | + if (!isUseEnterprise()) return DEFAULT_GITHUB_API; |
| 66 | + const base = getConfiguration().get<string>("github-enterprise.uri", DEFAULT_GITHUB_API).replace(/\/$/, ""); |
| 67 | + return base === DEFAULT_GITHUB_API ? base : `${base}/api/v3`; |
| 68 | +} |
| 69 | + |
| 70 | +function updateLanguageServerApiUrl() { |
| 71 | + // deactivateLanguageServer(); |
| 72 | + // TODO: restart language server with new URL configured |
| 73 | + throw new Error("Can't yet change the api url parameter without restart."); |
| 74 | +} |
0 commit comments