diff --git a/package.json b/package.json index a4f94aed7d..5dc7332e44 100644 --- a/package.json +++ b/package.json @@ -221,6 +221,12 @@ "name": "Chat", "when": "tabnine.chat.webview == 'chat'" }, + { + "id": "tabnine.chat.preview_ended", + "type": "webview", + "name": "Preview ended", + "when": "tabnine.chat.webview == 'preview_ended'" + }, { "id": "tabnine.chat.welcome", "type": "webview", diff --git a/src/capabilities/capabilities.ts b/src/capabilities/capabilities.ts index 1ea9df5a04..3813b6850a 100644 --- a/src/capabilities/capabilities.ts +++ b/src/capabilities/capabilities.ts @@ -44,6 +44,8 @@ export enum Capability { TEST_GEN = "vscode_test_gen", FORCE_REGISTRATION = "plugin.feature.force_registration", TABNINE_CHAT = "plugin.feature.tabnine_chat", + PREVIEW_CAPABILITIY = "preview", + PREVIEW_ENDED_CAPABILITIY = "preview_ended", } let enabledCapabilities: Record | null = null; diff --git a/src/extension.ts b/src/extension.ts index c71d8110a7..f722a1ba1a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -60,6 +60,7 @@ import BINARY_STATE from "./binary/binaryStateSingleton"; import EvalSaasChatEnabledState from "./tabnineChatWidget/EvalSaasChatEnabledState"; import { ChatAPI } from "./tabnineChatWidget/ChatApi"; import ChatViewProvider from "./tabnineChatWidget/ChatViewProvider"; +import { previewEndedView } from "./tabnineChatWidget/webviews/previewEndedView"; export async function activate( context: vscode.ExtensionContext @@ -127,6 +128,7 @@ async function backgroundInit(context: vscode.ExtensionContext) { void callForLogin(); }); context.subscriptions.push( + previewEndedView(context), emptyStateWelcomeView(context), emptyStateAuthenticateView(context) ); diff --git a/src/tabnineChatWidget/ChatEnabledState.ts b/src/tabnineChatWidget/ChatEnabledState.ts index e2280d4ce9..19fe6fc0a4 100644 --- a/src/tabnineChatWidget/ChatEnabledState.ts +++ b/src/tabnineChatWidget/ChatEnabledState.ts @@ -1,6 +1,7 @@ import { Disposable } from "vscode"; export type ChatNotEnabledReason = + | "preview_ended" | "capability_required" | "authnetication_required" | "part_of_a_team_required"; diff --git a/src/tabnineChatWidget/SaasChatEnabledState.ts b/src/tabnineChatWidget/SaasChatEnabledState.ts index 490a3b1ea6..10adb89c03 100644 --- a/src/tabnineChatWidget/SaasChatEnabledState.ts +++ b/src/tabnineChatWidget/SaasChatEnabledState.ts @@ -43,6 +43,8 @@ export default class SaasChatEnabledState if (getIsCapabilitesEnabled()) { this.set(ChatStates.enabled); + } else if (isPreviewEnded()) { + this.set(ChatStates.disabled("preview_ended")); } else if (isLoggedIn) { this.set(ChatStates.disabled("capability_required")); } else { @@ -54,6 +56,11 @@ export default class SaasChatEnabledState function getIsCapabilitesEnabled() { return ( isCapabilityEnabled(Capability.ALPHA_CAPABILITY) || - isCapabilityEnabled(Capability.TABNINE_CHAT) + isCapabilityEnabled(Capability.TABNINE_CHAT) || + isCapabilityEnabled(Capability.PREVIEW_CAPABILITIY) ); } + +function isPreviewEnded(): boolean { + return isCapabilityEnabled(Capability.PREVIEW_ENDED_CAPABILITIY); +} diff --git a/src/tabnineChatWidget/webviews/previewEnded.html.ts b/src/tabnineChatWidget/webviews/previewEnded.html.ts new file mode 100644 index 0000000000..1951f04d83 --- /dev/null +++ b/src/tabnineChatWidget/webviews/previewEnded.html.ts @@ -0,0 +1,21 @@ +import { template } from "./template.html"; + +export const PREVIEW_ENDED_MESSAGE = ` +
+

Tabnine Chat - Preview Period Ended

+

+The preview period for Tabnine Chat in Visual Studio Code has now ended. We hope you found it valuable for your coding projects and enjoyed the experience. +

+

+To continue using Tabnine Chat and access its full range of features, we invite you to subscribe to one of our plans. +

+

+You can find detailed information about our pricing and the additional benefits of a subscription on our pricing page. +

+

+If you have any questions or need assistance, our support team is always ready to help. +

+
`; + +export const html = (logoSrc: string) => + template(PREVIEW_ENDED_MESSAGE, logoSrc); diff --git a/src/tabnineChatWidget/webviews/previewEndedView.ts b/src/tabnineChatWidget/webviews/previewEndedView.ts new file mode 100644 index 0000000000..071f547f58 --- /dev/null +++ b/src/tabnineChatWidget/webviews/previewEndedView.ts @@ -0,0 +1,31 @@ +import { Disposable, ExtensionContext, WebviewView, window } from "vscode"; +import { fireEvent } from "../../binary/requests/requests"; +import { html } from "./previewEnded.html"; +import { getIcon } from "./getIcon"; + +export function previewEndedView(context: ExtensionContext): Disposable { + return window.registerWebviewViewProvider("tabnine.chat.preview_ended", { + resolveWebviewView(webviewView: WebviewView) { + context.subscriptions.push( + webviewView.onDidChangeVisibility(() => { + if (webviewView.visible) { + void fireEvent({ + name: "tabnine-chat-preview-ended-visible", + }); + } + }) + ); + const view = webviewView.webview; + view.options = { + enableScripts: true, + enableCommandUris: true, + }; + const logoSrc = getIcon(context, view); + view.html = html(logoSrc); + + void fireEvent({ + name: "tabnine-chat-preview-ended-inited", + }); + }, + }); +}