diff options
author | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-10-03 18:55:27 +0200 |
---|---|---|
committer | Stas Vilchik <stas.vilchik@sonarsource.com> | 2017-10-04 10:35:13 +0200 |
commit | 56f06b7ea6456a56defd8eebe5f12bfe5163df6f (patch) | |
tree | c8a4a9aca32e8c7f876a84b6d5491db577a6e19b /server | |
parent | f34b192c12afc5987ff24787d7a008ff2605d92d (diff) | |
download | sonarqube-56f06b7ea6456a56defd8eebe5f12bfe5163df6f.tar.gz sonarqube-56f06b7ea6456a56defd8eebe5f12bfe5163df6f.zip |
SONAR-9496 group changelog events by action and date
Diffstat (limited to 'server')
-rw-r--r-- | server/sonar-web/src/main/js/apps/quality-profiles/changelog/Changelog.tsx | 17 |
1 files changed, 12 insertions, 5 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 021f1d3dca0..422ee1b8a81 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 @@ -19,11 +19,13 @@ */ import * as React from 'react'; import { Link } from 'react-router'; +import { sortBy } from 'lodash'; +import { isSameMinute, startOfMinute } from 'date-fns'; import ChangesList from './ChangesList'; import DateTimeFormatter from '../../../components/intl/DateTimeFormatter'; import { translate } from '../../../helpers/l10n'; import { getRulesUrl } from '../../../helpers/urls'; -import { differenceInSeconds, parseDate } from '../../../helpers/dates'; +import { parseDate } from '../../../helpers/dates'; import { ProfileChangelogEvent } from '../types'; interface Props { @@ -33,11 +35,16 @@ interface Props { export default function Changelog(props: Props) { let isEvenRow = false; + const sortedRows = sortBy( + props.events, + // sort events by date, rounded to a minute, recent events first + e => -Number(startOfMinute(parseDate(e.date))), + e => e.action + ); - const rows = props.events.map((event, index) => { - const prev = index > 0 ? props.events[index - 1] : null; - const isSameDate = - prev != null && differenceInSeconds(parseDate(prev.date), parseDate(event.date)) < 10; + const rows = sortedRows.map((event, index) => { + const prev = index > 0 ? sortedRows[index - 1] : null; + const isSameDate = prev != null && isSameMinute(parseDate(prev.date), parseDate(event.date)); const isBulkChange = prev != null && isSameDate && |