From a8c77ad222fda8cf614aaf3fde812dc51274729a Mon Sep 17 00:00:00 2001 From: Ambroise C Date: Wed, 18 Oct 2023 16:51:59 +0200 Subject: [PATCH] SONAR-20672 Group changelog events by datetime --- .../quality-profiles/changelog/Changelog.tsx | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx index e5945afe2fe..a0e66ceb693 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx @@ -58,31 +58,37 @@ export default function Changelog(props: Props) { const isSameEventDate = (thisEvent: ProfileChangelogEvent, otherEvent?: ProfileChangelogEvent) => otherEvent !== undefined && isSameMinute(parseDate(otherEvent.date), parseDate(thisEvent.date)); - const isSameEventGroup = (thisEvent: ProfileChangelogEvent, otherEvent?: ProfileChangelogEvent) => - otherEvent !== undefined && - isSameEventDate(thisEvent, otherEvent) && - otherEvent.authorName === thisEvent.authorName && - otherEvent.action === thisEvent.action; + const isSameEventAuthor = ( + thisEvent: ProfileChangelogEvent, + otherEvent?: ProfileChangelogEvent, + ) => otherEvent !== undefined && otherEvent.authorName === thisEvent.authorName; + + const isSameEventAction = ( + thisEvent: ProfileChangelogEvent, + otherEvent?: ProfileChangelogEvent, + ) => otherEvent !== undefined && otherEvent.action === thisEvent.action; const rows = sortedRows.map((event, index) => { - const prev = sortedRows[index - 1]; - const isBulkChange = isSameEventGroup(event, prev); + const prevRow = sortedRows[index - 1]; + const shouldDisplayDate = !isSameEventDate(event, prevRow); + const shouldDisplayAuthor = shouldDisplayDate || !isSameEventAuthor(event, prevRow); + const shouldDisplayAction = shouldDisplayAuthor || !isSameEventAction(event, prevRow); const nextEventInDifferentGroup = sortedRows .slice(index + 1) - .find((e) => !isSameEventGroup(event, e)); + .find((e) => !isSameEventDate(event, e)); const isNewSonarQubeVersion = - !isBulkChange && + shouldDisplayDate && nextEventInDifferentGroup !== undefined && nextEventInDifferentGroup.sonarQubeVersion !== event.sonarQubeVersion; return ( - {!isBulkChange && ( + {shouldDisplayDate && (
@@ -106,23 +112,23 @@ export default function Changelog(props: Props) { - {!isBulkChange && (event.authorName ? event.authorName : System)} + {shouldDisplayAuthor && (event.authorName ? event.authorName : System)} - {!isBulkChange && + {shouldDisplayAction && intl.formatMessage({ id: `quality_profiles.changelog.${event.action}` })} {event.ruleName && ( {event.ruleName} @@ -145,7 +151,7 @@ export default function Changelog(props: Props) { {event.params && } -- 2.39.5