@selfcommunity/react-ui 0.7.50-events.106 → 0.7.50-events.107

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.
@@ -74,6 +74,6 @@ function EventInfoWidget(inProps) {
74
74
  if (!scEvent) {
75
75
  return (0, jsx_runtime_1.jsx)(HiddenPlaceholder_1.default, {});
76
76
  }
77
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.titleWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "info" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.textWrapper }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), (0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo })] })) })));
77
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: classes.root }, rest, { children: (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ className: classes.content }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.titleWrapper }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "info" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "h5" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.textWrapper }, { children: (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), (0, jsx_runtime_1.jsx)(EventInfoDetails_1.default, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo, hasInProgress: false })] })) })));
78
78
  }
79
79
  exports.default = EventInfoWidget;
@@ -3,7 +3,7 @@ import { WidgetProps } from '../Widget';
3
3
  export interface MyEventsWidgetProps extends WidgetProps {
4
4
  /**
5
5
  * Feed API Query Params
6
- * @default [{'limit': 20, 'offset': 0}]
6
+ * @default [{'limit': 20, 'offset': 0, subscription_status: 'going'}]
7
7
  */
8
8
  endpointQueryParams?: Record<string, string | number>;
9
9
  /**
@@ -14,12 +14,12 @@ const react_intl_1 = require("react-intl");
14
14
  const Errors_1 = require("../../constants/Errors");
15
15
  const Pagination_1 = require("../../constants/Pagination");
16
16
  const HiddenPlaceholder_1 = tslib_1.__importDefault(require("../../shared/HiddenPlaceholder"));
17
+ const event_1 = require("../../types/event");
17
18
  const widget_1 = require("../../utils/widget");
19
+ const Event_1 = tslib_1.__importDefault(require("../Event"));
18
20
  const Widget_1 = tslib_1.__importDefault(require("../Widget"));
19
21
  const constants_1 = require("./constants");
20
22
  const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
21
- const event_1 = require("../../types/event");
22
- const Event_1 = tslib_1.__importDefault(require("../Event"));
23
23
  const classes = {
24
24
  root: `${constants_1.PREFIX}-root`,
25
25
  titleWrapper: `${constants_1.PREFIX}-title-wrapper`,
@@ -47,7 +47,11 @@ function MyEventsWidget(inProps) {
47
47
  name: constants_1.PREFIX
48
48
  });
49
49
  // CONST
50
- const { endpointQueryParams = { limit: Pagination_1.DEFAULT_PAGINATION_LIMIT, offset: Pagination_1.DEFAULT_PAGINATION_OFFSET }, cacheStrategy } = props, rest = tslib_1.__rest(props, ["endpointQueryParams", "cacheStrategy"]);
50
+ const { endpointQueryParams = {
51
+ limit: Pagination_1.DEFAULT_PAGINATION_LIMIT,
52
+ offset: Pagination_1.DEFAULT_PAGINATION_OFFSET,
53
+ subscription_status: types_1.SCEventSubscriptionStatusType.GOING
54
+ }, cacheStrategy } = props, rest = tslib_1.__rest(props, ["endpointQueryParams", "cacheStrategy"]);
51
55
  // STATE
52
56
  const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
53
57
  isLoadingNext: false,
@@ -14,5 +14,6 @@ export declare const EDIT_CONTRIBUTION = "_edit_contribution";
14
14
  export declare const DELETE_CONTRIBUTION = "_delete_contribution";
15
15
  export declare const RESTORE_CONTRIBUTION = "_restore_contribution";
16
16
  export declare const SUSPEND_NOTIFICATION_CONTRIBUTION = "_suspend_notification_contribution";
17
+ export declare const SUSPEND_NOTIFICATION_EVENT = "_suspend_notification_event";
17
18
  export declare const MODERATE_CONTRIBUTION_HIDDEN = "_moderate_contribution_hidden";
18
19
  export declare const MODERATE_CONTRIBUTION_DELETED = "_moderate_contribution_deleted";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MODERATE_CONTRIBUTION_DELETED = exports.MODERATE_CONTRIBUTION_HIDDEN = exports.SUSPEND_NOTIFICATION_CONTRIBUTION = exports.RESTORE_CONTRIBUTION = exports.DELETE_CONTRIBUTION = exports.EDIT_CONTRIBUTION = exports.GET_CONTRIBUTION_PERMALINK = exports.DELETE_CONTRIBUTION_SECTION = exports.HIDE_CONTRIBUTION_SECTION = exports.FLAG_CONTRIBUTION_SECTION = exports.GENERAL_SECTION = void 0;
3
+ exports.MODERATE_CONTRIBUTION_DELETED = exports.MODERATE_CONTRIBUTION_HIDDEN = exports.SUSPEND_NOTIFICATION_EVENT = exports.SUSPEND_NOTIFICATION_CONTRIBUTION = exports.RESTORE_CONTRIBUTION = exports.DELETE_CONTRIBUTION = exports.EDIT_CONTRIBUTION = exports.GET_CONTRIBUTION_PERMALINK = exports.DELETE_CONTRIBUTION_SECTION = exports.HIDE_CONTRIBUTION_SECTION = exports.FLAG_CONTRIBUTION_SECTION = exports.GENERAL_SECTION = void 0;
4
4
  /**
5
5
  * Sections
6
6
  * @type {string}
@@ -17,5 +17,6 @@ exports.EDIT_CONTRIBUTION = '_edit_contribution';
17
17
  exports.DELETE_CONTRIBUTION = '_delete_contribution';
18
18
  exports.RESTORE_CONTRIBUTION = '_restore_contribution';
19
19
  exports.SUSPEND_NOTIFICATION_CONTRIBUTION = '_suspend_notification_contribution';
20
+ exports.SUSPEND_NOTIFICATION_EVENT = '_suspend_notification_event';
20
21
  exports.MODERATE_CONTRIBUTION_HIDDEN = '_moderate_contribution_hidden';
21
22
  exports.MODERATE_CONTRIBUTION_DELETED = '_moderate_contribution_deleted';
@@ -54,6 +54,10 @@ export interface ContributionActionsMenuProps {
54
54
  * Handle suspend notification obj
55
55
  */
56
56
  onSuspendNotificationContribution?: (obj: SCCommentType | SCFeedObjectType) => void;
57
+ /**
58
+ * Handle suspend notification event embedded in obj
59
+ */
60
+ onSuspendNotificationEvent?: (obj: SCCommentType | SCFeedObjectType) => void;
57
61
  /**
58
62
  * Props to spread to popper
59
63
  * @default empty object
@@ -78,7 +78,7 @@ const messages = (0, react_intl_1.defineMessages)({
78
78
  });
79
79
  function ContributionActionsMenu(props) {
80
80
  // PROPS
81
- const { className, feedObjectId, feedObject, feedObjectType = types_1.SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, PopperProps = {} } = props, rest = tslib_1.__rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "PopperProps"]);
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"]);
82
82
  // INTL
83
83
  const intl = (0, react_intl_1.useIntl)();
84
84
  // CONTEXT
@@ -173,7 +173,7 @@ function ContributionActionsMenu(props) {
173
173
  }
174
174
  }
175
175
  /**
176
- * Performs notification suspension
176
+ * Performs notification suspension
177
177
  */
178
178
  const performSuspendNotification = (0, react_1.useMemo)(() => () => {
179
179
  return api_services_1.http
@@ -188,14 +188,30 @@ function ContributionActionsMenu(props) {
188
188
  return Promise.resolve(res.data);
189
189
  });
190
190
  }, [contributionObj]);
