Skip to content

Commit

Permalink
feat(frontend): adds message with severity support via inquirer-gui (#…
Browse files Browse the repository at this point in the history
…763)

* feat(frontend): adds message with severity support via inquirer-gui

consumes inquirer-gui with messages with seveity support, adds type for same

* chore(foodq): reverts version bump - will be done automatically

* chore(backend): reverts file addition
  • Loading branch information
IainSAP authored May 8, 2023
1 parent e714c18 commit d5cbde3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/backend/src/images/messageImages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const errorVSCodeLight =

// const errorTheiaLight = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHdpZHRoPSIxNyIgaGVpZ2h0PSIxNyIgdmlld0JveD0iMCAwIDE3IDE3Ij4NCiAgPGRlZnM+DQogICAgPGNsaXBQYXRoIGlkPSJjbGlwLWVycm9yX3RoZWlhX2xpZ2h0Ij4NCiAgICAgIDxyZWN0IHdpZHRoPSIxNyIgaGVpZ2h0PSIxNyIvPg0KICAgIDwvY2xpcFBhdGg+DQogIDwvZGVmcz4NCiAgPGcgaWQ9ImVycm9yX3RoZWlhX2xpZ2h0IiBjbGlwLXBhdGg9InVybCgjY2xpcC1lcnJvcl90aGVpYV9saWdodCkiPg0KICAgIDxnIGlkPSJHcm91cF8zNTMxIiBkYXRhLW5hbWU9Ikdyb3VwIDM1MzEiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xIC0xLjAwNCkiPg0KICAgICAgPHBhdGggaWQ9IlBhdGhfMTYwOCIgZGF0YS1uYW1lPSJQYXRoIDE2MDgiIGQ9Ik0yMzAuMzUxLTEwMi40YTguNSw4LjUsMCwwLDAtOC41LDguNSw4LjUsOC41LDAsMCwwLDguNSw4LjUsOC41LDguNSwwLDAsMCw4LjUtOC41LDguNSw4LjUsMCwwLDAtOC41LTguNVptMy41NTQsMTIuMzc2YS43OTMuNzkzLDAsMCwxLS41NTkuMjI3LjguOCwwLDAsMS0uNTY3LS4yMzdsLTIuNDQtMi40NzMtMi41NTgsMi42MjdhLjc5My43OTMsMCwwLDEtLjU2Ny4yNDEuNzkzLjc5MywwLDAsMS0uNTU2LS4yMjcuNzkzLjc5MywwLDAsMS0uMjQzLS41NjEuNzkzLjc5MywwLDAsMSwuMjI4LS41NjdsMi41ODItMi42NS0yLjM2NS0yLjRhLjc5My43OTMsMCwwLDEtLjIzMS0uNTY1Ljc5My43OTMsMCwwLDEsLjIzOS0uNTYyLjc5My43OTMsMCwwLDEsLjU2NS0uMjMxLjc5My43OTMsMCwwLDEsLjU2Mi4yMzlsMi4zNDMsMi4zNzMsMi4zMDktMi4zNzFhLjc5NC43OTQsMCwwLDEsLjU2LS4yNDIuNzkzLjc5MywwLDAsMSwuNTY2LjIyNy43OTMuNzkzLDAsMCwxLC4yNDMuNTYxLjc5My43OTMsMCwwLDEtLjIyOC41NjdsLTIuMzMxLDIuMzkyLDIuNDYyLDIuNDkzYS43OTMuNzkzLDAsMCwxLC4yMjkuNTY3Ljc5My43OTMsMCwwLDEtLjI0My41NjJaIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMjIwLjg1MSAxMDMuNDA0KSIgZmlsbD0iI2U4NGQ0ZCIvPg0KICAgIDwvZz4NCiAgPC9nPg0KPC9zdmc+DQo="

export function getImage(state: number) {
export function getImage(state: Severity) {
if (state === Severity.error) {
return Constants.IS_IN_BAS
? errorTheiaDark
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"dependencies": {
"@mdi/font": "5.9.55",
"@sap-devx/inquirer-gui": "0.5.0",
"@sap-devx/inquirer-gui": "0.6.0",
"@sap-devx/inquirer-gui-auto-complete-plugin": "0.0.1",
"@sap-devx/inquirer-gui-file-browser-plugin": "0.0.5",
"@sap-devx/inquirer-gui-folder-browser-plugin": "0.0.3",
Expand Down
35 changes: 35 additions & 0 deletions packages/generator-foodq/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,41 @@ module.exports = class extends Generator {
hint: "Our recommendation is green",
breadcrumb: "Napkin color",
},
additionalMessages: (input, answers) => {
if (input === "warn") {
return {
message: "Some warning message",
severity: 1,
};
}
if (input === "blue" && answers["confirmHungry"] === false) {
return {
message: `Some conditional warning message (Confirm hungry: ${answers["confirmHungry"]})`,
severity: 1,
};
}
if (input === "infolong") {
return {
message:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." +
"Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." +
"Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",
severity: 2,
};
}
if (input === "info") {
return {
message: "Some info message",
severity: 2,
};
}
if (input === "error") {
return {
message: "Some error message (consider using a validation message)",
severity: 0,
};
}
},
when: (response) => {
if (_.isNil(this._getOption("favColor"))) {
const hungry = this._getAnswer("hungry", response);
Expand Down
8 changes: 8 additions & 0 deletions packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,11 @@ export interface IValidationLink {
*/
toString(): string;
}

/**
* Messages with severity
*/
export interface IMessageSeverity {
message: string;
severity: Severity;
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2381,10 +2381,10 @@
dependencies:
vue "^2.6.10"

"@sap-devx/inquirer-gui@0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@sap-devx/inquirer-gui/-/inquirer-gui-0.5.0.tgz#fa6cc903b301fc653f1bfba92772fa224304e3b6"
integrity sha512-4ldYrKyoqtgcJioCxEp+QZMDck2bQgzN/rkh9S2cKPqCJs1oEl0f6hFB1uqmkF2Te+oaK9mI1/CemwCS4BRovA==
"@sap-devx/inquirer-gui@0.6.0":
version "0.6.0"
resolved "https://registry.yarnpkg.com/@sap-devx/inquirer-gui/-/inquirer-gui-0.6.0.tgz#57cbb4a8108137e74432d544456ee835d66419d6"
integrity sha512-/daSaSx6ul6+4CIslG/LDZQbldgMb+5JAmjpLmhx8DQLhsOrNxYQABJbaDFws9h0om1EcQcelXn8KbOY3alSzQ==
dependencies:
strip-ansi "^6.0.0"
vue "2.6.12"
Expand Down

0 comments on commit d5cbde3

Please sign in to comment.