@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,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
@@ -10,7 +10,10 @@ const system_1 = require("@mui/system");
|
|
|
10
10
|
const constants_1 = require("./constants");
|
|
11
11
|
const react_intl_1 = require("react-intl");
|
|
12
12
|
const types_1 = require("@selfcommunity/types");
|
|
13
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
13
14
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
15
|
+
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
16
|
+
const PubSub_1 = require("../../constants/PubSub");
|
|
14
17
|
const classes = {
|
|
15
18
|
root: `${constants_1.PREFIX}-root`,
|
|
16
19
|
title: `${constants_1.PREFIX}-title`,
|
|
@@ -19,6 +22,7 @@ const classes = {
|
|
|
19
22
|
privacyTitle: `${constants_1.PREFIX}-privacy-title`,
|
|
20
23
|
visibility: `${constants_1.PREFIX}-visibility`,
|
|
21
24
|
visibilityTitle: `${constants_1.PREFIX}-visibility-title`,
|
|
25
|
+
admin: `${constants_1.PREFIX}-admin`,
|
|
22
26
|
date: `${constants_1.PREFIX}-date`
|
|
23
27
|
};
|
|
24
28
|
const Root = (0, styles_1.styled)(Widget_1.default, {
|
|
@@ -61,9 +65,36 @@ function GroupInfoWidget(inProps) {
|
|
|
61
65
|
});
|
|
62
66
|
const { className, group, groupId, onHeightChange, onStateChange } = props, rest = tslib_1.__rest(props, ["className", "group", "groupId", "onHeightChange", "onStateChange"]);
|
|
63
67
|
// HOOKS
|
|
64
|
-
const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
68
|
+
const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
65
69
|
// INTL
|
|
66
70
|
const intl = (0, react_intl_1.useIntl)();
|
|
71
|
+
// REFS
|
|
72
|
+
const updatesSubscription = (0, react_1.useRef)(null);
|
|
73
|
+
/**
|
|
74
|
+
* Subscriber for pubsub callback
|
|
75
|
+
*/
|
|
76
|
+
const onChangeGroupHandler = (0, react_1.useCallback)((_msg, data) => {
|
|
77
|
+
if (data && scGroup.id === data.id) {
|
|
78
|
+
setSCGroup(data);
|
|
79
|
+
}
|
|
80
|
+
}, [scGroup, setSCGroup]);
|
|
81
|
+
/**
|
|
82
|
+
* On mount, subscribe to receive groups updates (only edit)
|
|
83
|
+
*/
|
|
84
|
+
(0, react_1.useEffect)(() => {
|
|
85
|
+
if (scGroup) {
|
|
86
|
+
updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.EDIT}`, onChangeGroupHandler);
|
|
87
|
+
}
|
|
88
|
+
return () => {
|
|
89
|
+
updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
|
|
90
|
+
};
|
|
91
|
+
}, [scGroup]);
|
|
92
|
+
/**
|
|
93
|
+
* Loading group
|
|
94
|
+
*/
|
|
95
|
+
if (!scGroup) {
|
|
96
|
+
return react_1.default.createElement(Skeleton_1.default, null);
|
|
97
|
+
}
|
|
67
98
|
/**
|
|
68
99
|
* Renders root object
|
|
69
100
|
*/
|
|
@@ -75,26 +106,49 @@ function GroupInfoWidget(inProps) {
|
|
|
75
106
|
react_1.default.createElement(material_1.Typography, { component: "div", className: classes.privacy }, scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
76
107
|
react_1.default.createElement(material_1.Typography, { className: classes.privacyTitle },
|
|
77
108
|
react_1.default.createElement(material_1.Icon, null, "public"),
|
|
78
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.
|
|
109
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.privacy.public", defaultMessage: "ui.groupInfoWidget.privacy.public" })),
|
|
79
110
|
react_1.default.createElement(material_1.Typography, { variant: "body2" },
|
|
80
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.
|
|
111
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.privacy.public.info", defaultMessage: "ui.groupInfoWidget.privacy.public.info", values: {
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
b: (chunks) => react_1.default.createElement("strong", null, chunks)
|
|
115
|
+
} })))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
81
116
|
react_1.default.createElement(material_1.Typography, { className: classes.privacyTitle },
|
|
82
117
|
react_1.default.createElement(material_1.Icon, null, "private"),
|
|
83
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.
|
|
118
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.privacy.private", defaultMessage: "ui.groupInfoWidget.privacy.private" })),
|
|
84
119
|
react_1.default.createElement(material_1.Typography, { variant: "body2" },
|
|
85
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.
|
|
120
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.privacy.private.info", defaultMessage: "ui.groupInfoWidget.private.public.info", values: {
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
b: (chunks) => react_1.default.createElement("strong", null, chunks)
|
|
124
|
+
} }))))),
|
|
86
125
|
scGroup.privacy === types_1.SCGroupPrivacyType.PRIVATE && (react_1.default.createElement(material_1.Typography, { component: "div", className: classes.visibility }, scGroup.visible ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
87
126
|
react_1.default.createElement(material_1.Typography, { className: classes.visibilityTitle },
|
|
88
127
|
react_1.default.createElement(material_1.Icon, null, "visibility"),
|
|
89
128
|
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" })),
|
|
90
129
|
react_1.default.createElement(material_1.Typography, { variant: "body2" },
|
|
91
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: {
|
|
130
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: {
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
b: (chunks) => react_1.default.createElement("strong", null, chunks)
|
|
134
|
+
} })))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
92
135
|
react_1.default.createElement(material_1.Typography, { className: classes.visibilityTitle },
|
|
93
136
|
react_1.default.createElement(material_1.Icon, null, "visibility_off"),
|
|
94
137
|
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
|
|
95
138
|
react_1.default.createElement(material_1.Typography, { variant: "body2" },
|
|
96
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: {
|
|
139
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: {
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
141
|
+
// @ts-ignore
|
|
142
|
+
b: (chunks) => react_1.default.createElement("strong", null, chunks)
|
|
143
|
+
} })))))),
|
|
97
144
|
react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.date },
|
|
98
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } }))
|
|
145
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })),
|
|
146
|
+
react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.admin },
|
|
147
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInfoWidget.admin", defaultMessage: "ui.groupInfoWidget.admin", values: {
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
b: (chunks) => react_1.default.createElement("strong", null, chunks),
|
|
151
|
+
admin: scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by.username
|
|
152
|
+
} })))));
|
|
99
153
|
}
|
|
100
154
|
exports.default = GroupInfoWidget;
|
|
@@ -15,6 +15,8 @@ const Autocomplete_1 = tslib_1.__importDefault(require("@mui/material/Autocomple
|
|
|
15
15
|
const User_1 = tslib_1.__importDefault(require("../User"));
|
|
16
16
|
const Errors_1 = require("../../constants/Errors");
|
|
17
17
|
const utils_1 = require("@selfcommunity/utils");
|
|
18
|
+
const PubSub_1 = require("../../constants/PubSub");
|
|
19
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
18
20
|
const messages = (0, react_intl_1.defineMessages)({
|
|
19
21
|
placeholder: {
|
|
20
22
|
id: 'ui.groupInviteButton.searchBar.placeholder',
|
|
@@ -90,12 +92,22 @@ function GroupInviteButton(inProps) {
|
|
|
90
92
|
const [list, setList] = (0, react_1.useState)([]);
|
|
91
93
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
92
94
|
const [invited, setInvited] = (0, react_1.useState)([]);
|
|
95
|
+
/**
|
|
96
|
+
* Notify UI when a member is invited to a group
|
|
97
|
+
* @param group
|
|
98
|
+
* @param usersInvited
|
|
99
|
+
*/
|
|
100
|
+
function notifyChanges(group, usersInvited) {
|
|
101
|
+
if (group && usersInvited) {
|
|
102
|
+
pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.INVITE_MEMBER}`, usersInvited);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
93
105
|
function convertToInvitedUsersObject(data) {
|
|
94
|
-
const
|
|
106
|
+
const invite_users = {};
|
|
95
107
|
data.forEach((user, index) => {
|
|
96
|
-
|
|
108
|
+
invite_users[`invite_users[${index}]`] = user.id;
|
|
97
109
|
});
|
|
98
|
-
return
|
|
110
|
+
return invite_users;
|
|
99
111
|
}
|
|
100
112
|
/**
|
|
101
113
|
* Memoized users invited ids
|
|
@@ -110,7 +122,7 @@ function GroupInviteButton(inProps) {
|
|
|
110
122
|
}, [invited]);
|
|
111
123
|
// HOOKS
|
|
112
124
|
const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
113
|
-
const
|
|
125
|
+
const isGroupAdmin = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
114
126
|
// INTL
|
|
115
127
|
const intl = (0, react_intl_1.useIntl)();
|
|
116
128
|
function fetchResults() {
|
|
@@ -155,11 +167,13 @@ function GroupInviteButton(inProps) {
|
|
|
155
167
|
* If a value is entered in new message field, it fetches user suggested
|
|
156
168
|
*/
|
|
157
169
|
(0, react_1.useEffect)(() => {
|
|
158
|
-
if (
|
|
170
|
+
if (scGroup) {
|
|
159
171
|
fetchResults();
|
|
160
172
|
}
|
|
161
|
-
|
|
162
|
-
|
|
173
|
+
else {
|
|
174
|
+
fetchGeneralResults();
|
|
175
|
+
}
|
|
176
|
+
}, [value, scGroup]);
|
|
163
177
|
/**
|
|
164
178
|
* Handles dialog close
|
|
165
179
|
*/
|
|
@@ -182,6 +196,7 @@ function GroupInviteButton(inProps) {
|
|
|
182
196
|
setIsSending(false);
|
|
183
197
|
setOpen(false);
|
|
184
198
|
setInvited([]);
|
|
199
|
+
notifyChanges(scGroup, invited);
|
|
185
200
|
})
|
|
186
201
|
.catch((error) => {
|
|
187
202
|
setOpen(false);
|
|
@@ -225,10 +240,17 @@ function GroupInviteButton(inProps) {
|
|
|
225
240
|
setInvited(invited.filter((v) => v !== option));
|
|
226
241
|
setList((prev) => [...prev, option]);
|
|
227
242
|
};
|
|
243
|
+
const filterOptions = (options, { inputValue }) => {
|
|
244
|
+
return options.filter((option) => {
|
|
245
|
+
const usernameMatch = option.username.toLowerCase().includes(inputValue.toLowerCase());
|
|
246
|
+
const nameMatch = option.real_name.toLowerCase().includes(inputValue.toLowerCase());
|
|
247
|
+
return usernameMatch || nameMatch;
|
|
248
|
+
});
|
|
249
|
+
};
|
|
228
250
|
/**
|
|
229
251
|
* If in group edit mode and logged-in user is not also the group manager, the component is hidden.
|
|
230
252
|
// */
|
|
231
|
-
if (group && !
|
|
253
|
+
if (group && !isGroupAdmin) {
|
|
232
254
|
return null;
|
|
233
255
|
}
|
|
234
256
|
/**
|
|
@@ -245,7 +267,7 @@ function GroupInviteButton(inProps) {
|
|
|
245
267
|
react_1.default.createElement(lab_1.LoadingButton, { size: "small", color: "secondary", variant: "contained", onClick: handleSendInvitations, loading: isSending, disabled: !invited.length },
|
|
246
268
|
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInviteButton.dialog.button.end", defaultMessage: "ui.groupInviteButton.dialog.button.end" }))) },
|
|
247
269
|
react_1.default.createElement(material_1.Box, { className: classes.dialogContent },
|
|
248
|
-
react_1.default.createElement(Autocomplete_1.default, { className: classes.autocomplete, loading: loading, size: "small", multiple: true, freeSolo: true, disableClearable: true, options: suggested, onChange: handleChange, onInputChange: handleInputChange, inputValue: value, value: invited, getOptionLabel: (option) => (option ? option.username : '...'), isOptionEqualToValue: (option, value) => (option ? value.id === option.id : false), renderTags: () => null, renderOption: (props, option) => (react_1.default.createElement(material_1.Box, Object.assign({ component: "li" }, props),
|
|
270
|
+
react_1.default.createElement(Autocomplete_1.default, { className: classes.autocomplete, loading: loading, size: "small", multiple: true, freeSolo: true, disableClearable: true, options: suggested, onChange: handleChange, onInputChange: handleInputChange, inputValue: value, filterOptions: filterOptions, value: invited, getOptionLabel: (option) => (option ? option.username : '...'), isOptionEqualToValue: (option, value) => (option ? value.id === option.id : false), renderTags: () => null, renderOption: (props, option) => (react_1.default.createElement(material_1.Box, Object.assign({ component: "li" }, props),
|
|
249
271
|
react_1.default.createElement(material_1.Avatar, { alt: option.username, src: option.avatar }),
|
|
250
272
|
react_1.default.createElement(material_1.Typography, { ml: 1 }, option.username))), renderInput: (params) => (react_1.default.createElement(material_1.TextField, Object.assign({}, params, { variant: "outlined", placeholder: `${intl.formatMessage(messages.placeholder)}`, InputProps: Object.assign(Object.assign({}, params.InputProps), { className: classes.input, startAdornment: (react_1.default.createElement(react_1.default.Fragment, null,
|
|
251
273
|
react_1.default.createElement(material_1.InputAdornment, { position: "start" },
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { WidgetProps } from '../Widget';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
import { CacheStrategies } from '@selfcommunity/utils';
|
|
4
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
5
|
+
import { VirtualScrollerItemProps } from '../../types/virtualScroller';
|
|
6
|
+
import { UserProps } from '../User';
|
|
7
|
+
export interface GroupInvitedWidgetProps extends VirtualScrollerItemProps, WidgetProps {
|
|
8
|
+
/**
|
|
9
|
+
* Group Object
|
|
10
|
+
* @default null
|
|
11
|
+
*/
|
|
12
|
+
group?: SCGroupType;
|
|
13
|
+
/**
|
|
14
|
+
* Id of the group
|
|
15
|
+
* @default null
|
|
16
|
+
*/
|
|
17
|
+
groupId?: number | string;
|
|
18
|
+
/**
|
|
19
|
+
* Limit the number of users to show
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
limit?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Caching strategies
|
|
25
|
+
* @default CacheStrategies.CACHE_FIRST
|
|
26
|
+
*/
|
|
27
|
+
cacheStrategy?: CacheStrategies;
|
|
28
|
+
/**
|
|
29
|
+
* Props to spread to single user object
|
|
30
|
+
* @default empty object
|
|
31
|
+
*/
|
|
32
|
+
UserProps?: UserProps;
|
|
33
|
+
/**
|
|
34
|
+
* Props to spread to followers users dialog
|
|
35
|
+
* @default {}
|
|
36
|
+
*/
|
|
37
|
+
DialogProps?: BaseDialogProps;
|
|
38
|
+
/**
|
|
39
|
+
* Other props
|
|
40
|
+
*/
|
|
41
|
+
[p: string]: any;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* > API documentation for the Community-JS Group Invited Widget component. Learn about the available props and the CSS API.
|
|
45
|
+
*
|
|
46
|
+
*
|
|
47
|
+
* This component renders the list of users who have been invited to join the specified group.
|
|
48
|
+
|
|
49
|
+
#### Import
|
|
50
|
+
|
|
51
|
+
```jsx
|
|
52
|
+
import {GroupInvitedWidget} from '@selfcommunity/react-ui';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### Component Name
|
|
56
|
+
|
|
57
|
+
The name `SCGroupInvitedWidget` can be used when providing style overrides in the theme.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
#### CSS
|
|
61
|
+
|
|
62
|
+
|Rule Name|Global class|Description|
|
|
63
|
+
|---|---|---|
|
|
64
|
+
|root|.SCGroupInvitedWidget-root|Styles applied to the root element.|
|
|
65
|
+
|title|.SCGroupInvitedWidget-title|Styles applied to the title element.|
|
|
66
|
+
|noResults|.SCGroupInvitedWidget-no-results|Styles applied to no results section.|
|
|
67
|
+
|showMore|.SCGroupInvitedWidget-show-more|Styles applied to show more button element.|
|
|
68
|
+
|dialogRoot|.SCGroupInvitedWidget-dialog-root|Styles applied to the dialog root element.|
|
|
69
|
+
|endMessage|.SCGroupInvitedWidget-end-message|Styles applied to the end message element.|
|
|
70
|
+
|
|
71
|
+
* @param inProps
|
|
72
|
+
*/
|
|
73
|
+
export default function GroupInvitedWidget(inProps: GroupInvitedWidgetProps): JSX.Element;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
const List_1 = tslib_1.__importDefault(require("@mui/material/List"));
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
9
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
10
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
11
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
12
|
+
const widget_1 = require("../../utils/widget");
|
|
13
|
+
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
14
|
+
const react_intl_1 = require("react-intl");
|
|
15
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
16
|
+
const Errors_1 = require("../../constants/Errors");
|
|
17
|
+
const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
|
|
18
|
+
const InfiniteScroll_1 = tslib_1.__importDefault(require("../../shared/InfiniteScroll"));
|
|
19
|
+
const system_1 = require("@mui/system");
|
|
20
|
+
const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
|
|
21
|
+
const constants_1 = require("./constants");
|
|
22
|
+
const User_1 = tslib_1.__importStar(require("../User"));
|
|
23
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
24
|
+
const PubSub_1 = require("../../constants/PubSub");
|
|
25
|
+
const classes = {
|
|
26
|
+
root: `${constants_1.PREFIX}-root`,
|
|
27
|
+
title: `${constants_1.PREFIX}-title`,
|
|
28
|
+
noResults: `${constants_1.PREFIX}-no-results`,
|
|
29
|
+
showMore: `${constants_1.PREFIX}-show-more`,
|
|
30
|
+
dialogRoot: `${constants_1.PREFIX}-dialog-root`,
|
|
31
|
+
endMessage: `${constants_1.PREFIX}-end-message`
|
|
32
|
+
};
|
|
33
|
+
const Root = (0, styles_1.styled)(Widget_1.default, {
|
|
34
|
+
name: constants_1.PREFIX,
|
|
35
|
+
slot: 'Root'
|
|
36
|
+
})(() => ({}));
|
|
37
|
+
const DialogRoot = (0, styles_1.styled)(BaseDialog_1.default, {
|
|
38
|
+
name: constants_1.PREFIX,
|
|
39
|
+
slot: 'DialogRoot'
|
|
40
|
+
})(() => ({}));
|
|
41
|
+
/**
|
|
42
|
+
* > API documentation for the Community-JS Group Invited Widget component. Learn about the available props and the CSS API.
|
|
43
|
+
*
|
|
44
|
+
*
|
|
45
|
+
* This component renders the list of users who have been invited to join the specified group.
|
|
46
|
+
|
|
47
|
+
#### Import
|
|
48
|
+
|
|
49
|
+
```jsx
|
|
50
|
+
import {GroupInvitedWidget} from '@selfcommunity/react-ui';
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### Component Name
|
|
54
|
+
|
|
55
|
+
The name `SCGroupInvitedWidget` can be used when providing style overrides in the theme.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
#### CSS
|
|
59
|
+
|
|
60
|
+
|Rule Name|Global class|Description|
|
|
61
|
+
|---|---|---|
|
|
62
|
+
|root|.SCGroupInvitedWidget-root|Styles applied to the root element.|
|
|
63
|
+
|title|.SCGroupInvitedWidget-title|Styles applied to the title element.|
|
|
64
|
+
|noResults|.SCGroupInvitedWidget-no-results|Styles applied to no results section.|
|
|
65
|
+
|showMore|.SCGroupInvitedWidget-show-more|Styles applied to show more button element.|
|
|
66
|
+
|dialogRoot|.SCGroupInvitedWidget-dialog-root|Styles applied to the dialog root element.|
|
|
67
|
+
|endMessage|.SCGroupInvitedWidget-end-message|Styles applied to the end message element.|
|
|
68
|
+
|
|
69
|
+
* @param inProps
|
|
70
|
+
*/
|
|
71
|
+
function GroupInvitedWidget(inProps) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
// PROPS
|
|
74
|
+
const props = (0, system_1.useThemeProps)({
|
|
75
|
+
props: inProps,
|
|
76
|
+
name: constants_1.PREFIX
|
|
77
|
+
});
|
|
78
|
+
const { groupId, group, limit = 5, className, cacheStrategy = utils_1.CacheStrategies.NETWORK_ONLY, onHeightChange, onStateChange, UserProps = {}, DialogProps = {} } = props, rest = tslib_1.__rest(props, ["groupId", "group", "limit", "className", "cacheStrategy", "onHeightChange", "onStateChange", "UserProps", "DialogProps"]);
|
|
79
|
+
// STATE
|
|
80
|
+
const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
|
|
81
|
+
isLoadingNext: false,
|
|
82
|
+
next: null,
|
|
83
|
+
cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.GROUP_REQUESTS_TOOLS_STATE_CACHE_PREFIX_KEY, (0, utils_1.isInteger)(groupId) ? groupId : group.id),
|
|
84
|
+
cacheStrategy,
|
|
85
|
+
visibleItems: limit
|
|
86
|
+
}, widget_1.stateWidgetInitializer);
|
|
87
|
+
const [openDialog, setOpenDialog] = (0, react_1.useState)(false);
|
|
88
|
+
// CONTEXT
|
|
89
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
90
|
+
const scPreferencesContext = (0, react_core_1.useSCPreferences)();
|
|
91
|
+
const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
92
|
+
// MEMO
|
|
93
|
+
const contentAvailability = (0, react_1.useMemo)(() => react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY in scPreferencesContext.preferences &&
|
|
94
|
+
scPreferencesContext.preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value, [scPreferencesContext.preferences]);
|
|
95
|
+
// HOOKS
|
|
96
|
+
const theme = (0, material_1.useTheme)();
|
|
97
|
+
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
98
|
+
const isGroupAdmin = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
99
|
+
// REFS
|
|
100
|
+
const updatesSubscription = (0, react_1.useRef)(null);
|
|
101
|
+
/**
|
|
102
|
+
* Initialize component
|
|
103
|
+
* Fetch data only if the component is not initialized and it is not loading data
|
|
104
|
+
*/
|
|
105
|
+
const _initComponent = (0, react_1.useMemo)(() => () => {
|
|
106
|
+
if (!state.initialized && !state.isLoadingNext) {
|
|
107
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
108
|
+
api_services_1.GroupService.getGroupInvitedUsers(scGroup.id, { limit })
|
|
109
|
+
.then((payload) => {
|
|
110
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: Object.assign(Object.assign({}, payload), { initialized: true }) });
|
|
111
|
+
})
|
|
112
|
+
.catch((error) => {
|
|
113
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
114
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}, [state.isLoadingNext, state.initialized, scGroup, limit, dispatch]);
|
|
118
|
+
// EFFECTS
|
|
119
|
+
(0, react_1.useEffect)(() => {
|
|
120
|
+
var _a;
|
|
121
|
+
let _t;
|
|
122
|
+
if ((contentAvailability || (!contentAvailability && ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id))) && scGroup && scUserContext.user !== undefined) {
|
|
123
|
+
_t = setTimeout(_initComponent);
|
|
124
|
+
return () => {
|
|
125
|
+
_t && clearTimeout(_t);
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}, [scUserContext.user, contentAvailability, scGroup]);
|
|
129
|
+
(0, react_1.useEffect)(() => {
|
|
130
|
+
if (openDialog && state.next && state.results.length === limit && state.initialized) {
|
|
131
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
132
|
+
api_services_1.GroupService.getGroupInvitedUsers(scGroup.id, { offset: limit, limit: 10 })
|
|
133
|
+
.then((payload) => {
|
|
134
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: payload });
|
|
135
|
+
})
|
|
136
|
+
.catch((error) => {
|
|
137
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_FAILURE, payload: { errorLoadNext: error } });
|
|
138
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, [openDialog, state.next, state.results.length, state.initialized, limit]);
|
|
142
|
+
/**
|
|
143
|
+
* Virtual feed update
|
|
144
|
+
*/
|
|
145
|
+
(0, react_1.useEffect)(() => {
|
|
146
|
+
onHeightChange && onHeightChange();
|
|
147
|
+
}, [state.results]);
|
|
148
|
+
(0, react_1.useEffect)(() => {
|
|
149
|
+
if (!scGroup || (!contentAvailability && !scUserContext.user)) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
else if (cacheStrategy === utils_1.CacheStrategies.NETWORK_ONLY) {
|
|
153
|
+
onStateChange && onStateChange({ cacheStrategy: utils_1.CacheStrategies.CACHE_FIRST });
|
|
154
|
+
}
|
|
155
|
+
}, [scUserContext.user, scGroup, contentAvailability]);
|
|
156
|
+
(0, react_1.useEffect)(() => {
|
|
157
|
+
if (!scGroup || !scUserContext.user || !state.initialized) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}, []);
|
|
161
|
+
/**
|
|
162
|
+
* Subscriber for pubsub callback
|
|
163
|
+
*/
|
|
164
|
+
const onChangeGroupHandler = (0, react_1.useCallback)((_msg, newInvited) => {
|
|
165
|
+
dispatch({
|
|
166
|
+
type: widget_1.actionWidgetTypes.SET_RESULTS,
|
|
167
|
+
payload: { results: [...state.results, ...newInvited], count: state.count + newInvited.length }
|
|
168
|
+
});
|
|
169
|
+
}, [scGroup, dispatch, state.results]);
|
|
170
|
+
/**
|
|
171
|
+
* On mount, subscribe to receive groups updates (only edit)
|
|
172
|
+
*/
|
|
173
|
+
(0, react_1.useEffect)(() => {
|
|
174
|
+
if (scGroup && state.results) {
|
|
175
|
+
updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCEventType.INVITE_MEMBER}`, onChangeGroupHandler);
|
|
176
|
+
}
|
|
177
|
+
return () => {
|
|
178
|
+
updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
|
|
179
|
+
};
|
|
180
|
+
}, [scGroup, state.results]);
|
|
181
|
+
// HANDLERS
|
|
182
|
+
const handleNext = (0, react_1.useMemo)(() => () => {
|
|
183
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOADING_NEXT });
|
|
184
|
+
api_services_1.http
|
|
185
|
+
.request({
|
|
186
|
+
url: state.next,
|
|
187
|
+
method: api_services_1.Endpoints.getGroupInvitedUsers.method
|
|
188
|
+
})
|
|
189
|
+
.then((res) => {
|
|
190
|
+
dispatch({ type: widget_1.actionWidgetTypes.LOAD_NEXT_SUCCESS, payload: res.data });
|
|
191
|
+
});
|
|
192
|
+
}, [dispatch, state.next, state.isLoadingNext, state.initialized]);
|
|
193
|
+
const handleToggleDialogOpen = () => {
|
|
194
|
+
setOpenDialog((prev) => !prev);
|
|
195
|
+
};
|
|
196
|
+
// RENDER
|
|
197
|
+
if ((!state.count && state.initialized) || !contentAvailability || !scGroup || !state.count || !state.results.length || !isGroupAdmin) {
|
|
198
|
+
return react_1.default.createElement(HiddenPlaceholder_1.default, null);
|
|
199
|
+
}
|
|
200
|
+
if (!state.initialized) {
|
|
201
|
+
return react_1.default.createElement(Skeleton_1.default, null);
|
|
202
|
+
}
|
|
203
|
+
const content = (react_1.default.createElement(material_1.CardContent, null,
|
|
204
|
+
react_1.default.createElement(material_1.Typography, { className: classes.title, variant: "h5" },
|
|
205
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInvitedWidget.title", defaultMessage: "ui.groupInvitedWidget.title" })),
|
|
206
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
207
|
+
react_1.default.createElement(List_1.default, null, state.results.slice(0, state.visibleItems).map((user) => (react_1.default.createElement(material_1.ListItem, { key: user.id },
|
|
208
|
+
react_1.default.createElement(User_1.default, { elevation: 0, actions: react_1.default.createElement(material_1.Button, { disabled: true, size: "small" },
|
|
209
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInvitedWidget.status", defaultMessage: "ui.groupInvitedWidget.status" })), user: user, userId: user.id }))))),
|
|
210
|
+
state.count > state.visibleItems && (react_1.default.createElement(material_1.Button, { className: classes.showMore, onClick: handleToggleDialogOpen },
|
|
211
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInvitedWidget.button.showMore", defaultMessage: "ui.groupInvitedWidget.button.showMore" })))),
|
|
212
|
+
openDialog && (react_1.default.createElement(DialogRoot, Object.assign({ className: classes.dialogRoot, title: react_1.default.createElement(react_intl_1.FormattedMessage, { defaultMessage: "ui.groupInvitedWidget.dialogTitle", id: "ui.groupInvitedWidget.dialogTitle", values: { total: (_b = state === null || state === void 0 ? void 0 : state.results) === null || _b === void 0 ? void 0 : _b.length } }), onClose: handleToggleDialogOpen, open: openDialog }, DialogProps),
|
|
213
|
+
react_1.default.createElement(InfiniteScroll_1.default, { dataLength: state.results.length, next: handleNext, hasMoreNext: Boolean(state.next), loaderNext: react_1.default.createElement(User_1.UserSkeleton, Object.assign({ elevation: 0 }, UserProps)), height: isMobile ? '100%' : 400, endMessage: react_1.default.createElement(material_1.Typography, { className: classes.endMessage },
|
|
214
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInvitedWidget.noMoreResults", defaultMessage: "ui.groupInvitedWidget.noMoreResults" })) },
|
|
215
|
+
react_1.default.createElement(List_1.default, null, state.results.map((user) => (react_1.default.createElement(material_1.ListItem, { key: user.id },
|
|
216
|
+
react_1.default.createElement(User_1.default, { elevation: 0, actions: react_1.default.createElement(material_1.Button, { disabled: true, size: "small" },
|
|
217
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupInvitedWidget.status", defaultMessage: "ui.groupInvitedWidget.status" })), user: user, userId: user.id }))))))))));
|
|
218
|
+
return (react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest), content));
|
|
219
|
+
}
|
|
220
|
+
exports.default = GroupInvitedWidget;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { WidgetProps } from '../Widget';
|
|
2
|
+
/**
|
|
3
|
+
* > API documentation for the Community-JS Group Invited Widget Skeleton component. Learn about the available props and the CSS API.
|
|
4
|
+
|
|
5
|
+
#### Import
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import {GroupInvitedWidgetSkeleton} from '@selfcommunity/react-ui';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
#### Component Name
|
|
12
|
+
|
|
13
|
+
The name `SCGroupInvitedWidget-skeleton-root` can be used when providing style overrides in the theme.
|
|
14
|
+
|
|
15
|
+
#### CSS
|
|
16
|
+
|
|
17
|
+
|Rule Name|Global class|Description|
|
|
18
|
+
|---|---|---|
|
|
19
|
+
|root|.SCGroupInvitedWidget-skeleton-root|Styles applied to the root element.|
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export default function GroupInvitedWidgetSkeleton(props: WidgetProps): JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
5
|
+
const CategoryTrendingUsersWidget_1 = require("../CategoryTrendingUsersWidget");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const constants_1 = require("./constants");
|
|
8
|
+
const classes = {
|
|
9
|
+
root: `${constants_1.PREFIX}-skeleton-root`
|
|
10
|
+
};
|
|
11
|
+
const Root = (0, styles_1.styled)(CategoryTrendingUsersWidget_1.CategoryTrendingPeopleWidgetSkeleton, {
|
|
12
|
+
name: constants_1.PREFIX,
|
|
13
|
+
slot: 'SkeletonRoot'
|
|
14
|
+
})(() => ({}));
|
|
15
|
+
/**
|
|
16
|
+
* > API documentation for the Community-JS Group Invited Widget Skeleton component. Learn about the available props and the CSS API.
|
|
17
|
+
|
|
18
|
+
#### Import
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
import {GroupInvitedWidgetSkeleton} from '@selfcommunity/react-ui';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
#### Component Name
|
|
25
|
+
|
|
26
|
+
The name `SCGroupInvitedWidget-skeleton-root` can be used when providing style overrides in the theme.
|
|
27
|
+
|
|
28
|
+
#### CSS
|
|
29
|
+
|
|
30
|
+
|Rule Name|Global class|Description|
|
|
31
|
+
|---|---|---|
|
|
32
|
+
|root|.SCGroupInvitedWidget-skeleton-root|Styles applied to the root element.|
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
function GroupInvitedWidgetSkeleton(props) {
|
|
36
|
+
return react_1.default.createElement(Root, Object.assign({ className: classes.root }, props));
|
|
37
|
+
}
|
|
38
|
+
exports.default = GroupInvitedWidgetSkeleton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCGroupInvitedWidget";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupInvitedWidgetSkeleton = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const GroupInvitedWidget_1 = tslib_1.__importDefault(require("./GroupInvitedWidget"));
|
|
6
|
+
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
7
|
+
exports.GroupInvitedWidgetSkeleton = Skeleton_1.default;
|
|
8
|
+
exports.default = GroupInvitedWidget_1.default;
|
|
@@ -17,6 +17,11 @@ export interface GroupMembersButtonProps extends Pick<ButtonProps, Exclude<keyof
|
|
|
17
17
|
* @default {}
|
|
18
18
|
*/
|
|
19
19
|
DialogProps?: BaseDialogProps;
|
|
20
|
+
/**
|
|
21
|
+
* Hides this component
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
autoHide?: boolean;
|
|
20
25
|
/**
|
|
21
26
|
* Any other properties
|
|
22
27
|
*/
|