Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move powerPagesNavigationActionsHub to common #931

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,6 @@
{
"id": "powerpages.powerPagesFileExplorer",
"name": "%microsoft-powerplatform-portals.navigation-loop.powerPagesFileExplorer.title%",
"when": "isWeb && virtualWorkspace",
"icon": "./src/web/client/assets/powerPages.svg",
"contextualTitle": "%microsoft-powerplatform-portals.navigation-loop.powerPagesFileExplorer.title%",
"visibility": "visible"
Expand Down Expand Up @@ -1124,4 +1123,4 @@
"bufferutil": "^4.0.6",
"utf-8-validate": "^5.0.9"
}
}
}
13 changes: 13 additions & 0 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { oneDSLoggerWrapper } from "../common/OneDSLoggerTelemetry/oneDSLoggerWr
import { OrgChangeNotifier, orgChangeEvent } from "../common/OrgChangeNotifier";
import { ActiveOrgOutput } from "./pac/PacTypes";
import { telemetryEventNames } from "./telemetry/TelemetryEventNames";
import { PowerPagesNavigationProvider } from "../common/webViews/powerPagesNavigationProvider";

let client: LanguageClient;
let _context: vscode.ExtensionContext;
Expand Down Expand Up @@ -114,6 +115,18 @@ export async function activate(
)
);

// portals action hub
const powerPagesNavigationProvider = new PowerPagesNavigationProvider();
_context.subscriptions.push(
vscode.window.registerTreeDataProvider('powerpages.powerPagesFileExplorer', powerPagesNavigationProvider)
);
_context.subscriptions.push(
vscode.commands.registerCommand('powerpages.powerPagesFileExplorer.powerPagesRuntimePreview', () => powerPagesNavigationProvider.previewPowerPageSite("https://site-zih6k.powerappsportals.com/"))
);
_context.subscriptions.push(
vscode.commands.registerCommand('powerpages.powerPagesFileExplorer.backToStudio', () => powerPagesNavigationProvider.backToStudio("https://make.powerpages.microsoft.com/e/1fdc4473-a512-e14e-8326-a5b8a3fa024f/sites/37de2c85-bdf3-48b1-b262-df1f3a152ac3/pages#webpages/1f653e2b-0768-46b7-8047-2cf373f1fa17"))
);

