Skip to content
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

Add <LoadingIndicator onClick> prop, allowing to trigger actions (like a refresh) on click #9420

Merged
merged 2 commits into from
Nov 7, 2023
Merged
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
9 changes: 6 additions & 3 deletions packages/ra-ui-materialui/src/layout/LoadingIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import CircularProgress from '@mui/material/CircularProgress';
import { useLoading } from 'ra-core';

import { RefreshIconButton } from '../button';
import { RefreshIconButton, RefreshIconButtonProps } from '../button';
import { SxProps } from '@mui/system';

export const LoadingIndicator = (props: LoadingIndicatorProps) => {
const { className, sx, ...rest } = props;
const { className, onClick, sx, ...rest } = props;
const loading = useLoading();

const theme = useTheme();
Expand All @@ -20,6 +20,7 @@
className={`${LoadingIndicatorClasses.loadedIcon} ${
loading && LoadingIndicatorClasses.loadedLoading
}`}
onClick={onClick}
/>
{loading && (
<CircularProgress
Expand All @@ -43,11 +44,13 @@
width: PropTypes.string,
};

interface LoadingIndicatorProps {
interface Props {
className?: string;
sx?: SxProps;
}

type LoadingIndicatorProps = Props & Pick<RefreshIconButtonProps, 'onClick'>;

const PREFIX = 'RaLoadingIndicator';

export const LoadingIndicatorClasses = {
Expand All @@ -59,7 +62,7 @@
const Root = styled('div', {
name: PREFIX,
overridesResolver: (props, styles) => styles.root,
})(({ theme }) => ({

Check warning on line 65 in packages/ra-ui-materialui/src/layout/LoadingIndicator.tsx

View workflow job for this annotation

GitHub Actions / typecheck

'theme' is defined but never used. Allowed unused args must match /^_/u
position: 'relative',
[`& .${LoadingIndicatorClasses.loadedIcon}`]: {
[`&.${LoadingIndicatorClasses.loadedLoading}`]: {
Expand Down
Loading