diff --git a/CHANGELOG.md b/CHANGELOG.md index 02058291..d763d838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## 0.25.2 +- ux - Improve wording on project modernization by @FluoriteCafe-work in https://github.com/microsoft/vscode-java-dependency/pull/912 - ux - Check extension existence on-the-fly when needed by @FluoriteCafe-work in https://github.com/microsoft/vscode-java-dependency/pull/911 ## 0.25.0 diff --git a/src/upgrade/upgradeManager.ts b/src/upgrade/upgradeManager.ts index 9808a3ac..87fe3372 100644 --- a/src/upgrade/upgradeManager.ts +++ b/src/upgrade/upgradeManager.ts @@ -11,7 +11,7 @@ import { Commands } from "../commands"; import notificationManager from "./display/notificationManager"; import { Settings } from "../settings"; import assessmentManager from "./assessmentManager"; -import { checkOrInstallAppModExtension, checkOrPromptToInstallAppModExtension } from "./utility"; +import { checkOrInstallAppModExtensionForUpgrade, checkOrPopupToInstallAppModExtensionForModernization } from "./utility"; const DEFAULT_UPGRADE_PROMPT = "Upgrade Java project dependency to latest version."; @@ -26,16 +26,16 @@ class UpgradeManager { // Upgrade project context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.JAVA_UPGRADE_WITH_COPILOT, async (promptText?: string) => { - await checkOrInstallAppModExtension(ExtensionName.APP_MODERNIZATION_UPGRADE_FOR_JAVA); + await checkOrInstallAppModExtensionForUpgrade(ExtensionName.APP_MODERNIZATION_UPGRADE_FOR_JAVA); const promptToUse = promptText ?? DEFAULT_UPGRADE_PROMPT; await commands.executeCommand(Commands.GOTO_AGENT_MODE, { prompt: promptToUse }); })); // Show modernization view context.subscriptions.push(instrumentOperationAsVsCodeCommand(Commands.VIEW_MODERNIZE_JAVA_PROJECT, async () => { - await checkOrPromptToInstallAppModExtension( + await checkOrPopupToInstallAppModExtensionForModernization( ExtensionName.APP_MODERNIZATION_FOR_JAVA, - "Install GitHub Copilot app modernization to modernize the Java project.", + `${ExtensionName.APP_MODERNIZATION_EXTENSION_NAME} extension is required to modernize Java projects. Would you like to install it and modernize this project?`, "Install Extension and Modernize"); await commands.executeCommand("workbench.view.extension.azureJavaMigrationExplorer"); })); diff --git a/src/upgrade/utility.ts b/src/upgrade/utility.ts index b14bb81b..09588801 100644 --- a/src/upgrade/utility.ts +++ b/src/upgrade/utility.ts @@ -5,6 +5,7 @@ import { commands, extensions, Uri, window } from "vscode"; import * as semver from "semver"; import { UpgradeReason, type UpgradeIssue } from "./type"; import { ExtensionName, Upgrade } from "../constants"; +import { instrumentOperation } from "vscode-extension-telemetry-wrapper"; function findEolDate(currentVersion: string, eolDate: Record): string | null { @@ -74,24 +75,27 @@ export function normalizePath(path: string): string { return Uri.parse(path).toString(); } -async function checkOrPromptToEnableAppModExtension() { +async function checkOrPromptToEnableAppModExtension(keyword: string) { if (extensions.getExtension(ExtensionName.APP_MODERNIZATION_FOR_JAVA)) { return; } - // The extension is disabled if we cannot detect the extension after installing it. - await commands.executeCommand("workbench.extensions.search", ExtensionName.APP_MODERNIZATION_FOR_JAVA); - const BTN_TEXT = "Show extension in sidebar"; - const choice2 = await window.showInformationMessage( - `${ExtensionName.APP_MODERNIZATION_EXTENSION_NAME} extension is needed for the feature to work but it seems disabled. Please enable it manually and try again.`, - BTN_TEXT - ); - if (choice2 === BTN_TEXT) { + // The extension is in a disabled state since we cannot detect the extension after installing it. + await instrumentOperation("java.dependency.extensionDisabled", async () => { await commands.executeCommand("workbench.extensions.search", ExtensionName.APP_MODERNIZATION_FOR_JAVA); - } + const BTN_TEXT = "Show extension in sidebar"; + const choice2 = await window.showInformationMessage( + `${ExtensionName.APP_MODERNIZATION_EXTENSION_NAME} extension is required to ${keyword} Java projects but it seems disabled. Please enable it manually and try again.`, + { modal: true }, + BTN_TEXT + ); + if (choice2 === BTN_TEXT) { + await commands.executeCommand("workbench.extensions.search", ExtensionName.APP_MODERNIZATION_FOR_JAVA); + } + })(); } -export async function checkOrPromptToInstallAppModExtension( +export async function checkOrPopupToInstallAppModExtensionForModernization( extensionIdToCheck: string, notificationText: string, buttonText: string): Promise { @@ -99,22 +103,22 @@ export async function checkOrPromptToInstallAppModExtension( return; } - const choice = await window.showInformationMessage(notificationText, buttonText); + const choice = await window.showInformationMessage(notificationText, { modal: true }, buttonText); if (choice === buttonText) { await commands.executeCommand("workbench.extensions.installExtension", ExtensionName.APP_MODERNIZATION_FOR_JAVA); } else { return; } - await checkOrPromptToEnableAppModExtension(); + await checkOrPromptToEnableAppModExtension("modernize"); } -export async function checkOrInstallAppModExtension( +export async function checkOrInstallAppModExtensionForUpgrade( extensionIdToCheck: string): Promise { if (extensions.getExtension(extensionIdToCheck)) { return; } await commands.executeCommand("workbench.extensions.installExtension", ExtensionName.APP_MODERNIZATION_FOR_JAVA); - await checkOrPromptToEnableAppModExtension(); + await checkOrPromptToEnableAppModExtension("upgrade"); } \ No newline at end of file