diff --git a/src-gui/src/renderer/components/App.tsx b/src-gui/src/renderer/components/App.tsx index 581b333a..7e4dc89a 100644 --- a/src-gui/src/renderer/components/App.tsx +++ b/src-gui/src/renderer/components/App.tsx @@ -26,19 +26,11 @@ const theme = createTheme({ }, secondary: indigo, }, - transitions: { - create: () => "none", - }, - props: { - MuiButtonBase: { - disableRipple: true, - }, - }, typography: { overline: { - textTransform: 'none', // This prevents the text from being all caps + textTransform: "none", // This prevents the text from being all caps }, - } + }, }); function InnerContent() { diff --git a/src-gui/src/renderer/components/PromiseInvokeButton.tsx b/src-gui/src/renderer/components/PromiseInvokeButton.tsx index c4044da1..1acdfaa7 100644 --- a/src-gui/src/renderer/components/PromiseInvokeButton.tsx +++ b/src-gui/src/renderer/components/PromiseInvokeButton.tsx @@ -1,33 +1,44 @@ -import { Button, ButtonProps, IconButton } from "@material-ui/core"; +import { + Button, + ButtonProps, + IconButton, + IconButtonProps, + Tooltip, +} from "@material-ui/core"; import CircularProgress from "@material-ui/core/CircularProgress"; import { useSnackbar } from "notistack"; import { ReactNode, useState } from "react"; +import { useIsContextAvailable } from "store/hooks"; interface PromiseInvokeButtonProps { - onSuccess?: (data: T) => void; + onSuccess: (data: T) => void | null; onClick: () => Promise; - onPendingChange?: (isPending: boolean) => void; - isLoadingOverride?: boolean; - isIconButton?: boolean; - loadIcon?: ReactNode; - disabled?: boolean; - displayErrorSnackbar?: boolean; - tooltipTitle?: string; + onPendingChange: (isPending: boolean) => void | null; + isLoadingOverride: boolean; + isIconButton: boolean; + loadIcon: ReactNode; + disabled: boolean; + displayErrorSnackbar: boolean; + tooltipTitle: string | null; + requiresContext: boolean; } export default function PromiseInvokeButton({ - disabled, - onSuccess, + disabled = false, + onSuccess = null, onClick, endIcon, - loadIcon, - isLoadingOverride, - isIconButton, - displayErrorSnackbar, - onPendingChange, + loadIcon = null, + isLoadingOverride = false, + isIconButton = false, + displayErrorSnackbar = false, + onPendingChange = null, + requiresContext = true, + tooltipTitle = null, ...rest }: ButtonProps & PromiseInvokeButtonProps) { const { enqueueSnackbar } = useSnackbar(); + const isContextAvailable = useIsContextAvailable(); const [isPending, setIsPending] = useState(false); @@ -36,7 +47,7 @@ export default function PromiseInvokeButton({ ? loadIcon || : endIcon; - async function handleClick(event: React.MouseEvent) { + async function handleClick() { if (!isPending) { try { onPendingChange?.(true); @@ -57,18 +68,34 @@ export default function PromiseInvokeButton({ } } - const isDisabled = disabled || isLoading; + const requiresContextButNotAvailable = requiresContext && !isContextAvailable; + const isDisabled = disabled || isLoading || requiresContextButNotAvailable; - return isIconButton ? ( - - {actualEndIcon} - - ) : ( -