@@ -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