Skip to content

Commit

Permalink
[PowerPages][Actions Hub] Add commands to open active and inactive si…
Browse files Browse the repository at this point in the history
…te in PP Studio (#1124)

* [PowerPages][Actions Hub] Add commands to open active and inactive sites in Power Pages Studio

* Refactor studio URL handling to use constants for endpoints

* Add localization entries for "Current" and "Instance url" in JSON and XLF files

* Refactor studio URL generation to include environment ID and add openInactiveSitesInStudio function
  • Loading branch information
priyanshu92 authored Feb 14, 2025
1 parent 361b6a0 commit df62521
Show file tree
Hide file tree
Showing 11 changed files with 336 additions and 6 deletions.
7 changes: 7 additions & 0 deletions l10n/bundle.l10n.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"Select an environment": "Select an environment",
"Session Details": "Session Details",
"Changing environment...": "Changing environment...",
"Current": "Current",
"Active Environment is expired or deleted. Please select a new environment.": "Active Environment is expired or deleted. Please select a new environment.",
"Timestamp: {0}/{0} is the timestamp": {
"message": "Timestamp: {0}",
Expand Down Expand Up @@ -216,6 +217,12 @@
"{0} is the Unique name"
]
},
"Instance url: {0}/{0} is the Instance Url": {
"message": "Instance url: {0}",
"comment": [
"{0} is the Instance Url"
]
},
"Environment ID: {0}/{0} is the Environment ID": {
"message": "Environment ID: {0}",
"comment": [
Expand Down
10 changes: 10 additions & 0 deletions loc/translations-export/vscode-powerplatform.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@
<source xml:lang="en">Creating {0}...</source>
<note>{0} will be replaced by the entity type.</note>
</trans-unit>
<trans-unit id="++CODE++e0d1b68224bf0b31ef16b206c65b5f8f6b89d18161f4a7cdcb8d0ac8d952549a">
<source xml:lang="en">Current</source>
</trans-unit>
<trans-unit id="++CODE++5bd78fcb75f98d65ab8f89a8f0b6681c25c13308fa8643c44ab459b7783c06c9">
<source xml:lang="en">Default Environment: {0}</source>
<note>The {0} represents profile's resource/environment URL</note>
Expand Down Expand Up @@ -285,6 +288,10 @@ Return to this chat and @powerpages can help you write and edit your website cod
<source xml:lang="en">Installing Power Pages generator(v{0})...</source>
<note>{0} represents the version number</note>
</trans-unit>
<trans-unit id="++CODE++f351355077e2d6b421620f76832f108d9b4d84f31c14857d802cd8db01e4d330">
<source xml:lang="en">Instance url: {0}</source>
<note>{0} is the Instance Url</note>
</trans-unit>
<trans-unit id="++CODE++c59fe0045151cddc10b8384a437337e86eab905877883c18b53e068a3d36121d">
<source xml:lang="en">Learn more about Copilot</source>
</trans-unit>
Expand Down Expand Up @@ -722,6 +729,9 @@ The second line should be '[TRANSLATION HERE](command:powerplatform-walkthrough.
<trans-unit id="pacCLI.openPacLab.title">
<source xml:lang="en">Open PAC Lab</source>
</trans-unit>
<trans-unit id="microsoft.powerplatform.pages.actionsHub.openSitesInStudio.title">
<source xml:lang="en">Open in Power Pages Studio</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
30 changes: 28 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,22 @@
"command": "microsoft.powerplatform.pages.actionsHub.switchEnvironment",
"title": "%microsoft.powerplatform.pages.actionsHub.switchEnvironment.title%",
"icon": "$(arrow-swap)"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.openActiveSitesInStudio",
"title": "%microsoft.powerplatform.pages.actionsHub.openSitesInStudio.title%",
"icon": {
"dark": "./src/client/assets/open-icon/dark/open.svg",
"light": "./src/client/assets/open-icon/light/open.svg"
}
},
{
"command": "microsoft.powerplatform.pages.actionsHub.openInactiveSitesInStudio",
"title": "%microsoft.powerplatform.pages.actionsHub.openSitesInStudio.title%",
"icon": {
"dark": "./src/client/assets/open-icon/dark/open.svg",
"light": "./src/client/assets/open-icon/light/open.svg"
}
}
],
"configuration": {
Expand Down Expand Up @@ -950,14 +966,24 @@
"group": "inline@1"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.showEnvironmentDetails",
"command": "microsoft.powerplatform.pages.actionsHub.switchEnvironment",
"when": "view == microsoft.powerplatform.pages.actionsHub && viewItem == environmentGroup",
"group": "inline@2"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.switchEnvironment",
"command": "microsoft.powerplatform.pages.actionsHub.showEnvironmentDetails",
"when": "view == microsoft.powerplatform.pages.actionsHub && viewItem == environmentGroup",
"group": "inline@3"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.openActiveSitesInStudio",
"when": "view == microsoft.powerplatform.pages.actionsHub && viewItem == activeSitesGroup",
"group": "inline"
},
{
"command": "microsoft.powerplatform.pages.actionsHub.openInactiveSitesInStudio",
"when": "view == microsoft.powerplatform.pages.actionsHub && viewItem == inactiveSitesGroup",
"group": "inline"
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@
"microsoft.powerplatform.pages.actionsHub.title": "POWER PAGES ACTIONS",
"microsoft.powerplatform.pages.actionsHub.refresh.title": "Refresh",
"microsoft.powerplatform.pages.actionsHub.switchEnvironment.title": "Change Environment",
"microsoft.powerplatform.pages.actionsHub.showEnvironmentDetails.title": "Show Environment Details"
"microsoft.powerplatform.pages.actionsHub.showEnvironmentDetails.title": "Show Environment Details",
"microsoft.powerplatform.pages.actionsHub.openSitesInStudio.title": "Open in Power Pages Studio"
}
5 changes: 5 additions & 0 deletions src/client/assets/open-icon/dark/open.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/client/assets/open-icon/light/open.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions src/client/power-pages/actions-hub/ActionsHubCommandHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { OrgListOutput } from '../../pac/PacTypes';
import { extractAuthInfo } from '../commonUtility';
import { showProgressWithNotification } from '../../../common/utilities/Utils';
import PacContext from '../../pac/PacContext';
import ArtemisContext from '../../ArtemisContext';
import { ServiceEndpointCategory } from '../../../common/services/Constants';

