diff --git a/src/hooks/MountEffects.ts b/src/hooks/MountEffects.ts deleted file mode 100644 index 98c36bf92faa1d16ada1aef1abdda52057f74a55..0000000000000000000000000000000000000000 --- a/src/hooks/MountEffects.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { useEffect, useRef } from "react"; - -function useMountEffect(effect, deps = [], afterMount) { - const didMountRef = useRef(false); - - useEffect(() => { - let cleanup; - if (didMountRef.current === afterMount) { - cleanup = effect(); - } - didMountRef.current = true; - return cleanup; - // eslint-disable-next-line - }, deps); -} - -export function useEffectOnMount(effect) { - useMountEffect(effect, [], false); -} - -export function useEffectAfterMount(effect, deps) { - useMountEffect(effect, deps, true); -} diff --git a/src/hooks/Redirect.ts b/src/hooks/Redirect.ts index cf0f577444ed274aae948ba40f5806a7b575c2fd..27fa682380a855fad72edd7b1e231684d3bff1a6 100644 --- a/src/hooks/Redirect.ts +++ b/src/hooks/Redirect.ts @@ -6,7 +6,7 @@ export function useRedirect() { const navigate = useNavigate(); // const history = useHistory(); const redirect = useCallback( - (destination, state, replace = false) => { + (destination: string, state: object, replace: boolean = false) => { /* const method = replace ? history.replace : history.push; method(destination, { ...state, from: history.location.pathname });*/ navigate(destination, { replace: replace, state: state }); diff --git a/src/hooks/useTypingTimer.tsx b/src/hooks/useTypingTimer.tsx index 92538a99954267cef52ef2cf0ef6d5f283642136..eb680237f4889efd5a53329369fff2f26a1a73bc 100644 --- a/src/hooks/useTypingTimer.tsx +++ b/src/hooks/useTypingTimer.tsx @@ -1,12 +1,21 @@ -import { useState } from "react"; +import { useState, type KeyboardEvent } from "react"; -export function useTypingTimer({ init = "", interval = 750 } = {}) { - const [typingTimer, setTypingTimer] = useState(); +interface UseTypingTimerReturn { + value: string; + onKeyUp: (event: KeyboardEvent<HTMLInputElement>) => void; +} + +export function useTypingTimer({ + init = "", + interval = 750 +} = {}): UseTypingTimerReturn { + const [typingTimer, setTypingTimer] = useState<number | undefined>(undefined); const [value, setValue] = useState(init); const doneTypingInterval = interval; // ms - const onKeyUp = (event) => { - const { target, key } = event; + const onKeyUp = (event: KeyboardEvent<HTMLInputElement>): void => { + const target = event.target as HTMLInputElement; + const { key } = event; clearTimeout(typingTimer); if (key === "Enter") { setValue(target.value); @@ -20,5 +29,5 @@ export function useTypingTimer({ init = "", interval = 750 } = {}) { } }; - return [value, onKeyUp]; + return { value, onKeyUp }; } diff --git a/src/icons/BatchDeploySymbol.tsx b/src/icons/BatchDeploySymbol.tsx index 2cad91c34d61d8b9a0b8009fdb4be2648e637081..4177beaea2d14e77061a7ddcacb4314c3d08ce13 100644 --- a/src/icons/BatchDeploySymbol.tsx +++ b/src/icons/BatchDeploySymbol.tsx @@ -1,5 +1,9 @@ -import BatchDeployIcon from "./resources/batch/batch_deploy_icon.svg?react"; +import { ComponentProps } from "react"; +import BatchDeployIconSvg from "./resources/batch/batch_deploy_icon.svg?react"; +import { BatchDeployIcon } from "../components/Job/JobIcons"; -export function BatchDeploySymbol(props) { - return <BatchDeployIcon {...props} />; +export function BatchDeploySymbol( + props: ComponentProps<typeof BatchDeployIcon> +) { + return <BatchDeployIconSvg {...props} />; } diff --git a/src/icons/BatchUndeploySymbol.tsx b/src/icons/BatchUndeploySymbol.tsx index 4afdad2d4cc24d842804806d31a90036c9576798..3ad1d693442b12dbd151bc4221fe145175b5a85f 100644 --- a/src/icons/BatchUndeploySymbol.tsx +++ b/src/icons/BatchUndeploySymbol.tsx @@ -1,5 +1,9 @@ -import BatchUndeployIcon from "./resources/batch/batch_undeploy_icon.svg?react"; +import { type ComponentProps } from "react"; +import BatchUndeployIconSvg from "./resources/batch/batch_undeploy_icon.svg?react"; +import { BatchUndeployIcon } from "../components/Job/JobIcons"; -export function BatchUndeploySymbol(props) { - return <BatchUndeployIcon {...props} />; +export function BatchUndeploySymbol( + props: ComponentProps<typeof BatchUndeployIcon> +) { + return <BatchUndeployIconSvg {...props} />; } diff --git a/src/icons/CCCEControlSymbol.tsx b/src/icons/CCCEControlSymbol.tsx index 11061f4d65fefee013b5d484df3038b5cb6f8c16..92627a161de9813ee6c2b690bb4c1616d6fa0353 100644 --- a/src/icons/CCCEControlSymbol.tsx +++ b/src/icons/CCCEControlSymbol.tsx @@ -1,5 +1,5 @@ import CcceControlSymbolGray from "./resources/control/ccce-control-symbol_757575.svg?react"; -export function CCCEControlSymbol(props) { +export function CCCEControlSymbol(props: { width: string; height: string }) { return <CcceControlSymbolGray {...props} />; } diff --git a/src/icons/RocketLaunch.tsx b/src/icons/RocketLaunch.tsx deleted file mode 100644 index c960e88b04fd62640c0a8f7ef603756c8ce64fff..0000000000000000000000000000000000000000 --- a/src/icons/RocketLaunch.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Tooltip } from "@mui/material"; -import { ReactComponent as RocketLaunchBlack } from "./resources/rocket/rocket_launch_black_24dp.svg?react"; - -export function RocketLaunch(props) { - return ( - <Tooltip title="Deployment"> - <RocketLaunchBlack {...props} /> - </Tooltip> - ); -} diff --git a/src/style/Theme.ts b/src/style/Theme.ts index 127994bf4db15e6fd27d99daf42ff13beb069cbf..7a7c76efdc60e05b4528aa173d0a474708a860e0 100644 --- a/src/style/Theme.ts +++ b/src/style/Theme.ts @@ -17,6 +17,13 @@ declare module "@mui/material/styles" { disabled: { main: string; }; + icons: string; + }; + error: { + main: string; + }; + warning: { + main: string; }; primary: { inconsistency: string; diff --git a/src/types/common.ts b/src/types/common.ts index 4f06d5aa1d90b463cc89a81392f32b050189c11c..97affd9cb3052f164113f085376fe4c96415240f 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -47,3 +47,25 @@ export interface ApiResult<T> { export type FormElements<U extends string> = HTMLFormControlsCollection & Record<U, HTMLInputElement>; + +export interface Pagination { + page: number; + rows: number; + query?: string; + orderAsc?: boolean; + totalCount?: number; + rowsPerPageOptions?: number[]; +} + +export interface DeployIocFormDefaults { + name: string; + description: string; + git: string; + gitProjectId?: number; + reference?: string; + short_reference?: string; + netBoxHost?: { + fqdn: string; + hostId: string; + }; +}