Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into users/amitjoshi/actionsHubActiveSiteUpload
  • Loading branch information
amitjoshi committed Feb 20, 2025
2 parents 354d676 + 107d0cb commit 3ccaf27
Show file tree
Hide file tree
Showing 21 changed files with 203 additions and 47 deletions.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
{
"cSpell.words": [
"appmoduleid",
"dataverse",
"entityrecord",
"Entra",
"lcid",
"MSPP",
"nupkg",
"pagetype",
"powerapps",
"powerpages",
"powerpagesiteid",
"powerplatform",
"PPAPI",
"primarydomainname",
"Puid",
"testorg",
"uniquename",
"websiteid"
],
"sarif-viewer.connectToGithubCodeScanning": "off"
Expand Down
12 changes: 9 additions & 3 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@
"Failed to get website endpoint. Please try again later": "Failed to get website endpoint. Please try again later",
"Getting website endpoint...": "Getting website endpoint...",
"Failed to get organization details. Please try again later": "Failed to get organization details. Please try again later",
"Clearing cache...": "Clearing cache...",
"Clearing cache. See [details](https://aka.ms/pages-clear-cache)./This is a markdown formatting which must persist across translations.The second line should be '[TRANSLATION HERE](https://aka.ms/pages-clear-cache).', keeping brackets and the text in the parentheses unmodified": {
"message": "Clearing cache. See [details](https://aka.ms/pages-clear-cache).",
"comment": [
"This is a markdown formatting which must persist across translations.",
"The second line should be '[TRANSLATION HERE](https://aka.ms/pages-clear-cache).', keeping brackets and the text in the parentheses unmodified"
]
},
"Authenticating...": "Authenticating...",
"Unable to clear cache": "Unable to clear cache",
"Enter the name of the web template": "Enter the name of the web template",
Expand Down Expand Up @@ -188,7 +194,7 @@
"Current": "Current",
"Be careful when you're updating public sites. The changes you make are visible to anyone immediately. Do you want to continue?": "Be careful when you're updating public sites. The changes you make are visible to anyone immediately. Do you want to continue?",
"Yes": "Yes",
"Active Environment is expired or deleted. Please select a new environment.": "Active Environment is expired or deleted. Please select a new environment.",
"Site management URL not found for the selected site. Please try again after refreshing the environment.": "Site management URL not found for the selected site. Please try again after refreshing the environment.",
"Timestamp: {0}/{0} is the timestamp": {
"message": "Timestamp: {0}",
"comment": [
Expand Down Expand Up @@ -354,4 +360,4 @@
"The {0} represents profile's Azure Cloud Instances"
]
}
}
}
15 changes: 10 additions & 5 deletions loc/translations-export/vscode-powerplatform.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
<trans-unit id="++CODE++8d35e64354d3db3df1df4ef8e6068b6b9dd58514fcf980f7071e10ed160db95a">
<source xml:lang="en">AI-generated content can contain mistakes</source>
</trans-unit>
<trans-unit id="++CODE++b7a871816816225e2493a94b2b40d7c0ab9fa8a8d14666e68c00e5a511c9f4f6">
<source xml:lang="en">Active Environment is expired or deleted. Please select a new environment.</source>
</trans-unit>
<trans-unit id="++CODE++b82f83283cc4275cf0d58b4f55d1242fe46227ee1da9db4b81b6b08804dcbf01">
<source xml:lang="en">Active Sites</source>
</trans-unit>
Expand Down Expand Up @@ -99,8 +96,10 @@
<trans-unit id="++CODE++2c8d1f9ca282591926b952dc5949d44df6204f1f0a3f5183bcd5ef7ae5864bad">
<source xml:lang="en">Choose web template</source>
</trans-unit>
<trans-unit id="++CODE++149fd22e94b05db4102d8eb8dc887a15388e66177b1e7d7b6634e5530b0998b0">
<source xml:lang="en">Clearing cache...</source>
<trans-unit id="++CODE++7aaafd1c6d6875eb1cd67e841f87457e929c922a18fef7c1452c1e1a4c036456">
<source xml:lang="en">Clearing cache. See [details](https://aka.ms/pages-clear-cache).</source>
<note>This is a markdown formatting which must persist across translations.
The second line should be '[TRANSLATION HERE](https://aka.ms/pages-clear-cache).', keeping brackets and the text in the parentheses unmodified</note>
</trans-unit>
<trans-unit id="++CODE++eef726ad55117038c05eaa478148144884ab56cadc5a46785e8221040ff7a6ec">
<source xml:lang="en">Cloud Instance: {0}</source>
Expand Down Expand Up @@ -476,6 +475,9 @@ The {3} represents Dataverse Environment's Organization ID (GUID)</note>
<trans-unit id="++CODE++899fb203e6c2faac8093e21a2fa8db0d4b13d16ea5492461d8b72dbcee3ecf2a">
<source xml:lang="en">Show Output Panel</source>
</trans-unit>
<trans-unit id="++CODE++a72357d268bce5e1643bfd74563495784179f75ace0d652db8f808f293586b63">
<source xml:lang="en">Site management URL not found for the selected site. Please try again after refreshing the environment.</source>
</trans-unit>
<trans-unit id="++CODE++f7094162bd4c4b59aa706387714347223e1569c79c5b37eb19ac754a33a0fdd0">
<source xml:lang="en">Site runtime preview feature is not enabled.</source>
</trans-unit>
Expand Down Expand Up @@ -750,6 +752,9 @@ The second line should be '[TRANSLATION HERE](command:powerplatform-walkthrough.
<trans-unit id="microsoft.powerplatform.pages.actionsHub.openSitesInStudio.title">
<source xml:lang="en">Open in Power Pages Studio</source>
</trans-unit>
<trans-unit id="microsoft.powerplatform.pages.actionsHub.inactiveSite.openSiteManagement.title">
<source xml:lang="en">Open site management</source>
</trans-unit>
<trans-unit id="powerPlatform.experimental.auth.testCloudOverride.description">
<source xml:lang="en">Overrides `#powerPlatform.auth.cloud#` for test targets. Leave blank for default behavior.</source>
<note>This is a Markdown formatted string, and `#powerPlatform.auth.cloud#` must remain unmodified.</note>
Expand Down
13 changes: 13 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@
"command": "microsoft.powerplatform.pages.actionsHub.currentActiveSite.revealInOS.linux",
"title": "%microsoft.powerplatform.pages.actionsHub.currentActiveSite.revealInOS.linux.title%"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.inactiveSite.openSiteManagement",
"title": "%microsoft.powerplatform.pages.actionsHub.inactiveSite.openSiteManagement.title%"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.activeSite.uploadSite",
"title": "%microsoft.powerplatform.pages.actionsHub.activeSite.uploadSite.title%"
Expand Down Expand Up @@ -912,6 +916,10 @@
"command": "microsoft.powerplatform.pages.actionsHub.currentActiveSite.revealInOS.linux",
"when": "never"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.inactiveSite.openSiteManagement",
"when": "never"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.activeSite.uploadSite",
"when": "never"
Expand Down Expand Up @@ -1058,6 +1066,11 @@
"when": "view == microsoft.powerplatform.pages.actionsHub && viewItem == currentActiveSite && isLinux",
"group": "activeSiteContextMenuGroup@2"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.inactiveSite.openSiteManagement",
"when": "view == microsoft.powerplatform.pages.actionsHub && viewItem == inactiveSite",
"group": "inactiveSiteContextMenuGroup@1"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.activeSite.uploadSite",
"when": "view == microsoft.powerplatform.pages.actionsHub && (viewItem == currentActiveSite)",
Expand Down
2 changes: 1 addition & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,5 @@
"microsoft.powerplatform.pages.actionsHub.currentActiveSite.revealInOS.windows.title": "Reveal in Explorer",
"microsoft.powerplatform.pages.actionsHub.currentActiveSite.revealInOS.mac.title": "Reveal in Finder",
"microsoft.powerplatform.pages.actionsHub.currentActiveSite.revealInOS.linux.title": "Open Containing Folder",
"microsoft.powerplatform.pages.actionsHub.activeSite.uploadSite.title": "Upload changes"
"microsoft.powerplatform.pages.actionsHub.inactiveSite.openSiteManagement.title": "Open site management"
}
10 changes: 10 additions & 0 deletions src/client/power-pages/actions-hub/ActionsHubCommandHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const fetchWebsites = async (): Promise<{ activeSites: IWebsiteDetails[],
]);
const activeSiteIds = new Set(activeWebsiteDetails.map(activeSite => activeSite.websiteRecordId));
const inactiveWebsiteDetails = allSites?.filter(site => !activeSiteIds.has(site.websiteRecordId)) || [];
activeWebsiteDetails = activeWebsiteDetails.map(detail => ({ ...detail, siteManagementUrl: allSites.find(site => site.websiteRecordId === detail.websiteRecordId)?.siteManagementUrl ?? "" }));

