From 7ccfda19c968d17934e952327b4ef166ecd41eb3 Mon Sep 17 00:00:00 2001 From: Amit Joshi Date: Tue, 12 Sep 2023 17:33:41 +0530 Subject: [PATCH 1/6] Created a panel for websites --- package.json | 19 +++ src/client/lib/PacActivityBarUI.ts | 5 +- src/client/lib/PowerPagesWebsiteView.ts | 198 ++++++++++++++++++++++++ src/client/pac/PacTypes.ts | 11 ++ 4 files changed, 232 insertions(+), 1 deletion(-) create mode 100644 src/client/lib/PowerPagesWebsiteView.ts diff --git a/package.json b/package.json index 430ea276..4c36cc70 100644 --- a/package.json +++ b/package.json @@ -291,6 +291,11 @@ "command": "microsoft-powerapps-portals.webExtension.init", "title": "%microsoft-powerapps-portals.webExtension.init.title%" }, + { + "command": "powerpages.websitePanel.refresh", + "title": "Refresh", + "icon": "$(refresh)" + }, { "command": "microsoft-powerapps-portals.webpage", "category": "Powerpages", @@ -595,6 +600,10 @@ "command": "microsoft-powerapps-portals.preview-show", "when": "never" }, + { + "command": "powerpages.websitePanel.refresh", + "when": "never" + }, { "command": "pacCLI.authPanel.refresh", "when": "never" @@ -749,6 +758,11 @@ "command": "powerpages.copilot.clearConversation", "when": "!virtualWorkspace && view == powerpages.copilot", "group": "navigation" + }, + { + "command": "powerpages.websitePanel.refresh", + "when": "!virtualWorkspace && view == powerpages.websitePanel", + "group": "navigation@1" } ], "view/item/context": [ @@ -839,6 +853,11 @@ "name": "%pacCLI.envAndSolutionsPanel.title%", "when": "!virtualWorkspace && !config.powerPlatform.experimental.disableActivityBarPanels" }, + { + "id": "powerpages.websitePanel", + "name": "Powerpages Websites", + "when": "!virtualWorkspace" + }, { "type": "webview", "id": "powerpages.copilot", diff --git a/src/client/lib/PacActivityBarUI.ts b/src/client/lib/PacActivityBarUI.ts index 7cb9bc09..df8a4649 100644 --- a/src/client/lib/PacActivityBarUI.ts +++ b/src/client/lib/PacActivityBarUI.ts @@ -9,6 +9,7 @@ import { AuthTreeView } from './AuthPanelView'; import { EnvAndSolutionTreeView } from './EnvAndSolutionTreeView'; import { PowerPagesCopilot } from '../../common/copilot/PowerPagesCopilot'; import { ITelemetry } from '../telemetry/ITelemetry'; +import { WebsiteTreeView } from './PowerPagesWebsiteView'; export function RegisterPanels(pacWrapper: PacWrapper, context: vscode.ExtensionContext, telemetry: ITelemetry): vscode.Disposable[] { const authPanel = new AuthTreeView(() => pacWrapper.authList(), pacWrapper); @@ -17,6 +18,8 @@ export function RegisterPanels(pacWrapper: PacWrapper, context: vscode.Extension (environmentUrl) => pacWrapper.solutionListFromEnvironment(environmentUrl), authPanel.onDidChangeTreeData, pacWrapper); + + const websitePanel = new WebsiteTreeView(() => pacWrapper.websiteList(), pacWrapper); const copilotPanel = new PowerPagesCopilot(context.extensionUri, context, telemetry, pacWrapper); @@ -26,5 +29,5 @@ export function RegisterPanels(pacWrapper: PacWrapper, context: vscode.Extension }, }); - return [authPanel, envAndSolutionPanel, copilotPanel]; + return [authPanel, envAndSolutionPanel, copilotPanel, websitePanel]; } diff --git a/src/client/lib/PowerPagesWebsiteView.ts b/src/client/lib/PowerPagesWebsiteView.ts new file mode 100644 index 00000000..55a0e47e --- /dev/null +++ b/src/client/lib/PowerPagesWebsiteView.ts @@ -0,0 +1,198 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + +import * as os from 'os'; +import path from 'path'; +import * as vscode from 'vscode'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { WebsiteListOutput, WebsiteListing, } from '../pac/PacTypes'; +import { PacWrapper } from '../pac/PacWrapper'; + +export class WebsiteTreeView implements vscode.TreeDataProvider, vscode.Disposable { + private readonly _disposables: vscode.Disposable[] = []; + private _refreshTimeout?: NodeJS.Timeout; + private _onDidChangeTreeData: vscode.EventEmitter = new vscode.EventEmitter(); + public readonly onDidChangeTreeData: vscode.Event = this._onDidChangeTreeData.event; + + constructor( + public readonly dataSource: () => Promise, + pacWrapper: PacWrapper) { + + const watchPath = GetAuthProfileWatchPattern(); + if (watchPath) { + const watcher = vscode.workspace.createFileSystemWatcher(watchPath); + this._disposables.push( + watcher, + watcher.onDidChange(() => this.delayRefresh()), + watcher.onDidCreate(() => this.delayRefresh()), + watcher.onDidDelete(() => this.delayRefresh()) + ); + } + + this._disposables.push(...this.registerPanel(pacWrapper)); + } + + public dispose(): void { + this._disposables.forEach(d => d.dispose()); + } + + // We refresh the Auth Panel by both the FileWatcher events and by direct invocation + // after a executing a create/delete/select/etc command via the UI buttons. + // This can cause doubled refresh (and thus double `pac auth list` and `pac org list` calls). + // We want both routes, but don't want the double refresh, so use a singleton timeout limit + // to a single refresh call. + private delayRefresh(): void { + if (!this._refreshTimeout) { + this._refreshTimeout = setTimeout(() => this.refresh(), 200); + } + } + + refresh(): void { + if (this._refreshTimeout) { + clearTimeout(this._refreshTimeout); + this._refreshTimeout = undefined; + } + this._onDidChangeTreeData.fire(); + } + + public getTreeItem(element: AuthProfileTreeItem): vscode.TreeItem | Thenable { + return element; + } + + public async getChildren(element?: AuthProfileTreeItem): Promise { + if (element) { + // This "Tree" view is a flat list, so return no children when not at the root + return []; + } else { + const pacOutput = await this.dataSource(); + if (pacOutput && pacOutput.Status === "Success" && pacOutput.Information) { + const items = pacOutput.Information + // .filter(item => item.Kind !== "ADMIN") // Only Universal and Dataverse profiles + .map(item => new AuthProfileTreeItem(item)); + return items; + } else { + return []; + } + } + } + + private registerPanel(_: PacWrapper): vscode.Disposable[] { + return [ + vscode.window.registerTreeDataProvider("powerpages.websitePanel", this), + vscode.commands.registerCommand("powerpages.websitePanel.refresh", () => this.refresh()), + // vscode.commands.registerCommand("pacCLI.authPanel.clearAuthProfile", async () => { + // const confirm = vscode.l10n.t("Confirm"); + // const confirmResult = await vscode.window.showWarningMessage( + // vscode.l10n.t("Are you sure you want to clear all the Auth Profiles?"), + // confirm, + // vscode.l10n.t("Cancel")); + // if (confirmResult && confirmResult === confirm) { + // await pacWrapper.authClear(); + // this.delayRefresh(); + // } + // }), + // vscode.commands.registerCommand("pacCLI.authPanel.newAuthProfile", async () => { + // await pacWrapper.authCreateNewAuthProfile(); + // this.delayRefresh(); + // }), + // vscode.commands.registerCommand("pacCLI.authPanel.selectAuthProfile", async (item: AuthProfileTreeItem) => { + // await pacWrapper.authSelectByIndex(item.model.Index); + // this.delayRefresh(); + // }), + // vscode.commands.registerCommand("pacCLI.authPanel.deleteAuthProfile", async (item: AuthProfileTreeItem) => { + // const confirm = vscode.l10n.t("Confirm"); + // const confirmResult = await vscode.window.showWarningMessage( + // vscode.l10n.t({ message: "Are you sure you want to delete the Auth Profile {0}-{1}?", + // args: [item.model.User, item.model.Resource], + // comment: ["{0} is the user name, {1} is the URL of environment of the auth profile"] }), + // confirm, + // vscode.l10n.t("Cancel")); + // if (confirmResult && confirmResult === confirm) { + // await pacWrapper.authDeleteByIndex(item.model.Index); + // this.delayRefresh(); + // } + // }), + // vscode.commands.registerCommand('pacCLI.authPanel.nameAuthProfile', async (item: AuthProfileTreeItem) => { + // const authProfileName = await vscode.window.showInputBox({ + // title: vscode.l10n.t("Name/Rename Auth Profile"), + // prompt: vscode.l10n.t("The name you want to give to this authentication profile"), + // validateInput: value => value.length <= 30 ? null : vscode.l10n.t('Maximum 30 characters allowed') + // }); + // if (authProfileName) { + // await pacWrapper.authNameByIndex(item.model.Index, authProfileName); + // this.delayRefresh(); + // } + // }), + // vscode.commands.registerCommand('pacCLI.authPanel.navigateToResource', (item: AuthProfileTreeItem) => { + // vscode.env.openExternal(vscode.Uri.parse(item.model.Resource)); + // }), + // vscode.commands.registerCommand('pacCLI.authPanel.copyUser', (item: AuthProfileTreeItem) => { + // vscode.env.clipboard.writeText(item.model.User); + // }) + ]; + } +} + +class AuthProfileTreeItem extends vscode.TreeItem { + public constructor(public readonly model: string) { + super(AuthProfileTreeItem.createLabel(model), vscode.TreeItemCollapsibleState.Collapsed); + this.contextValue = model; + //this.tooltip = AuthProfileTreeItem.createTooltip(model); + // if (model.IsActive){ + // this.iconPath = new vscode.ThemeIcon("star-full") + // } + } + private static createLabel(profile: string): string { + // if (profile.Name) { + // return `${profile.Kind}: ${profile.Name}`; + // } else if (profile.Kind === "ADMIN" || profile.Kind === "UNIVERSAL") { + // return `${profile.Kind}: ${profile.User}`; + // } else { + // return `${profile.Kind}: ${profile.Resource}`; + // } + return `${profile}`; + } + // private static createTooltip(profile: WebsiteListing): string { + // const tooltip = [ + // vscode.l10n.t({ + // message: "Profile Kind: {0}", + // args: [profile.Kind], + // comment: ["The {0} represents the profile type (Admin vs Dataverse)"]}) + // ]; + // if (profile.Name) { + // tooltip.push(vscode.l10n.t({ + // message: "Name: {0}", + // args: [profile.Name], + // comment: ["The {0} represents the optional name the user provided for the profile)"]})); + // } + + // tooltip.push(vscode.l10n.t({ + // message: "User: {0}", + // args: [profile.User], + // comment: ["The {0} represents auth profile's user name (email address))"]})); + // if (profile.CloudInstance) { + // tooltip.push(vscode.l10n.t({ + // message: "Cloud Instance: {0}", + // args: [profile.CloudInstance], + // comment: ["The {0} represents profile's Azure Cloud Instances"]})); + // } + // return tooltip.join('\n'); + // } +} + +export function GetAuthProfileWatchPattern(): vscode.RelativePattern | undefined { + if (os.platform() === 'win32') { + return process.env.LOCALAPPDATA + ? new vscode.RelativePattern(path.join(process.env.LOCALAPPDATA, "Microsoft", "PowerAppsCli"), "authprofiles*.json") + : undefined; + } + else if (os.platform() === 'linux' || os.platform() === 'darwin') { + return process.env.HOME + ? new vscode.RelativePattern(path.join(process.env.HOME, ".local", "share", "Microsoft", "PowerAppsCli"), "authprofiles*.json") + : undefined + } + + return undefined; +} diff --git a/src/client/pac/PacTypes.ts b/src/client/pac/PacTypes.ts index f0a6a098..00208494 100644 --- a/src/client/pac/PacTypes.ts +++ b/src/client/pac/PacTypes.ts @@ -75,3 +75,14 @@ export type ActiveOrgOutput = { UserId : string, EnvironmentId: string, } + +export type WebsiteListOutput = PacOutput & { + Results: WebsiteListing[]; +} + +export type WebsiteListing = { + Index: number; + WebsiteId: string; + WebsiteName: string; +} + From 58bb103d31ec2451ac01953842098a866356ccaf Mon Sep 17 00:00:00 2001 From: Amit Joshi Date: Tue, 12 Sep 2023 21:20:34 +0530 Subject: [PATCH 2/6] website download functionality --- src/client/lib/PacTerminal.ts | 1 + src/client/lib/PowerPagesWebsiteView.ts | 20 ++++++++++++++++++++ src/client/pac/PacWrapper.ts | 6 +++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/client/lib/PacTerminal.ts b/src/client/lib/PacTerminal.ts index 8b3e8560..d37fe8f1 100644 --- a/src/client/lib/PacTerminal.ts +++ b/src/client/lib/PacTerminal.ts @@ -46,6 +46,7 @@ export class PacTerminal implements vscode.Disposable { vscode.commands.registerCommand('pacCLI.pacPackageHelp', () => PacTerminal.getTerminal().sendText("pac package help")), vscode.commands.registerCommand('pacCLI.pacPcfHelp', () => PacTerminal.getTerminal().sendText("pac pcf help")), vscode.commands.registerCommand('pacCLI.pacSolutionHelp', () => PacTerminal.getTerminal().sendText("pac solution help"))); + vscode.commands.registerCommand('pacCLI.pacPaportalDownload', (websiteId, path) => PacTerminal.getTerminal().sendText(`pac paportal download -id ${websiteId} -p ${path} -o`)); this._cmdDisposables.push(vscode.commands.registerCommand(`pacCLI.enableTelemetry`, async () => { const result = await this._pacWrapper.enableTelemetry(); diff --git a/src/client/lib/PowerPagesWebsiteView.ts b/src/client/lib/PowerPagesWebsiteView.ts index 55a0e47e..04a2f39b 100644 --- a/src/client/lib/PowerPagesWebsiteView.ts +++ b/src/client/lib/PowerPagesWebsiteView.ts @@ -82,6 +82,19 @@ export class WebsiteTreeView implements vscode.TreeDataProvider this.refresh()), + vscode.commands.registerCommand("powerpages.websitePanel.downloadWebsite", async () => { + const downloadPath = await vscode.window.showOpenDialog({ + canSelectFiles: false, + canSelectFolders: true, + canSelectMany: false, + openLabel: vscode.l10n.t("Select Folder") + }); + if (downloadPath && downloadPath.length > 0) { + const websiteDownloadPath = this.removeLeadingSlash(downloadPath[0].path); + vscode.window.showInformationMessage(vscode.l10n.t("Downloading website...")); + vscode.commands.executeCommand("pacCLI.pacPaportalDownload", '7b9d41f2-9748-ee11-be6f-6045bd072a16' , websiteDownloadPath); + } + }), // vscode.commands.registerCommand("pacCLI.authPanel.clearAuthProfile", async () => { // const confirm = vscode.l10n.t("Confirm"); // const confirmResult = await vscode.window.showWarningMessage( @@ -133,6 +146,13 @@ export class WebsiteTreeView implements vscode.TreeDataProvider(new PacArguments("telemetry", "disable")); } + public async websiteList(): Promise { + return this.executeCommandAndParseResults(new PacArguments("paportal", "list")); + } + public exit() : void { this.pacInterop.exit(); } From 6b6e4a2fe98b6c23f73699ee4da8f89c6328243b Mon Sep 17 00:00:00 2001 From: Amit Joshi Date: Wed, 13 Sep 2023 15:55:59 +0530 Subject: [PATCH 3/6] updated DL icon and flow --- package.json | 16 +++++++++++++++- src/client/lib/PowerPagesWebsiteView.ts | 12 +++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4c36cc70..dcccf88a 100644 --- a/package.json +++ b/package.json @@ -296,6 +296,11 @@ "title": "Refresh", "icon": "$(refresh)" }, + { + "command": "powerpages.websitePanel.downloadWebsite", + "title": "Download Website", + "icon": "$(arrow-down)" + }, { "command": "microsoft-powerapps-portals.webpage", "category": "Powerpages", @@ -604,6 +609,10 @@ "command": "powerpages.websitePanel.refresh", "when": "never" }, + { + "command": "powerpages.websitePanel.downloadWebsite", + "when": "never" + }, { "command": "pacCLI.authPanel.refresh", "when": "never" @@ -823,6 +832,11 @@ { "command": "pacCLI.envAndSolutionsPanel.copyOrganizationId", "when": "!virtualWorkspace && view == pacCLI.envAndSolutionsPanel && viewItem == ENVIRONMENT" + }, + { + "command": "powerpages.websitePanel.downloadWebsite", + "when": "!virtualWorkspace && view == powerpages.websitePanel", + "group": "inline" } ] }, @@ -855,7 +869,7 @@ }, { "id": "powerpages.websitePanel", - "name": "Powerpages Websites", + "name": "Power Pages Websites", "when": "!virtualWorkspace" }, { diff --git a/src/client/lib/PowerPagesWebsiteView.ts b/src/client/lib/PowerPagesWebsiteView.ts index 04a2f39b..e79861a0 100644 --- a/src/client/lib/PowerPagesWebsiteView.ts +++ b/src/client/lib/PowerPagesWebsiteView.ts @@ -83,14 +83,12 @@ export class WebsiteTreeView implements vscode.TreeDataProvider this.refresh()), vscode.commands.registerCommand("powerpages.websitePanel.downloadWebsite", async () => { - const downloadPath = await vscode.window.showOpenDialog({ - canSelectFiles: false, - canSelectFolders: true, - canSelectMany: false, - openLabel: vscode.l10n.t("Select Folder") - }); + let downloadPath: string | undefined; + if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) { + downloadPath = vscode.workspace.workspaceFolders[0].uri.fsPath; + } if (downloadPath && downloadPath.length > 0) { - const websiteDownloadPath = this.removeLeadingSlash(downloadPath[0].path); + const websiteDownloadPath = this.removeLeadingSlash(downloadPath); vscode.window.showInformationMessage(vscode.l10n.t("Downloading website...")); vscode.commands.executeCommand("pacCLI.pacPaportalDownload", '7b9d41f2-9748-ee11-be6f-6045bd072a16' , websiteDownloadPath); } From 2cefb1e9d3cc20cfe35585da0c4d700e763cfdbc Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 19 Sep 2023 11:08:25 +0530 Subject: [PATCH 4/6] added upload command --- package.json | 14 ++++++++++++++ src/client/lib/PacTerminal.ts | 1 + src/client/lib/PowerPagesWebsiteView.ts | 12 ++++++++++++ 3 files changed, 27 insertions(+) diff --git a/package.json b/package.json index dcccf88a..e4447ffa 100644 --- a/package.json +++ b/package.json @@ -301,6 +301,11 @@ "title": "Download Website", "icon": "$(arrow-down)" }, + { + "command": "powerpages.websitePanel.uploadWebsite", + "title": "Upload Website", + "icon": "$(arrow-up)" + }, { "command": "microsoft-powerapps-portals.webpage", "category": "Powerpages", @@ -613,6 +618,10 @@ "command": "powerpages.websitePanel.downloadWebsite", "when": "never" }, + { + "command": "powerpages.websitePanel.uploadWebsite", + "when": "never" + }, { "command": "pacCLI.authPanel.refresh", "when": "never" @@ -837,6 +846,11 @@ "command": "powerpages.websitePanel.downloadWebsite", "when": "!virtualWorkspace && view == powerpages.websitePanel", "group": "inline" + }, + { + "command": "powerpages.websitePanel.uploadWebsite", + "when": "!virtualWorkspace && view == powerpages.websitePanel", + "group": "inline" } ] }, diff --git a/src/client/lib/PacTerminal.ts b/src/client/lib/PacTerminal.ts index d37fe8f1..ae93c541 100644 --- a/src/client/lib/PacTerminal.ts +++ b/src/client/lib/PacTerminal.ts @@ -47,6 +47,7 @@ export class PacTerminal implements vscode.Disposable { vscode.commands.registerCommand('pacCLI.pacPcfHelp', () => PacTerminal.getTerminal().sendText("pac pcf help")), vscode.commands.registerCommand('pacCLI.pacSolutionHelp', () => PacTerminal.getTerminal().sendText("pac solution help"))); vscode.commands.registerCommand('pacCLI.pacPaportalDownload', (websiteId, path) => PacTerminal.getTerminal().sendText(`pac paportal download -id ${websiteId} -p ${path} -o`)); + vscode.commands.registerCommand('pacCLI.pacPaportalUpload', (path, modelVersion) => PacTerminal.getTerminal().sendText(`pac paportal upload -p ${path} -mv ${modelVersion}`)) this._cmdDisposables.push(vscode.commands.registerCommand(`pacCLI.enableTelemetry`, async () => { const result = await this._pacWrapper.enableTelemetry(); diff --git a/src/client/lib/PowerPagesWebsiteView.ts b/src/client/lib/PowerPagesWebsiteView.ts index e79861a0..c548cacd 100644 --- a/src/client/lib/PowerPagesWebsiteView.ts +++ b/src/client/lib/PowerPagesWebsiteView.ts @@ -93,6 +93,18 @@ export class WebsiteTreeView implements vscode.TreeDataProvider { + let uploadPath: string | undefined; + const modelVersion = 1 // get model version from + if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) { + uploadPath = vscode.workspace.workspaceFolders[0].uri.fsPath; + } + if (uploadPath && uploadPath.length > 0) { + const websiteUploadPath = this.removeLeadingSlash(uploadPath); + vscode.window.showInformationMessage(vscode.l10n.t("Uploading website...")); + vscode.commands.executeCommand("pacCLI.pacPaportalDownload", websiteUploadPath, modelVersion); + } + }), // vscode.commands.registerCommand("pacCLI.authPanel.clearAuthProfile", async () => { // const confirm = vscode.l10n.t("Confirm"); // const confirmResult = await vscode.window.showWarningMessage( From 7948f75ec9afa71687e0c3b7fee2501c1dcbab9c Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 19 Sep 2023 17:46:50 +0530 Subject: [PATCH 5/6] added submenus --- package.json | 40 +++++++++++++++++++++++++ src/client/lib/PacTerminal.ts | 3 +- src/client/lib/PowerPagesWebsiteView.ts | 14 ++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e4447ffa..5bc125a6 100644 --- a/package.json +++ b/package.json @@ -306,6 +306,10 @@ "title": "Upload Website", "icon": "$(arrow-up)" }, + { + "command": "powerpages.websitePanel.uploadWebsiteForceAll", + "title": "Upload Website (force all)" + }, { "command": "microsoft-powerapps-portals.webpage", "category": "Powerpages", @@ -622,6 +626,10 @@ "command": "powerpages.websitePanel.uploadWebsite", "when": "never" }, + { + "command": "powerpages.websitePanel.uploadWebsiteForceAll", + "when": "never" + }, { "command": "pacCLI.authPanel.refresh", "when": "never" @@ -851,13 +859,45 @@ "command": "powerpages.websitePanel.uploadWebsite", "when": "!virtualWorkspace && view == powerpages.websitePanel", "group": "inline" + }, + { + "submenu": "microsoft-powerpages-download" + }, + { + "submenu": "microsoft-powerpages-upload" + } + + ], + "microsoft-powerpages-download":[ + { + "command": "powerpages.websitePanel.downloadWebsite", + "when": "!virtualWorkspace && view == powerpages.websitePanel" + } + ], + "microsoft-powerpages-upload":[ + { + "command": "powerpages.websitePanel.uploadWebsite", + "when": "!virtualWorkspace && view == powerpages.websitePanel" + }, + { + "command": "powerpages.websitePanel.uploadWebsiteForceAll", + "when": "!virtualWorkspace && view == powerpages.websitePanel" } ] + }, "submenus": [ { "id": "microsoft-powerapps-portals.powerpages", "label": "Power Pages" + }, + { + "id": "microsoft-powerpages-download", + "label": "Download" + }, + { + "id": "microsoft-powerpages-upload", + "label": "Upload" } ], "viewsContainers": { diff --git a/src/client/lib/PacTerminal.ts b/src/client/lib/PacTerminal.ts index ae93c541..8731c816 100644 --- a/src/client/lib/PacTerminal.ts +++ b/src/client/lib/PacTerminal.ts @@ -46,8 +46,9 @@ export class PacTerminal implements vscode.Disposable { vscode.commands.registerCommand('pacCLI.pacPackageHelp', () => PacTerminal.getTerminal().sendText("pac package help")), vscode.commands.registerCommand('pacCLI.pacPcfHelp', () => PacTerminal.getTerminal().sendText("pac pcf help")), vscode.commands.registerCommand('pacCLI.pacSolutionHelp', () => PacTerminal.getTerminal().sendText("pac solution help"))); - vscode.commands.registerCommand('pacCLI.pacPaportalDownload', (websiteId, path) => PacTerminal.getTerminal().sendText(`pac paportal download -id ${websiteId} -p ${path} -o`)); + vscode.commands.registerCommand('pacCLI.pacPaportalDownload', (websiteId, path) => PacTerminal.getTerminal().sendText(`pac paportal download -id ${websiteId} -p ${path}`)); vscode.commands.registerCommand('pacCLI.pacPaportalUpload', (path, modelVersion) => PacTerminal.getTerminal().sendText(`pac paportal upload -p ${path} -mv ${modelVersion}`)) + vscode.commands.registerCommand('pacCLI.pacPaportalUploadForce', (path, modelVersion) => PacTerminal.getTerminal().sendText(`pac paportal upload -p ${path} -mv ${modelVersion} -f`)) this._cmdDisposables.push(vscode.commands.registerCommand(`pacCLI.enableTelemetry`, async () => { const result = await this._pacWrapper.enableTelemetry(); diff --git a/src/client/lib/PowerPagesWebsiteView.ts b/src/client/lib/PowerPagesWebsiteView.ts index c548cacd..0c57689a 100644 --- a/src/client/lib/PowerPagesWebsiteView.ts +++ b/src/client/lib/PowerPagesWebsiteView.ts @@ -102,7 +102,19 @@ export class WebsiteTreeView implements vscode.TreeDataProvider 0) { const websiteUploadPath = this.removeLeadingSlash(uploadPath); vscode.window.showInformationMessage(vscode.l10n.t("Uploading website...")); - vscode.commands.executeCommand("pacCLI.pacPaportalDownload", websiteUploadPath, modelVersion); + vscode.commands.executeCommand("pacCLI.pacPaportalUpload", websiteUploadPath, modelVersion); + } + }), + vscode.commands.registerCommand("powerpages.websitePanel.uploadWebsiteForceAll", async () => { + let uploadPath: string | undefined; + const modelVersion = 1 // get model version from + if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) { + uploadPath = vscode.workspace.workspaceFolders[0].uri.fsPath; + } + if (uploadPath && uploadPath.length > 0) { + const websiteUploadPath = this.removeLeadingSlash(uploadPath); + vscode.window.showInformationMessage(vscode.l10n.t("Uploading website (force all)...")); + vscode.commands.executeCommand("pacCLI.pacPaportalUploadForce", websiteUploadPath, modelVersion); } }), // vscode.commands.registerCommand("pacCLI.authPanel.clearAuthProfile", async () => { From 19854d930d229db467bea56c4468c4feea5075e6 Mon Sep 17 00:00:00 2001 From: amitjoshi Date: Tue, 19 Sep 2023 18:00:13 +0530 Subject: [PATCH 6/6] added bootstrap migration --- package.json | 12 ++++++++++ src/client/lib/PacTerminal.ts | 1 + src/client/lib/PowerPagesWebsiteView.ts | 31 +++++++++++++++---------- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 5bc125a6..8e55fc7f 100644 --- a/package.json +++ b/package.json @@ -310,6 +310,10 @@ "command": "powerpages.websitePanel.uploadWebsiteForceAll", "title": "Upload Website (force all)" }, + { + "command": "powerpages.websitePanel.bootstrap-migration", + "title": "Bootstrap Migration" + }, { "command": "microsoft-powerapps-portals.webpage", "category": "Powerpages", @@ -626,6 +630,10 @@ "command": "powerpages.websitePanel.uploadWebsite", "when": "never" }, + { + "command": "powerpages.websitePanel.bootstrap-migration", + "when": "never" + }, { "command": "powerpages.websitePanel.uploadWebsiteForceAll", "when": "never" @@ -860,6 +868,10 @@ "when": "!virtualWorkspace && view == powerpages.websitePanel", "group": "inline" }, + { + "command": "powerpages.websitePanel.bootstrap-migration", + "when": "!virtualWorkspace && view == powerpages.websitePanel" + }, { "submenu": "microsoft-powerpages-download" }, diff --git a/src/client/lib/PacTerminal.ts b/src/client/lib/PacTerminal.ts index 8731c816..77e19b6b 100644 --- a/src/client/lib/PacTerminal.ts +++ b/src/client/lib/PacTerminal.ts @@ -49,6 +49,7 @@ export class PacTerminal implements vscode.Disposable { vscode.commands.registerCommand('pacCLI.pacPaportalDownload', (websiteId, path) => PacTerminal.getTerminal().sendText(`pac paportal download -id ${websiteId} -p ${path}`)); vscode.commands.registerCommand('pacCLI.pacPaportalUpload', (path, modelVersion) => PacTerminal.getTerminal().sendText(`pac paportal upload -p ${path} -mv ${modelVersion}`)) vscode.commands.registerCommand('pacCLI.pacPaportalUploadForce', (path, modelVersion) => PacTerminal.getTerminal().sendText(`pac paportal upload -p ${path} -mv ${modelVersion} -f`)) + vscode.commands.registerCommand('pacCLI.pacPaportalBootstrapMigration', (path) => PacTerminal.getTerminal().sendText(`pac paportal bootstrap-migrate -p ${path}`)) this._cmdDisposables.push(vscode.commands.registerCommand(`pacCLI.enableTelemetry`, async () => { const result = await this._pacWrapper.enableTelemetry(); diff --git a/src/client/lib/PowerPagesWebsiteView.ts b/src/client/lib/PowerPagesWebsiteView.ts index 0c57689a..5e8afaf7 100644 --- a/src/client/lib/PowerPagesWebsiteView.ts +++ b/src/client/lib/PowerPagesWebsiteView.ts @@ -83,10 +83,7 @@ export class WebsiteTreeView implements vscode.TreeDataProvider this.refresh()), vscode.commands.registerCommand("powerpages.websitePanel.downloadWebsite", async () => { - let downloadPath: string | undefined; - if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) { - downloadPath = vscode.workspace.workspaceFolders[0].uri.fsPath; - } + const downloadPath: string | undefined = this.getCurrentWorkspacePath(); if (downloadPath && downloadPath.length > 0) { const websiteDownloadPath = this.removeLeadingSlash(downloadPath); vscode.window.showInformationMessage(vscode.l10n.t("Downloading website...")); @@ -94,11 +91,9 @@ export class WebsiteTreeView implements vscode.TreeDataProvider { - let uploadPath: string | undefined; + const uploadPath: string | undefined = this.getCurrentWorkspacePath(); const modelVersion = 1 // get model version from - if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) { - uploadPath = vscode.workspace.workspaceFolders[0].uri.fsPath; - } + if (uploadPath && uploadPath.length > 0) { const websiteUploadPath = this.removeLeadingSlash(uploadPath); vscode.window.showInformationMessage(vscode.l10n.t("Uploading website...")); @@ -106,17 +101,22 @@ export class WebsiteTreeView implements vscode.TreeDataProvider { - let uploadPath: string | undefined; + const uploadPath: string | undefined = this.getCurrentWorkspacePath(); const modelVersion = 1 // get model version from - if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) { - uploadPath = vscode.workspace.workspaceFolders[0].uri.fsPath; - } if (uploadPath && uploadPath.length > 0) { const websiteUploadPath = this.removeLeadingSlash(uploadPath); vscode.window.showInformationMessage(vscode.l10n.t("Uploading website (force all)...")); vscode.commands.executeCommand("pacCLI.pacPaportalUploadForce", websiteUploadPath, modelVersion); } }), + vscode.commands.registerCommand("powerpages.websitePanel.bootstrap-migration", async () => { + const uploadPath: string | undefined = this.getCurrentWorkspacePath(); + if (uploadPath && uploadPath.length > 0) { + const websiteUploadPath = this.removeLeadingSlash(uploadPath); + vscode.window.showInformationMessage(vscode.l10n.t("Bootstrap Migration...")); + vscode.commands.executeCommand("pacCLI.pacPaportalBootstrapMigration", websiteUploadPath); + } + }) // vscode.commands.registerCommand("pacCLI.authPanel.clearAuthProfile", async () => { // const confirm = vscode.l10n.t("Confirm"); // const confirmResult = await vscode.window.showWarningMessage( @@ -175,6 +175,13 @@ export class WebsiteTreeView implements vscode.TreeDataProvider 0) { + return vscode.workspace.workspaceFolders[0].uri.fsPath; + } + return undefined; + } } class AuthProfileTreeItem extends vscode.TreeItem {