From d6077d9ded5f587576833285294ee79dd2380cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cintia=20S=C3=A1nchez=20Garc=C3=ADa?= Date: Tue, 8 Oct 2024 17:19:32 +0200 Subject: [PATCH] Hide versions with no changes in changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cintia Sánchez García --- web/src/layout/package/changelog/Content.module.css | 4 ++-- web/src/layout/package/changelog/Content.tsx | 6 ++++-- web/src/layout/package/changelog/Modal.tsx | 9 ++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/web/src/layout/package/changelog/Content.module.css b/web/src/layout/package/changelog/Content.module.css index cb02b14f9..ac8df3156 100644 --- a/web/src/layout/package/changelog/Content.module.css +++ b/web/src/layout/package/changelog/Content.module.css @@ -65,8 +65,8 @@ background-color: #df2a29; } -.badgeIcon { - top: -1px; +.badgeContent { + margin-top: 1px; } .lastVersion { diff --git a/web/src/layout/package/changelog/Content.tsx b/web/src/layout/package/changelog/Content.tsx index a850bd883..bfbb91e07 100644 --- a/web/src/layout/package/changelog/Content.tsx +++ b/web/src/layout/package/changelog/Content.tsx @@ -143,7 +143,7 @@ const Content = (props: Props) => { styles[`${change.kind.toString()}ChangeBadge`] )} > - + {(() => { switch (change.kind) { case ChangeKind.added: @@ -163,7 +163,9 @@ const Content = (props: Props) => { } })()} - {change.kind.toString()} + + {change.kind.toString()} + ) : ( diff --git a/web/src/layout/package/changelog/Modal.tsx b/web/src/layout/package/changelog/Modal.tsx index f476824c1..a5c4ecbe0 100644 --- a/web/src/layout/package/changelog/Modal.tsx +++ b/web/src/layout/package/changelog/Modal.tsx @@ -1,4 +1,5 @@ import classnames from 'classnames'; +import isEmpty from 'lodash/isEmpty'; import isNull from 'lodash/isNull'; import isUndefined from 'lodash/isUndefined'; import moment from 'moment'; @@ -74,6 +75,12 @@ const ChangelogModal = (props: Props) => { } }, [activeVersionIndex]); + const removeEmptyVersions = (data: ChangeLog[]): ChangeLog[] => { + return data.filter( + (item: ChangeLog) => !isNull(item.changes) && !isUndefined(item.changes) && !isEmpty(item.changes) + ); + }; + useEffect(() => { // We load correct active version after rendering modal if (openStatus && changelog && isUndefined(activeVersionIndex)) { @@ -109,7 +116,7 @@ const ChangelogModal = (props: Props) => { try { setIsLoading(true); setCurrentPkgId(props.packageId); - setChangelog(await API.getChangelog(props.packageId)); + setChangelog(removeEmptyVersions(await API.getChangelog(props.packageId))); setIsLoading(false); setOpenStatus(true); } catch {