Skip to content

Commit

Permalink
fix: remove show done message if no files are generated (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-gilin authored Aug 18, 2024
1 parent c79c3f6 commit eed513e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
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

0 comments on commit eed513e

Please sign in to comment.