// registering bootstrapdiff command
_context.subscriptions.push(
vscode.commands.registerCommand('microsoft-powerapps-portals.bootstrap-diff', async () => {
Expand Down
4 changes: 4 additions & 0 deletions src/common/TelemetryConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ export const VSCODE_EXTENSION_NPS_AUTHENTICATION_COMPLETED = "VSCodeExtensionNPS
export const VSCODE_EXTENSION_NPS_AUTHENTICATION_FAILED = "VSCodeExtensionNPSAuthenticationFailed";
export const VSCODE_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_FAILED = "VSCodeExtensionGraphClientAuthenticationFailed";
export const VSCODE_EXTENSION_GRAPH_CLIENT_AUTHENTICATION_COMPLETED = "VSCodeExtensionGraphClientAuthenticationCompleted";

// Telemetry Event Names for WebViews
export const WEB_EXTENSION_PREVIEW_SITE_TRIGGERED = "WebExtensionPreviewSiteTriggered";
export const WEB_EXTENSION_BACK_TO_STUDIO_TRIGGERED = "WebExtensionBackToStudioTriggered";
5 changes: 4 additions & 1 deletion src/common/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export function getNonce() {
return text;
}


export function getUserName(user: string) {
const parts = user.split(" - ");
return parts[0];
Expand Down Expand Up @@ -152,3 +151,7 @@ export async function createAuthProfileExp(pacWrapper: PacWrapper | undefined) {
return;
}
}

export function isStringUndefinedOrEmpty(value: string | undefined): boolean {
return value === undefined || value === '';
}
11 changes: 11 additions & 0 deletions src/common/webViews/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

export enum httpMethod {
PATCH = "PATCH",
GET = "GET",
POST = "POST",
DELETE = "DELETE",
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

import * as vscode from 'vscode';
import * as path from 'path';
import WebExtensionContext from "../WebExtensionContext";
import { httpMethod, queryParameters } from '../common/constants';
import { getBackToStudioURL, isStringUndefinedOrEmpty } from '../utilities/commonUtil';
import { telemetryEventNames } from '../telemetry/constants';
import WebExtensionContext from "../../web/client/WebExtensionContext";
import { httpMethod } from './constants';
import { isStringUndefinedOrEmpty } from '../Utils';
import { WEB_EXTENSION_BACK_TO_STUDIO_TRIGGERED, WEB_EXTENSION_PREVIEW_SITE_TRIGGERED } from '../TelemetryConstants';

declare const IS_DESKTOP: string | undefined;

export class PowerPagesNavigationProvider implements vscode.TreeDataProvider<PowerPagesNode> {

Expand Down Expand Up @@ -60,15 +62,14 @@ export class PowerPagesNavigationProvider implements vscode.TreeDataProvider<Pow
return nodes;
}

async previewPowerPageSite(): Promise<void> {
async previewPowerPageSite(websitePreviewUrl: string): Promise<void> {
let requestSentAtTime = new Date().getTime();
const websitePreviewUrl = WebExtensionContext.urlParametersMap.get(queryParameters.WEBSITE_PREVIEW_URL) as string;

if (isStringUndefinedOrEmpty(websitePreviewUrl)) {
vscode.window.showErrorMessage(vscode.l10n.t("Preview site URL is not available"));

WebExtensionContext.telemetry.sendErrorTelemetry(
telemetryEventNames.WEB_EXTENSION_PREVIEW_SITE_TRIGGERED,
WEB_EXTENSION_PREVIEW_SITE_TRIGGERED,
vscode.l10n.t("Preview site URL is not available")
);
return;
Expand All @@ -84,7 +85,12 @@ export class PowerPagesNavigationProvider implements vscode.TreeDataProvider<Pow
this.previewPowerPageSite.name
);
requestSentAtTime = new Date().getTime();
WebExtensionContext.dataverseAuthentication();

if (IS_DESKTOP) {
// call dataverseAuthentication() for desktop
} else {
WebExtensionContext.dataverseAuthentication();
}

await vscode.window.withProgress(
{
Expand All @@ -93,9 +99,17 @@ export class PowerPagesNavigationProvider implements vscode.TreeDataProvider<Pow
title: vscode.l10n.t("Opening preview site..."),
},
async () => {
let dataverseAccessToken = undefined;

if (IS_DESKTOP) {
// get dataverseAccessToken for desktop
} else {
dataverseAccessToken = WebExtensionContext.dataverseAccessToken;
}

const response = await WebExtensionContext.concurrencyHandler.handleRequest(requestUrl, {
headers: {
authorization: "Bearer " + WebExtensionContext.dataverseAccessToken,
authorization: "Bearer " + dataverseAccessToken,
'Accept': '*/*',
'Content-Type': 'text/plain',
},
Expand All @@ -122,31 +136,29 @@ export class PowerPagesNavigationProvider implements vscode.TreeDataProvider<Pow
response?.status.toString()
);
}


}
);

vscode.env.openExternal(vscode.Uri.parse(websitePreviewUrl));
WebExtensionContext.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_PREVIEW_SITE_TRIGGERED);
WebExtensionContext.telemetry.sendInfoTelemetry(WEB_EXTENSION_PREVIEW_SITE_TRIGGERED);
}

backToStudio(): void {
const backToStudioUrl = getBackToStudioURL();
backToStudio(backToStudio: string | undefined): void {
const backToStudioUrl = backToStudio;

if (backToStudioUrl === undefined) {
vscode.window.showErrorMessage(vscode.l10n.t("Power Pages studio URL is not available"));

WebExtensionContext.telemetry.sendErrorTelemetry(
telemetryEventNames.WEB_EXTENSION_BACK_TO_STUDIO_TRIGGERED,
WEB_EXTENSION_BACK_TO_STUDIO_TRIGGERED,
vscode.l10n.t("Power Pages studio URL is not available")
);
return;
}

vscode.env.openExternal(vscode.Uri.parse(backToStudioUrl));

WebExtensionContext.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_BACK_TO_STUDIO_TRIGGERED, {
WebExtensionContext.telemetry.sendInfoTelemetry(WEB_EXTENSION_BACK_TO_STUDIO_TRIGGERED, {
backToStudioUrl: backToStudioUrl
});
}
Expand Down
9 changes: 5 additions & 4 deletions src/web/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
showErrorDialog,
} from "./common/errorHandler";
import { WebExtensionTelemetry } from "./telemetry/webExtensionTelemetry";
import { isCoPresenceEnabled, updateFileContentInFileDataMap } from "./utilities/commonUtil";
import { getBackToStudioURL, isCoPresenceEnabled, updateFileContentInFileDataMap } from "./utilities/commonUtil";
import { NPSService } from "./services/NPSService";
import { vscodeExtAppInsightsResourceProvider } from "../../common/telemetry-generated/telemetryConfiguration";
import { NPSWebView } from "./webViews/NPSWebView";
Expand All @@ -30,7 +30,7 @@ import {
} from "./utilities/fileAndEntityUtil";
import { IEntityInfo } from "./common/interfaces";
import { telemetryEventNames } from "./telemetry/constants";
import { PowerPagesNavigationProvider } from "./webViews/powerPagesNavigationProvider";
import { PowerPagesNavigationProvider } from "../../common/webViews/powerPagesNavigationProvider";
import * as copilot from "../../common/copilot/PowerPagesCopilot";
import { IOrgInfo } from "../../common/copilot/model";
import { copilotNotificationPanel, disposeNotificationPanel } from "../../common/copilot/welcome-notification/CopilotNotificationPanel";
Expand Down Expand Up @@ -262,8 +262,9 @@ export function registerCollaborationView() {
export function powerPagesNavigation() {
const powerPagesNavigationProvider = new PowerPagesNavigationProvider();
vscode.window.registerTreeDataProvider('powerpages.powerPagesFileExplorer', powerPagesNavigationProvider);
vscode.commands.registerCommand('powerpages.powerPagesFileExplorer.powerPagesRuntimePreview', () => powerPagesNavigationProvider.previewPowerPageSite());
vscode.commands.registerCommand('powerpages.powerPagesFileExplorer.backToStudio', () => powerPagesNavigationProvider.backToStudio());
const websitePreviewUrl = WebExtensionContext.urlParametersMap.get(queryParameters.WEBSITE_PREVIEW_URL) as string;
vscode.commands.registerCommand('powerpages.powerPagesFileExplorer.powerPagesRuntimePreview', () => powerPagesNavigationProvider.previewPowerPageSite(websitePreviewUrl));
vscode.commands.registerCommand('powerpages.powerPagesFileExplorer.backToStudio', () => powerPagesNavigationProvider.backToStudio(getBackToStudioURL()));
WebExtensionContext.telemetry.sendInfoTelemetry(telemetryEventNames.WEB_EXTENSION_POWER_PAGES_WEB_VIEW_REGISTERED);
}

Expand Down
Loading