@applica-software-guru/react-admin 1.5.313 → 1.5.315
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Layout/Provider.d.ts.map +1 -1
- package/dist/components/ra-buttons/BulkDeleteWithConfirmButton.d.ts +3 -0
- package/dist/components/ra-buttons/BulkDeleteWithConfirmButton.d.ts.map +1 -1
- package/dist/components/ra-buttons/DeleteWithConfirmButton.d.ts.map +1 -1
- package/dist/i18n/messages.json +1 -1
- package/dist/i18n/messages.json.gz +0 -0
- package/dist/react-admin.cjs.js +48 -48
- package/dist/react-admin.cjs.js.gz +0 -0
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +5618 -5538
- package/dist/react-admin.es.js.gz +0 -0
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +54 -54
- package/dist/react-admin.umd.js.gz +0 -0
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/public/i18n/messages.json +1 -1
- package/src/components/Layout/Provider.tsx +4 -1
- package/src/components/ra-buttons/BulkDeleteWithConfirmButton.tsx +89 -5
- package/src/components/ra-buttons/DeleteWithConfirmButton.tsx +16 -11
package/package.json
CHANGED
|
@@ -645,7 +645,7 @@
|
|
|
645
645
|
"id": "en.ra.message.bulk_delete_content",
|
|
646
646
|
"code": "ra.message.bulk_delete_content",
|
|
647
647
|
"lang": "en",
|
|
648
|
-
"text": "Sei sicuro di voler cancellare questo %{name}? |||| Sei sicuro di voler eliminare questi %{smart_count}?"
|
|
648
|
+
"text": "Sei sicuro di voler cancellare questo %{name}? |||| Sei sicuro di voler eliminare questi %{smart_count} %{name}?"
|
|
649
649
|
},
|
|
650
650
|
{
|
|
651
651
|
"id": "en.ra.message.bulk_delete_title",
|
|
@@ -6,6 +6,7 @@ import { Dialog, useMediaQuery, useTheme } from '@mui/material';
|
|
|
6
6
|
import _ from 'lodash';
|
|
7
7
|
import { UseGetIdentityResult, useAuthProvider, useGetIdentity } from 'ra-core';
|
|
8
8
|
import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useReducer, useState } from 'react';
|
|
9
|
+
import { useLoading } from 'react-admin';
|
|
9
10
|
|
|
10
11
|
enum LayoutActionType {
|
|
11
12
|
UPDATE_MEDIA = 'updateMedia',
|
|
@@ -154,6 +155,7 @@ function LayoutProvider(props: ILayoutProviderProps) {
|
|
|
154
155
|
const handlePasswordChange = useCallback(() => setNeedToChangePassword(false), []);
|
|
155
156
|
const value = useMemo(() => ({ state, dispatch }), [state, dispatch]);
|
|
156
157
|
const { logoIcon, logoMain, enableNotification, notification } = props;
|
|
158
|
+
const isLayoutLoading = useLoading();
|
|
157
159
|
|
|
158
160
|
useEffect(() => {
|
|
159
161
|
dispatch({
|
|
@@ -216,6 +218,7 @@ function LayoutProvider(props: ILayoutProviderProps) {
|
|
|
216
218
|
}, [theme.palette.mode]);
|
|
217
219
|
|
|
218
220
|
useEffect(() => {
|
|
221
|
+
if (isLayoutLoading) return;
|
|
219
222
|
// Check if authProvider contains a method called isImpersonating
|
|
220
223
|
if (!authProvider.isImpersonating) {
|
|
221
224
|
// eslint-disable-next-line no-console
|
|
@@ -225,7 +228,7 @@ function LayoutProvider(props: ILayoutProviderProps) {
|
|
|
225
228
|
authProvider?.isImpersonating().then((isImpersonating: boolean) => {
|
|
226
229
|
setNeedToChangePassword(!isImpersonating && identity?.data?.needToChangePassword === true);
|
|
227
230
|
});
|
|
228
|
-
}, [identity?.data?.needToChangePassword, authProvider]);
|
|
231
|
+
}, [identity?.data?.needToChangePassword, authProvider, isLayoutLoading]);
|
|
229
232
|
|
|
230
233
|
return (
|
|
231
234
|
<LayoutContext.Provider value={value}>
|
|
@@ -3,7 +3,7 @@ import { ReactElement } from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import ActionDelete from '@mui/icons-material/Delete';
|
|
5
5
|
import inflection from 'inflection';
|
|
6
|
-
import { alpha, styled } from '@mui/material/styles';
|
|
6
|
+
import { SxProps, alpha, styled, useTheme } from '@mui/material/styles';
|
|
7
7
|
import {
|
|
8
8
|
DeleteManyParams,
|
|
9
9
|
MutationMode,
|
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
import { BulkActionProps, Button, ButtonProps, Confirm } from 'react-admin';
|
|
20
20
|
import { UseMutationOptions } from 'react-query';
|
|
21
21
|
import _ from 'lodash';
|
|
22
|
+
import { Box, Typography } from '@mui/material';
|
|
23
|
+
import { DeleteFilled } from '@ant-design/icons';
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
26
|
* BulkDeleteWithConfirmButton component allows you to delete multiple records with a confirmation dialog.
|
|
@@ -39,9 +41,10 @@ import _ from 'lodash';
|
|
|
39
41
|
*/
|
|
40
42
|
function BulkDeleteWithConfirmButton(props: BulkDeleteWithConfirmButtonProps) {
|
|
41
43
|
const {
|
|
42
|
-
confirmTitle
|
|
43
|
-
confirmContent
|
|
44
|
+
confirmTitle,
|
|
45
|
+
confirmContent,
|
|
44
46
|
confirmColor = 'primary',
|
|
47
|
+
dialogSx,
|
|
45
48
|
icon = defaultIcon,
|
|
46
49
|
label = 'ra.action.delete',
|
|
47
50
|
mutationMode = 'pessimistic',
|
|
@@ -58,6 +61,7 @@ function BulkDeleteWithConfirmButton(props: BulkDeleteWithConfirmButtonProps) {
|
|
|
58
61
|
const resource = useResourceContext(props);
|
|
59
62
|
const refresh = useRefresh();
|
|
60
63
|
const translate = useTranslate();
|
|
64
|
+
const theme = useTheme();
|
|
61
65
|
const [deleteMany, { isLoading }] = useDeleteMany(
|
|
62
66
|
resource,
|
|
63
67
|
{ ids: selectedIds, meta: mutationMeta },
|
|
@@ -119,8 +123,86 @@ function BulkDeleteWithConfirmButton(props: BulkDeleteWithConfirmButtonProps) {
|
|
|
119
123
|
<Confirm
|
|
120
124
|
isOpen={isOpen}
|
|
121
125
|
loading={isLoading}
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
sx={
|
|
127
|
+
dialogSx || {
|
|
128
|
+
'& .MuiPaper-root': {
|
|
129
|
+
p: 2
|
|
130
|
+
},
|
|
131
|
+
'& .MuiDialogActions-root': {
|
|
132
|
+
display: 'flex',
|
|
133
|
+
justifyContent: 'space-between',
|
|
134
|
+
width: '100%',
|
|
135
|
+
'& .RaConfirm-confirmPrimary': {
|
|
136
|
+
backgroundColor: theme.palette.primary.main,
|
|
137
|
+
color: theme.palette.primary.contrastText,
|
|
138
|
+
ml: 2,
|
|
139
|
+
'&:hover': {
|
|
140
|
+
backgroundColor: theme.palette.primary.dark
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
'& .MuiButtonBase-root': {
|
|
144
|
+
width: '50%',
|
|
145
|
+
border: `1px solid ${theme.palette.action.disabled}`
|
|
146
|
+
},
|
|
147
|
+
'& .MuiButton-icon': {
|
|
148
|
+
display: 'none'
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
title={
|
|
154
|
+
confirmTitle ? (
|
|
155
|
+
typeof confirmTitle === 'string' ? (
|
|
156
|
+
translate(confirmTitle)
|
|
157
|
+
) : (
|
|
158
|
+
confirmTitle
|
|
159
|
+
)
|
|
160
|
+
) : (
|
|
161
|
+
<Box
|
|
162
|
+
sx={{
|
|
163
|
+
display: 'flex',
|
|
164
|
+
alignItems: 'center',
|
|
165
|
+
justifyContent: 'center'
|
|
166
|
+
}}
|
|
167
|
+
>
|
|
168
|
+
<Box
|
|
169
|
+
sx={{
|
|
170
|
+
color: 'primary.main',
|
|
171
|
+
fontSize: '28px',
|
|
172
|
+
borderRadius: '50%',
|
|
173
|
+
backgroundColor: 'primary.lighter',
|
|
174
|
+
width: '56px',
|
|
175
|
+
height: '56px',
|
|
176
|
+
display: 'flex',
|
|
177
|
+
alignItems: 'center',
|
|
178
|
+
justifyContent: 'center'
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
<DeleteFilled />
|
|
182
|
+
</Box>
|
|
183
|
+
</Box>
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
content={
|
|
187
|
+
confirmContent || (
|
|
188
|
+
<Typography maxWidth="300px" variant="h4" align="center">
|
|
189
|
+
{translate('ra.message.bulk_delete_content', {
|
|
190
|
+
_: 'ra.message.bulk_delete_content',
|
|
191
|
+
smart_count: selectedIds.length,
|
|
192
|
+
name: translate(`resources.${resource}.forcedCaseName`, {
|
|
193
|
+
smart_count: selectedIds.length,
|
|
194
|
+
_: inflection.humanize(
|
|
195
|
+
translate(`resources.${resource}.name`, {
|
|
196
|
+
smart_count: selectedIds.length,
|
|
197
|
+
_: inflection.inflect(resource, selectedIds.length)
|
|
198
|
+
}),
|
|
199
|
+
true
|
|
200
|
+
)
|
|
201
|
+
})
|
|
202
|
+
})}
|
|
203
|
+
</Typography>
|
|
204
|
+
)
|
|
205
|
+
}
|
|
124
206
|
confirmColor={confirmColor}
|
|
125
207
|
translateOptions={{
|
|
126
208
|
smart_count: selectedIds.length,
|
|
@@ -158,6 +240,7 @@ interface BulkDeleteWithConfirmButtonProps<RecordType extends RaRecord = any, Mu
|
|
|
158
240
|
confirmContent?: React.ReactNode;
|
|
159
241
|
confirmTitle?: React.ReactNode;
|
|
160
242
|
confirmColor?: 'primary' | 'warning';
|
|
243
|
+
dialogSx?: SxProps;
|
|
161
244
|
icon?: ReactElement;
|
|
162
245
|
mutationMode: MutationMode;
|
|
163
246
|
mutationOptions?: UseMutationOptions<RecordType, MutationOptionsError, DeleteManyParams<RecordType>> & {
|
|
@@ -197,6 +280,7 @@ BulkDeleteWithConfirmButton.propTypes = {
|
|
|
197
280
|
confirmTitle: PropTypes.node,
|
|
198
281
|
confirmContent: PropTypes.node,
|
|
199
282
|
confirmColor: PropTypes.string,
|
|
283
|
+
dialogSx: PropTypes.object,
|
|
200
284
|
icon: PropTypes.element,
|
|
201
285
|
label: PropTypes.string,
|
|
202
286
|
mutationMode: PropTypes.oneOf(['pessimistic', 'optimistic', 'undoable']),
|
|
@@ -23,7 +23,7 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
|
|
|
23
23
|
confirmColor = 'primary',
|
|
24
24
|
color = 'error',
|
|
25
25
|
dialogSx,
|
|
26
|
-
icon =
|
|
26
|
+
icon = <ActionDelete />,
|
|
27
27
|
label = 'ra.action.delete',
|
|
28
28
|
mutationMode = 'pessimistic',
|
|
29
29
|
mutationOptions,
|
|
@@ -122,15 +122,22 @@ function DeleteWithConfirmButton<RecordType extends RaRecord = any>(
|
|
|
122
122
|
)
|
|
123
123
|
}
|
|
124
124
|
content={
|
|
125
|
-
confirmContent
|
|
126
|
-
typeof confirmContent === 'string' ? (
|
|
127
|
-
translate(confirmContent)
|
|
128
|
-
) : (
|
|
129
|
-
confirmContent
|
|
130
|
-
)
|
|
131
|
-
) : (
|
|
125
|
+
confirmContent || (
|
|
132
126
|
<Typography maxWidth="300px" variant="h4" align="center">
|
|
133
|
-
{translate('ra.message.delete_content'
|
|
127
|
+
{translate('ra.message.delete_content', {
|
|
128
|
+
_: 'ra.message.delete_content',
|
|
129
|
+
name: translate(`resources.${resource}.forcedCaseName`, {
|
|
130
|
+
smart_count: 1,
|
|
131
|
+
_: inflection.humanize(
|
|
132
|
+
translate(`resources.${resource}.name`, {
|
|
133
|
+
smart_count: 1,
|
|
134
|
+
_: inflection.singularize(resource)
|
|
135
|
+
}),
|
|
136
|
+
true
|
|
137
|
+
)
|
|
138
|
+
}),
|
|
139
|
+
id: record?.id
|
|
140
|
+
})}
|
|
134
141
|
</Typography>
|
|
135
142
|
)
|
|
136
143
|
}
|
|
@@ -172,6 +179,4 @@ DeleteWithConfirmButton.propTypes = {
|
|
|
172
179
|
translateOptions: PropTypes.object
|
|
173
180
|
};
|
|
174
181
|
|
|
175
|
-
const defaultIcon = <ActionDelete />;
|
|
176
|
-
|
|
177
182
|
export { DeleteWithConfirmButton };
|