microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
0.6.6

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/extension/appcenter/appCenterExtensionManager.ts

58lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { Disposable, StatusBarAlignment, StatusBarItem, window } from "vscode";
5import Auth from "../appcenter/auth/auth";
6import { ACStrings } from "./appCenterStrings";
7import * as Q from "q";
8import { ACCommandNames, ACConstants } from "./appCenterConstants";
9import { Profile } from "./auth/profile/profile";
10import { ACUtils } from "./helpers/utils";
11import { VsCodeUtils } from "./helpers/vscodeUtils";
12
13export class AppCenterExtensionManager implements Disposable {
14 private appCenterStatusBarItem: StatusBarItem;
15 private _projectRootPath: string;
16
17 public constructor(projectRootPath: string) {
18 this._projectRootPath = projectRootPath;
19 }
20
21 public get projectRootPath(): string {
22 return this._projectRootPath;
23 }
24
25 public setup(): Q.Promise<void> {
26 return ACUtils.isCodePushProject(this._projectRootPath).then((isCodePush: boolean) => {
27 if (!isCodePush) {
28 return Q.resolve(void 0);
29 } else {
30 this.appCenterStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 12);
31 return Auth.getProfile(this._projectRootPath).then((profile: Profile | null) => {
32 return this.setupAppCenterStatusBar(profile);
33 });
34 }
35 });
36 }
37
38 public dispose() {
39 if (this.appCenterStatusBarItem) {
40 this.appCenterStatusBarItem.dispose();
41 }
42 }
43
44 public setupAppCenterStatusBar(profile: Profile | null): Q.Promise<void> {
45 if (profile && profile.userName) {
46 return VsCodeUtils.setStatusBar(this.appCenterStatusBarItem,
47 `$(icon octicon-person) ${profile.userName}`,
48 ACStrings.YouAreLoggedInMsg(profile.userName),
49 `${ACConstants.ExtensionPrefixName}.${ACCommandNames.ShowMenu}`
50 );
51 }
52 return VsCodeUtils.setStatusBar(this.appCenterStatusBarItem,
53 `$(icon octicon-sign-in) ${ACStrings.LoginToAppCenterButton}`,
54 ACStrings.UserMustSignIn,
55 `${ACConstants.ExtensionPrefixName}.${ACCommandNames.Login}`
56 );
57 }
58}