Skip to content

Commit c9da940

Browse files
authored
[MDiff] Update metadata diff labels and add clear functionality (#1409)
✨ Renamed "Metadata Diff" to "Site Comparison" for clarity. ✨ Added confirmation dialogs for clearing metadata diff results. ✨ Implemented functionality to clear individual site comparisons. ✨ Updated localization files with new labels and messages. ✨ Added tests for new clear functionality and site comparison behavior. -Priyanshu
1 parent 7ef94ca commit c9da940

File tree

9 files changed

+268
-23
lines changed

9 files changed

+268
-23
lines changed

l10n/bundle.l10n.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@
358358
"Site download failed. Please try again later.": "Site download failed. Please try again later.",
359359
"No differences found between the remote site and your local workspace.": "No differences found between the remote site and your local workspace.",
360360
"Comparing files...": "Comparing files...",
361-
"Metadata Diff": "Metadata Diff",
361+
"Site Comparison": "Site Comparison",
362362
"Modified": "Modified",
363363
"Added locally": "Added locally",
364364
"Deleted locally": "Deleted locally",
@@ -373,6 +373,12 @@
373373
"Yes, Don't Ask Again": "Yes, Don't Ask Again",
374374
"The website was not found in the selected environment. Please select a different environment.": "The website was not found in the selected environment. Please select a different environment.",
375375
"Discard Changes": "Discard Changes",
376+
"Clear All": "Clear All",
377+
"Clear all results?": "Clear all results?",
378+
"This will close all active comparison views. Your local files will not be affected.": "This will close all active comparison views. Your local files will not be affected.",
379+
"Clear": "Clear",
380+
"Clear result?": "Clear result?",
381+
"This will close the active comparison view. Your local files will not be affected.": "This will close the active comparison view. Your local files will not be affected.",
376382
"Show Diff": "Show Diff",
377383
"All changed files are binary files (e.g., images) and cannot be displayed in the diff viewer. You can view them individually in the file tree.": "All changed files are binary files (e.g., images) and cannot be displayed in the diff viewer. You can view them individually in the file tree.",
378384
"1 file changed": "1 file changed",

loc/translations-export/vscode-powerplatform.xlf

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@
179179
<trans-unit id="++CODE++2c8d1f9ca282591926b952dc5949d44df6204f1f0a3f5183bcd5ef7ae5864bad">
180180
<source xml:lang="en">Choose web template</source>
181181
</trans-unit>
182+
<trans-unit id="++CODE++83b12c2216efb4fdc924e1deb5182e905e4926ed0c1c324d467107f46d5a26a9">
183+
<source xml:lang="en">Clear</source>
184+
</trans-unit>
185+
<trans-unit id="++CODE++ddceb7adfdb8816e4747bc48a2221702e830340e5596a701dc0993766eba5e60">
186+
<source xml:lang="en">Clear All</source>
187+
</trans-unit>
188+
<trans-unit id="++CODE++f404fdaebef56580458d681961f3f87aeee6d5b864fa2a5f4e10873a65d81d7a">
189+
<source xml:lang="en">Clear all results?</source>
190+
</trans-unit>
191+
<trans-unit id="++CODE++26ed15c8dd832c026cd98c581dcb29966b8181619b4c51247c04eceece2bb8b7">
192+
<source xml:lang="en">Clear result?</source>
193+
</trans-unit>
182194
<trans-unit id="++CODE++7aaafd1c6d6875eb1cd67e841f87457e929c922a18fef7c1452c1e1a4c036456">
183195
<source xml:lang="en">Clearing cache. See [details](https://aka.ms/pages-clear-cache).</source>
184196
<note>This is a markdown formatting which must persist across translations.
@@ -745,9 +757,6 @@ Return to this chat and @powerpages can help you write and edit your website cod
745757
<trans-unit id="++CODE++8a194d5287e3da019883144787cd5f282753f5ce892d933be0833b3818c25503">
746758
<source xml:lang="en">Maximum 30 characters allowed</source>
747759
</trans-unit>
748-
<trans-unit id="++CODE++a6d287e1a3ca10ca1e47de17060293fbb14d1e43cd8ffb9a296661c576615b69">
749-
<source xml:lang="en">Metadata Diff</source>
750-
</trans-unit>
751760
<trans-unit id="++CODE++d39a5fa0fca9df105f95b7dfa9a2705ccddaead33bd3119052baabe6c923a85d">
752761
<source xml:lang="en">Metadata Diff JSON</source>
753762
</trans-unit>
@@ -1102,6 +1111,9 @@ The {3} represents Dataverse Environment's Organization ID (GUID)</note>
11021111
<trans-unit id="++CODE++2f65ba5aa38a9acac3a9a9c0a9aeecd7b32796008dc63432bedbe6ef62982558">
11031112
<source xml:lang="en">Sign in to VS Code with PAC CLI account</source>
11041113
</trans-unit>
1114+
<trans-unit id="++CODE++413f481712d78c8cce54fc6b1ef2da1b4e35e9584c11fcdc51509c19017e2812">
1115+
<source xml:lang="en">Site Comparison</source>
1116+
</trans-unit>
11051117
<trans-unit id="++CODE++524bca0347e50e3801bebf27374124b3babf072729b4da4bcc45ef5c385ee8f4">
11061118
<source xml:lang="en">Site Details</source>
11071119
</trans-unit>
@@ -1209,6 +1221,12 @@ The {3} represents Dataverse Environment's Organization ID (GUID)</note>
12091221
<trans-unit id="++CODE++bcfc420c0358eb6f248fa6328797cfa38fa121baea6320a623280a0d34eeee75">
12101222
<source xml:lang="en">This file was exported with a newer version of the extension. Please update your extension to import this file.</source>
12111223
</trans-unit>
1224+
<trans-unit id="++CODE++e7de2855a45712e1d967171e4d86f37d4014c2f80a515bc552ed4c4a2984c3e4">
1225+
<source xml:lang="en">This will close all active comparison views. Your local files will not be affected.</source>
1226+
</trans-unit>
1227+
<trans-unit id="++CODE++f9463baef8e56e06230fca093d61bb43810240340033d21ecf4df81e02579913">
1228+
<source xml:lang="en">This will close the active comparison view. Your local files will not be affected.</source>
1229+
</trans-unit>
12121230
<trans-unit id="++CODE++75670337a398f9840d2951dbc6746497caec6da9dd506ecff57ef79d59c6280f">
12131231
<source xml:lang="en">Thumbs Down</source>
12141232
</trans-unit>
@@ -1517,9 +1535,6 @@ The fifth line should be '[TRANSLATION HERE](command:powerplatform-walkthrough.s
15171535
<trans-unit id="pacCLI.openDocumentation.title">
15181536
<source xml:lang="en">Documentation</source>
15191537
</trans-unit>
1520-
<trans-unit id="microsoft.powerplatform.pages.actionsHub.metadataDiff.generateHtmlReport.title">
1521-
<source xml:lang="en">Download HTML Report</source>
1522-
</trans-unit>
15231538
<trans-unit id="microsoft.powerplatform.pages.actionsHub.activeSite.downloadSite.title">
15241539
<source xml:lang="en">Download Site</source>
15251540
</trans-unit>
@@ -1532,8 +1547,11 @@ The fifth line should be '[TRANSLATION HERE](command:powerplatform-walkthrough.s
15321547
<trans-unit id="pacCLI.envAndSolutionsPanel.title">
15331548
<source xml:lang="en">Environments &amp; Solutions</source>
15341549
</trans-unit>
1550+
<trans-unit id="microsoft.powerplatform.pages.actionsHub.metadataDiff.generateHtmlReport.title">
1551+
<source xml:lang="en">Export as HTML Report</source>
1552+
</trans-unit>
15351553
<trans-unit id="microsoft.powerplatform.pages.actionsHub.metadataDiff.export.title">
1536-
<source xml:lang="en">Export Comparison</source>
1554+
<source xml:lang="en">Export as JSON</source>
15371555
</trans-unit>
15381556
<trans-unit id="microsoft-powerapps-portals.walkthrough.fileSystem.title">
15391557
<source xml:lang="en">File explorer</source>

package.nls.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@
130130
"microsoft.powerplatform.pages.actionsHub.metadataDiff.sortByName.title": "Sort by Name",
131131
"microsoft.powerplatform.pages.actionsHub.metadataDiff.sortByPath.title": "Sort by Path",
132132
"microsoft.powerplatform.pages.actionsHub.metadataDiff.sortByStatus.title": "Sort by Status",
133-
"microsoft.powerplatform.pages.actionsHub.metadataDiff.generateHtmlReport.title": "Download HTML Report",
134-
"microsoft.powerplatform.pages.actionsHub.metadataDiff.export.title": "Export Comparison",
133+
"microsoft.powerplatform.pages.actionsHub.metadataDiff.generateHtmlReport.title": "Export as HTML Report",
134+
"microsoft.powerplatform.pages.actionsHub.metadataDiff.export.title": "Export as JSON",
135135
"microsoft.powerplatform.pages.actionsHub.metadataDiff.import.title": "Import Comparison",
136136
"microsoft.powerplatform.pages.actionsHub.metadataDiff.resync.title": "Refresh Comparison",
137137
"microsoft-powerapps-portals.compareWithEnvironment.title": "Compare with Environment",

src/client/power-pages/actions-hub/Constants.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const Constants = {
179179
COMPARE_WITH_LOCAL_SITE_DOWNLOAD_FAILED: vscode.l10n.t("Site download failed. Please try again later."),
180180
NO_DIFFERENCES_FOUND: vscode.l10n.t("No differences found between the remote site and your local workspace."),
181181
COMPARING_FILES: vscode.l10n.t("Comparing files..."),
182-
METADATA_DIFF_GROUP: vscode.l10n.t("Metadata Diff"),
182+
METADATA_DIFF_GROUP: vscode.l10n.t("Site Comparison"),
183183
METADATA_DIFF_MODIFIED: vscode.l10n.t("Modified"),
184184
METADATA_DIFF_ADDED: vscode.l10n.t("Added locally"),
185185
METADATA_DIFF_DELETED: vscode.l10n.t("Deleted locally"),
@@ -194,6 +194,12 @@ export const Constants = {
194194
YES_DONT_ASK_AGAIN: vscode.l10n.t("Yes, Don't Ask Again"),
195195
WEBSITE_NOT_FOUND_IN_ENVIRONMENT: vscode.l10n.t("The website was not found in the selected environment. Please select a different environment."),
196196
DISCARD_CHANGES: vscode.l10n.t("Discard Changes"),
197+
CLEAR_ALL: vscode.l10n.t("Clear All"),
198+
CLEAR_ALL_RESULTS_TITLE: vscode.l10n.t("Clear all results?"),
199+
CLEAR_ALL_RESULTS_MESSAGE: vscode.l10n.t("This will close all active comparison views. Your local files will not be affected."),
200+
CLEAR: vscode.l10n.t("Clear"),
201+
CLEAR_RESULT_TITLE: vscode.l10n.t("Clear result?"),
202+
CLEAR_RESULT_MESSAGE: vscode.l10n.t("This will close the active comparison view. Your local files will not be affected."),
197203
SHOW_DIFF: vscode.l10n.t("Show Diff"),
198204
METADATA_DIFF_ONLY_BINARY_FILES: vscode.l10n.t("All changed files are binary files (e.g., images) and cannot be displayed in the diff viewer. You can view them individually in the file tree."),
199205
FILE_COUNT_DESCRIPTION_SINGULAR: vscode.l10n.t("1 file changed"),

src/client/power-pages/actions-hub/handlers/metadata-diff/ClearMetadataDiffHandler.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,29 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*/
55

6+
import * as vscode from "vscode";
67
import MetadataDiffContext from "../../MetadataDiffContext";
78
import { traceInfo } from "../../TelemetryHelper";
89
import { Constants } from "../../Constants";
910

1011
/**
11-
* Clears the metadata diff results from the tree view
12+
* Clears the metadata diff results from the tree view after user confirmation
1213
*/
13-
export function clearMetadataDiff(): void {
14+
export async function clearMetadataDiff(): Promise<void> {
1415
traceInfo(Constants.EventNames.ACTIONS_HUB_METADATA_DIFF_CLEAR, {
1516
methodName: clearMetadataDiff.name
1617
});
1718

19+
const confirmButton = Constants.Strings.CLEAR_ALL;
20+
const result = await vscode.window.showWarningMessage(
21+
Constants.Strings.CLEAR_ALL_RESULTS_TITLE,
22+
{ modal: true, detail: Constants.Strings.CLEAR_ALL_RESULTS_MESSAGE },
23+
confirmButton
24+
);
25+
26+
if (result !== confirmButton) {
27+
return;
28+
}
29+
1830
MetadataDiffContext.clear();
1931
}

src/client/power-pages/actions-hub/handlers/metadata-diff/RemoveSiteHandler.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,31 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*/
55

6+
import * as vscode from "vscode";
67
import { MetadataDiffSiteTreeItem } from "../../tree-items/metadata-diff/MetadataDiffSiteTreeItem";
78
import { traceInfo } from "../../TelemetryHelper";
89
import { Constants } from "../../Constants";
910
import MetadataDiffContext from "../../MetadataDiffContext";
1011

1112
/**
12-
* Removes a specific site's comparison results from the metadata diff view
13+
* Removes a specific site's comparison results from the metadata diff view after user confirmation
1314
*/
14-
export function removeSiteComparison(siteItem: MetadataDiffSiteTreeItem): void {
15+
export async function removeSiteComparison(siteItem: MetadataDiffSiteTreeItem): Promise<void> {
1516
traceInfo(Constants.EventNames.ACTIONS_HUB_METADATA_DIFF_CLEAR, {
1617
methodName: removeSiteComparison.name,
1718
siteName: siteItem.siteName
1819
});
1920

21+
const confirmButton = Constants.Strings.CLEAR;
22+
const result = await vscode.window.showWarningMessage(
23+
Constants.Strings.CLEAR_RESULT_TITLE,
24+
{ modal: true, detail: Constants.Strings.CLEAR_RESULT_MESSAGE },
25+
confirmButton
26+
);
27+
28+
if (result !== confirmButton) {
29+
return;
30+
}
31+
2032
MetadataDiffContext.clearSite(siteItem.siteName);
2133
}

src/client/test/Integration/power-pages/actions-hub/handlers/metadata-diff/ClearMetadataDiffHandler.test.ts

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ import { clearMetadataDiff } from "../../../../../../power-pages/actions-hub/han
1010
import MetadataDiffContext from "../../../../../../power-pages/actions-hub/MetadataDiffContext";
1111
import * as TelemetryHelper from "../../../../../../power-pages/actions-hub/TelemetryHelper";
1212
import { IFileComparisonResult } from "../../../../../../power-pages/actions-hub/models/IFileComparisonResult";
13+
import { Constants } from "../../../../../../power-pages/actions-hub/Constants";
1314

1415
describe("ClearMetadataDiffHandler", () => {
1516
let sandbox: sinon.SinonSandbox;
17+
let showWarningMessageStub: sinon.SinonStub;
1618

1719
beforeEach(() => {
1820
sandbox = sinon.createSandbox();
1921
sandbox.stub(TelemetryHelper, "traceInfo");
2022
sandbox.stub(vscode.env, "sessionId").get(() => "test-session-id");
23+
showWarningMessageStub = sandbox.stub(vscode.window, "showWarningMessage");
2124
});
2225

2326
afterEach(() => {
@@ -26,7 +29,7 @@ describe("ClearMetadataDiffHandler", () => {
2629
});
2730

2831
describe("clearMetadataDiff", () => {
29-
it("should clear the metadata diff context", () => {
32+
it("should clear the metadata diff context when user confirms", async () => {
3033
const results: IFileComparisonResult[] = [
3134
{
3235
localPath: "/local/file.txt",
@@ -36,18 +39,38 @@ describe("ClearMetadataDiffHandler", () => {
3639
}
3740
];
3841
MetadataDiffContext.setResults(results, "Test Site", "Local Test Site", "Test Environment", "test-website-id", "test-environment-id");
42+
showWarningMessageStub.resolves(Constants.Strings.CLEAR_ALL);
3943

40-
clearMetadataDiff();
44+
await clearMetadataDiff();
4145

4246
expect(MetadataDiffContext.comparisonResults).to.deep.equal([]);
4347
expect(MetadataDiffContext.siteName).to.equal("");
4448
expect(MetadataDiffContext.isActive).to.be.false;
4549
});
4650

47-
it("should log telemetry event", () => {
51+
it("should not clear when user cancels", async () => {
52+
const results: IFileComparisonResult[] = [
53+
{
54+
localPath: "/local/file.txt",
55+
remotePath: "/remote/file.txt",
56+
relativePath: "file.txt",
57+
status: "modified"
58+
}
59+
];
60+
MetadataDiffContext.setResults(results, "Test Site", "Local Test Site", "Test Environment", "test-website-id", "test-environment-id");
61+
showWarningMessageStub.resolves(undefined); // User cancelled
62+
63+
await clearMetadataDiff();
64+
65+
expect(MetadataDiffContext.comparisonResults).to.have.lengthOf(1);
66+
expect(MetadataDiffContext.isActive).to.be.true;
67+
});
68+
69+
it("should log telemetry event", async () => {
4870
const traceInfoStub = TelemetryHelper.traceInfo as sinon.SinonStub;
71+
showWarningMessageStub.resolves(Constants.Strings.CLEAR_ALL);
4972

50-
clearMetadataDiff();
73+
await clearMetadataDiff();
5174

5275
expect(traceInfoStub.calledOnce).to.be.true;
5376
expect(traceInfoStub.firstCall.args[0]).to.equal("ActionsHubMetadataDiffClear");
@@ -56,10 +79,25 @@ describe("ClearMetadataDiffHandler", () => {
5679
});
5780
});
5881

59-
it("should work when context is already empty", () => {
82+
it("should show confirmation dialog with correct message", async () => {
83+
showWarningMessageStub.resolves(undefined);
84+
85+
await clearMetadataDiff();
86+
87+
expect(showWarningMessageStub.calledOnce).to.be.true;
88+
expect(showWarningMessageStub.firstCall.args[0]).to.equal(Constants.Strings.CLEAR_ALL_RESULTS_TITLE);
89+
expect(showWarningMessageStub.firstCall.args[1]).to.deep.equal({
90+
modal: true,
91+
detail: Constants.Strings.CLEAR_ALL_RESULTS_MESSAGE
92+
});
93+
expect(showWarningMessageStub.firstCall.args[2]).to.equal(Constants.Strings.CLEAR_ALL);
94+
});
95+
96+
it("should work when context is already empty and user confirms", async () => {
6097
MetadataDiffContext.clear();
98+
showWarningMessageStub.resolves(Constants.Strings.CLEAR_ALL);
6199

62-
clearMetadataDiff();
100+
await clearMetadataDiff();
63101

64102
expect(MetadataDiffContext.comparisonResults).to.deep.equal([]);
65103
expect(MetadataDiffContext.isActive).to.be.false;

0 commit comments

Comments
 (0)