Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove show done message if no files are generated #846

Merged
merged 2 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/backend/src/vscode-youi-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ export class VSCodeYouiEvents implements YouiEvents {
}

const successInfoMessage = this.getSuccessInfoMessage(selectedWorkspace, type);
return vscode.window.showInformationMessage(successInfoMessage);
return successInfoMessage // show the message only if it is not empty
? vscode.window.showInformationMessage(successInfoMessage)
: Promise.resolve();
}

return vscode.window.showErrorMessage(errorMmessage);
Expand All @@ -211,6 +213,8 @@ export class VSCodeYouiEvents implements YouiEvents {
}
} else if (type === "module") {
successInfoMessage = this.messages.artifact_generated_module;
} else if (type === "") {
successInfoMessage = ""; // do not show information message
}
return successInfoMessage;
}
Expand Down
9 changes: 7 additions & 2 deletions packages/backend/src/yeomanui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export class YeomanUI {
// All the paths here absolute normilized paths.
const targetFolderPathBeforeGen: string = _.get(resourcesBeforeGen, "targetFolderPath");
const targetFolderPathAfterGen: string = _.get(resourcesAfterGen, "targetFolderPath");
let hasNewDirs: boolean = true;
if (targetFolderPathBeforeGen === targetFolderPathAfterGen) {
const newDirs: string[] = _.difference(
_.get(resourcesAfterGen, "childDirs"),
Expand All @@ -427,7 +428,10 @@ export class YeomanUI {
// One folder added by generator and targetFolderPath/destinationRoot was not changed by generator.
// ---> Fiori project generator flow.
targetFolderPath = newDirs[0];
} //else { //_.size(newDirs) = 0 (0 folders) or _.size(newDirs) > 1 (5 folders)
} else if (_.size(newDirs) === 0) {
hasNewDirs = false;
}
//else { // _.size(newDirs) > 1 (5 folders)
// We don't know what is the correct targetFolderPath ---> no buttons should be shown.
// No folder added by generator ---> Fiori module generator flow.
// Many folders added by generator --->
Expand All @@ -451,7 +455,8 @@ export class YeomanUI {
const generatedTemplatePath = targetFolderPath ? targetFolderPath : targetFolderPathBeforeGen;
this.logger.debug(`done running yeomanui! ${message} You can find it at ${generatedTemplatePath}`);
AnalyticsWrapper.updateGeneratorEnded(generatorName);
this.youiEvents.doGeneratorDone(true, message, selectedWorkspace, type, targetFolderPath);
// when targetFolderPath is undefined and no files are generated, send type = '' to get the empty toast message
this.youiEvents.doGeneratorDone(true, message, selectedWorkspace, hasNewDirs ? type : "", targetFolderPath);
this.setInitialProcessDir();
this.flowState.resolve();
this.generatorName = ""; // reset generator name
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/test/yeomanui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ describe("yeomanui unit test", () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_.get(yeomanUi, "uiOptions.messages.artifact_with_name_generated", (a: string) => "")("testGenName"),
create_and_close,
"files",
"",
null,
),
).to.be.true;
Expand Down
Loading