Skip to content

Commit 2802233

Browse files
committed
Move run context value logic to run model
1 parent 2b97fd5 commit 2802233

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/store/workflowRun.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {GitHubRepoContext} from "../git/repository";
2+
import {RepositoryPermission, hasWritePermission} from "../git/repository-permissions";
23
import {log, logDebug} from "../log";
34
import * as model from "../model";
45
import {WorkflowJob} from "./WorkflowJob";
@@ -50,6 +51,18 @@ abstract class WorkflowRunBase {
5051
return this._jobs;
5152
}
5253

54+
contextValue(permission: RepositoryPermission): string {
55+
const contextValues = ["run"];
56+
const completed = this._run.status === "completed";
57+
if (hasWritePermission(permission)) {
58+
contextValues.push(completed ? "rerunnable" : "cancelable");
59+
}
60+
if (completed) {
61+
contextValues.push("completed");
62+
}
63+
return contextValues.join(" ");
64+
}
65+
5366
protected abstract fetchJobs(): Promise<WorkflowJob[]>;
5467
}
5568

src/treeViews/shared/workflowRunNode.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,7 @@ export class WorkflowRunNode extends vscode.TreeItem {
2828
this.run = run;
2929
this.label = WorkflowRunNode._getLabel(run, this.workflowName);
3030

31-
const contextValues = ["run"];
32-
const completed = this.run.run.status === "completed";
33-
if (hasWritePermission(this.gitHubRepoContext.permissionLevel)) {
34-
contextValues.push(completed ? "rerunnable" : "cancelable");
35-
}
36-
if (completed) {
37-
contextValues.push("completed");
38-
}
39-
this.contextValue = contextValues.join(" ");
31+
this.contextValue = this.run.contextValue(this.gitHubRepoContext.permissionLevel);
4032

4133
this.iconPath = getIconForWorkflowRun(this.run.run);
4234
this.tooltip = this.getTooltip();

0 commit comments

Comments
 (0)