@selfcommunity/react-ui 0.7.9-alpha.8 → 0.7.9-alpha.81
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/lib/cjs/components/AccountRecover/AccountRecover.js +6 -1
- package/lib/cjs/components/BottomNavigation/BottomNavigation.js +4 -3
- package/lib/cjs/components/CategoryHeader/Skeleton.js +3 -2
- package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +6 -6
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +19 -16
- package/lib/cjs/components/Composer/Attributes/Attributes.js +3 -3
- package/lib/cjs/components/Composer/Composer.js +3 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
- package/lib/cjs/components/Editor/Editor.js +2 -0
- package/lib/cjs/components/Editor/nodes/ImageNode.js +6 -0
- package/lib/cjs/components/Editor/plugins/ImagePlugin.js +4 -0
- package/lib/cjs/components/Editor/plugins/ToolbarPlugin.js +17 -3
- package/lib/cjs/components/FeedObject/Actions/Share/Share.js +18 -16
- package/lib/cjs/components/FeedObject/Contributors/Contributors.js +1 -1
- package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/cjs/components/FeedObject/FeedObject.js +27 -8
- package/lib/cjs/components/FeedObject/Poll/Poll.js +20 -20
- package/lib/cjs/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
- package/lib/cjs/components/Footer/Footer.js +1 -1
- package/lib/cjs/components/Group/Group.d.ts +9 -1
- package/lib/cjs/components/Group/Group.js +18 -6
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +0 -1
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +1 -2
- package/lib/cjs/components/GroupForm/GroupForm.js +64 -13
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -6
- package/lib/cjs/components/GroupHeader/GroupHeader.js +53 -12
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +63 -9
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +31 -9
- package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +73 -0
- package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +220 -0
- package/lib/cjs/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
- package/lib/cjs/components/GroupInvitedWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupInvitedWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupInvitedWidget/constants.js +4 -0
- package/lib/cjs/components/GroupInvitedWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupInvitedWidget/index.js +8 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +8 -3
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +25 -4
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +12 -7
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +19 -9
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +151 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
- package/lib/cjs/components/Groups/Groups.d.ts +15 -8
- package/lib/cjs/components/Groups/Groups.js +86 -32
- package/lib/cjs/components/Groups/Skeleton.d.ts +4 -0
- package/lib/cjs/components/Groups/Skeleton.js +2 -2
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +7 -0
- package/lib/cjs/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +9 -2
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +9 -1
- package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
- package/lib/cjs/components/Notification/Group/Group.js +78 -0
- package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
- package/lib/cjs/components/Notification/Group/index.js +5 -0
- package/lib/cjs/components/Notification/Notification.js +31 -1
- package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +7 -1
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +16 -8
- package/lib/cjs/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +1 -1
- package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +9 -4
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +46 -20
- package/lib/cjs/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +6 -0
- package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
- package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/cjs/components/User/User.d.ts +6 -1
- package/lib/cjs/components/User/User.js +5 -4
- package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.js +46 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +183 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/constants.js +4 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/index.js +8 -0
- package/lib/cjs/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
- package/lib/cjs/constants/PubSub.d.ts +28 -0
- package/lib/cjs/constants/PubSub.js +22 -0
- package/lib/cjs/index.d.ts +6 -3
- package/lib/cjs/index.js +13 -4
- package/lib/cjs/types/index.d.ts +2 -1
- package/lib/esm/components/AccountRecover/AccountRecover.js +6 -1
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +5 -4
- package/lib/esm/components/CategoryHeader/Skeleton.js +3 -2
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +6 -6
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +19 -16
- package/lib/esm/components/Composer/Attributes/Attributes.js +3 -3
- package/lib/esm/components/Composer/Composer.js +3 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
- package/lib/esm/components/Editor/Editor.js +2 -0
- package/lib/esm/components/Editor/nodes/ImageNode.js +6 -0
- package/lib/esm/components/Editor/plugins/ImagePlugin.js +4 -0
- package/lib/esm/components/Editor/plugins/ToolbarPlugin.js +19 -5
- package/lib/esm/components/FeedObject/Actions/Share/Share.js +19 -17
- package/lib/esm/components/FeedObject/Contributors/Contributors.js +1 -1
- package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/esm/components/FeedObject/FeedObject.js +28 -9
- package/lib/esm/components/FeedObject/Poll/Poll.js +20 -20
- package/lib/esm/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
- package/lib/esm/components/Footer/Footer.js +2 -2
- package/lib/esm/components/Group/Group.d.ts +9 -1
- package/lib/esm/components/Group/Group.js +22 -10
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +0 -1
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +1 -2
- package/lib/esm/components/GroupForm/GroupForm.js +64 -13
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -6
- package/lib/esm/components/GroupHeader/GroupHeader.js +55 -14
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +63 -9
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +31 -9
- package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +73 -0
- package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +217 -0
- package/lib/esm/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
- package/lib/esm/components/GroupInvitedWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupInvitedWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupInvitedWidget/constants.js +1 -0
- package/lib/esm/components/GroupInvitedWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupInvitedWidget/index.js +4 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +9 -4
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +26 -5
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +12 -7
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +19 -9
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +148 -0
- package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
- package/lib/esm/components/Groups/Groups.d.ts +15 -8
- package/lib/esm/components/Groups/Groups.js +91 -37
- package/lib/esm/components/Groups/Skeleton.d.ts +4 -0
- package/lib/esm/components/Groups/Skeleton.js +2 -2
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +9 -2
- package/lib/esm/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +10 -3
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -3
- package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
- package/lib/esm/components/Notification/Group/Group.js +75 -0
- package/lib/esm/components/Notification/Group/index.d.ts +3 -0
- package/lib/esm/components/Notification/Group/index.js +2 -0
- package/lib/esm/components/Notification/Notification.js +31 -1
- package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +7 -1
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +17 -9
- package/lib/esm/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +1 -1
- package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +9 -4
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +48 -22
- package/lib/esm/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +7 -1
- package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
- package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/esm/components/User/User.d.ts +6 -1
- package/lib/esm/components/User/User.js +5 -4
- package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.js +42 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +180 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/constants.js +1 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/index.js +4 -0
- package/lib/esm/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
- package/lib/esm/constants/PubSub.d.ts +28 -0
- package/lib/esm/constants/PubSub.js +19 -0
- package/lib/esm/index.d.ts +6 -3
- package/lib/esm/index.js +6 -3
- package/lib/esm/types/index.d.ts +2 -1
- package/lib/umd/311.js +2 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +9 -9
- package/lib/umd/871.js +0 -2
- /package/lib/umd/{871.js.LICENSE.txt → 311.js.LICENSE.txt} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { Button, Card, CardContent, Icon, IconButton, List, TextField, useTheme } from '@mui/material';
|
|
5
5
|
import PubSub from 'pubsub-js';
|
|
6
|
-
import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType } from '@selfcommunity/types';
|
|
6
|
+
import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType, SCPrivateMessageType } from '@selfcommunity/types';
|
|
7
7
|
import PrivateMessageSnippetsSkeleton from './Skeleton';
|
|
8
8
|
import PrivateMessageSnippetItem from '../PrivateMessageSnippetItem';
|
|
9
9
|
import classNames from 'classnames';
|
|
@@ -69,25 +69,30 @@ export default function PrivateMessageSnippets(inProps) {
|
|
|
69
69
|
props: inProps,
|
|
70
70
|
name: PREFIX
|
|
71
71
|
});
|
|
72
|
-
const { className = null,
|
|
72
|
+
const { className = null, threadObj = null, type = null, snippetActions, clearSearch } = props, rest = __rest(props, ["className", "threadObj", "type", "snippetActions", "clearSearch"]);
|
|
73
73
|
// STATE
|
|
74
74
|
const theme = useTheme();
|
|
75
75
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
76
76
|
const { data, updateSnippets } = useSCFetchPrivateMessageSnippets({ cacheStrategy: CacheStrategies.CACHE_FIRST });
|
|
77
77
|
const [search, setSearch] = useState('');
|
|
78
|
-
const isObj = typeof
|
|
78
|
+
const isObj = typeof threadObj === 'object';
|
|
79
79
|
const scUserContext = useContext(SCUserContext);
|
|
80
80
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
81
|
+
const [_type, _setType] = useState(type);
|
|
81
82
|
// INTL
|
|
82
83
|
const intl = useIntl();
|
|
83
84
|
// REFS
|
|
84
85
|
const refreshSubscription = useRef(null);
|
|
85
86
|
// CONST
|
|
86
87
|
const filteredSnippets = data.snippets.filter((el) => {
|
|
88
|
+
var _a;
|
|
87
89
|
if (search === '') {
|
|
88
90
|
return el;
|
|
89
91
|
}
|
|
90
|
-
else if (el.
|
|
92
|
+
else if (el.group) {
|
|
93
|
+
return el.group.slug.includes(search.toLowerCase());
|
|
94
|
+
}
|
|
95
|
+
else if (((_a = el === null || el === void 0 ? void 0 : el.receiver) === null || _a === void 0 ? void 0 : _a.id) === authUserId) {
|
|
91
96
|
return el.sender.username.includes(search.toLowerCase());
|
|
92
97
|
}
|
|
93
98
|
return el.receiver.username.includes(search.toLowerCase());
|
|
@@ -99,6 +104,18 @@ export default function PrivateMessageSnippets(inProps) {
|
|
|
99
104
|
}
|
|
100
105
|
return ((_b = item === null || item === void 0 ? void 0 : item.receiver) === null || _b === void 0 ? void 0 : _b.id) !== loggedUserId ? (_c = item === null || item === void 0 ? void 0 : item.receiver) === null || _c === void 0 ? void 0 : _c.id : (_d = item === null || item === void 0 ? void 0 : item.sender) === null || _d === void 0 ? void 0 : _d.id;
|
|
101
106
|
};
|
|
107
|
+
const isSelected = useMemo(() => {
|
|
108
|
+
return (message) => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
if (threadObj && _type === SCPrivateMessageType.GROUP) {
|
|
111
|
+
return ((_a = message === null || message === void 0 ? void 0 : message.group) === null || _a === void 0 ? void 0 : _a.id) === (isObj ? (_b = threadObj === null || threadObj === void 0 ? void 0 : threadObj.group) === null || _b === void 0 ? void 0 : _b.id : threadObj);
|
|
112
|
+
}
|
|
113
|
+
else if (threadObj && threadObj !== SCPrivateMessageType.NEW) {
|
|
114
|
+
return messageReceiver(message, authUserId) === (isObj ? messageReceiver(threadObj, authUserId) : threadObj);
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
}, [threadObj, authUserId, _type]);
|
|
102
119
|
//HANDLERS
|
|
103
120
|
const handleChange = (event) => {
|
|
104
121
|
setSearch(event.target.value);
|
|
@@ -114,7 +131,9 @@ export default function PrivateMessageSnippets(inProps) {
|
|
|
114
131
|
snippetActions && snippetActions.onDeleteConfirm(msg);
|
|
115
132
|
};
|
|
116
133
|
function handleOpenThread(msg) {
|
|
117
|
-
|
|
134
|
+
const threadType = msg.group !== null ? SCPrivateMessageType.GROUP : SCPrivateMessageType.USER;
|
|
135
|
+
_setType(threadType);
|
|
136
|
+
snippetActions && snippetActions.onSnippetClick(msg, threadType);
|
|
118
137
|
handleClear();
|
|
119
138
|
updateSnippetsParams(msg.id, 'seen');
|
|
120
139
|
}
|
|
@@ -219,6 +238,5 @@ export default function PrivateMessageSnippets(inProps) {
|
|
|
219
238
|
} }),
|
|
220
239
|
React.createElement(List, null, filteredSnippets.map((message) => (React.createElement(PrivateMessageSnippetItem, { message: message, key: message.id, onItemClick: () => handleOpenThread(message), secondaryAction: React.createElement(React.Fragment, null,
|
|
221
240
|
message.thread_status === SCPrivateMessageStatusType.NEW && (React.createElement(Icon, { fontSize: "small", color: "secondary" }, "fiber_manual_record")),
|
|
222
|
-
!isMobile && (React.createElement(PrivateMessageSettingsIconButton, { threadToDelete: messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true) }))), selected:
|
|
223
|
-
messageReceiver(message, authUserId) === (isObj ? messageReceiver(userObj, authUserId) : userObj) })))))))));
|
|
241
|
+
!isMobile && (React.createElement(PrivateMessageSettingsIconButton, { threadToDelete: messageReceiver(message, authUserId), onItemDeleteConfirm: () => handleDeleteConversation(messageReceiver(message, authUserId)), user: messageReceiver(message, authUserId, true) }))), selected: isSelected(message) })))))))));
|
|
224
242
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { SCPrivateMessageType } from '@selfcommunity/types';
|
|
1
2
|
import { CardProps } from '@mui/material';
|
|
2
3
|
export interface PrivateMessageThreadProps extends CardProps {
|
|
3
4
|
/**
|
|
4
5
|
* Thread object or thread id
|
|
5
6
|
* default null
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
threadObj?: any;
|
|
8
9
|
/**
|
|
9
10
|
* Overrides or extends the styles applied to the component.
|
|
10
11
|
* @default null
|
|
@@ -30,6 +31,10 @@ export interface PrivateMessageThreadProps extends CardProps {
|
|
|
30
31
|
* @default null
|
|
31
32
|
*/
|
|
32
33
|
onSingleMessageOpen?: (open: boolean) => void;
|
|
34
|
+
/**
|
|
35
|
+
* The Thread type
|
|
36
|
+
*/
|
|
37
|
+
type?: SCPrivateMessageType;
|
|
33
38
|
/**
|
|
34
39
|
* Any other properties
|
|
35
40
|
*/
|
|
@@ -3,11 +3,11 @@ import React, { useCallback, useContext, useEffect, useMemo, useRef, useState }
|
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { Endpoints, http, PrivateMessageService } from '@selfcommunity/api-services';
|
|
5
5
|
import { SCUserContext, UserUtils, useSCFetchUser } from '@selfcommunity/react-core';
|
|
6
|
-
import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType } from '@selfcommunity/types';
|
|
6
|
+
import { SCNotificationTopicType, SCNotificationTypologyType, SCPrivateMessageStatusType, SCPrivateMessageType } from '@selfcommunity/types';
|
|
7
7
|
import PrivateMessageThreadItem, { PrivateMessageThreadItemSkeleton } from '../PrivateMessageThreadItem';
|
|
8
8
|
import PubSub from 'pubsub-js';
|
|
9
9
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
10
|
-
import { Box, Card, CardContent, IconButton, List, ListSubheader, TextField, Typography } from '@mui/material';
|
|
10
|
+
import { Avatar, Box, Card, CardContent, IconButton, List, ListItemAvatar, ListSubheader, TextField, Typography } from '@mui/material';
|
|
11
11
|
import PrivateMessageEditor from '../PrivateMessageEditor';
|
|
12
12
|
import Autocomplete from '@mui/material/Autocomplete';
|
|
13
13
|
import classNames from 'classnames';
|
|
@@ -41,6 +41,8 @@ const classes = {
|
|
|
41
41
|
newMessageContent: `${PREFIX}-new-message-content`,
|
|
42
42
|
sender: `${PREFIX}-sender`,
|
|
43
43
|
receiver: `${PREFIX}-receiver`,
|
|
44
|
+
avatar: `${PREFIX}-avatar`,
|
|
45
|
+
item: `${PREFIX}-item`,
|
|
44
46
|
autocomplete: `${PREFIX}-autocomplete`,
|
|
45
47
|
autocompleteDialog: `${PREFIX}-autocomplete-dialog`,
|
|
46
48
|
editor: `${PREFIX}-editor`
|
|
@@ -93,7 +95,7 @@ export default function PrivateMessageThread(inProps) {
|
|
|
93
95
|
props: inProps,
|
|
94
96
|
name: PREFIX
|
|
95
97
|
});
|
|
96
|
-
const {
|
|
98
|
+
const { threadObj, openNewMessage = false, onNewMessageClose = null, onNewMessageSent = null, onSingleMessageOpen = null, className, type } = props, rest = __rest(props, ["threadObj", "openNewMessage", "onNewMessageClose", "onNewMessageSent", "onSingleMessageOpen", "className", "type"]);
|
|
97
99
|
// CONTEXT
|
|
98
100
|
const scUserContext = useContext(SCUserContext);
|
|
99
101
|
// STATE
|
|
@@ -104,7 +106,7 @@ export default function PrivateMessageThread(inProps) {
|
|
|
104
106
|
const [loading, setLoading] = useState(false);
|
|
105
107
|
const [isHovered, setIsHovered] = useState({});
|
|
106
108
|
const [followers, setFollowers] = useState([]);
|
|
107
|
-
const isNew =
|
|
109
|
+
const isNew = threadObj && threadObj === SCPrivateMessageStatusType.NEW;
|
|
108
110
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
109
111
|
const [singleMessageUser, setSingleMessageUser] = useState(null);
|
|
110
112
|
const [receiver, setReceiver] = useState(null);
|
|
@@ -113,7 +115,7 @@ export default function PrivateMessageThread(inProps) {
|
|
|
113
115
|
const [openDeleteMessageDialog, setOpenDeleteMessageDialog] = useState(false);
|
|
114
116
|
const [recipients, setRecipients] = useState([]);
|
|
115
117
|
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
|
|
116
|
-
const isNumber = typeof
|
|
118
|
+
const isNumber = typeof threadObj === 'number';
|
|
117
119
|
const messageReceiver = (item, loggedUserId) => {
|
|
118
120
|
var _a, _b, _c;
|
|
119
121
|
return ((_a = item === null || item === void 0 ? void 0 : item.receiver) === null || _a === void 0 ? void 0 : _a.id) !== loggedUserId ? (_b = item === null || item === void 0 ? void 0 : item.receiver) === null || _b === void 0 ? void 0 : _b.id : (_c = item === null || item === void 0 ? void 0 : item.sender) === null || _c === void 0 ? void 0 : _c.id;
|
|
@@ -126,7 +128,7 @@ export default function PrivateMessageThread(inProps) {
|
|
|
126
128
|
// HOOKS
|
|
127
129
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
128
130
|
// @ts-ignore
|
|
129
|
-
const { scUser } = useSCFetchUser({ id:
|
|
131
|
+
const { scUser } = useSCFetchUser({ id: threadObj, threadObj });
|
|
130
132
|
const messagesEndRef = useRef(null);
|
|
131
133
|
const scrollToBottom = () => {
|
|
132
134
|
var _a;
|
|
@@ -254,9 +256,9 @@ export default function PrivateMessageThread(inProps) {
|
|
|
254
256
|
* Fetches thread
|
|
255
257
|
*/
|
|
256
258
|
function fetchThread() {
|
|
257
|
-
if (
|
|
259
|
+
if (threadObj && typeof threadObj !== 'string' && type !== SCPrivateMessageType.GROUP) {
|
|
258
260
|
setLoadingMessageObjs(true);
|
|
259
|
-
const _userObjId = isNumber ?
|
|
261
|
+
const _userObjId = isNumber ? threadObj : messageReceiver(threadObj, authUserId);
|
|
260
262
|
PrivateMessageService.getAThread({ user: _userObjId, limit: 10 })
|
|
261
263
|
.then((res) => {
|
|
262
264
|
setMessageObjs(res.results);
|
|
@@ -289,6 +291,20 @@ export default function PrivateMessageThread(inProps) {
|
|
|
289
291
|
Logger.error(SCOPE_SC_UI, { error });
|
|
290
292
|
});
|
|
291
293
|
}
|
|
294
|
+
else if (type === SCPrivateMessageType.GROUP) {
|
|
295
|
+
PrivateMessageService.getAThread({ group: isNumber ? threadObj : threadObj.group.id, limit: 10 })
|
|
296
|
+
.then((res) => {
|
|
297
|
+
setMessageObjs(res.results);
|
|
298
|
+
setPrevious(res.next && updateAndDeleteURLParameters(res.next, 'before_message', res.results[0].id, 'offset'));
|
|
299
|
+
setLoadingMessageObjs(false);
|
|
300
|
+
setSingleMessageThread(false);
|
|
301
|
+
})
|
|
302
|
+
.catch((error) => {
|
|
303
|
+
setLoadingMessageObjs(false);
|
|
304
|
+
console.log(error);
|
|
305
|
+
Logger.error(SCOPE_SC_UI, { error });
|
|
306
|
+
});
|
|
307
|
+
}
|
|
292
308
|
}
|
|
293
309
|
const isNewerThan60Seconds = (creationTime) => {
|
|
294
310
|
const date = new Date(creationTime);
|
|
@@ -353,11 +369,15 @@ export default function PrivateMessageThread(inProps) {
|
|
|
353
369
|
.request({
|
|
354
370
|
url: Endpoints.SendMessage.url(),
|
|
355
371
|
method: Endpoints.SendMessage.method,
|
|
356
|
-
data: {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
372
|
+
data: Object.assign(Object.assign({}, (type === SCPrivateMessageType.GROUP
|
|
373
|
+
? { group: isNumber ? threadObj : threadObj.group.id }
|
|
374
|
+
: {
|
|
375
|
+
recipients: openNewMessage || isNew || singleMessageThread
|
|
376
|
+
? ids
|
|
377
|
+
: [isNumber && threadObj ? threadObj : messageReceiver(threadObj, authUserId)]
|
|
378
|
+
})), {
|
|
379
|
+
// recipients: openNewMessage || isNew || singleMessageThread ? ids : [isNumber && threadObj ? threadObj : messageReceiver(threadObj, authUserId)],
|
|
380
|
+
message: message, file_uuid: file && !message ? file : null })
|
|
361
381
|
})
|
|
362
382
|
.then((res) => {
|
|
363
383
|
const isOne = res.data.length <= 1;
|
|
@@ -403,13 +423,13 @@ export default function PrivateMessageThread(inProps) {
|
|
|
403
423
|
if (!authUserId) {
|
|
404
424
|
return;
|
|
405
425
|
}
|
|
406
|
-
if (
|
|
426
|
+
if (threadObj) {
|
|
407
427
|
fetchThread();
|
|
408
428
|
}
|
|
409
429
|
else {
|
|
410
430
|
reset();
|
|
411
431
|
}
|
|
412
|
-
}, [
|
|
432
|
+
}, [threadObj, authUserId, scUser]);
|
|
413
433
|
/**
|
|
414
434
|
* Notification subscriber
|
|
415
435
|
*/
|
|
@@ -424,7 +444,7 @@ export default function PrivateMessageThread(inProps) {
|
|
|
424
444
|
if (index !== -1) {
|
|
425
445
|
setMessageObjs((prev) => [...prev, res.notification_obj.message]);
|
|
426
446
|
}
|
|
427
|
-
if (isNumber ?
|
|
447
|
+
if (isNumber ? threadObj === res.thread_id : threadObj.id === res.thread_id) {
|
|
428
448
|
scrollToBottom();
|
|
429
449
|
}
|
|
430
450
|
};
|
|
@@ -451,11 +471,17 @@ export default function PrivateMessageThread(inProps) {
|
|
|
451
471
|
React.createElement("ul", null,
|
|
452
472
|
React.createElement(ListSubheader, null,
|
|
453
473
|
React.createElement(Typography, { align: "center", className: classes.subHeader }, key)),
|
|
454
|
-
formattedMessages[key].map((msg) =>
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
474
|
+
formattedMessages[key].map((msg) => {
|
|
475
|
+
var _a;
|
|
476
|
+
return (React.createElement(Box, { className: classes.item, key: msg.id },
|
|
477
|
+
msg.group && ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) !== msg.sender.username && (React.createElement(ListItemAvatar, null,
|
|
478
|
+
React.createElement(Avatar, { alt: msg.sender.username, src: msg.sender.avatar, className: classes.avatar }))),
|
|
479
|
+
React.createElement(PrivateMessageThreadItem, { className: authUserId === msg.sender.id ? classes.sender : classes.receiver, message: msg, key: msg.id, mouseEvents: {
|
|
480
|
+
onMouseEnter: () => handleMouseEnter(msg.id),
|
|
481
|
+
onMouseLeave: () => handleMouseLeave(msg.id)
|
|
482
|
+
}, isHovering: isHovered[msg.id], showMenuIcon: authUserId === msg.sender.id, onMenuIconClick: () => handleOpenDeleteMessageDialog(msg) })));
|
|
483
|
+
}))))))),
|
|
484
|
+
React.createElement(PrivateMessageEditor, { className: classes.editor, send: handleSend, autoHide: type !== SCPrivateMessageType.GROUP && !(scUser === null || scUser === void 0 ? void 0 : scUser.can_send_pm_to), autoHideDeletion: type === SCPrivateMessageType.USER && ((receiver === null || receiver === void 0 ? void 0 : receiver.deleted) || (scUser === null || scUser === void 0 ? void 0 : scUser.deleted)), onThreadChangeId: isNumber ? threadObj : type === SCPrivateMessageType.USER ? threadObj.receiver.id : threadObj.group.id, error: error, onErrorRemove: () => setError(false) }),
|
|
459
485
|
openDeleteMessageDialog && (React.createElement(ConfirmDialog, { open: openDeleteMessageDialog, title: React.createElement(FormattedMessage, { id: "ui.privateMessage.component.delete.message.dialog.msg", defaultMessage: "ui.privateMessage.component.delete.message.dialog.msg" }), btnConfirm: React.createElement(FormattedMessage, { id: "ui.privateMessage.component.delete.message.dialog.confirm", defaultMessage: "ui.privateMessage.component.delete.message.dialog.confirm" }), onConfirm: handleDeleteMessage, onClose: handleCloseDeleteMessageDialog }))));
|
|
460
486
|
}
|
|
461
487
|
/**
|
|
@@ -483,5 +509,5 @@ export default function PrivateMessageThread(inProps) {
|
|
|
483
509
|
/**
|
|
484
510
|
* Renders the component
|
|
485
511
|
*/
|
|
486
|
-
return (React.createElement(Root, Object.assign({}, rest, { className: classNames(classes.root, className) }),
|
|
512
|
+
return (React.createElement(Root, Object.assign({}, rest, { className: classNames(classes.root, className) }), threadObj !== null && !isNew && !singleMessageThread ? renderThread() : renderNewOrNoMessageBox()));
|
|
487
513
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter, __rest } from "tslib";
|
|
2
|
-
import React, { useState } from 'react';
|
|
2
|
+
import React, { useContext, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import { ListItem, Typography, IconButton, Box, useTheme, Button } from '@mui/material';
|
|
5
5
|
import PrivateMessageThreadItemSkeleton from './Skeleton';
|
|
@@ -8,6 +8,7 @@ import { SCMessageFileType, SCPrivateMessageStatusType } from '@selfcommunity/ty
|
|
|
8
8
|
import Icon from '@mui/material/Icon';
|
|
9
9
|
import classNames from 'classnames';
|
|
10
10
|
import { useThemeProps } from '@mui/system';
|
|
11
|
+
import { SCUserContext } from '@selfcommunity/react-core';
|
|
11
12
|
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
12
13
|
import PrivateMessageSettingsIconButton from '../PrivateMessageSettingsIconButton';
|
|
13
14
|
import { bytesToSize } from '../../utils/sizeCoverter';
|
|
@@ -19,6 +20,7 @@ import { PREFIX } from './constants';
|
|
|
19
20
|
import { isSupportedVideoFormat } from '../../utils/thumbnailCoverter';
|
|
20
21
|
const classes = {
|
|
21
22
|
root: `${PREFIX}-root`,
|
|
23
|
+
username: `${PREFIX}-username`,
|
|
22
24
|
text: `${PREFIX}-text`,
|
|
23
25
|
img: `${PREFIX}-img`,
|
|
24
26
|
document: `${PREFIX}-document`,
|
|
@@ -70,6 +72,7 @@ const Root = styled(ListItem, {
|
|
|
70
72
|
* @param inProps
|
|
71
73
|
*/
|
|
72
74
|
export default function PrivateMessageThreadItem(inProps) {
|
|
75
|
+
var _a;
|
|
73
76
|
// PROPS
|
|
74
77
|
const props = useThemeProps({
|
|
75
78
|
props: inProps,
|
|
@@ -78,6 +81,8 @@ export default function PrivateMessageThreadItem(inProps) {
|
|
|
78
81
|
const { message = null, className = null, mouseEvents = {}, isHovering = null, showMenuIcon = false, onMenuIconClick = null } = props, rest = __rest(props, ["message", "className", "mouseEvents", "isHovering", "showMenuIcon", "onMenuIconClick"]);
|
|
79
82
|
// INTL
|
|
80
83
|
const intl = useIntl();
|
|
84
|
+
// CONTEXT
|
|
85
|
+
const scUserContext = useContext(SCUserContext);
|
|
81
86
|
// STATE
|
|
82
87
|
const theme = useTheme();
|
|
83
88
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
@@ -165,6 +170,7 @@ export default function PrivateMessageThreadItem(inProps) {
|
|
|
165
170
|
return (React.createElement(Root, Object.assign({ className: classNames(classes.root, className) }, getMouseEvents(mouseEvents.onMouseEnter, mouseEvents.onMouseLeave), rest, { secondaryAction: (isHovering || isMobile) &&
|
|
166
171
|
showMenuIcon &&
|
|
167
172
|
message.status !== SCPrivateMessageStatusType.HIDDEN && React.createElement(PrivateMessageSettingsIconButton, { onMenuItemDeleteClick: handleMenuItemClick }) }),
|
|
173
|
+
message.group && ((_a = scUserContext === null || scUserContext === void 0 ? void 0 : scUserContext.user) === null || _a === void 0 ? void 0 : _a.username) !== message.sender.username && (React.createElement(Typography, { color: "secondary", variant: "h4", className: classes.username }, message.sender.username)),
|
|
168
174
|
React.createElement(React.Fragment, null,
|
|
169
175
|
hasFile && message.status !== SCPrivateMessageStatusType.HIDDEN ? (renderMessageFile(message)) : (React.createElement(Box, { className: classes.text },
|
|
170
176
|
React.createElement(Typography, { component: "span", dangerouslySetInnerHTML: { __html: message.message } }))),
|
|
@@ -73,6 +73,25 @@ export default function SearchAutocomplete(inProps) {
|
|
|
73
73
|
setOptions([]);
|
|
74
74
|
onClear && onClear();
|
|
75
75
|
};
|
|
76
|
+
const getOptionData = (option) => {
|
|
77
|
+
let data = {};
|
|
78
|
+
if (option.type === SuggestionType.USER) {
|
|
79
|
+
data.name = option[SuggestionType.USER]['username'];
|
|
80
|
+
data.image = option[SuggestionType.USER]['avatar'];
|
|
81
|
+
data.variant = 'circular';
|
|
82
|
+
}
|
|
83
|
+
else if (option.type === SuggestionType.CATEGORY) {
|
|
84
|
+
data.name = option[SuggestionType.CATEGORY]['name'];
|
|
85
|
+
data.image = option[SuggestionType.CATEGORY]['image_medium'];
|
|
86
|
+
data.variant = 'square';
|
|
87
|
+
}
|
|
88
|
+
else if (option.type === SuggestionType.GROUP) {
|
|
89
|
+
data.name = option[SuggestionType.GROUP]['name'];
|
|
90
|
+
data.image = option[SuggestionType.GROUP]['image_big'];
|
|
91
|
+
data.variant = 'circular';
|
|
92
|
+
}
|
|
93
|
+
return data;
|
|
94
|
+
};
|
|
76
95
|
function fetchResults() {
|
|
77
96
|
setIsLoading(true);
|
|
78
97
|
SuggestionService.getSearchSuggestion(value)
|
|
@@ -96,11 +115,9 @@ export default function SearchAutocomplete(inProps) {
|
|
|
96
115
|
return option;
|
|
97
116
|
}
|
|
98
117
|
return (_a = option[option.type]['username']) !== null && _a !== void 0 ? _a : option[option.type]['name'];
|
|
99
|
-
}, renderOption: (props, option) => (React.createElement(Box, Object.assign({ component: "li" }, props),
|
|
100
|
-
React.createElement(Avatar, { alt: option
|
|
101
|
-
React.createElement(Typography, { ml: 1 }, option
|
|
102
|
-
React.createElement(Avatar, { alt: option[SuggestionType.CATEGORY]['name'], src: option[SuggestionType.CATEGORY]['image_medium'], variant: "square" }),
|
|
103
|
-
React.createElement(Typography, { ml: 1 }, option[SuggestionType.CATEGORY]['name']))))), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { placeholder: `${intl.formatMessage(messages.placeholder, {
|
|
118
|
+
}, renderOption: (props, option) => (React.createElement(Box, Object.assign({ component: "li" }, props),
|
|
119
|
+
React.createElement(Avatar, { alt: getOptionData(option).name, src: getOptionData(option).image, variant: getOptionData(option).variant }),
|
|
120
|
+
React.createElement(Typography, { ml: 1 }, getOptionData(option).name))), renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { placeholder: `${intl.formatMessage(messages.placeholder, {
|
|
104
121
|
community: scPreferences.preferences[SCPreferences.TEXT_APPLICATION_NAME].value
|
|
105
122
|
})}`, InputProps: Object.assign(Object.assign({}, params.InputProps), { autoFocus, name: 'search-autocomplete', className: classes.input, startAdornment: React.createElement(Icon, { className: classes.icon }, "search"), endAdornment: (React.createElement(Fade, { in: value.length > 0 || Boolean(onClear), appear: false },
|
|
106
123
|
React.createElement(IconButton, { className: classes.clear, onClick: handleClear, size: "small" },
|
|
@@ -31,6 +31,7 @@ import { useThemeProps } from '@mui/system';
|
|
|
31
31
|
import ContributionNotification from '../Notification/Contribution';
|
|
32
32
|
import NotificationItem from '../../shared/NotificationItem';
|
|
33
33
|
import { PREFIX } from './constants';
|
|
34
|
+
import GroupNotification from '../Notification/Group';
|
|
34
35
|
const classes = {
|
|
35
36
|
root: `${PREFIX}-root`,
|
|
36
37
|
notificationsWrap: `${PREFIX}-notifications-wrap`,
|
|
@@ -252,6 +253,12 @@ export default function SnippetNotifications(inProps) {
|
|
|
252
253
|
else if (type === SCNotificationTypologyType.CONTRIBUTION) {
|
|
253
254
|
content = React.createElement(ContributionNotification, { notificationObject: n, key: i, template: SCNotificationObjectTemplateType.SNIPPET });
|
|
254
255
|
}
|
|
256
|
+
else if (n.type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
|
|
257
|
+
n.type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
|
|
258
|
+
n.type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
|
|
259
|
+
n.type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
|
|
260
|
+
return React.createElement(GroupNotification, { notificationObject: n, key: i, template: SCNotificationObjectTemplateType.SNIPPET });
|
|
261
|
+
}
|
|
255
262
|
if (type && handleNotification) {
|
|
256
263
|
/** Override content */
|
|
257
264
|
content = handleNotification(type, n, content);
|
|
@@ -21,6 +21,7 @@ import Message from '../BroadcastMessages/Message';
|
|
|
21
21
|
import { useThemeProps } from '@mui/system';
|
|
22
22
|
import ContributionNotification from '../Notification/Contribution';
|
|
23
23
|
import { PREFIX } from './constants';
|
|
24
|
+
import GroupNotification from '../Notification/Group';
|
|
24
25
|
const Root = styled(Box, {
|
|
25
26
|
name: PREFIX,
|
|
26
27
|
slot: 'Root'
|
|
@@ -108,6 +109,12 @@ export default function UserToastNotifications(inProps) {
|
|
|
108
109
|
else if (type === SCNotificationTypologyType.CONTRIBUTION) {
|
|
109
110
|
content = React.createElement(ContributionNotification, { notificationObject: n.notification_obj, template: SCNotificationObjectTemplateType.TOAST });
|
|
110
111
|
}
|
|
112
|
+
else if (type === SCNotificationTypologyType.USER_ADDED_TO_GROUP ||
|
|
113
|
+
type === SCNotificationTypologyType.USER_INVITED_TO_JOIN_GROUP ||
|
|
114
|
+
type === SCNotificationTypologyType.USER_ACCEPTED_TO_JOIN_GROUP ||
|
|
115
|
+
type === SCNotificationTypologyType.USER_REQUESTED_TO_JOIN_GROUP) {
|
|
116
|
+
content = React.createElement(GroupNotification, { notificationObject: n.notification_obj, template: SCNotificationObjectTemplateType.TOAST });
|
|
117
|
+
}
|
|
111
118
|
}
|
|
112
119
|
if (n.activity_type && n.activity_type === SCNotificationTypologyType.NOTIFICATION_BANNER) {
|
|
113
120
|
/** Notification of type: 'notification_banner' */
|
|
@@ -34,6 +34,11 @@ export interface UserProps extends WidgetProps {
|
|
|
34
34
|
* Badge content to show as user avatar badge if show reaction is true.
|
|
35
35
|
*/
|
|
36
36
|
badgeContent?: any;
|
|
37
|
+
/**
|
|
38
|
+
* If true, shows a custom label next to the user username
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
isGroupAdmin?: boolean;
|
|
37
42
|
/**
|
|
38
43
|
* Prop to add actions
|
|
39
44
|
* @default null
|
|
@@ -43,7 +48,7 @@ export interface UserProps extends WidgetProps {
|
|
|
43
48
|
* Props to spread to the button
|
|
44
49
|
* @default {}
|
|
45
50
|
*/
|
|
46
|
-
buttonProps?: ButtonBaseProps;
|
|
51
|
+
buttonProps?: ButtonBaseProps | null;
|
|
47
52
|
/**
|
|
48
53
|
* Any other properties
|
|
49
54
|
*/
|
|
@@ -21,7 +21,8 @@ const messages = defineMessages({
|
|
|
21
21
|
const classes = {
|
|
22
22
|
root: `${PREFIX}-root`,
|
|
23
23
|
avatar: `${PREFIX}-avatar`,
|
|
24
|
-
staffBadgeLabel: `${PREFIX}-staff-badge-label
|
|
24
|
+
staffBadgeLabel: `${PREFIX}-staff-badge-label`,
|
|
25
|
+
groupAdminBadgeLabel: `${PREFIX}-group-admin-badge-label`
|
|
25
26
|
};
|
|
26
27
|
const Root = styled(BaseItemButton, {
|
|
27
28
|
name: PREFIX,
|
|
@@ -64,7 +65,7 @@ export default function User(inProps) {
|
|
|
64
65
|
props: inProps,
|
|
65
66
|
name: PREFIX
|
|
66
67
|
});
|
|
67
|
-
const { userId = null, user = null, handleIgnoreAction, className = null, followConnectUserButtonProps = {}, showFollowers = false, elevation, badgeContent = null, actions = null, buttonProps =
|
|
68
|
+
const { userId = null, user = null, handleIgnoreAction, className = null, followConnectUserButtonProps = {}, showFollowers = false, elevation, badgeContent = null, actions = null, isGroupAdmin = false, buttonProps = null } = props, rest = __rest(props, ["userId", "user", "handleIgnoreAction", "className", "followConnectUserButtonProps", "showFollowers", "elevation", "badgeContent", "actions", "isGroupAdmin", "buttonProps"]);
|
|
68
69
|
// STATE
|
|
69
70
|
const { scUser, setSCUser } = useSCFetchUser({ id: userId, user });
|
|
70
71
|
// CONTEXT
|
|
@@ -104,8 +105,8 @@ export default function User(inProps) {
|
|
|
104
105
|
? { onClick: () => setOpenAlert(true) }
|
|
105
106
|
: { component: Link, to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scUser) }), image: badgeContent ? (React.createElement(Badge, { overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: badgeContent },
|
|
106
107
|
React.createElement(Avatar, { alt: scUser.username, src: scUser.avatar, className: classes.avatar }))) : (React.createElement(UserAvatar, { hide: !hasBadge },
|
|
107
|
-
React.createElement(Avatar, { alt: scUser.username, src: scUser.avatar, className: classes.avatar }))), primary: hasBadge && preferences ? (React.createElement(React.Fragment, null,
|
|
108
|
+
React.createElement(Avatar, { alt: scUser.username, src: scUser.avatar, className: classes.avatar }))), primary: (hasBadge && preferences) || isGroupAdmin ? (React.createElement(React.Fragment, null,
|
|
108
109
|
scUser.username,
|
|
109
|
-
React.createElement(Chip, { component: "span", className: classes.staffBadgeLabel, size: "small", label: preferences[SCPreferences.STAFF_STAFF_BADGE_LABEL] }))) : (scUser.username), secondary: showFollowers ? `${intl.formatMessage(messages.userFollowers, { total: scUser.followers_counter })}` : scUser.description, actions: actions !== null && actions !== void 0 ? actions : renderAuthenticatedActions() })),
|
|
110
|
+
React.createElement(Chip, { component: "span", className: isGroupAdmin ? classes.groupAdminBadgeLabel : classes.staffBadgeLabel, size: "small", label: isGroupAdmin ? (React.createElement(FormattedMessage, { defaultMessage: "ui.user.group.admin", id: "ui.user.group.admin" })) : (preferences[SCPreferences.STAFF_STAFF_BADGE_LABEL]) }))) : (scUser.username), secondary: showFollowers ? `${intl.formatMessage(messages.userFollowers, { total: scUser.followers_counter })}` : scUser.description, actions: actions !== null && actions !== void 0 ? actions : renderAuthenticatedActions() })),
|
|
110
111
|
openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
111
112
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* > API documentation for the Community-JS User Profile Categories Followed Widget Skeleton component. Learn about the available props and the CSS API.
|
|
3
|
+
|
|
4
|
+
#### Import
|
|
5
|
+
|
|
6
|
+
```jsx
|
|
7
|
+
import {UserSubscribedGroupsWidgetSkeleton} from '@selfcommunity/react-ui';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
#### Component Name
|
|
11
|
+
|
|
12
|
+
The name `SCUserCategoriesFollowedWidget-skeleton-root` can be used when providing style overrides in the theme.
|
|
13
|
+
|
|
14
|
+
#### CSS
|
|
15
|
+
|
|
16
|
+
|Rule Name|Global class|Description|
|
|
17
|
+
|---|---|---|
|
|
18
|
+
|root|.SCUserSubscribedGroupsWidget-skeleton-root|Styles applied to the root element.|
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export default function UserSubscribedGroupsWidgetSkeleton(props: any): JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Widget from '../Widget';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
|
+
import { CardContent, ListItem } from '@mui/material';
|
|
5
|
+
import List from '@mui/material/List';
|
|
6
|
+
import GroupSkeleton from '../Group/Skeleton';
|
|
7
|
+
const PREFIX = 'SCUserSubscribedGroupsWidgetSkeleton';
|
|
8
|
+
const classes = {
|
|
9
|
+
root: `${PREFIX}-skeleton-root`,
|
|
10
|
+
list: `${PREFIX}-list`
|
|
11
|
+
};
|
|
12
|
+
const Root = styled(Widget, {
|
|
13
|
+
name: PREFIX,
|
|
14
|
+
slot: 'SkeletonRoot'
|
|
15
|
+
})(() => ({}));
|
|
16
|
+
/**
|
|
17
|
+
* > API documentation for the Community-JS User Profile Categories Followed Widget Skeleton component. Learn about the available props and the CSS API.
|
|
18
|
+
|
|
19
|
+
#### Import
|
|
20
|
+
|
|
21
|
+
```jsx
|
|
22
|
+
import {UserSubscribedGroupsWidgetSkeleton} from '@selfcommunity/react-ui';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
#### Component Name
|
|
26
|
+
|
|
27
|
+
The name `SCUserCategoriesFollowedWidget-skeleton-root` can be used when providing style overrides in the theme.
|
|
28
|
+
|
|
29
|
+
#### CSS
|
|
30
|
+
|
|
31
|
+
|Rule Name|Global class|Description|
|
|
32
|
+
|---|---|---|
|
|
33
|
+
|root|.SCUserSubscribedGroupsWidget-skeleton-root|Styles applied to the root element.|
|
|
34
|
+
*
|
|
35
|
+
*/
|
|
36
|
+
export default function UserSubscribedGroupsWidgetSkeleton(props) {
|
|
37
|
+
return (React.createElement(Root, Object.assign({ className: classes.root }, props),
|
|
38
|
+
React.createElement(CardContent, null,
|
|
39
|
+
React.createElement(List, { className: classes.list }, [...Array(3)].map((category, index) => (React.createElement(ListItem, { key: index },
|
|
40
|
+
React.createElement(GroupSkeleton, { elevation: 0 })))))),
|
|
41
|
+
");"));
|
|
42
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
2
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
3
|
+
import { WidgetProps } from '../Widget';
|
|
4
|
+
import { VirtualScrollerItemProps } from '../../types/virtualScroller';
|
|
5
|
+
import { GroupProps } from '../Group';
|
|
6
|
+
export interface UserSubscribedGroupsWidgetProps extends VirtualScrollerItemProps, WidgetProps {
|
|
7
|
+
/**
|
|
8
|
+
* The user id
|
|
9
|
+
* @default null
|
|
10
|
+
*/
|
|
11
|
+
userId: number;
|
|
12
|
+
/**
|
|
13
|
+
* Hides this component
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
autoHide?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Limit the number of groups to show
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
limit?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Props to spread to single group object
|
|
24
|
+
* @default empty object
|
|
25
|
+
*/
|
|
26
|
+
GroupProps?: GroupProps;
|
|
27
|
+
/**
|
|
28
|
+
* Caching strategies
|
|
29
|
+
* @default CacheStrategies.CACHE_FIRST
|
|
30
|
+
*/
|
|
31
|
+
cacheStrategy?: CacheStrategies;
|
|
32
|
+
/**
|
|
33
|
+
* Props to spread to subscribed groups dialog
|
|
34
|
+
* @default {}
|
|
35
|
+
*/
|
|
36
|
+
DialogProps?: BaseDialogProps;
|
|
37
|
+
/**
|
|
38
|
+
* Other props
|
|
39
|
+
*/
|
|
40
|
+
[p: string]: any;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* > API documentation for the Community-JS User Profile Groups Subscribed Widget component. Learn about the available props and the CSS API.
|
|
44
|
+
*
|
|
45
|
+
*
|
|
46
|
+
* This component renders the list of the groups that the given user follows.
|
|
47
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/UserSubscribedGroups)
|
|
48
|
+
|
|
49
|
+
#### Import
|
|
50
|
+
```jsx
|
|
51
|
+
import {UserSubscribedGroupsWidget} from '@selfcommunity/react-ui';
|
|
52
|
+
```
|
|
53
|
+
#### Component Name
|
|
54
|
+
The name `SCUserSubscribedGroupsWidget` can be used when providing style overrides in the theme.
|
|
55
|
+
|
|
56
|
+
#### CSS
|
|
57
|
+
|
|
58
|
+
|Rule Name|Global class|Description|
|
|
59
|
+
|---|---|---|
|
|
60
|
+
|root|.SCUserSubscribedGroupsWidget-root|Styles applied to the root element.|
|
|
61
|
+
|title|.SCUserSubscribedGroupsWidget-title|Styles applied to the title element.|
|
|
62
|
+
|noResults|.SCUserSubscribedGroupsWidget-no-results|Styles applied to no results section.|
|
|
63
|
+
|showMore|.SCUserSubscribedGroupsWidget-show-more|Styles applied to show more button element.|
|
|
64
|
+
|dialogRoot|.SCUserSubscribedGroupsWidget-dialog-root|Styles applied to the root dialog element.|
|
|
65
|
+
|endMessage|.SCUserSubscribedGroupsWidget-end-message|Styles applied to the end message element.|
|
|
66
|
+
* @param inProps
|
|
67
|
+
*/
|
|
68
|
+
export default function UserSubscribedGroupsWidget(inProps: UserSubscribedGroupsWidgetProps): JSX.Element;
|