Skip to content

Commit

Permalink
Named command, method and provider more logically
Browse files Browse the repository at this point in the history
  • Loading branch information
ritikramuka committed Dec 7, 2023
1 parent 584b763 commit 5f5617c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@
],
"commands": [
{
"command": "powerpages.powerPagesPeopleOnTheSite.openTeamsChat",
"command": "powerpages.collaboration.openTeamsChat",
"title": "Open Teams Chat",
"icon": {
"light": "src/web/client/assets/microsoftTeamsIcon/light/microsoftTeams.svg",
"dark": "src/web/client/assets/microsoftTeamsIcon/dark/microsoftTeams.svg"
}
},
{
"command": "powerpages.powerPagesPeopleOnTheSite.openMail",
"command": "powerpages.collaboration.openMail",
"title": "Open Mail",
"icon": "$(mail)"
},
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions src/web/client/WebExtensionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 4 additions & 0 deletions src/web/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
18 changes: 9 additions & 9 deletions src/web/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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(
Expand All @@ -365,7 +365,7 @@ export function createWebWorkerInstance(
data.userId,
data.entityId
);
WebExtensionContext.powerPagesUserCollaborationProvider.refresh();
WebExtensionContext.userCollaborationProvider.refresh();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserNode>
{
private graphClientService: GraphClientService;
Expand Down Expand Up @@ -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;
}

0 comments on commit 5f5617c

Please sign in to comment.