@microsoft/vscode-azext-github 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +7 -0
- package/out/src/GitHubContext.d.ts +9 -0
- package/out/src/GitHubContext.js +7 -0
- package/out/src/constants.d.ts +4 -0
- package/out/src/constants.js +13 -0
- package/out/src/createOctokitClient.d.ts +9 -0
- package/out/src/createOctokitClient.js +36 -0
- package/out/src/extensionVariables.d.ts +13 -0
- package/out/src/extensionVariables.js +43 -0
- package/out/src/index.d.ts +15 -0
- package/out/src/index.js +39 -0
- package/out/src/tree/ActionItem.d.ts +19 -0
- package/out/src/tree/ActionItem.js +81 -0
- package/out/src/tree/ActionsItemBase.d.ts +59 -0
- package/out/src/tree/ActionsItemBase.js +114 -0
- package/out/src/tree/JobItem.d.ts +16 -0
- package/out/src/tree/JobItem.js +51 -0
- package/out/src/tree/StepItem.d.ts +15 -0
- package/out/src/tree/StepItem.js +33 -0
- package/out/src/utils/actionUtils.d.ts +35 -0
- package/out/src/utils/actionUtils.js +128 -0
- package/out/src/utils/getGitHubAccessToken.d.ts +1 -0
- package/out/src/utils/getGitHubAccessToken.js +41 -0
- package/out/src/utils/gitHubUrlParse.d.ts +23 -0
- package/out/src/utils/gitHubUrlParse.js +23 -0
- package/out/src/wizard/GitHubBranchListStep.d.ts +13 -0
- package/out/src/wizard/GitHubBranchListStep.js +71 -0
- package/out/src/wizard/GitHubOrgListStep.d.ts +11 -0
- package/out/src/wizard/GitHubOrgListStep.js +52 -0
- package/out/src/wizard/GitHubRepositoryListStep.d.ts +13 -0
- package/out/src/wizard/GitHubRepositoryListStep.js +77 -0
- package/out/src/wrappers/getActions.d.ts +9 -0
- package/out/src/wrappers/getActions.js +28 -0
- package/out/src/wrappers/getAuthenticatedUser.d.ts +7 -0
- package/out/src/wrappers/getAuthenticatedUser.js +28 -0
- package/out/src/wrappers/getBranches.d.ts +11 -0
- package/out/src/wrappers/getBranches.js +28 -0
- package/out/src/wrappers/getJobs.d.ts +10 -0
- package/out/src/wrappers/getJobs.js +28 -0
- package/out/src/wrappers/getOrgs.d.ts +7 -0
- package/out/src/wrappers/getOrgs.js +28 -0
- package/out/src/wrappers/getRepositories.d.ts +16 -0
- package/out/src/wrappers/getRepositories.js +38 -0
- package/package.json +53 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IActionContext } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
export interface GitHubContext extends IActionContext {
|
|
3
|
+
gitHubAccessToken?: string;
|
|
4
|
+
gitHubOrg?: string;
|
|
5
|
+
gitHubRepository?: string;
|
|
6
|
+
gitHubRepositoryOwner?: string;
|
|
7
|
+
gitHubRepositoryUrl?: string;
|
|
8
|
+
gitHubBranch?: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
//# sourceMappingURL=GitHubContext.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.loadMoreQp = exports.gitHubScopes = exports.gitHubAuthProviderId = void 0;
|
|
8
|
+
const vscode_1 = require("vscode");
|
|
9
|
+
exports.gitHubAuthProviderId = 'github';
|
|
10
|
+
// Provide same scopes as the GitHub extension so we don't have to prompt for auth again
|
|
11
|
+
exports.gitHubScopes = ['repo', 'workflow', 'user:email', 'read:user'];
|
|
12
|
+
exports.loadMoreQp = { label: vscode_1.l10n.t('$(sync) Load More'), data: undefined, suppressPersistence: true };
|
|
13
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Octokit } from "@octokit/rest";
|
|
2
|
+
import type { GitHubContext } from "./GitHubContext";
|
|
3
|
+
/**
|
|
4
|
+
* Can be used to initialize a new Octokit client.
|
|
5
|
+
*
|
|
6
|
+
* Note: Typically does not need to be called directly by client extensions
|
|
7
|
+
* unless implementing a custom behavior.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createOctokitClient(context: GitHubContext): Promise<Octokit>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.createOctokitClient = void 0;
|
|
17
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
18
|
+
const rest_1 = require("@octokit/rest");
|
|
19
|
+
const getGitHubAccessToken_1 = require("./utils/getGitHubAccessToken");
|
|
20
|
+
/**
|
|
21
|
+
* Can be used to initialize a new Octokit client.
|
|
22
|
+
*
|
|
23
|
+
* Note: Typically does not need to be called directly by client extensions
|
|
24
|
+
* unless implementing a custom behavior.
|
|
25
|
+
*/
|
|
26
|
+
function createOctokitClient(context) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
context.gitHubAccessToken || (context.gitHubAccessToken = yield (0, getGitHubAccessToken_1.getGitHubAccessToken)());
|
|
29
|
+
return new rest_1.Octokit({
|
|
30
|
+
userAgent: (0, vscode_azext_utils_1.appendExtensionUserAgent)(),
|
|
31
|
+
auth: context.gitHubAccessToken
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
exports.createOctokitClient = createOctokitClient;
|
|
36
|
+
//# sourceMappingURL=createOctokitClient.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UIExtensionVariables } from '@microsoft/vscode-azext-utils';
|
|
2
|
+
interface IAzureUtilsExtensionVariables extends UIExtensionVariables {
|
|
3
|
+
prefix: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Container for common extension variables used throughout the github package. They must be initialized with `registerGitHubExtensionVariables`
|
|
7
|
+
*/
|
|
8
|
+
export declare let ext: IAzureUtilsExtensionVariables;
|
|
9
|
+
/**
|
|
10
|
+
* Call this to register common variables used throughout the github package.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerGitHubExtensionVariables(extVars: IAzureUtilsExtensionVariables): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.registerGitHubExtensionVariables = exports.ext = void 0;
|
|
8
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
9
|
+
const vscode_1 = require("vscode");
|
|
10
|
+
class UninitializedExtensionVariables {
|
|
11
|
+
constructor() {
|
|
12
|
+
this._error = new Error(vscode_1.l10n.t('"registerGitHubExtensionVariables" must be called before using the vscode-azext-github package.'));
|
|
13
|
+
}
|
|
14
|
+
get context() {
|
|
15
|
+
throw this._error;
|
|
16
|
+
}
|
|
17
|
+
get outputChannel() {
|
|
18
|
+
throw this._error;
|
|
19
|
+
}
|
|
20
|
+
get ui() {
|
|
21
|
+
throw this._error;
|
|
22
|
+
}
|
|
23
|
+
get prefix() {
|
|
24
|
+
throw this._error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Container for common extension variables used throughout the github package. They must be initialized with `registerGitHubExtensionVariables`
|
|
29
|
+
*/
|
|
30
|
+
exports.ext = new UninitializedExtensionVariables();
|
|
31
|
+
/**
|
|
32
|
+
* Call this to register common variables used throughout the github package.
|
|
33
|
+
*/
|
|
34
|
+
function registerGitHubExtensionVariables(extVars) {
|
|
35
|
+
if (exports.ext === extVars) {
|
|
36
|
+
// already registered
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
exports.ext = extVars;
|
|
40
|
+
(0, vscode_azext_utils_1.registerUIExtensionVariables)(extVars);
|
|
41
|
+
}
|
|
42
|
+
exports.registerGitHubExtensionVariables = registerGitHubExtensionVariables;
|
|
43
|
+
//# sourceMappingURL=extensionVariables.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from './extensionVariables';
|
|
2
|
+
export * from './GitHubContext';
|
|
3
|
+
export * from './createOctokitClient';
|
|
4
|
+
export * from './utils/getGitHubAccessToken';
|
|
5
|
+
export * from './utils/gitHubUrlParse';
|
|
6
|
+
export * from './tree/ActionsItemBase';
|
|
7
|
+
export * from './wizard/GitHubBranchListStep';
|
|
8
|
+
export * from './wizard/GitHubOrgListStep';
|
|
9
|
+
export * from './wizard/GitHubRepositoryListStep';
|
|
10
|
+
export * from './wrappers/getActions';
|
|
11
|
+
export * from './wrappers/getAuthenticatedUser';
|
|
12
|
+
export * from './wrappers/getBranches';
|
|
13
|
+
export * from './wrappers/getJobs';
|
|
14
|
+
export * from './wrappers/getOrgs';
|
|
15
|
+
export * from './wrappers/getRepositories';
|
package/out/src/index.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
__exportStar(require("./extensionVariables"), exports);
|
|
22
|
+
__exportStar(require("./GitHubContext"), exports);
|
|
23
|
+
__exportStar(require("./createOctokitClient"), exports);
|
|
24
|
+
__exportStar(require("./utils/getGitHubAccessToken"), exports);
|
|
25
|
+
__exportStar(require("./utils/gitHubUrlParse"), exports);
|
|
26
|
+
// Tree Items
|
|
27
|
+
__exportStar(require("./tree/ActionsItemBase"), exports);
|
|
28
|
+
// Wizard Steps
|
|
29
|
+
__exportStar(require("./wizard/GitHubBranchListStep"), exports);
|
|
30
|
+
__exportStar(require("./wizard/GitHubOrgListStep"), exports);
|
|
31
|
+
__exportStar(require("./wizard/GitHubRepositoryListStep"), exports);
|
|
32
|
+
// Octokit Wrappers
|
|
33
|
+
__exportStar(require("./wrappers/getActions"), exports);
|
|
34
|
+
__exportStar(require("./wrappers/getAuthenticatedUser"), exports);
|
|
35
|
+
__exportStar(require("./wrappers/getBranches"), exports);
|
|
36
|
+
__exportStar(require("./wrappers/getJobs"), exports);
|
|
37
|
+
__exportStar(require("./wrappers/getOrgs"), exports);
|
|
38
|
+
__exportStar(require("./wrappers/getRepositories"), exports);
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TreeElementBase } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
import type { ViewPropertiesModel } from "@microsoft/vscode-azureresources-api";
|
|
3
|
+
import { TreeItem } from "vscode";
|
|
4
|
+
import { ActionWorkflowRuns } from "../wrappers/getActions";
|
|
5
|
+
export declare class ActionItem implements TreeElementBase {
|
|
6
|
+
readonly parentResourceId: string;
|
|
7
|
+
readonly extensionPrefixContextValue: string;
|
|
8
|
+
readonly actionWorkflowRuns: ActionWorkflowRuns;
|
|
9
|
+
static readonly contextValueSuffix: string;
|
|
10
|
+
static readonly completedContextValue: string;
|
|
11
|
+
static readonly inProgressContextValue: string;
|
|
12
|
+
constructor(parentResourceId: string, extensionPrefixContextValue: string, actionWorkflowRuns: ActionWorkflowRuns);
|
|
13
|
+
id: string;
|
|
14
|
+
label: string;
|
|
15
|
+
viewProperties: ViewPropertiesModel;
|
|
16
|
+
private get contextValue();
|
|
17
|
+
getTreeItem(): TreeItem;
|
|
18
|
+
getChildren(): Promise<TreeElementBase[]>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ActionItem = void 0;
|
|
17
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
18
|
+
const vscode_1 = require("vscode");
|
|
19
|
+
const actionUtils_1 = require("../utils/actionUtils");
|
|
20
|
+
const gitHubUrlParse_1 = require("../utils/gitHubUrlParse");
|
|
21
|
+
const getJobs_1 = require("../wrappers/getJobs");
|
|
22
|
+
const JobItem_1 = require("./JobItem");
|
|
23
|
+
class ActionItem {
|
|
24
|
+
constructor(parentResourceId, extensionPrefixContextValue, actionWorkflowRuns) {
|
|
25
|
+
var _a;
|
|
26
|
+
this.parentResourceId = parentResourceId;
|
|
27
|
+
this.extensionPrefixContextValue = extensionPrefixContextValue;
|
|
28
|
+
this.actionWorkflowRuns = actionWorkflowRuns;
|
|
29
|
+
this.id = `${this.parentResourceId}/${this.actionWorkflowRuns.id}`;
|
|
30
|
+
this.label = ((_a = this.actionWorkflowRuns.head_commit) === null || _a === void 0 ? void 0 : _a.message) || this.actionWorkflowRuns.head_sha;
|
|
31
|
+
this.viewProperties = {
|
|
32
|
+
data: this.actionWorkflowRuns,
|
|
33
|
+
label: this.label,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
get contextValue() {
|
|
37
|
+
const actionTreeItemContextValue = `${this.extensionPrefixContextValue}${ActionItem.contextValueSuffix}`;
|
|
38
|
+
const values = [actionTreeItemContextValue];
|
|
39
|
+
if ((0, vscode_azext_utils_1.nonNullProp)(this.actionWorkflowRuns, 'status') === actionUtils_1.Status.Completed) {
|
|
40
|
+
values.push(ActionItem.completedContextValue);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
values.push(ActionItem.inProgressContextValue);
|
|
44
|
+
}
|
|
45
|
+
return (0, vscode_azext_utils_1.createContextValue)(values);
|
|
46
|
+
}
|
|
47
|
+
getTreeItem() {
|
|
48
|
+
return {
|
|
49
|
+
id: this.id,
|
|
50
|
+
label: this.label,
|
|
51
|
+
description: this.actionWorkflowRuns.event,
|
|
52
|
+
iconPath: (0, actionUtils_1.getActionBasedIconPath)(this.actionWorkflowRuns),
|
|
53
|
+
contextValue: this.contextValue,
|
|
54
|
+
collapsibleState: vscode_1.TreeItemCollapsibleState.Collapsed
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
getChildren() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const jobsData = yield (0, vscode_azext_utils_1.callWithTelemetryAndErrorHandling)('getActionChildren', (context) => __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const { ownerOrOrganization, repositoryName } = (0, gitHubUrlParse_1.gitHubUrlParse)(this.actionWorkflowRuns.repository.html_url);
|
|
61
|
+
const getJobsParams = {
|
|
62
|
+
owner: (0, vscode_azext_utils_1.nonNullValue)(ownerOrOrganization),
|
|
63
|
+
repo: (0, vscode_azext_utils_1.nonNullValue)(repositoryName),
|
|
64
|
+
run_id: this.actionWorkflowRuns.id
|
|
65
|
+
};
|
|
66
|
+
return yield (0, getJobs_1.getJobs)(context, getJobsParams);
|
|
67
|
+
}));
|
|
68
|
+
if (jobsData === null || jobsData === void 0 ? void 0 : jobsData.total_count) {
|
|
69
|
+
return jobsData.jobs.map((job) => new JobItem_1.JobItem(this.id, this.extensionPrefixContextValue, job));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.ActionItem = ActionItem;
|
|
78
|
+
ActionItem.contextValueSuffix = 'ActionItem';
|
|
79
|
+
ActionItem.completedContextValue = 'actionState:completed';
|
|
80
|
+
ActionItem.inProgressContextValue = 'actionState:inProgress';
|
|
81
|
+
//# sourceMappingURL=ActionItem.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TreeElementBase } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
import { TreeItem } from "vscode";
|
|
3
|
+
export interface GitHubSourceControl {
|
|
4
|
+
repoUrl: string;
|
|
5
|
+
repoBranch?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ConnectToGitHubCommand {
|
|
8
|
+
/**
|
|
9
|
+
* The command id to call for initiating the setup of source control for the client extension.
|
|
10
|
+
* The client extension should provide its own connect implementation to call.
|
|
11
|
+
*
|
|
12
|
+
* @example 'containerApps.connectToGitHub'
|
|
13
|
+
*/
|
|
14
|
+
commandId: string;
|
|
15
|
+
/**
|
|
16
|
+
* The list of corresponding args to provide when the command is called
|
|
17
|
+
*/
|
|
18
|
+
commandArgs: unknown[] | undefined;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Base tree node for setting up and tracking GitHub Actions in the tree view.
|
|
22
|
+
* Branching children will be automatically setup and included to track actions, jobs, and steps.
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class ActionsItemBase implements TreeElementBase {
|
|
25
|
+
readonly parentId: string;
|
|
26
|
+
readonly contextValueExtensionPrefix: string;
|
|
27
|
+
static readonly contextValueSuffix: string;
|
|
28
|
+
static readonly connectedContextValue: string;
|
|
29
|
+
static readonly unconnectedContextValue: string;
|
|
30
|
+
static readonly idSuffix: string;
|
|
31
|
+
/**
|
|
32
|
+
* @param parentId A unique identifier corresponding to the id of the parent tree node
|
|
33
|
+
* @param contextValueExtensionPrefix The extension prefix used in constructing context values for the 'ActionsItem'
|
|
34
|
+
* and its children. Passing 'containerApps' becomes `containerApps${ActionsItemBase.contextValueSuffix}`.
|
|
35
|
+
*/
|
|
36
|
+
constructor(parentId: string, contextValueExtensionPrefix: string);
|
|
37
|
+
/**
|
|
38
|
+
* Constructed using the format: `${this.parentId}/${ActionsTreeItemBase.idSuffix}`
|
|
39
|
+
*/
|
|
40
|
+
readonly id: string;
|
|
41
|
+
readonly label: string;
|
|
42
|
+
private getContextValue;
|
|
43
|
+
getTreeItem(): Promise<TreeItem>;
|
|
44
|
+
getChildren(): Promise<TreeElementBase[]>;
|
|
45
|
+
/**
|
|
46
|
+
* An optional method that the client extension may provide to initiate connection to a GitHub repository.
|
|
47
|
+
*
|
|
48
|
+
* The 'ActionsTreeItem' will display a generic tree item when no connection is detected (e.g. 'Connect to a GitHub Repository...').
|
|
49
|
+
* This tree item becomes an entrypoint for initiating a source control connection.
|
|
50
|
+
*
|
|
51
|
+
* When no method is supplied, clicking on the generic tree item does nothing.
|
|
52
|
+
*/
|
|
53
|
+
getConnectToGitHubCommand?(): Promise<ConnectToGitHubCommand>;
|
|
54
|
+
/**
|
|
55
|
+
* A required method for obtaining the connected GitHub repository's data.
|
|
56
|
+
* If no repository is connected, return undefined.
|
|
57
|
+
*/
|
|
58
|
+
abstract getSourceControl(): Promise<GitHubSourceControl | undefined>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.ActionsItemBase = void 0;
|
|
17
|
+
const vscode_azext_utils_1 = require("@microsoft/vscode-azext-utils");
|
|
18
|
+
const vscode_1 = require("vscode");
|
|
19
|
+
const gitHubUrlParse_1 = require("../utils/gitHubUrlParse");
|
|
20
|
+
const getActions_1 = require("../wrappers/getActions");
|
|
21
|
+
const ActionItem_1 = require("./ActionItem");
|
|
22
|
+
/**
|
|
23
|
+
* Base tree node for setting up and tracking GitHub Actions in the tree view.
|
|
24
|
+
* Branching children will be automatically setup and included to track actions, jobs, and steps.
|
|
25
|
+
*/
|
|
26
|
+
class ActionsItemBase {
|
|
27
|
+
/**
|
|
28
|
+
* @param parentId A unique identifier corresponding to the id of the parent tree node
|
|
29
|
+
* @param contextValueExtensionPrefix The extension prefix used in constructing context values for the 'ActionsItem'
|
|
30
|
+
* and its children. Passing 'containerApps' becomes `containerApps${ActionsItemBase.contextValueSuffix}`.
|
|
31
|
+
*/
|
|
32
|
+
constructor(parentId, contextValueExtensionPrefix) {
|
|
33
|
+
this.parentId = parentId;
|
|
34
|
+
this.contextValueExtensionPrefix = contextValueExtensionPrefix;
|
|
35
|
+
/**
|
|
36
|
+
* Constructed using the format: `${this.parentId}/${ActionsTreeItemBase.idSuffix}`
|
|
37
|
+
*/
|
|
38
|
+
this.id = `${this.parentId}/${ActionsItemBase.idSuffix}`;
|
|
39
|
+
this.label = 'Actions';
|
|
40
|
+
}
|
|
41
|
+
getContextValue(isConnected) {
|
|
42
|
+
const actionsTreeItemContextValue = `${this.contextValueExtensionPrefix}${ActionsItemBase.contextValueSuffix}`;
|
|
43
|
+
const values = [actionsTreeItemContextValue];
|
|
44
|
+
values.push(isConnected ? ActionsItemBase.connectedContextValue : ActionsItemBase.unconnectedContextValue);
|
|
45
|
+
return (0, vscode_azext_utils_1.createContextValue)(values);
|
|
46
|
+
}
|
|
47
|
+
getTreeItem() {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
+
const isConnected = !!(yield this.getSourceControl());
|
|
50
|
+
return {
|
|
51
|
+
id: this.id,
|
|
52
|
+
label: this.label,
|
|
53
|
+
description: isConnected ? vscode_1.l10n.t('Connected') : '',
|
|
54
|
+
iconPath: new vscode_1.ThemeIcon('github-inverted'),
|
|
55
|
+
contextValue: this.getContextValue(isConnected),
|
|
56
|
+
collapsibleState: vscode_1.TreeItemCollapsibleState.Collapsed,
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
getChildren() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const sourceControl = yield this.getSourceControl();
|
|
63
|
+
const actionsListWorkflowRuns = yield (0, vscode_azext_utils_1.callWithTelemetryAndErrorHandling)('getActionsChildren', (context) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
var _a;
|
|
65
|
+
if (!sourceControl) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const { ownerOrOrganization, repositoryName } = (0, gitHubUrlParse_1.gitHubUrlParse)(sourceControl.repoUrl);
|
|
69
|
+
const actionWorkflowRunsParams = {
|
|
70
|
+
owner: (0, vscode_azext_utils_1.nonNullValue)(ownerOrOrganization),
|
|
71
|
+
repo: (0, vscode_azext_utils_1.nonNullValue)(repositoryName),
|
|
72
|
+
branch: (_a = sourceControl.repoBranch) !== null && _a !== void 0 ? _a : 'main',
|
|
73
|
+
page: 1,
|
|
74
|
+
};
|
|
75
|
+
context.errorHandling.suppressDisplay = true;
|
|
76
|
+
return yield (0, getActions_1.getActions)(context, actionWorkflowRunsParams);
|
|
77
|
+
}));
|
|
78
|
+
if (actionsListWorkflowRuns === null || actionsListWorkflowRuns === void 0 ? void 0 : actionsListWorkflowRuns.total_count) {
|
|
79
|
+
return actionsListWorkflowRuns.workflow_runs.map((awr) => new ActionItem_1.ActionItem(this.id, this.contextValueExtensionPrefix, awr));
|
|
80
|
+
}
|
|
81
|
+
else if (sourceControl) {
|
|
82
|
+
// If we are able to detect a connection but fail to retrieve a list of actions
|
|
83
|
+
return [
|
|
84
|
+
(0, vscode_azext_utils_1.createGenericElement)({
|
|
85
|
+
contextValue: 'noActionsDetected',
|
|
86
|
+
id: `${this.parentId}/noActionsDetected`,
|
|
87
|
+
label: vscode_1.l10n.t('No actions detected'),
|
|
88
|
+
})
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
let command;
|
|
93
|
+
if (this.getConnectToGitHubCommand) {
|
|
94
|
+
command = yield this.getConnectToGitHubCommand();
|
|
95
|
+
}
|
|
96
|
+
return [
|
|
97
|
+
(0, vscode_azext_utils_1.createGenericElement)({
|
|
98
|
+
contextValue: 'connectToGitHub',
|
|
99
|
+
id: `${this.parentId}/connectToGitHub`,
|
|
100
|
+
label: vscode_1.l10n.t('Connect to a GitHub Repository...'),
|
|
101
|
+
commandId: command === null || command === void 0 ? void 0 : command.commandId,
|
|
102
|
+
commandArgs: command === null || command === void 0 ? void 0 : command.commandArgs
|
|
103
|
+
})
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.ActionsItemBase = ActionsItemBase;
|
|
110
|
+
ActionsItemBase.contextValueSuffix = 'ActionsItem';
|
|
111
|
+
ActionsItemBase.connectedContextValue = 'actionsConnected:true';
|
|
112
|
+
ActionsItemBase.unconnectedContextValue = 'actionsConnected:false';
|
|
113
|
+
ActionsItemBase.idSuffix = 'actions';
|
|
114
|
+
//# sourceMappingURL=ActionsItemBase.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TreeElementBase } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
import type { ViewPropertiesModel } from "@microsoft/vscode-azureresources-api";
|
|
3
|
+
import { TreeItem } from "vscode";
|
|
4
|
+
import { Job } from "../wrappers/getJobs";
|
|
5
|
+
export declare class JobItem implements TreeElementBase {
|
|
6
|
+
readonly parentResourceId: string;
|
|
7
|
+
readonly extensionPrefixContextValue: string;
|
|
8
|
+
readonly job: Job;
|
|
9
|
+
static contextValueSuffix: string;
|
|
10
|
+
constructor(parentResourceId: string, extensionPrefixContextValue: string, job: Job);
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
viewProperties: ViewPropertiesModel;
|
|
14
|
+
getTreeItem(): TreeItem;
|
|
15
|
+
getChildren(): Promise<TreeElementBase[]>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
8
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
9
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
12
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.JobItem = void 0;
|
|
17
|
+
const vscode_1 = require("vscode");
|
|
18
|
+
const actionUtils_1 = require("../utils/actionUtils");
|
|
19
|
+
const StepItem_1 = require("./StepItem");
|
|
20
|
+
class JobItem {
|
|
21
|
+
constructor(parentResourceId, extensionPrefixContextValue, job) {
|
|
22
|
+
this.parentResourceId = parentResourceId;
|
|
23
|
+
this.extensionPrefixContextValue = extensionPrefixContextValue;
|
|
24
|
+
this.job = job;
|
|
25
|
+
this.id = `${this.parentResourceId}/jobs/${this.job.id}`;
|
|
26
|
+
this.label = this.job.name || this.id;
|
|
27
|
+
this.viewProperties = {
|
|
28
|
+
data: this.job,
|
|
29
|
+
label: this.label,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
getTreeItem() {
|
|
33
|
+
return {
|
|
34
|
+
id: this.id,
|
|
35
|
+
label: this.label,
|
|
36
|
+
description: (0, actionUtils_1.getJobBasedDescription)(this.job),
|
|
37
|
+
iconPath: (0, actionUtils_1.getActionBasedIconPath)(this.job),
|
|
38
|
+
contextValue: `${this.extensionPrefixContextValue}${JobItem.contextValueSuffix}`,
|
|
39
|
+
collapsibleState: vscode_1.TreeItemCollapsibleState.Collapsed,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
getChildren() {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return (_b = (_a = this.job.steps) === null || _a === void 0 ? void 0 : _a.map((step) => new StepItem_1.StepItem(this.id, this.extensionPrefixContextValue, step))) !== null && _b !== void 0 ? _b : [];
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.JobItem = JobItem;
|
|
50
|
+
JobItem.contextValueSuffix = 'JobItem';
|
|
51
|
+
//# sourceMappingURL=JobItem.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TreeElementBase } from "@microsoft/vscode-azext-utils";
|
|
2
|
+
import type { ViewPropertiesModel } from "@microsoft/vscode-azureresources-api";
|
|
3
|
+
import { TreeItem } from "vscode";
|
|
4
|
+
import { JobStep } from "../wrappers/getJobs";
|
|
5
|
+
export declare class StepItem implements TreeElementBase {
|
|
6
|
+
readonly parentResourceId: string;
|
|
7
|
+
readonly extensionPrefixContextValue: string;
|
|
8
|
+
readonly step: JobStep;
|
|
9
|
+
static contextValueSuffix: string;
|
|
10
|
+
constructor(parentResourceId: string, extensionPrefixContextValue: string, step: JobStep);
|
|
11
|
+
id: string;
|
|
12
|
+
label: string;
|
|
13
|
+
viewProperties: ViewPropertiesModel;
|
|
14
|
+
getTreeItem(): TreeItem;
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.StepItem = void 0;
|
|
8
|
+
const actionUtils_1 = require("../utils/actionUtils");
|
|
9
|
+
class StepItem {
|
|
10
|
+
constructor(parentResourceId, extensionPrefixContextValue, step) {
|
|
11
|
+
this.parentResourceId = parentResourceId;
|
|
12
|
+
this.extensionPrefixContextValue = extensionPrefixContextValue;
|
|
13
|
+
this.step = step;
|
|
14
|
+
this.id = `${this.parentResourceId}/steps/${this.step.number}`;
|
|
15
|
+
this.label = this.step.name;
|
|
16
|
+
this.viewProperties = {
|
|
17
|
+
data: this.step,
|
|
18
|
+
label: this.step.name,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
getTreeItem() {
|
|
22
|
+
return {
|
|
23
|
+
id: this.id,
|
|
24
|
+
label: this.label,
|
|
25
|
+
description: (0, actionUtils_1.getJobBasedDescription)(this.step),
|
|
26
|
+
iconPath: (0, actionUtils_1.getActionBasedIconPath)(this.step),
|
|
27
|
+
contextValue: `${this.extensionPrefixContextValue}${StepItem.contextValueSuffix}`
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.StepItem = StepItem;
|
|
32
|
+
StepItem.contextValueSuffix = 'StepItem';
|
|
33
|
+
//# sourceMappingURL=StepItem.js.map
|