Skip to content

Commit

Permalink
Message or question list template - Add option in config file to choo…
Browse files Browse the repository at this point in the history
…se severity (#5595)

Signed-off-by: Giovanni Ferrari <giovanni.ferrari@soft.it>
  • Loading branch information
quinarygio committed Dec 14, 2023
1 parent 6b8da3b commit 8a7e488
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/docs/asciidoc/reference_doc/build-in_templates.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ If you want to use the template as is, the json file must follow this structure
"title": "Warning about the state of the grid",
"message": "A problem has been detected, please put maintenance work on hold and be on stand by",
"question": false,
"severity": "ALARM",
"recipients" : [
"ENTITY1_FR",
"ENTITY2_FR"
Expand All @@ -120,6 +121,7 @@ If you want to use the template as is, the json file must follow this structure
"title": "Confirmation the issues have been fixed",
"message": "Please confirm the issues in your area have been fixed",
"question": true,
"severity": "ACTION",
"recipients" : [
"ENTITY1_FR"
]
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/businessData/message-and-question-list
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"title": "Warning about the state of the grid",
"message": "A problem has been detected, please put maintenance work on hold and be on stand by",
"question": false,
"severity": "ALARM",
"recipients" : [
"ENTITY1_FR",
"ENTITY2_FR",
Expand All @@ -33,6 +34,7 @@
"title": "Confirmation the issues have been fixed",
"message": "Please confirm the issues in your area have been fixed",
"question": true,
"severity": "ACTION",
"recipients" : [
"ENTITY1_FR",
"ENTITY2_FR",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,25 @@ describe('MessageOrQuestionList UserCard template', () => {
it('GIVEN a user WHEN create card THEN card is the correct severity', () => {
const view = new MessageOrQuestionListUserCardTemplateView();

const selectedMessage = {title: "my title", question: true};
view.selectedMessage = selectedMessage;
let specficCardInformation = view.getSpecificCardInformation('my question');
expect(specficCardInformation.card.severity).toEqual('ACTION');
const selectedMessageWithoutseverity = {title: "default severity", question: true};
view.selectedMessage = selectedMessageWithoutseverity;

let specficCardInformation = view.getSpecificCardInformation('my question');
expect(specficCardInformation.card.severity).toEqual('ACTION')

view.selectedMessage.question = false;
specficCardInformation = view.getSpecificCardInformation('my message');
expect(specficCardInformation.card.severity).toEqual('INFORMATION');

let selectedMessageWithSeverity = {title: "my title", question: true, severity: 'ACTION'};
view.selectedMessage = selectedMessageWithSeverity;
specficCardInformation = view.getSpecificCardInformation('my question');
expect(specficCardInformation.card.severity).toEqual('ACTION');

view.selectedMessage.severity = 'ALARM';
specficCardInformation = view.getSpecificCardInformation('my message');
expect(specficCardInformation.card.severity).toEqual('ALARM');

});

});
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ export class MessageOrQuestionListUserCardTemplateView {
const title = this.selectedMessage.title.trim();
const id = this.selectedMessage.id;
const question = this.selectedMessage.question;
let severity = 'INFORMATION';
let severity = question ? 'ACTION' : 'INFORMATION';
if (this.selectedMessage.severity) severity = this.selectedMessage.severity;

let entitiesAllowedToRespond;

if (this.selectedMessage.question) {
severity = 'ACTION';
entitiesAllowedToRespond = this.selectedMessage?.possibleRecipients ? this.selectedMessage?.possibleRecipients : "";
} else {
entitiesAllowedToRespond = [];
Expand Down

0 comments on commit 8a7e488

Please sign in to comment.