2022-12-09 20:16:09 +05:30
|
|
|
import ReleaseNoteProps from 'components/ReleaseNote/ReleaseNoteProps';
|
|
|
|
|
import ReleaseNote0120 from 'components/ReleaseNote/Releases/ReleaseNote0120';
|
|
|
|
|
import ROUTES from 'constants/routes';
|
|
|
|
|
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;
|
|
|
|
|
}
|
2024-02-12 00:23:19 +05:30
|
|
|
const allowedPaths: string[] = [
|
2022-12-09 20:16:09 +05:30
|
|
|
ROUTES.LIST_ALL_ALERT,
|
|
|
|
|
ROUTES.APPLICATION,
|
|
|
|
|
ROUTES.ALL_DASHBOARD,
|
|
|
|
|
];
|
2024-02-12 00:23:19 +05:30
|
|
|
|
2022-12-09 20:16:09 +05:30
|
|
|
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,
|
|
|
|
|
);
|
|
|
|
|
|
2023-01-24 18:53:04 +05:30
|
|
|
const c = allComponentMap.find((item) =>
|
|
|
|
|
item.match(path, currentVersion, userFlags),
|
|
|
|
|
);
|
2022-12-09 20:16:09 +05:30
|
|
|
|
|
|
|
|
if (!c) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return <c.component path={path} release={currentVersion} />;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReleaseNote.defaultProps = {
|
|
|
|
|
path: '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ReleaseNote;
|