export const refreshEnvironment = async (pacTerminal: PacTerminal) => {
const pacWrapper = pacTerminal.getWrapper();
Expand Down Expand Up @@ -95,3 +97,45 @@ export const switchEnvironment = async (pacTerminal: PacTerminal) => {
}
}
}

const getStudioUrl = (): string => {
const artemisContext = ArtemisContext.ServiceResponse;

let baseEndpoint = "";

switch (artemisContext.stamp) {
case ServiceEndpointCategory.TEST:
baseEndpoint = Constants.StudioEndpoints.TEST;
break;
case ServiceEndpointCategory.PREPROD:
baseEndpoint = Constants.StudioEndpoints.PREPROD;
break;
case ServiceEndpointCategory.PROD:
baseEndpoint = Constants.StudioEndpoints.PROD;
break;
case ServiceEndpointCategory.DOD:
baseEndpoint = Constants.StudioEndpoints.DOD;
break;
case ServiceEndpointCategory.GCC:
baseEndpoint = Constants.StudioEndpoints.GCC;
break;
case ServiceEndpointCategory.HIGH:
baseEndpoint = Constants.StudioEndpoints.HIGH;
break;
case ServiceEndpointCategory.MOONCAKE:
baseEndpoint = Constants.StudioEndpoints.MOONCAKE;
break;
default:
break;
}

return `${baseEndpoint}/environments/${PacContext.AuthInfo?.EnvironmentId}/portals/home`;
}

const getActiveSitesUrl = () => `${getStudioUrl()}/?tab=active`;

const getInactiveSitesUrl = () => `${getStudioUrl()}/?tab=inactive`;

export const openActiveSitesInStudio = async () => await vscode.env.openExternal(vscode.Uri.parse(getActiveSitesUrl()));

export const openInactiveSitesInStudio = async () => await vscode.env.openExternal(vscode.Uri.parse(getInactiveSitesUrl()));
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 { refreshEnvironment, showEnvironmentDetails, switchEnvironment } from "./ActionsHubCommandHandlers";
import { openActiveSitesInStudio, openInactiveSitesInStudio, refreshEnvironment, showEnvironmentDetails, switchEnvironment } from "./ActionsHubCommandHandlers";
import { IWebsiteDetails } from "../../../common/services/Interfaces";
import { getActiveWebsites, getAllWebsites } from "../../../common/utilities/WebsiteUtil";
import PacContext, { OnPacContextChanged } from "../../pac/PacContext";
Expand Down Expand Up @@ -101,7 +101,11 @@ export class ActionsHubTreeDataProvider implements vscode.TreeDataProvider<Actio

vscode.commands.registerCommand("microsoft.powerplatform.pages.actionsHub.switchEnvironment", async () => await switchEnvironment(pacTerminal)),

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

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

vscode.commands.registerCommand("microsoft.powerplatform.pages.actionsHub.openInactiveSitesInStudio", openInactiveSitesInStudio)
];
}
}
9 changes: 9 additions & 0 deletions src/client/power-pages/actions-hub/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export const Constants = {
ACTIONS_HUB_CURRENT_ENV_FETCH_FAILED: "actionsHubCurrentEnvFetchFailed",
ACTIONS_HUB_REFRESH_FAILED: "actionsHubRefreshFailed",
ACTIONS_HUB_SHOW_ENVIRONMENT_DETAILS_FAILED: "actionsHubShowEnvironmentDetailsFailed"
},
StudioEndpoints: {
TEST: "https://make.test.powerpages.microsoft.com",
PREPROD: "https://make.preprod.powerpages.microsoft.com",
PROD: "https://make.powerpages.microsoft.com",
DOD: "https://make.powerpages.microsoft.appsplatform.us",
GCC: "https://make.gov.powerpages.microsoft.us",
HIGH: "https://make.high.powerpages.microsoft.us",
MOONCAKE: "https://make.powerpages.microsoft.cn"
}
};

Expand Down
Loading

0 comments on commit df62521

Please sign in to comment.