Skip to content

Commit 0446416

Browse files
authored
Add message for deletion verification (#96)
1 parent fd6b68d commit 0446416

2 files changed

Lines changed: 44 additions & 18 deletions

File tree

src/commands/secrets/deleteSecret.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,26 @@ export function registerDeleteSecret(context: vscode.ExtensionContext) {
66
vscode.commands.registerCommand("github-actions.settings.secret.delete", async (args: SecretCommandArgs) => {
77
const gitHubContext = args.gitHubRepoContext;
88
const secret = args.secret;
9-
10-
await gitHubContext.client.actions.deleteRepoSecret({
11-
owner: gitHubContext.owner,
12-
repo: gitHubContext.name,
13-
secret_name: secret.name
14-
});
15-
9+
const acceptText = "Yes, delete this secret";
10+
try {
11+
await vscode.window
12+
.showInformationMessage(
13+
`Are you sure you want to delete ${secret.name}?`,
14+
{modal: true, detail: "Deleting this secret cannot be undone and may impact workflows in this repository"},
15+
acceptText
16+
)
17+
.then(async answer => {
18+
if (answer === acceptText) {
19+
await gitHubContext.client.actions.deleteRepoSecret({
20+
owner: gitHubContext.owner,
21+
repo: gitHubContext.name,
22+
secret_name: secret.name
23+
});
24+
}
25+
});
26+
} catch (e) {
27+
await vscode.window.showErrorMessage((e as Error).message);
28+
}
1629
await vscode.commands.executeCommand("github-actions.explorer.refresh");
1730
})
1831
);

src/commands/variables/deleteVariable.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,36 @@ export function registerDeleteVariable(context: vscode.ExtensionContext) {
55
context.subscriptions.push(
66
vscode.commands.registerCommand("github-actions.settings.variable.delete", async (args: VariableCommandArgs) => {
77
const {gitHubRepoContext, variable, environment} = args;
8+
const acceptText = "Yes, delete this variable";
89

910
try {
10-
if (environment) {
11-
await gitHubRepoContext.client.request(
12-
`DELETE /repositories/${gitHubRepoContext.id}/environments/${environment.name}/variables/${variable.name}`
13-
);
14-
} else {
15-
await gitHubRepoContext.client.actions.deleteRepoVariable({
16-
owner: gitHubRepoContext.owner,
17-
repo: gitHubRepoContext.name,
18-
name: variable.name
11+
await vscode.window
12+
.showInformationMessage(
13+
`Are you sure you want to delete ${variable.name}?`,
14+
{
15+
modal: true,
16+
detail: "Deleting this variable cannot be undone and may impact workflows in this repository"
17+
},
18+
acceptText
19+
)
20+
.then(async answer => {
21+
if (answer === acceptText) {
22+
if (environment) {
23+
await gitHubRepoContext.client.request(
24+
`DELETE /repositories/${gitHubRepoContext.id}/environments/${environment.name}/variables/${variable.name}`
25+
);
26+
} else {
27+
await gitHubRepoContext.client.actions.deleteRepoVariable({
28+
owner: gitHubRepoContext.owner,
29+
repo: gitHubRepoContext.name,
30+
name: variable.name
31+
});
32+
}
33+
}
1934
});
20-
}
2135
} catch (e) {
2236
await vscode.window.showErrorMessage((e as Error).message);
2337
}
24-
2538
await vscode.commands.executeCommand("github-actions.explorer.refresh");
2639
})
2740
);

0 commit comments

Comments
 (0)