return { activeSites: activeWebsiteDetails, inactiveSites: inactiveWebsiteDetails };
}
Expand All @@ -229,6 +230,15 @@ export const revealInOS = async () => {
}
}

export const openSiteManagement = async (siteTreeItem: SiteTreeItem) => {
if (!siteTreeItem.siteInfo.siteManagementUrl) {
vscode.window.showErrorMessage(vscode.l10n.t(Constants.Strings.SITE_MANAGEMENT_URL_NOT_FOUND));
oneDSLoggerWrapper.getLogger().traceError(Constants.EventNames.SITE_MANAGEMENT_URL_NOT_FOUND, Constants.EventNames.SITE_MANAGEMENT_URL_NOT_FOUND, new Error(Constants.EventNames.SITE_MANAGEMENT_URL_NOT_FOUND), { method: openSiteManagement.name });
return;
}
await vscode.env.openExternal(vscode.Uri.parse(siteTreeItem.siteInfo.siteManagementUrl));
}

export const uploadSite = async (siteTreeItem: SiteTreeItem) => {

//Show a modal dialog to take confirmation from the user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { oneDSLoggerWrapper } from "../../../common/OneDSLoggerTelemetry/oneDSLo
import { EnvironmentGroupTreeItem } from "./tree-items/EnvironmentGroupTreeItem";
import { IEnvironmentInfo } from "./models/IEnvironmentInfo";
import { PacTerminal } from "../../lib/PacTerminal";
import { fetchWebsites, openActiveSitesInStudio, openInactiveSitesInStudio, previewSite, createNewAuthProfile, refreshEnvironment, showEnvironmentDetails, switchEnvironment, revealInOS, uploadSite } from "./ActionsHubCommandHandlers";
import { fetchWebsites, openActiveSitesInStudio, openInactiveSitesInStudio, previewSite, createNewAuthProfile, refreshEnvironment, showEnvironmentDetails, switchEnvironment, revealInOS, openSiteManagement, uploadSite } from "./ActionsHubCommandHandlers";
import PacContext from "../../pac/PacContext";
import CurrentSiteContext from "./CurrentSiteContext";
import { IWebsiteDetails } from "../../../common/services/Interfaces";
Expand Down Expand Up @@ -120,6 +120,8 @@ export class ActionsHubTreeDataProvider implements vscode.TreeDataProvider<Actio
vscode.commands.registerCommand("microsoft.powerplatform.pages.actionsHub.currentActiveSite.revealInOS.mac", revealInOS),
vscode.commands.registerCommand("microsoft.powerplatform.pages.actionsHub.currentActiveSite.revealInOS.linux", revealInOS),

vscode.commands.registerCommand("microsoft.powerplatform.pages.actionsHub.inactiveSite.openSiteManagement", openSiteManagement),

vscode.commands.registerCommand("microsoft.powerplatform.pages.actionsHub.activeSite.uploadSite", uploadSite)
];
}
Expand Down
12 changes: 10 additions & 2 deletions src/client/power-pages/actions-hub/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const Constants = {
SESSION_DETAILS: vscode.l10n.t("Session Details"),
CHANGING_ENVIRONMENT: vscode.l10n.t("Changing environment..."),
CURRENT: vscode.l10n.t("Current"),
SITE_MANAGEMENT_URL_NOT_FOUND: vscode.l10n.t("Site management URL not found for the selected site. Please try again after refreshing the environment."),
SITE_UPLOAD_CONFIRMATION: vscode.l10n.t(`Be careful when you're updating public sites. The changes you make are visible to anyone immediately. Do you want to continue?`),
YES: vscode.l10n.t("Yes"),
},
Expand All @@ -45,6 +46,7 @@ export const Constants = {
ORGANIZATION_URL_MISSING: "Organization URL is missing in the results.",
EMPTY_RESULTS_ARRAY: "Results array is empty or not an array.",
PAC_AUTH_OUTPUT_FAILURE: "pacAuthCreateOutput is missing or unsuccessful.",
SITE_MANAGEMENT_URL_NOT_FOUND: "siteManagementUrlNotFound",
ACTIONS_HUB_UPLOAD_SITE: "actionsHubUploadSite",
ACTIONS_HUB_UPLOAD_SITE_CANCELLED: "actionsHubUploadSiteCancelled",
},
Expand All @@ -60,7 +62,13 @@ export const Constants = {
SiteVisibility : {
PUBLIC: "public",
PRIVATE: "private"
},
AppNames: {
POWER_PAGES_MANAGEMENT: 'mspp_powerpagemanagement',
PORTAL_MANAGEMENT: 'dynamics365portals'
},
EntityNames: {
MSPP_WEBSITE: 'mspp_website',
ADX_WEBSITE: 'adx_website'
}
};

