Skip to content

Commit

Permalink
fix: wrong capabilities if .NET flag is enabled (#12014)
Browse files Browse the repository at this point in the history
* fix: dotnet

* fix: more

* fix: more

* fix: more

* test: ut
  • Loading branch information
yuqizhou77 authored Jul 17, 2024
1 parent 152ecad commit 446fc5b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
13 changes: 7 additions & 6 deletions packages/fx-core/src/question/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,10 @@ export class RuntimeOptions {

export function getRuntime(inputs: Inputs): string {
let runtime = RuntimeOptions.NodeJS().id;
if (featureFlagManager.getBooleanValue(FeatureFlags.CLIDotNet)) {
if (inputs?.platform === Platform.VS) {
runtime = RuntimeOptions.DotNet().id;
} else if (featureFlagManager.getBooleanValue(FeatureFlags.CLIDotNet)) {
runtime = inputs[QuestionNames.Runtime] || runtime;
} else {
if (inputs?.platform === Platform.VS) {
runtime = RuntimeOptions.DotNet().id;
}
}
return runtime;
}
Expand Down Expand Up @@ -475,7 +473,7 @@ export class CapabilityOptions {
};
}
static bots(inputs?: Inputs): OptionItem[] {
if (inputs?.platform === Platform.VS) {
if (inputs && getRuntime(inputs) === RuntimeOptions.DotNet().id) {
return [
CapabilityOptions.basicBot(),
CapabilityOptions.aiBot(),
Expand Down Expand Up @@ -647,6 +645,9 @@ export class CapabilityOptions {
* dynamic capability list, which depends on feature flags
*/
static all(inputs?: Inputs): OptionItem[] {
if (inputs && getRuntime(inputs) === RuntimeOptions.DotNet().id) {
return CapabilityOptions.dotnetCaps(inputs);
}
const capabilityOptions = [
...CapabilityOptions.bots(inputs),
...CapabilityOptions.tabs(),
Expand Down
24 changes: 14 additions & 10 deletions packages/fx-core/src/question/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ export function projectTypeQuestion(): SingleSelectQuestion {
staticOptions.push(ProjectTypeOptions.copilotPlugin(inputs.platform));
}

if (getRuntime(inputs) === RuntimeOptions.NodeJS().id) {
staticOptions.push(ProjectTypeOptions.customCopilot(inputs.platform));
}

staticOptions.push(
ProjectTypeOptions.customCopilot(inputs.platform),
ProjectTypeOptions.bot(inputs.platform),
ProjectTypeOptions.tab(inputs.platform),
ProjectTypeOptions.me(inputs.platform)
Expand All @@ -106,7 +109,7 @@ export function projectTypeQuestion(): SingleSelectQuestion {
if (projectType) {
return [projectType];
}
} else {
} else if (getRuntime(inputs) === RuntimeOptions.NodeJS().id) {
if (featureFlagManager.getBooleanValue(FeatureFlags.OfficeAddin)) {
staticOptions.push(ProjectTypeOptions.officeAddin(inputs.platform));
} else {
Expand Down Expand Up @@ -206,7 +209,7 @@ export function capabilityQuestion(): SingleSelectQuestion {
}
}
// dotnet capabilities
if (getRuntime(inputs) === RuntimeOptions.DotNet().id) {
if (inputs.platform === Platform.VS) {
return CapabilityOptions.dotnetCaps(inputs);
}

Expand All @@ -215,7 +218,7 @@ export function capabilityQuestion(): SingleSelectQuestion {
return CapabilityOptions.all(inputs);
}

// nodejs capabilities
// capabilities if VSC or CLI interactive mode
const projectType = inputs[QuestionNames.ProjectType];
if (projectType === ProjectTypeOptions.bot().id) {
return CapabilityOptions.bots(inputs);
Expand Down Expand Up @@ -1383,12 +1386,13 @@ export function capabilitySubTree(): IQTreeNode {
data: programmingLanguageQuestion(),
condition: (inputs: Inputs) => {
return (
!!inputs[QuestionNames.Capabilities] &&
inputs[QuestionNames.Capabilities] !== CapabilityOptions.copilotPluginApiSpec().id &&
inputs[QuestionNames.Capabilities] !== CapabilityOptions.customizeGptBasic().id &&
inputs[QuestionNames.MeArchitectureType] !== MeArchitectureOptions.apiSpec().id &&
inputs[QuestionNames.Capabilities] !== CapabilityOptions.officeAddinImport().id &&
inputs[QuestionNames.Capabilities] !== CapabilityOptions.outlookAddinImport().id
(!!inputs[QuestionNames.Capabilities] &&
inputs[QuestionNames.Capabilities] !== CapabilityOptions.copilotPluginApiSpec().id &&
inputs[QuestionNames.Capabilities] !== CapabilityOptions.customizeGptBasic().id &&
inputs[QuestionNames.MeArchitectureType] !== MeArchitectureOptions.apiSpec().id &&
inputs[QuestionNames.Capabilities] !== CapabilityOptions.officeAddinImport().id &&
inputs[QuestionNames.Capabilities] !== CapabilityOptions.outlookAddinImport().id) ||
getRuntime(inputs) === RuntimeOptions.DotNet().id
);
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/test/officeChat/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe("File: officeChat/utils.ts", () => {
shortDescription: "Using Shape related APIs to insert and format to work as a dashboard.",
fullDescription:
"The sample add-in demonstrates Excel add-in capablities to help users using shape API to work as a dashboard.",
tags: ["TS", "Shape", "Excel", "Office Add-in"],
tags: ["TS", "Shape", "Excel"],
time: "5min to run",
thumbnailPath: "assets/thumbnail.png",
suggested: false,
Expand Down

0 comments on commit 446fc5b

Please sign in to comment.