@selfcommunity/react-ui 0.7.9-alpha.5 → 0.7.9-alpha.50
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/CategoryHeader/Skeleton.js +3 -2
- package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
- package/lib/cjs/components/Composer/Attributes/Attributes.js +3 -3
- package/lib/cjs/components/Composer/Composer.js +3 -5
- package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +4 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +2 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +8 -9
- package/lib/cjs/components/EditGroupButton/EditGroupButton.js +4 -0
- package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/cjs/components/FeedObject/FeedObject.js +23 -6
- package/lib/cjs/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
- package/lib/cjs/components/Group/Group.d.ts +3 -0
- package/lib/cjs/components/Group/Group.js +16 -4
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
- package/lib/cjs/components/GroupForm/GroupForm.js +31 -9
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -5
- package/lib/cjs/components/GroupHeader/GroupHeader.js +53 -11
- package/lib/cjs/components/GroupHeader/Skeleton.d.ts +2 -4
- package/lib/cjs/components/GroupHeader/Skeleton.js +10 -10
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +40 -7
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +33 -46
- 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 +7 -2
- 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 +145 -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 +31 -10
- package/lib/cjs/components/Groups/Groups.d.ts +19 -16
- package/lib/cjs/components/Groups/Groups.js +89 -85
- package/lib/cjs/components/Groups/Skeleton.d.ts +4 -0
- package/lib/cjs/components/Groups/Skeleton.js +2 -2
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
- 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/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/constants/PubSub.d.ts +28 -0
- package/lib/cjs/constants/PubSub.js +22 -0
- package/lib/cjs/index.d.ts +5 -2
- package/lib/cjs/index.js +12 -4
- package/lib/esm/components/CategoryHeader/Skeleton.js +3 -2
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +24 -1
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
- package/lib/esm/components/Composer/Attributes/Attributes.js +3 -3
- package/lib/esm/components/Composer/Composer.js +3 -5
- package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +4 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +2 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +8 -9
- package/lib/esm/components/EditGroupButton/EditGroupButton.js +5 -1
- package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/esm/components/FeedObject/FeedObject.js +24 -7
- package/lib/esm/components/FeedUpdatesWidget/FeedUpdatesWidget.js +1 -1
- package/lib/esm/components/Group/Group.d.ts +3 -0
- package/lib/esm/components/Group/Group.js +18 -6
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +1 -1
- package/lib/esm/components/GroupForm/GroupForm.js +31 -9
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -5
- package/lib/esm/components/GroupHeader/GroupHeader.js +55 -13
- package/lib/esm/components/GroupHeader/Skeleton.d.ts +2 -4
- package/lib/esm/components/GroupHeader/Skeleton.js +10 -10
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +40 -7
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +33 -46
- 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 +8 -3
- 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 +142 -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 +32 -11
- package/lib/esm/components/Groups/Groups.d.ts +19 -16
- package/lib/esm/components/Groups/Groups.js +94 -90
- package/lib/esm/components/Groups/Skeleton.d.ts +4 -0
- package/lib/esm/components/Groups/Skeleton.js +2 -2
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -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 +1 -1
- package/lib/esm/components/PrivateMessageComponent/PrivateMessageComponent.js +13 -8
- 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/constants/PubSub.d.ts +28 -0
- package/lib/esm/constants/PubSub.js +19 -0
- package/lib/esm/index.d.ts +5 -2
- package/lib/esm/index.js +7 -4
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -7,7 +7,8 @@ const styles_1 = require("@mui/material/styles");
|
|
|
7
7
|
const Skeleton_1 = tslib_1.__importDefault(require("@mui/material/Skeleton"));
|
|
8
8
|
const constants_1 = require("./constants");
|
|
9
9
|
const classes = {
|
|
10
|
-
root: `${constants_1.PREFIX}-skeleton-root
|
|
10
|
+
root: `${constants_1.PREFIX}-skeleton-root`,
|
|
11
|
+
cover: `${constants_1.PREFIX}-skeleton-cover`,
|
|
11
12
|
};
|
|
12
13
|
const Root = (0, styles_1.styled)(material_1.Box, {
|
|
13
14
|
name: constants_1.PREFIX,
|
|
@@ -35,7 +36,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
35
36
|
*/
|
|
36
37
|
function CategoryHeaderSkeleton() {
|
|
37
38
|
return (react_1.default.createElement(Root, { className: classes.root },
|
|
38
|
-
react_1.default.createElement(Skeleton_1.default, { sx: { height:
|
|
39
|
+
react_1.default.createElement(Skeleton_1.default, { sx: { height: 230 }, animation: "wave", variant: "rectangular", className: classes.cover }),
|
|
39
40
|
react_1.default.createElement(material_1.Box, null,
|
|
40
41
|
react_1.default.createElement(Skeleton_1.default, { animation: "wave", sx: { height: 20, maxWidth: 300, width: '100%', margin: '0 auto' } })),
|
|
41
42
|
react_1.default.createElement(material_1.Box, null,
|
|
@@ -25,6 +25,10 @@ const messages = (0, react_intl_1.defineMessages)({
|
|
|
25
25
|
errorLoadImage: {
|
|
26
26
|
id: 'ui.changeGroupCover.button.change.alertErrorImage',
|
|
27
27
|
defaultMessage: 'ui.changeGroupCover.button.change.alertErrorImage'
|
|
28
|
+
},
|
|
29
|
+
errorImageSize: {
|
|
30
|
+
id: 'ui.changeGroupCover.alert',
|
|
31
|
+
defaultMessage: 'ui.changeGroupCover.alert'
|
|
28
32
|
}
|
|
29
33
|
});
|
|
30
34
|
/**
|
|
@@ -75,7 +79,26 @@ function ChangeGroupCover(inProps) {
|
|
|
75
79
|
*/
|
|
76
80
|
const handleUpload = (event) => {
|
|
77
81
|
fileInput = event.target.files[0];
|
|
78
|
-
|
|
82
|
+
if (fileInput) {
|
|
83
|
+
const reader = new FileReader();
|
|
84
|
+
reader.onload = (e) => {
|
|
85
|
+
const img = new Image();
|
|
86
|
+
img.onload = () => {
|
|
87
|
+
if (img.width < 1920) {
|
|
88
|
+
setAlert(intl.formatMessage(messages.errorImageSize));
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
isCreationMode ? onChange && onChange(fileInput) : handleSave();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
img.src = e.target.result;
|
|
97
|
+
};
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
reader.readAsDataURL(fileInput);
|
|
101
|
+
}
|
|
79
102
|
};
|
|
80
103
|
/**
|
|
81
104
|
* Handles cover saving after upload action
|
|
@@ -16,8 +16,8 @@ const react_intl_1 = require("react-intl");
|
|
|
16
16
|
const lab_1 = require("@mui/lab");
|
|
17
17
|
const messages = (0, react_intl_1.defineMessages)({
|
|
18
18
|
errorLoadImage: {
|
|
19
|
-
id: 'ui.
|
|
20
|
-
defaultMessage: 'ui.
|
|
19
|
+
id: 'ui.changeGroupPicture.alert',
|
|
20
|
+
defaultMessage: 'ui.changeGroupPicture.alert'
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const classes = {
|
|
@@ -59,12 +59,12 @@ function ChangeGroupPicture(inProps) {
|
|
|
59
59
|
name: constants_1.PREFIX
|
|
60
60
|
});
|
|
61
61
|
const { groupId, onChange, autoHide, className, isCreationMode = false } = props, rest = tslib_1.__rest(props, ["groupId", "onChange", "autoHide", "className", "isCreationMode"]);
|
|
62
|
+
//CONTEXT
|
|
63
|
+
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
62
64
|
//STATE
|
|
65
|
+
let fileInput = (0, react_1.useRef)(null);
|
|
63
66
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
64
67
|
const [alert, setAlert] = (0, react_1.useState)(null);
|
|
65
|
-
let fileInput = (0, react_1.useRef)(null);
|
|
66
|
-
//CONTEXT
|
|
67
|
-
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
68
68
|
// INTL
|
|
69
69
|
const intl = (0, react_intl_1.useIntl)();
|
|
70
70
|
// Anonymous
|
|
@@ -75,26 +75,47 @@ function ChangeGroupPicture(inProps) {
|
|
|
75
75
|
* Handles avatar upload
|
|
76
76
|
* @param event
|
|
77
77
|
*/
|
|
78
|
-
|
|
78
|
+
const handleUpload = (event) => {
|
|
79
79
|
fileInput = event.target.files[0];
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if (fileInput) {
|
|
81
|
+
const reader = new FileReader();
|
|
82
|
+
reader.onload = (e) => {
|
|
83
|
+
const img = new Image();
|
|
84
|
+
img.onload = () => {
|
|
85
|
+
if (img.width < 600 && img.height < 600) {
|
|
86
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
isCreationMode ? onChange && onChange(fileInput) : handleSave();
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
img.src = e.target.result;
|
|
95
|
+
};
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
reader.readAsDataURL(fileInput);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
82
101
|
/**
|
|
83
102
|
* Performs save avatar after upload
|
|
84
103
|
*/
|
|
85
104
|
function handleSave() {
|
|
86
105
|
setLoading(true);
|
|
87
106
|
const formData = new FormData();
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
108
|
+
// @ts-ignore
|
|
88
109
|
formData.append('image_original', fileInput);
|
|
89
110
|
api_services_1.GroupService.changeGroupAvatarOrCover(groupId, formData, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
90
111
|
.then((data) => {
|
|
112
|
+
onChange && onChange(data.image_big);
|
|
91
113
|
setLoading(false);
|
|
92
|
-
onChange && onChange(data.image_bigger);
|
|
93
114
|
})
|
|
94
115
|
.catch((error) => {
|
|
95
|
-
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
96
|
-
setLoading(false);
|
|
97
116
|
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
117
|
+
setLoading(false);
|
|
118
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
98
119
|
});
|
|
99
120
|
}
|
|
100
121
|
/**
|
|
@@ -16,7 +16,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
16
16
|
slot: 'AttributesRoot'
|
|
17
17
|
})(() => ({}));
|
|
18
18
|
exports.default = (props) => {
|
|
19
|
-
var _a, _b;
|
|
19
|
+
var _a, _b, _c;
|
|
20
20
|
// PROPS
|
|
21
21
|
const { className = null, value = null, onChange = null, onClick = null } = props;
|
|
22
22
|
// HANDLERS
|
|
@@ -47,8 +47,8 @@ exports.default = (props) => {
|
|
|
47
47
|
return (react_1.default.createElement(Root, { className: (0, classnames_1.default)(classes.root, className) },
|
|
48
48
|
((_a = value === null || value === void 0 ? void 0 : value.categories) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
49
49
|
(value === null || value === void 0 ? void 0 : value.categories.map((c) => (react_1.default.createElement(material_1.Chip, { key: c.id, label: c.name, onDelete: handleDeleteCategory(c.id), icon: react_1.default.createElement(Icon_1.default, null, "category"), onClick: handleClickCategory })))),
|
|
50
|
-
(value === null || value === void 0 ? void 0 : value.group) && (react_1.default.createElement(material_1.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_1.default.createElement(Icon_1.default, null, "groups"), onClick: handleClickGroup })),
|
|
51
|
-
((
|
|
50
|
+
(value === null || value === void 0 ? void 0 : value.group) && (react_1.default.createElement(material_1.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_1.default.createElement(Icon_1.default, null, "groups"), onClick: handleClickGroup, disabled: !((_b = value === null || value === void 0 ? void 0 : value.group) === null || _b === void 0 ? void 0 : _b.subscription_status) })),
|
|
51
|
+
((_c = value === null || value === void 0 ? void 0 : value.addressing) === null || _c === void 0 ? void 0 : _c.length) > 0 &&
|
|
52
52
|
(value === null || value === void 0 ? void 0 : value.addressing.map((t) => (react_1.default.createElement(TagChip_1.default, { key: t.id, tag: t, onDelete: handleDeleteTag(t.id), icon: react_1.default.createElement(Icon_1.default, null, "label"), onClick: handleClickTag })))),
|
|
53
53
|
(value === null || value === void 0 ? void 0 : value.location) && (react_1.default.createElement(material_1.Chip, { icon: react_1.default.createElement(Icon_1.default, null, "add_location_alt"), label: value === null || value === void 0 ? void 0 : value.location.location, onDelete: handleDeleteLocation, onClick: handleClickLocation }))));
|
|
54
54
|
};
|
|
@@ -29,7 +29,6 @@ const Attributes_1 = tslib_1.__importDefault(require("./Attributes"));
|
|
|
29
29
|
const constants_1 = require("./constants");
|
|
30
30
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
31
31
|
const CloseLayer_1 = tslib_1.__importDefault(require("./Layer/CloseLayer"));
|
|
32
|
-
const AudienceLayer_2 = require("./Layer/AudienceLayer/AudienceLayer");
|
|
33
32
|
const DialogTransition = (0, react_1.forwardRef)(function Transition(props, ref) {
|
|
34
33
|
return react_1.default.createElement(material_1.Fade, Object.assign({ ref: ref }, props));
|
|
35
34
|
});
|
|
@@ -308,7 +307,7 @@ function Composer(inProps) {
|
|
|
308
307
|
}
|
|
309
308
|
}), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
|
|
310
309
|
const handleChangeAudience = (0, react_1.useCallback)((value) => {
|
|
311
|
-
if (group) {
|
|
310
|
+
if (group || (value && Object.prototype.hasOwnProperty.call(value, 'managed_by'))) {
|
|
312
311
|
dispatch({ type: 'group', value });
|
|
313
312
|
}
|
|
314
313
|
else {
|
|
@@ -322,8 +321,7 @@ function Composer(inProps) {
|
|
|
322
321
|
ComponentProps: {
|
|
323
322
|
onClose: handleRemoveLayer,
|
|
324
323
|
onSave: handleChangeAudience,
|
|
325
|
-
defaultValue: group ? group : addressing
|
|
326
|
-
defaultType: group ? AudienceLayer_2.AudienceTypes.AUDIENCE_GROUP : addressing ? AudienceLayer_2.AudienceTypes.AUDIENCE_TAG : AudienceLayer_2.AudienceTypes.AUDIENCE_ALL
|
|
324
|
+
defaultValue: group || (addressing && Object.prototype.hasOwnProperty.call(addressing, 'managed_by')) ? group : addressing
|
|
327
325
|
}
|
|
328
326
|
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, group]);
|
|
329
327
|
const handleChangeLocation = (0, react_1.useCallback)((value) => {
|
|
@@ -555,7 +553,7 @@ function Composer(inProps) {
|
|
|
555
553
|
}),
|
|
556
554
|
react_1.default.createElement(material_1.IconButton, { disabled: isSubmitting, onClick: handleAddCategoryLayer },
|
|
557
555
|
react_1.default.createElement(Icon_1.default, null, "category")),
|
|
558
|
-
react_1.default.createElement(material_1.IconButton, { disabled: isSubmitting || !features.includes(types_1.SCFeatureName.TAGGING), onClick: handleAddAudienceLayer }, addressing === null || addressing.length === 0 ? react_1.default.createElement(Icon_1.default, null, "public") : react_1.default.createElement(Icon_1.default, null, "label")),
|
|
556
|
+
react_1.default.createElement(material_1.IconButton, { disabled: isSubmitting || !features.includes(types_1.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_1.default.createElement(Icon_1.default, null, "public") : group ? react_1.default.createElement(Icon_1.default, null, "groups") : react_1.default.createElement(Icon_1.default, null, "label")),
|
|
559
557
|
preferences[react_core_1.SCPreferences.ADDONS_POST_GEOLOCATION_ENABLED].value && (react_1.default.createElement(material_1.IconButton, { disabled: isSubmitting, onClick: handleAddLocationLayer, color: location !== null ? 'primary' : 'default' },
|
|
560
558
|
react_1.default.createElement(Icon_1.default, null, "add_location_alt"))))),
|
|
561
559
|
layer && (react_1.default.createElement(LayerTransitionRoot, { className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" },
|
|
@@ -25,7 +25,8 @@ const DEFAULT_POST = {
|
|
|
25
25
|
categories: [],
|
|
26
26
|
medias: [],
|
|
27
27
|
html: '',
|
|
28
|
-
addressing: []
|
|
28
|
+
addressing: [],
|
|
29
|
+
group: null
|
|
29
30
|
};
|
|
30
31
|
exports.default = (props) => {
|
|
31
32
|
// PROPS
|
|
@@ -43,7 +44,7 @@ exports.default = (props) => {
|
|
|
43
44
|
}, [value]);
|
|
44
45
|
// RENDER
|
|
45
46
|
return (react_1.default.createElement(Root, { className: (0, classnames_1.default)(classes.root, className) },
|
|
46
|
-
generalError && react_1.default.createElement(material_1.Typography, { className: classes.generalError },
|
|
47
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` })),
|
|
47
|
+
generalError && (react_1.default.createElement(material_1.Typography, { className: classes.generalError },
|
|
48
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }))),
|
|
48
49
|
react_1.default.createElement(Editor_1.default, Object.assign({ ref: editorRef }, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, defaultValue: value.html }))));
|
|
49
50
|
};
|
|
@@ -10,9 +10,8 @@ export declare enum AudienceTypes {
|
|
|
10
10
|
AUDIENCE_GROUP = "group"
|
|
11
11
|
}
|
|
12
12
|
export interface AudienceLayerProps extends Omit<BoxProps, 'defaultValue'>, ComposerLayerProps {
|
|
13
|
-
|
|
14
|
-
defaultValue: SCTagType[] | SCGroupType;
|
|
13
|
+
defaultValue: SCTagType[] | SCGroupType | any;
|
|
15
14
|
TextFieldProps?: TextFieldProps;
|
|
16
15
|
}
|
|
17
|
-
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" | "
|
|
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>>;
|
|
18
17
|
export default AudienceLayer;
|
|
@@ -35,10 +35,10 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
35
35
|
})(() => ({}));
|
|
36
36
|
const AudienceLayer = react_1.default.forwardRef((props, ref) => {
|
|
37
37
|
// Props
|
|
38
|
-
const { className, onClose, onSave,
|
|
38
|
+
const { className, onClose, onSave, defaultValue = AudienceTypes.AUDIENCE_TAG ? [] : null, TextFieldProps = {
|
|
39
39
|
variant: 'outlined',
|
|
40
40
|
label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tags.label", defaultMessage: "ui.composer.layer.audience.tags.label" })
|
|
41
|
-
} } = props, rest = tslib_1.__rest(props, ["className", "onClose", "onSave", "
|
|
41
|
+
} } = props, rest = tslib_1.__rest(props, ["className", "onClose", "onSave", "defaultValue", "TextFieldProps"]);
|
|
42
42
|
// STATE
|
|
43
43
|
const [autocompleteOpen, setAutocompleteOpen] = (0, react_1.useState)(false);
|
|
44
44
|
const [audience, setAudience] = (0, react_1.useState)(
|
|
@@ -46,7 +46,7 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
|
|
|
46
46
|
// @ts-ignore
|
|
47
47
|
defaultValue === null || defaultValue.length === 0
|
|
48
48
|
? AudienceTypes.AUDIENCE_ALL
|
|
49
|
-
:
|
|
49
|
+
: defaultValue && Object.prototype.hasOwnProperty.call(defaultValue, 'managed_by')
|
|
50
50
|
? AudienceTypes.AUDIENCE_GROUP
|
|
51
51
|
: AudienceTypes.AUDIENCE_TAG);
|
|
52
52
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -55,10 +55,9 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
|
|
|
55
55
|
// HOOKS
|
|
56
56
|
const { scAddressingTags } = (0, react_core_1.useSCFetchAddressingTagList)({ fetch: autocompleteOpen });
|
|
57
57
|
// HANDLERS
|
|
58
|
-
const handleSave = (0, react_1.useCallback)(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
() => (defaultType === 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)), [value, onSave]);
|
|
58
|
+
const handleSave = (0, react_1.useCallback)(() => {
|
|
59
|
+
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);
|
|
60
|
+
}, [value, onSave, audience]);
|
|
62
61
|
const handleChange = (0, react_1.useCallback)((event, tags) => setValue(tags), []);
|
|
63
62
|
const handleGroupChange = (0, react_1.useCallback)((group) => setValue(group), []);
|
|
64
63
|
const handleChangeAudience = (0, react_1.useCallback)((event, data) => setAudience(data), []);
|
|
@@ -75,8 +74,8 @@ const AudienceLayer = react_1.default.forwardRef((props, ref) => {
|
|
|
75
74
|
react_1.default.createElement(DialogContent_1.default, { className: classes.content },
|
|
76
75
|
react_1.default.createElement(material_1.Tabs, { value: audience, onChange: handleChangeAudience, "aria-label": "audience type" },
|
|
77
76
|
react_1.default.createElement(material_1.Tab, { value: AudienceTypes.AUDIENCE_ALL, icon: react_1.default.createElement(Icon_1.default, null, "public"), label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.all", defaultMessage: "ui.composer.layer.audience.all" }) }),
|
|
78
|
-
react_1.default.createElement(material_1.Tab, { disabled:
|
|
79
|
-
react_1.default.createElement(material_1.Tab, { disabled:
|
|
77
|
+
react_1.default.createElement(material_1.Tab, { disabled: value && Boolean(value === null || value === void 0 ? void 0 : value.length), value: AudienceTypes.AUDIENCE_GROUP, icon: react_1.default.createElement(Icon_1.default, null, "groups"), label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.group", defaultMessage: "ui.composer.layer.audience.group" }) }),
|
|
78
|
+
react_1.default.createElement(material_1.Tab, { disabled: value && Object.prototype.hasOwnProperty.call(value, 'managed_by'), value: AudienceTypes.AUDIENCE_TAG, icon: react_1.default.createElement(Icon_1.default, null, "label"), label: react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.tag", defaultMessage: "ui.composer.layer.audience.tag" }) })),
|
|
80
79
|
react_1.default.createElement(material_1.Typography, { className: classes.message },
|
|
81
80
|
audience === AudienceTypes.AUDIENCE_ALL && (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.all.message", defaultMessage: "ui.composer.audience.layer.all.message" })),
|
|
82
81
|
audience === AudienceTypes.AUDIENCE_GROUP && (react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.layer.audience.group.message", defaultMessage: "ui.composer.audience.layer.group.message" })),
|
|
@@ -44,10 +44,14 @@ function EditGroupButton(inProps) {
|
|
|
44
44
|
});
|
|
45
45
|
const { className, groupId, group, onEditSuccess } = props, rest = tslib_1.__rest(props, ["className", "groupId", "group", "onEditSuccess"]);
|
|
46
46
|
const { scGroup, setSCGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
47
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
47
48
|
const handleSuccess = (data) => {
|
|
48
49
|
setSCGroup(data);
|
|
49
50
|
onEditSuccess && onEditSuccess(data);
|
|
50
51
|
};
|
|
52
|
+
if (!scUserContext.user) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
51
55
|
/**
|
|
52
56
|
* Renders root object
|
|
53
57
|
*/
|
|
@@ -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.|
|
|
@@ -42,6 +42,10 @@ const messages = (0, react_intl_1.defineMessages)({
|
|
|
42
42
|
visibleToAll: {
|
|
43
43
|
id: 'ui.feedObject.visibleToAll',
|
|
44
44
|
defaultMessage: 'ui.feedObject.visibleToAll'
|
|
45
|
+
},
|
|
46
|
+
visibleToGroup: {
|
|
47
|
+
id: 'ui.feedObject.visibleToGroup',
|
|
48
|
+
defaultMessage: 'ui.feedObject.visibleToGroup'
|
|
45
49
|
}
|
|
46
50
|
});
|
|
47
51
|
const classes = {
|
|
@@ -49,6 +53,7 @@ const classes = {
|
|
|
49
53
|
deleted: `${constants_1.PREFIX}-deleted`,
|
|
50
54
|
header: `${constants_1.PREFIX}-header`,
|
|
51
55
|
category: `${constants_1.PREFIX}-category`,
|
|
56
|
+
group: `${constants_1.PREFIX}-group`,
|
|
52
57
|
avatar: `${constants_1.PREFIX}-avatar`,
|
|
53
58
|
username: `${constants_1.PREFIX}-username`,
|
|
54
59
|
activityAt: `${constants_1.PREFIX}-activity-at`,
|
|
@@ -102,6 +107,7 @@ const Root = (0, styles_1.styled)(Widget_1.default, {
|
|
|
102
107
|
|deleted|.SCFeedObject-deleted|Styles applied to the feed obj when is deleted (visible only for admin and moderator).|
|
|
103
108
|
|header|.SCFeedObject-header|Styles applied to the header of the card.|
|
|
104
109
|
|category|.SCFeedObject-category|Styles applied to the category element.|
|
|
110
|
+
|group|.SCFeedObject-group|Styles applied to the group element.|
|
|
105
111
|
|avatar|.SCFeedObject-avatar|Styles applied to the avatar element.|
|
|
106
112
|
|username|.SCFeedObject-username|Styles applied to the username element.|
|
|
107
113
|
|activityAt|.SCFeedObject-activity-at|Styles applied to the activity at section.|
|
|
@@ -169,7 +175,7 @@ function FeedObject(inProps) {
|
|
|
169
175
|
}, [onStateChange, onHeightChange]);
|
|
170
176
|
/**
|
|
171
177
|
* Update state object
|
|
172
|
-
* @param
|
|
178
|
+
* @param newObj
|
|
173
179
|
*/
|
|
174
180
|
const updateObject = (newObj) => {
|
|
175
181
|
setObj(newObj);
|
|
@@ -426,8 +432,13 @@ function FeedObject(inProps) {
|
|
|
426
432
|
template === feedObject_1.SCFeedObjectTemplateType.DETAIL ||
|
|
427
433
|
template === feedObject_1.SCFeedObjectTemplateType.SEARCH) {
|
|
428
434
|
objElement = (react_1.default.createElement(react_1.default.Fragment, null, obj ? (react_1.default.createElement(material_1.Box, { className: (0, classnames_1.default)({ [classes.deleted]: obj && obj.deleted }) },
|
|
429
|
-
obj.categories.length > 0 && (react_1.default.createElement("div", { className: classes.category },
|
|
430
|
-
react_1.default.createElement(
|
|
435
|
+
obj.categories.length > 0 && (react_1.default.createElement("div", { className: classes.category },
|
|
436
|
+
react_1.default.createElement(react_1.default.Fragment, null, obj.group && (react_1.default.createElement("div", { className: classes.group },
|
|
437
|
+
react_1.default.createElement(material_1.Chip, { color: "secondary", size: "small", key: obj.group.id, icon: react_1.default.createElement(Icon_1.default, null, "groups"), component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true })))),
|
|
438
|
+
obj.categories.map((c) => (react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
|
|
439
|
+
react_1.default.createElement(material_1.Typography, { variant: "overline" }, c.name)))))),
|
|
440
|
+
obj.group && !obj.categories.length && (react_1.default.createElement("div", { className: classes.group },
|
|
441
|
+
react_1.default.createElement(material_1.Chip, { color: "secondary", size: "small", key: obj.group.id, icon: react_1.default.createElement(Icon_1.default, null, "groups"), label: obj.group.name, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }))),
|
|
431
442
|
react_1.default.createElement(material_1.CardHeader, { className: classes.header, avatar: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null }),
|
|
432
443
|
react_1.default.createElement(UserAvatar_1.default, { hide: !obj.author.community_badge },
|
|
433
444
|
react_1.default.createElement(material_1.Avatar, { "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, obj.author.username))), title: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }), obj.author.username), subheader: react_1.default.createElement(react_1.default.Fragment, null,
|
|
@@ -439,7 +450,8 @@ function FeedObject(inProps) {
|
|
|
439
450
|
react_1.default.createElement(Icon_1.default, null, "add_location_alt"), (_a = obj.location) === null || _a === void 0 ? void 0 :
|
|
440
451
|
_a.location))),
|
|
441
452
|
react_1.default.createElement(Bullet_1.default, null),
|
|
442
|
-
react_1.default.createElement(material_1.Box, { className: classes.tag }, obj.addressing.length > 0 ? (react_1.default.createElement(Tags_1.default, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : (react_1.default.createElement(material_1.Tooltip, { title: `${intl.formatMessage(messages.
|
|
453
|
+
react_1.default.createElement(material_1.Box, { className: classes.tag }, obj.addressing.length > 0 ? (react_1.default.createElement(Tags_1.default, { tags: obj.addressing, TagChipProps: { disposable: false, clickable: false } })) : obj.group ? (react_1.default.createElement(material_1.Tooltip, { title: `${intl.formatMessage(messages.visibleToGroup, { group: obj.group.name })}` },
|
|
454
|
+
react_1.default.createElement(Icon_1.default, { color: "disabled", fontSize: "small" }, "groups"))) : (react_1.default.createElement(material_1.Tooltip, { title: `${intl.formatMessage(messages.visibleToAll)}` },
|
|
443
455
|
react_1.default.createElement(Icon_1.default, { color: "disabled", fontSize: "small" }, "public"))))), action: renderHeaderAction() }),
|
|
444
456
|
react_1.default.createElement(CardContent_1.default, { classes: { root: classes.content } },
|
|
445
457
|
react_1.default.createElement(material_1.Box, { className: classes.titleSection }, 'title' in obj && (react_1.default.createElement(react_1.default.Fragment, null, template === feedObject_1.SCFeedObjectTemplateType.DETAIL ? (react_1.default.createElement(material_1.Typography, { variant: "body1", gutterBottom: true, className: classes.title }, obj.title)) : (react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj)) },
|
|
@@ -468,8 +480,13 @@ function FeedObject(inProps) {
|
|
|
468
480
|
}
|
|
469
481
|
else if (template === feedObject_1.SCFeedObjectTemplateType.SHARE) {
|
|
470
482
|
objElement = (react_1.default.createElement(react_1.default.Fragment, null, obj ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
471
|
-
obj.categories.length > 0 && (react_1.default.createElement("div", { className: classes.category },
|
|
472
|
-
react_1.default.createElement(
|
|
483
|
+
obj.categories.length > 0 && (react_1.default.createElement("div", { className: classes.category },
|
|
484
|
+
react_1.default.createElement(react_1.default.Fragment, null, obj.group && (react_1.default.createElement("div", { className: classes.group },
|
|
485
|
+
react_1.default.createElement(material_1.Chip, { color: "secondary", size: "small", key: obj.group.id, icon: react_1.default.createElement(Icon_1.default, null, "groups"), component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true })))),
|
|
486
|
+
obj.categories.map((c) => (react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, c), key: c.id },
|
|
487
|
+
react_1.default.createElement(material_1.Typography, { variant: "overline" }, c.name)))))),
|
|
488
|
+
obj.group && !obj.categories.length && (react_1.default.createElement("div", { className: classes.group },
|
|
489
|
+
react_1.default.createElement(material_1.Chip, { color: "secondary", size: "small", key: obj.group.id, icon: react_1.default.createElement(Icon_1.default, null, "groups"), label: obj.group.name, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, obj.group), clickable: true }))),
|
|
473
490
|
react_1.default.createElement(material_1.CardHeader, { classes: { root: classes.header }, avatar: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }),
|
|
474
491
|
react_1.default.createElement(UserAvatar_1.default, { hide: !obj.author.community_badge },
|
|
475
492
|
react_1.default.createElement(material_1.Avatar, { "aria-label": "recipe", src: obj.author.avatar, className: classes.avatar }, obj.author.username))), title: react_1.default.createElement(react_core_1.Link, Object.assign({}, (!obj.author.deleted && { to: scRoutingContext.url(react_core_1.SCRoutes.USER_PROFILE_ROUTE_NAME, obj.author) }), { onClick: obj.author.deleted ? () => setOpenAlert(true) : null, className: classes.username }), obj.author.username), subheader: react_1.default.createElement(react_core_1.Link, { to: scRoutingContext.url((0, contribution_1.getContributionRouteName)(obj), (0, contribution_1.getRouteData)(obj)), className: classes.activityAt },
|
|
@@ -57,7 +57,7 @@ function FeedUpdatesWidget(inProps) {
|
|
|
57
57
|
const [updates, setUpdates] = (0, react_1.useState)(false);
|
|
58
58
|
// REFS
|
|
59
59
|
const updatesSubscription = (0, react_1.useRef)(null);
|
|
60
|
-
//
|
|
60
|
+
// Subscriber for pubsub callback
|
|
61
61
|
const subscriber = (msg, data) => {
|
|
62
62
|
if (subscriptionChannelUpdatesCallback(msg, data)) {
|
|
63
63
|
setUpdates(true);
|
|
@@ -61,6 +61,9 @@ export interface GroupProps extends WidgetProps {
|
|
|
61
61
|
|---|---|---|
|
|
62
62
|
|root|.SCGroup-root|Styles applied to the root element.|
|
|
63
63
|
|avatar|.SCGroup-avatar|Styles applied to the avatar element.|
|
|
64
|
+
|actions|.SCGroup-actions|Styles applied to the actions section.|
|
|
65
|
+
|icon|.SCGroup-icon|Styles applied to the group privacy icon element.|
|
|
66
|
+
|
|
64
67
|
|
|
65
68
|
*
|
|
66
69
|
* @param inProps
|
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
|
+
const types_1 = require("@selfcommunity/types");
|
|
7
8
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
8
9
|
const react_intl_1 = require("react-intl");
|
|
9
10
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
@@ -22,7 +23,8 @@ const messages = (0, react_intl_1.defineMessages)({
|
|
|
22
23
|
const classes = {
|
|
23
24
|
root: `${constants_1.PREFIX}-root`,
|
|
24
25
|
avatar: `${constants_1.PREFIX}-avatar`,
|
|
25
|
-
actions: `${constants_1.PREFIX}-actions
|
|
26
|
+
actions: `${constants_1.PREFIX}-actions`,
|
|
27
|
+
icon: `${constants_1.PREFIX}-icon`
|
|
26
28
|
};
|
|
27
29
|
const Root = (0, styles_1.styled)(BaseItemButton_1.default, {
|
|
28
30
|
name: constants_1.PREFIX,
|
|
@@ -53,21 +55,28 @@ const Root = (0, styles_1.styled)(BaseItemButton_1.default, {
|
|
|
53
55
|
|---|---|---|
|
|
54
56
|
|root|.SCGroup-root|Styles applied to the root element.|
|
|
55
57
|
|avatar|.SCGroup-avatar|Styles applied to the avatar element.|
|
|
58
|
+
|actions|.SCGroup-actions|Styles applied to the actions section.|
|
|
59
|
+
|icon|.SCGroup-icon|Styles applied to the group privacy icon element.|
|
|
60
|
+
|
|
56
61
|
|
|
57
62
|
*
|
|
58
63
|
* @param inProps
|
|
59
64
|
*/
|
|
60
65
|
function Group(inProps) {
|
|
66
|
+
var _a;
|
|
61
67
|
// PROPS
|
|
62
68
|
const props = (0, system_1.useThemeProps)({
|
|
63
69
|
props: inProps,
|
|
64
70
|
name: constants_1.PREFIX
|
|
65
71
|
});
|
|
66
|
-
const { groupId = null, group = null, className = null, elevation, hideActions = false, groupSubscribeButtonProps = {}
|
|
72
|
+
const { groupId = null, group = null, className = null, elevation, hideActions = false, groupSubscribeButtonProps = {} } = props, rest = tslib_1.__rest(props, ["groupId", "group", "className", "elevation", "hideActions", "groupSubscribeButtonProps"]);
|
|
67
73
|
// STATE
|
|
68
74
|
const { scGroup } = (0, react_core_1.useSCFetchGroup)({ id: groupId, group });
|
|
69
75
|
// CONTEXT
|
|
70
76
|
const scRoutingContext = (0, react_core_1.useSCRouting)();
|
|
77
|
+
const scUserContext = (0, react_core_1.useSCUser)();
|
|
78
|
+
// CONST
|
|
79
|
+
const isGroupAdmin = (0, react_1.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]);
|
|
71
80
|
const [openAlert, setOpenAlert] = (0, react_1.useState)(false);
|
|
72
81
|
// INTL
|
|
73
82
|
const intl = (0, react_intl_1.useIntl)();
|
|
@@ -77,7 +86,7 @@ function Group(inProps) {
|
|
|
77
86
|
*/
|
|
78
87
|
function renderAuthenticatedActions() {
|
|
79
88
|
return (react_1.default.createElement(material_1.Stack, { className: classes.actions, direction: "row", alignItems: "center", justifyContent: "center", spacing: 2 },
|
|
80
|
-
react_1.default.createElement(material_1.Icon, null,
|
|
89
|
+
isGroupAdmin && react_1.default.createElement(material_1.Icon, null, "face"),
|
|
81
90
|
react_1.default.createElement(GroupSubscribeButton_1.default, Object.assign({ group: group, groupId: groupId }, groupSubscribeButtonProps))));
|
|
82
91
|
}
|
|
83
92
|
/**
|
|
@@ -90,7 +99,10 @@ function Group(inProps) {
|
|
|
90
99
|
* Renders root object
|
|
91
100
|
*/
|
|
92
101
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
93
|
-
react_1.default.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps:
|
|
102
|
+
react_1.default.createElement(Root, Object.assign({ elevation: elevation }, rest, { className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUP_ROUTE_NAME, scGroup) }, image: react_1.default.createElement(material_1.Avatar, { alt: scGroup.name, src: scGroup.image_medium, className: classes.avatar }), primary: react_1.default.createElement(react_1.default.Fragment, null,
|
|
103
|
+
scGroup.name,
|
|
104
|
+
" ",
|
|
105
|
+
react_1.default.createElement(material_1.Icon, { className: classes.icon }, (group === null || group === void 0 ? void 0 : group.privacy) === types_1.SCGroupPrivacyType.PRIVATE ? 'private' : 'public')), secondary: `${intl.formatMessage(messages.groupMembers, { total: scGroup.subscribers_counter })}`, actions: hideActions ? null : renderAuthenticatedActions() })),
|
|
94
106
|
openAlert && react_1.default.createElement(UserDeletedSnackBar_1.default, { open: openAlert, handleClose: () => setOpenAlert(false) })));
|
|
95
107
|
}
|
|
96
108
|
exports.default = Group;
|
|
@@ -80,7 +80,7 @@ const GroupAutocomplete = (inProps) => {
|
|
|
80
80
|
setValue(value);
|
|
81
81
|
};
|
|
82
82
|
// Render
|
|
83
|
-
return (react_1.default.createElement(Root, Object.assign({
|
|
83
|
+
return (react_1.default.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_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.groupAutocomplete.empty", defaultMessage: "ui.groupAutocomplete.empty" }), onChange: handleChange, isOptionEqualToValue: (option, value) => value.id === option.id,
|
|
84
84
|
// renderTags={(value, getTagProps) => {
|
|
85
85
|
// return value.map((option: any, index) => (
|
|
86
86
|
// <Chip key={option.id} id={option.id} label={option.name} color={option.color} {...getTagProps({index})} />
|