Skip to content

Commit

Permalink
Hide versions with no changes in changelog (#4086)
Browse files Browse the repository at this point in the history
Signed-off-by: Cintia Sánchez García <cynthiasg@icloud.com>
  • Loading branch information
cynthia-sg authored Oct 8, 2024
1 parent 088b92b commit cec84f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions web/src/layout/package/changelog/Content.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
background-color: #df2a29;
}

.badgeIcon {
top: -1px;
.badgeContent {
margin-top: 1px;
}

.lastVersion {
Expand Down
6 changes: 4 additions & 2 deletions web/src/layout/package/changelog/Content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const Content = (props: Props) => {
styles[`${change.kind.toString()}ChangeBadge`]
)}
>
<span className={`position-relative ${styles.badgeIcon}`}>
<span>
{(() => {
switch (change.kind) {
case ChangeKind.added:
Expand All @@ -163,7 +163,9 @@ const Content = (props: Props) => {
}
})()}
</span>
<span className="d-none d-md-block ms-1">{change.kind.toString()}</span>
<span className={`d-none d-md-block ms-1 ${styles.badgeContent}`}>
{change.kind.toString()}
</span>
</div>
</div>
) : (
Expand Down
9 changes: 8 additions & 1 deletion web/src/layout/package/changelog/Modal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit cec84f9

Please sign in to comment.