Add Prompt Before Installation (#380)

* Update notification messages

* Add prompt before installation
This commit is contained in:
edzkite 2021-02-17 13:27:36 -08:00 committed by GitHub
parent 954ae979fb
commit 83e2a5de3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 15 deletions

View File

@ -479,9 +479,7 @@ export const Kite = {
return state;
}
this.shown[state] = true;
if (KiteAPI.hasKiteRun()) {
NotificationsManager.showKiteInstallNotification();
} else {
NotificationsManager.showKiteInstallNotification(() => {
NotificationsManager.showKiteDownloadingNotification();
this.installing = true;
KiteAPI.downloadKiteRelease({
@ -491,10 +489,9 @@ export const Kite = {
onRemove: () => { this.installing = false; },
})
.catch(e => {
console.error(e);
NotificationsManager.showKiteInstallErrorNotification();
NotificationsManager.showKiteInstallErrorNotification(e);
});
}
});
break;
case KiteAPI.STATES.INSTALLED:
if (
@ -559,7 +556,7 @@ export const Kite = {
const supported = this.isGrammarSupported(vscode.window.activeTextEditor);
const enabledFiletype = this.isEnabledAndSupported(vscode.window.activeTextEditor);
if (supported) {
if (!vscode.window.activeTextEditor || supported) {
this.statusBarItem.show();
switch (state) {
case KiteAPI.STATES.UNSUPPORTED:

View File

@ -104,6 +104,7 @@ export default {
sendCompletionSelected,
track: (event, props) => {
if (process.env.NODE_ENV !== "production") {
props = props || "";
console.log(`tracking ${event}`, props);
return;
}

View File

@ -99,18 +99,26 @@ export default class NotificationsManager {
.then(hasDone => !hasDone && openKiteTutorial('python'));
}
static showKiteInstallNotification() {
static showKiteInstallNotification(install) {
metrics.track("vscode_kite_installer_notification_shown");
vscode.window
.showInformationMessage(
"Kite requires the Kite Engine backend to provide completions and documentation. Please install it to use Kite.",
"Install"
"Kite requires the Kite Copilot desktop application to provide completions and documentation. Please install it to use Kite.",
"Install",
"Learn More"
)
.then(item => {
switch (item) {
case "Install":
open("https://www.kite.com/install/?utm_medium=editor&utm_source=vscode");
metrics.track("vscode_kite_installer_github_link_clicked");
if (!install) {
open("https://www.kite.com/install/?utm_medium=editor&utm_source=vscode");
metrics.track("vscode_kite_installer_github_link_clicked")
} else {
install();
}
break;
case "Learn More":
open("https://www.kite.com/copilot/");
break;
}
});
@ -135,11 +143,11 @@ export default class NotificationsManager {
});
}
static showKiteInstallErrorNotification() {
metrics.track("vscode_kite_downloading_failed_notification_shown");
static showKiteInstallErrorNotification(error) {
metrics.track("vscode_kite_downloading_failed_notification_shown", { error });
vscode.window
.showErrorMessage(
"There was an error installing the Kite Engine, which is required for Kite to provide completions and documentation. Please install it to use Kite.",
"There was an error installing the Kite Copilot, which is required for Kite to provide completions and documentation. Please install it to use Kite.",
"Install"
)
.then(item => {