Skip to content

Commit

Permalink
Add logs and fix notification function name
Browse files Browse the repository at this point in the history
  • Loading branch information
ofekby committed Dec 6, 2023
1 parent 8e2b5d8 commit d6c304c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/enterprise/statusBar/StatusBar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Disposable, ExtensionContext, window } from "vscode";
import { StatusItem } from "./StatusItem";
import { showLoginNotification } from "./statusAction";
import { showPleaseLoginNotification } from "./statusAction";
import { CONGRATS_MESSAGE_SHOWN_KEY } from "../../globals/consts";
import StatusBarState from "./StatusBarState";
import { useDerviedState } from "../../state/deriveState";
Expand Down Expand Up @@ -30,8 +30,8 @@ export class StatusBar implements Disposable {
USER_INFO_STATE,
(s) => s.isLoggedIn,
(isLoggedIn) => {
if (isLoggedIn) {
showLoginNotification();
if (!isLoggedIn) {
showPleaseLoginNotification();
}
}
)
Expand Down
26 changes: 26 additions & 0 deletions src/enterprise/statusBar/calculateStatusBarState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default function calculateStatusBarState(
userInfo: UserInfo | null
): StatusBarStateData {
if (!processStartedState.resolved) {
Logger.info("Waiting for process to start...");

return INITIAL_STATE;
}

Expand All @@ -36,20 +38,36 @@ export default function calculateStatusBarState(
}

if (!serverHealthOnPluginStart.resolved) {
Logger.info("Waiting for Tabnine server to be ready...");

return {
type: "loading",
};
}

if (serverHealthOnPluginStart.isError || !serverHealthOnPluginStart.data) {
Logger.error("Tabnine server is unhealthy.");

return {
type: "error",
message: "Please set your Tabnine server URL",
command: StatusState.SetServer,
};
}

if (cloudConnection === undefined || cloudConnection === null) {
Logger.info("Waiting for Tabnine cloud connection...");

return {
type: "loading",
};
}

if (cloudConnection !== "Ok") {
Logger.warn(
`Tabnine is not connected to your cloud. Connection status: ${cloudConnection}`
);

return {
type: "warning",
message: "Connectivity issue - Tabnine is unable to reach the server",
Expand All @@ -58,19 +76,25 @@ export default function calculateStatusBarState(
}

if (!isCompletionsEnabled) {
Logger.debug("Showing completions disabled status.");

return {
type: "warning",
command: StatusState.Ready,
};
}

if (!userInfo) {
Logger.info("Waiting for user info...");

return {
type: "loading",
};
}

if (!userInfo.isLoggedIn) {
Logger.debug("User is logged out. Showing logged out status.");

return {
type: "warning",
message: "Please sign in to access Tabnine",
Expand All @@ -79,6 +103,8 @@ export default function calculateStatusBarState(
}

if (!userInfo.team) {
Logger.debug("User is not part of a team. Showing logged out status.");

return {
type: "warning",
message: "You are not part of a team",
Expand Down
4 changes: 2 additions & 2 deletions src/enterprise/statusBar/statusAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function action(state: StatusState): void {
);
break;
case StatusState.LogIn:
showLoginNotification();
showPleaseLoginNotification();
break;
case StatusState.ErrorWaitingForProcess:
void window
Expand Down Expand Up @@ -102,7 +102,7 @@ export function action(state: StatusState): void {
}
}

export function showLoginNotification() {
export function showPleaseLoginNotification() {
void window
.showInformationMessage("Please sign in to access Tabnine.", "Sign in")
.then((selection) => {
Expand Down

0 comments on commit d6c304c

Please sign in to comment.