mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-29 01:52:01 +08:00

* feat: show release note in alerts dashboards and services pages * fix: made code changes as per review and changed message in release note * fix: solved build pipeline issue * fix: solved lint issue Co-authored-by: mindhash <mindhash@mindhashs-MacBook-Pro.local> Co-authored-by: Pranay Prateek <pranay@signoz.io> Co-authored-by: Ankit Nayan <ankit@signoz.io>
67 lines
1.6 KiB
TypeScript
67 lines
1.6 KiB
TypeScript
import ReleaseNoteProps from 'components/ReleaseNote/ReleaseNoteProps';
|
|
import ReleaseNote0120 from 'components/ReleaseNote/Releases/ReleaseNote0120';
|
|
import ROUTES from 'constants/routes';
|
|
import React from 'react';
|
|
import { useSelector } from 'react-redux';
|
|
import { AppState } from 'store/reducers';
|
|
import { UserFlags } from 'types/api/user/setFlags';
|
|
import AppReducer from 'types/reducer/app';
|
|
|
|
interface ComponentMapType {
|
|
match: (
|
|
path: string | undefined,
|
|
version: string,
|
|
userFlags: UserFlags | null,
|
|
) => boolean;
|
|
component: ({ path, release }: ReleaseNoteProps) => JSX.Element | null;
|
|
}
|
|
|
|
const allComponentMap: ComponentMapType[] = [
|
|
{
|
|
match: (
|
|
path: string | undefined,
|
|
version: string,
|
|
userFlags: UserFlags | null,
|
|
): boolean => {
|
|
if (!path) {
|
|
return false;
|
|
}
|
|
const allowedPaths = [
|
|
ROUTES.LIST_ALL_ALERT,
|
|
ROUTES.APPLICATION,
|
|
ROUTES.ALL_DASHBOARD,
|
|
];
|
|
return (
|
|
userFlags?.ReleaseNote0120Hide !== 'Y' &&
|
|
allowedPaths.includes(path) &&
|
|
version.startsWith('v0.12')
|
|
);
|
|
},
|
|
component: ReleaseNote0120,
|
|
},
|
|
];
|
|
|
|
// ReleaseNote prints release specific warnings and notes that
|
|
// user needs to be aware of before using the upgraded version.
|
|
function ReleaseNote({ path }: ReleaseNoteProps): JSX.Element | null {
|
|
const { userFlags, currentVersion } = useSelector<AppState, AppReducer>(
|
|
(state) => state.app,
|
|
);
|
|
|
|
const c = allComponentMap.find((item) => {
|
|
return item.match(path, currentVersion, userFlags);
|
|
});
|
|
|
|
if (!c) {
|
|
return null;
|
|
}
|
|
|
|
return <c.component path={path} release={currentVersion} />;
|
|
}
|
|
|
|
ReleaseNote.defaultProps = {
|
|
path: '',
|
|
};
|
|
|
|
export default ReleaseNote;
|