@selfcommunity/react-ui 0.8.0-alpha.8 → 0.8.0-embeds.16
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 +8 -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/EventForm.js +10 -3
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +24 -1
- 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/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +7 -2
- package/lib/cjs/shared/ContributionActionsMenu/index.js +6 -6
- package/lib/cjs/shared/Media/Link/DisplayComponent.js +2 -2
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +11 -2
- package/lib/esm/components/Composer/Composer.js +8 -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/EventForm.js +10 -3
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +25 -2
- 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/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +8 -3
- package/lib/esm/shared/ContributionActionsMenu/index.js +6 -6
- package/lib/esm/shared/Media/Link/DisplayComponent.js +2 -2
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
|
@@ -63,8 +63,17 @@ function BottomNavigation(inProps) {
|
|
|
63
63
|
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
64
64
|
// MEMO
|
|
65
65
|
const privateMessagingEnabled = (0, react_1.useMemo)(() => features.includes(types_1.SCFeatureName.PRIVATE_MESSAGING), [features]);
|
|
66
|
-
const groupsEnabled = (0, react_1.useMemo)(() =>
|
|
67
|
-
|
|
66
|
+
const groupsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
67
|
+
features &&
|
|
68
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
69
|
+
features.includes(types_1.SCFeatureName.GROUPING) &&
|
|
70
|
+
react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
71
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
72
|
+
const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
73
|
+
features &&
|
|
74
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
75
|
+
react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
76
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
68
77
|
const exploreStreamEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
69
78
|
const postOnlyStaffEnabled = preferences[react_core_1.SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
|
|
70
79
|
const contentAvailable = preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
@@ -430,10 +430,16 @@ function Composer(inProps) {
|
|
|
430
430
|
if (features.includes(types_1.SCFeatureName.TAGGING) && addressing !== null) {
|
|
431
431
|
data.addressing = addressing.map((t) => t.id);
|
|
432
432
|
}
|
|
433
|
-
if (features.includes(types_1.SCFeatureName.
|
|
433
|
+
if (features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
434
|
+
features.includes(types_1.SCFeatureName.GROUPING) &&
|
|
435
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value &&
|
|
436
|
+
group !== null) {
|
|
434
437
|
data.group = group.id;
|
|
435
438
|
}
|
|
436
|
-
if (features.includes(types_1.SCFeatureName.
|
|
439
|
+
if (features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
440
|
+
features.includes(types_1.SCFeatureName.EVENT) &&
|
|
441
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value &&
|
|
442
|
+
event !== null) {
|
|
437
443
|
data.event = event.id;
|
|
438
444
|
}
|
|
439
445
|
setIsSubmitting(true);
|
|
@@ -60,10 +60,19 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
|
|
|
60
60
|
const [value, setValue] = (0, react_1.useState)(defaultValue || undefined);
|
|
61
61
|
// HOOKS
|
|
62
62
|
const { scAddressingTags } = (0, react_core_1.useSCFetchAddressingTagList)({ fetch: autocompleteOpen });
|
|
63
|
-
const { features } = (0, react_core_1.useSCPreferences)();
|
|
63
|
+
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
64
64
|
// MEMO
|
|
65
|
-
const
|
|
66
|
-
|
|
65
|
+
const groupsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
66
|
+
features &&
|
|
67
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
68
|
+
features.includes(types_1.SCFeatureName.GROUPING) &&
|
|
69
|
+
react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
70
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
71
|
+
const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
72
|
+
features &&
|
|
73
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
74
|
+
react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
75
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
67
76
|
// HANDLERS
|
|
68
77
|
const handleSave = (0, react_1.useCallback)(() => {
|
|
69
78
|
audience === AudienceTypes.AUDIENCE_GROUP || audience === AudienceTypes.AUDIENCE_EVENT
|
|
@@ -54,7 +54,11 @@ function CreateEventButton(inProps) {
|
|
|
54
54
|
// CONST
|
|
55
55
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
56
56
|
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
57
|
-
const eventsEnabled = (0, react_1.useMemo)(() =>
|
|
57
|
+
const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
58
|
+
features &&
|
|
59
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
60
|
+
react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
61
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
58
62
|
const onlyStaffEnabled = (0, react_1.useMemo)(() => preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED].value, [preferences]);
|
|
59
63
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
60
64
|
// @ts-ignore
|
|
@@ -40,7 +40,11 @@ function CreateEventWidget(inProps) {
|
|
|
40
40
|
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
41
41
|
// HOOK
|
|
42
42
|
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
43
|
-
const eventsEnabled = (0, react_1.useMemo)(() =>
|
|
43
|
+
const eventsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
44
|
+
features &&
|
|
45
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
46
|
+
react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
47
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
44
48
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
45
49
|
const onlyStaffEnabled = (0, react_1.useMemo)(() => preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED].value, [preferences]);
|
|
46
50
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
@@ -254,6 +254,10 @@ function EventForm(inProps) {
|
|
|
254
254
|
delete error[`${name}Error`];
|
|
255
255
|
setError(error);
|
|
256
256
|
}
|
|
257
|
+
else if (error['endDateError']) {
|
|
258
|
+
delete error['endDateError'];
|
|
259
|
+
setError(error);
|
|
260
|
+
}
|
|
257
261
|
}, [error]);
|
|
258
262
|
const shouldDisabledDate = (0, react_1.useCallback)((date) => {
|
|
259
263
|
let disabled = false;
|
|
@@ -313,11 +317,14 @@ function EventForm(inProps) {
|
|
|
313
317
|
return (0, jsx_runtime_1.jsx)("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
|
|
314
318
|
}
|
|
315
319
|
return ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
|
|
316
|
-
}, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "frequency" }) }) })) }, { children: Object.values(types_1.SCEventRecurrenceType).map((f) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: f }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
|
|
320
|
+
}, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "frequency" }) }) })) }, { children: Object.values(types_1.SCEventRecurrenceType).map((f) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: f }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, minDate: field.startDate, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
|
|
317
321
|
textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "calendar_off" }) }) }))) }) })))
|
|
318
322
|
}, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisabledDate }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
|
|
319
|
-
textField: (params) =>
|
|
320
|
-
|
|
323
|
+
textField: (params) => {
|
|
324
|
+
var _a;
|
|
325
|
+
return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
|
|
326
|
+
}
|
|
327
|
+
}, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
|
|
321
328
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
322
329
|
// @ts-ignore
|
|
323
330
|
b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
|
|
@@ -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, {});
|
|
@@ -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 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;
|
|
@@ -73,8 +73,13 @@ function UserSubscribedGroupsWidget(inProps) {
|
|
|
73
73
|
// CONTEXT
|
|
74
74
|
const scUserContext = (0, react_core_1.useSCUser)();
|
|
75
75
|
const isMe = (0, react_1.useMemo)(() => scUserContext.user && userId === scUserContext.user.id, [scUserContext.user, userId]);
|
|
76
|
-
const { features } = (0, react_core_1.useSCPreferences)();
|
|
77
|
-
const groupsEnabled = (0, react_1.useMemo)(() =>
|
|
76
|
+
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
77
|
+
const groupsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
78
|
+
features &&
|
|
79
|
+
features.includes(types_1.SCFeatureName.TAGGING) &&
|
|
80
|
+
features.includes(types_1.SCFeatureName.GROUPING) &&
|
|
81
|
+
react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
82
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
78
83
|
// STATE
|
|
79
84
|
const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
|
|
80
85
|
isLoadingNext: false,
|
|
@@ -77,7 +77,6 @@ const messages = (0, react_intl_1.defineMessages)({
|
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
function ContributionActionsMenu(props) {
|
|
80
|
-
var _a, _b, _c;
|
|
81
80
|
// PROPS
|
|
82
81
|
const { className, feedObjectId, feedObject, feedObjectType = types_1.SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, onSuspendNotificationEvent, PopperProps = {} } = props, rest = tslib_1.__rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "onSuspendNotificationEvent", "PopperProps"]);
|
|
83
82
|
// INTL
|
|
@@ -624,9 +623,9 @@ function ContributionActionsMenu(props) {
|
|
|
624
623
|
return name;
|
|
625
624
|
}
|
|
626
625
|
/**
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
626
|
+
* action
|
|
627
|
+
* @param sectionId
|
|
628
|
+
*/
|
|
630
629
|
function handleOpenSection(sectionId) {
|
|
631
630
|
if (sectionId) {
|
|
632
631
|
if (sectionId === openSection) {
|
|
@@ -705,7 +704,8 @@ function ContributionActionsMenu(props) {
|
|
|
705
704
|
scUserContext.user.id !== contributionObj.author.id &&
|
|
706
705
|
contributionObj &&
|
|
707
706
|
contributionObj.type !== types_1.SCContributionType.COMMENT &&
|
|
708
|
-
Boolean(contributionObj.event)
|
|
707
|
+
Boolean(contributionObj.event) &&
|
|
708
|
+
Boolean(contributionObj.event.active));
|
|
709
709
|
}
|
|
710
710
|
/**
|
|
711
711
|
* Renders section general
|
|
@@ -728,7 +728,7 @@ function ContributionActionsMenu(props) {
|
|
|
728
728
|
, Object.assign({
|
|
729
729
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
730
730
|
// @ts-ignore
|
|
731
|
-
|
|
731
|
+
ref: (ref) => {
|
|
732
732
|
popperRef.current = ref;
|
|
733
733
|
}, "aria-haspopup": "true", onClick: handleOpen, className: classes.button, size: "small" }, { children: contributionObj && (contributionObj.collapsed || contributionObj.deleted) ? ((0, jsx_runtime_1.jsxs)("span", Object.assign({ className: classes.visibilityIcons }, { children: [contributionObj.collapsed ? (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "visibility_off" }) : (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "delete" }), (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "expand_more" })] }))) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "more_vert" })) })), isMobile ? ((0, jsx_runtime_1.jsx)(material_1.SwipeableDrawer, Object.assign({ open: open, onClose: handleClose, onOpen: handleOpen, anchor: "bottom", disableSwipeToOpen: true }, { children: renderContent() }))) : ((0, jsx_runtime_1.jsx)(PopperRoot, Object.assign({ open: open, anchorEl: popperRef.current, role: undefined, transition: true, className: classes.popperRoot }, PopperProps, { placement: "bottom-end" }, { children: ({ TransitionProps, placement }) => ((0, jsx_runtime_1.jsx)(material_1.Grow, Object.assign({}, TransitionProps, { style: { transformOrigin: placement === 'bottom' ? 'center top' : 'center bottom' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ variant: 'outlined', className: classes.paper }, { children: (0, jsx_runtime_1.jsx)(material_1.ClickAwayListener, Object.assign({ onClickAway: handleClose }, { children: renderContent() })) })) }))) }))), openConfirmDialog && ((0, jsx_runtime_1.jsx)(ConfirmDialog_1.default, Object.assign({ open: openConfirmDialog }, (currentAction === ContributionsActionsMenu_1.DELETE_CONTRIBUTION
|
|
734
734
|
? {
|
|
@@ -53,7 +53,7 @@ exports.default = (props) => {
|
|
|
53
53
|
return renderHtml(media, key);
|
|
54
54
|
}
|
|
55
55
|
const domain = new URL(media.embed.metadata.url).hostname.replace('www.', '');
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayLink }, { children: [media.embed.metadata.images && media.embed.metadata.images.length > 0 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fullWidth ? ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnailFullWidth, classes.image), style: { background: `url(${media.image})`, paddingBottom: `${100 / media.image_width / media.image_height}%` } })) : ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnail, classes.image), style: { background: `url(${media.image})` } })) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.snippet }, { children: [(0, jsx_runtime_1.jsx)("b", Object.assign({ className: classes.snippetTitle }, { children: media.embed.metadata.title })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: classes.snippetDescription }, { children: media.embed.metadata.description })), (0, jsx_runtime_1.jsx)("a", Object.assign({ href: media.embed.metadata.url, target: '_blank', onClick: () => handleLinkClick(media) }, { children: domain }))] })), (0, jsx_runtime_1.jsx)("div", { style: { clear: 'both' } })] })
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayLink }, { children: [media.embed.metadata.images && media.embed.metadata.images.length > 0 && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: fullWidth ? ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnailFullWidth, classes.image), style: { background: `url(${media.image})`, paddingBottom: `${100 / media.image_width / media.image_height}%` } })) : ((0, jsx_runtime_1.jsx)(Box_1.default, { className: (0, classnames_1.default)(classes.thumbnail, classes.image), style: { background: `url(${media.image})` } })) })), (0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.snippet }, { children: [(0, jsx_runtime_1.jsx)("b", Object.assign({ className: classes.snippetTitle }, { children: media.embed.metadata.title })), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("p", Object.assign({ className: classes.snippetDescription }, { children: media.embed.metadata.description })), (0, jsx_runtime_1.jsx)("a", Object.assign({ href: media.embed.metadata.url, target: '_blank', onClick: () => handleLinkClick(media) }, { children: domain }))] })), (0, jsx_runtime_1.jsx)("div", { style: { clear: 'both' } })] })));
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
59
|
* Render html embed
|
|
@@ -61,7 +61,7 @@ exports.default = (props) => {
|
|
|
61
61
|
* @param key
|
|
62
62
|
*/
|
|
63
63
|
const renderHtml = (media, key) => {
|
|
64
|
-
return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayHtmlWrap }, { children: [(0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: { __html: media.embed.metadata.html }, className: classes.displayHtml }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.displayHtmlPlaceholder, style: { paddingTop: `${(100 * media.embed.metadata.height) / media.embed.metadata.width}%`, maxHeight: media.embed.metadata.height } }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20, className: classes.displayHtmlLoading }) }))] })
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)(Box_1.default, Object.assign({ className: classes.displayHtmlWrap }, { children: [(0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: { __html: media.embed.metadata.html }, className: classes.displayHtml }), (0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.displayHtmlPlaceholder, style: { paddingTop: `${(100 * media.embed.metadata.height) / media.embed.metadata.width}%`, maxHeight: media.embed.metadata.height } }, { children: (0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20, className: classes.displayHtmlLoading }) }))] })));
|
|
65
65
|
};
|
|
66
66
|
/**
|
|
67
67
|
* Renders component
|
|
@@ -61,8 +61,17 @@ export default function BottomNavigation(inProps) {
|
|
|
61
61
|
const { preferences, features } = useSCPreferences();
|
|
62
62
|
// MEMO
|
|
63
63
|
const privateMessagingEnabled = useMemo(() => features.includes(SCFeatureName.PRIVATE_MESSAGING), [features]);
|
|
64
|
-
const groupsEnabled = useMemo(() =>
|
|
65
|
-
|
|
64
|
+
const groupsEnabled = useMemo(() => preferences &&
|
|
65
|
+
features &&
|
|
66
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
67
|
+
features.includes(SCFeatureName.GROUPING) &&
|
|
68
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
69
|
+
preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
70
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
71
|
+
features &&
|
|
72
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
73
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
74
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
66
75
|
const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
67
76
|
const postOnlyStaffEnabled = preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
|
|
68
77
|
const contentAvailable = preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
@@ -428,10 +428,16 @@ export default function Composer(inProps) {
|
|
|
428
428
|
if (features.includes(SCFeatureName.TAGGING) && addressing !== null) {
|
|
429
429
|
data.addressing = addressing.map((t) => t.id);
|
|
430
430
|
}
|
|
431
|
-
if (features.includes(SCFeatureName.
|
|
431
|
+
if (features.includes(SCFeatureName.TAGGING) &&
|
|
432
|
+
features.includes(SCFeatureName.GROUPING) &&
|
|
433
|
+
preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value &&
|
|
434
|
+
group !== null) {
|
|
432
435
|
data.group = group.id;
|
|
433
436
|
}
|
|
434
|
-
if (features.includes(SCFeatureName.
|
|
437
|
+
if (features.includes(SCFeatureName.TAGGING) &&
|
|
438
|
+
features.includes(SCFeatureName.EVENT) &&
|
|
439
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value &&
|
|
440
|
+
event !== null) {
|
|
435
441
|
data.event = event.id;
|
|
436
442
|
}
|
|
437
443
|
setIsSubmitting(true);
|
|
@@ -11,7 +11,7 @@ import TagChip from '../../../../shared/TagChip';
|
|
|
11
11
|
import classNames from 'classnames';
|
|
12
12
|
import Icon from '@mui/material/Icon';
|
|
13
13
|
import DialogContent from '@mui/material/DialogContent';
|
|
14
|
-
import { useSCFetchAddressingTagList, useSCPreferences } from '@selfcommunity/react-core';
|
|
14
|
+
import { SCPreferences, useSCFetchAddressingTagList, useSCPreferences } from '@selfcommunity/react-core';
|
|
15
15
|
import { PREFIX } from '../../constants';
|
|
16
16
|
import GroupAutocomplete from '../../../GroupAutocomplete';
|
|
17
17
|
import { SCFeatureName } from '@selfcommunity/types';
|
|
@@ -57,10 +57,19 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
57
57
|
const [value, setValue] = useState(defaultValue || undefined);
|
|
58
58
|
// HOOKS
|
|
59
59
|
const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: autocompleteOpen });
|
|
60
|
-
const { features } = useSCPreferences();
|
|
60
|
+
const { preferences, features } = useSCPreferences();
|
|
61
61
|
// MEMO
|
|
62
|
-
const
|
|
63
|
-
|
|
62
|
+
const groupsEnabled = useMemo(() => preferences &&
|
|
63
|
+
features &&
|
|
64
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
65
|
+
features.includes(SCFeatureName.GROUPING) &&
|
|
66
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
67
|
+
preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
68
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
69
|
+
features &&
|
|
70
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
71
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
72
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
64
73
|
// HANDLERS
|
|
65
74
|
const handleSave = useCallback(() => {
|
|
66
75
|
audience === AudienceTypes.AUDIENCE_GROUP || audience === AudienceTypes.AUDIENCE_EVENT
|
|
@@ -52,7 +52,11 @@ export default function CreateEventButton(inProps) {
|
|
|
52
52
|
// CONST
|
|
53
53
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
54
54
|
const { preferences, features } = useSCPreferences();
|
|
55
|
-
const eventsEnabled = useMemo(() =>
|
|
55
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
56
|
+
features &&
|
|
57
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
58
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
59
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
56
60
|
const onlyStaffEnabled = useMemo(() => preferences[SCPreferences.CONFIGURATIONS_EVENTS_ONLY_STAFF_ENABLED].value, [preferences]);
|
|
57
61
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
58
62
|
// @ts-ignore
|
|
@@ -38,7 +38,11 @@ export default function CreateEventWidget(inProps) {
|
|
|
38
38
|
const scUserContext = useContext(SCUserContext);
|
|
39
39
|
// HOOK
|
|
40
40
|
const { preferences, features } = useSCPreferences();
|
|
41
|
-
const eventsEnabled = useMemo(() =>
|
|
41
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
42
|
+
features &&
|
|
43
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
44
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
45
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
42
46
|
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
43
47
|
const onlyStaffEnabled = useMemo(() => preferences[SCPreferences.CONFIGURATIONS_GROUPS_ONLY_STAFF_ENABLED].value, [preferences]);
|
|
44
48
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
@@ -252,6 +252,10 @@ export default function EventForm(inProps) {
|
|
|
252
252
|
delete error[`${name}Error`];
|
|
253
253
|
setError(error);
|
|
254
254
|
}
|
|
255
|
+
else if (error['endDateError']) {
|
|
256
|
+
delete error['endDateError'];
|
|
257
|
+
setError(error);
|
|
258
|
+
}
|
|
255
259
|
}, [error]);
|
|
256
260
|
const shouldDisabledDate = useCallback((date) => {
|
|
257
261
|
let disabled = false;
|
|
@@ -311,11 +315,14 @@ export default function EventForm(inProps) {
|
|
|
311
315
|
return _jsx("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
|
|
312
316
|
}
|
|
313
317
|
return (_jsx(FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
|
|
314
|
-
}, startAdornment: _jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "frequency" }) }) })) }, { children: Object.values(SCEventRecurrenceType).map((f) => (_jsx(MenuItem, Object.assign({ value: f }, { children: _jsx(FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), _jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker, disablePast: true, label: _jsx(FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
|
|
318
|
+
}, startAdornment: _jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "frequency" }) }) })) }, { children: Object.values(SCEventRecurrenceType).map((f) => (_jsx(MenuItem, Object.assign({ value: f }, { children: _jsx(FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), _jsx(Box, Object.assign({ className: classes.dateTime }, { children: _jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? itLocale : enLocale }, { children: [_jsx(MobileDatePicker, { className: classes.picker, disablePast: true, minDate: field.startDate, label: _jsx(FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
|
|
315
319
|
textField: (params) => (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "calendar_off" }) }) }))) }) })))
|
|
316
320
|
}, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisabledDate }), _jsx(MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && _jsx(FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
|
|
317
|
-
textField: (params) =>
|
|
318
|
-
|
|
321
|
+
textField: (params) => {
|
|
322
|
+
var _a;
|
|
323
|
+
return (_jsx(TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: (_jsx(InputAdornment, Object.assign({ position: "start" }, { children: _jsx(IconButton, { children: _jsx(Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? (_jsx(FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
|
|
324
|
+
}
|
|
325
|
+
}, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), _jsx(EventAddress, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && (_jsxs(Box, Object.assign({ className: classes.privacySection }, { children: [_jsxs(Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [_jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [_jsx(Icon, { children: "private" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), _jsx(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), _jsxs(Typography, Object.assign({ className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [_jsx(Icon, { children: "public" }), _jsx(FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), _jsx(Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? (_jsx(FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
|
|
319
326
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
320
327
|
// @ts-ignore
|
|
321
328
|
b: (chunks) => _jsx("strong", { children: chunks })
|
|
@@ -3,13 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { Box, Button, CardContent, Icon, Stack, styled, Typography, useThemeProps } from '@mui/material';
|
|
4
4
|
import { useSCFetchEvent } from '@selfcommunity/react-core';
|
|
5
5
|
import { SCEventPrivacyType, SCEventSubscriptionStatusType } from '@selfcommunity/types';
|
|
6
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
7
|
import { FormattedMessage } from 'react-intl';
|
|
8
8
|
import EventInfoDetails from '../../shared/EventInfoDetails';
|
|
9
9
|
import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
|
|
10
10
|
import Widget from '../Widget';
|
|
11
11
|
import { PREFIX } from './constants';
|
|
12
12
|
import Skeleton from './Skeleton';
|
|
13
|
+
import PubSub from 'pubsub-js';
|
|
14
|
+
import { SCGroupEventType, SCTopicType } from '../../constants/PubSub';
|
|
13
15
|
const classes = {
|
|
14
16
|
root: `${PREFIX}-root`,
|
|
15
17
|
content: `${PREFIX}-content`,
|
|
@@ -43,7 +45,9 @@ export default function EventInfoWidget(inProps) {
|
|
|
43
45
|
const [showButton, setShowButton] = useState(!summaryExpanded);
|
|
44
46
|
const [loading, setLoading] = useState(true);
|
|
45
47
|
// HOOKS
|
|
46
|
-
const { scEvent } = useSCFetchEvent({ id: eventId, event });
|
|
48
|
+
const { scEvent, setSCEvent } = useSCFetchEvent({ id: eventId, event });
|
|
49
|
+
// REFS
|
|
50
|
+
const updatesSubscription = useRef(null);
|
|
47
51
|
useEffect(() => {
|
|
48
52
|
setLoading(false);
|
|
49
53
|
}, []);
|
|
@@ -65,6 +69,25 @@ export default function EventInfoWidget(inProps) {
|
|
|
65
69
|
const showInfo = useMemo(() => (scEvent === null || scEvent === void 0 ? void 0 : scEvent.privacy) === SCEventPrivacyType.PUBLIC ||
|
|
66
70
|
[SCEventSubscriptionStatusType.SUBSCRIBED, SCEventSubscriptionStatusType.GOING, SCEventSubscriptionStatusType.NOT_GOING].indexOf(scEvent === null || scEvent === void 0 ? void 0 : scEvent.subscription_status) > -1, [scEvent]);
|
|
67
71
|
const description = useMemo(() => (expanded ? scEvent === null || scEvent === void 0 ? void 0 : scEvent.description : getTruncatedText(scEvent === null || scEvent === void 0 ? void 0 : scEvent.description, 220)), [expanded, scEvent]);
|
|
72
|
+
/**
|
|
73
|
+
* Subscriber for pubsub callback
|
|
74
|
+
*/
|
|
75
|
+
const onChangeGroupHandler = useCallback((_msg, data) => {
|
|
76
|
+
if (data && scEvent.id === data.id) {
|
|
77
|
+
setSCEvent(data);
|
|
78
|
+
}
|
|
79
|
+
}, [scEvent, setSCEvent]);
|
|
80
|
+
/**
|
|
81
|
+
* On mount, subscribe to receive groups updates (only edit)
|
|
82
|
+
*/
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (scEvent) {
|
|
85
|
+
updatesSubscription.current = PubSub.subscribe(`${SCTopicType.EVENT}.${SCGroupEventType.EDIT}`, onChangeGroupHandler);
|
|
86
|
+
}
|
|
87
|
+
return () => {
|
|
88
|
+
updatesSubscription.current && PubSub.unsubscribe(updatesSubscription.current);
|
|
89
|
+
};
|
|
90
|
+
}, [scEvent]);
|
|
68
91
|
// RENDER
|
|
69
92
|
if (!scEvent && loading) {
|
|
70
93
|
return _jsx(Skeleton, {});
|
|
@@ -4,7 +4,7 @@ import { Button, CardActions, Icon, IconButton, Typography } from '@mui/material
|
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { Box, useThemeProps } from '@mui/system';
|
|
6
6
|
import { Endpoints, EventService, http } from '@selfcommunity/api-services';
|
|
7
|
-
import { SCCache, SCRoutes, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
|
+
import { SCCache, SCPreferences, SCRoutes, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
8
8
|
import { SCEventSubscriptionStatusType, SCFeatureName } from '@selfcommunity/types';
|
|
9
9
|
import { Logger } from '@selfcommunity/utils';
|
|
10
10
|
import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
|
@@ -64,8 +64,12 @@ export default function MyEventsWidget(inProps) {
|
|
|
64
64
|
// CONTEXT
|
|
65
65
|
const scUserContext = useSCUser();
|
|
66
66
|
const scRoutingContext = useSCRouting();
|
|
67
|
-
const { features } = useSCPreferences();
|
|
68
|
-
const eventsEnabled = useMemo(() =>
|
|
67
|
+
const { preferences, features } = useSCPreferences();
|
|
68
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
69
|
+
features &&
|
|
70
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
71
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
72
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
69
73
|
// REFS
|
|
70
74
|
const updatesSubscription = useRef(null);
|
|
71
75
|
/**
|
|
@@ -108,12 +108,21 @@ export default function NavigationToolbar(inProps) {
|
|
|
108
108
|
return _preferences;
|
|
109
109
|
}, [scPreferences.preferences]);
|
|
110
110
|
const privateMessagingEnabled = useMemo(() => scPreferences.features.includes(SCFeatureName.PRIVATE_MESSAGING), [scPreferences.features]);
|
|
111
|
-
const groupsEnabled = useMemo(() => scPreferences.
|
|
112
|
-
|
|
111
|
+
const groupsEnabled = useMemo(() => scPreferences.preferences &&
|
|
112
|
+
scPreferences.features &&
|
|
113
|
+
scPreferences.features.includes(SCFeatureName.TAGGING) &&
|
|
114
|
+
scPreferences.features.includes(SCFeatureName.GROUPING) &&
|
|
115
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in scPreferences.preferences &&
|
|
116
|
+
scPreferences.preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
|
|
117
|
+
const eventsEnabled = useMemo(() => scPreferences.preferences &&
|
|
118
|
+
scPreferences.features &&
|
|
119
|
+
scPreferences.features.includes(SCFeatureName.TAGGING) &&
|
|
120
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
121
|
+
scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
|
|
113
122
|
const showComposer = useMemo(() => {
|
|
114
123
|
return (!disableComposer &&
|
|
115
124
|
(!scPreferences.preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value || UserUtils.isStaff(scUserContext.user)));
|
|
116
|
-
}, [
|
|
125
|
+
}, [preferences, disableComposer, scUserContext.user]);
|
|
117
126
|
// STATE
|
|
118
127
|
const [anchorNotification, setAnchorNotification] = React.useState(null);
|
|
119
128
|
// HANDLERS
|
|
@@ -78,8 +78,17 @@ export default function NavigationToolbarMobile(inProps) {
|
|
|
78
78
|
// STATE
|
|
79
79
|
const [searchOpen, setSearchOpen] = useState(false);
|
|
80
80
|
// MEMO
|
|
81
|
-
const groupsEnabled = useMemo(() =>
|
|
82
|
-
|
|
81
|
+
const groupsEnabled = useMemo(() => preferences &&
|
|
82
|
+
features &&
|
|
83
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
84
|
+
features.includes(SCFeatureName.GROUPING) &&
|
|
85
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
86
|
+
preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
87
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
88
|
+
features &&
|
|
89
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
90
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
91
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
83
92
|
const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
84
93
|
const postOnlyStaffEnabled = preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
|
|
85
94
|
const contentAvailable = preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|