@selfcommunity/react-ui 0.11.0-alpha.81 → 0.11.0-alpha.83
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.
|
@@ -83,7 +83,7 @@ const exampleExploreData = {
|
|
|
83
83
|
addressing: [],
|
|
84
84
|
poll: null
|
|
85
85
|
},
|
|
86
|
-
|
|
86
|
+
seen: true,
|
|
87
87
|
has_boost: false
|
|
88
88
|
},
|
|
89
89
|
{
|
|
@@ -194,7 +194,7 @@ const exampleExploreData = {
|
|
|
194
194
|
poll: null,
|
|
195
195
|
title: "Socioterapeuti dicono che l'Italia ha inglobato secondo un'analisi storica con tanto di bibliografia. Senno' ha a che fare con le pellicce, ovviamente. Ritengo che vedere cio' che si semina.."
|
|
196
196
|
},
|
|
197
|
-
|
|
197
|
+
seen: true,
|
|
198
198
|
has_boost: false
|
|
199
199
|
},
|
|
200
200
|
{
|
|
@@ -330,7 +330,7 @@ const exampleExploreData = {
|
|
|
330
330
|
poll: null,
|
|
331
331
|
title: "Prima, mentre che io facevo le derapate, popo a sfonna' 'a bariera der sono, co'a machina de mi'fratello su 'a prenestina... aho'... a'n certo punto... nun te vado a sbatte co er Siringa???!! Ve dico... 'na grezza da paura! E allora je strillo \"Vie'"
|
|
332
332
|
},
|
|
333
|
-
|
|
333
|
+
seen: true,
|
|
334
334
|
has_boost: false
|
|
335
335
|
},
|
|
336
336
|
{
|
|
@@ -415,7 +415,7 @@ const exampleExploreData = {
|
|
|
415
415
|
poll: null,
|
|
416
416
|
title: "Un mattino P'an-shan fece visita a Seng-ts'an e lo preg\u00f2 di mostrargli la strada pi\u00f9 facile per conseguire l'illuminazione. Il maestro indic\u00f2 una consunta statua di platino e disse: \"Se davvero desideri diventare saggio devi riuscire a comprendere la"
|
|
417
417
|
},
|
|
418
|
-
|
|
418
|
+
seen: true,
|
|
419
419
|
has_boost: false
|
|
420
420
|
},
|
|
421
421
|
{
|
|
@@ -510,7 +510,7 @@ const exampleExploreData = {
|
|
|
510
510
|
addressing: [],
|
|
511
511
|
poll: null
|
|
512
512
|
},
|
|
513
|
-
|
|
513
|
+
seen: true,
|
|
514
514
|
has_boost: false
|
|
515
515
|
}
|
|
516
516
|
]
|
|
@@ -46,6 +46,10 @@ const messages = (0, react_intl_1.defineMessages)({
|
|
|
46
46
|
visibleToGroup: {
|
|
47
47
|
id: 'ui.feedObject.visibleToGroup',
|
|
48
48
|
defaultMessage: 'ui.feedObject.visibleToGroup'
|
|
49
|
+
},
|
|
50
|
+
visibleToRecipients: {
|
|
51
|
+
id: 'ui.feedObject.visibleToRecipients',
|
|
52
|
+
defaultMessage: 'ui.feedObject.visibleToRecipients'
|
|
49
53
|
}
|
|
50
54
|
});
|
|
51
55
|
const classes = {
|
|
@@ -78,7 +82,6 @@ const classes = {
|
|
|
78
82
|
activitiesContent: `${constants_1.PREFIX}-activities-content`,
|
|
79
83
|
followButton: `${constants_1.PREFIX}-follow-button`,
|
|
80
84
|
vote: `${constants_1.PREFIX}-vote`,
|
|
81
|
-
objElement: `${constants_1.PREFIX}-obj-element`,
|
|
82
85
|
new: `${constants_1.PREFIX}-new`
|
|
83
86
|
};
|
|
84
87
|
const Root = (0, material_1.styled)(Widget_1.default, {
|
|
@@ -138,7 +141,7 @@ const Root = (0, material_1.styled)(Widget_1.default, {
|
|
|
138
141
|
* @param inProps
|
|
139
142
|
*/
|
|
140
143
|
function FeedObject(inProps) {
|
|
141
|
-
var _a, _b, _c, _d, _f, _g, _h, _j;
|
|
144
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k;
|
|
142
145
|
// PROPS
|
|
143
146
|
const props = (0, system_1.useThemeProps)({
|
|
144
147
|
props: inProps,
|
|
@@ -153,8 +156,6 @@ function FeedObject(inProps) {
|
|
|
153
156
|
const { preferences } = (0, react_core_1.useSCPreferences)();
|
|
154
157
|
const allShareEnabled = react_core_1.SCPreferences.ADDONS_SHARE_POST_ENABLED in preferences && preferences[react_core_1.SCPreferences.ADDONS_SHARE_POST_ENABLED].value;
|
|
155
158
|
const commentsEnabled = react_core_1.SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED in preferences && preferences[react_core_1.SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED].value;
|
|
156
|
-
// HOOKS
|
|
157
|
-
const theme = (0, material_1.useTheme)();
|
|
158
159
|
// OBJECTS
|
|
159
160
|
const { obj, setObj, error } = (0, react_core_1.useSCFetchFeedObject)({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
|
|
160
161
|
const objId = obj ? obj.id : null;
|
|
@@ -443,10 +444,10 @@ function FeedObject(inProps) {
|
|
|
443
444
|
else if (template === feedObject_1.SCFeedObjectTemplateType.PREVIEW ||
|
|
444
445
|
template === feedObject_1.SCFeedObjectTemplateType.DETAIL ||
|
|
445
446
|
template === feedObject_1.SCFeedObjectTemplateType.SEARCH) {
|
|
446
|
-
objElement = ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: obj ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: (0, classnames_1.default)({ [classes.deleted]: obj && obj.deleted }
|
|
447
|
+
objElement = ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: obj ? ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: (0, classnames_1.default)({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && ((0, jsx_runtime_1.jsxs)("div", Object.assign({ className: classes.category }, { children: [(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [obj.group && ((0, jsx_runtime_1.jsx)(material_1.Chip, { className: classes.group, color: "secondary", size: "small", icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "groups" }), component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id)), obj.event && ((0, jsx_runtime_1.jsx)(material_1.Chip, { className: classes.event, color: "secondary", size: "small", label: obj.event.name, icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }), component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id))] }), obj.categories.map((c) => ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && ((0, jsx_runtime_1.jsx)("div", Object.assign({ className: classes.group }, { children: (0, jsx_runtime_1.jsx)(material_1.Chip, { color: "secondary", size: "small", icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "groups" }), label: obj.group.name, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && ((0, jsx_runtime_1.jsx)(material_1.Chip, { className: classes.event, color: "secondary", size: "small", icon: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }), label: obj.event.name, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id)), (0, jsx_runtime_1.jsx)(material_1.CardHeader, { className: classes.header, avatar: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: (0, jsx_runtime_1.jsx)(UserAvatar_1.default, Object.assign({ hide: !obj.author.community_badge }, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [scUserContext.user && markRead && (0, jsx_runtime_1.jsx)("span", Object.assign({ className: classes.new }, { children: "NEW" })), (0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj)), className: classes.activityAt }, { children: (0, jsx_runtime_1.jsx)(DateTimeAgo_1.default, { component: "span", date: obj.added_at }) })), obj.location && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.location }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "add_location_alt" }), (_a = obj.location) === null || _a === void 0 ? void 0 : _a.location] }))] })), (((_b = obj.addressing) !== null && _b !== void 0 ? _b : []).filter((tag) => tag.visible).length > 0 || (obj === null || obj === void 0 ? void 0 : obj.group)) && (0, jsx_runtime_1.jsx)(Bullet_1.default, {}), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.tag }, { children: obj.addressing.length > 0 ? ((0, jsx_runtime_1.jsx)(Tags_1.default, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "groups" })) }))) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Bullet_1.default, {}), ((_c = obj.recipients) === null || _c === void 0 ? void 0 : _c.length) > 0 ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToRecipients)}` }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "private" })) }))) : ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToAll)}` }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "public" })) })))] })) }))] }), action: renderHeaderAction() }), (0, jsx_runtime_1.jsxs)(material_1.CardContent, Object.assign({ classes: { root: classes.content } }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: template === feedObject_1.SCFeedObjectTemplateType.DETAIL ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title }))) : ((0, jsx_runtime_1.jsx)(react_core_1.Link, Object.assign({ to: scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj)) }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.mediasSection }, { children: (0, jsx_runtime_1.jsx)(FeedObjectMediaPreview_1.default, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && ((0, jsx_runtime_1.jsx)(Poll_1.default, Object.assign({ visible: pollVisible ||
|
|
447
448
|
template === feedObject_1.SCFeedObjectTemplateType.DETAIL ||
|
|
448
|
-
Boolean(obj.type !== types_1.SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), !obj.draft && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.infoSection }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!commentsEnabled && !allShareEnabled ? ((0, jsx_runtime_1.jsx)(Vote_1.default, { feedObjectId: feedObjectId || (feedObject === null || feedObject === void 0 ? void 0 : feedObject.id), feedObjectType: feedObjectType, feedObject: obj, inlineAction: true, onVoteAction: handleVoteSuccess, className: classes.vote })) : (!hideParticipantsPreview && ((0, jsx_runtime_1.jsx)(Contributors_1.default, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy })))), !_hideFollowAction && (0, jsx_runtime_1.jsx)(Follow_1.default, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) })))] })), (0, jsx_runtime_1.jsxs)(material_1.CardActions, Object.assign({ className: classes.actionsSection }, { children: [(0, jsx_runtime_1.jsx)(Actions_1.default, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideVoteAction: !allShareEnabled && !commentsEnabled, hideCommentAction: !commentsEnabled || template === feedObject_1.SCFeedObjectTemplateType.DETAIL || (hasEvent && !((
|
|
449
|
-
((template === feedObject_1.SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((
|
|
449
|
+
Boolean(obj.type !== types_1.SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), !obj.draft && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.infoSection }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!commentsEnabled && !allShareEnabled ? ((0, jsx_runtime_1.jsx)(Vote_1.default, { feedObjectId: feedObjectId || (feedObject === null || feedObject === void 0 ? void 0 : feedObject.id), feedObjectType: feedObjectType, feedObject: obj, inlineAction: true, onVoteAction: handleVoteSuccess, className: classes.vote })) : (!hideParticipantsPreview && ((0, jsx_runtime_1.jsx)(Contributors_1.default, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy })))), !_hideFollowAction && (0, jsx_runtime_1.jsx)(Follow_1.default, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) })))] })), (0, jsx_runtime_1.jsxs)(material_1.CardActions, Object.assign({ className: classes.actionsSection }, { children: [(0, jsx_runtime_1.jsx)(Actions_1.default, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideVoteAction: !allShareEnabled && !commentsEnabled, hideCommentAction: !commentsEnabled || template === feedObject_1.SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _d === void 0 ? void 0 : _d.metadata) === null || _f === void 0 ? void 0 : _f.active)), hideShareAction: !allShareEnabled, handleExpandActivities: template === feedObject_1.SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), commentsEnabled &&
|
|
450
|
+
((template === feedObject_1.SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_k = (_j = (_h = (_g = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.embed) === null || _j === void 0 ? void 0 : _j.metadata) === null || _k === void 0 ? void 0 : _k.active))) ||
|
|
450
451
|
expandedActivities) && ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.replyContent }, { children: (0, jsx_runtime_1.jsx)(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) })))] })), commentsEnabled &&
|
|
451
452
|
template === feedObject_1.SCFeedObjectTemplateType.PREVIEW &&
|
|
452
453
|
(obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && ((0, jsx_runtime_1.jsx)(material_1.Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: (0, jsx_runtime_1.jsx)(material_1.CardContent, Object.assign({ className: classes.activitiesContent }, { children: (0, jsx_runtime_1.jsx)(Activities_1.default, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
@@ -463,6 +464,6 @@ function FeedObject(inProps) {
|
|
|
463
464
|
/**
|
|
464
465
|
* Renders root object
|
|
465
466
|
*/
|
|
466
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`) }, rest, { children: [obj && markRead && (0, jsx_runtime_1.jsx)(MarkRead_1.default, { endpoint: api_services_1.Endpoints.FeedObjectMarkRead, data: { object: [obj.id] }, callback: handleMarkReadComplete }), objElement] })), openAlert && (0, jsx_runtime_1.jsx)(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
467
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className, `${constants_1.PREFIX}-${template}`) }, rest, { children: [scUserContext.user && obj && markRead && ((0, jsx_runtime_1.jsx)(MarkRead_1.default, { endpoint: api_services_1.Endpoints.FeedObjectMarkRead, data: { object: [obj.id] }, callback: handleMarkReadComplete })), objElement] })), openAlert && (0, jsx_runtime_1.jsx)(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
467
468
|
}
|
|
468
469
|
exports.default = FeedObject;
|
|
@@ -80,7 +80,7 @@ const exampleExploreData = {
|
|
|
80
80
|
addressing: [],
|
|
81
81
|
poll: null
|
|
82
82
|
},
|
|
83
|
-
|
|
83
|
+
seen: true,
|
|
84
84
|
has_boost: false
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -191,7 +191,7 @@ const exampleExploreData = {
|
|
|
191
191
|
poll: null,
|
|
192
192
|
title: "Socioterapeuti dicono che l'Italia ha inglobato secondo un'analisi storica con tanto di bibliografia. Senno' ha a che fare con le pellicce, ovviamente. Ritengo che vedere cio' che si semina.."
|
|
193
193
|
},
|
|
194
|
-
|
|
194
|
+
seen: true,
|
|
195
195
|
has_boost: false
|
|
196
196
|
},
|
|
197
197
|
{
|
|
@@ -327,7 +327,7 @@ const exampleExploreData = {
|
|
|
327
327
|
poll: null,
|
|
328
328
|
title: "Prima, mentre che io facevo le derapate, popo a sfonna' 'a bariera der sono, co'a machina de mi'fratello su 'a prenestina... aho'... a'n certo punto... nun te vado a sbatte co er Siringa???!! Ve dico... 'na grezza da paura! E allora je strillo \"Vie'"
|
|
329
329
|
},
|
|
330
|
-
|
|
330
|
+
seen: true,
|
|
331
331
|
has_boost: false
|
|
332
332
|
},
|
|
333
333
|
{
|
|
@@ -412,7 +412,7 @@ const exampleExploreData = {
|
|
|
412
412
|
poll: null,
|
|
413
413
|
title: "Un mattino P'an-shan fece visita a Seng-ts'an e lo preg\u00f2 di mostrargli la strada pi\u00f9 facile per conseguire l'illuminazione. Il maestro indic\u00f2 una consunta statua di platino e disse: \"Se davvero desideri diventare saggio devi riuscire a comprendere la"
|
|
414
414
|
},
|
|
415
|
-
|
|
415
|
+
seen: true,
|
|
416
416
|
has_boost: false
|
|
417
417
|
},
|
|
418
418
|
{
|
|
@@ -507,7 +507,7 @@ const exampleExploreData = {
|
|
|
507
507
|
addressing: [],
|
|
508
508
|
poll: null
|
|
509
509
|
},
|
|
510
|
-
|
|
510
|
+
seen: true,
|
|
511
511
|
has_boost: false
|
|
512
512
|
}
|
|
513
513
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
|
-
import { Avatar, Box, Button, CardActions, CardHeader, Chip, Collapse, Stack, Tooltip, Typography, styled, CardContent, Icon
|
|
4
|
+
import { Avatar, Box, Button, CardActions, CardHeader, Chip, Collapse, Stack, Tooltip, Typography, styled, CardContent, Icon } from '@mui/material';
|
|
5
5
|
import FeedObjectSkeleton from './Skeleton';
|
|
6
6
|
import DateTimeAgo from '../../shared/DateTimeAgo';
|
|
7
7
|
import Bullet from '../../shared/Bullet';
|
|
@@ -44,6 +44,10 @@ const messages = defineMessages({
|
|
|
44
44
|
visibleToGroup: {
|
|
45
45
|
id: 'ui.feedObject.visibleToGroup',
|
|
46
46
|
defaultMessage: 'ui.feedObject.visibleToGroup'
|
|
47
|
+
},
|
|
48
|
+
visibleToRecipients: {
|
|
49
|
+
id: 'ui.feedObject.visibleToRecipients',
|
|
50
|
+
defaultMessage: 'ui.feedObject.visibleToRecipients'
|
|
47
51
|
}
|
|
48
52
|
});
|
|
49
53
|
const classes = {
|
|
@@ -76,7 +80,6 @@ const classes = {
|
|
|
76
80
|
activitiesContent: `${PREFIX}-activities-content`,
|
|
77
81
|
followButton: `${PREFIX}-follow-button`,
|
|
78
82
|
vote: `${PREFIX}-vote`,
|
|
79
|
-
objElement: `${PREFIX}-obj-element`,
|
|
80
83
|
new: `${PREFIX}-new`
|
|
81
84
|
};
|
|
82
85
|
const Root = styled(Widget, {
|
|
@@ -136,7 +139,7 @@ const Root = styled(Widget, {
|
|
|
136
139
|
* @param inProps
|
|
137
140
|
*/
|
|
138
141
|
export default function FeedObject(inProps) {
|
|
139
|
-
var _a, _b, _c, _d, _f, _g, _h, _j;
|
|
142
|
+
var _a, _b, _c, _d, _f, _g, _h, _j, _k;
|
|
140
143
|
// PROPS
|
|
141
144
|
const props = useThemeProps({
|
|
142
145
|
props: inProps,
|
|
@@ -151,8 +154,6 @@ export default function FeedObject(inProps) {
|
|
|
151
154
|
const { preferences } = useSCPreferences();
|
|
152
155
|
const allShareEnabled = SCPreferences.ADDONS_SHARE_POST_ENABLED in preferences && preferences[SCPreferences.ADDONS_SHARE_POST_ENABLED].value;
|
|
153
156
|
const commentsEnabled = SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED in preferences && preferences[SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED].value;
|
|
154
|
-
// HOOKS
|
|
155
|
-
const theme = useTheme();
|
|
156
157
|
// OBJECTS
|
|
157
158
|
const { obj, setObj, error } = useSCFetchFeedObject({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
|
|
158
159
|
const objId = obj ? obj.id : null;
|
|
@@ -441,10 +442,10 @@ export default function FeedObject(inProps) {
|
|
|
441
442
|
else if (template === SCFeedObjectTemplateType.PREVIEW ||
|
|
442
443
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
443
444
|
template === SCFeedObjectTemplateType.SEARCH) {
|
|
444
|
-
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }
|
|
445
|
+
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }) }, { children: [obj.categories.length > 0 && (_jsxs("div", Object.assign({ className: classes.category }, { children: [_jsxs(_Fragment, { children: [obj.group && (_jsx(Chip, { className: classes.group, color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id)), obj.event && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", label: obj.event.name, icon: _jsx(Icon, { children: "CalendarIcon" }), component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id))] }), obj.categories.map((c) => (_jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c) }, { children: _jsx(Typography, Object.assign({ variant: "overline" }, { children: c.name })) }), c.id)))] }))), obj.group && !obj.categories.length && (_jsx("div", Object.assign({ className: classes.group }, { children: _jsx(Chip, { color: "secondary", size: "small", icon: _jsx(Icon, { children: "groups" }), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }, obj.group.id) }))), obj.event && !obj.categories.length && (_jsx(Chip, { className: classes.event, color: "secondary", size: "small", icon: _jsx(Icon, { children: "CalendarIcon" }), label: obj.event.name, component: Link, to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, obj.event), clickable: true }, obj.event.id)), _jsx(CardHeader, { className: classes.header, avatar: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !obj.author.community_badge }, { children: _jsx(Avatar, Object.assign({ "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, { children: obj.author.username })) })) })), title: _jsx(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: obj.author.username })), subheader: _jsxs(_Fragment, { children: [scUserContext.user && markRead && _jsx("span", Object.assign({ className: classes.new }, { children: "NEW" })), _jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt }, { children: _jsx(DateTimeAgo, { component: "span", date: obj.added_at }) })), obj.location && (_jsxs(_Fragment, { children: [_jsx(Bullet, {}), _jsxs(Box, Object.assign({ className: classes.location }, { children: [_jsx(Icon, { children: "add_location_alt" }), (_a = obj.location) === null || _a === void 0 ? void 0 : _a.location] }))] })), (((_b = obj.addressing) !== null && _b !== void 0 ? _b : []).filter((tag) => tag.visible).length > 0 || (obj === null || obj === void 0 ? void 0 : obj.group)) && _jsx(Bullet, {}), _jsx(Box, Object.assign({ className: classes.tag }, { children: obj.addressing.length > 0 ? (_jsx(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "groups" })) }))) : (_jsxs(_Fragment, { children: [_jsx(Bullet, {}), ((_c = obj.recipients) === null || _c === void 0 ? void 0 : _c.length) > 0 ? (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToRecipients)}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "private" })) }))) : (_jsx(Tooltip, Object.assign({ title: `${intl.formatMessage(messages.visibleToAll)}` }, { children: _jsx(Icon, Object.assign({ color: "disabled", fontSize: "small" }, { children: "public" })) })))] })) }))] }), action: renderHeaderAction() }), _jsxs(CardContent, Object.assign({ classes: { root: classes.content } }, { children: [_jsx(Box, Object.assign({ className: classes.titleSection }, { children: 'title' in obj && (_jsx(_Fragment, { children: template === SCFeedObjectTemplateType.DETAIL ? (_jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title }))) : (_jsx(Link, Object.assign({ to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) }, { children: _jsx(Typography, Object.assign({ variant: "body1", gutterBottom: true, className: classes.title }, { children: obj.title })) }))) })) })), _jsx(Box, Object.assign({ className: classes.textSection }, { children: getContributionSummary(obj, template) })), _jsx(Box, Object.assign({ className: classes.mediasSection }, { children: _jsx(FeedObjectMediaPreview, Object.assign({ medias: obj.medias }, FeedObjectMediaPreviewProps)) })), _jsx(Box, Object.assign({ className: classes.pollsSection }, { children: obj['poll'] && (_jsx(PollObject, Object.assign({ visible: pollVisible ||
|
|
445
446
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
446
|
-
Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), !obj.draft && (_jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!commentsEnabled && !allShareEnabled ? (_jsx(Vote, { feedObjectId: feedObjectId || (feedObject === null || feedObject === void 0 ? void 0 : feedObject.id), feedObjectType: feedObjectType, feedObject: obj, inlineAction: true, onVoteAction: handleVoteSuccess, className: classes.vote })) : (!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy })))), !_hideFollowAction && _jsx(Follow, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) })))] })), _jsxs(CardActions, Object.assign({ className: classes.actionsSection }, { children: [_jsx(Actions, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideVoteAction: !allShareEnabled && !commentsEnabled, hideCommentAction: !commentsEnabled || template === SCFeedObjectTemplateType.DETAIL || (hasEvent && !((
|
|
447
|
-
((template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((
|
|
447
|
+
Boolean(obj.type !== SCContributionType.DISCUSSION && !obj.html && !obj.medias.length), feedObject: obj, pollObject: obj['poll'], onChange: handleChangePoll, onToggleVisibility: handleTogglePollVisibility }, PollObjectProps))) })), !obj.draft && (_jsx(Box, Object.assign({ className: classes.infoSection }, { children: _jsxs(Stack, Object.assign({ direction: "row", justifyContent: "space-between", alignItems: "center", spacing: 2 }, { children: [!commentsEnabled && !allShareEnabled ? (_jsx(Vote, { feedObjectId: feedObjectId || (feedObject === null || feedObject === void 0 ? void 0 : feedObject.id), feedObjectType: feedObjectType, feedObject: obj, inlineAction: true, onVoteAction: handleVoteSuccess, className: classes.vote })) : (!hideParticipantsPreview && (_jsx(ContributorsFeedObject, Object.assign({ feedObject: obj, feedObjectType: obj.type }, ContributorsFeedObjectProps, { cacheStrategy: cacheStrategy })))), !_hideFollowAction && _jsx(Follow, Object.assign({ feedObject: obj, feedObjectType: obj.type, handleFollow: handleFollow }, FollowButtonProps))] })) })))] })), _jsxs(CardActions, Object.assign({ className: classes.actionsSection }, { children: [_jsx(Actions, Object.assign({ feedObjectId: feedObjectId, feedObjectType: feedObjectType, feedObject: obj, hideVoteAction: !allShareEnabled && !commentsEnabled, hideCommentAction: !commentsEnabled || template === SCFeedObjectTemplateType.DETAIL || (hasEvent && !((_f = (_d = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _d === void 0 ? void 0 : _d.metadata) === null || _f === void 0 ? void 0 : _f.active)), hideShareAction: !allShareEnabled, handleExpandActivities: template === SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), commentsEnabled &&
|
|
448
|
+
((template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_k = (_j = (_h = (_g = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _g === void 0 ? void 0 : _g[0]) === null || _h === void 0 ? void 0 : _h.embed) === null || _j === void 0 ? void 0 : _j.metadata) === null || _k === void 0 ? void 0 : _k.active))) ||
|
|
448
449
|
expandedActivities) && (_jsx(Box, Object.assign({ className: classes.replyContent }, { children: _jsx(CommentObjectReplyComponent, Object.assign({ id: `reply-feedObject-${obj.id}`, onReply: handleReply, editable: !isReplying || Boolean(obj) }, CommentObjectReplyComponentProps), Number(isReplying)) })))] })), commentsEnabled &&
|
|
449
450
|
template === SCFeedObjectTemplateType.PREVIEW &&
|
|
450
451
|
(obj.comment_count > 0 || (feedObjectActivities && feedObjectActivities.length > 0)) && (_jsx(Collapse, Object.assign({ in: expandedActivities, timeout: "auto", classes: { root: classes.activitiesSection } }, { children: _jsx(CardContent, Object.assign({ className: classes.activitiesContent }, { children: _jsx(Activities, Object.assign({ feedObject: obj, feedObjectActivities: feedObjectActivities, activitiesType: selectedActivities, onSetSelectedActivities: handleSelectedActivities, comments: comments, CommentsObjectProps: {
|
|
@@ -461,5 +462,5 @@ export default function FeedObject(inProps) {
|
|
|
461
462
|
/**
|
|
462
463
|
* Renders root object
|
|
463
464
|
*/
|
|
464
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`) }, rest, { children: [obj && markRead && _jsx(MarkRead, { endpoint: Endpoints.FeedObjectMarkRead, data: { object: [obj.id] }, callback: handleMarkReadComplete }), objElement] })), openAlert && _jsx(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
465
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className, `${PREFIX}-${template}`) }, rest, { children: [scUserContext.user && obj && markRead && (_jsx(MarkRead, { endpoint: Endpoints.FeedObjectMarkRead, data: { object: [obj.id] }, callback: handleMarkReadComplete })), objElement] })), openAlert && _jsx(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })] }));
|
|
465
466
|
}
|