Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide versions with no changes in changelog #4086

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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