-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
People Present On The Site Tree Webview (#788)
* tree webview for users present on power pages studio and vscode for web * inline icon for mail and teams chat * open teams chat and mail * renamed provider * renamed provider * renamed provider * formatting reverted * formatting reverted * microsoft teams chat icon updated * Named command, method and provider more logically
- Loading branch information
1 parent
323293b
commit 608dbe1
Showing
8 changed files
with
153 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/web/client/assets/microsoftTeamsIcon/dark/microsoftTeams.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
src/web/client/assets/microsoftTeamsIcon/light/microsoftTeams.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import * as vscode from "vscode"; | ||
import WebExtensionContext from "../WebExtensionContext"; | ||
import { GraphClientService } from "../services/graphClientService"; | ||
import { getMailToPath, getTeamChatURL } from "../utilities/commonUtil"; | ||
import * as Constants from "../common/constants"; | ||
|
||
export class UserCollaborationProvider | ||
implements vscode.TreeDataProvider<UserNode> | ||
{ | ||
private graphClientService: GraphClientService; | ||
private _onDidChangeTreeData: vscode.EventEmitter< | ||
UserNode | undefined | void | ||
> = new vscode.EventEmitter<UserNode | undefined | void>(); | ||
readonly onDidChangeTreeData: vscode.Event<UserNode | undefined | void> = | ||
this._onDidChangeTreeData.event; | ||
|
||
constructor() { | ||
this.graphClientService = new GraphClientService(); | ||
} | ||
|
||
refresh(): void { | ||
this._onDidChangeTreeData.fire(); | ||
} | ||
|
||
getTreeItem(element: UserNode): vscode.TreeItem { | ||
return element; | ||
} | ||
|
||
getChildren(): Thenable<UserNode[]> { | ||
return Promise.resolve(this.getConnectedUsers()); | ||
} | ||
|
||
getConnectedUsers(): UserNode[] { | ||
const connectedUsersMap = WebExtensionContext.connectedUsers.getUserMap; | ||
const connectedUsers: UserNode[] = Array.from( | ||
connectedUsersMap.entries() | ||
).map(([, value]) => { | ||
return new UserNode( | ||
value._userName, | ||
value._userId, | ||
vscode.TreeItemCollapsibleState.None | ||
); | ||
}); | ||
|
||
return connectedUsers; | ||
} | ||
|
||
async openTeamsChat(userId: string): Promise<void> { | ||
const mail = await this.graphClientService.getUserEmail(userId); | ||
const teamsChatLink = getTeamChatURL(mail); | ||
vscode.env.openExternal(vscode.Uri.parse(teamsChatLink.href)); | ||
} | ||
|
||
async openMail(userId: string): Promise<void> { | ||
const mail = await this.graphClientService.getUserEmail(userId); | ||
const mailToPath = getMailToPath(mail); | ||
vscode.env.openExternal(vscode.Uri.parse(mailToPath)); | ||
} | ||
} | ||
|
||
export class UserNode extends vscode.TreeItem { | ||
constructor( | ||
public readonly label: string, | ||
public readonly id: string, | ||
public readonly collapsibleState: vscode.TreeItemCollapsibleState | ||
) { | ||
super(label, collapsibleState); | ||
|
||
this.tooltip = this.label; | ||
this.iconPath = new vscode.ThemeIcon(Constants.THEME_ICON_ACCOUNT); | ||
} | ||
|
||
contextValue = Constants.USER_COLLABORATION_CONTEXT_VALUE; | ||
} |