Skip to content

Commit 1049ba0

Browse files
committed
Improve delete button props type.
1 parent fd54978 commit 1049ba0

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

packages/ra-ui-materialui/src/button/DeleteButton.tsx

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import * as React from 'react';
2-
import { UseMutationOptions } from '@tanstack/react-query';
32
import {
43
RaRecord,
5-
MutationMode,
6-
DeleteParams,
74
useRecordContext,
85
useSaveContext,
96
SaveContextValue,
10-
RedirectionSideEffect,
117
useResourceContext,
128
useCanAccess,
139
} from 'ra-core';
1410
import { useThemeProps } from '@mui/material/styles';
1511

16-
import { ButtonProps } from './Button';
17-
import { DeleteWithUndoButton } from './DeleteWithUndoButton';
18-
import { DeleteWithConfirmButton } from './DeleteWithConfirmButton';
12+
import {
13+
DeleteWithUndoButton,
14+
DeleteWithUndoButtonProps,
15+
} from './DeleteWithUndoButton';
16+
import {
17+
DeleteWithConfirmButton,
18+
DeleteWithConfirmButtonProps,
19+
} from './DeleteWithConfirmButton';
1920

2021
/**
2122
* Button used to delete a single record. Added by default by the <Toolbar> of edit and show views.
@@ -95,26 +96,14 @@ export const DeleteButton = <RecordType extends RaRecord = any>(
9596
);
9697
};
9798

98-
export interface DeleteButtonProps<
99+
export type DeleteButtonProps<
99100
RecordType extends RaRecord = any,
100101
MutationOptionsError = unknown,
101-
> extends ButtonProps,
102-
SaveContextValue {
103-
confirmTitle?: React.ReactNode;
104-
confirmContent?: React.ReactNode;
105-
confirmColor?: 'primary' | 'warning';
106-
icon?: React.ReactNode;
107-
mutationMode?: MutationMode;
108-
mutationOptions?: UseMutationOptions<
109-
RecordType,
110-
MutationOptionsError,
111-
DeleteParams<RecordType>
112-
>;
113-
record?: RecordType;
114-
redirect?: RedirectionSideEffect;
115-
resource?: string;
116-
successMessage?: string;
117-
}
102+
> = SaveContextValue &
103+
(
104+
| DeleteWithUndoButtonProps<RecordType, MutationOptionsError>
105+
| DeleteWithConfirmButtonProps<RecordType, MutationOptionsError>
106+
);
118107

119108
const PREFIX = 'RaDeleteButton';
120109

0 commit comments

Comments
 (0)