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

Add actions field to Card. Handle PROPAGATE_READ_ACK_TO_PARENT_CARD action (#5461) #5651

Merged
merged 1 commit into from Jan 15, 2024

Conversation

quinarygio
Copy link
Contributor

Fix #5461

@quinarygio quinarygio marked this pull request as draft December 20, 2023 17:36
@quinarygio quinarygio changed the title Add actions field to Card. Handle PROPAGATE_READ_ACK_TO_PARENT_CARD qction (#5461) Add actions field to Card. Handle PROPAGATE_READ_ACK_TO_PARENT_CARD action (#5461) Dec 21, 2023
@quinarygio quinarygio force-pushed the FE-5461 branch 3 times, most recently from 2ba1344 to 1b4c9f3 Compare January 9, 2024 11:07
Comment on lines 247 to 265
if (hasBeenRead && children) {
for (let child of children) {
if (!child.hasBeenRead) {
hasBeenRead = false;
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shall take into account the PROPAGATE_READ_ACK_TO_PARENT_CARD

const parent = this.lightCards.get(card.parentCardId);
if (card.actions?.includes(CardAction.PROPAGATE_READ_ACK_TO_PARENT_CARD)) {
if (parent.hasBeenRead && !card.hasBeenRead) {
CardService.deleteUserCardRead(parent.uid).subscribe();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to propagate the read status of the parent to the back , the read status is always processed on the front bases on the read status of the child .

this.setLightCardRead(parent.id, false);
}
if (parent.hasBeenAcknowledged && !card.hasBeenAcknowledged) {
AcknowledgeService.deleteUserAcknowledgement(parent.uid).subscribe();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to propagate the ack status of the parent to the back , the ack status is always processed on the front bases on the ack status of the child . So you need to modify ui/main/src/app/modules/card/components/card-ack/card-ack.component.ts to take into account the ack of the child cards (method setAcknowledgeButtonVisibility) in the card detail view

Comment on lines 206 to 248
const childCards = OpfabStore.getLightCardStore().getChildCards(this.card.id);
if (childCards) {
childCards.forEach(child => {
if (child.actions?.includes(CardAction.PROPAGATE_READ_ACK_TO_PARENT_CARD)) {
AcknowledgeService.deleteUserAcknowledgement(child.uid).subscribe();
}
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not necessary to cancel ack for child cards as if the parent ack is cancelled the card will be considered as unack whatever the status of the childs

@@ -246,6 +263,18 @@ export class LightCardsStore {
} else {
this.childCards.set(card.parentCardId, [card]);
}

const parent = this.lightCards.get(card.parentCardId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parent could be null if child is received before parent cards (we have no guarantee of the receive order when loading cards) so you should check this case
But if it arise , the processing of the ack/read should be done when receiving the card , it is already done for read card in your code line 239 but it has to be done as well for ack

@quinarygio quinarygio force-pushed the FE-5461 branch 2 times, most recently from 585cc55 to 8414a2b Compare January 11, 2024 09:30
@quinarygio quinarygio marked this pull request as ready for review January 11, 2024 09:45
@quinarygio quinarygio force-pushed the FE-5461 branch 2 times, most recently from 777fd5f to 8b6e97c Compare January 11, 2024 14:23
Comment on lines +275 to +276
const childIndex = children.findIndex(child => child.id === card.id);
if (childIndex >= 0) children.splice(childIndex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why this two lines of code ? could you explain ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that when a child card is updated we end up having the both version of the child card in the "children" collection. So before adding a child card I check if it already exists and eventually remove it before adding the updated one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok understood

}
}

private setReadAndAckOnParentCardIfNeeded(card: LightCard) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest naming it unreadAndUnackParentCardIfNeeded

.subscribe();
}

private updateAcknowledgeButtonVisibilityIfNeeded(childCard) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would suggest naming it " updateAcknowledgeButtonVisibilityIfCardsIsChildOfCurrentCard"

Comment on lines 278 to 284
}
this.lastCardSetToReadButNotYetOnFeed = this.card;
CardService.postUserCardRead(this.card.uid).subscribe();

} else this.updateLastReadCardStatusOnFeedIfNeeded();

if (this.childCards) {
this.childCards.forEach(child => {
if (child.actions?.includes(CardAction.PROPAGATE_READ_ACK_TO_PARENT_CARD) && !child.hasBeenRead) {
CardService.postUserCardRead(child.uid).subscribe();
}
})
}
this.lastCardSetToReadButNotYetOnFeed = this.card;

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.lastCardSetToReadButNotYetOnFeed = this.card shall only be done if read status change

So keep the old this.lastCardSetToReadButNotYetOnFeed = this.card;
and add a new after CardService.postUserCardRead(child.uid).subscribe();

Comment on lines 204 to 207
private computeCardHasBeenAcknowledged() {
this.card.hasBeenAcknowledged = OpfabStore.getLightCardStore().isLightCardHasBeenAcknowledged(this.card);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the ack status is not used directly in card-body.component , i suggest to avoid dealing with ack here but do the processing where it is needed i.e in setAcknowledgeButtonVisibility method in card-ack.component.ts

Comment on lines 18 to 22
"lttd" : ${current_date_in_milliseconds_from_epoch_plus_3minutes},
"lttd" : ${current_date_in_milliseconds_from_epoch_plus_4hours},
"timeSpans" : [
{"start" : ${current_date_in_milliseconds_from_epoch_plus_4hours}}
]
],
"actions" : ["PROPAGATE_READ_ACK_TO_PARENT_CARD"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think these modifications are useful ?

…ction (#5461)

Signed-off-by: Giovanni Ferrari <giovanni.ferrari@soft.it>
Copy link

sonarcloud bot commented Jan 15, 2024

Quality Gate Failed Quality Gate failed

Failed conditions

36.4% Coverage on New Code (required ≥ 50%)

See analysis details on SonarCloud

@freddidierRTE freddidierRTE merged commit 32c20df into develop Jan 15, 2024
7 of 8 checks passed
@freddidierRTE freddidierRTE deleted the FE-5461 branch January 15, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants