signoz/frontend/src/api/changelog/getChangelogByVersion.ts

30 lines
992 B
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 { ErrorResponseHandler } from 'api/ErrorResponseHandler';
import axios, { AxiosError } from 'axios';
import { ErrorResponse, SuccessResponse } from 'types/api';
import { ChangelogSchema } from 'types/api/changelog/getChangelogByVersion';
const getChangelogByVersion = async (
versionId: string,
): Promise<SuccessResponse<ChangelogSchema> | ErrorResponse> => {
try {
const response = await axios.get(`
https://cms.signoz.cloud/api/release-changelogs?filters[version][$eq]=${versionId}&populate[features][sort]=sort_order:asc&populate[features][populate][media][fields]=id,ext,url,mime,alternativeText
`);
if (!Array.isArray(response.data.data) || response.data.data.length === 0) {
throw new Error('No changelog found!');
}
return {
statusCode: 200,
error: null,
message: response.statusText,
payload: response.data.data[0],
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);
}
};
export default getChangelogByVersion;