163 lines
4.4 KiB
TypeScript
Raw Normal View History

feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
import './ChangelogModal.styles.scss';
import { CheckOutlined, CloseOutlined } from '@ant-design/icons';
import { Button, Modal } from 'antd';
import updateUserPreference from 'api/v1/user/preferences/name/update';
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
import cx from 'classnames';
import { USER_PREFERENCES } from 'constants/userPreferences';
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
import dayjs from 'dayjs';
import { useGetTenantLicense } from 'hooks/useGetTenantLicense';
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
import { ChevronsDown, ScrollText } from 'lucide-react';
import { useAppContext } from 'providers/App/App';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useMutation } from 'react-query';
import { ChangelogSchema } from 'types/api/changelog/getChangelogByVersion';
import { UserPreference } from 'types/api/preferences/preference';
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
import ChangelogRenderer from './components/ChangelogRenderer';
interface Props {
changelog: ChangelogSchema;
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
onClose: () => void;
}
function ChangelogModal({ changelog, onClose }: Props): JSX.Element {
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
const [hasScroll, setHasScroll] = useState(false);
const changelogContentSectionRef = useRef<HTMLDivElement>(null);
const { userPreferences, updateUserPreferenceInContext } = useAppContext();
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
const formattedReleaseDate = dayjs(changelog?.release_date).format(
'MMMM D, YYYY',
);
const { isCloudUser } = useGetTenantLicense();
const seenChangelogVersion = userPreferences?.find(
(preference) =>
preference.name === USER_PREFERENCES.LAST_SEEN_CHANGELOG_VERSION,
)?.value as string;
const { mutate: updateUserPreferenceMutation } = useMutation(
updateUserPreference,
);
useEffect(() => {
// Update the seen version
if (seenChangelogVersion !== changelog.version) {
const version = {
name: USER_PREFERENCES.LAST_SEEN_CHANGELOG_VERSION,
value: changelog.version,
};
updateUserPreferenceInContext(version as UserPreference);
updateUserPreferenceMutation(version);
}
}, [
seenChangelogVersion,
changelog.version,
updateUserPreferenceMutation,
updateUserPreferenceInContext,
]);
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
const checkScroll = useCallback((): void => {
if (changelogContentSectionRef.current) {
const {
scrollHeight,
clientHeight,
scrollTop,
} = changelogContentSectionRef.current;
const isAtBottom = scrollHeight - clientHeight - scrollTop <= 8;
setHasScroll(scrollHeight > clientHeight + 24 && !isAtBottom); // 24px - buffer height to show show more
}
}, []);
useEffect(() => {
checkScroll();
const changelogContentSection = changelogContentSectionRef.current;
if (changelogContentSection) {
changelogContentSection.addEventListener('scroll', checkScroll);
}
return (): void => {
if (changelogContentSection) {
changelogContentSection.removeEventListener('scroll', checkScroll);
}
};
}, [checkScroll]);
const onClickUpdateWorkspace = (): void => {
window.open(
'https://github.com/SigNoz/signoz/releases',
'_blank',
'noopener,noreferrer',
);
};
const onClickScrollForMore = (): void => {
if (changelogContentSectionRef.current) {
changelogContentSectionRef.current.scrollTo({
top: changelogContentSectionRef.current.scrollTop + 600, // Scroll 600px from the current position
behavior: 'smooth',
});
}
};
return (
<Modal
className={cx('changelog-modal')}
title={
<div className="changelog-modal-title">
<ScrollText size={16} />
Whats New Changelog : {formattedReleaseDate}
</div>
}
width={820}
open
onCancel={onClose}
footer={
<div
className={cx('changelog-modal-footer', hasScroll && 'scroll-available')}
>
{!isCloudUser && (
<div className="changelog-modal-footer-ctas">
<Button type="default" icon={<CloseOutlined />} onClick={onClose}>
Skip for now
</Button>
<Button
type="primary"
icon={<CheckOutlined />}
onClick={onClickUpdateWorkspace}
>
Update my workspace
</Button>
</div>
)}
feat(changelog): show changelogs for newer versions available (#8270) * feat(changelog): add getChangelogByVersion API and related types * feat(changelog): implement ChangelogModal and ChangelogRenderer components with styles * test(dateUtils): add unit tests for formatDate utility * chore(changelog): fixed pr review changes * style(ChangelogRenderer): format SCSS for improved readability * feat(SideNav): integrate ChangelogModal and manage its visibility state * feat(changelog): refactor changelog handling and integrate into app state * test(ChangelogModal): add unit tests for scroll functionality and data rendering * test(ChangelogRenderer): add unit tests for rendering changelog details * test(ChangelogModal, ChangelogRenderer): refactor tests * fix(applayout): bot fetching changelog for cloud users * fix(ChangelogModal): update footer to display feature count dynamically * fix(ChangelogModal): update link for workspace migration to point to releases page * feat(ChangelogModal): enhance footer layout and update link behavior * test(ChangelogModal): update link for workspace migration to point to releases page * refactor(AppContext): migrate changelog state management to context and update related components * feat(test-utils): add changelog state and updateChangelog mock to app context * test(changelogModal): fixed test by adding mock for useAppContext * fix: added PR review fixes * Fixed css variable name in ChangelogModal.styles.scss Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix(style): added light mode support for changelog modal * Fixed heading color token Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fix: remove debug log for isLatestVersion in AppLayout --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-20 10:55:52 +05:30
{changelog && (
<div className="scroll-btn-container">
<button
data-testid="scroll-more-btn"
type="button"
className="scroll-btn"
onClick={onClickScrollForMore}
>
<ChevronsDown size={14} />
<span>Scroll for more</span>
</button>
</div>
)}
</div>
}
>
<div
className="changelog-modal-content"
data-testid="changelog-content"
ref={changelogContentSectionRef}
>
{changelog && <ChangelogRenderer changelog={changelog} />}
</div>
</Modal>
);
}
export default ChangelogModal;