From: Ambroise C Date: Wed, 18 Oct 2023 14:51:59 +0000 (+0200) Subject: SONAR-20672 Group changelog events by datetime X-Git-Tag: 10.3.0.82913~146 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a8c77ad222fda8cf614aaf3fde812dc51274729a;p=sonarqube.git SONAR-20672 Group changelog events by datetime --- 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 && }