mirror of
https://github.com/kiteco/vscode-plugin.git
synced 2024-09-11 16:08:10 +03:00
Enable Plugin Install Flow (#369)
* Implement notifications * Implement auto install flow * hasKiteConfig -> hasKiteRun * Send launchCopilot and channel opts * Remove jsconfig.json * Minor tweaks * Remove this.showCopilot * Update kite-api to 3.2.0 and kite-connector to 3.14.0
This commit is contained in:
parent
4a7f71aff7
commit
45fca23db3
@ -1,12 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"lib": [
|
||||
"es6"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
@ -388,8 +388,8 @@
|
||||
"install-local": "vsce package && code --install-extension kite-*.vsix && rm kite-*.vsix"
|
||||
},
|
||||
"dependencies": {
|
||||
"kite-api": "=3.19.0",
|
||||
"kite-connector": "=3.12.0",
|
||||
"kite-api": "=3.20.0",
|
||||
"kite-connector": "=3.14.0",
|
||||
"md5": "^2.2.0",
|
||||
"mixpanel": "^0.5.0",
|
||||
"open": "^7.3.0",
|
||||
|
36
src/kite.js
36
src/kite.js
@ -86,10 +86,6 @@ export const Kite = {
|
||||
vscode.workspace.getConfiguration("kite").loggingLevel.toUpperCase()
|
||||
];
|
||||
|
||||
KiteAPI
|
||||
.isKiteInstalled()
|
||||
.catch(NotificationsManager.showKiteInstallNotification);
|
||||
|
||||
this.setMaxFileSize();
|
||||
|
||||
this.disposables.push(
|
||||
@ -427,6 +423,7 @@ export const Kite = {
|
||||
this.shown = {};
|
||||
this.disposables = [];
|
||||
this.attemptedToStartKite = false;
|
||||
this.installing = false;
|
||||
this.notifications = new NotificationsManager();
|
||||
delete this.lastState;
|
||||
delete this.lastStatus;
|
||||
@ -522,12 +519,32 @@ export const Kite = {
|
||||
return state;
|
||||
}
|
||||
this.shown[state] = true;
|
||||
if (KiteAPI.hasKiteRun()) {
|
||||
NotificationsManager.showKiteInstallNotification();
|
||||
} else {
|
||||
NotificationsManager.showKiteDownloadingNotification();
|
||||
this.installing = true;
|
||||
KiteAPI.downloadKiteRelease({
|
||||
install: true,
|
||||
launchCopilot: true,
|
||||
channel: 'vscode',
|
||||
onRemove: () => { this.installing = false; },
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e);
|
||||
NotificationsManager.showKiteInstallErrorNotification();
|
||||
});
|
||||
}
|
||||
break;
|
||||
case KiteAPI.STATES.INSTALLED:
|
||||
if (
|
||||
!this.attemptedToStartKite &&
|
||||
vscode.workspace.getConfiguration("kite").startKiteEngineOnStartup
|
||||
) {
|
||||
if (this.installing) {
|
||||
// Guard against running Kite before installation fully completes.
|
||||
break;
|
||||
}
|
||||
KiteAPI.runKiteAndWait(RUN_KITE_ATTEMPTS, RUN_KITE_INTERVAL).then(() => this.checkState(src));
|
||||
this.attemptedToStartKite = true;
|
||||
}
|
||||
@ -586,14 +603,19 @@ export const Kite = {
|
||||
this.statusBarItem.show();
|
||||
switch (state) {
|
||||
case KiteAPI.STATES.UNSUPPORTED:
|
||||
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: not supported";
|
||||
this.statusBarItem.tooltip =
|
||||
"Kite engine is currently not supported on your platform";
|
||||
this.statusBarItem.color = ERROR_COLOR();
|
||||
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: not supported";
|
||||
break;
|
||||
case KiteAPI.STATES.UNINSTALLED:
|
||||
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: not installed";
|
||||
this.statusBarItem.tooltip = "Kite engine is not installed";
|
||||
if (this.installing) {
|
||||
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: installing components";
|
||||
this.statusBarItem.tooltip = "Installing components. Kite will launch automatically when ready.";
|
||||
} else {
|
||||
this.statusBarItem.text = "𝕜𝕚𝕥𝕖: not installed";
|
||||
this.statusBarItem.tooltip = "Kite engine is not installed";
|
||||
}
|
||||
this.statusBarItem.color = ERROR_COLOR();
|
||||
break;
|
||||
case KiteAPI.STATES.INSTALLED:
|
||||
|
@ -1,6 +1,5 @@
|
||||
import vscode from "vscode";
|
||||
import open from "open";
|
||||
import path from "path";
|
||||
|
||||
import metrics from "./metrics";
|
||||
|
||||
@ -78,22 +77,56 @@ export default class NotificationsManager {
|
||||
.then(hasDone => !hasDone && openKiteTutorial('python'));
|
||||
}
|
||||
|
||||
static showKiteInstallNotification(err) {
|
||||
if (typeof err.data !== 'undefined' && err.data.state === KiteAPI.STATES.UNINSTALLED) {
|
||||
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"
|
||||
)
|
||||
.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");
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
static showKiteInstallNotification() {
|
||||
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"
|
||||
)
|
||||
.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");
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static showKiteDownloadingNotification() {
|
||||
metrics.track("vscode_kite_downloading_notification_shown");
|
||||
vscode.window
|
||||
.showInformationMessage(
|
||||
"Kite ships with a standalone application called the Copilot that can show you documentation while you code. The Copilot will launch automatically after Kite is finished installing.",
|
||||
"OK",
|
||||
"Learn More"
|
||||
)
|
||||
.then(item => {
|
||||
switch (item) {
|
||||
case "OK":
|
||||
break;
|
||||
case "Learn More":
|
||||
open("https://www.kite.com/copilot/");
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static showKiteInstallErrorNotification() {
|
||||
metrics.track("vscode_kite_downloading_failed_notification_shown");
|
||||
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.",
|
||||
"Install"
|
||||
)
|
||||
.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");
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user