@selfcommunity/react-ui 0.7.9-alpha.8 → 0.7.9-alpha.81
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/ChangeGroupCover/ChangeGroupCover.js +6 -6
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +19 -16
- 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/Editor/Editor.js +2 -0
- package/lib/cjs/components/Editor/nodes/ImageNode.js +6 -0
- package/lib/cjs/components/Editor/plugins/ImagePlugin.js +4 -0
- package/lib/cjs/components/Editor/plugins/ToolbarPlugin.js +17 -3
- package/lib/cjs/components/FeedObject/Actions/Share/Share.js +18 -16
- 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/Footer/Footer.js +1 -1
- package/lib/cjs/components/Group/Group.d.ts +9 -1
- package/lib/cjs/components/Group/Group.js +18 -6
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +0 -1
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +1 -2
- package/lib/cjs/components/GroupForm/GroupForm.js +64 -13
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -6
- package/lib/cjs/components/GroupHeader/GroupHeader.js +53 -12
- 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 +73 -0
- package/lib/cjs/components/GroupInvitedWidget/GroupInvitedWidget.js +220 -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 +12 -7
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +19 -9
- 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/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +9 -2
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +9 -1
- 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 +7 -1
- package/lib/cjs/components/PrivateMessageComponent/PrivateMessageComponent.js +16 -8
- 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 +9 -4
- 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 +46 -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 -3
- package/lib/cjs/index.js +13 -4
- package/lib/cjs/types/index.d.ts +2 -1
- 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/ChangeGroupCover/ChangeGroupCover.js +6 -6
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +19 -16
- 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/Editor/Editor.js +2 -0
- package/lib/esm/components/Editor/nodes/ImageNode.js +6 -0
- package/lib/esm/components/Editor/plugins/ImagePlugin.js +4 -0
- package/lib/esm/components/Editor/plugins/ToolbarPlugin.js +19 -5
- package/lib/esm/components/FeedObject/Actions/Share/Share.js +19 -17
- 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/Footer/Footer.js +2 -2
- package/lib/esm/components/Group/Group.d.ts +9 -1
- package/lib/esm/components/Group/Group.js +22 -10
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +0 -1
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +1 -2
- package/lib/esm/components/GroupForm/GroupForm.js +64 -13
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -6
- package/lib/esm/components/GroupHeader/GroupHeader.js +55 -14
- 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 +73 -0
- package/lib/esm/components/GroupInvitedWidget/GroupInvitedWidget.js +217 -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 +12 -7
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +19 -9
- 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/NavigationSettingsIconButton/NavigationSettingsIconButton.js +4 -4
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +10 -3
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +1 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -3
- 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 +7 -1
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +17 -9
- 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 +9 -4
- 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 +48 -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 -3
- package/lib/esm/index.js +6 -3
- package/lib/esm/types/index.d.ts +2 -1
- package/lib/umd/311.js +2 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +9 -9
- package/lib/umd/871.js +0 -2
- /package/lib/umd/{871.js.LICENSE.txt → 311.js.LICENSE.txt} +0 -0
|
@@ -57,12 +57,12 @@ export default function ChangeGroupPicture(inProps) {
|
|
|
57
57
|
name: PREFIX
|
|
58
58
|
});
|
|
59
59
|
const { groupId, onChange, autoHide, className, isCreationMode = false } = props, rest = __rest(props, ["groupId", "onChange", "autoHide", "className", "isCreationMode"]);
|
|
60
|
+
//CONTEXT
|
|
61
|
+
const scUserContext = useContext(SCUserContext);
|
|
60
62
|
//STATE
|
|
63
|
+
let fileInput = useRef(null);
|
|
61
64
|
const [loading, setLoading] = useState(false);
|
|
62
65
|
const [alert, setAlert] = useState(null);
|
|
63
|
-
let fileInput = useRef(null);
|
|
64
|
-
//CONTEXT
|
|
65
|
-
const scUserContext = useContext(SCUserContext);
|
|
66
66
|
// INTL
|
|
67
67
|
const intl = useIntl();
|
|
68
68
|
// Anonymous
|
|
@@ -73,44 +73,47 @@ export default function ChangeGroupPicture(inProps) {
|
|
|
73
73
|
* Handles avatar upload
|
|
74
74
|
* @param event
|
|
75
75
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const handleUpload = (event) => {
|
|
77
|
+
fileInput = event.target.files[0];
|
|
78
78
|
if (fileInput) {
|
|
79
79
|
const reader = new FileReader();
|
|
80
80
|
reader.onload = (e) => {
|
|
81
81
|
const img = new Image();
|
|
82
82
|
img.onload = () => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
else {
|
|
87
|
-
|
|
88
|
-
}
|
|
83
|
+
isCreationMode ? onChange && onChange(fileInput) : handleSave();
|
|
84
|
+
// if (img.width < 600 && img.height < 600) {
|
|
85
|
+
// setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
86
|
+
// } else {
|
|
87
|
+
// isCreationMode ? onChange && onChange(fileInput) : handleSave();
|
|
88
|
+
// }
|
|
89
89
|
};
|
|
90
90
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
91
91
|
// @ts-ignore
|
|
92
92
|
img.src = e.target.result;
|
|
93
93
|
};
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
95
|
+
// @ts-ignore
|
|
94
96
|
reader.readAsDataURL(fileInput);
|
|
95
97
|
}
|
|
96
|
-
}
|
|
97
|
-
// ui.changeGroupPicture.alert
|
|
98
|
+
};
|
|
98
99
|
/**
|
|
99
100
|
* Performs save avatar after upload
|
|
100
101
|
*/
|
|
101
102
|
function handleSave() {
|
|
102
103
|
setLoading(true);
|
|
103
104
|
const formData = new FormData();
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
106
|
+
// @ts-ignore
|
|
104
107
|
formData.append('image_original', fileInput);
|
|
105
108
|
GroupService.changeGroupAvatarOrCover(groupId, formData, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
106
109
|
.then((data) => {
|
|
110
|
+
onChange && onChange(data.image_big);
|
|
107
111
|
setLoading(false);
|
|
108
|
-
onChange && onChange(data.image_bigger);
|
|
109
112
|
})
|
|
110
113
|
.catch((error) => {
|
|
111
|
-
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
112
|
-
setLoading(false);
|
|
113
114
|
Logger.error(SCOPE_SC_UI, error);
|
|
115
|
+
setLoading(false);
|
|
116
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
114
117
|
});
|
|
115
118
|
}
|
|
116
119
|
/**
|
|
@@ -13,7 +13,7 @@ const Root = styled(Box, {
|
|
|
13
13
|
slot: 'AttributesRoot'
|
|
14
14
|
})(() => ({}));
|
|
15
15
|
export default (props) => {
|
|
16
|
-
var _a, _b;
|
|
16
|
+
var _a, _b, _c;
|
|
17
17
|
// PROPS
|
|
18
18
|
const { className = null, value = null, onChange = null, onClick = null } = props;
|
|
19
19
|
// HANDLERS
|
|
@@ -44,8 +44,8 @@ export default (props) => {
|
|
|
44
44
|
return (React.createElement(Root, { className: classNames(classes.root, className) },
|
|
45
45
|
((_a = value === null || value === void 0 ? void 0 : value.categories) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
46
46
|
(value === null || value === void 0 ? void 0 : value.categories.map((c) => (React.createElement(Chip, { key: c.id, label: c.name, onDelete: handleDeleteCategory(c.id), icon: React.createElement(Icon, null, "category"), onClick: handleClickCategory })))),
|
|
47
|
-
(value === null || value === void 0 ? void 0 : value.group) && (React.createElement(Chip, { key: value === null || value === void 0 ? void 0 : value.group.id, label: value === null || value === void 0 ? void 0 : value.group.name, onDelete: handleDeleteGroup, icon: React.createElement(Icon, null, "groups"), onClick: handleClickGroup })),
|
|
48
|
-
((
|
|
47
|
+
(value === null || value === void 0 ? void 0 : value.group) && (React.createElement(Chip, { key: value === null || value === void 0 ? void 0 : value.group.id, label: value === null || value === void 0 ? void 0 : value.group.name, onDelete: handleDeleteGroup, icon: React.createElement(Icon, null, "groups"), onClick: handleClickGroup, disabled: !((_b = value === null || value === void 0 ? void 0 : value.group) === null || _b === void 0 ? void 0 : _b.subscription_status) })),
|
|
48
|
+
((_c = value === null || value === void 0 ? void 0 : value.addressing) === null || _c === void 0 ? void 0 : _c.length) > 0 &&
|
|
49
49
|
(value === null || value === void 0 ? void 0 : value.addressing.map((t) => (React.createElement(TagChip, { key: t.id, tag: t, onDelete: handleDeleteTag(t.id), icon: React.createElement(Icon, null, "label"), onClick: handleClickTag })))),
|
|
50
50
|
(value === null || value === void 0 ? void 0 : value.location) && (React.createElement(Chip, { icon: React.createElement(Icon, null, "add_location_alt"), label: value === null || value === void 0 ? void 0 : value.location.location, onDelete: handleDeleteLocation, onClick: handleClickLocation }))));
|
|
51
51
|
};
|
|
@@ -305,7 +305,7 @@ export default function Composer(inProps) {
|
|
|
305
305
|
}
|
|
306
306
|
}), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
|
|
307
307
|
const handleChangeAudience = useCallback((value) => {
|
|
308
|
-
if (group ||
|
|
308
|
+
if (group || (value && Object.prototype.hasOwnProperty.call(value, 'managed_by'))) {
|
|
309
309
|
dispatch({ type: 'group', value });
|
|
310
310
|
}
|
|
311
311
|
else {
|
|
@@ -319,7 +319,7 @@ export default function Composer(inProps) {
|
|
|
319
319
|
ComponentProps: {
|
|
320
320
|
onClose: handleRemoveLayer,
|
|
321
321
|
onSave: handleChangeAudience,
|
|
322
|
-
defaultValue: group ||
|
|
322
|
+
defaultValue: group || (addressing && Object.prototype.hasOwnProperty.call(addressing, 'managed_by')) ? group : addressing
|
|
323
323
|
}
|
|
324
324
|
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, group]);
|
|
325
325
|
const handleChangeLocation = useCallback((value) => {
|
|
@@ -551,7 +551,7 @@ export default function Composer(inProps) {
|
|
|
551
551
|
}),
|
|
552
552
|
React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddCategoryLayer },
|
|
553
553
|
React.createElement(Icon, null, "category")),
|
|
554
|
-
React.createElement(IconButton, { disabled: isSubmitting || !features.includes(SCFeatureName.TAGGING), onClick: handleAddAudienceLayer }, addressing === null || addressing.length === 0 ?
|
|
554
|
+
React.createElement(IconButton, { disabled: isSubmitting || !features.includes(SCFeatureName.TAGGING) || Boolean(feedObject === null || feedObject === void 0 ? void 0 : feedObject.group), onClick: handleAddAudienceLayer }, (!group && addressing === null) || (addressing === null || addressing === void 0 ? void 0 : addressing.length) === 0 ? React.createElement(Icon, null, "public") : group ? React.createElement(Icon, null, "groups") : React.createElement(Icon, null, "label")),
|
|
555
555
|
preferences[SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED].value && (React.createElement(IconButton, { disabled: isSubmitting, onClick: handleAddLocationLayer, color: location !== null ? 'primary' : 'default' },
|
|
556
556
|
React.createElement(Icon, null, "add_location_alt"))))),
|
|
557
557
|
layer && (React.createElement(LayerTransitionRoot, { className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" },
|
|
@@ -10,7 +10,7 @@ export declare enum AudienceTypes {
|
|
|
10
10
|
AUDIENCE_GROUP = "group"
|
|
11
11
|
}
|
|
12
12
|
export interface AudienceLayerProps extends Omit<BoxProps, 'defaultValue'>, ComposerLayerProps {
|
|
13
|
-
defaultValue: SCTagType[] | SCGroupType;
|
|
13
|
+
defaultValue: SCTagType[] | SCGroupType | any;
|
|
14
14
|
TextFieldProps?: TextFieldProps;
|
|
15
15
|
}
|
|
16
16
|
declare const AudienceLayer: React.ForwardRefExoticComponent<Pick<AudienceLayerProps, "p" | "slot" | "style" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "border" | "borderTop" | "borderRight" | "borderBottom" | "borderLeft" | "borderColor" | "borderRadius" | "display" | "displayPrint" | "overflow" | "textOverflow" | "visibility" | "whiteSpace" | "flexBasis" | "flexDirection" | "flexWrap" | "justifyContent" | "alignItems" | "alignContent" | "order" | "flex" | "flexGrow" | "flexShrink" | "alignSelf" | "justifyItems" | "justifySelf" | "gap" | "columnGap" | "rowGap" | "gridColumn" | "gridRow" | "gridAutoFlow" | "gridAutoColumns" | "gridAutoRows" | "gridTemplateColumns" | "gridTemplateRows" | "gridTemplateAreas" | "gridArea" | "bgcolor" | "zIndex" | "position" | "top" | "right" | "bottom" | "left" | "boxShadow" | "width" | "maxWidth" | "minWidth" | "height" | "maxHeight" | "minHeight" | "boxSizing" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "my" | "pt" | "pr" | "pb" | "pl" | "px" | "py" | "margin" | "marginTop" | "marginRight" | "marginBottom" | "marginLeft" | "marginX" | "marginY" | "marginInline" | "marginInlineStart" | "marginInlineEnd" | "marginBlock" | "marginBlockStart" | "marginBlockEnd" | "padding" | "paddingTop" | "paddingRight" | "paddingBottom" | "paddingLeft" | "paddingX" | "paddingY" | "paddingInline" | "paddingInlineStart" | "paddingInlineEnd" | "paddingBlock" | "paddingBlockStart" | "paddingBlockEnd" | "typography" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "letterSpacing" | "lineHeight" | "textAlign" | "textTransform" | "component" | "sx" | "classes" | "onClose" | "TextFieldProps" | "onSave"> & React.RefAttributes<unknown>>;
|
|
@@ -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" })),
|
|
@@ -101,6 +101,8 @@ function convertImageElement(domNode) {
|
|
|
101
101
|
}
|
|
102
102
|
return null;
|
|
103
103
|
}
|
|
104
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
105
|
+
// @ts-ignore
|
|
104
106
|
export class ImageNode extends DecoratorNode {
|
|
105
107
|
constructor(src, altText, maxWidth, key) {
|
|
106
108
|
super(key);
|
|
@@ -166,8 +168,12 @@ export class ImageNode extends DecoratorNode {
|
|
|
166
168
|
}
|
|
167
169
|
exportJSON() {
|
|
168
170
|
return {
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
172
|
+
// @ts-ignore
|
|
169
173
|
altText: this.getAltText(),
|
|
170
174
|
maxWidth: this.__maxWidth,
|
|
175
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
176
|
+
// @ts-ignore
|
|
171
177
|
src: this.getSrc(),
|
|
172
178
|
type: 'image',
|
|
173
179
|
version: 1
|
|
@@ -76,6 +76,8 @@ const Root = styled(Image, {
|
|
|
76
76
|
export default function ImagePlugin() {
|
|
77
77
|
const [editor] = useLexicalComposerContext();
|
|
78
78
|
useEffect(() => {
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
80
|
+
// @ts-ignore
|
|
79
81
|
if (!editor.hasNodes([ImageNode])) {
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
@@ -92,6 +94,8 @@ export default function ImagePlugin() {
|
|
|
92
94
|
return true;
|
|
93
95
|
}, COMMAND_PRIORITY_EDITOR);
|
|
94
96
|
}, [editor]);
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
98
|
+
// @ts-ignore
|
|
95
99
|
if (!editor.hasNodes([ImageNode])) {
|
|
96
100
|
return null;
|
|
97
101
|
}
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { $createParagraphNode, $getSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, COMMAND_PRIORITY_CRITICAL,
|
|
8
|
+
import { $createParagraphNode, $getSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, COMMAND_PRIORITY_CRITICAL, FORMAT_ELEMENT_COMMAND, FORMAT_TEXT_COMMAND, SELECTION_CHANGE_COMMAND } from 'lexical';
|
|
9
9
|
import { $isLinkNode, TOGGLE_LINK_COMMAND } from '@lexical/link';
|
|
10
10
|
import { $isListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListNode, REMOVE_LIST_COMMAND } from '@lexical/list';
|
|
11
11
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
12
12
|
import { $isDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode';
|
|
13
13
|
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode } from '@lexical/rich-text';
|
|
14
14
|
import { $setBlocksType } from '@lexical/selection';
|
|
15
|
-
import { $isTableNode } from '@lexical/table';
|
|
15
|
+
import { $isTableNode, $isTableSelection } from '@lexical/table';
|
|
16
16
|
import { $findMatchingParent, $getNearestBlockElementAncestorOrThrow, $getNearestNodeOfType, mergeRegister } from '@lexical/utils';
|
|
17
17
|
import * as React from 'react';
|
|
18
18
|
import { useCallback, useEffect, useState } from 'react';
|
|
@@ -47,7 +47,7 @@ function BlockFormatIconButton({ className = '', editor, blockType, disabled = f
|
|
|
47
47
|
const formatParagraph = () => {
|
|
48
48
|
editor.update(() => {
|
|
49
49
|
const selection = $getSelection();
|
|
50
|
-
if ($isRangeSelection(selection) ||
|
|
50
|
+
if ($isRangeSelection(selection) || $isTableSelection(selection)) {
|
|
51
51
|
$setBlocksType(selection, () => $createParagraphNode());
|
|
52
52
|
}
|
|
53
53
|
});
|
|
@@ -56,7 +56,7 @@ function BlockFormatIconButton({ className = '', editor, blockType, disabled = f
|
|
|
56
56
|
if (blockType !== headingSize) {
|
|
57
57
|
editor.update(() => {
|
|
58
58
|
const selection = $getSelection();
|
|
59
|
-
if ($isRangeSelection(selection) ||
|
|
59
|
+
if ($isRangeSelection(selection) || $isTableSelection(selection)) {
|
|
60
60
|
$setBlocksType(selection, () => $createHeadingNode(headingSize));
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -82,7 +82,7 @@ function BlockFormatIconButton({ className = '', editor, blockType, disabled = f
|
|
|
82
82
|
if (blockType !== 'quote') {
|
|
83
83
|
editor.update(() => {
|
|
84
84
|
const selection = $getSelection();
|
|
85
|
-
if ($isRangeSelection(selection) ||
|
|
85
|
+
if ($isRangeSelection(selection) || $isTableSelection(selection)) {
|
|
86
86
|
$setBlocksType(selection, () => $createQuoteNode());
|
|
87
87
|
}
|
|
88
88
|
});
|
|
@@ -166,6 +166,8 @@ export default function ToolbarPlugin(inProps) {
|
|
|
166
166
|
const elementDOM = activeEditor.getElementByKey(elementKey);
|
|
167
167
|
// Update text format
|
|
168
168
|
setFormats(FORMATS.filter((f) => selection.hasFormat(f)));
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
170
|
+
// @ts-ignore
|
|
169
171
|
setAlignment(ALIGNMENTS.find((a) => element.getFormatType() === a) || ALIGNMENTS[0]);
|
|
170
172
|
// Update links
|
|
171
173
|
const node = getSelectedNode(selection);
|
|
@@ -191,6 +193,8 @@ export default function ToolbarPlugin(inProps) {
|
|
|
191
193
|
setBlockType(type);
|
|
192
194
|
}
|
|
193
195
|
else {
|
|
196
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
197
|
+
// @ts-ignore
|
|
194
198
|
const type = $isHeadingNode(element) ? element.getTag() : element.getType();
|
|
195
199
|
if (type in blockTypeToBlockIcon) {
|
|
196
200
|
setBlockType(type);
|
|
@@ -233,12 +237,22 @@ export default function ToolbarPlugin(inProps) {
|
|
|
233
237
|
node = node.splitText(anchor.offset)[1] || node;
|
|
234
238
|
}
|
|
235
239
|
if (idx === nodes.length - 1) {
|
|
240
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
241
|
+
// @ts-ignore
|
|
236
242
|
node = node.splitText(focus.offset)[0] || node;
|
|
237
243
|
}
|
|
244
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
245
|
+
// @ts-ignore
|
|
238
246
|
if (node.__style !== '') {
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
248
|
+
// @ts-ignore
|
|
239
249
|
node.setStyle('');
|
|
240
250
|
}
|
|
251
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
252
|
+
// @ts-ignore
|
|
241
253
|
if (node.__format !== 0) {
|
|
254
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
255
|
+
// @ts-ignore
|
|
242
256
|
node.setFormat(0);
|
|
243
257
|
$getNearestBlockElementAncestorOrThrow(node).setFormat('');
|
|
244
258
|
}
|
|
@@ -13,7 +13,7 @@ import { SCOPE_SC_UI } from '../../../../constants/Errors';
|
|
|
13
13
|
import classNames from 'classnames';
|
|
14
14
|
import { useSnackbar } from 'notistack';
|
|
15
15
|
import Skeleton from '@mui/material/Skeleton';
|
|
16
|
-
import { SCContributionType } from '@selfcommunity/types';
|
|
16
|
+
import { SCContributionType, SCGroupPrivacyType } from '@selfcommunity/types';
|
|
17
17
|
import { Endpoints, http } from '@selfcommunity/api-services';
|
|
18
18
|
import { copyTextToClipboard, Logger } from '@selfcommunity/utils';
|
|
19
19
|
import { SCPreferences, SCPreferencesContext, UserUtils, useSCContext, useSCFetchFeedObject, useSCRouting, useSCUser } from '@selfcommunity/react-core';
|
|
@@ -68,6 +68,7 @@ export default function Share(props) {
|
|
|
68
68
|
const { enqueueSnackbar } = useSnackbar();
|
|
69
69
|
const domain = typeof location !== 'undefined' && location.origin ? location.origin : '';
|
|
70
70
|
const url = domain + scRoutingContext.url(getContributionRouteName(obj), getRouteData(obj));
|
|
71
|
+
const isGroupPublic = useMemo(() => feedObject.group && feedObject.group.privacy === SCGroupPrivacyType.PUBLIC, [feedObject.group]);
|
|
71
72
|
// INTL
|
|
72
73
|
const intl = useIntl();
|
|
73
74
|
// HANDLERS
|
|
@@ -186,22 +187,23 @@ export default function Share(props) {
|
|
|
186
187
|
}
|
|
187
188
|
function renderShareMenuItems() {
|
|
188
189
|
return (React.createElement(Box, null,
|
|
189
|
-
|
|
190
|
-
React.createElement(
|
|
191
|
-
React.createElement(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
React.createElement(
|
|
195
|
-
React.createElement(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
React.createElement(
|
|
199
|
-
React.createElement(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
React.createElement(
|
|
203
|
-
React.createElement(
|
|
204
|
-
|
|
190
|
+
(!feedObject.group || isGroupPublic) && (React.createElement(React.Fragment, null,
|
|
191
|
+
React.createElement(MenuItem, { onClick: () => share(false) },
|
|
192
|
+
React.createElement(ListItemIcon, null,
|
|
193
|
+
React.createElement(Icon, { fontSize: "small" }, "redo")),
|
|
194
|
+
React.createElement(ListItemText, { primary: React.createElement(FormattedMessage, { id: "ui.feedObject.share.shareNow", defaultMessage: "ui.feedObject.share.shareNow" }) })),
|
|
195
|
+
facebookShareEnabled && (React.createElement(MenuItem, { onClick: () => window.open(FACEBOOK_SHARE + url, 'facebook-share-dialog', 'width=626,height=436') },
|
|
196
|
+
React.createElement(ListItemIcon, null,
|
|
197
|
+
React.createElement(Icon, { fontSize: "small" }, "facebook")),
|
|
198
|
+
React.createElement(ListItemText, { primary: React.createElement(FormattedMessage, { id: "ui.feedObject.share.facebook", defaultMessage: "ui.feedObject.share.facebook" }) }))),
|
|
199
|
+
twitterShareEnabled && (React.createElement(MenuItem, { onClick: () => window.open(TWITTER_SHARE + url, 'twitter-share-dialog', 'width=626,height=436') },
|
|
200
|
+
React.createElement(ListItemIcon, null,
|
|
201
|
+
React.createElement(Icon, { fontSize: "small" }, "twitter")),
|
|
202
|
+
React.createElement(ListItemText, { primary: React.createElement(FormattedMessage, { id: "ui.feedObject.share.twitter", defaultMessage: "ui.feedObject.share.twitter" }) }))),
|
|
203
|
+
linkedinShareEnabled && (React.createElement(MenuItem, { onClick: () => window.open(LINKEDIN_SHARE + url, 'linkedin-share-dialog', 'width=626,height=436') },
|
|
204
|
+
React.createElement(ListItemIcon, null,
|
|
205
|
+
React.createElement(Icon, { fontSize: "small" }, "linkedin")),
|
|
206
|
+
React.createElement(ListItemText, { primary: React.createElement(FormattedMessage, { id: "ui.feedObject.share.linkedin", defaultMessage: "ui.feedObject.share.linkedin" }) }))))),
|
|
205
207
|
React.createElement(MenuItem, null,
|
|
206
208
|
React.createElement(ListItemIcon, null,
|
|
207
209
|
React.createElement(Icon, { fontSize: "small" }, "link")),
|
|
@@ -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);
|