@abtnode/ux 1.16.20 → 1.16.21-beta-edf184e1

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.
@@ -0,0 +1,216 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = NotificationsList;
7
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _react = require("react");
10
+ var _reactRouterDom = require("react-router-dom");
11
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
12
+ var _context = require("@arcblock/ux/lib/Locale/context");
13
+ var _Avatar = _interopRequireDefault(require("@mui/material/Avatar"));
14
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
15
+ var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
16
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
17
+ var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
18
+ var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
19
+ var _List = _interopRequireDefault(require("@mui/material/List"));
20
+ var _ListItemAvatar = _interopRequireDefault(require("@mui/material/ListItemAvatar"));
21
+ var _ListItemButton = _interopRequireDefault(require("@mui/material/ListItemButton"));
22
+ var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
23
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
24
+ var _useTheme = _interopRequireDefault(require("@mui/material/styles/useTheme"));
25
+ var _tag = _interopRequireDefault(require("./tag"));
26
+ var _permission = _interopRequireDefault(require("../permission"));
27
+ var _relativeTime = _interopRequireDefault(require("../relative-time"));
28
+ var _node = require("../contexts/node");
29
+ var _util = require("../util");
30
+ var _jsxRuntime = require("react/jsx-runtime");
31
+ var _templateObject;
32
+ /* eslint-disable operator-linebreak */
33
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
35
+ function NotificationsList(_ref) {
36
+ let {
37
+ onHide,
38
+ api,
39
+ notifications,
40
+ updateNotifications,
41
+ viewAllUrl,
42
+ teamDid
43
+ } = _ref;
44
+ const {
45
+ inService
46
+ } = (0, _node.useNodeContext)();
47
+ const {
48
+ t,
49
+ locale
50
+ } = (0, _react.useContext)(_context.LocaleContext);
51
+ const [showRead, setShowRead] = (0, _react.useState)(true);
52
+ const [isMarkingAll, setIsMarkingAll] = (0, _react.useState)(false);
53
+ const navigate = (0, _reactRouterDom.useNavigate)();
54
+ const theme = (0, _useTheme.default)();
55
+ let filtered = showRead ? notifications : notifications.filter(x => x.read === false);
56
+ filtered = filtered.slice(0, 5);
57
+ const hasUnRead = notifications.filter(x => x.read === false).length > 0;
58
+ const onUnreadNotifications = async () => {
59
+ setIsMarkingAll(true);
60
+ const ids = notifications.filter(x => x.read === false).map(x => x.id).join(',');
61
+ if (inService) {
62
+ await api.readBlockletNotifications({
63
+ input: {
64
+ id: ids,
65
+ teamDid
66
+ }
67
+ });
68
+ } else {
69
+ await api.readNotifications({
70
+ input: {
71
+ id: ids
72
+ }
73
+ });
74
+ }
75
+ updateNotifications();
76
+ setIsMarkingAll(false);
77
+ };
78
+ const handleNotificationClick = (e, notification) => {
79
+ if (!notification.read) {
80
+ if (inService) {
81
+ api.readBlockletNotifications({
82
+ input: {
83
+ id: notification.id,
84
+ teamDid
85
+ }
86
+ }).then(() => updateNotifications());
87
+ } else {
88
+ api.readNotifications({
89
+ input: {
90
+ id: notification.id
91
+ }
92
+ }).then(() => updateNotifications());
93
+ }
94
+ }
95
+ onHide(e);
96
+ navigate(viewAllUrl);
97
+ };
98
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
99
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
100
+ component: "h3",
101
+ variant: "h6",
102
+ className: "notification-header",
103
+ children: [t('notification.title'), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Button.default, {
104
+ component: _reactRouterDom.Link,
105
+ to: viewAllUrl,
106
+ "data-cy": "view-all-notifications-btn",
107
+ onClick: onHide,
108
+ children: t('notification.viewAll')
109
+ })]
110
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_List.default, {
111
+ className: "notification-list",
112
+ style: {
113
+ maxHeight: 'calc(100vh - 200px)',
114
+ overflow: 'auto'
115
+ },
116
+ children: [filtered.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
117
+ component: "p",
118
+ variant: "body1",
119
+ className: "notification-tip",
120
+ children: t('notification.empty')
121
+ }), filtered.length > 0 && filtered.map(x => /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ListItemButton.default, {
122
+ alignItems: "flex-start",
123
+ disabled: x.read,
124
+ onClick: e => handleNotificationClick(e, x),
125
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemAvatar.default, {
126
+ className: "list-item-avatar",
127
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
128
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, {
129
+ children: x.entityType.substr(0, 1).toUpperCase()
130
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_tag.default, {
131
+ className: "notification-tag",
132
+ status: x.severity
133
+ })]
134
+ })
135
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemText.default, {
136
+ primary: x.title,
137
+ secondary: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
138
+ sx: {
139
+ display: 'flex',
140
+ flexDirection: 'column',
141
+ justifyContent: 'space-between'
142
+ },
143
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
144
+ component: "span",
145
+ sx: {
146
+ overflow: 'hidden',
147
+ '-webkit-line-clamp': '3',
148
+ '-webkit-box-orient': 'vertical',
149
+ display: '-webkit-box',
150
+ 'text-overflow': 'ellipsis'
151
+ },
152
+ children: x.description
153
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_relativeTime.default, {
154
+ value: x.createdAt,
155
+ locale: locale,
156
+ style: {
157
+ color: theme.palette.text.secondary,
158
+ fontSize: '0.875rem',
159
+ marginTop: '4px'
160
+ }
161
+ })]
162
+ })
163
+ })]
164
+ }, x.id))]
165
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
166
+ component: "div",
167
+ className: "notification-footer",
168
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
169
+ control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.default, {
170
+ checked: showRead,
171
+ onChange: () => setShowRead(!showRead),
172
+ name: "showRead",
173
+ color: "primary"
174
+ }),
175
+ label: t('notification.showRead')
176
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
177
+ permission: inService ? '' : 'mutate_notification',
178
+ role: inService ? _util.BlockletAdminRoles : [],
179
+ children: hasUnRead && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
180
+ disabled: isMarkingAll,
181
+ onClick: onUnreadNotifications,
182
+ className: "",
183
+ children: [isMarkingAll && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
184
+ size: 16,
185
+ style: {
186
+ marginRight: '1em'
187
+ }
188
+ }), t('notification.markAllAsRead')]
189
+ })
190
+ })]
191
+ })]
192
+ });
193
+ }
194
+ const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 420px;\n\n @media (max-width: ", "px) {\n width: calc(100vw - 10px);\n }\n\n .notification-header {\n padding: 8px 16px;\n display: flex;\n justify-content: space-between;\n }\n\n .notification-tip {\n padding: 8px 16px;\n }\n\n .notification-footer {\n padding: 8px 16px;\n display: flex;\n justify-content: space-between;\n }\n\n .MuiButtonBase-root {\n white-space: pre-wrap;\n }\n\n .list-item-avatar {\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 80px;\n\n .notification-tag {\n margin-top: 4px;\n }\n }\n\n .MuiButtonBase-root:not(.Mui-disabled) {\n .MuiAvatar-root {\n background: ", ";\n }\n }\n"])), props => props.theme.breakpoints.values.sm, props => props.theme.palette.primary.light);
195
+ NotificationsList.propTypes = {
196
+ onHide: _propTypes.default.func,
197
+ api: _propTypes.default.shape({
198
+ readNotifications: _propTypes.default.func.isRequired,
199
+ readBlockletNotifications: _propTypes.default.func.isRequired
200
+ }).isRequired,
201
+ notifications: _propTypes.default.arrayOf(_propTypes.default.shape({
202
+ id: _propTypes.default.string,
203
+ read: _propTypes.default.bool,
204
+ entityType: _propTypes.default.string,
205
+ title: _propTypes.default.string,
206
+ createdAt: _propTypes.default.string,
207
+ description: _propTypes.default.string
208
+ }).isRequired).isRequired,
209
+ updateNotifications: _propTypes.default.func.isRequired,
210
+ viewAllUrl: _propTypes.default.string.isRequired,
211
+ teamDid: _propTypes.default.string
212
+ };
213
+ NotificationsList.defaultProps = {
214
+ onHide: () => {},
215
+ teamDid: ''
216
+ };
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _styles = require("@mui/styles");
10
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
11
+ var _colors = require("@mui/material/colors");
12
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
13
+ var _Close = _interopRequireDefault(require("@mui/icons-material/Close"));
14
+ var _reactRouterDom = require("react-router-dom");
15
+ var _notistack = require("notistack");
16
+ var _useWidth = _interopRequireDefault(require("../hooks/use-width"));
17
+ var _defaultIconVariants = _interopRequireDefault(require("./default-icon-variants"));
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ var _templateObject;
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
22
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
23
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
26
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint-disable no-unused-vars */ /* eslint-disable operator-linebreak */
27
+ const useStyles = (0, _styles.makeStyles)(theme => {
28
+ const breakpointsMap = {
29
+ xl: '400px',
30
+ lg: '400px',
31
+ md: '400px',
32
+ sm: '300px'
33
+ };
34
+ // const backgroundColor = emphasize(theme.palette.background.default, theme.palette.mode === 'light' ? 0.8 : 0.98);
35
+ const backgroundColor = theme.palette.background.default;
36
+ return {
37
+ lessPadding: {
38
+ paddingLeft: 8 * 2.5
39
+ },
40
+ contentRoot: _objectSpread(_objectSpread({}, theme.typography.body2), {}, {
41
+ display: 'flex',
42
+ backgroundColor,
43
+ color: '#fff',
44
+ alignItems: 'center',
45
+ padding: '6px 16px',
46
+ borderRadius: '4px',
47
+ boxShadow: '0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)'
48
+ }),
49
+ success: props => ({
50
+ backgroundColor: "".concat(_colors.green[600], " !important"),
51
+ width: breakpointsMap[props.breakpoint]
52
+ }),
53
+ error: props => ({
54
+ backgroundColor: "".concat(theme.palette.error.dark, " !important"),
55
+ width: breakpointsMap[props.breakpoint]
56
+ }),
57
+ info: props => ({
58
+ backgroundColor: "".concat(theme.palette.primary.main, " !important"),
59
+ width: breakpointsMap[props.breakpoint]
60
+ }),
61
+ warning: props => ({
62
+ backgroundColor: "".concat(_colors.amber[700], " !important"),
63
+ width: breakpointsMap[props.breakpoint]
64
+ }),
65
+ icon: {
66
+ fontSize: 20
67
+ },
68
+ message: {
69
+ display: 'flex',
70
+ alignItems: 'center',
71
+ padding: '8px 0',
72
+ flex: 1,
73
+ width: 0
74
+ },
75
+ action: {
76
+ display: 'flex',
77
+ alignItems: 'center',
78
+ marginLeft: 'auto',
79
+ marginRight: -8,
80
+ width: 44
81
+ }
82
+ };
83
+ });
84
+ function NotificationComponent(_ref, ref) {
85
+ let {
86
+ keyId: key,
87
+ notification = {},
88
+ viewAllUrl
89
+ } = _ref;
90
+ const classes = useStyles({
91
+ breakpoint: (0, _useWidth.default)()
92
+ });
93
+ const combinedClassname = [classes.contentRoot, classes.lessPadding, classes[notification.severity]].join(' ');
94
+ const icon = _defaultIconVariants.default[notification.severity];
95
+ const {
96
+ closeSnackbar
97
+ } = (0, _notistack.useSnackbar)();
98
+ const onClickDismiss = () => closeSnackbar(key);
99
+ const navigate = (0, _reactRouterDom.useNavigate)();
100
+ const onGoNotification = () => {
101
+ closeSnackbar(key);
102
+ navigate(viewAllUrl);
103
+ };
104
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_notistack.SnackbarContent, {
105
+ ref: ref,
106
+ className: combinedClassname,
107
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
108
+ className: classes.message,
109
+ children: [icon, /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
110
+ onClick: onGoNotification,
111
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
112
+ className: "title",
113
+ children: notification.title
114
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
115
+ className: "desc",
116
+ children: notification.description
117
+ })]
118
+ })]
119
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
120
+ className: classes.action,
121
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
122
+ "aria-label": "close",
123
+ color: "inherit",
124
+ onClick: onClickDismiss,
125
+ size: "large",
126
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Close.default, {
127
+ className: classes.icon
128
+ })
129
+ }, "close")
130
+ })]
131
+ });
132
+ }
133
+ var _default = exports.default = /*#__PURE__*/(0, _react.forwardRef)(NotificationComponent);
134
+ NotificationComponent.propTypes = {
135
+ viewAllUrl: _propTypes.default.string.isRequired,
136
+ keyId: _propTypes.default.number.isRequired,
137
+ notification: _propTypes.default.object.isRequired
138
+ };
139
+ const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n display: flex;\n flex-direction: column;\n .title {\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 1;\n -webkit-box-orient: vertical;\n font-weight: bold;\n }\n .desc {\n overflow: hidden;\n text-overflow: ellipsis;\n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n word-break: break-word;\n }\n"])));
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = NotificationsPage;
7
+ var _react = require("react");
8
+ var _styled = _interopRequireDefault(require("@emotion/styled"));
9
+ var _reactRouterDom = require("react-router-dom");
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _timeago = require("timeago.js");
12
+ var _List = _interopRequireDefault(require("@mui/material/List"));
13
+ var _ListItem = _interopRequireDefault(require("@mui/material/ListItem"));
14
+ var _ListItemText = _interopRequireDefault(require("@mui/material/ListItemText"));
15
+ var _CircularProgress = _interopRequireDefault(require("@mui/material/CircularProgress"));
16
+ var _ListItemAvatar = _interopRequireDefault(require("@mui/material/ListItemAvatar"));
17
+ var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
18
+ var _Avatar = _interopRequireDefault(require("@mui/material/Avatar"));
19
+ var _Divider = _interopRequireDefault(require("@mui/material/Divider"));
20
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
21
+ var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
22
+ var _FormControlLabel = _interopRequireDefault(require("@mui/material/FormControlLabel"));
23
+ var _ListItemSecondaryAction = _interopRequireDefault(require("@mui/material/ListItemSecondaryAction"));
24
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
25
+ var _VisibilityOff = _interopRequireDefault(require("@mui/icons-material/VisibilityOff"));
26
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
27
+ var _Pagination = _interopRequireDefault(require("@mui/lab/Pagination"));
28
+ var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
29
+ var _context = require("@arcblock/ux/lib/Locale/context");
30
+ var _tag = _interopRequireDefault(require("./tag"));
31
+ var _util = require("../util");
32
+ var _permission = _interopRequireDefault(require("../permission"));
33
+ var _node = require("../contexts/node");
34
+ var _jsxRuntime = require("react/jsx-runtime");
35
+ var _templateObject;
36
+ /* eslint-disable react/jsx-one-expression-per-line */
37
+ /* eslint-disable operator-linebreak */
38
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
40
+ function NotificationsPage(_ref) {
41
+ let {
42
+ api,
43
+ paging,
44
+ loading,
45
+ notifications,
46
+ updateNotifications,
47
+ teamDid
48
+ } = _ref;
49
+ const {
50
+ inService
51
+ } = (0, _node.useNodeContext)();
52
+ const [showRead, setShowRead] = (0, _react.useState)(true);
53
+ const [isMarkingAll, setIsMarkingAll] = (0, _react.useState)(false);
54
+ const {
55
+ t,
56
+ locale
57
+ } = (0, _react.useContext)(_context.LocaleContext);
58
+ const onUnreadNotifications = async () => {
59
+ setIsMarkingAll(true);
60
+ const ids = notifications.filter(x => x.read === false).map(x => x.id).join(',');
61
+ if (inService) {
62
+ await api.readBlockletNotifications({
63
+ input: {
64
+ id: ids,
65
+ teamDid
66
+ }
67
+ });
68
+ } else {
69
+ await api.readNotifications({
70
+ input: {
71
+ id: ids
72
+ }
73
+ });
74
+ }
75
+ updateNotifications();
76
+ setIsMarkingAll(false);
77
+ };
78
+ const markAsRead = async id => {
79
+ if (inService) {
80
+ await api.readBlockletNotifications({
81
+ input: {
82
+ id,
83
+ teamDid
84
+ }
85
+ });
86
+ } else {
87
+ await api.readNotifications({
88
+ input: {
89
+ id
90
+ }
91
+ });
92
+ }
93
+ updateNotifications();
94
+ };
95
+ const filtered = showRead ? notifications : notifications.filter(x => x.read === false);
96
+ const hasUnRead = notifications.filter(x => x.read === false).length > 0;
97
+ const itemTitle = x => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
98
+ className: "title",
99
+ children: [x.title, ' ', /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
100
+ className: "time-ago",
101
+ title: (0, _util.formatToDatetime)(x.createdAt, locale),
102
+ children: (0, _timeago.format)(new Date(x.createdAt), (0, _util.formatLocale)(locale))
103
+ })]
104
+ });
105
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, {
106
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
107
+ component: "h2",
108
+ variant: "h4",
109
+ className: "page-header",
110
+ color: "textPrimary",
111
+ children: [t('notification.title'), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Typography.default, {
112
+ component: "span",
113
+ className: "notification-actions",
114
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControlLabel.default, {
115
+ control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Checkbox.default, {
116
+ checked: showRead,
117
+ onChange: () => setShowRead(!showRead),
118
+ name: "showRead",
119
+ color: "primary"
120
+ }),
121
+ label: t('notification.showRead')
122
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_permission.default, {
123
+ permission: inService ? '' : 'mutate_notification',
124
+ role: inService ? _util.BlockletAdminRoles : [],
125
+ children: hasUnRead && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Button.default, {
126
+ disabled: isMarkingAll,
127
+ onClick: onUnreadNotifications,
128
+ className: "",
129
+ children: [isMarkingAll && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
130
+ size: 16,
131
+ style: {
132
+ marginRight: '1em'
133
+ }
134
+ }), t('notification.markAllAsRead')]
135
+ })
136
+ })]
137
+ })]
138
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Divider.default, {}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_List.default, {
139
+ className: "notification-list",
140
+ children: [loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_CircularProgress.default, {
141
+ size: [32, 20],
142
+ style: {
143
+ opacity: '0.8',
144
+ zIndex: 10000,
145
+ position: 'fixed',
146
+ top: 30,
147
+ left: '50%',
148
+ marginLeft: -16
149
+ }
150
+ }), filtered.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
151
+ component: "p",
152
+ variant: "body1",
153
+ className: "notification-tip",
154
+ children: t('notification.empty')
155
+ }), filtered.length > 0 && filtered.map(x => {
156
+ if (x.action) {
157
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ListItem.default, {
158
+ component: _reactRouterDom.Link,
159
+ to: x.action,
160
+ alignItems: "flex-start",
161
+ disabled: x.read,
162
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemAvatar.default, {
163
+ className: "list-item-avatar",
164
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
165
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, {
166
+ children: x.entityType.substr(0, 1).toUpperCase()
167
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_tag.default, {
168
+ className: "notification-tag",
169
+ status: x.severity
170
+ })]
171
+ })
172
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemText.default, {
173
+ className: "list-item-text",
174
+ classes: {
175
+ secondary: 'list-item-secondary-text'
176
+ },
177
+ primary: itemTitle(x),
178
+ secondary: x.description
179
+ }), x.read === false && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemSecondaryAction.default, {
180
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
181
+ title: t('notification.markAsRead'),
182
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
183
+ edge: "end",
184
+ "aria-label": "delete",
185
+ onClick: () => markAsRead(x.id),
186
+ size: "large",
187
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_VisibilityOff.default, {})
188
+ })
189
+ })
190
+ })]
191
+ }, x.id);
192
+ }
193
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ListItem.default, {
194
+ alignItems: "flex-start",
195
+ disabled: x.read,
196
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemAvatar.default, {
197
+ className: "list-item-avatar",
198
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
199
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, {
200
+ children: x.entityType.substr(0, 1).toUpperCase()
201
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_tag.default, {
202
+ className: "notification-tag",
203
+ status: x.severity
204
+ })]
205
+ })
206
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemText.default, {
207
+ className: "list-item-text",
208
+ classes: {
209
+ secondary: 'list-item-secondary-text'
210
+ },
211
+ primary: itemTitle(x),
212
+ secondary: x.description
213
+ }), x.read === false && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ListItemSecondaryAction.default, {
214
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
215
+ title: t('notification.markAsRead'),
216
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_IconButton.default, {
217
+ edge: "end",
218
+ "aria-label": "delete",
219
+ onClick: () => markAsRead(x.id),
220
+ size: "large",
221
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_VisibilityOff.default, {})
222
+ })
223
+ })
224
+ })]
225
+ }, x.id);
226
+ })]
227
+ }), !!filtered.length && paging.pageCount > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
228
+ mt: 2,
229
+ display: "flex",
230
+ justifyContent: "flex-end",
231
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pagination.default, {
232
+ disabled: loading,
233
+ count: paging.pageCount,
234
+ page: paging.page,
235
+ onChange: (e, value) => {
236
+ updateNotifications({
237
+ page: value
238
+ });
239
+ }
240
+ })
241
+ })]
242
+ });
243
+ }
244
+ const Div = _styled.default.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n min-height: 60vh;\n\n .page-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n\n .notification-actions {\n width: auto;\n display: flex;\n justify-content: space-between;\n }\n }\n\n .page-content {\n margin-top: 16px;\n }\n\n .list-item-avatar {\n display: flex;\n flex-direction: column;\n align-items: center;\n min-width: 80px;\n\n .notification-tag {\n margin-top: 4px;\n }\n }\n\n .MuiListItem-root:not(.Mui-disabled) {\n .MuiAvatar-root {\n background: ", ";\n }\n }\n\n .list-item-text {\n .title {\n display: flex;\n align-items: center;\n .time-ago {\n background: #bdbdbd;\n font-size: 11px;\n margin-left: 8px;\n color: #f7f8f8;\n border-radius: 3px;\n padding: 1px 4px;\n }\n }\n }\n .Mui-disabled .list-item-text .title .time-ago {\n background: #666;\n }\n\n .list-item-secondary-text {\n word-break: break-word;\n }\n"])), props => props.theme.palette.primary.light);
245
+ NotificationsPage.propTypes = {
246
+ loading: _propTypes.default.bool,
247
+ paging: _propTypes.default.objectOf(_propTypes.default.any),
248
+ api: _propTypes.default.shape({
249
+ readNotifications: _propTypes.default.func.isRequired,
250
+ readBlockletNotifications: _propTypes.default.func.isRequired
251
+ }).isRequired,
252
+ notifications: _propTypes.default.arrayOf(_propTypes.default.shape({
253
+ id: _propTypes.default.string,
254
+ read: _propTypes.default.bool,
255
+ entityType: _propTypes.default.string,
256
+ title: _propTypes.default.string,
257
+ createdAt: _propTypes.default.string,
258
+ description: _propTypes.default.string
259
+ }).isRequired).isRequired,
260
+ updateNotifications: _propTypes.default.func.isRequired,
261
+ teamDid: _propTypes.default.string
262
+ };
263
+ NotificationsPage.defaultProps = {
264
+ paging: false,
265
+ loading: false,
266
+ teamDid: ''
267
+ };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = NotificationTag;
7
+ var _propTypes = _interopRequireDefault(require("prop-types"));
8
+ var _Tag = _interopRequireDefault(require("@arcblock/ux/lib/Tag"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ const _excluded = ["status"];
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
16
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
18
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
19
+ function NotificationTag(_ref) {
20
+ let {
21
+ status
22
+ } = _ref,
23
+ rest = _objectWithoutProperties(_ref, _excluded);
24
+ const map = {
25
+ warning: 'warning',
26
+ error: 'error',
27
+ info: 'primary'
28
+ };
29
+ if (!status || status === 'info' || status === 'success') {
30
+ return null;
31
+ }
32
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tag.default, _objectSpread(_objectSpread({
33
+ type: map[status],
34
+ style: {
35
+ borderRadius: 5,
36
+ border: '1px solid #ccc'
37
+ }
38
+ }, rest), {}, {
39
+ children: status
40
+ }));
41
+ }
42
+ NotificationTag.propTypes = {
43
+ status: _propTypes.default.string.isRequired
44
+ };