191
+ /**
192
+ * Performs notification suspension of event embedded
193
+ */
194
+ const performSuspendNotificationEvent = (0, react_1.useMemo)(() => () => {
195
+ const _endpoint = contributionObj.event.show_on_feed ? api_services_1.Endpoints.HideEvent : api_services_1.Endpoints.ShowEvent;
196
+ return api_services_1.http
197
+ .request({
198
+ url: _endpoint.url({ id: contributionObj.event.id }),
199
+ method: _endpoint.method
200
+ })
201
+ .then((res) => {
202
+ if (res.status >= 300) {
203
+ return Promise.reject(res);
204
+ }
205
+ return Promise.resolve(res.data);
206
+ });
207
+ }, [contributionObj]);
191
208
  /**
192
209
  * Handles stop notification for contributionObj
193
- * @param contribution
194
210
  */
195
211
  function handleSuspendContentNotification() {
196
212
  setCurrentActionLoading(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION);
197
213
  performSuspendNotification()
198
- .then((data) => {
214
+ .then(() => {
199
215
  const _feedObj = Object.assign({}, feedObj, { suspended: !feedObj.suspended });
200
216
  setFeedObj(_feedObj);
201
217
  onSuspendNotificationContribution && onSuspendNotificationContribution(_feedObj);
@@ -211,6 +227,29 @@ function ContributionActionsMenu(props) {
211
227
  });
212
228
  });
213
229
  }
230
+ /**
231
+ * Handles stop notification for event embedded in contributionObj
232
+ */
233
+ function handleSuspendEventNotification() {
234
+ setCurrentActionLoading(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT);
235
+ performSuspendNotificationEvent()
236
+ .then(() => {
237
+ const _eventObj = Object.assign({}, feedObj.event, { show_on_feed: !feedObj.event.show_on_feed });
238
+ const _feedObj = Object.assign({}, feedObj, { event: _eventObj });
239
+ setFeedObj(_feedObj);
240
+ onSuspendNotificationEvent && onSuspendNotificationEvent(_feedObj);
241
+ setCurrentActionLoading(null);
242
+ })
243
+ .catch((error) => {
244
+ utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
245
+ setCurrentAction(null);
246
+ setCurrentActionLoading(null);
247
+ enqueueSnackbar((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.actionError", defaultMessage: "ui.contributionActionMenu.actionError" }), {
248
+ variant: 'error',
249
+ autoHideDuration: 3000
250
+ });
251
+ });
252
+ }
214
253
  /**
215
254
  * Get Status Flag
216
255
  */
@@ -355,7 +394,7 @@ function ContributionActionsMenu(props) {
355
394
  else if (contributionObj && !isLoading && !isFlagging && type !== 'undefined') {
356
395
  setIsFlagging(true);
357
396
  performFlag(type)
358
- .then((data) => {
397
+ .then(() => {
359
398
  setFlagType(flagType === type ? null : type);
360
399
  setIsFlagging(false);
361
400
  onFlagContribution && onFlagContribution(contributionObj, type, flagType !== type);
@@ -443,6 +482,10 @@ function ContributionActionsMenu(props) {
443
482
  setCurrentAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION);
444
483
  handleSuspendContentNotification();
445
484
  }
485
+ else if (action === ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT) {
486
+ setCurrentAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT);
487
+ handleSuspendEventNotification();
488
+ }
446
489
  else if (action === ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_HIDDEN) {
447
490
  setCurrentAction(ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_HIDDEN);
448
491
  setOpenConfirmDialog(true);
@@ -496,7 +539,7 @@ function ContributionActionsMenu(props) {
496
539
  if (currentAction === ContributionsActionsMenu_1.DELETE_CONTRIBUTION) {
497
540
  setCurrentActionLoading(ContributionsActionsMenu_1.DELETE_CONTRIBUTION);
498
541
  performDeleteContribution()
499
- .then((data) => {
542
+ .then(() => {
500
543
  const _contributionObj = Object.assign({}, contributionObj, { deleted: true });
501
544
  onDeleteContribution && onDeleteContribution(_contributionObj);
502
545
  performPostConfirmAction(true);
@@ -509,7 +552,7 @@ function ContributionActionsMenu(props) {
509
552
  else if (currentAction === ContributionsActionsMenu_1.RESTORE_CONTRIBUTION) {
510
553
  setCurrentActionLoading(ContributionsActionsMenu_1.RESTORE_CONTRIBUTION);
511
554
  performRestoreContribution()
512
- .then((data) => {
555
+ .then(() => {
513
556
  const _contributionObj = Object.assign({}, contributionObj, { deleted: false });
514
557
  onRestoreContribution && onRestoreContribution(_contributionObj);
515
558
  performPostConfirmAction(true);
@@ -522,7 +565,7 @@ function ContributionActionsMenu(props) {
522
565
  else if (currentAction === ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_HIDDEN) {
523
566
  setCurrentActionLoading(ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_HIDDEN);
524
567
  performModerationContribution(Flagging_1.MODERATION_TYPE_ACTION_HIDE, hideFlagType)
525
- .then((data) => {
568
+ .then(() => {
526
569
  const _contributionObj = Object.assign({}, contributionObj, { collapsed: !contributionObj.collapsed });
527
570
  setHideType(hideType === hideFlagType ? null : hideFlagType);
528
571
  setHideFlagType(null);
@@ -537,7 +580,7 @@ function ContributionActionsMenu(props) {
537
580
  else if (currentAction === ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_DELETED) {
538
581
  setCurrentActionLoading(ContributionsActionsMenu_1.MODERATE_CONTRIBUTION_DELETED);
539
582
  performModerationContribution(Flagging_1.MODERATION_TYPE_ACTION_DELETE, deleteFlagType)
540
- .then((data) => {
583
+ .then(() => {
541
584
  const _contributionObj = Object.assign({}, contributionObj, { deleted: !contributionObj.deleted });
542
585
  setDeleteType(deleteType === deleteFlagType ? null : deleteFlagType);
543
586
  setDeleteFlagType(null);
@@ -580,9 +623,9 @@ function ContributionActionsMenu(props) {
580
623
  return name;
581
624
  }
582
625
  /**
583
- * action
584
- * @param actionId
585
- */
626
+ * action
627
+ * @param sectionId
628
+ */
586
629
  function handleOpenSection(sectionId) {
587
630
  if (sectionId) {
588
631
  if (sectionId === openSection) {
@@ -653,11 +696,21 @@ function ContributionActionsMenu(props) {
653
696
  contributionObj &&
654
697
  contributionObj.type !== types_1.SCContributionType.COMMENT);
655
698
  }
699
+ /**
700
+ * Can authenticated user suspend notification for the event related to the contribution
701
+ */
702
+ function canSuspendNotificationEvent() {
703
+ return (scUserContext.user &&
704
+ scUserContext.user.id !== contributionObj.author.id &&
705
+ contributionObj &&
706
+ contributionObj.type !== types_1.SCContributionType.COMMENT &&
707
+ Boolean(contributionObj.event));
708
+ }
656
709
  /**
657
710
  * Renders section general
658
711
  */
659
712
  function renderGeneralSection() {
660
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { 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)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.permanentLink", defaultMessage: "ui.contributionActionMenu.permanentLink" }), onClick: () => handleAction(ContributionsActionsMenu_1.GET_CONTRIBUTION_PERMALINK), classes: { root: classes.itemText } })] })), canModifyContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { 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)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.editContribution", defaultMessage: "ui.contributionActionMenu.editContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.EDIT_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canDeleteContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.DELETE_CONTRIBUTION || currentActionLoading === ContributionsActionsMenu_1.RESTORE_CONTRIBUTION ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "delete" })) }), contributionObj.deleted ? ((0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.restoreContribution", defaultMessage: "ui.contributionActionMenu.restoreContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.RESTORE_CONTRIBUTION), classes: { root: classes.itemText } })) : ((0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.deleteContribution", defaultMessage: "ui.contributionActionMenu.deleteContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.DELETE_CONTRIBUTION), classes: { root: classes.itemText } }))] }))), canSuspendNotificationContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : contributionObj['suspended'] ? ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_active" })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_off" })) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: contributionObj['suspended'] ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION), classes: { root: classes.itemText } })] })))] }, ContributionsActionsMenu_1.GENERAL_SECTION));
713
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { 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)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.permanentLink", defaultMessage: "ui.contributionActionMenu.permanentLink" }), onClick: () => handleAction(ContributionsActionsMenu_1.GET_CONTRIBUTION_PERMALINK), classes: { root: classes.itemText } })] })), canModifyContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { 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)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.editContribution", defaultMessage: "ui.contributionActionMenu.editContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.EDIT_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canDeleteContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.DELETE_CONTRIBUTION || currentActionLoading === ContributionsActionsMenu_1.RESTORE_CONTRIBUTION ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "delete" })) }), contributionObj.deleted ? ((0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.restoreContribution", defaultMessage: "ui.contributionActionMenu.restoreContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.RESTORE_CONTRIBUTION), classes: { root: classes.itemText } })) : ((0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.deleteContribution", defaultMessage: "ui.contributionActionMenu.deleteContribution" }), onClick: () => handleAction(ContributionsActionsMenu_1.DELETE_CONTRIBUTION), classes: { root: classes.itemText } }))] }))), canSuspendNotificationContribution() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : contributionObj['suspended'] ? ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_active" })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_off" })) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: contributionObj['suspended'] ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canSuspendNotificationEvent() && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: currentActionLoading === ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT ? ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 20 })) : contributionObj.event['show_on_feed'] ? ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_active" })) : ((0, jsx_runtime_1.jsx)(Icon_1.default, { children: "notifications_off" })) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: !contributionObj.event['show_on_feed'] ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(ContributionsActionsMenu_1.SUSPEND_NOTIFICATION_EVENT), classes: { root: classes.itemText } })] })))] }, ContributionsActionsMenu_1.GENERAL_SECTION));
661
714
  }
662
715
  /**
663
716
  * Renders contribution menu content
@@ -12,6 +12,7 @@ export interface EventInfoDetailsProps {
12
12
  hasPrivacyInfo?: boolean;
13
13
  hasLocationInfo?: boolean;
14
14
  hasCreatedInfo?: boolean;
15
+ hasInProgress?: boolean;
15
16
  beforeDateInfo?: ReactNode | null;
16
17
  beforeRecurringInfo?: ReactNode | null;
17
18
  beforePrivacyInfo?: ReactNode | null;
@@ -10,6 +10,7 @@ const PREFIX = 'SCEventInfoDetails';
10
10
  const classes = {
11
11
  root: `${PREFIX}-root`,
12
12
  iconTextWrapper: `${PREFIX}-icon-text-wrapper`,
13
+ live: `${PREFIX}-live`,
13
14
  link: `${PREFIX}-link`,
14
15
  url: `${PREFIX}-url`,
15
16
  creationWrapper: `${PREFIX}-creation-wrapper`
@@ -25,7 +26,7 @@ function EventInfoDetails(inProps) {
25
26
  props: inProps,
26
27
  name: PREFIX
27
28
  });
28
- const { event, hideDateIcon = false, hideRecurringIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasRecurringInfo = false, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, beforeDateInfo, beforeRecurringInfo, beforePrivacyInfo, beforeLocationInfo, beforeCreatedInfo } = props;
29
+ const { event, hideDateIcon = false, hideRecurringIcon = false, hidePrivacyIcon = false, hideLocationIcon = false, hideCreatedIcon = false, hasDateInfo = true, hasRecurringInfo = false, hasPrivacyInfo = true, hasLocationInfo = true, hasCreatedInfo = false, hasInProgress = true, beforeDateInfo, beforeRecurringInfo, beforePrivacyInfo, beforeLocationInfo, beforeCreatedInfo } = props;
29
30
  // HOOKS
30
31
  const intl = (0, react_intl_1.useIntl)();
31
32
  const privacy = (0, react_1.useMemo)(() => (event.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'ui.eventInfoDetails.privacy.public' : 'ui.eventInfoDetails.privacy.private'), [event]);
@@ -38,7 +39,7 @@ function EventInfoDetails(inProps) {
38
39
  month: 'long'
39
40
  }),
40
41
  start: intl.formatDate(event.running ? event.running_start_date : event.next_start_date, { hour: 'numeric', minute: 'numeric' })
41
- } }) }))] }))), beforeRecurringInfo, hasRecurringInfo && event.recurring !== types_1.SCEventRecurrenceType.NEVER && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: event.location === types_1.SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), event.location === types_1.SCEventLocationType.ONLINE ? ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "create" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
42
+ } }) })), hasInProgress && ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.inProgress", defaultMessage: "ui.eventInfoDetails.inProgress" }) }, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { className: classes.live }) })))] }))), beforeRecurringInfo, hasRecurringInfo && event.recurring !== types_1.SCEventRecurrenceType.NEVER && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideRecurringIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "frequency" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder`, defaultMessage: `ui.eventInfoDetails.frequency.${event.recurring}.placeholder` }) }))] }))), beforePrivacyInfo, hasPrivacyInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hidePrivacyIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: event.privacy === types_1.SCEventPrivacyType.PUBLIC ? 'public' : 'private' })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: privacy, defaultMessage: privacy }) })), "-", (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: location, defaultMessage: location }) }))] }))), beforeLocationInfo, hasLocationInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.iconTextWrapper }, { children: [!hideLocationIcon && ((0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: event.location === types_1.SCEventLocationType.ONLINE ? 'play_circle_outline' : 'add_location_alt' }))), event.location === types_1.SCEventLocationType.ONLINE ? ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: event.link, target: "_blank", className: classes.link }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.link })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", className: classes.url }, { children: event.geolocation })))] }))), beforeCreatedInfo, hasCreatedInfo && ((0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ className: classes.creationWrapper }, { children: [!hideCreatedIcon && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "create" })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventInfoDetails.date.create", defaultMessage: "ui.eventInfoDetails.date.create", values: {
42
43
  date: intl.formatDate(event.created_at, {
43
44
  weekday: 'long',
44
45
  day: 'numeric',
@@ -72,5 +72,5 @@ export default function EventInfoWidget(inProps) {
72
72
  if (!scEvent) {
73
73
  return _jsx(HiddenPlaceholder, {});
74
74
  }
75
- return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ className: classes.titleWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "info" })), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), _jsx(Box, Object.assign({ className: classes.textWrapper }, { children: _jsxs(Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && (_jsx(Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), _jsx(EventInfoDetails, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo })] })) })));
75
+ return (_jsx(Root, Object.assign({ className: classes.root }, rest, { children: _jsxs(CardContent, Object.assign({ className: classes.content }, { children: [_jsxs(Stack, Object.assign({ className: classes.titleWrapper }, { children: [_jsx(Icon, Object.assign({ fontSize: "small" }, { children: "info" })), _jsx(Typography, Object.assign({ variant: "h5" }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.title", defaultMessage: "ui.infoEventWidget.title" }) }))] })), _jsx(Box, Object.assign({ className: classes.textWrapper }, { children: _jsxs(Typography, Object.assign({ component: "span", variant: "body1" }, { children: [description, showButton && !expanded && (_jsx(Button, Object.assign({ size: "small", variant: "text", className: classes.showMore, onClick: handleToggleSummary }, { children: _jsx(FormattedMessage, { id: "ui.infoEventWidget.showMore", defaultMessage: "ui.infoEventWidget.showMore" }) })))] })) })), _jsx(EventInfoDetails, { event: scEvent, hasRecurringInfo: true, hasCreatedInfo: true, hasLocationInfo: showInfo, hasInProgress: false })] })) })));
76
76
  }
@@ -3,7 +3,7 @@ import { WidgetProps } from '../Widget';
3
3
  export interface MyEventsWidgetProps extends WidgetProps {
4
4
  /**
5
5
  * Feed API Query Params
6
- * @default [{'limit': 20, 'offset': 0}]
6
+ * @default [{'limit': 20, 'offset': 0, subscription_status: 'going'}]
7
7
  */
8
8
  endpointQueryParams?: Record<string, string | number>;
9
9
  /**
@@ -5,19 +5,19 @@ 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
7
  import { SCCache, SCRoutes, useSCPreferences, useSCRouting, useSCUser } from '@selfcommunity/react-core';
8
- import { SCFeatureName } from '@selfcommunity/types';
8
+ import { SCEventSubscriptionStatusType, SCFeatureName } from '@selfcommunity/types';
9
9
  import { Logger } from '@selfcommunity/utils';
10
10
  import { useCallback, useEffect, useMemo, useReducer, useState } from 'react';
11
11
  import { FormattedMessage } from 'react-intl';
12
12
  import { SCOPE_SC_UI } from '../../constants/Errors';
13
13
  import { DEFAULT_PAGINATION_LIMIT, DEFAULT_PAGINATION_OFFSET } from '../../constants/Pagination';
14
14
  import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
15
+ import { SCEventTemplateType } from '../../types/event';
15
16
  import { actionWidgetTypes, dataWidgetReducer, stateWidgetInitializer } from '../../utils/widget';
17
+ import Event from '../Event';
16
18
  import Widget from '../Widget';
17
19
  import { PREFIX } from './constants';
18
20
  import Skeleton from './Skeleton';
19
- import { SCEventTemplateType } from '../../types/event';
20
- import Event from '../Event';
21
21
  const classes = {
22
22
  root: `${PREFIX}-root`,
23
23
  titleWrapper: `${PREFIX}-title-wrapper`,
@@ -45,7 +45,11 @@ export default function MyEventsWidget(inProps) {
45
45
  name: PREFIX
46
46
  });
47
47
  // CONST
48
- const { endpointQueryParams = { limit: DEFAULT_PAGINATION_LIMIT, offset: DEFAULT_PAGINATION_OFFSET }, cacheStrategy } = props, rest = __rest(props, ["endpointQueryParams", "cacheStrategy"]);
48
+ const { endpointQueryParams = {
49
+ limit: DEFAULT_PAGINATION_LIMIT,
50
+ offset: DEFAULT_PAGINATION_OFFSET,
51
+ subscription_status: SCEventSubscriptionStatusType.GOING
52
+ }, cacheStrategy } = props, rest = __rest(props, ["endpointQueryParams", "cacheStrategy"]);
49
53
  // STATE
50
54
  const [state, dispatch] = useReducer(dataWidgetReducer, {
51
55
  isLoadingNext: false,
@@ -14,5 +14,6 @@ export declare const EDIT_CONTRIBUTION = "_edit_contribution";
14
14
  export declare const DELETE_CONTRIBUTION = "_delete_contribution";
15
15
  export declare const RESTORE_CONTRIBUTION = "_restore_contribution";
16
16
  export declare const SUSPEND_NOTIFICATION_CONTRIBUTION = "_suspend_notification_contribution";
17
+ export declare const SUSPEND_NOTIFICATION_EVENT = "_suspend_notification_event";
17
18
  export declare const MODERATE_CONTRIBUTION_HIDDEN = "_moderate_contribution_hidden";
18
19
  export declare const MODERATE_CONTRIBUTION_DELETED = "_moderate_contribution_deleted";
@@ -14,5 +14,6 @@ export const EDIT_CONTRIBUTION = '_edit_contribution';
14
14
  export const DELETE_CONTRIBUTION = '_delete_contribution';
15
15
  export const RESTORE_CONTRIBUTION = '_restore_contribution';
16
16
  export const SUSPEND_NOTIFICATION_CONTRIBUTION = '_suspend_notification_contribution';
17
+ export const SUSPEND_NOTIFICATION_EVENT = '_suspend_notification_event';
17
18
  export const MODERATE_CONTRIBUTION_HIDDEN = '_moderate_contribution_hidden';
18
19
  export const MODERATE_CONTRIBUTION_DELETED = '_moderate_contribution_deleted';
@@ -54,6 +54,10 @@ export interface ContributionActionsMenuProps {
54
54
  * Handle suspend notification obj
55
55
  */
56
56
  onSuspendNotificationContribution?: (obj: SCCommentType | SCFeedObjectType) => void;
57
+ /**
58
+ * Handle suspend notification event embedded in obj
59
+ */
60
+ onSuspendNotificationEvent?: (obj: SCCommentType | SCFeedObjectType) => void;
57
61
  /**
58
62
  * Props to spread to popper
59
63
  * @default empty object
@@ -17,7 +17,7 @@ import { MODERATION_CONTRIBUTION_STATE_DELETED, MODERATION_CONTRIBUTION_STATE_HI
17
17
  import { Endpoints, http } from '@selfcommunity/api-services';
18
18
  import { SCContext, SCUserContext, UserUtils, useSCFetchCommentObject, useSCFetchFeedObject, useSCRouting } from '@selfcommunity/react-core';
19
19
  import { SCContributionType } from '@selfcommunity/types';
20
- import { DELETE_CONTRIBUTION, DELETE_CONTRIBUTION_SECTION, EDIT_CONTRIBUTION, FLAG_CONTRIBUTION_SECTION, GENERAL_SECTION, GET_CONTRIBUTION_PERMALINK, HIDE_CONTRIBUTION_SECTION, MODERATE_CONTRIBUTION_DELETED, MODERATE_CONTRIBUTION_HIDDEN, RESTORE_CONTRIBUTION, SUSPEND_NOTIFICATION_CONTRIBUTION } from '../../constants/ContributionsActionsMenu';
20
+ import { DELETE_CONTRIBUTION, DELETE_CONTRIBUTION_SECTION, EDIT_CONTRIBUTION, FLAG_CONTRIBUTION_SECTION, GENERAL_SECTION, GET_CONTRIBUTION_PERMALINK, HIDE_CONTRIBUTION_SECTION, MODERATE_CONTRIBUTION_DELETED, MODERATE_CONTRIBUTION_HIDDEN, RESTORE_CONTRIBUTION, SUSPEND_NOTIFICATION_CONTRIBUTION, SUSPEND_NOTIFICATION_EVENT } from '../../constants/ContributionsActionsMenu';
21
21
  const PREFIX = 'SCContributionActionsMenu';
22
22
  const classes = {
23
23
  root: `${PREFIX}-root`,
@@ -76,7 +76,7 @@ const messages = defineMessages({
76
76
  });
77
77
  export default function ContributionActionsMenu(props) {
78
78
  // PROPS
79
- const { className, feedObjectId, feedObject, feedObjectType = SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, PopperProps = {} } = props, rest = __rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "PopperProps"]);
79
+ const { className, feedObjectId, feedObject, feedObjectType = SCContributionType.POST, commentObjectId, commentObject, onFlagContribution, onEditContribution, onHideContribution, onDeleteContribution, onRestoreContribution, onSuspendNotificationContribution, onSuspendNotificationEvent, PopperProps = {} } = props, rest = __rest(props, ["className", "feedObjectId", "feedObject", "feedObjectType", "commentObjectId", "commentObject", "onFlagContribution", "onEditContribution", "onHideContribution", "onDeleteContribution", "onRestoreContribution", "onSuspendNotificationContribution", "onSuspendNotificationEvent", "PopperProps"]);
80
80
  // INTL
81
81
  const intl = useIntl();
82
82
  // CONTEXT
@@ -171,7 +171,7 @@ export default function ContributionActionsMenu(props) {
171
171
  }
172
172
  }
173
173
  /**
174
- * Performs notification suspension
174
+ * Performs notification suspension
175
175
  */
176
176
  const performSuspendNotification = useMemo(() => () => {
177
177
  return http
@@ -186,14 +186,30 @@ export default function ContributionActionsMenu(props) {
186
186
  return Promise.resolve(res.data);
187
187
  });
188
188
  }, [contributionObj]);
189
+ /**
190
+ * Performs notification suspension of event embedded
191
+ */
192
+ const performSuspendNotificationEvent = useMemo(() => () => {
193
+ const _endpoint = contributionObj.event.show_on_feed ? Endpoints.HideEvent : Endpoints.ShowEvent;
194
+ return http
195
+ .request({
196
+ url: _endpoint.url({ id: contributionObj.event.id }),
197
+ method: _endpoint.method
198
+ })
199
+ .then((res) => {
200
+ if (res.status >= 300) {
201
+ return Promise.reject(res);
202
+ }
203
+ return Promise.resolve(res.data);
204
+ });
205
+ }, [contributionObj]);
189
206
  /**
190
207
  * Handles stop notification for contributionObj
191
- * @param contribution
192
208
  */
193
209
  function handleSuspendContentNotification() {
194
210
  setCurrentActionLoading(SUSPEND_NOTIFICATION_CONTRIBUTION);
195
211
  performSuspendNotification()
196
- .then((data) => {
212
+ .then(() => {
197
213
  const _feedObj = Object.assign({}, feedObj, { suspended: !feedObj.suspended });
198
214
  setFeedObj(_feedObj);
199
215
  onSuspendNotificationContribution && onSuspendNotificationContribution(_feedObj);
@@ -209,6 +225,29 @@ export default function ContributionActionsMenu(props) {
209
225
  });
210
226
  });
211
227
  }
228
+ /**
229
+ * Handles stop notification for event embedded in contributionObj
230
+ */
231
+ function handleSuspendEventNotification() {
232
+ setCurrentActionLoading(SUSPEND_NOTIFICATION_EVENT);
233
+ performSuspendNotificationEvent()
234
+ .then(() => {
235
+ const _eventObj = Object.assign({}, feedObj.event, { show_on_feed: !feedObj.event.show_on_feed });
236
+ const _feedObj = Object.assign({}, feedObj, { event: _eventObj });
237
+ setFeedObj(_feedObj);
238
+ onSuspendNotificationEvent && onSuspendNotificationEvent(_feedObj);
239
+ setCurrentActionLoading(null);
240
+ })
241
+ .catch((error) => {
242
+ Logger.error(SCOPE_SC_UI, error);
243
+ setCurrentAction(null);
244
+ setCurrentActionLoading(null);
245
+ enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.contributionActionMenu.actionError", defaultMessage: "ui.contributionActionMenu.actionError" }), {
246
+ variant: 'error',
247
+ autoHideDuration: 3000
248
+ });
249
+ });
250
+ }
212
251
  /**
213
252
  * Get Status Flag
214
253
  */
@@ -353,7 +392,7 @@ export default function ContributionActionsMenu(props) {
353
392
  else if (contributionObj && !isLoading && !isFlagging && type !== 'undefined') {
354
393
  setIsFlagging(true);
355
394
  performFlag(type)
356
- .then((data) => {
395
+ .then(() => {
357
396
  setFlagType(flagType === type ? null : type);
358
397
  setIsFlagging(false);
359
398
  onFlagContribution && onFlagContribution(contributionObj, type, flagType !== type);
@@ -441,6 +480,10 @@ export default function ContributionActionsMenu(props) {
441
480
  setCurrentAction(SUSPEND_NOTIFICATION_CONTRIBUTION);
442
481
  handleSuspendContentNotification();
443
482
  }
483
+ else if (action === SUSPEND_NOTIFICATION_EVENT) {
484
+ setCurrentAction(SUSPEND_NOTIFICATION_EVENT);
485
+ handleSuspendEventNotification();
486
+ }
444
487
  else if (action === MODERATE_CONTRIBUTION_HIDDEN) {
445
488
  setCurrentAction(MODERATE_CONTRIBUTION_HIDDEN);
446
489
  setOpenConfirmDialog(true);
@@ -494,7 +537,7 @@ export default function ContributionActionsMenu(props) {
494
537
  if (currentAction === DELETE_CONTRIBUTION) {
495
538
  setCurrentActionLoading(DELETE_CONTRIBUTION);
496
539
  performDeleteContribution()
497
- .then((data) => {
540
+ .then(() => {
498
541
  const _contributionObj = Object.assign({}, contributionObj, { deleted: true });
499
542
  onDeleteContribution && onDeleteContribution(_contributionObj);
500
543
  performPostConfirmAction(true);
@@ -507,7 +550,7 @@ export default function ContributionActionsMenu(props) {
507
550
  else if (currentAction === RESTORE_CONTRIBUTION) {
508
551
  setCurrentActionLoading(RESTORE_CONTRIBUTION);
509
552
  performRestoreContribution()
510
- .then((data) => {
553
+ .then(() => {
511
554
  const _contributionObj = Object.assign({}, contributionObj, { deleted: false });
512
555
  onRestoreContribution && onRestoreContribution(_contributionObj);
513
556
  performPostConfirmAction(true);
@@ -520,7 +563,7 @@ export default function ContributionActionsMenu(props) {
520
563
  else if (currentAction === MODERATE_CONTRIBUTION_HIDDEN) {
521
564
  setCurrentActionLoading(MODERATE_CONTRIBUTION_HIDDEN);
522
565
  performModerationContribution(MODERATION_TYPE_ACTION_HIDE, hideFlagType)
523
- .then((data) => {
566
+ .then(() => {
524
567
  const _contributionObj = Object.assign({}, contributionObj, { collapsed: !contributionObj.collapsed });
525
568
  setHideType(hideType === hideFlagType ? null : hideFlagType);
526
569
  setHideFlagType(null);
@@ -535,7 +578,7 @@ export default function ContributionActionsMenu(props) {
535
578
  else if (currentAction === MODERATE_CONTRIBUTION_DELETED) {
536
579
  setCurrentActionLoading(MODERATE_CONTRIBUTION_DELETED);
537
580
  performModerationContribution(MODERATION_TYPE_ACTION_DELETE, deleteFlagType)
538
- .then((data) => {
581
+ .then(() => {
539
582
  const _contributionObj = Object.assign({}, contributionObj, { deleted: !contributionObj.deleted });
540
583
  setDeleteType(deleteType === deleteFlagType ? null : deleteFlagType);
541
584
  setDeleteFlagType(null);
@@ -578,9 +621,9 @@ export default function ContributionActionsMenu(props) {
578
621
  return name;
579
622
  }
580
623
  /**
581
- * action
582
- * @param actionId
583
- */
624
+ * action
625
+ * @param sectionId
626
+ */
584
627
  function handleOpenSection(sectionId) {
585
628
  if (sectionId) {
586
629
  if (sectionId === openSection) {
@@ -651,11 +694,21 @@ export default function ContributionActionsMenu(props) {
651
694
  contributionObj &&
652
695
  contributionObj.type !== SCContributionType.COMMENT);
653
696
  }
697
+ /**
698
+ * Can authenticated user suspend notification for the event related to the contribution
699
+ */
700
+ function canSuspendNotificationEvent() {
701
+ return (scUserContext.user &&
702
+ scUserContext.user.id !== contributionObj.author.id &&
703
+ contributionObj &&
704
+ contributionObj.type !== SCContributionType.COMMENT &&
705
+ Boolean(contributionObj.event));
706
+ }
654
707
  /**
655
708
  * Renders section general
656
709
  */
657
710
  function renderGeneralSection() {
658
- return (_jsxs(Box, { children: [_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "link" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.permanentLink", defaultMessage: "ui.contributionActionMenu.permanentLink" }), onClick: () => handleAction(GET_CONTRIBUTION_PERMALINK), classes: { root: classes.itemText } })] })), canModifyContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "edit" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.editContribution", defaultMessage: "ui.contributionActionMenu.editContribution" }), onClick: () => handleAction(EDIT_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canDeleteContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === DELETE_CONTRIBUTION || currentActionLoading === RESTORE_CONTRIBUTION ? (_jsx(CircularProgress, { size: 20 })) : (_jsx(Icon, { children: "delete" })) }), contributionObj.deleted ? (_jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.restoreContribution", defaultMessage: "ui.contributionActionMenu.restoreContribution" }), onClick: () => handleAction(RESTORE_CONTRIBUTION), classes: { root: classes.itemText } })) : (_jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.deleteContribution", defaultMessage: "ui.contributionActionMenu.deleteContribution" }), onClick: () => handleAction(DELETE_CONTRIBUTION), classes: { root: classes.itemText } }))] }))), canSuspendNotificationContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === SUSPEND_NOTIFICATION_CONTRIBUTION ? (_jsx(CircularProgress, { size: 20 })) : contributionObj['suspended'] ? (_jsx(Icon, { children: "notifications_active" })) : (_jsx(Icon, { children: "notifications_off" })) }), _jsx(ListItemText, { primary: contributionObj['suspended'] ? (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(SUSPEND_NOTIFICATION_CONTRIBUTION), classes: { root: classes.itemText } })] })))] }, GENERAL_SECTION));
711
+ return (_jsxs(Box, { children: [_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "link" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.permanentLink", defaultMessage: "ui.contributionActionMenu.permanentLink" }), onClick: () => handleAction(GET_CONTRIBUTION_PERMALINK), classes: { root: classes.itemText } })] })), canModifyContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: _jsx(Icon, { children: "edit" }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.editContribution", defaultMessage: "ui.contributionActionMenu.editContribution" }), onClick: () => handleAction(EDIT_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canDeleteContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === DELETE_CONTRIBUTION || currentActionLoading === RESTORE_CONTRIBUTION ? (_jsx(CircularProgress, { size: 20 })) : (_jsx(Icon, { children: "delete" })) }), contributionObj.deleted ? (_jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.restoreContribution", defaultMessage: "ui.contributionActionMenu.restoreContribution" }), onClick: () => handleAction(RESTORE_CONTRIBUTION), classes: { root: classes.itemText } })) : (_jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: "ui.contributionActionMenu.deleteContribution", defaultMessage: "ui.contributionActionMenu.deleteContribution" }), onClick: () => handleAction(DELETE_CONTRIBUTION), classes: { root: classes.itemText } }))] }))), canSuspendNotificationContribution() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === SUSPEND_NOTIFICATION_CONTRIBUTION ? (_jsx(CircularProgress, { size: 20 })) : contributionObj['suspended'] ? (_jsx(Icon, { children: "notifications_active" })) : (_jsx(Icon, { children: "notifications_off" })) }), _jsx(ListItemText, { primary: contributionObj['suspended'] ? (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(SUSPEND_NOTIFICATION_CONTRIBUTION), classes: { root: classes.itemText } })] }))), canSuspendNotificationEvent() && (_jsxs(MenuItem, Object.assign({ className: classes.subItem, disabled: isFlagging }, { children: [_jsx(ListItemIcon, { children: currentActionLoading === SUSPEND_NOTIFICATION_EVENT ? (_jsx(CircularProgress, { size: 20 })) : contributionObj.event['show_on_feed'] ? (_jsx(Icon, { children: "notifications_active" })) : (_jsx(Icon, { children: "notifications_off" })) }), _jsx(ListItemText, { primary: !contributionObj.event['show_on_feed'] ? (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.enableNotificationContribution", defaultMessage: "ui.contributionActionMenu.enableNotificationContribution" })) : (_jsx(FormattedMessage, { id: "ui.contributionActionMenu.suspendNotificationContribution", defaultMessage: "ui.contributionActionMenu.suspendNotificationContribution" })), onClick: () => handleAction(SUSPEND_NOTIFICATION_EVENT), classes: { root: classes.itemText } })] })))] }, GENERAL_SECTION));
659
712
  }
660
713
  /**
661
714
  * Renders contribution menu content
@@ -12,6 +12,7 @@ export interface EventInfoDetailsProps {
12
12
  hasPrivacyInfo?: boolean;
13
13
  hasLocationInfo?: boolean;
14
14
  hasCreatedInfo?: boolean;
15
+ hasInProgress?: boolean;
15
16
  beforeDateInfo?: ReactNode | null;
16
17
  beforeRecurringInfo?: ReactNode | null;
17
18
  beforePrivacyInfo?: ReactNode | null;