@selfcommunity/react-ui 0.8.0-alpha.2 → 0.8.0-alpha.20
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/BottomNavigation/BottomNavigation.js +11 -2
- package/lib/cjs/components/Composer/Composer.js +10 -2
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +12 -3
- package/lib/cjs/components/CreateEventButton/CreateEventButton.js +5 -1
- package/lib/cjs/components/CreateEventWidget/CreateEventWidget.js +5 -1
- package/lib/cjs/components/EventForm/EventAddress.d.ts +3 -8
- package/lib/cjs/components/EventForm/EventAddress.js +20 -20
- package/lib/cjs/components/EventForm/EventForm.d.ts +1 -1
- package/lib/cjs/components/EventForm/EventForm.js +90 -76
- package/lib/cjs/components/EventForm/constants.d.ts +4 -0
- package/lib/cjs/components/EventForm/constants.js +5 -1
- package/lib/cjs/components/EventForm/types.d.ts +27 -0
- package/lib/cjs/components/EventForm/types.js +2 -0
- package/lib/cjs/components/EventForm/utils.d.ts +4 -0
- package/lib/cjs/components/EventForm/utils.js +28 -0
- package/lib/cjs/components/EventHeader/EventHeader.js +1 -1
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +24 -1
- package/lib/cjs/components/Events/Events.js +4 -4
- package/lib/cjs/components/Feed/Feed.js +10 -2
- package/lib/cjs/components/GroupActionsMenu/index.d.ts +57 -0
- package/lib/cjs/components/GroupActionsMenu/index.js +157 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.js +8 -4
- package/lib/cjs/components/Groups/Groups.js +26 -0
- package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +6 -2
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +12 -3
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
- package/lib/cjs/components/Notification/Event/Event.js +4 -0
- package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.d.ts +10 -1
- package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +69 -26
- package/lib/cjs/components/OnBoardingWidget/Steps/Invite/Invite.js +26 -3
- package/lib/cjs/components/PlatformWidget/constants.d.ts +0 -4
- package/lib/cjs/components/PlatformWidget/constants.js +1 -5
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +7 -2
- package/lib/cjs/constants/GroupActionsMenu.d.ts +5 -0
- package/lib/cjs/constants/GroupActionsMenu.js +8 -0
- package/lib/cjs/index.d.ts +2 -1
- package/lib/cjs/index.js +6 -4
- package/lib/cjs/shared/ContributionActionsMenu/index.js +6 -6
- package/lib/cjs/shared/EventActionsMenu/index.d.ts +4 -0
- package/lib/cjs/shared/EventActionsMenu/index.js +13 -3
- package/lib/cjs/shared/InfiniteScroll/index.js +3 -3
- package/lib/cjs/shared/Media/Link/DisplayComponent.js +21 -5
- package/lib/cjs/utils/formatRelativeTime.js +2 -2
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +11 -2
- package/lib/esm/components/Composer/Composer.js +10 -2
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +13 -4
- package/lib/esm/components/CreateEventButton/CreateEventButton.js +5 -1
- package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +5 -1
- package/lib/esm/components/EventForm/EventAddress.d.ts +3 -8
- package/lib/esm/components/EventForm/EventAddress.js +20 -20
- package/lib/esm/components/EventForm/EventForm.d.ts +1 -1
- package/lib/esm/components/EventForm/EventForm.js +92 -78
- package/lib/esm/components/EventForm/constants.d.ts +4 -0
- package/lib/esm/components/EventForm/constants.js +4 -0
- package/lib/esm/components/EventForm/types.d.ts +27 -0
- package/lib/esm/components/EventForm/types.js +1 -0
- package/lib/esm/components/EventForm/utils.d.ts +4 -0
- package/lib/esm/components/EventForm/utils.js +21 -0
- package/lib/esm/components/EventHeader/EventHeader.js +1 -1
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +25 -2
- package/lib/esm/components/Events/Events.js +4 -4
- package/lib/esm/components/Feed/Feed.js +12 -4
- package/lib/esm/components/GroupActionsMenu/index.d.ts +57 -0
- package/lib/esm/components/GroupActionsMenu/index.js +154 -0
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -0
- package/lib/esm/components/GroupHeader/GroupHeader.js +9 -5
- package/lib/esm/components/Groups/Groups.js +27 -1
- package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +7 -3
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +12 -3
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
- package/lib/esm/components/Notification/Event/Event.js +4 -0
- package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.d.ts +10 -1
- package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +71 -28
- package/lib/esm/components/OnBoardingWidget/Steps/Invite/Invite.js +27 -4
- package/lib/esm/components/PlatformWidget/constants.d.ts +0 -4
- package/lib/esm/components/PlatformWidget/constants.js +0 -4
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +8 -3
- package/lib/esm/constants/GroupActionsMenu.d.ts +5 -0
- package/lib/esm/constants/GroupActionsMenu.js +5 -0
- package/lib/esm/index.d.ts +2 -1
- package/lib/esm/index.js +2 -1
- package/lib/esm/shared/ContributionActionsMenu/index.js +6 -6
- package/lib/esm/shared/EventActionsMenu/index.d.ts +4 -0
- package/lib/esm/shared/EventActionsMenu/index.js +13 -3
- package/lib/esm/shared/InfiniteScroll/index.js +3 -3
- package/lib/esm/shared/Media/Link/DisplayComponent.js +21 -5
- package/lib/esm/utils/formatRelativeTime.js +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.combineDateAndTime = exports.getLaterDaysDate = exports.getLaterHoursDate = exports.getNewDate = void 0;
|
|
4
|
+
const date_fns_1 = require("date-fns");
|
|
5
|
+
function getNewDate(date) {
|
|
6
|
+
if (date) {
|
|
7
|
+
return new Date(date);
|
|
8
|
+
}
|
|
9
|
+
return new Date();
|
|
10
|
+
}
|
|
11
|
+
exports.getNewDate = getNewDate;
|
|
12
|
+
function getLaterHoursDate(h) {
|
|
13
|
+
return (0, date_fns_1.addHours)(getNewDate(), h);
|
|
14
|
+
}
|
|
15
|
+
exports.getLaterHoursDate = getLaterHoursDate;
|
|
16
|
+
function getLaterDaysDate(d) {
|
|
17
|
+
return (0, date_fns_1.addDays)(getNewDate(), d);
|
|
18
|
+
}
|
|
19
|
+
exports.getLaterDaysDate = getLaterDaysDate;
|
|
20
|
+
const combineDateAndTime = (date, time) => {
|
|
21
|
+
const combined = date;
|
|
22
|
+
combined.setHours(time.getHours());
|
|
23
|
+
combined.setMinutes(time.getMinutes());
|
|
24
|
+
combined.setSeconds(time.getSeconds());
|
|
25
|
+
combined.setMilliseconds(time.getMilliseconds());
|
|
26
|
+
return combined.toISOString();
|
|
27
|
+
};
|
|
28
|
+
exports.combineDateAndTime = combineDateAndTime;
|
|
@@ -176,6 +176,6 @@ function EventHeader(inProps) {
|
|
|
176
176
|
month: 'long'
|
|
177
177
|
}),
|
|
178
178
|
hour: intl.formatDate(scEvent.start_date, { hour: 'numeric', minute: 'numeric' })
|
|
179
|
-
} })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.visibility.public" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === types_1.SCEventLocationType.PERSON ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.online", defaultMessage: "ui.eventHeader.location.online" })) }))] })), (0, jsx_runtime_1.jsx)(User_1.default, { className: classes.planner, userId: scEvent.managed_by.id, secondary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isEventAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, disabled: isEventFinished }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(EditEventButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data), disabled: isEventFinished }), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent }, EventActionsProps))] })] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(EventSubscribeButton_1.default, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent }, EventActionsProps))] })) }) })] }))] })));
|
|
179
|
+
} })) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scEvent.name })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scEvent.privacy === types_1.SCEventPrivacyType.PUBLIC ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.visibility.public", defaultMessage: "ui.eventHeader.visibility.public" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.visibility.private", defaultMessage: "ui.eventHeader.visibility.private" })] }))) }), (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: scEvent.location === types_1.SCEventLocationType.PERSON ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.live", defaultMessage: "ui.eventHeader.location.live" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.location.online", defaultMessage: "ui.eventHeader.location.online" })) }))] })), (0, jsx_runtime_1.jsx)(User_1.default, { className: classes.planner, userId: scEvent.managed_by.id, secondary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventHeader.user.manager", defaultMessage: "ui.eventHeader.user.manager" }), elevation: 0, actions: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: isEventAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EventInviteButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, disabled: isEventFinished }), (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [!isMobile && ((0, jsx_runtime_1.jsx)(EditEventButton_1.default, { size: isMobile ? 'small' : 'medium', event: scEvent, eventId: scEvent.id, onEditSuccess: (data) => setSCEvent(data), disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })] }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(EventSubscribeButton_1.default, Object.assign({ event: scEvent, onSubscribe: handleSubscribe }, EventSubscribeButtonProps, { disabled: isEventFinished })), (0, jsx_runtime_1.jsx)(EventActionsMenu_1.default, Object.assign({ event: scEvent, onEditSuccess: (data) => setSCEvent(data) }, EventActionsProps))] })) }) })] }))] })));
|
|
180
180
|
}
|
|
181
181
|
exports.default = EventHeader;
|
|
@@ -12,6 +12,8 @@ const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/Hidden
|
|
|
12
12
|
const Widget_1 = tslib_1.__importDefault(require("../Widget"));
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
15
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
16
|
+
const PubSub_1 = require("../../constants/PubSub");
|
|
15
17
|
const classes = {
|
|
16
18
|
root: `${constants_1.PREFIX}-root`,
|
|
17
19
|
content: `${constants_1.PREFIX}-content`,
|
|
@@ -45,7 +47,9 @@ function EventInfoWidget(inProps) {
|
|
|
45
47
|
const [showButton, setShowButton] = (0, react_1.useState)(!summaryExpanded);
|
|
46
48
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
47
49
|
// HOOKS
|
|
48
|
-
const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
50
|
+
const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
|
|
51
|
+
// REFS
|
|
52
|
+
const updatesSubscription = (0, react_1.useRef)(null);
|
|
49
53
|
(0, react_1.useEffect)(() => {
|
|
50
54
|
setLoading(false);
|
|
51
55
|
}, []);
|
|
@@ -67,6 +71,25 @@ function EventInfoWidget(inProps) {
|
|
|
67
71
|
const showInfo = (0, react_1.useMemo)(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === types_1.SCEventPrivacyType.PUBLIC ||
|
|
68
72
|
[types_1.SCEventSubscriptionStatusType.SUBSCRIBED, types_1.SCEventSubscriptionStatusType.GOING, types_1.SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1, [scEvent]);
|
|
69
73
|
const description = (0, react_1.useMemo)(() => (expanded ? scEvent === null || scEvent === void 0 ? void 0 : scEvent.description : getTruncatedText(scEvent === null || scEvent === void 0 ? void 0 : scEvent.description, 220)), [expanded, scEvent]);
|
|
74
|
+
/**
|
|
75
|
+
* Subscriber for pubsub callback
|
|
76
|
+
*/
|
|
77
|
+
const onChangeGroupHandler = (0, react_1.useCallback)((_msg, data) => {
|
|
78
|
+
if (data && scEvent.id === data.id) {
|
|
79
|
+
setSCEvent(data);
|
|
80
|
+
}
|
|
81
|
+
}, [scEvent, setSCEvent]);
|
|
82
|
+
/**
|
|
83
|
+
* On mount, subscribe to receive groups updates (only edit)
|
|
84
|
+
*/
|
|
85
|
+
(0, react_1.useEffect)(() => {
|
|
86
|
+
if (scEvent) {
|
|
87
|
+
updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.EVENT}.${PubSub_1.SCGroupEventType.EDIT}`, onChangeGroupHandler);
|
|
88
|
+
}
|
|
89
|
+
return () => {
|
|
90
|
+
updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
|
|
91
|
+
};
|
|
92
|
+
}, [scEvent]);
|
|
70
93
|
// RENDER
|
|
71
94
|
if (!scEvent && loading) {
|
|
72
95
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
|
|
@@ -217,14 +217,14 @@ function Events(inProps) {
|
|
|
217
217
|
variant: showMyEvents ? 'filled' : 'outlined', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByCreatedByMe", defaultMessage: "ui.events.filterByCreatedByMe" }), onClick: () => setShowMyEvents(!showMyEvents),
|
|
218
218
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
219
219
|
// @ts-ignore
|
|
220
|
-
showFollowed: showMyEvents, deleteIcon: showMyEvents ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, disabled: loading }) })))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading, onKeyUp: (e) => {
|
|
220
|
+
showFollowed: showMyEvents, deleteIcon: showMyEvents ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showMyEvents ? handleDeleteClick : null, disabled: loading }) })))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 4 }, { children: (0, jsx_runtime_1.jsx)(material_1.TextField, { className: classes.search, size: 'small', fullWidth: true, value: query, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByName", defaultMessage: "ui.events.filterByName" }), variant: "outlined", onChange: handleOnChangeFilterName, disabled: loading || (!events.length && !query), onKeyUp: (e) => {
|
|
221
221
|
e.preventDefault();
|
|
222
222
|
if (e.key === 'Enter') {
|
|
223
223
|
fetchEvents(true);
|
|
224
224
|
}
|
|
225
225
|
}, InputProps: {
|
|
226
|
-
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }) }))) : ((0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }), disabled: loading })) })))
|
|
227
|
-
} }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ disabled: showPastEvents || loading, size: 'small', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: option.value }, { children: [(0, jsx_runtime_1.jsx)(material_1.Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), authUserId && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
|
|
226
|
+
endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isMobile ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ onClick: () => fetchEvents(true), disabled: loading || (!events.length && !query) }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }) }))) : ((0, jsx_runtime_1.jsx)(material_1.Button, { size: "small", variant: "contained", color: "secondary", onClick: () => fetchEvents(true), endIcon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "search" }), disabled: loading || (!events.length && !query) })) })))
|
|
227
|
+
} }) })), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.InputLabel, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }) }), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ disabled: showPastEvents || loading || (!events.length && dateSearch === types_1.SCEventDateFilterType.ANY), size: 'small', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByDate", defaultMessage: "ui.events.filterByDate" }), value: dateSearch, onChange: handleOnChangeTimeFrame, renderValue: (selected) => options.find((option) => option.value === selected).label }, { children: options.map((option) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: option.value }, { children: [(0, jsx_runtime_1.jsx)(material_1.Radio, { checked: dateSearch === option.value, value: option.value, name: "radio-button-select", inputProps: { 'aria-label': option.label } }), option.label] }), option.value))) }))] })) })), authUserId && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(exports.EventsChipRoot
|
|
228
228
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
229
229
|
// @ts-ignore
|
|
230
230
|
, {
|
|
@@ -236,7 +236,7 @@ function Events(inProps) {
|
|
|
236
236
|
variant: showFollowed ? 'filled' : 'outlined', label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.filterByFollowedInterest", defaultMessage: "ui.events.filterByFollowedInterest" }), onClick: handleChipClick,
|
|
237
237
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
238
238
|
// @ts-ignore
|
|
239
|
-
showFollowed: showFollowed, deleteIcon: showFollowed ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading }) }))), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(PastEventsFilter_1.default, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: dateSearch !== types_1.SCEventDateFilterType.ANY || loading }) }))] })) }))), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: loading ? ((0, jsx_runtime_1.jsx)(Skeleton_1.default, Object.assign({}, EventsSkeletonComponentProps, { EventSkeletonProps: EventSkeletonComponentProps }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !events.length ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.noResults }, { children: (onlyStaffEnabled && !react_core_1.UserUtils.isStaff(scUserContext.user)) ||
|
|
239
|
+
showFollowed: showFollowed, deleteIcon: showFollowed ? (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) : null, onDelete: showFollowed ? handleDeleteClick : null, disabled: loading || (!events.length && !showFollowed) }) }))), (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true }, { children: (0, jsx_runtime_1.jsx)(PastEventsFilter_1.default, { showPastEvents: showPastEvents, handleClick: handleChipPastClick, handleDeleteClick: handleDeletePastClick, disabled: dateSearch !== types_1.SCEventDateFilterType.ANY || loading || (!events.length && !showPastEvents) }) }))] })) }))), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: loading ? ((0, jsx_runtime_1.jsx)(Skeleton_1.default, Object.assign({}, EventsSkeletonComponentProps, { EventSkeletonProps: EventSkeletonComponentProps }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !events.length ? ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.noResults }, { children: (onlyStaffEnabled && !react_core_1.UserUtils.isStaff(scUserContext.user)) ||
|
|
240
240
|
(onlyStaffEnabled && react_core_1.UserUtils.isStaff(scUserContext.user) && general) ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps)), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.noEvents.title", defaultMessage: "ui.events.noEvents.title" }) }))] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (0, jsx_runtime_1.jsx)(CreateEventButton_1.default, {}) })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.noEvents.title.onlyStaff", defaultMessage: "ui.events.noEvents.title.onlyStaff" }) }))] })) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ container: true, spacing: { xs: 2 }, className: classes.events }, GridContainerComponentProps, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [events.map((event) => ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.item }, GridItemComponentProps, { children: (0, jsx_runtime_1.jsx)(Event_1.default, Object.assign({ event: event, eventId: event.id }, EventComponentProps)) }), event.id))), authUserId && events.length % 2 !== 0 && ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, sm: 12, md: 6, className: classes.itemSkeleton }, GridItemComponentProps, { children: (0, jsx_runtime_1.jsx)(Event_1.EventSkeleton, Object.assign({}, EventSkeletonComponentProps, { skeletonsAnimation: false, actions: (0, jsx_runtime_1.jsx)(CreateEventButton_1.default, Object.assign({ variant: "outlined", color: "primary", size: "small" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.skeleton.action.add", defaultMessage: "ui.events.skeleton.action.add" }) })) })) }), 'skeleton-item'))] }) })), Boolean(next) && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "secondary", variant: "text", onClick: handleNext, className: classes.showMore }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.events.button.seeMore", defaultMessage: "ui.events.button.seeMore" }) })))] })) })) })] }));
|
|
241
241
|
/**
|
|
242
242
|
* Renders root object (if content availability community option is false and user is anonymous, component is hidden)
|
|
@@ -26,6 +26,12 @@ const Skeleton_2 = tslib_1.__importDefault(require("./Skeleton"));
|
|
|
26
26
|
const use_deep_compare_effect_1 = require("use-deep-compare-effect");
|
|
27
27
|
const StickyBox_1 = tslib_1.__importDefault(require("../../shared/StickyBox"));
|
|
28
28
|
const constants_1 = require("./constants");
|
|
29
|
+
const messages = (0, react_intl_1.defineMessages)({
|
|
30
|
+
refresh: {
|
|
31
|
+
id: 'ui.feed.refreshRelease',
|
|
32
|
+
defaultMessage: 'ui.feed.refreshRelease'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
29
35
|
const classes = {
|
|
30
36
|
root: `${constants_1.PREFIX}-root`,
|
|
31
37
|
left: `${constants_1.PREFIX}-left`,
|
|
@@ -78,7 +84,9 @@ const Feed = (inProps, ref) => {
|
|
|
78
84
|
props: inProps,
|
|
79
85
|
name: constants_1.PREFIX
|
|
80
86
|
});
|
|
81
|
-
|
|
87
|
+
// HOOKS
|
|
88
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
89
|
+
const { id = 'feed', className, endpoint, endpointQueryParams = { limit: Pagination_1.DEFAULT_PAGINATION_LIMIT, offset: Pagination_1.DEFAULT_PAGINATION_OFFSET }, endMessage = (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.feed.noOtherFeedObject", defaultMessage: "ui.feed.noOtherFeedObject" }), refreshMessage = (0, jsx_runtime_1.jsx)(material_1.Typography, { dangerouslySetInnerHTML: { __html: `${intl.formatMessage(messages.refresh)}` } }), HeaderComponent, FooterComponent = Footer_1.default, FooterComponentProps = {}, widgets = [], ItemComponent, itemPropsGenerator, itemIdGenerator, ItemProps = {}, ItemSkeleton, ItemSkeletonProps = {}, onNextData, onPreviousData, FeedSidebarProps = {}, CustomAdvProps = {}, enabledCustomAdvPositions = [types_1.SCCustomAdvPosition.POSITION_FEED_SIDEBAR, types_1.SCCustomAdvPosition.POSITION_FEED], requireAuthentication = false, cacheStrategy = utils_1.CacheStrategies.NETWORK_ONLY, prefetchedData, scrollableTargetId, VirtualizedScrollerProps = {}, disablePaginationLinks = false, hidePaginationLinks = true, paginationLinksPageQueryParam = Pagination_1.DEFAULT_PAGINATION_QUERY_PARAM_NAME, PaginationLinkProps = {}, hideAdvs = false, emptyFeedPlaceholder } = props;
|
|
82
90
|
// CONTEXT
|
|
83
91
|
const scPreferences = (0, react_1.useContext)(react_core_1.SCPreferencesContext);
|
|
84
92
|
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
@@ -411,6 +419,6 @@ const Feed = (inProps, ref) => {
|
|
|
411
419
|
if (feedDataObject.isLoadingNext && !feedDataLeft.length) {
|
|
412
420
|
return ((0, jsx_runtime_1.jsx)(Skeleton_2.default, { children: [...Array(3)].map((v, i) => ((0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps), i))) }));
|
|
413
421
|
}
|
|
414
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ container: true, spacing: 2, id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: [advEnabled && !hideAdvs && enabledCustomAdvPositions.includes(types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR) ? ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(CustomAdv_1.default, Object.assign({ position: types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR }, CustomAdvProps)) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: (0, jsx_runtime_1.jsxs)(InfiniteScroll_1.default, Object.assign({ ref: containerRef, className: classes.left, dataLength: feedDataLeft.length, next: getNextPage, previous: getPreviousPage, hasMoreNext: Boolean(feedDataObject.next), hasMorePrevious: Boolean(feedDataObject.previous), header: PreviousPageLink, footer: NextPageLink, loaderNext: (0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps)), loaderPrevious: (0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps)), scrollThreshold: '90%', endMessage: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.end }, { children: [(0, jsx_runtime_1.jsx)(Widget_1.default, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(material_1.CardContent, { children: endMessage }) })), FooterComponent ? (0, jsx_runtime_1.jsx)(FooterComponent, Object.assign({}, FooterComponentProps)) : null] })), refreshFunction: refresh, pullDownToRefresh: true, pullDownToRefreshThreshold: 1000, pullDownToRefreshContent: null, releaseToRefreshContent: (0, jsx_runtime_1.jsx)(
|
|
422
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ container: true, spacing: 2, id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: [advEnabled && !hideAdvs && enabledCustomAdvPositions.includes(types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR) ? ((0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12 }, { children: (0, jsx_runtime_1.jsx)(CustomAdv_1.default, Object.assign({ position: types_1.SCCustomAdvPosition.POSITION_BELOW_TOPBAR }, CustomAdvProps)) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 7 }, { children: (0, jsx_runtime_1.jsxs)(InfiniteScroll_1.default, Object.assign({ ref: containerRef, className: classes.left, dataLength: feedDataLeft.length, next: getNextPage, previous: getPreviousPage, hasMoreNext: Boolean(feedDataObject.next), hasMorePrevious: Boolean(feedDataObject.previous), header: PreviousPageLink, footer: NextPageLink, loaderNext: (0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps)), loaderPrevious: (0, jsx_runtime_1.jsx)(ItemSkeleton, Object.assign({}, ItemSkeletonProps)), scrollThreshold: '90%', endMessage: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.end }, { children: [(0, jsx_runtime_1.jsx)(Widget_1.default, Object.assign({ className: classes.endMessage }, { children: (0, jsx_runtime_1.jsx)(material_1.CardContent, { children: endMessage }) })), FooterComponent ? (0, jsx_runtime_1.jsx)(FooterComponent, Object.assign({}, FooterComponentProps)) : null] })), refreshFunction: refresh, pullDownToRefresh: true, pullDownToRefreshThreshold: 1000, pullDownToRefreshContent: null, releaseToRefreshContent: (0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ color: "secondary", variant: "contained", className: classes.refresh }, { children: refreshMessage })), style: { overflow: 'visible' } }, (scrollableTargetId && { scrollableTarget: scrollableTargetId }), { children: [renderHeaderComponent(), feedDataObject.count === 0 && emptyFeedPlaceholder && emptyFeedPlaceholder, (0, jsx_runtime_1.jsx)(VirtualizedScroller_1.default, Object.assign({ className: classes.leftItems, items: feedDataLeft, itemComponent: InnerItem, onMount: onScrollerMount, onScrollerStateChange: onScrollerStateChange, getItemId: getScrollItemId, preserveScrollPosition: true, preserveScrollPositionOnPrependItems: true, cacheScrollStateKey: react_core_1.SCCache.getVirtualizedScrollStateCacheKey(id), cacheScrollerPositionKey: react_core_1.SCCache.getFeedSPCacheKey(id), cacheStrategy: cacheStrategy }, (scrollableTargetId && { getScrollableContainer: () => document.getElementById(scrollableTargetId) }), VirtualizedScrollerProps))] })) })), feedDataRight.length > 0 && !hideAdvs && ((0, jsx_runtime_1.jsx)(material_1.Hidden, Object.assign({ smDown: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Grid, Object.assign({ item: true, xs: 12, md: 5 }, { children: (0, jsx_runtime_1.jsx)(StickyBox_1.default, Object.assign({ className: classes.right }, FeedSidebarProps, { children: (0, jsx_runtime_1.jsx)(react_1.default.Suspense, Object.assign({ fallback: (0, jsx_runtime_1.jsx)(Skeleton_1.GenericSkeleton, {}) }, { children: feedDataRight.map((d, i) => ((0, jsx_runtime_1.jsx)(d.component, Object.assign({}, d.componentProps), i))) })) })) })) })))] })));
|
|
415
423
|
};
|
|
416
424
|
exports.default = (0, react_1.forwardRef)(Feed);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { IconButtonProps } from '@mui/material';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
export interface GroupActionsMenuProps extends IconButtonProps {
|
|
4
|
+
/**
|
|
5
|
+
* Overrides or extends the styles applied to the component.
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The group
|
|
11
|
+
*/
|
|
12
|
+
group: SCGroupType;
|
|
13
|
+
/**
|
|
14
|
+
* The group id
|
|
15
|
+
*/
|
|
16
|
+
groupId?: number;
|
|
17
|
+
/**
|
|
18
|
+
* Handles callback on delete confirm
|
|
19
|
+
*/
|
|
20
|
+
onDeleteConfirm?: () => void;
|
|
21
|
+
/**
|
|
22
|
+
* Handles on edit success
|
|
23
|
+
*/
|
|
24
|
+
onEditSuccess?: (data: SCGroupType) => any;
|
|
25
|
+
/**
|
|
26
|
+
* Any other properties
|
|
27
|
+
*/
|
|
28
|
+
[p: string]: any;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* > API documentation for the Community-JS GroupActionsMenu component. Learn about the available props and the CSS API.
|
|
32
|
+
|
|
33
|
+
#### Import
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
import {GroupActionsMenu} from '@selfcommunity/react-ui';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### Component Name
|
|
40
|
+
|
|
41
|
+
The name `SCGroupActionsMenu` can be used when providing style overrides in the theme.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
#### CSS
|
|
45
|
+
|
|
46
|
+
|Rule Name|Global class|Description|
|
|
47
|
+
|---|---|---|
|
|
48
|
+
|root|.SCGroupActionsMenu-root|Styles applied to the root element.|
|
|
49
|
+
|drawerRoot|.SCGroupActionsMenu-drawer-root|Styles applied to the drawer root element.|
|
|
50
|
+
|menuRoot|.SCGroupActionsMenu-menu-root|Styles applied to the menu root element.|
|
|
51
|
+
|paper|.SCGroupActionsMenu-paper|Styles applied to the paper element.|
|
|
52
|
+
|item|.SCGroupActionsMenu-item|Styles applied to the item element.|
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
* @param inProps
|
|
56
|
+
*/
|
|
57
|
+
export default function GroupActionsMenu(inProps: GroupActionsMenuProps): JSX.Element;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
const material_1 = require("@mui/material");
|
|
8
|
+
const react_intl_1 = require("react-intl");
|
|
9
|
+
const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
|
|
10
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
11
|
+
const system_1 = require("@mui/system");
|
|
12
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
13
|
+
const ConfirmDialog_1 = tslib_1.__importDefault(require("../../shared/ConfirmDialog/ConfirmDialog"));
|
|
14
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
15
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
16
|
+
const notistack_1 = require("notistack");
|
|
17
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
18
|
+
const PubSub_1 = require("../../constants/PubSub");
|
|
19
|
+
const GroupForm_1 = tslib_1.__importDefault(require("../../components/GroupForm"));
|
|
20
|
+
const GroupActionsMenu_1 = require("../../constants/GroupActionsMenu");
|
|
21
|
+
const PREFIX = 'SCGroupActionsMenu';
|
|
22
|
+
const classes = {
|
|
23
|
+
root: `${PREFIX}-root`,
|
|
24
|
+
drawerRoot: `${PREFIX}-drawer-root`,
|
|
25
|
+
menuRoot: `${PREFIX}-menu-root`,
|
|
26
|
+
paper: `${PREFIX}-paper`,
|
|
27
|
+
item: `${PREFIX}-item`
|
|
28
|
+
};
|
|
29
|
+
const Root = (0, styles_1.styled)(material_1.IconButton, {
|
|
30
|
+
name: PREFIX,
|
|
31
|
+
slot: 'Root'
|
|
32
|
+
})(() => ({}));
|
|
33
|
+
const SwipeableDrawerRoot = (0, styles_1.styled)(material_1.SwipeableDrawer, {
|
|
34
|
+
name: PREFIX,
|
|
35
|
+
slot: 'DrawerRoot'
|
|
36
|
+
})(() => ({}));
|
|
37
|
+
const MenuRoot = (0, styles_1.styled)(material_1.Menu, {
|
|
38
|
+
name: PREFIX,
|
|
39
|
+
slot: 'MenuRoot'
|
|
40
|
+
})(() => ({}));
|
|
41
|
+
/**
|
|
42
|
+
* > API documentation for the Community-JS GroupActionsMenu component. Learn about the available props and the CSS API.
|
|
43
|
+
|
|
44
|
+
#### Import
|
|
45
|
+
|
|
46
|
+
```jsx
|
|
47
|
+
import {GroupActionsMenu} from '@selfcommunity/react-ui';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Component Name
|
|
51
|
+
|
|
52
|
+
The name `SCGroupActionsMenu` can be used when providing style overrides in the theme.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
#### CSS
|
|
56
|
+
|
|
57
|
+
|Rule Name|Global class|Description|
|
|
58
|
+
|---|---|---|
|
|
59
|
+
|root|.SCGroupActionsMenu-root|Styles applied to the root element.|
|
|
60
|
+
|drawerRoot|.SCGroupActionsMenu-drawer-root|Styles applied to the drawer root element.|
|
|
61
|
+
|menuRoot|.SCGroupActionsMenu-menu-root|Styles applied to the menu root element.|
|
|
62
|
+
|paper|.SCGroupActionsMenu-paper|Styles applied to the paper element.|
|
|
63
|
+
|item|.SCGroupActionsMenu-item|Styles applied to the item element.|
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
* @param inProps
|
|
67
|
+
*/
|
|
68
|
+
function GroupActionsMenu(inProps) {
|
|
69
|
+
var _a;
|
|
70
|
+
// PROPS
|
|
71
|
+
const props = (0, system_1.useThemeProps)({
|
|
72
|
+
props: inProps,
|
|
73
|
+
name: PREFIX
|
|
74
|
+
});
|
|
75
|
+
const { className, group, groupId, onDeleteConfirm, onEditSuccess } = props, rest = tslib_1.__rest(props, ["className", "group", "groupId", "onDeleteConfirm", "onEditSuccess"]);
|
|
76
|
+
// STATE
|
|
77
|
+
const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
|
|
78
|
+
const [openConfirmDialog, setOpenConfirmDialog] = (0, react_1.useState)(false);
|
|
79
|
+
const [openEdit, setOpenEdit] = (0, react_1.useState)(false);
|
|
80
|
+
// HOOKS
|
|
81
|
+
const theme = (0, material_1.useTheme)();
|
|
82
|
+
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
83
|
+
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
84
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
85
|
+
const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
86
|
+
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]);
|
|
87
|
+
// HANDLERS
|
|
88
|
+
const handleOpen = (group) => {
|
|
89
|
+
setAnchorEl(group.currentTarget);
|
|
90
|
+
};
|
|
91
|
+
const handleClose = () => {
|
|
92
|
+
setAnchorEl(null);
|
|
93
|
+
};
|
|
94
|
+
const handleEditClick = () => {
|
|
95
|
+
setOpenEdit((o) => !o);
|
|
96
|
+
};
|
|
97
|
+
const handleCloseDialog = () => {
|
|
98
|
+
setOpenConfirmDialog(false);
|
|
99
|
+
setAnchorEl(null);
|
|
100
|
+
};
|
|
101
|
+
const handleEditSuccess = (data) => {
|
|
102
|
+
setSCGroup(data);
|
|
103
|
+
onEditSuccess && onEditSuccess(data);
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Handles thread deletion
|
|
107
|
+
*/
|
|
108
|
+
function handleDeleteThread() {
|
|
109
|
+
api_services_1.GroupService.deleteGroup(scGroup.id)
|
|
110
|
+
.then(() => {
|
|
111
|
+
onDeleteConfirm();
|
|
112
|
+
handleCloseDialog();
|
|
113
|
+
pubsub_js_1.default.publish(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.DELETE}`, scGroup.id);
|
|
114
|
+
})
|
|
115
|
+
.catch((error) => {
|
|
116
|
+
setOpenConfirmDialog(false);
|
|
117
|
+
console.log(error);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Handles actions
|
|
122
|
+
*/
|
|
123
|
+
function handleAction(action) {
|
|
124
|
+
if (action === GroupActionsMenu_1.GET_GROUP_LINK) {
|
|
125
|
+
(0, utils_1.copyTextToClipboard)(`${location.protocol}//${location.host}${scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup)}`).then(() => {
|
|
126
|
+
(0, notistack_1.enqueueSnackbar)((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.common.permanentLinkCopied", defaultMessage: "ui.common.permanentLinkCopied" }), {
|
|
127
|
+
variant: 'success',
|
|
128
|
+
autoHideDuration: 3000
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
handleClose();
|
|
132
|
+
}
|
|
133
|
+
else if (action === GroupActionsMenu_1.DELETE_GROUP) {
|
|
134
|
+
setOpenConfirmDialog(true);
|
|
135
|
+
handleClose();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
const renderList = () => {
|
|
142
|
+
return [
|
|
143
|
+
(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(GroupActionsMenu_1.GET_GROUP_LINK) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "link" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.item.link", defaultMessage: "ui.groupActionsMenu.item.link" })] }), "link"),
|
|
144
|
+
isGroupAdmin &&
|
|
145
|
+
scGroup.active && [
|
|
146
|
+
(0, jsx_runtime_1.jsx)(material_1.Divider, {}, "divider"),
|
|
147
|
+
isMobile && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: handleEditClick }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "edit" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.item.edit", defaultMessage: "ui.groupActionsMenu.item.edit" })] }), "edit")),
|
|
148
|
+
(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(GroupActionsMenu_1.DELETE_GROUP) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "delete" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.item.delete", defaultMessage: "ui.groupActionsMenu.item.delete" })] }), "delete")
|
|
149
|
+
]
|
|
150
|
+
];
|
|
151
|
+
};
|
|
152
|
+
if (!scGroup) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { onClick: handleOpen }, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "more_vert" }) })), isMobile ? ((0, jsx_runtime_1.jsx)(SwipeableDrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "bottom", open: Boolean(anchorEl), onClose: handleClose, onOpen: handleOpen, PaperProps: { className: classes.paper }, disableSwipeToOpen: true }, { children: (0, jsx_runtime_1.jsx)(material_1.List, { children: renderList() }) }))) : ((0, jsx_runtime_1.jsx)(MenuRoot, Object.assign({ className: classes.menuRoot, anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleClose, PaperProps: { className: classes.paper } }, { children: renderList() }))), openConfirmDialog && ((0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, { open: openConfirmDialog, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.dialog.msg", defaultMessage: "ui.groupActionsMenu.dialog.msg" }), btnConfirm: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupActionsMenu.dialog.confirm", defaultMessage: "ui.groupActionsMenu.dialog.confirm" }), onConfirm: handleDeleteThread, onClose: handleCloseDialog })), openEdit && (0, jsx_runtime_1.jsx)(GroupForm_1.default, { onClose: handleEditClick, group: scGroup, onSuccess: handleEditSuccess })] }));
|
|
156
|
+
}
|
|
157
|
+
exports.default = GroupActionsMenu;
|
|
@@ -3,6 +3,7 @@ import { ChangeGroupCoverProps } from '../ChangeGroupCover';
|
|
|
3
3
|
import { ChangeGroupPictureProps } from '../ChangeGroupPicture';
|
|
4
4
|
import { GroupMembersButtonProps } from '../GroupMembersButton';
|
|
5
5
|
import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
|
|
6
|
+
import { GroupActionsMenuProps } from '../GroupActionsMenu';
|
|
6
7
|
export interface GroupHeaderProps {
|
|
7
8
|
/**
|
|
8
9
|
* Id of group object
|
|
@@ -44,6 +45,11 @@ export interface GroupHeaderProps {
|
|
|
44
45
|
* @default {}
|
|
45
46
|
*/
|
|
46
47
|
GroupMembersButtonProps?: GroupMembersButtonProps;
|
|
48
|
+
/**
|
|
49
|
+
* Props to spread event actions menu
|
|
50
|
+
* @default {}
|
|
51
|
+
*/
|
|
52
|
+
GroupActionsProps?: Omit<GroupActionsMenuProps, 'group'>;
|
|
47
53
|
/**
|
|
48
54
|
* Any other properties
|
|
49
55
|
*/
|
|
@@ -21,6 +21,7 @@ const GroupSubscribeButton_1 = tslib_1.__importDefault(require("../GroupSubscrib
|
|
|
21
21
|
const GroupInviteButton_1 = tslib_1.__importDefault(require("../GroupInviteButton"));
|
|
22
22
|
const PubSub_1 = require("../../constants/PubSub");
|
|
23
23
|
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
24
|
+
const GroupActionsMenu_1 = tslib_1.__importDefault(require("../GroupActionsMenu"));
|
|
24
25
|
const classes = {
|
|
25
26
|
root: `${constants_1.PREFIX}-root`,
|
|
26
27
|
cover: `${constants_1.PREFIX}-cover`,
|
|
@@ -32,7 +33,8 @@ const classes = {
|
|
|
32
33
|
visibility: `${constants_1.PREFIX}-visibility`,
|
|
33
34
|
visibilityItem: `${constants_1.PREFIX}-visibility-item`,
|
|
34
35
|
members: `${constants_1.PREFIX}-members`,
|
|
35
|
-
membersCounter: `${constants_1.PREFIX}-members-counter
|
|
36
|
+
membersCounter: `${constants_1.PREFIX}-members-counter`,
|
|
37
|
+
multiActions: `${constants_1.PREFIX}-multi-actions`
|
|
36
38
|
};
|
|
37
39
|
const Root = (0, styles_1.styled)(material_1.Box, {
|
|
38
40
|
name: constants_1.PREFIX,
|
|
@@ -76,7 +78,7 @@ function GroupHeader(inProps) {
|
|
|
76
78
|
props: inProps,
|
|
77
79
|
name: constants_1.PREFIX
|
|
78
80
|
});
|
|
79
|
-
const { id = null, className = null, group, groupId = null, ChangePictureProps = {}, ChangeCoverProps = {}, GroupSubscribeButtonProps = {}, GroupMembersButtonProps = {} } = props, rest = tslib_1.__rest(props, ["id", "className", "group", "groupId", "ChangePictureProps", "ChangeCoverProps", "GroupSubscribeButtonProps", "GroupMembersButtonProps"]);
|
|
81
|
+
const { id = null, className = null, group, groupId = null, ChangePictureProps = {}, ChangeCoverProps = {}, GroupSubscribeButtonProps = {}, GroupMembersButtonProps = {}, GroupActionsProps } = props, rest = tslib_1.__rest(props, ["id", "className", "group", "groupId", "ChangePictureProps", "ChangeCoverProps", "GroupSubscribeButtonProps", "GroupMembersButtonProps", "GroupActionsProps"]);
|
|
80
82
|
// PREFERENCES
|
|
81
83
|
const scPreferences = (0, react_core_1.useSCPreferences)();
|
|
82
84
|
const visibilityEnabled = (0, react_1.useMemo)(() => scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_VISIBILITY_ENABLED].value, [scPreferences.preferences]);
|
|
@@ -85,6 +87,8 @@ function GroupHeader(inProps) {
|
|
|
85
87
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
86
88
|
// HOOKS
|
|
87
89
|
const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
90
|
+
const theme = (0, material_1.useTheme)();
|
|
91
|
+
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
88
92
|
// REFS
|
|
89
93
|
const updatesSubscription = (0, react_1.useRef)(null);
|
|
90
94
|
// CONST
|
|
@@ -147,8 +151,8 @@ function GroupHeader(inProps) {
|
|
|
147
151
|
const _backgroundCover = Object.assign({}, (scGroup.emotional_image
|
|
148
152
|
? { background: `url('${scGroup.emotional_image}') center / cover` }
|
|
149
153
|
: { background: `url('${scPreferences.preferences[react_core_1.SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
|
|
150
|
-
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.avatar }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { children: (0, jsx_runtime_1.jsx)("img", { alt: "group", src: scGroup.image_big ? scGroup.image_big : '' }) }) })), isGroupAdmin && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ChangeGroupPicture_1.default, Object.assign({ groupId: scGroup.id, onChange: handleChangeAvatar, className: classes.changePicture }, ChangePictureProps)), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.changeCover }, { children: (0, jsx_runtime_1.jsx)(ChangeGroupCover_1.default, Object.assign({ groupId: scGroup.id, onChange: handleChangeCover }, ChangeCoverProps)) }))] }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.info }, { children: [isGroupAdmin && (0, jsx_runtime_1.jsx)(EditGroupButton_1.default, { group: scGroup, groupId: scGroup.id, onEditSuccess: (data) => setSCGroup(data) }), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scGroup.name })), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [privateEnabled && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.public", defaultMessage: "ui.groupHeader.visibility.public" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.private", defaultMessage: "ui.groupHeader.visibility.private" })] }))) })), visibilityEnabled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [privateEnabled && (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), scGroup.visible ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "visibility" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.visible", defaultMessage: "ui.groupHeader.visibility.visible" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "visibility_off" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.hidden", defaultMessage: "ui.groupHeader.visibility.hidden" })] })))] }))] }))), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: ((scGroup && scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC) ||
|
|
154
|
+
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.avatar }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { children: (0, jsx_runtime_1.jsx)("img", { alt: "group", src: scGroup.image_big ? scGroup.image_big : '' }) }) })), isGroupAdmin && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ChangeGroupPicture_1.default, Object.assign({ groupId: scGroup.id, onChange: handleChangeAvatar, className: classes.changePicture }, ChangePictureProps)), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.changeCover }, { children: (0, jsx_runtime_1.jsx)(ChangeGroupCover_1.default, Object.assign({ groupId: scGroup.id, onChange: handleChangeCover }, ChangeCoverProps)) }))] }))] })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.info }, { children: [isGroupAdmin && !isMobile && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.multiActions }, { children: [(0, jsx_runtime_1.jsx)(EditGroupButton_1.default, { group: scGroup, groupId: scGroup.id, onEditSuccess: (data) => setSCGroup(data) }), (0, jsx_runtime_1.jsx)(GroupActionsMenu_1.default, Object.assign({ group: scGroup, onEditSuccess: (data) => setSCGroup(data) }, GroupActionsProps))] }))), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5", className: classes.name }, { children: scGroup.name })), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.visibility }, { children: [privateEnabled && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.public", defaultMessage: "ui.groupHeader.visibility.public" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.private", defaultMessage: "ui.groupHeader.visibility.private" })] }))) })), visibilityEnabled && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [privateEnabled && (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), scGroup.visible ? ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "visibility" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.visible", defaultMessage: "ui.groupHeader.visibility.visible" })] }))) : ((0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: classes.visibilityItem }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "visibility_off" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.visibility.hidden", defaultMessage: "ui.groupHeader.visibility.hidden" })] })))] }))] }))), (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: ((scGroup && scGroup.privacy === types_1.SCGroupPrivacyType.PUBLIC) ||
|
|
151
155
|
scGroup.subscription_status === types_1.SCGroupSubscriptionStatusType.SUBSCRIBED ||
|
|
152
|
-
isGroupAdmin) && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.members }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.membersCounter, component: "div" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } }) })), (0, jsx_runtime_1.jsx)(GroupMembersButton_1.default, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps), scGroup.subscribers_counter)] }))) }), isGroupAdmin ? ((0, jsx_runtime_1.jsx)(GroupInviteButton_1.default, { group: scGroup, groupId: scGroup.id })) : ((0, jsx_runtime_1.jsx)(GroupSubscribeButton_1.default, Object.assign({ group: scGroup, onSubscribe: handleSubscribe }, GroupSubscribeButtonProps)))] }))] })));
|
|
156
|
+
isGroupAdmin) && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.members }, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.membersCounter, component: "div" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } }) })), (0, jsx_runtime_1.jsx)(GroupMembersButton_1.default, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps), scGroup.subscribers_counter)] }))) }), isGroupAdmin ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(GroupInviteButton_1.default, { group: scGroup, groupId: scGroup.id }), isMobile && (0, jsx_runtime_1.jsx)(GroupActionsMenu_1.default, Object.assign({ group: scGroup, onEditSuccess: (data) => setSCGroup(data) }, GroupActionsProps))] })) : ((0, jsx_runtime_1.jsx)(GroupSubscribeButton_1.default, Object.assign({ group: scGroup, onSubscribe: handleSubscribe }, GroupSubscribeButtonProps)))] }))] })));
|
|
153
157
|
}
|
|
154
158
|
exports.default = GroupHeader;
|
|
@@ -18,6 +18,8 @@ const constants_1 = require("./constants");
|
|
|
18
18
|
const Group_1 = tslib_1.__importStar(require("../Group"));
|
|
19
19
|
const Pagination_1 = require("../../constants/Pagination");
|
|
20
20
|
const InfiniteScroll_1 = tslib_1.__importDefault(require("../../shared/InfiniteScroll"));
|
|
21
|
+
const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
|
|
22
|
+
const PubSub_1 = require("../../constants/PubSub");
|
|
21
23
|
const classes = {
|
|
22
24
|
root: `${constants_1.PREFIX}-root`,
|
|
23
25
|
filters: `${constants_1.PREFIX}-filter`,
|
|
@@ -85,6 +87,8 @@ function Groups(inProps) {
|
|
|
85
87
|
scPreferencesContext.preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value, [scPreferencesContext.preferences]);
|
|
86
88
|
// CONST
|
|
87
89
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
90
|
+
// REFS
|
|
91
|
+
const updatesSubscription = (0, react_1.useRef)(null);
|
|
88
92
|
// HANDLERS
|
|
89
93
|
const handleScrollUp = () => {
|
|
90
94
|
window.scrollTo({ left: 0, top: 0, behavior: 'smooth' });
|
|
@@ -121,6 +125,28 @@ function Groups(inProps) {
|
|
|
121
125
|
fetchGroups();
|
|
122
126
|
}
|
|
123
127
|
}, [contentAvailability, authUserId, search]);
|
|
128
|
+
/**
|
|
129
|
+
* Subscriber for pubsub callback
|
|
130
|
+
*/
|
|
131
|
+
const onDeleteGroupHandler = (0, react_1.useCallback)((_msg, deleted) => {
|
|
132
|
+
setGroups((prev) => {
|
|
133
|
+
if (prev.some((e) => e.id === deleted)) {
|
|
134
|
+
return prev.filter((e) => e.id !== deleted);
|
|
135
|
+
}
|
|
136
|
+
return prev;
|
|
137
|
+
});
|
|
138
|
+
}, [groups]);
|
|
139
|
+
/**
|
|
140
|
+
* On mount, subscribe to receive event updates (only delete)
|
|
141
|
+
*/
|
|
142
|
+
(0, react_1.useEffect)(() => {
|
|
143
|
+
if (groups) {
|
|
144
|
+
updatesSubscription.current = pubsub_js_1.default.subscribe(`${PubSub_1.SCTopicType.GROUP}.${PubSub_1.SCGroupEventType.DELETE}`, onDeleteGroupHandler);
|
|
145
|
+
}
|
|
146
|
+
return () => {
|
|
147
|
+
updatesSubscription.current && pubsub_js_1.default.unsubscribe(updatesSubscription.current);
|
|
148
|
+
};
|
|
149
|
+
}, [groups]);
|
|
124
150
|
const handleNext = (0, react_1.useMemo)(() => () => {
|
|
125
151
|
if (!next) {
|
|
126
152
|
return;
|
|
@@ -66,8 +66,12 @@ function MyEventsWidget(inProps) {
|
|
|
66
66
|
// CONTEXT
|
|
67
67
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
68
68
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
69
|
-
const { features } = (0, react_core_1.useSCPreferences)();
|
|
70
|
-
const eventsEnabled = (0, react_1.useMemo)(() =>
|
|
69
|
+
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
70
|
+
const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
71
|
+
features &&
|
|
72
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
73
|
+
react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
74
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
71
75
|
// REFS
|
|
72
76
|
const updatesSubscription = (0, react_1.useRef)(null);
|
|
73
77
|
/**
|
|
@@ -110,12 +110,21 @@ function NavigationToolbar(inProps) {
|
|
|
110
110
|
return _preferences;
|
|
111
111
|
}, [scPreferences.preferences]);
|
|
112
112
|
const privateMessagingEnabled = (0, react_1.useMemo)(() => scPreferences.features.includes(types_1.SCFeatureName.PRIVATE_MESSAGING), [scPreferences.features]);
|
|
113
|
-
const groupsEnabled = (0, react_1.useMemo)(() => scPreferences.
|
|
114
|
-
|
|
113
|
+
const groupsEnabled = (0, react_1.useMemo)(() => scPreferences.preferences &&
|
|
114
|
+
scPreferences.features &&
|
|
115
|
+
scPreferences.features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
116
|
+
scPreferences.features.includes(types_1.SCFeatureName.GROUPING) &&
|
|
117
|
+
react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in scPreferences.preferences &&
|
|
118
|
+
scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
|
|
119
|
+
const eventsEnabled = (0, react_1.useMemo)(() => scPreferences.preferences &&
|
|
120
|
+
scPreferences.features &&
|
|
121
|
+
scPreferences.features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
122
|
+
react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in scPreferences.preferences &&
|
|
123
|
+
scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
|
|
115
124
|
const showComposer = (0, react_1.useMemo)(() => {
|
|
116
125
|
return (!disableComposer &&
|
|
117
126
|
(!scPreferences.preferences[react_core_1.SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value || react_core_1.UserUtils.isStaff(scUserContext.user)));
|
|
118
|
-
}, [
|
|
127
|
+
}, [preferences, disableComposer, scUserContext.user]);
|
|
119
128
|
// STATE
|
|
120
129
|
const [anchorNotification, setAnchorNotification] = react_1.default.useState(null);
|
|
121
130
|
// HANDLERS
|
|
@@ -80,8 +80,17 @@ function NavigationToolbarMobile(inProps) {
|
|
|
80
80
|
// STATE
|
|
81
81
|
const [searchOpen, setSearchOpen] = (0, react_1.useState)(false);
|
|
82
82
|
// MEMO
|
|
83
|
-
const groupsEnabled = (0, react_1.useMemo)(() =>
|
|
84
|
-
|
|
83
|
+
const groupsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
84
|
+
features &&
|
|
85
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
86
|
+
features.includes(types_1.SCFeatureName.GROUPING) &&
|
|
87
|
+
react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
88
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
89
|
+
const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
90
|
+
features &&
|
|
91
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
92
|
+
react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
93
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
85
94
|
const exploreStreamEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
86
95
|
const postOnlyStaffEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
|
|
87
96
|
const contentAvailable = preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
@@ -53,6 +53,8 @@ function EventNotification(props) {
|
|
|
53
53
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }) })) })), primary: (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
54
54
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
55
55
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.event.${notificationObject.type}`, defaultMessage: `ui.notification.event.${notificationObject.type}`, values: {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
57
|
+
// @ts-ignore
|
|
56
58
|
icon: (...chunks) => (0, jsx_runtime_1.jsx)(material_1.Icon, { children: chunks }),
|
|
57
59
|
event: notificationObject.event.name,
|
|
58
60
|
link: (...chunks) => (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|
|
@@ -71,6 +73,8 @@ function EventNotification(props) {
|
|
|
71
73
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, { className: classes.avatar, alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar }) })) })), primary: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
72
74
|
to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
73
75
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
77
|
+
// @ts-ignore
|
|
74
78
|
icon: (...chunks) => (0, jsx_runtime_1.jsx)(material_1.Icon, { children: chunks }),
|
|
75
79
|
event: notificationObject.event.name,
|
|
76
80
|
link: (...chunks) => (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|