mirror of
https://github.com/kiteco/vscode-plugin.git
synced 2024-09-11 16:08:10 +03:00
Add Prompt Before Installation (#380)
* Update notification messages * Add prompt before installation
This commit is contained in:
parent
954ae979fb
commit
83e2a5de3a
11
src/kite.js
11
src/kite.js
@ -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:
|
||||
|
@ -104,6 +104,7 @@ export default {
|
||||
sendCompletionSelected,
|
||||
track: (event, props) => {
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
props = props || "";
|
||||
console.log(`tracking ${event}`, props);
|
||||
return;
|
||||
}
|
||||
|
@ -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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user