Skip to content

Commit

Permalink
DEV2-4342 fix tabnine.enterprise key (#1390)
Browse files Browse the repository at this point in the history
  • Loading branch information
yonip23 authored Dec 3, 2023
1 parent 03d842e commit 7c1f1ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
12 changes: 7 additions & 5 deletions src/enterprise/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import TabnineAuthenticationProvider from "../authentication/TabnineAuthenticati
import {
BRAND_NAME,
ENTERPRISE_BRAND_NAME,
TABNINE_ENTERPRISE_KEY,
IS_SELF_HOSTED_CONTEXT_KEY,
} from "../globals/consts";
import { StatusBar } from "./statusBar";
import { isHealthyServer } from "./update/isHealthyServer";
Expand All @@ -46,6 +46,8 @@ import SignInUsingCustomTokenCommand from "../authentication/loginWithCustomToke
import { SIGN_IN_AUTH_TOKEN_COMMAND } from "../commandsHandler";
import { WorkspaceUpdater } from "../WorkspaceUpdater";

const TABNINE_ENTERPISE_CONTEXT_KEY = "tabnine.enterprise";

export async function activate(
context: vscode.ExtensionContext
): Promise<void> {
Expand Down Expand Up @@ -119,16 +121,16 @@ async function setEnterpriseContext(
): Promise<vscode.Disposable> {
await vscode.commands.executeCommand(
"setContext",
TABNINE_ENTERPRISE_KEY,
TABNINE_ENTERPISE_CONTEXT_KEY,
true
);
await context.workspaceState.update(TABNINE_ENTERPRISE_KEY, true);
await context.workspaceState.update(IS_SELF_HOSTED_CONTEXT_KEY, true);

return new vscode.Disposable(() => {
void context.workspaceState.update(TABNINE_ENTERPRISE_KEY, undefined);
void context.workspaceState.update(IS_SELF_HOSTED_CONTEXT_KEY, undefined);
void vscode.commands.executeCommand(
"setContext",
TABNINE_ENTERPRISE_KEY,
TABNINE_ENTERPISE_CONTEXT_KEY,
undefined
);
});
Expand Down
2 changes: 1 addition & 1 deletion src/globals/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,4 @@ export enum SuggestionTrigger {
}

export const TLS_CONFIG_MIN_SUPPORTED_VERSION = "4.22.0";
export const TABNINE_ENTERPRISE_KEY = "tabnine.enterprise";
export const IS_SELF_HOSTED_CONTEXT_KEY = "tabnine.isSelfHosted";
7 changes: 5 additions & 2 deletions src/tabnineChatWidget/ChatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { peekDefinition } from "./handlers/peekDefinition";
import { ServiceLevel } from "../binary/state";
import {
GET_CHAT_STATE_COMMAND,
TABNINE_ENTERPRISE_KEY,
IS_SELF_HOSTED_CONTEXT_KEY,
} from "../globals/consts";
import {
BasicContext,
Expand Down Expand Up @@ -122,7 +122,10 @@ export function initChatApi(
].includes(vscode.window.activeColorTheme.kind),
isTelemetryEnabled: isCapabilityEnabled(Capability.ALPHA_CAPABILITY),
serverUrl,
isSelfHosted: context.workspaceState.get(TABNINE_ENTERPRISE_KEY, false),
isSelfHosted: context.workspaceState.get(
IS_SELF_HOSTED_CONTEXT_KEY,
false
),
});
})
.registerEvent<void, GetUserResponse>("get_user", async () => {
Expand Down

0 comments on commit 7c1f1ea

Please sign in to comment.