mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-23 01:16:27 +02:00
**Upgrade to React v18 for Unleash v6. Here's why I think it's a good time to do it:** - Command Bar project: We've begun work on the command bar project, and there's a fantastic library we want to use. However, it requires React v18 support. - Straightforward Upgrade: I took a look at the upgrade guide https://react.dev/blog/2022/03/08/react-18-upgrade-guide and it seems fairly straightforward. In fact, I was able to get React v18 running with minimal changes in just 10 minutes! - Dropping IE Support: React v18 no longer supports Internet Explorer (IE), which is no longer supported by Microsoft as of June 15, 2022. Upgrading to v18 in v6 would be a good way to align with this change. TS updates: * FC children has to be explicit: https://stackoverflow.com/questions/71788254/react-18-typescript-children-fc * forcing version 18 types in resolutions: https://sentry.io/answers/type-is-not-assignable-to-type-reactnode/ Test updates: * fixing SWR issue that we have always had but it manifests more in new React (https://github.com/vercel/swr/issues/2373) --------- Co-authored-by: kwasniew <kwasniewski.mateusz@gmail.com>
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import type React from 'react';
|
|
import type { FC } from 'react';
|
|
|
|
import CheckBox from '@mui/icons-material/Check';
|
|
import Today from '@mui/icons-material/Today';
|
|
import { APPLY_CHANGE_REQUEST } from 'component/providers/AccessProvider/permissions';
|
|
import { MultiActionButton } from 'component/common/MultiActionButton/MultiActionButton';
|
|
import { useChangeRequest } from 'hooks/api/getters/useChangeRequest/useChangeRequest';
|
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
|
|
|
export const ApplyButton: FC<{
|
|
disabled: boolean;
|
|
onSchedule: () => void;
|
|
onApply: () => void;
|
|
variant?: 'create' | 'update';
|
|
children?: React.ReactNode;
|
|
}> = ({ disabled, onSchedule, onApply, variant = 'create', children }) => {
|
|
const projectId = useRequiredPathParam('projectId');
|
|
const id = useRequiredPathParam('id');
|
|
const { data } = useChangeRequest(projectId, id);
|
|
|
|
return (
|
|
<MultiActionButton
|
|
permission={APPLY_CHANGE_REQUEST}
|
|
disabled={disabled}
|
|
actions={[
|
|
{
|
|
label: 'Apply changes',
|
|
onSelect: onApply,
|
|
icon: <CheckBox fontSize='small' />,
|
|
},
|
|
{
|
|
label:
|
|
variant === 'create'
|
|
? 'Schedule changes'
|
|
: 'Update schedule',
|
|
onSelect: onSchedule,
|
|
icon: <Today fontSize='small' />,
|
|
},
|
|
]}
|
|
environmentId={data?.environment}
|
|
projectId={projectId}
|
|
ariaLabel='apply or schedule changes'
|
|
>
|
|
{children}
|
|
</MultiActionButton>
|
|
);
|
|
};
|