Skip to content

Fix spinner in action buttons #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/components/RJST/Actions/Create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { getCreateDisabledReason } from '../utils';
import { ActionContent, LOADING_DISABLED_REASON } from './ActionContent';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faMagic } from '@fortawesome/free-solid-svg-icons/faMagic';
import { Box, Button } from '@mui/material';
import { Spinner } from '../../Spinner';
import { Box, Button, CircularProgress } from '@mui/material';
import { useTranslation } from '../../../hooks/useTranslations';
import { Tooltip } from '../../Tooltip';

Expand Down Expand Up @@ -91,12 +90,18 @@ export const Create = <T extends RJSTBaseResource<T>>({
}));
}}
>
<Box display="flex" justifyContent="space-between">
<Box
display="flex"
justifyContent="space-between"
alignItems="center"
>
{action.title}
<Spinner
sx={{ ml: 2 }}
show={disabledReason === LOADING_DISABLED_REASON}
/>
{disabledReason === LOADING_DISABLED_REASON && (
<CircularProgress
size="1rem"
sx={{ ml: 2, color: 'currentcolor' }}
/>
)}
</Box>
</ActionContent>
</Button>
Expand Down
32 changes: 22 additions & 10 deletions src/components/RJST/Actions/Update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faPenToSquare } from '@fortawesome/free-solid-svg-icons/faPenToSquare';
import type { CheckedState } from '../components/Table/utils';
import { useTranslation } from '../../../hooks/useTranslations';
import { Box, Button, useMediaQuery, useTheme } from '@mui/material';
import {
Box,
Button,
CircularProgress,
useMediaQuery,
useTheme,
} from '@mui/material';
import type { DropDownButtonProps } from '../../DropDownButton';
import { DropDownButton } from '../../DropDownButton';
import { Spinner } from '../../Spinner';
import { Tooltip } from '../../Tooltip';

interface UpdateProps<T extends RJSTBaseResource<T>> {
Expand Down Expand Up @@ -101,6 +106,7 @@ export const Update = <T extends RJSTBaseResource<T>>({
<Box
display="flex"
justifyContent="space-between"
alignItems="center"
gap={2}
color={
action.isDangerous && !disabledReasonsByAction[action.title]
Expand All @@ -109,9 +115,9 @@ export const Update = <T extends RJSTBaseResource<T>>({
}
>
{action.title}
<Spinner
show={disabledActionReason === LOADING_DISABLED_REASON}
/>
{disabledActionReason === LOADING_DISABLED_REASON && (
<CircularProgress size="1rem" sx={{ color: 'currentcolor' }} />
)}
</Box>
</ActionContent>
),
Expand Down Expand Up @@ -209,12 +215,18 @@ export const Update = <T extends RJSTBaseResource<T>>({
}));
}}
>
<Box display="flex" justifyContent="space-between">
<Box
display="flex"
justifyContent="space-between"
alignItems="center"
>
{action.title}
<Spinner
sx={{ ml: 2 }}
show={disabledUpdateReason === LOADING_DISABLED_REASON}
/>
{disabledUpdateReason === LOADING_DISABLED_REASON && (
<CircularProgress
size="1rem"
sx={{ ml: 2, color: 'currentcolor' }}
/>
)}
</Box>
</ActionContent>
</Button>
Expand Down
Loading