@applica-software-guru/react-admin 1.3.173 → 1.3.175
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/Header/Notification/Notification.d.ts.map +1 -1
- package/dist/components/Layout/Header/Notification/NotificationItem.d.ts.map +1 -1
- package/dist/components/ra-fields/DateAgoField.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +47 -47
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +4765 -4702
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +60 -60
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Layout/Header/Notification/Notification.tsx +28 -4
- package/src/components/Layout/Header/Notification/NotificationItem.tsx +18 -2
- package/src/components/ra-fields/DateAgoField.jsx +2 -0
- package/src/components/ra-lists/BulkFloatingActionsToolbar.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BellOutlined, CheckCircleOutlined } from '@ant-design/icons';
|
|
2
2
|
import { useLayoutMediaState, useLayoutNotificationsState } from '../../Provider';
|
|
3
3
|
import { HeaderToggleButton } from '../Buttons';
|
|
4
|
-
import { useGetList, useTranslate } from 'ra-core';
|
|
4
|
+
import { useGetList, useNotify, useRefresh, useTranslate, useUpdateMany } from 'ra-core';
|
|
5
5
|
import { HeaderNotificationItem, INotification } from './NotificationItem';
|
|
6
|
-
import { useEffect, useState } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
7
7
|
import {
|
|
8
8
|
Badge,
|
|
9
9
|
ClickAwayListener,
|
|
@@ -21,6 +21,7 @@ import { usePopoverState } from '../../../../hooks';
|
|
|
21
21
|
import { IconButton, Transitions } from '../../../@extended';
|
|
22
22
|
import MainCard from '../../../MainCard';
|
|
23
23
|
import { Link } from 'react-router-dom';
|
|
24
|
+
import dayjs from 'dayjs';
|
|
24
25
|
|
|
25
26
|
const avatarSx = {
|
|
26
27
|
width: 36,
|
|
@@ -45,6 +46,8 @@ function HeaderNotification() {
|
|
|
45
46
|
function HeaderNotificationButton() {
|
|
46
47
|
const translate = useTranslate(),
|
|
47
48
|
theme = useTheme(),
|
|
49
|
+
refresh = useRefresh(),
|
|
50
|
+
notify = useNotify(),
|
|
48
51
|
{ downMd } = useLayoutMediaState(),
|
|
49
52
|
{ resource } = useLayoutNotificationsState(),
|
|
50
53
|
[notifications, setNotifications] = useState<Array<INotification>>([]),
|
|
@@ -64,6 +67,27 @@ function HeaderNotificationButton() {
|
|
|
64
67
|
}
|
|
65
68
|
}, [data, isLoading]);
|
|
66
69
|
|
|
70
|
+
const unreadNotificationIds = notifications.filter((notification) => !notification.readed).map((notification) => notification.id);
|
|
71
|
+
|
|
72
|
+
const [updateMany] = useUpdateMany(
|
|
73
|
+
resource,
|
|
74
|
+
{
|
|
75
|
+
ids: unreadNotificationIds,
|
|
76
|
+
data: { readed: dayjs().format('YYYY-MM-DD HH:mm:ss') }
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
onSuccess: () => {
|
|
80
|
+
refresh();
|
|
81
|
+
notify('resources.notifications.messages.readed.done');
|
|
82
|
+
},
|
|
83
|
+
onError: () => notify('ra.notification.readed_error')
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const handleUpdateMany = useCallback(() => {
|
|
88
|
+
updateMany();
|
|
89
|
+
}, [updateMany]);
|
|
90
|
+
|
|
67
91
|
return (
|
|
68
92
|
<>
|
|
69
93
|
<HeaderToggleButton value="notifications" selected={open} onChange={handleToggle}>
|
|
@@ -90,14 +114,14 @@ function HeaderNotificationButton() {
|
|
|
90
114
|
>
|
|
91
115
|
<ClickAwayListener onClickAway={handleClose}>
|
|
92
116
|
<MainCard
|
|
93
|
-
title=
|
|
117
|
+
title={translate('ra.notification.title')}
|
|
94
118
|
elevation={0}
|
|
95
119
|
border={false}
|
|
96
120
|
content={false}
|
|
97
121
|
secondary={
|
|
98
122
|
<>
|
|
99
123
|
{read > 0 && (
|
|
100
|
-
<Tooltip title=
|
|
124
|
+
<Tooltip title={translate('ra.notification.mark-as-read')} onClick={handleUpdateMany}>
|
|
101
125
|
{/*@ts-ignore*/}
|
|
102
126
|
<IconButton color="success" size="small">
|
|
103
127
|
<CheckCircleOutlined style={{ fontSize: '1.15rem' }} />
|
|
@@ -74,9 +74,25 @@ function HeaderNotificationItem(props: IHeaderNotificationItemProps) {
|
|
|
74
74
|
<MessageOutlined />
|
|
75
75
|
</Avatar>
|
|
76
76
|
</ListItemAvatar>
|
|
77
|
-
<ListItemText
|
|
77
|
+
<ListItemText
|
|
78
|
+
sx={{
|
|
79
|
+
overflow: 'hidden',
|
|
80
|
+
wordBreak: 'break-word',
|
|
81
|
+
width: '90%'
|
|
82
|
+
}}
|
|
83
|
+
primary={notification.title}
|
|
84
|
+
secondary={notification.content}
|
|
85
|
+
/>
|
|
78
86
|
<Box flexGrow={1} flexShrink={1} minWidth={theme.spacing(2)} />
|
|
79
|
-
<ListItemText
|
|
87
|
+
<ListItemText
|
|
88
|
+
sx={{
|
|
89
|
+
overflow: 'hidden',
|
|
90
|
+
whiteSpace: 'pre-wrap',
|
|
91
|
+
wordBreak: 'break-word'
|
|
92
|
+
}}
|
|
93
|
+
primary={ago}
|
|
94
|
+
primaryTypographyProps={{ variant: 'caption' }}
|
|
95
|
+
/>
|
|
80
96
|
</ListItemButton>
|
|
81
97
|
</ListItem>
|
|
82
98
|
);
|
|
@@ -26,9 +26,9 @@ const BulkFloatingActionsToolbar = (props: BulkFloatingActionsToolbarProps) => {
|
|
|
26
26
|
setAnchorEl(null);
|
|
27
27
|
};
|
|
28
28
|
const isSmall = useMediaQuery((theme: Theme) => theme.breakpoints.down('md'));
|
|
29
|
-
const open = Boolean(anchorEl);
|
|
30
|
-
const id = open ? 'simple-popover' : undefined;
|
|
31
29
|
const { filterValues, resource, selectedIds = [], onUnselectItems } = useListContext(props);
|
|
30
|
+
const open = Boolean(anchorEl) && selectedIds !== undefined && selectedIds.length > 0;
|
|
31
|
+
const id = open ? 'simple-popover' : undefined;
|
|
32
32
|
|
|
33
33
|
const handleUnselectAllClick = React.useCallback(() => {
|
|
34
34
|
onUnselectItems();
|