export const ENVIRONMENT_EXPIRED = vscode.l10n.t("Active Environment is expired or deleted. Please select a new environment.")
1 change: 1 addition & 0 deletions src/client/power-pages/actions-hub/models/IWebsiteInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface IWebsiteInfo {
status: WebsiteStatus | undefined;
isCurrent: boolean;
siteVisibility: string;
siteManagementUrl: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class ActiveGroupTreeItem extends ActionsHubTreeItem {
websiteUrl: site.websiteUrl,
status: WebsiteStatus.Active,
isCurrent: CurrentSiteContext.currentSiteId === site.websiteRecordId,
siteVisibility: site.siteVisibility ?? ""
siteVisibility: site.siteVisibility ?? "",
siteManagementUrl: site.siteManagementUrl
};

return new SiteTreeItem(siteInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export class InactiveGroupTreeItem extends ActionsHubTreeItem {
websiteUrl: site.websiteUrl,
status: WebsiteStatus.Inactive,
isCurrent: false,
siteVisibility: ""
siteVisibility: "",
siteManagementUrl: site.siteManagementUrl
};
const siteItem = new SiteTreeItem(siteInfo);
return siteItem;
Expand Down
8 changes: 7 additions & 1 deletion src/client/power-pages/preview-site/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ export const Messages = {
FAILED_TO_GET_ENDPOINT: vscode.l10n.t("Failed to get website endpoint. Please try again later"),
GETTING_WEBSITE_ENDPOINT: vscode.l10n.t("Getting website endpoint..."),
ORG_DETAILS_ERROR: vscode.l10n.t("Failed to get organization details. Please try again later"),
CLEARING_CACHE: vscode.l10n.t("Clearing cache..."),
CLEARING_CACHE: vscode.l10n.t({
message: "Clearing cache. See [details](https://aka.ms/pages-clear-cache).",
comment: [
"This is a markdown formatting which must persist across translations.",
"The second line should be '[TRANSLATION HERE](https://aka.ms/pages-clear-cache).', keeping brackets and the text in the parentheses unmodified"
]
}),
AUTHENTICATING: vscode.l10n.t("Authenticating..."),
UNABLE_TO_CLEAR_CACHE: vscode.l10n.t("Unable to clear cache"),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ describe('ActionsHubCommandHandlers', () => {
status: WebsiteStatus.Active,
websiteUrl: 'https://test-site.com',
isCurrent: false,
siteVisibility: 'Public'
siteVisibility: 'Public',
siteManagementUrl: 'https://test-site-management.com',
};
});

Expand Down Expand Up @@ -690,12 +691,13 @@ describe('ActionsHubCommandHandlers', () => {
dataModel: WebsiteDataModel.Enhanced,
websiteUrl: 'https://inactive-site-1.com',
id: 'inactive-site-1',
siteVisibility: 'private'
siteVisibility: 'private',
siteManagementUrl: "https://inactive-site-1-management.com"
}
] as IWebsiteDetails[];

const allSites = [
...activeSites,
...activeSites.map(site => ({ ...site, siteManagementUrl: "https://portalmanagement.com" })),
...inactiveSites

] as IWebsiteDetails[];
Expand All @@ -704,7 +706,7 @@ describe('ActionsHubCommandHandlers', () => {

const response = await fetchWebsites();

expect(response.activeSites).to.deep.equal(activeSites);
expect(response.activeSites).to.deep.equal([...activeSites.map(site => ({ ...site, siteManagementUrl: "https://portalmanagement.com" }))]);
expect(response.inactiveSites).to.deep.equal(inactiveSites);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,18 @@ describe("ActionsHubTreeDataProvider", () => {
expect(mockCommandHandler.calledThrice).to.be.true;
});

it("should register openSiteManagement commands", async () => {
const mockCommandHandler = sinon.stub(CommandHandlers, 'openSiteManagement');
mockCommandHandler.resolves();
const actionsHubTreeDataProvider = ActionsHubTreeDataProvider.initialize(context, pacTerminal);
actionsHubTreeDataProvider["registerPanel"](pacTerminal);

expect(registerCommandStub.calledWith("microsoft.powerplatform.pages.actionsHub.inactiveSite.openSiteManagement")).to.be.true;

await registerCommandStub.getCall(10).args[1]();
expect(mockCommandHandler.calledOnce).to.be.true;
});

//command "microsoft.powerplatform.pages.actionsHub.activeSite.uploadSite"
it("should register uploadSite command", async () => {
const mockCommandHandler = sinon.stub(CommandHandlers, 'uploadSite');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ describe('ActiveGroupTreeItem', () => {
dataverseOrganizationId: "org1",
dataModel: WebsiteDataModel.Standard,
environmentId: "env1",
siteVisibility: "public"
siteVisibility: "public",
siteManagementUrl: "http://site1.com/manage"
},
{
websiteRecordId: "2",
Expand All @@ -83,7 +84,8 @@ describe('ActiveGroupTreeItem', () => {
dataverseOrganizationId: "org2",
dataModel: WebsiteDataModel.Enhanced,
environmentId: "env2",
siteVisibility: "private"
siteVisibility: "private",
siteManagementUrl: "http://site1.com/manage"
}
];

Expand All @@ -98,7 +100,8 @@ describe('ActiveGroupTreeItem', () => {
websiteUrl: 'http://site1.com',
status: WebsiteStatus.Active,
isCurrent: true,
siteVisibility: "public"
siteVisibility: "public",
siteManagementUrl: "http://site1.com/manage"
});

const site2 = children[1] as SiteTreeItem;
Expand All @@ -109,7 +112,8 @@ describe('ActiveGroupTreeItem', () => {
websiteUrl: 'http://site2.com',
status: WebsiteStatus.Active,
isCurrent: false,
siteVisibility: "private"
siteVisibility: "private",
siteManagementUrl: "http://site1.com/manage"
});
});
});
Expand Down
Loading

0 comments on commit 3ccaf27

Please sign in to comment.