@selfcommunity/react-ui 0.7.9-alpha.7 → 0.7.9-alpha.71
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/AccountRecover/AccountRecover.js +6 -1
- package/lib/cjs/components/BottomNavigation/BottomNavigation.js +4 -3
- package/lib/cjs/components/CategoryHeader/Skeleton.js +3 -2
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +13 -10
- package/lib/cjs/components/Composer/Attributes/Attributes.js +3 -3
- package/lib/cjs/components/Composer/Composer.js +3 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
- package/lib/cjs/components/FeedObject/Contributors/Contributors.js +1 -1
- package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/cjs/components/FeedObject/FeedObject.js +27 -8
- package/lib/cjs/components/FeedObject/Poll/Poll.js +20 -20
- package/lib/cjs/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
- package/lib/cjs/components/Group/Group.d.ts +8 -0
- package/lib/cjs/components/Group/Group.js +17 -5
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
- package/lib/cjs/components/GroupForm/GroupForm.js +64 -13
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
- package/lib/cjs/components/GroupHeader/GroupHeader.js +53 -11
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +63 -9
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +31 -9
- package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +74 -0
- package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +221 -0
- package/lib/cjs/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
- package/lib/cjs/components/GroupInvitedWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupInvitedWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupInvitedWidget/constants.js +4 -0
- package/lib/cjs/components/GroupInvitedWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupInvitedWidget/index.js +8 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +8 -3
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +25 -4
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +151 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupSettingsIconButton/index.js +5 -0
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
- package/lib/cjs/components/Groups/Groups.d.ts +15 -8
- package/lib/cjs/components/Groups/Groups.js +86 -32
- package/lib/cjs/components/Groups/Skeleton.d.ts +4 -0
- package/lib/cjs/components/Groups/Skeleton.js +2 -2
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +7 -0
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/cjs/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +6 -2
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -4
- package/lib/cjs/components/Notification/Group/Group.d.ts +15 -0
- package/lib/cjs/components/Notification/Group/Group.js +78 -0
- package/lib/cjs/components/Notification/Group/index.d.ts +3 -0
- package/lib/cjs/components/Notification/Group/index.js +5 -0
- package/lib/cjs/components/Notification/Notification.js +31 -1
- package/lib/cjs/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +12 -7
- package/lib/cjs/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +1 -1
- package/lib/cjs/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
- package/lib/cjs/components/PrivateMessageSnippets/PrivateMessageSnippets.js +24 -6
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
- package/lib/cjs/components/PrivateMessageThread/PrivateMessageThread.js +45 -20
- package/lib/cjs/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +6 -0
- package/lib/cjs/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
- package/lib/cjs/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/cjs/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/cjs/components/User/User.d.ts +6 -1
- package/lib/cjs/components/User/User.js +5 -4
- package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/Skeleton.js +46 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +183 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/constants.js +4 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
- package/lib/cjs/components/UserSubscribedGroupsWidget/index.js +8 -0
- package/lib/cjs/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
- package/lib/cjs/constants/PubSub.d.ts +28 -0
- package/lib/cjs/constants/PubSub.js +22 -0
- package/lib/cjs/index.d.ts +6 -2
- package/lib/cjs/index.js +15 -4
- package/lib/esm/components/AccountRecover/AccountRecover.js +6 -1
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +5 -4
- package/lib/esm/components/CategoryHeader/Skeleton.js +3 -2
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +13 -10
- package/lib/esm/components/Composer/Attributes/Attributes.js +3 -3
- package/lib/esm/components/Composer/Composer.js +3 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +1 -1
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +9 -19
- package/lib/esm/components/FeedObject/Contributors/Contributors.js +1 -1
- package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/esm/components/FeedObject/FeedObject.js +28 -9
- package/lib/esm/components/FeedObject/Poll/Poll.js +20 -20
- package/lib/esm/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
- package/lib/esm/components/Group/Group.d.ts +8 -0
- package/lib/esm/components/Group/Group.js +21 -9
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
- package/lib/esm/components/GroupForm/GroupForm.js +64 -13
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
- package/lib/esm/components/GroupHeader/GroupHeader.js +55 -13
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +63 -9
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +31 -9
- package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.d.ts +74 -0
- package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +218 -0
- package/lib/esm/components/GroupInvitedWidget/Skeleton.d.ts +22 -0
- package/lib/esm/components/GroupInvitedWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupInvitedWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupInvitedWidget/constants.js +1 -0
- package/lib/esm/components/GroupInvitedWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupInvitedWidget/index.js +4 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +9 -4
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +26 -5
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +11 -5
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +18 -7
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +148 -0
- package/lib/esm/components/GroupSettingsIconButton/index.d.ts +3 -0
- package/lib/esm/components/GroupSettingsIconButton/index.js +2 -0
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.d.ts +8 -3
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +30 -11
- package/lib/esm/components/Groups/Groups.d.ts +15 -8
- package/lib/esm/components/Groups/Groups.js +91 -37
- package/lib/esm/components/Groups/Skeleton.d.ts +4 -0
- package/lib/esm/components/Groups/Skeleton.js +2 -2
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +9 -2
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/esm/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +7 -3
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +5 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +13 -6
- package/lib/esm/components/Notification/Group/Group.d.ts +15 -0
- package/lib/esm/components/Notification/Group/Group.js +75 -0
- package/lib/esm/components/Notification/Group/index.d.ts +3 -0
- package/lib/esm/components/Notification/Group/index.js +2 -0
- package/lib/esm/components/Notification/Notification.js +31 -1
- package/lib/esm/components/Notification/PrivateMessage/PrivateMessage.js +16 -5
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.d.ts +1 -1
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +13 -8
- package/lib/esm/components/PrivateMessageSettingsIconButton/PrivateMessageSettingsIconButton.js +1 -1
- package/lib/esm/components/PrivateMessageSnippetItem/PrivateMessageSnippetItem.js +11 -6
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.d.ts +3 -3
- package/lib/esm/components/PrivateMessageSnippets/PrivateMessageSnippets.js +26 -8
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.d.ts +6 -1
- package/lib/esm/components/PrivateMessageThread/PrivateMessageThread.js +47 -22
- package/lib/esm/components/PrivateMessageThreadItem/PrivateMessageThreadItem.js +7 -1
- package/lib/esm/components/SearchAutocomplete/SearchAutocomplete.js +22 -5
- package/lib/esm/components/SnippetNotifications/SnippetNotifications.js +7 -0
- package/lib/esm/components/ToastNotifications/ToastNotifications.js +7 -0
- package/lib/esm/components/User/User.d.ts +6 -1
- package/lib/esm/components/User/User.js +5 -4
- package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.d.ts +21 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/Skeleton.js +42 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.d.ts +68 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +180 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/constants.d.ts +1 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/constants.js +1 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/index.d.ts +4 -0
- package/lib/esm/components/UserSubscribedGroupsWidget/index.js +4 -0
- package/lib/esm/components/VoteAudienceButton/VoteAudienceButton.js +1 -1
- package/lib/esm/constants/PubSub.d.ts +28 -0
- package/lib/esm/constants/PubSub.js +19 -0
- package/lib/esm/index.d.ts +6 -2
- package/lib/esm/index.js +8 -4
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -43,7 +43,7 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
43
43
|
// @ts-ignore
|
|
44
44
|
defaultValue === null || defaultValue.length === 0
|
|
45
45
|
? AudienceTypes.AUDIENCE_ALL
|
|
46
|
-
:
|
|
46
|
+
: defaultValue && Object.prototype.hasOwnProperty.call(defaultValue, 'managed_by')
|
|
47
47
|
? AudienceTypes.AUDIENCE_GROUP
|
|
48
48
|
: AudienceTypes.AUDIENCE_TAG);
|
|
49
49
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -52,15 +52,15 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
52
52
|
// HOOKS
|
|
53
53
|
const { scAddressingTags } = useSCFetchAddressingTagList({ fetch: autocompleteOpen });
|
|
54
54
|
// HANDLERS
|
|
55
|
-
const handleSave = useCallback(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
() => (typeof defaultValue === 'object' ? onSave(value) : onSave((value === null || value === void 0 ? void 0 : value.length) && (value === null || value === void 0 ? void 0 : value.length) > 0 ? value : null)), [value, onSave]);
|
|
55
|
+
const handleSave = useCallback(() => {
|
|
56
|
+
audience === AudienceTypes.AUDIENCE_GROUP ? onSave(value) : onSave((value === null || value === void 0 ? void 0 : value.length) && (value === null || value === void 0 ? void 0 : value.length) > 0 ? value : null);
|
|
57
|
+
}, [value, onSave, audience]);
|
|
59
58
|
const handleChange = useCallback((event, tags) => setValue(tags), []);
|
|
60
59
|
const handleGroupChange = useCallback((group) => setValue(group), []);
|
|
61
60
|
const handleChangeAudience = useCallback((event, data) => setAudience(data), []);
|
|
62
61
|
const handleAutocompleteOpen = useCallback(() => setAutocompleteOpen(true), []);
|
|
63
62
|
const handleAutocompleteClose = useCallback(() => setAutocompleteOpen(false), []);
|
|
63
|
+
console.log(defaultValue);
|
|
64
64
|
return (React.createElement(Root, Object.assign({ ref: ref, className: classNames(className, classes.root) }, rest),
|
|
65
65
|
React.createElement(DialogTitle, { className: classes.title },
|
|
66
66
|
React.createElement(IconButton, { onClick: onClose },
|
|
@@ -72,20 +72,10 @@ const AudienceLayer = React.forwardRef((props, ref) => {
|
|
|
72
72
|
React.createElement(DialogContent, { className: classes.content },
|
|
73
73
|
React.createElement(Tabs, { value: audience, onChange: handleChangeAudience, "aria-label": "audience type" },
|
|
74
74
|
React.createElement(Tab, { value: AudienceTypes.AUDIENCE_ALL, icon: React.createElement(Icon, null, "public"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
|
|
75
|
-
React.createElement(Tab
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
, {
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
disabled: defaultValue && defaultValue.length !== 0, value: AudienceTypes.AUDIENCE_GROUP, icon: React.createElement(Icon, null, "groups"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) }),
|
|
82
|
-
React.createElement(Tab
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
, {
|
|
86
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
disabled: typeof defaultValue === 'object', value: AudienceTypes.AUDIENCE_TAG, icon: React.createElement(Icon, null, "label"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
|
|
75
|
+
React.createElement(Tab, { disabled: (Boolean(value === null || value === void 0 ? void 0 : value.length) && !Object.prototype.hasOwnProperty.call(value, 'managed_by')) ||
|
|
76
|
+
(value !== undefined && Boolean(!(value === null || value === void 0 ? void 0 : value.length)) && audience !== AudienceTypes.AUDIENCE_ALL) ||
|
|
77
|
+
(Boolean((value === null || value === void 0 ? void 0 : value.length) === 0) && audience === AudienceTypes.AUDIENCE_ALL && Boolean((defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.length) !== 0)), value: AudienceTypes.AUDIENCE_GROUP, icon: React.createElement(Icon, null, "groups"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) }),
|
|
78
|
+
React.createElement(Tab, { disabled: value && Object.prototype.hasOwnProperty.call(value, 'managed_by'), value: AudienceTypes.AUDIENCE_TAG, icon: React.createElement(Icon, null, "label"), label: React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
|
|
89
79
|
React.createElement(Typography, { className: classes.message },
|
|
90
80
|
audience === AudienceTypes.AUDIENCE_ALL && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
|
|
91
81
|
audience === AudienceTypes.AUDIENCE_GROUP && (React.createElement(FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.audience.layer.group.message" })),
|
|
@@ -58,5 +58,5 @@ export default function ContributorsFeedObject(props) {
|
|
|
58
58
|
openContributorsDialog && (React.createElement(BaseDialog, { title: React.createElement(FormattedMessage, { defaultMessage: "ui.feedObject.contributors.title", id: "ui.feedObject.contributors.title", values: { total: contributorsObject.total } }), onClose: () => setOpenContributorsDialog(false), open: openContributorsDialog }, contributorsObject.isLoadingNext ? (React.createElement(CentralProgress, { size: 50 })) : (React.createElement(InfiniteScroll, { dataLength: contributorsObject.contributors.length, next: contributorsObject.getNextPage(), hasMoreNext: Boolean(contributorsObject.next), loaderNext: React.createElement(CentralProgress, { size: 30 }), height: 400, endMessage: React.createElement(Typography, { variant: "body2", align: "center", fontWeight: "bold" },
|
|
59
59
|
React.createElement(FormattedMessage, { id: "ui.feedObject.contributors.noOtherContributors", defaultMessage: "ui.feedObject.contributors.noOtherContributors" })) },
|
|
60
60
|
React.createElement(List, null, contributorsObject.contributors.map((c, i) => (React.createElement(ListItem, { key: i },
|
|
61
|
-
React.createElement(User, { elevation: 0, user: c, key: c.id, sx: { m: 0 } }))))))))))) : null)))));
|
|
61
|
+
React.createElement(User, { elevation: 0, user: c, key: c.id, sx: { m: 0 }, onClick: () => setOpenContributorsDialog(false) }))))))))))) : null)))));
|
|
62
62
|
}
|
|
@@ -188,6 +188,7 @@ export interface FeedObjectProps extends CardProps, VirtualScrollerItemProps {
|
|
|
188
188
|
|deleted|.SCFeedObject-deleted|Styles applied to the feed obj when is deleted (visible only for admin and moderator).|
|
|
189
189
|
|header|.SCFeedObject-header|Styles applied to the header of the card.|
|
|
190
190
|
|category|.SCFeedObject-category|Styles applied to the category element.|
|
|
191
|
+
|group|.SCFeedObject-group|Styles applied to the group element.|
|
|
191
192
|
|avatar|.SCFeedObject-avatar|Styles applied to the avatar element.|
|
|
192
193
|
|username|.SCFeedObject-username|Styles applied to the username element.|
|
|
193
194
|
|activityAt|.SCFeedObject-activity-at|Styles applied to the activity at section.|
|
|
@@ -2,7 +2,7 @@ import { __rest } from "tslib";
|
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
import CardContent from '@mui/material/CardContent';
|
|
5
|
-
import { Avatar, Box, Button, CardActions, CardHeader, Collapse, Stack, Tooltip, Typography } from '@mui/material';
|
|
5
|
+
import { Avatar, Box, Button, CardActions, CardHeader, Chip, Collapse, Stack, Tooltip, Typography } from '@mui/material';
|
|
6
6
|
import FeedObjectSkeleton from './Skeleton';
|
|
7
7
|
import DateTimeAgo from '../../shared/DateTimeAgo';
|
|
8
8
|
import Bullet from '../../shared/Bullet';
|
|
@@ -40,6 +40,10 @@ const messages = defineMessages({
|
|
|
40
40
|
visibleToAll: {
|
|
41
41
|
id: 'ui.feedObject.visibleToAll',
|
|
42
42
|
defaultMessage: 'ui.feedObject.visibleToAll'
|
|
43
|
+
},
|
|
44
|
+
visibleToGroup: {
|
|
45
|
+
id: 'ui.feedObject.visibleToGroup',
|
|
46
|
+
defaultMessage: 'ui.feedObject.visibleToGroup'
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
49
|
const classes = {
|
|
@@ -47,6 +51,7 @@ const classes = {
|
|
|
47
51
|
deleted: `${PREFIX}-deleted`,
|
|
48
52
|
header: `${PREFIX}-header`,
|
|
49
53
|
category: `${PREFIX}-category`,
|
|
54
|
+
group: `${PREFIX}-group`,
|
|
50
55
|
avatar: `${PREFIX}-avatar`,
|
|
51
56
|
username: `${PREFIX}-username`,
|
|
52
57
|
activityAt: `${PREFIX}-activity-at`,
|
|
@@ -100,6 +105,7 @@ const Root = styled(Widget, {
|
|
|
100
105
|
|deleted|.SCFeedObject-deleted|Styles applied to the feed obj when is deleted (visible only for admin and moderator).|
|
|
101
106
|
|header|.SCFeedObject-header|Styles applied to the header of the card.|
|
|
102
107
|
|category|.SCFeedObject-category|Styles applied to the category element.|
|
|
108
|
+
|group|.SCFeedObject-group|Styles applied to the group element.|
|
|
103
109
|
|avatar|.SCFeedObject-avatar|Styles applied to the avatar element.|
|
|
104
110
|
|username|.SCFeedObject-username|Styles applied to the username element.|
|
|
105
111
|
|activityAt|.SCFeedObject-activity-at|Styles applied to the activity at section.|
|
|
@@ -167,7 +173,7 @@ export default function FeedObject(inProps) {
|
|
|
167
173
|
}, [onStateChange, onHeightChange]);
|
|
168
174
|
/**
|
|
169
175
|
* Update state object
|
|
170
|
-
* @param
|
|
176
|
+
* @param newObj
|
|
171
177
|
*/
|
|
172
178
|
const updateObject = (newObj) => {
|
|
173
179
|
setObj(newObj);
|
|
@@ -196,8 +202,10 @@ export default function FeedObject(inProps) {
|
|
|
196
202
|
/**
|
|
197
203
|
* Handle change/update poll: votes
|
|
198
204
|
*/
|
|
199
|
-
const handleChangePoll = useCallback((
|
|
200
|
-
|
|
205
|
+
const handleChangePoll = useCallback((pollChoices) => {
|
|
206
|
+
if ('poll' in obj) {
|
|
207
|
+
updateObject(Object.assign({}, obj, { poll: Object.assign(Object.assign({}, obj.poll), { choices: pollChoices }) }));
|
|
208
|
+
}
|
|
201
209
|
}, [obj]);
|
|
202
210
|
/**
|
|
203
211
|
* Handle change poll visibility
|
|
@@ -424,8 +432,13 @@ export default function FeedObject(inProps) {
|
|
|
424
432
|
template === SCFeedObjectTemplateType.DETAIL ||
|
|
425
433
|
template === SCFeedObjectTemplateType.SEARCH) {
|
|
426
434
|
objElement = (React.createElement(React.Fragment, null, obj ? (React.createElement(Box, { className: classNames({ [classes.deleted]: obj && obj.deleted }) },
|
|
427
|
-
obj.categories.length > 0 && (React.createElement("div", { className: classes.category },
|
|
428
|
-
React.createElement(
|
|
435
|
+
obj.categories.length > 0 && (React.createElement("div", { className: classes.category },
|
|
436
|
+
React.createElement(React.Fragment, null, obj.group && (React.createElement("div", { className: classes.group },
|
|
437
|
+
React.createElement(Chip, { color: "secondary", size: "small", key: obj.group.id, icon: React.createElement(Icon, null, "groups"), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true })))),
|
|
438
|
+
obj.categories.map((c) => (React.createElement(Link, { to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
|
|
439
|
+
React.createElement(Typography, { variant: "overline" }, c.name)))))),
|
|
440
|
+
obj.group && !obj.categories.length && (React.createElement("div", { className: classes.group },
|
|
441
|
+
React.createElement(Chip, { color: "secondary", size: "small", key: obj.group.id, icon: React.createElement(Icon, null, "groups"), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }))),
|
|
429
442
|
React.createElement(CardHeader, { className: classes.header, avatar: React.createElement(Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }),
|
|
430
443
|
React.createElement(UserAvatar, { hide: !obj.author.community_badge },
|
|
431
444
|
React.createElement(Avatar, { "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, obj.author.username))), title: React.createElement(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 }), obj.author.username), subheader: React.createElement(React.Fragment, null,
|
|
@@ -437,7 +450,8 @@ export default function FeedObject(inProps) {
|
|
|
437
450
|
React.createElement(Icon, null, "add_location_alt"), (_a = obj.location) === null || _a === void 0 ? void 0 :
|
|
438
451
|
_a.location))),
|
|
439
452
|
React.createElement(Bullet, null),
|
|
440
|
-
React.createElement(Box, { className: classes.tag }, obj.addressing.length > 0 ? (React.createElement(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : (React.createElement(Tooltip, { title: `${intl.formatMessage(messages.
|
|
453
|
+
React.createElement(Box, { className: classes.tag }, obj.addressing.length > 0 ? (React.createElement(Tags, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (React.createElement(Tooltip, { title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` },
|
|
454
|
+
React.createElement(Icon, { color: "disabled", fontSize: "small" }, "groups"))) : (React.createElement(Tooltip, { title: `${intl.formatMessage(messages.visibleToAll)}` },
|
|
441
455
|
React.createElement(Icon, { color: "disabled", fontSize: "small" }, "public"))))), action: renderHeaderAction() }),
|
|
442
456
|
React.createElement(CardContent, { classes: { root: classes.content } },
|
|
443
457
|
React.createElement(Box, { className: classes.titleSection }, 'title' in obj && (React.createElement(React.Fragment, null, template === SCFeedObjectTemplateType.DETAIL ? (React.createElement(Typography, { variant: "body1", gutterBottom: true, className: classes.title }, obj.title)) : (React.createElement(Link, { to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)) },
|
|
@@ -466,8 +480,13 @@ export default function FeedObject(inProps) {
|
|
|
466
480
|
}
|
|
467
481
|
else if (template === SCFeedObjectTemplateType.SHARE) {
|
|
468
482
|
objElement = (React.createElement(React.Fragment, null, obj ? (React.createElement(React.Fragment, null,
|
|
469
|
-
obj.categories.length > 0 && (React.createElement("div", { className: classes.category },
|
|
470
|
-
React.createElement(
|
|
483
|
+
obj.categories.length > 0 && (React.createElement("div", { className: classes.category },
|
|
484
|
+
React.createElement(React.Fragment, null, obj.group && (React.createElement("div", { className: classes.group },
|
|
485
|
+
React.createElement(Chip, { color: "secondary", size: "small", key: obj.group.id, icon: React.createElement(Icon, null, "groups"), component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true })))),
|
|
486
|
+
obj.categories.map((c) => (React.createElement(Link, { to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
|
|
487
|
+
React.createElement(Typography, { variant: "overline" }, c.name)))))),
|
|
488
|
+
obj.group && !obj.categories.length && (React.createElement("div", { className: classes.group },
|
|
489
|
+
React.createElement(Chip, { color: "secondary", size: "small", key: obj.group.id, icon: React.createElement(Icon, null, "groups"), label: obj.group.name, component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }))),
|
|
471
490
|
React.createElement(CardHeader, { classes: { root: classes.header }, avatar: React.createElement(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 }),
|
|
472
491
|
React.createElement(UserAvatar, { hide: !obj.author.community_badge },
|
|
473
492
|
React.createElement(Avatar, { "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, obj.author.username))), title: React.createElement(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 }), obj.author.username), subheader: React.createElement(Link, { to: scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj)), className: classes.activityAt },
|
|
@@ -67,36 +67,36 @@ export default function PollObject(props) {
|
|
|
67
67
|
* Handles choice upvote
|
|
68
68
|
*/
|
|
69
69
|
const handleVote = (id) => {
|
|
70
|
+
const prevChoices = [...choices];
|
|
71
|
+
let updatedChoices;
|
|
70
72
|
if (multipleChoices) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}));
|
|
76
|
-
});
|
|
73
|
+
updatedChoices = prevChoices.map((choice) => Object.assign({}, choice, {
|
|
74
|
+
voted: choice.id === id ? true : choice.voted,
|
|
75
|
+
vote_count: choice.id === id ? choice.vote_count + 1 : choice.vote_count
|
|
76
|
+
}));
|
|
77
77
|
setVotes((prevVotes) => prevVotes + 1);
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
setVotes(newVotes);
|
|
86
|
-
return updatedChoices;
|
|
87
|
-
});
|
|
80
|
+
updatedChoices = prevChoices.map((choice) => Object.assign({}, choice, {
|
|
81
|
+
voted: choice.id === id,
|
|
82
|
+
vote_count: choice.id === id ? choice.vote_count + 1 : choice.vote_count > 0 && choice.voted ? choice.vote_count - 1 : choice.vote_count
|
|
83
|
+
}));
|
|
84
|
+
setVotes(updatedChoices.reduce((totalVotes, choice) => totalVotes + choice.vote_count, 0));
|
|
88
85
|
}
|
|
86
|
+
setChoices(updatedChoices);
|
|
87
|
+
onChange(updatedChoices);
|
|
89
88
|
};
|
|
90
89
|
/**
|
|
91
90
|
* Handles choice unvote
|
|
92
91
|
*/
|
|
93
92
|
const handleUnVote = (id) => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
const prevChoices = [...choices];
|
|
94
|
+
const updatedChoices = prevChoices.map((choice) => Object.assign({}, choice, {
|
|
95
|
+
voted: choice.id === id ? false : choice.voted,
|
|
96
|
+
vote_count: choice.id === id && choice.vote_count > 0 ? choice.vote_count - 1 : choice.vote_count
|
|
97
|
+
}));
|
|
98
|
+
setChoices(updatedChoices);
|
|
99
|
+
onChange(updatedChoices);
|
|
100
100
|
setVotes((prevVotes) => prevVotes - 1);
|
|
101
101
|
};
|
|
102
102
|
/**
|
|
@@ -55,7 +55,7 @@ export default function FeedUpdatesWidget(inProps) {
|
|
|
55
55
|
const [updates, setUpdates] = useState(false);
|
|
56
56
|
// REFS
|
|
57
57
|
const updatesSubscription = useRef(null);
|
|
58
|
-
//
|
|
58
|
+
// Subscriber for pubsub callback
|
|
59
59
|
const subscriber = (msg, data) => {
|
|
60
60
|
if (subscriptionChannelUpdatesCallback(msg, data)) {
|
|
61
61
|
setUpdates(true);
|
|
@@ -27,6 +27,11 @@ export interface GroupProps extends WidgetProps {
|
|
|
27
27
|
* @default false
|
|
28
28
|
*/
|
|
29
29
|
hideActions?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Prop to redirect the user to the group page
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
actionRedirect?: boolean;
|
|
30
35
|
/**
|
|
31
36
|
* Props to spread to the button
|
|
32
37
|
* @default {}
|
|
@@ -61,6 +66,9 @@ export interface GroupProps extends WidgetProps {
|
|
|
61
66
|
|---|---|---|
|
|
62
67
|
|root|.SCGroup-root|Styles applied to the root element.|
|
|
63
68
|
|avatar|.SCGroup-avatar|Styles applied to the avatar element.|
|
|
69
|
+
|actions|.SCGroup-actions|Styles applied to the actions section.|
|
|
70
|
+
|icon|.SCGroup-icon|Styles applied to the group privacy icon element.|
|
|
71
|
+
|
|
64
72
|
|
|
65
73
|
*
|
|
66
74
|
* @param inProps
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import React, { useState } from 'react';
|
|
2
|
+
import React, { useMemo, useState } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { Avatar, Icon, Stack } from '@mui/material';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { Avatar, Button, Icon, Stack } from '@mui/material';
|
|
5
|
+
import { SCGroupPrivacyType, SCGroupSubscriptionStatusType } from '@selfcommunity/types';
|
|
6
|
+
import { Link, SCRoutes, useSCFetchGroup, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
7
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
7
8
|
import classNames from 'classnames';
|
|
8
9
|
import { useThemeProps } from '@mui/system';
|
|
9
10
|
import BaseItemButton from '../../shared/BaseItemButton';
|
|
@@ -20,7 +21,8 @@ const messages = defineMessages({
|
|
|
20
21
|
const classes = {
|
|
21
22
|
root: `${PREFIX}-root`,
|
|
22
23
|
avatar: `${PREFIX}-avatar`,
|
|
23
|
-
actions: `${PREFIX}-actions
|
|
24
|
+
actions: `${PREFIX}-actions`,
|
|
25
|
+
icon: `${PREFIX}-icon`
|
|
24
26
|
};
|
|
25
27
|
const Root = styled(BaseItemButton, {
|
|
26
28
|
name: PREFIX,
|
|
@@ -51,21 +53,28 @@ const Root = styled(BaseItemButton, {
|
|
|
51
53
|
|---|---|---|
|
|
52
54
|
|root|.SCGroup-root|Styles applied to the root element.|
|
|
53
55
|
|avatar|.SCGroup-avatar|Styles applied to the avatar element.|
|
|
56
|
+
|actions|.SCGroup-actions|Styles applied to the actions section.|
|
|
57
|
+
|icon|.SCGroup-icon|Styles applied to the group privacy icon element.|
|
|
58
|
+
|
|
54
59
|
|
|
55
60
|
*
|
|
56
61
|
* @param inProps
|
|
57
62
|
*/
|
|
58
63
|
export default function Group(inProps) {
|
|
64
|
+
var _a;
|
|
59
65
|
// PROPS
|
|
60
66
|
const props = useThemeProps({
|
|
61
67
|
props: inProps,
|
|
62
68
|
name: PREFIX
|
|
63
69
|
});
|
|
64
|
-
const { groupId = null, group = null, className = null, elevation, hideActions = false,
|
|
70
|
+
const { groupId = null, group = null, className = null, elevation, hideActions = false, actionRedirect = false, groupSubscribeButtonProps = {} } = props, rest = __rest(props, ["groupId", "group", "className", "elevation", "hideActions", "actionRedirect", "groupSubscribeButtonProps"]);
|
|
65
71
|
// STATE
|
|
66
72
|
const { scGroup } = useSCFetchGroup({ id: groupId, group });
|
|
67
73
|
// CONTEXT
|
|
68
74
|
const scRoutingContext = useSCRouting();
|
|
75
|
+
const scUserContext = useSCUser();
|
|
76
|
+
// CONST
|
|
77
|
+
const isGroupAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
69
78
|
const [openAlert, setOpenAlert] = useState(false);
|
|
70
79
|
// INTL
|
|
71
80
|
const intl = useIntl();
|
|
@@ -75,8 +84,8 @@ export default function Group(inProps) {
|
|
|
75
84
|
*/
|
|
76
85
|
function renderAuthenticatedActions() {
|
|
77
86
|
return (React.createElement(Stack, { className: classes.actions, direction: "row", alignItems: "center", justifyContent: "center", spacing: 2 },
|
|
78
|
-
React.createElement(Icon, null,
|
|
79
|
-
React.createElement(GroupSubscribeButton, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps))));
|
|
87
|
+
isGroupAdmin && React.createElement(Icon, null, "face"),
|
|
88
|
+
actionRedirect ? (React.createElement(Button, { size: "small", variant: "outlined", component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, scGroup) }, scGroup.subscription_status === SCGroupSubscriptionStatusType.SUBSCRIBED ? (React.createElement(FormattedMessage, { defaultMessage: "ui.group.status.enter", id: "ui.group.status.enter" })) : (React.createElement(FormattedMessage, { defaultMessage: "ui.group.status.discover", id: "ui.group.status.discover" })))) : (React.createElement(GroupSubscribeButton, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps)))));
|
|
80
89
|
}
|
|
81
90
|
/**
|
|
82
91
|
* Renders group object
|
|
@@ -88,6 +97,9 @@ export default function Group(inProps) {
|
|
|
88
97
|
* Renders root object
|
|
89
98
|
*/
|
|
90
99
|
return (React.createElement(React.Fragment, null,
|
|
91
|
-
React.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: classNames(classes.root, className), ButtonBaseProps: { component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: React.createElement(Avatar, { alt: scGroup.name, src: scGroup.image_medium, className: classes.avatar }), primary:
|
|
100
|
+
React.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: classNames(classes.root, className), ButtonBaseProps: { component: Link, to: scRoutingContext.url(SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: React.createElement(Avatar, { alt: scGroup.name, src: scGroup.image_medium, className: classes.avatar }), primary: React.createElement(React.Fragment, null,
|
|
101
|
+
scGroup.name,
|
|
102
|
+
" ",
|
|
103
|
+
React.createElement(Icon, { className: classes.icon }, (group === null || group === void 0 ? void 0 : group.privacy) === SCGroupPrivacyType.PRIVATE ? 'private' : 'public')), secondary: `${intl.formatMessage(messages.groupMembers, { total: scGroup.subscribers_counter })}`, actions: hideActions ? null : renderAuthenticatedActions() })),
|
|
92
104
|
openAlert && React.createElement(UserDeletedSnackBar, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
93
105
|
}
|
|
@@ -78,7 +78,7 @@ const GroupAutocomplete = (inProps) => {
|
|
|
78
78
|
setValue(value);
|
|
79
79
|
};
|
|
80
80
|
// Render
|
|
81
|
-
return (React.createElement(Root, Object.assign({
|
|
81
|
+
return (React.createElement(Root, Object.assign({ className: classes.root, open: open, onOpen: handleOpen, onClose: handleClose, options: groups || [], getOptionLabel: (option) => option.name || '', value: value, selectOnFocus: true, clearOnBlur: true, blurOnSelect: true, handleHomeEndKeys: true, clearIcon: null, disabled: disabled || isLoading, noOptionsText: React.createElement(FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
|
|
82
82
|
// renderTags={(value, getTagProps) => {
|
|
83
83
|
// return value.map((option: any, index) => (
|
|
84
84
|
// <Chip key={option.id} id={option.id} label={option.name} color={option.color} {...getTagProps({index})} />
|
|
@@ -13,10 +13,12 @@ import ChangeGroupPicture from '../ChangeGroupPicture';
|
|
|
13
13
|
import ChangeGroupCover from '../ChangeGroupCover';
|
|
14
14
|
import { GROUP_DESCRIPTION_MAX_LENGTH, GROUP_TITLE_MAX_LENGTH } from '../../constants/Group';
|
|
15
15
|
import GroupInviteButton from '../GroupInviteButton';
|
|
16
|
+
import PubSub from 'pubsub-js';
|
|
16
17
|
import { SCGroupPrivacyType } from '@selfcommunity/types';
|
|
17
18
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
18
19
|
import { formatHttpErrorCode, GroupService } from '@selfcommunity/api-services';
|
|
19
20
|
import { Logger } from '@selfcommunity/utils';
|
|
21
|
+
import { SCEventType, SCTopicType } from '../../constants/PubSub';
|
|
20
22
|
const messages = defineMessages({
|
|
21
23
|
name: {
|
|
22
24
|
id: 'ui.groupForm.name.placeholder',
|
|
@@ -88,6 +90,7 @@ const Root = styled(BaseDialog, {
|
|
|
88
90
|
* @param inProps
|
|
89
91
|
*/
|
|
90
92
|
export default function GroupForm(inProps) {
|
|
93
|
+
var _a;
|
|
91
94
|
//PROPS
|
|
92
95
|
const props = useThemeProps({
|
|
93
96
|
props: inProps,
|
|
@@ -140,6 +143,22 @@ export default function GroupForm(inProps) {
|
|
|
140
143
|
setError(error);
|
|
141
144
|
}
|
|
142
145
|
}
|
|
146
|
+
/**
|
|
147
|
+
* Notify when a group info changed
|
|
148
|
+
* @param data
|
|
149
|
+
*/
|
|
150
|
+
function notifyChanges(data) {
|
|
151
|
+
if (data) {
|
|
152
|
+
if (group) {
|
|
153
|
+
// Edit group
|
|
154
|
+
PubSub.publish(`${SCTopicType.GROUP}.${SCEventType.EDIT}`, data);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
// Create group
|
|
158
|
+
PubSub.publish(`${SCTopicType.GROUP}.${SCEventType.CREATE}`, data);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
143
162
|
const handleSubmit = () => {
|
|
144
163
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
|
|
145
164
|
const formData = new FormData();
|
|
@@ -153,8 +172,10 @@ export default function GroupForm(inProps) {
|
|
|
153
172
|
if (field.emotionalImageOriginalFile) {
|
|
154
173
|
formData.append('emotional_image_original', field.emotionalImageOriginalFile);
|
|
155
174
|
}
|
|
156
|
-
|
|
157
|
-
|
|
175
|
+
if (!group) {
|
|
176
|
+
for (const key in field.invitedUsers) {
|
|
177
|
+
formData.append(key, field.invitedUsers[key]);
|
|
178
|
+
}
|
|
158
179
|
}
|
|
159
180
|
let groupService;
|
|
160
181
|
if (group) {
|
|
@@ -166,6 +187,7 @@ export default function GroupForm(inProps) {
|
|
|
166
187
|
groupService
|
|
167
188
|
.then((data) => {
|
|
168
189
|
onSuccess && onSuccess(data);
|
|
190
|
+
notifyChanges(data);
|
|
169
191
|
onClose && onClose();
|
|
170
192
|
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
171
193
|
})
|
|
@@ -204,33 +226,62 @@ export default function GroupForm(inProps) {
|
|
|
204
226
|
endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_TITLE_MAX_LENGTH - field.name.length)
|
|
205
227
|
} }),
|
|
206
228
|
React.createElement(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
207
|
-
endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_DESCRIPTION_MAX_LENGTH - field.description.length)
|
|
229
|
+
endAdornment: (React.createElement(Typography, { variant: "body2" }, ((_a = field.description) === null || _a === void 0 ? void 0 : _a.length) ? GROUP_DESCRIPTION_MAX_LENGTH - field.description.length : GROUP_DESCRIPTION_MAX_LENGTH))
|
|
208
230
|
} }),
|
|
209
231
|
React.createElement(Box, { className: classes.privacySection },
|
|
210
232
|
React.createElement(Typography, { variant: "h4" },
|
|
211
|
-
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: {
|
|
233
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: {
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
235
|
+
// @ts-ignore
|
|
236
|
+
b: (chunks) => React.createElement("strong", null, chunks)
|
|
237
|
+
} })),
|
|
212
238
|
React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
213
239
|
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) },
|
|
214
240
|
React.createElement(Icon, null, "private"),
|
|
215
241
|
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
|
|
216
|
-
React.createElement(Switch, { className: classes.switch, checked: field.isPublic,
|
|
242
|
+
React.createElement(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: group && group.privacy === SCGroupPrivacyType.PRIVATE }),
|
|
217
243
|
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) },
|
|
218
244
|
React.createElement(Icon, null, "public"),
|
|
219
245
|
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" }))),
|
|
220
|
-
React.createElement(Typography, { variant: "body2", className: classes.privacySectionInfo }, field.isPublic ? (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: {
|
|
221
|
-
|
|
246
|
+
React.createElement(Typography, { variant: "body2", className: classes.privacySectionInfo }, field.isPublic ? (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: {
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
248
|
+
// @ts-ignore
|
|
249
|
+
b: (chunks) => React.createElement("strong", null, chunks)
|
|
250
|
+
} })) : (React.createElement(React.Fragment, null, group && group.privacy === SCGroupPrivacyType.PRIVATE ? (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info.edit", defaultMessage: "ui.groupForm.private.public.info.edit", values: {
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
252
|
+
// @ts-ignore
|
|
253
|
+
b: (chunks) => React.createElement("strong", null, chunks)
|
|
254
|
+
} })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: {
|
|
255
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
256
|
+
// @ts-ignore
|
|
257
|
+
b: (chunks) => React.createElement("strong", null, chunks)
|
|
258
|
+
} })))))),
|
|
259
|
+
React.createElement(Box, { className: classes.visibilitySection }, ((!field.isPublic && !group) || (group && !field.isPublic)) && (React.createElement(React.Fragment, null,
|
|
222
260
|
React.createElement(Typography, { variant: "h4" },
|
|
223
|
-
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.title", defaultMessage: "ui.groupForm.visibility.title", values: {
|
|
261
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.title", defaultMessage: "ui.groupForm.visibility.title", values: {
|
|
262
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
263
|
+
// @ts-ignore
|
|
264
|
+
b: (chunks) => React.createElement("strong", null, chunks)
|
|
265
|
+
} })),
|
|
224
266
|
React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
225
267
|
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !field.isVisible }) },
|
|
226
268
|
React.createElement(Icon, null, "visibility_off"),
|
|
227
269
|
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
|
|
228
|
-
React.createElement(Switch, { className: classes.switch, checked: field.isVisible,
|
|
270
|
+
React.createElement(Switch, { className: classes.switch, checked: field.isVisible, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isVisible']: !field.isVisible }))) }),
|
|
229
271
|
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: field.isVisible }) },
|
|
230
272
|
React.createElement(Icon, null, "visibility"),
|
|
231
273
|
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" }))),
|
|
232
|
-
React.createElement(Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !field.isVisible ? (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
274
|
+
React.createElement(Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !field.isVisible ? (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: {
|
|
275
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
276
|
+
// @ts-ignore
|
|
277
|
+
b: (chunks) => React.createElement("strong", null, chunks)
|
|
278
|
+
} })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: {
|
|
279
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
280
|
+
// @ts-ignore
|
|
281
|
+
b: (chunks) => React.createElement("strong", null, chunks)
|
|
282
|
+
} }))))))),
|
|
283
|
+
!group && (React.createElement(React.Fragment, null,
|
|
284
|
+
React.createElement(Divider, null),
|
|
285
|
+
React.createElement(Box, { className: classes.inviteSection },
|
|
286
|
+
React.createElement(GroupInviteButton, { handleInvitations: handleInviteSection })))))));
|
|
236
287
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { SCGroupType } from '@selfcommunity/types';
|
|
3
2
|
import { ChangeGroupCoverProps } from '../ChangeGroupCover';
|
|
4
3
|
import { ChangeGroupPictureProps } from '../ChangeGroupPicture';
|
|
5
4
|
import { GroupMembersButtonProps } from '../GroupMembersButton';
|
|
5
|
+
import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
|
|
6
6
|
export interface GroupHeaderProps {
|
|
7
7
|
/**
|
|
8
8
|
* Id of group object
|
|
@@ -35,14 +35,15 @@ export interface GroupHeaderProps {
|
|
|
35
35
|
*/
|
|
36
36
|
ChangeCoverProps?: ChangeGroupCoverProps;
|
|
37
37
|
/**
|
|
38
|
-
* Props to spread
|
|
38
|
+
* Props to spread group button followed
|
|
39
39
|
* @default {}
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
GroupSubscribeButtonProps?: GroupSubscribeButtonProps;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Props to spread to the group memebers button
|
|
44
|
+
* @default {}
|
|
44
45
|
*/
|
|
45
|
-
|
|
46
|
+
GroupMembersButtonProps?: GroupMembersButtonProps;
|
|
46
47
|
/**
|
|
47
48
|
* Any other properties
|
|
48
49
|
*/
|