From 92c9001c9d1f2cbd272a5897ea1157d2cadbce2d Mon Sep 17 00:00:00 2001 From: sct Date: Mon, 14 Dec 2020 06:37:34 +0000 Subject: [PATCH] fix(frontend): new radarr/sonarr ports will be converted to a number before posting --- src/components/Common/Modal/index.tsx | 220 +++++++++--------- src/components/Settings/RadarrModal/index.tsx | 2 +- src/components/Settings/SonarrModal/index.tsx | 2 +- src/hooks/useClickOutside.ts | 2 +- 4 files changed, 111 insertions(+), 115 deletions(-) diff --git a/src/components/Common/Modal/index.tsx b/src/components/Common/Modal/index.tsx index 2a7347023..beb8ff8ee 100644 --- a/src/components/Common/Modal/index.tsx +++ b/src/components/Common/Modal/index.tsx @@ -63,126 +63,122 @@ const Modal: React.FC = ({ }); useLockBodyScroll(true, disableScrollLock); - return ( - <> - {ReactDOM.createPortal( - // eslint-disable-next-line jsx-a11y/no-static-element-interactions + return ReactDOM.createPortal( + // eslint-disable-next-line jsx-a11y/no-static-element-interactions +
{ + if (e.key === 'Escape') { + typeof onCancel === 'function' && backgroundClickable + ? onCancel() + : undefined; + } + }} + > + +
+ +
+
+
{ - if (e.key === 'Escape') { - typeof onCancel === 'function' && backgroundClickable - ? onCancel() - : undefined; - } - }} + className="inline-block align-bottom bg-gray-700 sm:rounded-lg px-4 pt-5 pb-4 text-left overflow-auto shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-3xl w-full sm:p-6 max-h-full" + role="dialog" + aria-modal="true" + aria-labelledby="modal-headline" + ref={modalRef} > - -
- -
-
- +
+ {iconSvg && ( +
+ {iconSvg} +
+ )}
-
- {iconSvg && ( -
- {iconSvg} -
- )} - -
- {children && ( -
- {children} -
+ {title} + + )} +
+
+ {children && ( +
+ {children} +
+ )} + {(onCancel || onOk || onSecondary || onTertiary) && ( +
+ {typeof onOk === 'function' && ( + + )} + {typeof onSecondary === 'function' && secondaryText && ( + )} - {(onCancel || onOk || onSecondary || onTertiary) && ( -
- {typeof onOk === 'function' && ( - - )} - {typeof onSecondary === 'function' && secondaryText && ( - - )} - {typeof onTertiary === 'function' && tertiaryText && ( - - )} - {typeof onCancel === 'function' && ( - - )} -
+ {typeof onTertiary === 'function' && tertiaryText && ( + + )} + {typeof onCancel === 'function' && ( + )}
-
-
, - document.body - )} - + )} +
+ + , + document.body ); }; diff --git a/src/components/Settings/RadarrModal/index.tsx b/src/components/Settings/RadarrModal/index.tsx index 5542facfd..d536dfd91 100644 --- a/src/components/Settings/RadarrModal/index.tsx +++ b/src/components/Settings/RadarrModal/index.tsx @@ -108,7 +108,7 @@ const RadarrModal: React.FC = ({ { hostname, apiKey, - port, + port: Number(port), baseUrl, useSsl, } diff --git a/src/components/Settings/SonarrModal/index.tsx b/src/components/Settings/SonarrModal/index.tsx index c6674781e..ff13807fb 100644 --- a/src/components/Settings/SonarrModal/index.tsx +++ b/src/components/Settings/SonarrModal/index.tsx @@ -111,7 +111,7 @@ const SonarrModal: React.FC = ({ { hostname, apiKey, - port, + port: Number(port), baseUrl, useSsl, } diff --git a/src/hooks/useClickOutside.ts b/src/hooks/useClickOutside.ts index 3b8adf35e..0c762593a 100644 --- a/src/hooks/useClickOutside.ts +++ b/src/hooks/useClickOutside.ts @@ -15,7 +15,7 @@ const useClickOutside = ( ): void => { useEffect(() => { const handleBodyClick = (e: MouseEvent) => { - if (!ref.current?.contains(e.target as Node)) { + if (ref.current && !ref.current.contains(e.target as Node)) { callback(e); } };