Pause downloads (#385)

* Add new notifications

* Integrate install paused notifications

* Add link to Kite unavailable page

* Update kite-api and kite-connector
This commit is contained in:
edzkite 2021-06-01 18:04:33 -07:00 committed by GitHub
parent d39194d7f8
commit e9e7c8b9d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 4 deletions

View File

@ -389,8 +389,8 @@
"install-local": "vsce package && code --install-extension kite-*.vsix && rm kite-*.vsix"
},
"dependencies": {
"kite-api": "=3.20.0",
"kite-connector": "=3.14.0",
"kite-api": "=3.21.0",
"kite-connector": "=3.16.0",
"md5": "^2.2.0",
"mixpanel": "^0.5.0",
"open": "^7.3.0",

View File

@ -134,6 +134,8 @@ const KITE_BRANDING = " 𝕜𝕚𝕥𝕖";
const OFFSET_ENCODING = "utf-16";
const INSTALL_PAUSED_NOTIFICATION_SHOWN = "kite.hasShownInstallPausedNotification";
export {
ATTEMPTS,
INTERVAL,
@ -141,6 +143,7 @@ export {
CompletionsSupport,
SupportedExtensions,
IsSupportedFile,
INSTALL_PAUSED_NOTIFICATION_SHOWN,
CONNECT_ERROR_LOCKOUT,
ERROR_COLOR,
WARNING_COLOR,

View File

@ -15,6 +15,7 @@ import {
PythonHoverSupport,
PythonSignaturesSupport,
IsSupportedFile,
INSTALL_PAUSED_NOTIFICATION_SHOWN,
} from "./constants";
import { KiteHoverProvider, DocsCommands } from "./docs";
import KiteCompletionProvider from "./completion";
@ -52,7 +53,7 @@ export const Kite = {
_activate() {
if (this.globalState.setKeysForSync) {
this.globalState.setKeysForSync(["kite.showWelcomeNotificationOnStartup"]);
this.globalState.setKeysForSync(["kite.showWelcomeNotificationOnStartup", INSTALL_PAUSED_NOTIFICATION_SHOWN]);
}
metrics.featureRequested("starting");
@ -465,7 +466,8 @@ export const Kite = {
return state;
}
this.shown[state] = true;
NotificationsManager.showKiteInstallNotification(() => {
const installFunc = () => {
NotificationsManager.showKiteDownloadingNotification();
this.installing = true;
KiteAPI.downloadKiteRelease({
@ -477,6 +479,22 @@ export const Kite = {
.catch(e => {
NotificationsManager.showKiteInstallErrorNotification(e);
});
}
KiteAPI.canDownloadKite().then(yes => {
if (!yes) {
if (!this.globalState.get(INSTALL_PAUSED_NOTIFICATION_SHOWN)) {
NotificationsManager.showKiteInstallPausedNotification();
this.globalState.update(INSTALL_PAUSED_NOTIFICATION_SHOWN, true);
}
return;
}
if (this.globalState.get(INSTALL_PAUSED_NOTIFICATION_SHOWN)) {
NotificationsManager.showKiteInstallResumedNotification(installFunc);
this.globalState.update(INSTALL_PAUSED_NOTIFICATION_SHOWN, undefined);
} else {
NotificationsManager.showKiteInstallNotification(installFunc);
}
});
break;
case KiteAPI.STATES.INSTALLED:

View File

@ -99,6 +99,48 @@ export default class NotificationsManager {
.then(hasDone => !hasDone && openKiteTutorial('python'));
}
static showKiteInstallPausedNotification() {
vscode.window
.showInformationMessage(
"The Kite Copilot cannot be installed for the time being. We'll notify you when it's available again.",
"OK",
"Learn More"
)
.then(item => {
switch (item) {
case "OK":
break;
case "Learn More":
open("https://kite.com/kite-is-temporarily-unavailable/?source=vscode");
break;
}
});
}
static showKiteInstallResumedNotification(install) {
vscode.window
.showInformationMessage(
"The Kite Copilot is installable again. 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":
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;
}
});
}
static showKiteInstallNotification(install) {
metrics.track("vscode_kite_installer_notification_shown");
vscode.window