From 41a01bb40db002bda8236ca31c076450cd8f8603 Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Mon, 4 Dec 2023 13:13:32 +0530 Subject: [PATCH 01/10] tree webview for users present on power pages studio and vscode for web --- package.json | 17 +++ src/web/client/WebExtensionContext.ts | 105 +++++++++++------- src/web/client/extension.ts | 16 +++ .../powerPagesPeopleOnTheSiteProvider.ts | 65 +++++++++++ 4 files changed, 162 insertions(+), 41 deletions(-) create mode 100644 src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts diff --git a/package.json b/package.json index 1f8868e3..4ed97bc0 100644 --- a/package.json +++ b/package.json @@ -154,6 +154,16 @@ } ], "commands": [ + { + "command": "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", + "title": "Open Teams Chat", + "icon": "$(person)" + }, + { + "command": "powerpages.powerPagesPeopleOnTheSite.openMail", + "title": "Open Mail", + "icon": "$(mail)" + }, { "command": "powerpages.powerPagesFileExplorer.powerPagesRuntimePreview", "title": "Preview site", @@ -913,6 +923,13 @@ "icon": "./src/web/client/assets/powerPages.svg", "contextualTitle": "%microsoft-powerplatform-portals.navigation-loop.powerPagesFileExplorer.title%", "visibility": "visible" + }, + { + "id": "powerpages.powerPagesPeopleOnTheSite", + "name": "People On The Site", + "when": "isWeb && virtualWorkspace", + "contextualTitle": "People On The Site", + "visibility": "visible" } ] }, diff --git a/src/web/client/WebExtensionContext.ts b/src/web/client/WebExtensionContext.ts index 3cd6f2f5..b2aeb80f 100644 --- a/src/web/client/WebExtensionContext.ts +++ b/src/web/client/WebExtensionContext.ts @@ -32,6 +32,7 @@ import { isMultifileEnabled } from "./utilities/commonUtil"; import { UserDataMap } from "./context/userDataMap"; import { EntityForeignKeyDataMap } from "./context/entityForeignKeyDataMap"; import { QuickPickProvider } from "./webViews/QuickPickProvider"; +import { PowerPagesPeopleOnTheSiteProvider } from "./webViews/powerPagesPeopleOnTheSiteProvider"; export interface IWebExtensionContext { // From portalSchema properties @@ -112,6 +113,7 @@ class WebExtensionContext implements IWebExtensionContext { private _containerId: string; private _connectedUsers: UserDataMap; private _quickPickProvider: QuickPickProvider; + private _powerPagesPeopleOnTheSiteProvider: PowerPagesPeopleOnTheSiteProvider; public get schemaDataSourcePropertiesMap() { return this._schemaDataSourcePropertiesMap; @@ -159,10 +161,10 @@ class WebExtensionContext implements IWebExtensionContext { return this._showMultifileInVSCode; } public get extensionActivationTime() { - return this._extensionActivationTime + return this._extensionActivationTime; } public get extensionUri() { - return this._extensionUri + return this._extensionUri; } public get dataverseAccessToken() { return this._dataverseAccessToken; @@ -215,7 +217,10 @@ class WebExtensionContext implements IWebExtensionContext { public get quickPickProvider() { return this._quickPickProvider; } - + public get powerPagesPeopleOnTheSiteProvider() { + return this._powerPagesPeopleOnTheSiteProvider; + } + constructor() { this._schemaDataSourcePropertiesMap = new Map(); this._schemaEntitiesMap = new Map>(); @@ -249,6 +254,7 @@ class WebExtensionContext implements IWebExtensionContext { this._containerId = ""; this._connectedUsers = new UserDataMap(); this._quickPickProvider = new QuickPickProvider(); + this._powerPagesPeopleOnTheSiteProvider = new PowerPagesPeopleOnTheSiteProvider(); } public setWebExtensionContext( @@ -264,17 +270,21 @@ class WebExtensionContext implements IWebExtensionContext { this._defaultEntityId = entityId; this._urlParametersMap = queryParamsMap; this._rootDirectory = vscode.Uri.parse( - `${Constants.PORTALS_URI_SCHEME}:/${queryParamsMap.get( - Constants.queryParameters.WEBSITE_NAME - ) as string + `${Constants.PORTALS_URI_SCHEME}:/${ + queryParamsMap.get( + Constants.queryParameters.WEBSITE_NAME + ) as string }/`, true ); this._extensionUri = extensionUri as vscode.Uri; // Initialize multifile FF here - const enableMultifile = queryParamsMap?.get(Constants.queryParameters.ENABLE_MULTIFILE); - const isEnableMultifile = (String(enableMultifile).toLowerCase() === 'true'); + const enableMultifile = queryParamsMap?.get( + Constants.queryParameters.ENABLE_MULTIFILE + ); + const isEnableMultifile = + String(enableMultifile).toLowerCase() === "true"; this._showMultifileInVSCode = isMultifileEnabled() && isEnableMultifile; this.telemetry.sendInfoTelemetry( @@ -298,8 +308,10 @@ class WebExtensionContext implements IWebExtensionContext { const entityInfo = workspaceState.get(key) as IEntityInfo; this._vscodeWorkspaceState.set(key, entityInfo); }); - this.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_SET_VSCODE_WORKSPACE_STATE_SUCCESS, - { count: this._vscodeWorkspaceState.size.toString() }); + this.telemetry.sendInfoTelemetry( + telemetryEventNames.WEB_EXTENSION_SET_VSCODE_WORKSPACE_STATE_SUCCESS, + { count: this._vscodeWorkspaceState.size.toString() } + ); } catch (error) { this.telemetry.sendErrorTelemetry( telemetryEventNames.WEB_EXTENSION_SET_VSCODE_WORKSPACE_STATE_FAILED, @@ -403,7 +415,8 @@ class WebExtensionContext implements IWebExtensionContext { encodeAsBase64, mimeType, isContentLoaded, - logicalEntityName); + logicalEntityName + ); } public async updateEntityDetailsInContext( @@ -414,7 +427,7 @@ class WebExtensionContext implements IWebExtensionContext { attributeContent: string, mappingEntityId?: string, fileUri?: string, - rootWebPageId?: string, + rootWebPageId?: string ) { this.entityDataMap.setEntity( entityId, @@ -424,12 +437,13 @@ class WebExtensionContext implements IWebExtensionContext { attributeContent, mappingEntityId, fileUri, - rootWebPageId); + rootWebPageId + ); } public async updateForeignKeyDetailsInContext( rootWebPageId: string, - entityId: string, + entityId: string ) { this.entityForeignKeyDataMap.setEntityForeignKey( rootWebPageId, @@ -464,9 +478,12 @@ class WebExtensionContext implements IWebExtensionContext { ); requestSentAtTime = new Date().getTime(); - const response = await this._concurrencyHandler.handleRequest(requestUrl, { - headers: getCommonHeaders(accessToken), - }); + const response = await this._concurrencyHandler.handleRequest( + requestUrl, + { + headers: getCommonHeaders(accessToken), + } + ); if (!response?.ok) { throw new Error(JSON.stringify(response)); } @@ -493,8 +510,8 @@ class WebExtensionContext implements IWebExtensionContext { new Date().getTime() - requestSentAtTime, this.populateLanguageIdToCode.name, errorMsg, - '', - (error as Response)?.status.toString(), + "", + (error as Response)?.status.toString() ); } else { this.telemetry.sendErrorTelemetry( @@ -530,9 +547,12 @@ class WebExtensionContext implements IWebExtensionContext { ); requestSentAtTime = new Date().getTime(); - const response = await this._concurrencyHandler.handleRequest(requestUrl, { - headers: getCommonHeaders(accessToken), - }); + const response = await this._concurrencyHandler.handleRequest( + requestUrl, + { + headers: getCommonHeaders(accessToken), + } + ); if (!response?.ok) { throw new Error(JSON.stringify(response)); } @@ -556,7 +576,7 @@ class WebExtensionContext implements IWebExtensionContext { new Date().getTime() - requestSentAtTime, this.populateWebsiteLanguageIdToPortalLanguageMap.name, errorMsg, - '', + "", (error as Response)?.status.toString() ); } else { @@ -592,9 +612,12 @@ class WebExtensionContext implements IWebExtensionContext { ); requestSentAtTime = new Date().getTime(); - const response = await this._concurrencyHandler.handleRequest(requestUrl, { - headers: getCommonHeaders(accessToken), - }); + const response = await this._concurrencyHandler.handleRequest( + requestUrl, + { + headers: getCommonHeaders(accessToken), + } + ); if (!response?.ok) { throw new Error(JSON.stringify(response)); @@ -618,7 +641,7 @@ class WebExtensionContext implements IWebExtensionContext { new Date().getTime() - requestSentAtTime, this.populateWebsiteIdToLanguageMap.name, errorMsg, - '', + "", (error as Response)?.status.toString() ); } else { @@ -644,9 +667,7 @@ class WebExtensionContext implements IWebExtensionContext { { lcid: lcid ? lcid.toString() : "" } ); - this._websiteLanguageCode = this.languageIdCodeMap.get( - lcid - ) as string; + this._websiteLanguageCode = this.languageIdCodeMap.get(lcid) as string; this.telemetry.sendInfoTelemetry( telemetryEventNames.WEB_EXTENSION_WEBSITE_LANGUAGE_CODE, { languageCode: this._websiteLanguageCode } @@ -666,14 +687,14 @@ class WebExtensionContext implements IWebExtensionContext { } /** - * Store a value maintained in Extension context workspaceState. - * - * *Note* that using `undefined` as value removes the key from the underlying - * storage. - * - * @param key A string. - * @param value A value. - */ + * Store a value maintained in Extension context workspaceState. + * + * *Note* that using `undefined` as value removes the key from the underlying + * storage. + * + * @param key A string. + * @param value A value. + */ public updateVscodeWorkspaceState(key: string, value?: IEntityInfo) { if (value === undefined) { this._vscodeWorkspaceState.delete(key); @@ -687,7 +708,7 @@ class WebExtensionContext implements IWebExtensionContext { } // eslint-disable-next-line @typescript-eslint/no-explicit-any - public async getWorkerScript(workerUrl : URL) : Promise { + public async getWorkerScript(workerUrl: URL): Promise { try { this.telemetry.sendInfoTelemetry( telemetryEventNames.WEB_EXTENSION_FETCH_WORKER_SCRIPT @@ -695,11 +716,13 @@ class WebExtensionContext implements IWebExtensionContext { const response = await this.concurrencyHandler.handleRequest( workerUrl - ) + ); if (!response.ok) { throw new Error( - `Failed to fetch worker script '${workerUrl.toString()}': ${response.statusText}` + `Failed to fetch worker script '${workerUrl.toString()}': ${ + response.statusText + }` ); } diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index 4832566b..580f3b79 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -195,6 +195,19 @@ export function activate(context: vscode.ExtensionContext): void { showWalkthrough(context, WebExtensionContext.telemetry); } +export function powerPagesOnTheSite() { + vscode.window.registerTreeDataProvider('powerpages.powerPagesPeopleOnTheSite', WebExtensionContext.powerPagesPeopleOnTheSiteProvider); + vscode.commands.registerCommand( + "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", + () => + WebExtensionContext.powerPagesPeopleOnTheSiteProvider.openTeamsChat() + ); + vscode.commands.registerCommand( + "powerpages.powerPagesPeopleOnTheSite.openMail", + () => WebExtensionContext.powerPagesPeopleOnTheSiteProvider.openMail() + ); +} + export function powerPagesNavigation() { const powerPagesNavigationProvider = new PowerPagesNavigationProvider(); vscode.window.registerTreeDataProvider('powerpages.powerPagesFileExplorer', powerPagesNavigationProvider); @@ -301,6 +314,7 @@ export function processWillSaveDocument(context: vscode.ExtensionContext) { export function processWillStartCollaboartion(context: vscode.ExtensionContext) { // feature in progress, hence disabling it if (isCoPresenceEnabled()) { + powerPagesOnTheSite(); vscode.commands.registerCommand('powerPlatform.previewCurrentActiveUsers', () => WebExtensionContext.quickPickProvider.showQuickPick()); createWebWorkerInstance(context); } @@ -339,6 +353,7 @@ export function createWebWorkerInstance( WebExtensionContext.removeConnectedUserInContext( data.userId ); + WebExtensionContext.powerPagesPeopleOnTheSiteProvider.refresh(); } if (data.type === Constants.workerEventMessages.UPDATE_CONNECTED_USERS) { WebExtensionContext.updateConnectedUsersInContext( @@ -347,6 +362,7 @@ export function createWebWorkerInstance( data.userId, data.entityId ); + WebExtensionContext.powerPagesPeopleOnTheSiteProvider.refresh(); } }; } diff --git a/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts b/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts new file mode 100644 index 00000000..9ea345e3 --- /dev/null +++ b/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts @@ -0,0 +1,65 @@ +/* + * 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"; + +export class PowerPagesPeopleOnTheSiteProvider + implements vscode.TreeDataProvider +{ + private _onDidChangeTreeData: vscode.EventEmitter< + UserNode | undefined | void + > = new vscode.EventEmitter(); + readonly onDidChangeTreeData: vscode.Event = + this._onDidChangeTreeData.event; + + refresh(): void { + this._onDidChangeTreeData.fire(); + } + + getTreeItem(element: UserNode): vscode.TreeItem { + return element; + } + + getChildren(): Thenable { + 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, + vscode.TreeItemCollapsibleState.None + ); + }); + + return connectedUsers; + } + + openTeamsChat(): void { + console.log("Open Teams chat"); + } + + openMail(): void { + console.log("Open mail"); + } +} + +export class UserNode extends vscode.TreeItem { + constructor( + public readonly label: string, + public readonly collapsibleState: vscode.TreeItemCollapsibleState + ) { + super(label, collapsibleState); + + this.tooltip = this.label; + this.iconPath = new vscode.ThemeIcon("account"); + } + + contextValue = "userNode"; +} From 6267f3a0c05af4e2bea4be395f9feb322c9d961a Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Mon, 4 Dec 2023 13:30:44 +0530 Subject: [PATCH 02/10] inline icon for mail and teams chat --- package.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/package.json b/package.json index 4ed97bc0..78ab1680 100644 --- a/package.json +++ b/package.json @@ -872,6 +872,16 @@ { "command": "pacCLI.envAndSolutionsPanel.copyOrganizationId", "when": "!virtualWorkspace && view == pacCLI.envAndSolutionsPanel && viewItem == ENVIRONMENT" + }, + { + "command": "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", + "group": "inline", + "when": "viewItem == userNode" + }, + { + "command": "powerpages.powerPagesPeopleOnTheSite.openMail", + "group": "inline", + "when": "viewItem == userNode" } ] }, From 09aa1771346b9b7e9cf62e9e057111b5e9147590 Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Mon, 4 Dec 2023 17:31:44 +0530 Subject: [PATCH 03/10] open teams chat and mail --- src/web/client/extension.ts | 9 +++++--- src/web/client/utilities/commonUtil.ts | 8 +++++++ .../powerPagesPeopleOnTheSiteProvider.ts | 21 +++++++++++++++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index 580f3b79..ad9e5ba8 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -199,12 +199,15 @@ export function powerPagesOnTheSite() { vscode.window.registerTreeDataProvider('powerpages.powerPagesPeopleOnTheSite', WebExtensionContext.powerPagesPeopleOnTheSiteProvider); vscode.commands.registerCommand( "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", - () => - WebExtensionContext.powerPagesPeopleOnTheSiteProvider.openTeamsChat() + (event) => { + WebExtensionContext.powerPagesPeopleOnTheSiteProvider.openTeamsChat(event.id) + } ); vscode.commands.registerCommand( "powerpages.powerPagesPeopleOnTheSite.openMail", - () => WebExtensionContext.powerPagesPeopleOnTheSiteProvider.openMail() + (event) => { + WebExtensionContext.powerPagesPeopleOnTheSiteProvider.openMail(event.id) + } ); } diff --git a/src/web/client/utilities/commonUtil.ts b/src/web/client/utilities/commonUtil.ts index f2ce812c..f1828075 100644 --- a/src/web/client/utilities/commonUtil.ts +++ b/src/web/client/utilities/commonUtil.ts @@ -266,3 +266,11 @@ export function getImageFileContent(fileFsPath: string, fileContent: Uint8Array) return webFileV2 ? fileContent : convertContentToString(fileContent, true); } + +export function getTeamChatURL (mail: string) { + return new URL(mail, "https://teams.microsoft.com/l/chat/0/0?users="); +} + +export function getMailToPath (mail: string) { + return `mailto:${mail}`; +} diff --git a/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts b/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts index 9ea345e3..14aec93c 100644 --- a/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts +++ b/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts @@ -5,16 +5,23 @@ import * as vscode from "vscode"; import WebExtensionContext from "../WebExtensionContext"; +import { GraphClientService } from "../services/graphClientService"; +import { getMailToPath, getTeamChatURL } from "../utilities/commonUtil"; export class PowerPagesPeopleOnTheSiteProvider implements vscode.TreeDataProvider { + private graphClientService: GraphClientService; private _onDidChangeTreeData: vscode.EventEmitter< UserNode | undefined | void > = new vscode.EventEmitter(); readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; + constructor() { + this.graphClientService = new GraphClientService(); + } + refresh(): void { this._onDidChangeTreeData.fire(); } @@ -34,6 +41,7 @@ export class PowerPagesPeopleOnTheSiteProvider ).map(([, value]) => { return new UserNode( value._userName, + value._userId, vscode.TreeItemCollapsibleState.None ); }); @@ -41,18 +49,23 @@ export class PowerPagesPeopleOnTheSiteProvider return connectedUsers; } - openTeamsChat(): void { - console.log("Open Teams chat"); + async openTeamsChat(userId: string): Promise { + const mail = await this.graphClientService.getUserEmail(userId); + const teamsChatLink = getTeamChatURL(mail); + vscode.env.openExternal(vscode.Uri.parse(teamsChatLink.href)); } - openMail(): void { - console.log("Open mail"); + async openMail(userId: string): Promise { + 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); From 57ce58c82b82d5fa47d884cb9a5c6f4bd88f80ab Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Mon, 4 Dec 2023 17:42:26 +0530 Subject: [PATCH 04/10] renamed provider --- src/web/client/WebExtensionContext.ts | 15 +++++++++------ ....ts => powerPagesUserCollaborationProvider.ts} | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) rename src/web/client/webViews/{powerPagesPeopleOnTheSiteProvider.ts => powerPagesUserCollaborationProvider.ts} (98%) diff --git a/src/web/client/WebExtensionContext.ts b/src/web/client/WebExtensionContext.ts index b2aeb80f..d9c9e963 100644 --- a/src/web/client/WebExtensionContext.ts +++ b/src/web/client/WebExtensionContext.ts @@ -21,7 +21,10 @@ import { getWebsiteIdToLcidMap, getWebsiteLanguageIdToPortalLanguageIdMap, } from "./utilities/schemaHelperUtil"; -import { getCustomRequestURL, getOrCreateSharedWorkspace } from "./utilities/urlBuilderUtil"; +import { + getCustomRequestURL, + getOrCreateSharedWorkspace, +} from "./utilities/urlBuilderUtil"; import { schemaKey } from "./schema/constants"; import { telemetryEventNames } from "./telemetry/constants"; import { EntityDataMap } from "./context/entityDataMap"; @@ -32,7 +35,7 @@ import { isMultifileEnabled } from "./utilities/commonUtil"; import { UserDataMap } from "./context/userDataMap"; import { EntityForeignKeyDataMap } from "./context/entityForeignKeyDataMap"; import { QuickPickProvider } from "./webViews/QuickPickProvider"; -import { PowerPagesPeopleOnTheSiteProvider } from "./webViews/powerPagesPeopleOnTheSiteProvider"; +import { PowerPagesUserCollaborationProvider } from "./webViews/powerPagesUserCollaborationProvider"; export interface IWebExtensionContext { // From portalSchema properties @@ -60,7 +63,7 @@ export interface IWebExtensionContext { defaultFileUri: vscode.Uri; // This will default to home page or current page in multifile scenario showMultifileInVSCode: boolean; extensionActivationTime: number; - extensionUri: vscode.Uri + extensionUri: vscode.Uri; // Org specific details dataverseAccessToken: string; @@ -113,7 +116,7 @@ class WebExtensionContext implements IWebExtensionContext { private _containerId: string; private _connectedUsers: UserDataMap; private _quickPickProvider: QuickPickProvider; - private _powerPagesPeopleOnTheSiteProvider: PowerPagesPeopleOnTheSiteProvider; + private _powerPagesUserCollaborationProvider: PowerPagesUserCollaborationProvider; public get schemaDataSourcePropertiesMap() { return this._schemaDataSourcePropertiesMap; @@ -218,7 +221,7 @@ class WebExtensionContext implements IWebExtensionContext { return this._quickPickProvider; } public get powerPagesPeopleOnTheSiteProvider() { - return this._powerPagesPeopleOnTheSiteProvider; + return this._powerPagesUserCollaborationProvider; } constructor() { @@ -254,7 +257,7 @@ class WebExtensionContext implements IWebExtensionContext { this._containerId = ""; this._connectedUsers = new UserDataMap(); this._quickPickProvider = new QuickPickProvider(); - this._powerPagesPeopleOnTheSiteProvider = new PowerPagesPeopleOnTheSiteProvider(); + this._powerPagesUserCollaborationProvider = new PowerPagesUserCollaborationProvider(); } public setWebExtensionContext( diff --git a/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts b/src/web/client/webViews/powerPagesUserCollaborationProvider.ts similarity index 98% rename from src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts rename to src/web/client/webViews/powerPagesUserCollaborationProvider.ts index 14aec93c..9e219d35 100644 --- a/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts +++ b/src/web/client/webViews/powerPagesUserCollaborationProvider.ts @@ -8,7 +8,7 @@ import WebExtensionContext from "../WebExtensionContext"; import { GraphClientService } from "../services/graphClientService"; import { getMailToPath, getTeamChatURL } from "../utilities/commonUtil"; -export class PowerPagesPeopleOnTheSiteProvider +export class PowerPagesUserCollaborationProvider implements vscode.TreeDataProvider { private graphClientService: GraphClientService; From 2bf3feaafd5af30bde9b0153de3f7c81842c33fc Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Mon, 4 Dec 2023 17:52:39 +0530 Subject: [PATCH 05/10] renamed provider --- src/web/client/WebExtensionContext.ts | 15 +++++++++------ ....ts => powerPagesUserCollaborationProvider.ts} | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) rename src/web/client/webViews/{powerPagesPeopleOnTheSiteProvider.ts => powerPagesUserCollaborationProvider.ts} (98%) diff --git a/src/web/client/WebExtensionContext.ts b/src/web/client/WebExtensionContext.ts index b2aeb80f..d9c9e963 100644 --- a/src/web/client/WebExtensionContext.ts +++ b/src/web/client/WebExtensionContext.ts @@ -21,7 +21,10 @@ import { getWebsiteIdToLcidMap, getWebsiteLanguageIdToPortalLanguageIdMap, } from "./utilities/schemaHelperUtil"; -import { getCustomRequestURL, getOrCreateSharedWorkspace } from "./utilities/urlBuilderUtil"; +import { + getCustomRequestURL, + getOrCreateSharedWorkspace, +} from "./utilities/urlBuilderUtil"; import { schemaKey } from "./schema/constants"; import { telemetryEventNames } from "./telemetry/constants"; import { EntityDataMap } from "./context/entityDataMap"; @@ -32,7 +35,7 @@ import { isMultifileEnabled } from "./utilities/commonUtil"; import { UserDataMap } from "./context/userDataMap"; import { EntityForeignKeyDataMap } from "./context/entityForeignKeyDataMap"; import { QuickPickProvider } from "./webViews/QuickPickProvider"; -import { PowerPagesPeopleOnTheSiteProvider } from "./webViews/powerPagesPeopleOnTheSiteProvider"; +import { PowerPagesUserCollaborationProvider } from "./webViews/powerPagesUserCollaborationProvider"; export interface IWebExtensionContext { // From portalSchema properties @@ -60,7 +63,7 @@ export interface IWebExtensionContext { defaultFileUri: vscode.Uri; // This will default to home page or current page in multifile scenario showMultifileInVSCode: boolean; extensionActivationTime: number; - extensionUri: vscode.Uri + extensionUri: vscode.Uri; // Org specific details dataverseAccessToken: string; @@ -113,7 +116,7 @@ class WebExtensionContext implements IWebExtensionContext { private _containerId: string; private _connectedUsers: UserDataMap; private _quickPickProvider: QuickPickProvider; - private _powerPagesPeopleOnTheSiteProvider: PowerPagesPeopleOnTheSiteProvider; + private _powerPagesUserCollaborationProvider: PowerPagesUserCollaborationProvider; public get schemaDataSourcePropertiesMap() { return this._schemaDataSourcePropertiesMap; @@ -218,7 +221,7 @@ class WebExtensionContext implements IWebExtensionContext { return this._quickPickProvider; } public get powerPagesPeopleOnTheSiteProvider() { - return this._powerPagesPeopleOnTheSiteProvider; + return this._powerPagesUserCollaborationProvider; } constructor() { @@ -254,7 +257,7 @@ class WebExtensionContext implements IWebExtensionContext { this._containerId = ""; this._connectedUsers = new UserDataMap(); this._quickPickProvider = new QuickPickProvider(); - this._powerPagesPeopleOnTheSiteProvider = new PowerPagesPeopleOnTheSiteProvider(); + this._powerPagesUserCollaborationProvider = new PowerPagesUserCollaborationProvider(); } public setWebExtensionContext( diff --git a/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts b/src/web/client/webViews/powerPagesUserCollaborationProvider.ts similarity index 98% rename from src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts rename to src/web/client/webViews/powerPagesUserCollaborationProvider.ts index 14aec93c..9e219d35 100644 --- a/src/web/client/webViews/powerPagesPeopleOnTheSiteProvider.ts +++ b/src/web/client/webViews/powerPagesUserCollaborationProvider.ts @@ -8,7 +8,7 @@ import WebExtensionContext from "../WebExtensionContext"; import { GraphClientService } from "../services/graphClientService"; import { getMailToPath, getTeamChatURL } from "../utilities/commonUtil"; -export class PowerPagesPeopleOnTheSiteProvider +export class PowerPagesUserCollaborationProvider implements vscode.TreeDataProvider { private graphClientService: GraphClientService; From e1c158a4fc1741f0c6fb2c13a8dfbd999bdc3980 Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Mon, 4 Dec 2023 17:58:11 +0530 Subject: [PATCH 06/10] renamed provider --- src/web/client/WebExtensionContext.ts | 2 +- src/web/client/extension.ts | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/web/client/WebExtensionContext.ts b/src/web/client/WebExtensionContext.ts index d9c9e963..9ac64be2 100644 --- a/src/web/client/WebExtensionContext.ts +++ b/src/web/client/WebExtensionContext.ts @@ -220,7 +220,7 @@ class WebExtensionContext implements IWebExtensionContext { public get quickPickProvider() { return this._quickPickProvider; } - public get powerPagesPeopleOnTheSiteProvider() { + public get powerPagesUserCollaborationProvider() { return this._powerPagesUserCollaborationProvider; } diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index ad9e5ba8..643b0660 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -196,17 +196,17 @@ export function activate(context: vscode.ExtensionContext): void { } export function powerPagesOnTheSite() { - vscode.window.registerTreeDataProvider('powerpages.powerPagesPeopleOnTheSite', WebExtensionContext.powerPagesPeopleOnTheSiteProvider); + vscode.window.registerTreeDataProvider('powerpages.powerPagesPeopleOnTheSite', WebExtensionContext.powerPagesUserCollaborationProvider); vscode.commands.registerCommand( "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", (event) => { - WebExtensionContext.powerPagesPeopleOnTheSiteProvider.openTeamsChat(event.id) + WebExtensionContext.powerPagesUserCollaborationProvider.openTeamsChat(event.id) } ); vscode.commands.registerCommand( "powerpages.powerPagesPeopleOnTheSite.openMail", (event) => { - WebExtensionContext.powerPagesPeopleOnTheSiteProvider.openMail(event.id) + WebExtensionContext.powerPagesUserCollaborationProvider.openMail(event.id) } ); } @@ -356,7 +356,7 @@ export function createWebWorkerInstance( WebExtensionContext.removeConnectedUserInContext( data.userId ); - WebExtensionContext.powerPagesPeopleOnTheSiteProvider.refresh(); + WebExtensionContext.powerPagesUserCollaborationProvider.refresh(); } if (data.type === Constants.workerEventMessages.UPDATE_CONNECTED_USERS) { WebExtensionContext.updateConnectedUsersInContext( @@ -365,7 +365,7 @@ export function createWebWorkerInstance( data.userId, data.entityId ); - WebExtensionContext.powerPagesPeopleOnTheSiteProvider.refresh(); + WebExtensionContext.powerPagesUserCollaborationProvider.refresh(); } }; } From ec0ecc81f5eccc11309822365696e91eb2e713c8 Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Tue, 5 Dec 2023 09:17:31 +0530 Subject: [PATCH 07/10] formatting reverted --- src/web/client/WebExtensionContext.ts | 102 +++++++++++--------------- 1 file changed, 41 insertions(+), 61 deletions(-) diff --git a/src/web/client/WebExtensionContext.ts b/src/web/client/WebExtensionContext.ts index 9ac64be2..eada8791 100644 --- a/src/web/client/WebExtensionContext.ts +++ b/src/web/client/WebExtensionContext.ts @@ -21,10 +21,7 @@ import { getWebsiteIdToLcidMap, getWebsiteLanguageIdToPortalLanguageIdMap, } from "./utilities/schemaHelperUtil"; -import { - getCustomRequestURL, - getOrCreateSharedWorkspace, -} from "./utilities/urlBuilderUtil"; +import { getCustomRequestURL, getOrCreateSharedWorkspace } from "./utilities/urlBuilderUtil"; import { schemaKey } from "./schema/constants"; import { telemetryEventNames } from "./telemetry/constants"; import { EntityDataMap } from "./context/entityDataMap"; @@ -63,7 +60,7 @@ export interface IWebExtensionContext { defaultFileUri: vscode.Uri; // This will default to home page or current page in multifile scenario showMultifileInVSCode: boolean; extensionActivationTime: number; - extensionUri: vscode.Uri; + extensionUri: vscode.Uri // Org specific details dataverseAccessToken: string; @@ -164,10 +161,10 @@ class WebExtensionContext implements IWebExtensionContext { return this._showMultifileInVSCode; } public get extensionActivationTime() { - return this._extensionActivationTime; + return this._extensionActivationTime } public get extensionUri() { - return this._extensionUri; + return this._extensionUri } public get dataverseAccessToken() { return this._dataverseAccessToken; @@ -273,21 +270,17 @@ class WebExtensionContext implements IWebExtensionContext { this._defaultEntityId = entityId; this._urlParametersMap = queryParamsMap; this._rootDirectory = vscode.Uri.parse( - `${Constants.PORTALS_URI_SCHEME}:/${ - queryParamsMap.get( - Constants.queryParameters.WEBSITE_NAME - ) as string + `${Constants.PORTALS_URI_SCHEME}:/${queryParamsMap.get( + Constants.queryParameters.WEBSITE_NAME + ) as string }/`, true ); this._extensionUri = extensionUri as vscode.Uri; // Initialize multifile FF here - const enableMultifile = queryParamsMap?.get( - Constants.queryParameters.ENABLE_MULTIFILE - ); - const isEnableMultifile = - String(enableMultifile).toLowerCase() === "true"; + const enableMultifile = queryParamsMap?.get(Constants.queryParameters.ENABLE_MULTIFILE); + const isEnableMultifile = (String(enableMultifile).toLowerCase() === 'true'); this._showMultifileInVSCode = isMultifileEnabled() && isEnableMultifile; this.telemetry.sendInfoTelemetry( @@ -311,10 +304,8 @@ class WebExtensionContext implements IWebExtensionContext { const entityInfo = workspaceState.get(key) as IEntityInfo; this._vscodeWorkspaceState.set(key, entityInfo); }); - this.telemetry.sendInfoTelemetry( - telemetryEventNames.WEB_EXTENSION_SET_VSCODE_WORKSPACE_STATE_SUCCESS, - { count: this._vscodeWorkspaceState.size.toString() } - ); + this.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_SET_VSCODE_WORKSPACE_STATE_SUCCESS, + { count: this._vscodeWorkspaceState.size.toString() }); } catch (error) { this.telemetry.sendErrorTelemetry( telemetryEventNames.WEB_EXTENSION_SET_VSCODE_WORKSPACE_STATE_FAILED, @@ -418,8 +409,7 @@ class WebExtensionContext implements IWebExtensionContext { encodeAsBase64, mimeType, isContentLoaded, - logicalEntityName - ); + logicalEntityName); } public async updateEntityDetailsInContext( @@ -430,7 +420,7 @@ class WebExtensionContext implements IWebExtensionContext { attributeContent: string, mappingEntityId?: string, fileUri?: string, - rootWebPageId?: string + rootWebPageId?: string, ) { this.entityDataMap.setEntity( entityId, @@ -440,13 +430,12 @@ class WebExtensionContext implements IWebExtensionContext { attributeContent, mappingEntityId, fileUri, - rootWebPageId - ); + rootWebPageId); } public async updateForeignKeyDetailsInContext( rootWebPageId: string, - entityId: string + entityId: string, ) { this.entityForeignKeyDataMap.setEntityForeignKey( rootWebPageId, @@ -481,12 +470,9 @@ class WebExtensionContext implements IWebExtensionContext { ); requestSentAtTime = new Date().getTime(); - const response = await this._concurrencyHandler.handleRequest( - requestUrl, - { - headers: getCommonHeaders(accessToken), - } - ); + const response = await this._concurrencyHandler.handleRequest(requestUrl, { + headers: getCommonHeaders(accessToken), + }); if (!response?.ok) { throw new Error(JSON.stringify(response)); } @@ -513,8 +499,8 @@ class WebExtensionContext implements IWebExtensionContext { new Date().getTime() - requestSentAtTime, this.populateLanguageIdToCode.name, errorMsg, - "", - (error as Response)?.status.toString() + '', + (error as Response)?.status.toString(), ); } else { this.telemetry.sendErrorTelemetry( @@ -550,12 +536,9 @@ class WebExtensionContext implements IWebExtensionContext { ); requestSentAtTime = new Date().getTime(); - const response = await this._concurrencyHandler.handleRequest( - requestUrl, - { - headers: getCommonHeaders(accessToken), - } - ); + const response = await this._concurrencyHandler.handleRequest(requestUrl, { + headers: getCommonHeaders(accessToken), + }); if (!response?.ok) { throw new Error(JSON.stringify(response)); } @@ -579,7 +562,7 @@ class WebExtensionContext implements IWebExtensionContext { new Date().getTime() - requestSentAtTime, this.populateWebsiteLanguageIdToPortalLanguageMap.name, errorMsg, - "", + '', (error as Response)?.status.toString() ); } else { @@ -615,12 +598,9 @@ class WebExtensionContext implements IWebExtensionContext { ); requestSentAtTime = new Date().getTime(); - const response = await this._concurrencyHandler.handleRequest( - requestUrl, - { - headers: getCommonHeaders(accessToken), - } - ); + const response = await this._concurrencyHandler.handleRequest(requestUrl, { + headers: getCommonHeaders(accessToken), + }); if (!response?.ok) { throw new Error(JSON.stringify(response)); @@ -644,7 +624,7 @@ class WebExtensionContext implements IWebExtensionContext { new Date().getTime() - requestSentAtTime, this.populateWebsiteIdToLanguageMap.name, errorMsg, - "", + '', (error as Response)?.status.toString() ); } else { @@ -670,7 +650,9 @@ class WebExtensionContext implements IWebExtensionContext { { lcid: lcid ? lcid.toString() : "" } ); - this._websiteLanguageCode = this.languageIdCodeMap.get(lcid) as string; + this._websiteLanguageCode = this.languageIdCodeMap.get( + lcid + ) as string; this.telemetry.sendInfoTelemetry( telemetryEventNames.WEB_EXTENSION_WEBSITE_LANGUAGE_CODE, { languageCode: this._websiteLanguageCode } @@ -690,14 +672,14 @@ class WebExtensionContext implements IWebExtensionContext { } /** - * Store a value maintained in Extension context workspaceState. - * - * *Note* that using `undefined` as value removes the key from the underlying - * storage. - * - * @param key A string. - * @param value A value. - */ + * Store a value maintained in Extension context workspaceState. + * + * *Note* that using `undefined` as value removes the key from the underlying + * storage. + * + * @param key A string. + * @param value A value. + */ public updateVscodeWorkspaceState(key: string, value?: IEntityInfo) { if (value === undefined) { this._vscodeWorkspaceState.delete(key); @@ -719,13 +701,11 @@ class WebExtensionContext implements IWebExtensionContext { const response = await this.concurrencyHandler.handleRequest( workerUrl - ); + ) if (!response.ok) { throw new Error( - `Failed to fetch worker script '${workerUrl.toString()}': ${ - response.statusText - }` + `Failed to fetch worker script '${workerUrl.toString()}': ${response.statusText}` ); } From e48400fc775688ddf9240827a6291ce1ed7ad8c1 Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Tue, 5 Dec 2023 09:21:57 +0530 Subject: [PATCH 08/10] formatting reverted --- src/web/client/extension.ts | 58 ++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index d11e9539..5856ebb7 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -337,42 +337,42 @@ export function createWebWorkerInstance( const workerUrl = new URL(webworkerMain.toString()); WebExtensionContext.getWorkerScript(workerUrl) - .then((workerScript) => { - const workerBlob = new Blob([workerScript], { - type: "application/javascript", - }); + .then((workerScript) => { + const workerBlob = new Blob([workerScript], { + type: "application/javascript", + }); - const urlObj = URL.createObjectURL(workerBlob); + const urlObj = URL.createObjectURL(workerBlob); - WebExtensionContext.setWorker(new Worker(urlObj)); + WebExtensionContext.setWorker(new Worker(urlObj)); - if (WebExtensionContext.worker !== undefined) { - WebExtensionContext.worker.onmessage = (event) => { - const { data } = event; + if (WebExtensionContext.worker !== undefined) { + WebExtensionContext.worker.onmessage = (event) => { + const { data } = event; - WebExtensionContext.containerId = event.data.containerId; + WebExtensionContext.containerId = event.data.containerId; - if (data.type === Constants.workerEventMessages.REMOVE_CONNECTED_USER) { - WebExtensionContext.removeConnectedUserInContext( - data.userId - ); - WebExtensionContext.powerPagesUserCollaborationProvider.refresh(); - } - if (data.type === Constants.workerEventMessages.UPDATE_CONNECTED_USERS) { - WebExtensionContext.updateConnectedUsersInContext( - data.containerId, - data.userName, - data.userId, - data.entityId - ); - WebExtensionContext.powerPagesUserCollaborationProvider.refresh(); - } - }; - } - }) + if (data.type === Constants.workerEventMessages.REMOVE_CONNECTED_USER) { + WebExtensionContext.removeConnectedUserInContext( + data.userId + ); + WebExtensionContext.powerPagesUserCollaborationProvider.refresh(); + } + if (data.type === Constants.workerEventMessages.UPDATE_CONNECTED_USERS) { + WebExtensionContext.updateConnectedUsersInContext( + data.containerId, + data.userName, + data.userId, + data.entityId + ); + WebExtensionContext.powerPagesUserCollaborationProvider.refresh(); + } + }; + } + }) WebExtensionContext.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_WEB_WORKER_REGISTERED); - } catch(error) { + } catch (error) { WebExtensionContext.telemetry.sendErrorTelemetry( telemetryEventNames.WEB_EXTENSION_WEB_WORKER_REGISTRATION_FAILED, createWebWorkerInstance.name, From 584b76367124c6b538e6a42bf029cbfd0e1721ee Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Wed, 6 Dec 2023 15:33:08 +0530 Subject: [PATCH 09/10] microsoft teams chat icon updated --- package.json | 5 ++++- .../client/assets/microsoftTeamsIcon/dark/microsoftTeams.svg | 3 +++ .../assets/microsoftTeamsIcon/light/microsoftTeams.svg | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 src/web/client/assets/microsoftTeamsIcon/dark/microsoftTeams.svg create mode 100644 src/web/client/assets/microsoftTeamsIcon/light/microsoftTeams.svg diff --git a/package.json b/package.json index 78ab1680..5913e440 100644 --- a/package.json +++ b/package.json @@ -157,7 +157,10 @@ { "command": "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", "title": "Open Teams Chat", - "icon": "$(person)" + "icon": { + "light": "src/web/client/assets/microsoftTeamsIcon/light/microsoftTeams.svg", + "dark": "src/web/client/assets/microsoftTeamsIcon/dark/microsoftTeams.svg" + } }, { "command": "powerpages.powerPagesPeopleOnTheSite.openMail", diff --git a/src/web/client/assets/microsoftTeamsIcon/dark/microsoftTeams.svg b/src/web/client/assets/microsoftTeamsIcon/dark/microsoftTeams.svg new file mode 100644 index 00000000..ea7d130a --- /dev/null +++ b/src/web/client/assets/microsoftTeamsIcon/dark/microsoftTeams.svg @@ -0,0 +1,3 @@ + + + diff --git a/src/web/client/assets/microsoftTeamsIcon/light/microsoftTeams.svg b/src/web/client/assets/microsoftTeamsIcon/light/microsoftTeams.svg new file mode 100644 index 00000000..d34e8b6a --- /dev/null +++ b/src/web/client/assets/microsoftTeamsIcon/light/microsoftTeams.svg @@ -0,0 +1,3 @@ + + + From 5f5617cda870548aba60100c7fb1817384f50521 Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Thu, 7 Dec 2023 09:41:41 +0530 Subject: [PATCH 10/10] Named command, method and provider more logically --- package.json | 10 +++++----- src/web/client/WebExtensionContext.ts | 10 +++++----- src/web/client/common/constants.ts | 4 ++++ src/web/client/extension.ts | 18 +++++++++--------- ...rovider.ts => userCollaborationProvider.ts} | 7 ++++--- 5 files changed, 27 insertions(+), 22 deletions(-) rename src/web/client/webViews/{powerPagesUserCollaborationProvider.ts => userCollaborationProvider.ts} (91%) diff --git a/package.json b/package.json index 5913e440..800844b4 100644 --- a/package.json +++ b/package.json @@ -155,7 +155,7 @@ ], "commands": [ { - "command": "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", + "command": "powerpages.collaboration.openTeamsChat", "title": "Open Teams Chat", "icon": { "light": "src/web/client/assets/microsoftTeamsIcon/light/microsoftTeams.svg", @@ -163,7 +163,7 @@ } }, { - "command": "powerpages.powerPagesPeopleOnTheSite.openMail", + "command": "powerpages.collaboration.openMail", "title": "Open Mail", "icon": "$(mail)" }, @@ -877,12 +877,12 @@ "when": "!virtualWorkspace && view == pacCLI.envAndSolutionsPanel && viewItem == ENVIRONMENT" }, { - "command": "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", + "command": "powerpages.collaboration.openTeamsChat", "group": "inline", "when": "viewItem == userNode" }, { - "command": "powerpages.powerPagesPeopleOnTheSite.openMail", + "command": "powerpages.collaboration.openMail", "group": "inline", "when": "viewItem == userNode" } @@ -938,7 +938,7 @@ "visibility": "visible" }, { - "id": "powerpages.powerPagesPeopleOnTheSite", + "id": "powerpages.collaborationView", "name": "People On The Site", "when": "isWeb && virtualWorkspace", "contextualTitle": "People On The Site", diff --git a/src/web/client/WebExtensionContext.ts b/src/web/client/WebExtensionContext.ts index eada8791..26b3a14f 100644 --- a/src/web/client/WebExtensionContext.ts +++ b/src/web/client/WebExtensionContext.ts @@ -32,7 +32,7 @@ import { isMultifileEnabled } from "./utilities/commonUtil"; import { UserDataMap } from "./context/userDataMap"; import { EntityForeignKeyDataMap } from "./context/entityForeignKeyDataMap"; import { QuickPickProvider } from "./webViews/QuickPickProvider"; -import { PowerPagesUserCollaborationProvider } from "./webViews/powerPagesUserCollaborationProvider"; +import { UserCollaborationProvider } from "./webViews/userCollaborationProvider"; export interface IWebExtensionContext { // From portalSchema properties @@ -113,7 +113,7 @@ class WebExtensionContext implements IWebExtensionContext { private _containerId: string; private _connectedUsers: UserDataMap; private _quickPickProvider: QuickPickProvider; - private _powerPagesUserCollaborationProvider: PowerPagesUserCollaborationProvider; + private _userCollaborationProvider: UserCollaborationProvider; public get schemaDataSourcePropertiesMap() { return this._schemaDataSourcePropertiesMap; @@ -217,8 +217,8 @@ class WebExtensionContext implements IWebExtensionContext { public get quickPickProvider() { return this._quickPickProvider; } - public get powerPagesUserCollaborationProvider() { - return this._powerPagesUserCollaborationProvider; + public get userCollaborationProvider() { + return this._userCollaborationProvider; } constructor() { @@ -254,7 +254,7 @@ class WebExtensionContext implements IWebExtensionContext { this._containerId = ""; this._connectedUsers = new UserDataMap(); this._quickPickProvider = new QuickPickProvider(); - this._powerPagesUserCollaborationProvider = new PowerPagesUserCollaborationProvider(); + this._userCollaborationProvider = new UserCollaborationProvider(); } public setWebExtensionContext( diff --git a/src/web/client/common/constants.ts b/src/web/client/common/constants.ts index 67c256d7..ecaaf6a3 100644 --- a/src/web/client/common/constants.ts +++ b/src/web/client/common/constants.ts @@ -132,3 +132,7 @@ export enum GraphService { } export const MICROSOFT_GRAPH_PROFILE_PICTURE_SERVICE_CALL = "/photo/$value"; + +// User collaboration constants +export const USER_COLLABORATION_CONTEXT_VALUE = "userNode"; +export const THEME_ICON_ACCOUNT = "account"; diff --git a/src/web/client/extension.ts b/src/web/client/extension.ts index 5856ebb7..c3d416a0 100644 --- a/src/web/client/extension.ts +++ b/src/web/client/extension.ts @@ -195,18 +195,18 @@ export function activate(context: vscode.ExtensionContext): void { showWalkthrough(context, WebExtensionContext.telemetry); } -export function powerPagesOnTheSite() { - vscode.window.registerTreeDataProvider('powerpages.powerPagesPeopleOnTheSite', WebExtensionContext.powerPagesUserCollaborationProvider); +export function registerCollaborationView() { + vscode.window.registerTreeDataProvider('powerpages.collaborationView', WebExtensionContext.userCollaborationProvider); vscode.commands.registerCommand( - "powerpages.powerPagesPeopleOnTheSite.openTeamsChat", + "powerpages.collaboration.openTeamsChat", (event) => { - WebExtensionContext.powerPagesUserCollaborationProvider.openTeamsChat(event.id) + WebExtensionContext.userCollaborationProvider.openTeamsChat(event.id) } ); vscode.commands.registerCommand( - "powerpages.powerPagesPeopleOnTheSite.openMail", + "powerpages.collaboration.openMail", (event) => { - WebExtensionContext.powerPagesUserCollaborationProvider.openMail(event.id) + WebExtensionContext.userCollaborationProvider.openMail(event.id) } ); } @@ -317,7 +317,7 @@ export function processWillSaveDocument(context: vscode.ExtensionContext) { export function processWillStartCollaboartion(context: vscode.ExtensionContext) { // feature in progress, hence disabling it if (isCoPresenceEnabled()) { - powerPagesOnTheSite(); + registerCollaborationView(); vscode.commands.registerCommand('powerPlatform.previewCurrentActiveUsers', () => WebExtensionContext.quickPickProvider.showQuickPick()); createWebWorkerInstance(context); } @@ -356,7 +356,7 @@ export function createWebWorkerInstance( WebExtensionContext.removeConnectedUserInContext( data.userId ); - WebExtensionContext.powerPagesUserCollaborationProvider.refresh(); + WebExtensionContext.userCollaborationProvider.refresh(); } if (data.type === Constants.workerEventMessages.UPDATE_CONNECTED_USERS) { WebExtensionContext.updateConnectedUsersInContext( @@ -365,7 +365,7 @@ export function createWebWorkerInstance( data.userId, data.entityId ); - WebExtensionContext.powerPagesUserCollaborationProvider.refresh(); + WebExtensionContext.userCollaborationProvider.refresh(); } }; } diff --git a/src/web/client/webViews/powerPagesUserCollaborationProvider.ts b/src/web/client/webViews/userCollaborationProvider.ts similarity index 91% rename from src/web/client/webViews/powerPagesUserCollaborationProvider.ts rename to src/web/client/webViews/userCollaborationProvider.ts index 9e219d35..f69df3ac 100644 --- a/src/web/client/webViews/powerPagesUserCollaborationProvider.ts +++ b/src/web/client/webViews/userCollaborationProvider.ts @@ -7,8 +7,9 @@ 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 PowerPagesUserCollaborationProvider +export class UserCollaborationProvider implements vscode.TreeDataProvider { private graphClientService: GraphClientService; @@ -71,8 +72,8 @@ export class UserNode extends vscode.TreeItem { super(label, collapsibleState); this.tooltip = this.label; - this.iconPath = new vscode.ThemeIcon("account"); + this.iconPath = new vscode.ThemeIcon(Constants.THEME_ICON_ACCOUNT); } - contextValue = "userNode"; + contextValue = Constants.USER_COLLABORATION_CONTEXT_VALUE; }