Skip to content

Commit 53fc823

Browse files
Improve wording on project modernization (#912)
* chore: strings * docs: CHANGELOG * chore: wording Co-authored-by: Miller Wang <[email protected]> * feat: pop-up on disabled extension * chore: telemetry for `extensionDisabled` event * chore: lint --------- Co-authored-by: Miller Wang <[email protected]>
1 parent b8548d6 commit 53fc823

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## 0.25.2
88

9+
- ux - Improve wording on project modernization by @FluoriteCafe-work in https://github.com/microsoft/vscode-java-dependency/pull/912
910
- ux - Check extension existence on-the-fly when needed by @FluoriteCafe-work in https://github.com/microsoft/vscode-java-dependency/pull/911
1011

1112
## 0.25.0

src/upgrade/upgradeManager.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Commands } from "../commands";
1111
import notificationManager from "./display/notificationManager";
1212
import { Settings } from "../settings";
1313
import assessmentManager from "./assessmentManager";
14-
import { checkOrInstallAppModExtension, checkOrPromptToInstallAppModExtension } from "./utility";
14+
import { checkOrInstallAppModExtensionForUpgrade, checkOrPopupToInstallAppModExtensionForModernization } from "./utility";
1515

1616
const DEFAULT_UPGRADE_PROMPT = "Upgrade Java project dependency to latest version.";
1717

@@ -26,16 +26,16 @@ class UpgradeManager {
2626

2727
// Upgrade project
2828
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_UPGRADE_WITH_COPILOT, async (promptText?: string) => {
29-
await checkOrInstallAppModExtension(ExtensionName.APP_MODERNIZATION_UPGRADE_FOR_JAVA);
29+
await checkOrInstallAppModExtensionForUpgrade(ExtensionName.APP_MODERNIZATION_UPGRADE_FOR_JAVA);
3030
const promptToUse = promptText ?? DEFAULT_UPGRADE_PROMPT;
3131
await commands.executeCommand(Commands.GOTO_AGENT_MODE, { prompt: promptToUse });
3232
}));
3333

3434
// Show modernization view
3535
context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_MODERNIZE_JAVA_PROJECT, async () => {
36-
await checkOrPromptToInstallAppModExtension(
36+
await checkOrPopupToInstallAppModExtensionForModernization(
3737
ExtensionName.APP_MODERNIZATION_FOR_JAVA,
38-
"Install GitHub Copilot app modernization to modernize the Java project.",
38+
`${ExtensionName.APP_MODERNIZATION_EXTENSION_NAME} extension is required to modernize Java projects. Would you like to install it and modernize this project?`,
3939
"Install Extension and Modernize");
4040
await commands.executeCommand("workbench.view.extension.azureJavaMigrationExplorer");
4141
}));

src/upgrade/utility.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { commands, extensions, Uri, window } from "vscode";
55
import * as semver from "semver";
66
import { UpgradeReason, type UpgradeIssue } from "./type";
77
import { ExtensionName, Upgrade } from "../constants";
8+
import { instrumentOperation } from "vscode-extension-telemetry-wrapper";
89

910

1011
function findEolDate(currentVersion: string, eolDate: Record<string, string>): string | null {
@@ -74,47 +75,50 @@ export function normalizePath(path: string): string {
7475
return Uri.parse(path).toString();
7576
}
7677

77-
async function checkOrPromptToEnableAppModExtension() {
78+
async function checkOrPromptToEnableAppModExtension(keyword: string) {
7879
if (extensions.getExtension(ExtensionName.APP_MODERNIZATION_FOR_JAVA)) {
7980
return;
8081
}
8182

82-
// The extension is disabled if we cannot detect the extension after installing it.
83-
await commands.executeCommand("workbench.extensions.search", ExtensionName.APP_MODERNIZATION_FOR_JAVA);
84-
const BTN_TEXT = "Show extension in sidebar";
85-
const choice2 = await window.showInformationMessage(
86-
`${ExtensionName.APP_MODERNIZATION_EXTENSION_NAME} extension is needed for the feature to work but it seems disabled. Please enable it manually and try again.`,
87-
BTN_TEXT
88-
);
89-
if (choice2 === BTN_TEXT) {
83+
// The extension is in a disabled state since we cannot detect the extension after installing it.
84+
await instrumentOperation("java.dependency.extensionDisabled", async () => {
9085
await commands.executeCommand("workbench.extensions.search", ExtensionName.APP_MODERNIZATION_FOR_JAVA);
91-
}
86+
const BTN_TEXT = "Show extension in sidebar";
87+
const choice2 = await window.showInformationMessage(
88+
`${ExtensionName.APP_MODERNIZATION_EXTENSION_NAME} extension is required to ${keyword} Java projects but it seems disabled. Please enable it manually and try again.`,
89+
{ modal: true },
90+
BTN_TEXT
91+
);
92+
if (choice2 === BTN_TEXT) {
93+
await commands.executeCommand("workbench.extensions.search", ExtensionName.APP_MODERNIZATION_FOR_JAVA);
94+
}
95+
})();
9296
}
9397

94-
export async function checkOrPromptToInstallAppModExtension(
98+
export async function checkOrPopupToInstallAppModExtensionForModernization(
9599
extensionIdToCheck: string,
96100
notificationText: string,
97101
buttonText: string): Promise<void> {
98102
if (extensions.getExtension(extensionIdToCheck)) {
99103
return;
100104
}
101105

102-
const choice = await window.showInformationMessage(notificationText, buttonText);
106+
const choice = await window.showInformationMessage(notificationText, { modal: true }, buttonText);
103107
if (choice === buttonText) {
104108
await commands.executeCommand("workbench.extensions.installExtension", ExtensionName.APP_MODERNIZATION_FOR_JAVA);
105109
} else {
106110
return;
107111
}
108112

109-
await checkOrPromptToEnableAppModExtension();
113+
await checkOrPromptToEnableAppModExtension("modernize");
110114
}
111115

112-
export async function checkOrInstallAppModExtension(
116+
export async function checkOrInstallAppModExtensionForUpgrade(
113117
extensionIdToCheck: string): Promise<void> {
114118
if (extensions.getExtension(extensionIdToCheck)) {
115119
return;
116120
}
117121

118122
await commands.executeCommand("workbench.extensions.installExtension", ExtensionName.APP_MODERNIZATION_FOR_JAVA);
119-
await checkOrPromptToEnableAppModExtension();
123+
await checkOrPromptToEnableAppModExtension("upgrade");
120124
}

0 commit comments

Comments
 (0)