Skip to content

Commit b2fe3e7

Browse files
committed
Support copying variables in the sidebar
1 parent abcd792 commit b2fe3e7

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@
201201
"light": "resources/icons/light/remove.svg"
202202
}
203203
},
204+
{
205+
"command": "github-actions.settings.variable.copy-name",
206+
"category": "GitHub Actions",
207+
"title": "Copy variable name"
208+
},
209+
{
210+
"command": "github-actions.settings.variable.copy-value",
211+
"category": "GitHub Actions",
212+
"title": "Copy variable value"
213+
},
204214
{
205215
"command": "github-actions.workflow.pin",
206216
"category": "GitHub Actions",
@@ -348,6 +358,16 @@
348358
"group": "inline@2",
349359
"when": "viewItem == 'repo-variable' || viewItem == 'env-variable'"
350360
},
361+
{
362+
"command": "github-actions.settings.variable.copy-name",
363+
"when": "viewItem == 'repo-variable' || viewItem == 'env-variable'",
364+
"group": "context"
365+
},
366+
{
367+
"command": "github-actions.settings.variable.copy-value",
368+
"when": "viewItem == 'repo-variable' || viewItem == 'env-variable'",
369+
"group": "context"
370+
},
351371
{
352372
"command": "github-actions.workflow.run.open",
353373
"when": "viewItem =~ /run\\s/",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import * as vscode from "vscode";
2+
import {VariableCommandArgs} from "../../treeViews/settings/variableNode";
3+
4+
export function registerCopyVariable(context: vscode.ExtensionContext) {
5+
context.subscriptions.push(
6+
vscode.commands.registerCommand("github-actions.settings.variable.copy-name", async (args: VariableCommandArgs) => {
7+
const {variable} = args;
8+
9+
await vscode.env.clipboard.writeText(variable.name);
10+
11+
vscode.window.setStatusBarMessage(`Copied ${variable.name}`, 2000);
12+
}),
13+
vscode.commands.registerCommand(
14+
"github-actions.settings.variable.copy-value",
15+
async (args: VariableCommandArgs) => {
16+
const {variable} = args;
17+
18+
await vscode.env.clipboard.writeText(variable.value);
19+
20+
vscode.window.setStatusBarMessage(`Copied ${variable.value}`, 2000);
21+
}
22+
)
23+
);
24+
}

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {registerUpdateSecret} from "./commands/secrets/updateSecret";
1515
import {registerTriggerWorkflowRun} from "./commands/triggerWorkflowRun";
1616
import {registerUnPinWorkflow} from "./commands/unpinWorkflow";
1717
import {registerAddVariable} from "./commands/variables/addVariable";
18+
import {registerCopyVariable} from "./commands/variables/copyVariable";
1819
import {registerDeleteVariable} from "./commands/variables/deleteVariable";
1920
import {registerUpdateVariable} from "./commands/variables/updateVariable";
2021
import {initConfiguration} from "./configuration/configuration";
@@ -68,6 +69,7 @@ export async function activate(context: vscode.ExtensionContext) {
6869
registerAddVariable(context);
6970
registerUpdateVariable(context);
7071
registerDeleteVariable(context);
72+
registerCopyVariable(context);
7173

7274
registerPinWorkflow(context);
7375
registerUnPinWorkflow(context);

0 commit comments

Comments
 (0)