Skip to content

Commit 93e2420

Browse files
committed
feat(quota-view): Add refresh button
1 parent 81daec0 commit 93e2420

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed

images/refresh-dark.svg

Lines changed: 1 addition & 0 deletions
Loading

images/refresh-light.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@
5656
{
5757
"command": "gitguardian.openProblems",
5858
"title": "Open Problems"
59+
},
60+
{
61+
"command": "gitguardian.refreshQuota",
62+
"title": "Refresh Quota",
63+
"icon": {
64+
"light": "images/refresh-light.svg",
65+
"dark": "images/refresh-dark.svg"
66+
}
5967
}
6068
],
6169
"viewsContainers": {
@@ -86,7 +94,16 @@
8694
"view": "gitguardianView",
8795
"contents": "To get started with GitGuardian, please authenticate.\n[Authenticate](command:gitguardian.authenticate)"
8896
}
89-
]
97+
],
98+
"menus": {
99+
"view/title": [
100+
{
101+
"command": "gitguardian.refreshQuota",
102+
"group": "navigation",
103+
"when": "view == gitguardianQuotaView"
104+
}
105+
]
106+
}
90107
},
91108
"scripts": {
92109
"vscode:prepublish": "yarn run compile",

src/extension.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ function registerOpenViewsCommands(
111111
);
112112
}
113113

114+
function registerQuotaViewCommands(view: GitGuardianQuotaWebviewProvider) {
115+
commands.registerCommand(
116+
"gitguardian.refreshQuota",
117+
async () => await view.refresh()
118+
);
119+
}
120+
114121
export function activate(context: ExtensionContext) {
115122
// Check if ggshield if available
116123
const outputChannel = window.createOutputChannel("GGShield Resolver");
@@ -142,6 +149,7 @@ export function activate(context: ExtensionContext) {
142149

143150
//generic commands to open correct view on status bar click
144151
registerOpenViewsCommands(context, outputChannel);
152+
registerQuotaViewCommands(ggshieldQuotaViewProvider);
145153
context.subscriptions.push(statusBar);
146154

147155
context.subscriptions.push(
@@ -181,15 +189,13 @@ export function activate(context: ExtensionContext) {
181189
textDocument.uri,
182190
ggshieldResolver.configuration
183191
);
184-
ggshieldQuotaViewProvider.refresh();
185192
}
186193
}),
187194
workspace.onDidCloseTextDocument((textDocument) =>
188195
cleanUpFileDiagnostics(textDocument.uri)
189196
),
190197
commands.registerCommand("gitguardian.quota", () => {
191198
showAPIQuota(ggshieldResolver.configuration);
192-
ggshieldQuotaViewProvider.refresh();
193199
}),
194200
commands.registerCommand("gitguardian.ignore", () => {
195201
ignoreLastFound(ggshieldResolver.configuration);
@@ -235,7 +241,6 @@ export function activate(context: ExtensionContext) {
235241
outputChannel.appendLine(`Error: ${error.message}`);
236242
updateStatusBarItem(StatusBarStatus.error, statusBar);
237243
});
238-
outputChannel.show();
239244
}
240245

241246
export function deactivate() {

src/ggshield-webview/gitguardian-quota-webview.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ export class GitGuardianQuotaWebviewProvider
9090
}
9191
}
9292

93-
public refresh() {
94-
this.checkAuthenticationStatus();
95-
this.updateQuota();
93+
public async refresh() {
94+
await this.checkAuthenticationStatus();
95+
await this.updateQuota();
9696

9797
this.updateWebViewContent(this._view);
9898
}

0 commit comments

Comments
 (0)