updateCodeSuggestionsItem()

in src/desktop/accounts/account_status_bar_item.ts [39:73]


  updateCodeSuggestionsItem(state: WorkspaceAccountState) {
    switch (state.type) {
      case NO_ACCOUNTS:
        this.#codeSuggestionsStatusBarItem.hide();
        break;

      case SINGLE_ACCOUNT:
        this.#codeSuggestionsStatusBarItem.hide();
        break;

      case ACCOUNT_SELECTED:
        this.#codeSuggestionsStatusBarItem.show();
        this.#codeSuggestionsStatusBarItem.text = `$(gitlab-logo) ${truncateUsername(state.account.username)}`;
        this.#codeSuggestionsStatusBarItem.tooltip = `Active account: ${state.account.username} (${hostOnly(state.account.instanceUrl)}). Click to change.`;
        this.#codeSuggestionsStatusBarItem.command = USER_COMMANDS.SELECT_WORKSPACE_ACCOUNT;
        break;

      case ACCOUNT_PRESELECTED:
        this.#codeSuggestionsStatusBarItem.show();
        this.#codeSuggestionsStatusBarItem.text = `$(gitlab-logo) ${truncateUsername(state.account.username)}`;
        this.#codeSuggestionsStatusBarItem.tooltip = `Preselected account: ${state.account.username} (${hostOnly(state.account.instanceUrl)}). Click to change.`;
        this.#codeSuggestionsStatusBarItem.command = USER_COMMANDS.SELECT_WORKSPACE_ACCOUNT;
        break;

      case MULTIPLE_AVAILABLE_ACCOUNTS:
        this.#codeSuggestionsStatusBarItem.show();
        this.#codeSuggestionsStatusBarItem.text = `$(question) Multiple GitLab Accounts`;
        this.#codeSuggestionsStatusBarItem.tooltip = 'Click to select the account to use';
        this.#codeSuggestionsStatusBarItem.command = USER_COMMANDS.SELECT_WORKSPACE_ACCOUNT;
        break;
      default:
        this.#codeSuggestionsStatusBarItem.hide();
        log.error(`Unexpected workspace account state ${JSON.stringify(state)}`);
    }
  }