-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathdeleteSecret.ts
More file actions
41 lines (39 loc) · 1.59 KB
/
deleteSecret.ts
File metadata and controls
41 lines (39 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as vscode from "vscode";
import {SecretCommandArgs} from "../../treeViews/settings/secretNode";
export function registerDeleteSecret(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand("github-actions.settings.secret.delete", async (args: SecretCommandArgs) => {
const {gitHubRepoContext, secret, environment} = args;
const acceptText = "Yes, delete this secret";
try {
await vscode.window
.showInformationMessage(
`Are you sure you want to delete ${secret.name}?`,
{modal: true, detail: "Deleting this secret cannot be undone and may impact workflows in this repository"},
acceptText
)
.then(async answer => {
if (answer === acceptText) {
if (environment) {
await gitHubRepoContext.client.actions.deleteEnvironmentSecret({
owner: gitHubRepoContext.owner,
repo: gitHubRepoContext.name,
environment_name: environment.name,
secret_name: secret.name
});
} else {
await gitHubRepoContext.client.actions.deleteRepoSecret({
owner: gitHubRepoContext.owner,
repo: gitHubRepoContext.name,
secret_name: secret.name
});
}
}
});
} catch (e) {
await vscode.window.showErrorMessage((e as Error).message);
}
await vscode.commands.executeCommand("github-actions.explorer.refresh");
})
);
}