Skip to content

Commit

Permalink
Merge pull request #7777 from OfficeDev/zhaofeng/migration/update-not…
Browse files Browse the repository at this point in the history
…ification

chore(migration): update notification
  • Loading branch information
adashen committed Feb 16, 2023
2 parents a7601e6 + 3d9ab0b commit 0262715
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
8 changes: 5 additions & 3 deletions packages/fx-core/src/core/middleware/projectMigratorV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import { AppLocalYmlGenerator } from "./utils/debug/appLocalYmlGenerator";
import { EOL } from "os";
import { getTemplatesFolder } from "../../folder";
import { MetadataV2, MetadataV3, VersionSource, VersionState } from "../../common/versionMetadata";
import { isMigrationV3Enabled, isSPFxProject } from "../../common/tools";
import { isSPFxProject, isV3Enabled } from "../../common/tools";
import { VersionForMigration } from "./types";
import { environmentManager } from "../environment";
import { getLocalizedString } from "../../common/localizeUtils";
Expand Down Expand Up @@ -130,11 +130,13 @@ export const TelemetryPropertyValue = {
};

export const learnMoreLink = "https://aka.ms/teams-toolkit-5.0-upgrade";

// MigrationError provides learnMoreLink as helplink for user. Remember add related error message in learnMoreLink when adding new error.
export const errorNames = {
appPackageNotExist: "AppPackageNotExist",
manifestTemplateNotExist: "ManifestTemplateNotExist",
};
const migrationMessageButtons = [learnMoreText, upgradeButton];
const migrationMessageButtons = [upgradeButton, learnMoreText];

type Migration = (context: MigrationContext) => Promise<void>;
const subMigrations: Array<Migration> = [
Expand Down Expand Up @@ -168,7 +170,7 @@ export const ProjectMigratorMWV3: Middleware = async (ctx: CoreHookContext, next
ctx.result = ok(undefined);
return;
}
if (!isMigrationV3Enabled()) {
if (!isV3Enabled()) {
await TOOLS?.ui.showMessage(
"warn",
getLocalizedString("core.migrationV3.CreateNewProject"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe("ProjectMigratorMW", () => {
await fs.ensureDir(projectPath);
await fs.ensureDir(path.join(projectPath, ".fx"));
mockedEnvRestore = mockedEnv({
TEAMSFX_V3_MIGRATION: "true",
TEAMSFX_V3: "true",
});
});

Expand Down Expand Up @@ -158,7 +158,7 @@ describe("ProjectMigratorMW", () => {
});
});

describe("ProjectMigratorMW with no TEAMSFX_V3_MIGRATION", () => {
describe("ProjectMigratorMW with no TEAMSFX_V3", () => {
const sandbox = sinon.createSandbox();
const appName = randomAppName();
const projectPath = path.join(os.tmpdir(), appName);
Expand All @@ -167,7 +167,7 @@ describe("ProjectMigratorMW with no TEAMSFX_V3_MIGRATION", () => {
await fs.ensureDir(projectPath);
await fs.ensureDir(path.join(projectPath, ".fx"));
mockedEnvRestore = mockedEnv({
TEAMSFX_V3_MIGRATION: "false",
TEAMSFX_V3: "false",
});
});

Expand All @@ -177,7 +177,7 @@ describe("ProjectMigratorMW with no TEAMSFX_V3_MIGRATION", () => {
mockedEnvRestore();
});

it("TEAMSFX_V3_MIGRATION is false", async () => {
it("TEAMSFX_V3 is false", async () => {
sandbox.stub(MockUserInteraction.prototype, "showMessage").resolves(ok(""));
const tools = new MockTools();
setTools(tools);
Expand Down
18 changes: 6 additions & 12 deletions packages/vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ import { loadLocalizedStrings } from "./utils/localizeUtils";
import { ExtensionSurvey } from "./utils/survey";
import { ExtensionUpgrade } from "./utils/upgrade";
import { hasAAD } from "@microsoft/teamsfx-core/build/common/projectSettingsHelperV3";
import {
AuthSvcScopes,
isMigrationV3Enabled,
setRegion,
} from "@microsoft/teamsfx-core/build/common/tools";
import { AuthSvcScopes, setRegion } from "@microsoft/teamsfx-core/build/common/tools";
import { UriHandler } from "./uriHandler";
import { isV3Enabled, isTDPIntegrationEnabled } from "@microsoft/teamsfx-core";
import { VersionState } from "@microsoft/teamsfx-core/build/common/versionMetadata";
Expand Down Expand Up @@ -727,12 +723,10 @@ async function initializeContextKey(context: vscode.ExtensionContext, isTeamsFxP
await setTDPIntegrationEnabledContext();

if (isV3Enabled()) {
if (isMigrationV3Enabled()) {
const upgradeable = await checkProjectUpgradable();
if (upgradeable) {
await vscode.commands.executeCommand("setContext", "fx-extension.canUpgradeV3", true);
await handlers.checkUpgrade([TelemetryTriggerFrom.Auto]);
}
const upgradeable = await checkProjectUpgradable();
if (upgradeable) {
await vscode.commands.executeCommand("setContext", "fx-extension.canUpgradeV3", true);
await handlers.checkUpgrade([TelemetryTriggerFrom.Auto]);
}
} else {
await vscode.commands.executeCommand(
Expand Down Expand Up @@ -1022,7 +1016,7 @@ async function runBackgroundAsyncTasks(
}

async function runTeamsFxBackgroundTasks() {
const upgradeable = isV3Enabled() && isMigrationV3Enabled() && (await checkProjectUpgradable());
const upgradeable = isV3Enabled() && (await checkProjectUpgradable());
await handlers.autoOpenProjectHandler();
await handlers.promptSPFxUpgrade();
await TreeViewManagerInstance.updateTreeViewsByContent(upgradeable);
Expand Down

0 comments on commit 0262715

Please sign in to comment.