This repository was archived by the owner on Nov 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 105
105
"title" : " Setup Gitlab Token..." ,
106
106
"category" : " GitHub"
107
107
},
108
+ {
109
+ "command" : " vscode-github.clearToken" ,
110
+ "title" : " Remove Token..." ,
111
+ "category" : " GitHub"
112
+ },
108
113
{
109
114
"command" : " vscode-github.browseProject" ,
110
115
"title" : " Browse project" ,
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { component, inject } from 'tsdi';
2
2
import * as vscode from 'vscode' ;
3
3
4
4
import { Command } from '../command' ;
5
+ import { listTokenHosts , removeToken } from '../tokens' ;
5
6
import { WorkflowManager , Tokens } from '../workflow-manager' ;
6
7
7
8
@component ( { eager : true } )
@@ -109,3 +110,23 @@ export class SetGitLabToken extends Command {
109
110
}
110
111
111
112
}
113
+
114
+ @component ( { eager : true } )
115
+ export class ClearToken extends Command {
116
+
117
+ public id = 'vscode-github.clearToken' ;
118
+
119
+ @inject ( 'vscode.ExtensionContext' )
120
+ private context : vscode . ExtensionContext ;
121
+
122
+ public async run ( ) : Promise < void > {
123
+ this . track ( 'execute' ) ;
124
+ const host = await vscode . window . showQuickPick ( listTokenHosts ( this . context . globalState ) , {
125
+ placeHolder : 'Token to remove'
126
+ } ) ;
127
+ if ( host ) {
128
+ removeToken ( this . context . globalState , host ) ;
129
+ }
130
+ }
131
+
132
+ }
Original file line number Diff line number Diff line change @@ -30,3 +30,19 @@ export function migrateToken(memento: Memento): void {
30
30
memento . update ( 'tokens' , struct ) ;
31
31
}
32
32
}
33
+
34
+ export function listTokenHosts ( memento : Memento ) : string [ ] {
35
+ const tokens : Tokens | undefined = memento . get ( 'tokens' ) ;
36
+ if ( ! tokens ) {
37
+ return [ ] ;
38
+ }
39
+ return Object . keys ( tokens ) ;
40
+ }
41
+
42
+ export function removeToken ( memento : Memento , host : string ) : void {
43
+ const tokens : Tokens | undefined = memento . get ( 'tokens' ) ;
44
+ if ( tokens ) {
45
+ delete tokens [ host ] ;
46
+ memento . update ( 'tokens' , tokens ) ;
47
+ }
48
+ }
You can’t perform that action at this time.
0 commit comments