@selfcommunity/react-ui 0.11.0-alpha.79 → 0.11.0-alpha.80
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/FeedObject/FeedObject.js +3 -1
- package/lib/cjs/shared/ContributionActionsMenu/index.js +9 -5
- package/lib/esm/components/FeedObject/FeedObject.js +4 -2
- package/lib/esm/shared/ContributionActionsMenu/index.js +9 -5
- package/lib/umd/react-ui.js +1 -1
- package/package.json +2 -2
|
@@ -153,6 +153,8 @@ function FeedObject(inProps) {
|
|
|
153
153
|
const { preferences } = (0, react_core_1.useSCPreferences)();
|
|
154
154
|
const allShareEnabled = react_core_1.SCPreferences.ADDONS_SHARE_POST_ENABLED in preferences && preferences[react_core_1.SCPreferences.ADDONS_SHARE_POST_ENABLED].value;
|
|
155
155
|
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)();
|
|
156
158
|
// OBJECTS
|
|
157
159
|
const { obj, setObj, error } = (0, react_core_1.useSCFetchFeedObject)({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
|
|
158
160
|
const objId = obj ? obj.id : null;
|
|
@@ -441,7 +443,7 @@ function FeedObject(inProps) {
|
|
|
441
443
|
else if (template === feedObject_1.SCFeedObjectTemplateType.PREVIEW ||
|
|
442
444
|
template === feedObject_1.SCFeedObjectTemplateType.DETAIL ||
|
|
443
445
|
template === feedObject_1.SCFeedObjectTemplateType.SEARCH) {
|
|
444
|
-
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 }, classes.objElement) }, { children: [markRead && (0, jsx_runtime_1.jsx)("span", { className: classes.new }), obj.categories.length > 0 && ((0, jsx_runtime_1.jsxs)(
|
|
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 }, classes.objElement) }, { children: [markRead && (0, jsx_runtime_1.jsx)("span", { className: classes.new }), obj.categories.length > 0 && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.category, sx: { paddingLeft: markRead ? theme.spacing(1) : undefined } }, { 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: [(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, {}), (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 ||
|
|
445
447
|
template === feedObject_1.SCFeedObjectTemplateType.DETAIL ||
|
|
446
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 && !((_d = (_c = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.active)), hideShareAction: !allShareEnabled, handleExpandActivities: template === feedObject_1.SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), commentsEnabled &&
|
|
447
449
|
((template === feedObject_1.SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_j = (_h = (_g = (_f = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.embed) === null || _h === void 0 ? void 0 : _h.metadata) === null || _j === void 0 ? void 0 : _j.active))) ||
|
|
@@ -36,12 +36,12 @@ const classes = {
|
|
|
36
36
|
const PopperRoot = (0, material_1.styled)(material_1.Popper, {
|
|
37
37
|
name: PREFIX,
|
|
38
38
|
slot: 'Root',
|
|
39
|
-
overridesResolver: (
|
|
39
|
+
overridesResolver: (_props, styles) => styles.popperRoot
|
|
40
40
|
})(() => ({}));
|
|
41
41
|
const Root = (0, material_1.styled)(material_1.Box, {
|
|
42
42
|
name: PREFIX,
|
|
43
43
|
slot: 'Root',
|
|
44
|
-
overridesResolver: (
|
|
44
|
+
overridesResolver: (_props, styles) => styles.root
|
|
45
45
|
})(() => ({}));
|
|
46
46
|
const messages = (0, react_intl_1.defineMessages)({
|
|
47
47
|
title: {
|
|
@@ -113,13 +113,17 @@ function ContributionActionsMenu(props) {
|
|
|
113
113
|
const scheduledPostsEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
114
114
|
react_core_1.SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED in preferences &&
|
|
115
115
|
preferences[react_core_1.SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED].value, [preferences]);
|
|
116
|
+
const postOnlyStaffEnabled = (0, react_1.useMemo)(() => preferences &&
|
|
117
|
+
react_core_1.SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED in preferences &&
|
|
118
|
+
preferences[react_core_1.SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value, [preferences]);
|
|
116
119
|
/**
|
|
117
120
|
* Intial extra sections to render, in addition to the GENERAL_SECTION
|
|
118
121
|
* @return {array}
|
|
119
122
|
*/
|
|
120
123
|
const getExtraSections = (0, react_1.useMemo)(() => () => {
|
|
121
124
|
let _extra = [];
|
|
122
|
-
if (
|
|
125
|
+
if (!postOnlyStaffEnabled &&
|
|
126
|
+
scUserContext.user &&
|
|
123
127
|
Boolean(contributionObj) &&
|
|
124
128
|
scUserId !== contributionObj.author.id &&
|
|
125
129
|
!contributionObj.deleted &&
|
|
@@ -127,13 +131,13 @@ function ContributionActionsMenu(props) {
|
|
|
127
131
|
_extra.push(ContributionsActionsMenu_1.FLAG_CONTRIBUTION_SECTION);
|
|
128
132
|
}
|
|
129
133
|
// Enable when backend is ready
|
|
130
|
-
if (react_core_1.UserUtils.isAdmin(scUserContext.user) || react_core_1.UserUtils.isModerator(scUserContext.user)) {
|
|
134
|
+
if ((!postOnlyStaffEnabled && react_core_1.UserUtils.isAdmin(scUserContext.user)) || react_core_1.UserUtils.isModerator(scUserContext.user)) {
|
|
131
135
|
// admin or moderator
|
|
132
136
|
_extra.push(ContributionsActionsMenu_1.HIDE_CONTRIBUTION_SECTION);
|
|
133
137
|
_extra.push(ContributionsActionsMenu_1.DELETE_CONTRIBUTION_SECTION);
|
|
134
138
|
}
|
|
135
139
|
return _extra;
|
|
136
|
-
}, [contributionObj, scUserId]);
|
|
140
|
+
}, [postOnlyStaffEnabled, contributionObj, scUserId]);
|
|
137
141
|
/**
|
|
138
142
|
* Extra sections to render in the popup
|
|
139
143
|
*/
|
|
@@ -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 } from '@mui/material';
|
|
4
|
+
import { Avatar, Box, Button, CardActions, CardHeader, Chip, Collapse, Stack, Tooltip, Typography, styled, CardContent, Icon, useTheme } from '@mui/material';
|
|
5
5
|
import FeedObjectSkeleton from './Skeleton';
|
|
6
6
|
import DateTimeAgo from '../../shared/DateTimeAgo';
|
|
7
7
|
import Bullet from '../../shared/Bullet';
|
|
@@ -151,6 +151,8 @@ export default function FeedObject(inProps) {
|
|
|
151
151
|
const { preferences } = useSCPreferences();
|
|
152
152
|
const allShareEnabled = SCPreferences.ADDONS_SHARE_POST_ENABLED in preferences && preferences[SCPreferences.ADDONS_SHARE_POST_ENABLED].value;
|
|
153
153
|
const commentsEnabled = SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED in preferences && preferences[SCPreferences.CONFIGURATIONS_COMMENTS_ENABLED].value;
|
|
154
|
+
// HOOKS
|
|
155
|
+
const theme = useTheme();
|
|
154
156
|
// OBJECTS
|
|
155
157
|
const { obj, setObj, error } = useSCFetchFeedObject({ id: feedObjectId, feedObject, feedObjectType, cacheStrategy });
|
|
156
158
|
const objId = obj ? obj.id : null;
|
|
@@ -439,7 +441,7 @@ export default function FeedObject(inProps) {
|
|
|
439
441
|
else if (template === SCFeedObjectTemplateType.PREVIEW ||
|
|
440
442
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
441
443
|
template === SCFeedObjectTemplateType.SEARCH) {
|
|
442
|
-
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }, classes.objElement) }, { children: [markRead && _jsx("span", { className: classes.new }), obj.categories.length > 0 && (_jsxs(
|
|
444
|
+
objElement = (_jsx(React.Fragment, { children: obj ? (_jsxs(Box, Object.assign({ className: classNames({ [classes.deleted]: obj && obj.deleted }, classes.objElement) }, { children: [markRead && _jsx("span", { className: classes.new }), obj.categories.length > 0 && (_jsxs(Box, Object.assign({ className: classes.category, sx: { paddingLeft: markRead ? theme.spacing(1) : undefined } }, { 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: [_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, {}), _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 ||
|
|
443
445
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
444
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 && !((_d = (_c = obj === null || obj === void 0 ? void 0 : obj.medias[0].embed) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.active)), hideShareAction: !allShareEnabled, handleExpandActivities: template === SCFeedObjectTemplateType.PREVIEW ? handleExpandActivities : null, VoteActionProps: { onVoteAction: handleVoteSuccess } }, ActionsProps)), commentsEnabled &&
|
|
445
447
|
((template === SCFeedObjectTemplateType.DETAIL && (!hasEvent || ((_j = (_h = (_g = (_f = obj === null || obj === void 0 ? void 0 : obj.medias) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.embed) === null || _h === void 0 ? void 0 : _h.metadata) === null || _j === void 0 ? void 0 : _j.active))) ||
|
|
@@ -34,12 +34,12 @@ const classes = {
|
|
|
34
34
|
const PopperRoot = styled(Popper, {
|
|
35
35
|
name: PREFIX,
|
|
36
36
|
slot: 'Root',
|
|
37
|
-
overridesResolver: (
|
|
37
|
+
overridesResolver: (_props, styles) => styles.popperRoot
|
|
38
38
|
})(() => ({}));
|
|
39
39
|
const Root = styled(Box, {
|
|
40
40
|
name: PREFIX,
|
|
41
41
|
slot: 'Root',
|
|
42
|
-
overridesResolver: (
|
|
42
|
+
overridesResolver: (_props, styles) => styles.root
|
|
43
43
|
})(() => ({}));
|
|
44
44
|
const messages = defineMessages({
|
|
45
45
|
title: {
|
|
@@ -111,13 +111,17 @@ export default function ContributionActionsMenu(props) {
|
|
|
111
111
|
const scheduledPostsEnabled = useMemo(() => preferences &&
|
|
112
112
|
SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED in preferences &&
|
|
113
113
|
preferences[SCPreferences.CONFIGURATIONS_SCHEDULED_POSTS_ENABLED].value, [preferences]);
|
|
114
|
+
const postOnlyStaffEnabled = useMemo(() => preferences &&
|
|
115
|
+
SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED in preferences &&
|
|
116
|
+
preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value, [preferences]);
|
|
114
117
|
/**
|
|
115
118
|
* Intial extra sections to render, in addition to the GENERAL_SECTION
|
|
116
119
|
* @return {array}
|
|
117
120
|
*/
|
|
118
121
|
const getExtraSections = useMemo(() => () => {
|
|
119
122
|
let _extra = [];
|
|
120
|
-
if (
|
|
123
|
+
if (!postOnlyStaffEnabled &&
|
|
124
|
+
scUserContext.user &&
|
|
121
125
|
Boolean(contributionObj) &&
|
|
122
126
|
scUserId !== contributionObj.author.id &&
|
|
123
127
|
!contributionObj.deleted &&
|
|
@@ -125,13 +129,13 @@ export default function ContributionActionsMenu(props) {
|
|
|
125
129
|
_extra.push(FLAG_CONTRIBUTION_SECTION);
|
|
126
130
|
}
|
|
127
131
|
// Enable when backend is ready
|
|
128
|
-
if (UserUtils.isAdmin(scUserContext.user) || UserUtils.isModerator(scUserContext.user)) {
|
|
132
|
+
if ((!postOnlyStaffEnabled && UserUtils.isAdmin(scUserContext.user)) || UserUtils.isModerator(scUserContext.user)) {
|
|
129
133
|
// admin or moderator
|
|
130
134
|
_extra.push(HIDE_CONTRIBUTION_SECTION);
|
|
131
135
|
_extra.push(DELETE_CONTRIBUTION_SECTION);
|
|
132
136
|
}
|
|
133
137
|
return _extra;
|
|
134
|
-
}, [contributionObj, scUserId]);
|
|
138
|
+
}, [postOnlyStaffEnabled, contributionObj, scUserId]);
|
|
135
139
|
/**
|
|
136
140
|
* Extra sections to render in the popup
|
|
137
141
|
*/
|