@selfcommunity/react-ui 0.7.9-alpha.1 → 0.7.9-alpha.10
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/BottomNavigation/BottomNavigation.js +3 -1
- package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
- package/lib/cjs/components/ChangeGroupCover/ChangeGroupCover.js +140 -0
- package/lib/cjs/components/ChangeGroupCover/constants.d.ts +1 -0
- package/lib/cjs/components/ChangeGroupCover/constants.js +4 -0
- package/lib/cjs/components/ChangeGroupCover/index.d.ts +3 -0
- package/lib/cjs/components/ChangeGroupCover/index.js +5 -0
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.d.ts +57 -0
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +135 -0
- package/lib/cjs/components/ChangeGroupPicture/constants.d.ts +1 -0
- package/lib/cjs/components/ChangeGroupPicture/constants.js +4 -0
- package/lib/cjs/components/ChangeGroupPicture/index.d.ts +3 -0
- package/lib/cjs/components/ChangeGroupPicture/index.js +5 -0
- package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/cjs/components/Composer/Attributes/Attributes.js +7 -0
- package/lib/cjs/components/Composer/Composer.d.ts +2 -1
- package/lib/cjs/components/Composer/Composer.js +39 -12
- package/lib/cjs/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/cjs/components/Composer/Content/ContentPost/ContentPost.js +4 -3
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +46 -12
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +72 -0
- package/lib/cjs/components/CreateGroupButton/index.d.ts +3 -0
- package/lib/cjs/components/CreateGroupButton/index.js +5 -0
- package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/cjs/components/EditGroupButton/EditGroupButton.d.ts +43 -0
- package/lib/cjs/components/EditGroupButton/EditGroupButton.js +61 -0
- package/lib/cjs/components/EditGroupButton/index.d.ts +3 -0
- package/lib/cjs/components/EditGroupButton/index.js +5 -0
- package/lib/cjs/components/Group/Group.d.ts +68 -0
- package/lib/cjs/components/Group/Group.js +96 -0
- package/lib/cjs/components/Group/Skeleton.d.ts +22 -0
- package/lib/cjs/components/Group/Skeleton.js +42 -0
- package/lib/cjs/components/Group/constants.d.ts +1 -0
- package/lib/cjs/components/Group/constants.js +4 -0
- package/lib/cjs/components/Group/index.d.ts +4 -0
- package/lib/cjs/components/Group/index.js +8 -0
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/cjs/components/GroupAutocomplete/GroupAutocomplete.js +101 -0
- package/lib/cjs/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/cjs/components/GroupAutocomplete/index.js +5 -0
- package/lib/cjs/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/cjs/components/GroupForm/GroupForm.js +239 -0
- package/lib/cjs/components/GroupForm/constants.d.ts +1 -0
- package/lib/cjs/components/GroupForm/constants.js +4 -0
- package/lib/cjs/components/GroupForm/index.d.ts +3 -0
- package/lib/cjs/components/GroupForm/index.js +5 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +84 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.js +147 -0
- package/lib/cjs/components/GroupHeader/Skeleton.d.ts +25 -0
- package/lib/cjs/components/GroupHeader/Skeleton.js +56 -0
- package/lib/cjs/components/GroupHeader/constants.d.ts +1 -0
- package/lib/cjs/components/GroupHeader/constants.js +4 -0
- package/lib/cjs/components/GroupHeader/index.d.ts +4 -0
- package/lib/cjs/components/GroupHeader/index.js +8 -0
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.d.ts +52 -0
- package/lib/cjs/components/GroupInfoWidget/GroupInfoWidget.js +100 -0
- package/lib/cjs/components/GroupInfoWidget/Skeleton.d.ts +21 -0
- package/lib/cjs/components/GroupInfoWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupInfoWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupInfoWidget/constants.js +4 -0
- package/lib/cjs/components/GroupInfoWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupInfoWidget/index.js +8 -0
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.d.ts +57 -0
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +262 -0
- package/lib/cjs/components/GroupInviteButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupInviteButton/index.js +5 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +51 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +136 -0
- package/lib/cjs/components/GroupMembersButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupMembersButton/index.js +5 -0
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.d.ts +79 -0
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +205 -0
- package/lib/cjs/components/GroupMembersWidget/Skeleton.d.ts +22 -0
- package/lib/cjs/components/GroupMembersWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupMembersWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupMembersWidget/constants.js +4 -0
- package/lib/cjs/components/GroupMembersWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupMembersWidget/index.js +8 -0
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +74 -0
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +203 -0
- package/lib/cjs/components/GroupRequestsWidget/Skeleton.d.ts +22 -0
- package/lib/cjs/components/GroupRequestsWidget/Skeleton.js +38 -0
- package/lib/cjs/components/GroupRequestsWidget/constants.d.ts +1 -0
- package/lib/cjs/components/GroupRequestsWidget/constants.js +4 -0
- package/lib/cjs/components/GroupRequestsWidget/index.d.ts +4 -0
- package/lib/cjs/components/GroupRequestsWidget/index.js +8 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +56 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +137 -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 +56 -0
- package/lib/cjs/components/GroupSubscribeButton/GroupSubscribeButton.js +132 -0
- package/lib/cjs/components/GroupSubscribeButton/index.d.ts +3 -0
- package/lib/cjs/components/GroupSubscribeButton/index.js +5 -0
- package/lib/cjs/components/Groups/Groups.d.ts +61 -0
- package/lib/cjs/components/Groups/Groups.js +128 -0
- package/lib/cjs/components/Groups/Skeleton.d.ts +34 -0
- package/lib/cjs/components/Groups/Skeleton.js +45 -0
- package/lib/cjs/components/Groups/constants.d.ts +1 -0
- package/lib/cjs/components/Groups/constants.js +4 -0
- package/lib/cjs/components/Groups/index.d.ts +4 -0
- package/lib/cjs/components/Groups/index.js +8 -0
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +6 -1
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.js +2 -3
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
- package/lib/cjs/components/User/User.d.ts +12 -0
- package/lib/cjs/components/User/User.js +5 -3
- package/lib/cjs/constants/Group.d.ts +2 -0
- package/lib/cjs/constants/Group.js +5 -0
- package/lib/cjs/index.d.ts +17 -1
- package/lib/cjs/index.js +40 -2
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +3 -1
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.d.ts +55 -0
- package/lib/esm/components/ChangeGroupCover/ChangeGroupCover.js +137 -0
- package/lib/esm/components/ChangeGroupCover/constants.d.ts +1 -0
- package/lib/esm/components/ChangeGroupCover/constants.js +1 -0
- package/lib/esm/components/ChangeGroupCover/index.d.ts +3 -0
- package/lib/esm/components/ChangeGroupCover/index.js +2 -0
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.d.ts +57 -0
- package/lib/esm/components/ChangeGroupPicture/ChangeGroupPicture.js +132 -0
- package/lib/esm/components/ChangeGroupPicture/constants.d.ts +1 -0
- package/lib/esm/components/ChangeGroupPicture/constants.js +1 -0
- package/lib/esm/components/ChangeGroupPicture/index.d.ts +3 -0
- package/lib/esm/components/ChangeGroupPicture/index.js +2 -0
- package/lib/esm/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/esm/components/Composer/Attributes/Attributes.js +7 -0
- package/lib/esm/components/Composer/Composer.d.ts +2 -1
- package/lib/esm/components/Composer/Composer.js +39 -12
- package/lib/esm/components/Composer/Content/ContentDiscussion/ContentDiscussion.js +7 -3
- package/lib/esm/components/Composer/Content/ContentPost/ContentPost.js +4 -3
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.d.ts +7 -1
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +45 -12
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.d.ts +38 -0
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +69 -0
- package/lib/esm/components/CreateGroupButton/index.d.ts +3 -0
- package/lib/esm/components/CreateGroupButton/index.js +2 -0
- package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/esm/components/EditGroupButton/EditGroupButton.d.ts +43 -0
- package/lib/esm/components/EditGroupButton/EditGroupButton.js +58 -0
- package/lib/esm/components/EditGroupButton/index.d.ts +3 -0
- package/lib/esm/components/EditGroupButton/index.js +2 -0
- package/lib/esm/components/Group/Group.d.ts +68 -0
- package/lib/esm/components/Group/Group.js +93 -0
- package/lib/esm/components/Group/Skeleton.d.ts +22 -0
- package/lib/esm/components/Group/Skeleton.js +38 -0
- package/lib/esm/components/Group/constants.d.ts +1 -0
- package/lib/esm/components/Group/constants.js +1 -0
- package/lib/esm/components/Group/index.d.ts +4 -0
- package/lib/esm/components/Group/index.js +4 -0
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.d.ts +49 -0
- package/lib/esm/components/GroupAutocomplete/GroupAutocomplete.js +99 -0
- package/lib/esm/components/GroupAutocomplete/index.d.ts +3 -0
- package/lib/esm/components/GroupAutocomplete/index.js +2 -0
- package/lib/esm/components/GroupForm/GroupForm.d.ts +70 -0
- package/lib/esm/components/GroupForm/GroupForm.js +236 -0
- package/lib/esm/components/GroupForm/constants.d.ts +1 -0
- package/lib/esm/components/GroupForm/constants.js +1 -0
- package/lib/esm/components/GroupForm/index.d.ts +3 -0
- package/lib/esm/components/GroupForm/index.js +2 -0
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +84 -0
- package/lib/esm/components/GroupHeader/GroupHeader.js +144 -0
- package/lib/esm/components/GroupHeader/Skeleton.d.ts +25 -0
- package/lib/esm/components/GroupHeader/Skeleton.js +53 -0
- package/lib/esm/components/GroupHeader/constants.d.ts +1 -0
- package/lib/esm/components/GroupHeader/constants.js +1 -0
- package/lib/esm/components/GroupHeader/index.d.ts +4 -0
- package/lib/esm/components/GroupHeader/index.js +4 -0
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.d.ts +52 -0
- package/lib/esm/components/GroupInfoWidget/GroupInfoWidget.js +97 -0
- package/lib/esm/components/GroupInfoWidget/Skeleton.d.ts +21 -0
- package/lib/esm/components/GroupInfoWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupInfoWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupInfoWidget/constants.js +1 -0
- package/lib/esm/components/GroupInfoWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupInfoWidget/index.js +4 -0
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.d.ts +57 -0
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +259 -0
- package/lib/esm/components/GroupInviteButton/index.d.ts +3 -0
- package/lib/esm/components/GroupInviteButton/index.js +2 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +51 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +133 -0
- package/lib/esm/components/GroupMembersButton/index.d.ts +3 -0
- package/lib/esm/components/GroupMembersButton/index.js +2 -0
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.d.ts +79 -0
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +202 -0
- package/lib/esm/components/GroupMembersWidget/Skeleton.d.ts +22 -0
- package/lib/esm/components/GroupMembersWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupMembersWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupMembersWidget/constants.js +1 -0
- package/lib/esm/components/GroupMembersWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupMembersWidget/index.js +4 -0
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +74 -0
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +200 -0
- package/lib/esm/components/GroupRequestsWidget/Skeleton.d.ts +22 -0
- package/lib/esm/components/GroupRequestsWidget/Skeleton.js +34 -0
- package/lib/esm/components/GroupRequestsWidget/constants.d.ts +1 -0
- package/lib/esm/components/GroupRequestsWidget/constants.js +1 -0
- package/lib/esm/components/GroupRequestsWidget/index.d.ts +4 -0
- package/lib/esm/components/GroupRequestsWidget/index.js +4 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +56 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +134 -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 +56 -0
- package/lib/esm/components/GroupSubscribeButton/GroupSubscribeButton.js +129 -0
- package/lib/esm/components/GroupSubscribeButton/index.d.ts +3 -0
- package/lib/esm/components/GroupSubscribeButton/index.js +2 -0
- package/lib/esm/components/Groups/Groups.d.ts +61 -0
- package/lib/esm/components/Groups/Groups.js +125 -0
- package/lib/esm/components/Groups/Skeleton.d.ts +34 -0
- package/lib/esm/components/Groups/Skeleton.js +42 -0
- package/lib/esm/components/Groups/constants.d.ts +1 -0
- package/lib/esm/components/Groups/constants.js +1 -0
- package/lib/esm/components/Groups/index.d.ts +4 -0
- package/lib/esm/components/Groups/index.js +4 -0
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +6 -1
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.js +3 -4
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +1 -1
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +5 -1
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.d.ts +4 -0
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +2 -3
- package/lib/esm/components/User/User.d.ts +12 -0
- package/lib/esm/components/User/User.js +5 -3
- package/lib/esm/constants/Group.d.ts +2 -0
- package/lib/esm/constants/Group.js +2 -0
- package/lib/esm/index.d.ts +17 -1
- package/lib/esm/index.js +19 -3
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
|
@@ -14,7 +14,7 @@ const classes = {
|
|
|
14
14
|
root: `${PREFIX}-root`,
|
|
15
15
|
ios: `${PREFIX}-ios`,
|
|
16
16
|
action: `${PREFIX}-action`,
|
|
17
|
-
composer: `${PREFIX}-composer
|
|
17
|
+
composer: `${PREFIX}-composer`
|
|
18
18
|
};
|
|
19
19
|
const Root = (0, material_1.styled)(material_1.BottomNavigation, {
|
|
20
20
|
name: PREFIX,
|
|
@@ -62,6 +62,7 @@ function BottomNavigation(inProps) {
|
|
|
62
62
|
const { preferences, features } = (0, react_core_1.useSCPreferences)();
|
|
63
63
|
// MEMO
|
|
64
64
|
const privateMessagingEnabled = (0, react_1.useMemo)(() => features.includes(types_1.SCFeatureName.PRIVATE_MESSAGING), [features]);
|
|
65
|
+
const groupsEnabled = (0, react_1.useMemo)(() => features.includes(types_1.SCFeatureName.GROUPING), [features]);
|
|
65
66
|
const isIOS = (0, react_1.useMemo)(() => (0, utils_1.iOS)(), []);
|
|
66
67
|
// RENDER
|
|
67
68
|
return (react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.root, { [classes.ios]: isIOS }) }, rest), children
|
|
@@ -71,6 +72,7 @@ function BottomNavigation(inProps) {
|
|
|
71
72
|
(scUserContext.user || preferences[react_core_1.SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value) &&
|
|
72
73
|
preferences[react_core_1.SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value ? (react_1.default.createElement(material_1.BottomNavigationAction, { key: "explore", className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.EXPLORE_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.EXPLORE_ROUTE_NAME, {}), icon: react_1.default.createElement(material_1.Icon, null, "explore") })) : null,
|
|
73
74
|
react_1.default.createElement(material_1.BottomNavigationAction, { key: "composer", className: (0, classnames_1.default)(classes.composer, classes.action), component: ComposerIconButton_1.default, disableRipple: true }),
|
|
75
|
+
groupsEnabled && scUserContext.user ? (react_1.default.createElement(material_1.BottomNavigationAction, { key: "groups", className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.GROUPS_ROUTE_NAME, {}), icon: react_1.default.createElement(material_1.Icon, null, "groups") })) : null,
|
|
74
76
|
scUserContext.user ? (react_1.default.createElement(material_1.BottomNavigationAction, { key: "notifications", className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}), icon: react_1.default.createElement(material_1.Badge, { badgeContent: scUserContext.user.unseen_notification_banners_counter + scUserContext.user.unseen_interactions_counter, color: "secondary" },
|
|
75
77
|
react_1.default.createElement(material_1.Icon, null, "notifications_active")) })) : null,
|
|
76
78
|
privateMessagingEnabled && scUserContext.user ? (react_1.default.createElement(material_1.BottomNavigationAction, { key: "messages", className: classes.action, component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, {}), value: scRoutingContext.url(react_core_1.SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, {}), icon: react_1.default.createElement(material_1.Badge, { badgeContent: 0, color: "secondary" },
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface ChangeGroupCoverProps {
|
|
2
|
+
/**
|
|
3
|
+
* Id of the group. It is optional only for group creation modal.
|
|
4
|
+
* @default null
|
|
5
|
+
*/
|
|
6
|
+
groupId?: number;
|
|
7
|
+
/**
|
|
8
|
+
* On change function.
|
|
9
|
+
* @default null
|
|
10
|
+
*/
|
|
11
|
+
onChange?: (cover: any) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Hides this component
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
autoHide?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Overrides or extends the styles applied to the component.
|
|
19
|
+
* @default null
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Prop to handle cover loading in the create group modal.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
isCreationMode?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Any other properties
|
|
29
|
+
*/
|
|
30
|
+
[p: string]: any;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* > API documentation for the Community-JS Change Group Cover component. Learn about the available props and the CSS API.
|
|
34
|
+
*
|
|
35
|
+
*
|
|
36
|
+
* This component renders a button that allows admins to edit the group cover and a popover that specifies format and sizes allowed.
|
|
37
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/ChangeGroupCover)
|
|
38
|
+
|
|
39
|
+
#### Import
|
|
40
|
+
```jsx
|
|
41
|
+
import {ChangeGroupCover} from '@selfcommunity/react-ui';
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
#### Component Name
|
|
45
|
+
The name `SCChangeGroupCoverButton` can be used when providing style overrides in the theme.
|
|
46
|
+
|
|
47
|
+
#### CSS
|
|
48
|
+
|
|
49
|
+
|Rule Name|Global class|Description|
|
|
50
|
+
|---|---|---|
|
|
51
|
+
|root|.SCChangeGroupCoverButton-root|Styles applied to the root element.|
|
|
52
|
+
|
|
53
|
+
* @param inProps
|
|
54
|
+
*/
|
|
55
|
+
export default function ChangeGroupCover(inProps: ChangeGroupCoverProps): JSX.Element;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
8
|
+
const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
|
|
9
|
+
const react_intl_1 = require("react-intl");
|
|
10
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
11
|
+
const system_1 = require("@mui/system");
|
|
12
|
+
const constants_1 = require("./constants");
|
|
13
|
+
const lab_1 = require("@mui/lab");
|
|
14
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
15
|
+
const Errors_1 = require("../../constants/Errors");
|
|
16
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
17
|
+
const classes = {
|
|
18
|
+
root: `${constants_1.PREFIX}-root`
|
|
19
|
+
};
|
|
20
|
+
const Root = (0, styles_1.styled)(lab_1.LoadingButton, {
|
|
21
|
+
name: constants_1.PREFIX,
|
|
22
|
+
slot: 'Root'
|
|
23
|
+
})(() => ({}));
|
|
24
|
+
const messages = (0, react_intl_1.defineMessages)({
|
|
25
|
+
errorLoadImage: {
|
|
26
|
+
id: 'ui.changeGroupCover.button.change.alertErrorImage',
|
|
27
|
+
defaultMessage: 'ui.changeGroupCover.button.change.alertErrorImage'
|
|
28
|
+
},
|
|
29
|
+
errorImageSize: {
|
|
30
|
+
id: 'ui.changeGroupCover.alert',
|
|
31
|
+
defaultMessage: 'ui.changeGroupCover.alert'
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* > API documentation for the Community-JS Change Group Cover component. Learn about the available props and the CSS API.
|
|
36
|
+
*
|
|
37
|
+
*
|
|
38
|
+
* This component renders a button that allows admins to edit the group cover and a popover that specifies format and sizes allowed.
|
|
39
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/ChangeGroupCover)
|
|
40
|
+
|
|
41
|
+
#### Import
|
|
42
|
+
```jsx
|
|
43
|
+
import {ChangeGroupCover} from '@selfcommunity/react-ui';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
#### Component Name
|
|
47
|
+
The name `SCChangeGroupCoverButton` can be used when providing style overrides in the theme.
|
|
48
|
+
|
|
49
|
+
#### CSS
|
|
50
|
+
|
|
51
|
+
|Rule Name|Global class|Description|
|
|
52
|
+
|---|---|---|
|
|
53
|
+
|root|.SCChangeGroupCoverButton-root|Styles applied to the root element.|
|
|
54
|
+
|
|
55
|
+
* @param inProps
|
|
56
|
+
*/
|
|
57
|
+
function ChangeGroupCover(inProps) {
|
|
58
|
+
//PROPS
|
|
59
|
+
const props = (0, system_1.useThemeProps)({
|
|
60
|
+
props: inProps,
|
|
61
|
+
name: constants_1.PREFIX
|
|
62
|
+
});
|
|
63
|
+
const { groupId, onChange, autoHide, className, isCreationMode = false } = props, rest = tslib_1.__rest(props, ["groupId", "onChange", "autoHide", "className", "isCreationMode"]);
|
|
64
|
+
//CONTEXT
|
|
65
|
+
const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
|
|
66
|
+
//STATE
|
|
67
|
+
let fileInput = (0, react_1.useRef)(null);
|
|
68
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
69
|
+
const [alert, setAlert] = (0, react_1.useState)(null);
|
|
70
|
+
// INTL
|
|
71
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
72
|
+
// Anonymous
|
|
73
|
+
if (!scUserContext.user) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Handles file upload
|
|
78
|
+
* @param event
|
|
79
|
+
*/
|
|
80
|
+
const handleUpload = (event) => {
|
|
81
|
+
fileInput = event.target.files[0];
|
|
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
|
+
}
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Handles cover saving after upload action
|
|
105
|
+
*/
|
|
106
|
+
function handleSave() {
|
|
107
|
+
setLoading(true);
|
|
108
|
+
const formData = new FormData();
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
formData.append('emotional_image_original', fileInput);
|
|
112
|
+
api_services_1.GroupService.changeGroupAvatarOrCover(groupId, formData, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
113
|
+
.then((data) => {
|
|
114
|
+
onChange && onChange(data.emotional_image);
|
|
115
|
+
setLoading(false);
|
|
116
|
+
})
|
|
117
|
+
.catch((error) => {
|
|
118
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
119
|
+
setLoading(false);
|
|
120
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* If there is an error
|
|
125
|
+
*/
|
|
126
|
+
if (alert) {
|
|
127
|
+
return (react_1.default.createElement(material_1.Alert, { color: "error", onClose: () => setAlert(null) }, alert));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Renders root object (if not hidden by autoHide prop)
|
|
131
|
+
*/
|
|
132
|
+
if (!autoHide) {
|
|
133
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
134
|
+
react_1.default.createElement("input", { type: "file", onChange: handleUpload, ref: fileInput, hidden: true, accept: ".gif,.png,.jpg,.jpeg" }),
|
|
135
|
+
react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), size: "medium", variant: "contained", disabled: loading, onClick: () => fileInput.current.click(), loading: loading }, rest),
|
|
136
|
+
react_1.default.createElement(Icon_1.default, null, "image"))));
|
|
137
|
+
}
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
exports.default = ChangeGroupCover;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCChangeGroupCoverButton";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface ChangeGroupPictureProps {
|
|
2
|
+
/**
|
|
3
|
+
* Id of the group. It is optional only for group creation modal.
|
|
4
|
+
* @default null
|
|
5
|
+
*/
|
|
6
|
+
groupId?: number;
|
|
7
|
+
/**
|
|
8
|
+
* On change function.
|
|
9
|
+
* @default null
|
|
10
|
+
*/
|
|
11
|
+
onChange?: (cover: any) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Hides this component
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
autoHide?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Overrides or extends the styles applied to the component.
|
|
19
|
+
* @default null
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Prop to handle avatar loading in the create group modal.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
isCreationMode?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Any other properties
|
|
29
|
+
*/
|
|
30
|
+
[p: string]: any;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* > API documentation for the Community-JS Change Group Picture component. Learn about the available props and the CSS API.
|
|
34
|
+
*
|
|
35
|
+
*
|
|
36
|
+
* This component renders a button that allows admins to manage their group pictures.
|
|
37
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/ChangeGroupPicture)
|
|
38
|
+
|
|
39
|
+
#### Import
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
import {ChangeGroupPicture} from '@selfcommunity/react-ui';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
#### Component Name
|
|
46
|
+
|
|
47
|
+
The name `SCChangeGroupPictureButton` can be used when providing style overrides in the theme.
|
|
48
|
+
|
|
49
|
+
#### CSS
|
|
50
|
+
|
|
51
|
+
|Rule Name|Global class|Description|
|
|
52
|
+
|---|---|---|
|
|
53
|
+
|root|.SCChangeGroupPictureButton-root|Styles applied to the root element.|
|
|
54
|
+
|
|
55
|
+
* @param inProps
|
|
56
|
+
*/
|
|
57
|
+
export default function ChangeGroupPicture(inProps: ChangeGroupPictureProps): JSX.Element;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const styles_1 = require("@mui/material/styles");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
|
|
8
|
+
const react_core_1 = require("@selfcommunity/react-core");
|
|
9
|
+
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
10
|
+
const system_1 = require("@mui/system");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
const Errors_1 = require("../../constants/Errors");
|
|
13
|
+
const api_services_1 = require("@selfcommunity/api-services");
|
|
14
|
+
const utils_1 = require("@selfcommunity/utils");
|
|
15
|
+
const react_intl_1 = require("react-intl");
|
|
16
|
+
const lab_1 = require("@mui/lab");
|
|
17
|
+
const messages = (0, react_intl_1.defineMessages)({
|
|
18
|
+
errorLoadImage: {
|
|
19
|
+
id: 'ui.changeGroupPicture.alert',
|
|
20
|
+
defaultMessage: 'ui.changeGroupPicture.alert'
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const classes = {
|
|
24
|
+
root: `${constants_1.PREFIX}-root`
|
|
25
|
+
};
|
|
26
|
+
const Root = (0, styles_1.styled)(lab_1.LoadingButton, {
|
|
27
|
+
name: constants_1.PREFIX,
|
|
28
|
+
slot: 'Root'
|
|
29
|
+
})(() => ({}));
|
|
30
|
+
/**
|
|
31
|
+
* > API documentation for the Community-JS Change Group Picture component. Learn about the available props and the CSS API.
|
|
32
|
+
*
|
|
33
|
+
*
|
|
34
|
+
* This component renders a button that allows admins to manage their group pictures.
|
|
35
|
+
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-ui/Components/ChangeGroupPicture)
|
|
36
|
+
|
|
37
|
+
#### Import
|
|
38
|
+
|
|
39
|
+
```jsx
|
|
40
|
+
import {ChangeGroupPicture} from '@selfcommunity/react-ui';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Component Name
|
|
44
|
+
|
|
45
|
+
The name `SCChangeGroupPictureButton` can be used when providing style overrides in the theme.
|
|
46
|
+
|
|
47
|
+
#### CSS
|
|
48
|
+
|
|
49
|
+
|Rule Name|Global class|Description|
|
|
50
|
+
|---|---|---|
|
|
51
|
+
|root|.SCChangeGroupPictureButton-root|Styles applied to the root element.|
|
|
52
|
+
|
|
53
|
+
* @param inProps
|
|
54
|
+
*/
|
|
55
|
+
function ChangeGroupPicture(inProps) {
|
|
56
|
+
//PROPS
|
|
57
|
+
const props = (0, system_1.useThemeProps)({
|
|
58
|
+
props: inProps,
|
|
59
|
+
name: constants_1.PREFIX
|
|
60
|
+
});
|
|
61
|
+
const { groupId, onChange, autoHide, className, isCreationMode = false } = props, rest = tslib_1.__rest(props, ["groupId", "onChange", "autoHide", "className", "isCreationMode"]);
|
|
62
|
+
//STATE
|
|
63
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
64
|
+
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
|
+
// INTL
|
|
69
|
+
const intl = (0, react_intl_1.useIntl)();
|
|
70
|
+
// Anonymous
|
|
71
|
+
if (!scUserContext.user) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Handles avatar upload
|
|
76
|
+
* @param event
|
|
77
|
+
*/
|
|
78
|
+
function handleUpload(event) {
|
|
79
|
+
const fileInput = event.target.files[0];
|
|
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
|
+
reader.readAsDataURL(fileInput);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// ui.changeGroupPicture.alert
|
|
100
|
+
/**
|
|
101
|
+
* Performs save avatar after upload
|
|
102
|
+
*/
|
|
103
|
+
function handleSave() {
|
|
104
|
+
setLoading(true);
|
|
105
|
+
const formData = new FormData();
|
|
106
|
+
formData.append('image_original', fileInput);
|
|
107
|
+
api_services_1.GroupService.changeGroupAvatarOrCover(groupId, formData, { headers: { 'Content-Type': 'multipart/form-data' } })
|
|
108
|
+
.then((data) => {
|
|
109
|
+
setLoading(false);
|
|
110
|
+
onChange && onChange(data.image_bigger);
|
|
111
|
+
})
|
|
112
|
+
.catch((error) => {
|
|
113
|
+
setAlert(intl.formatMessage(messages.errorLoadImage));
|
|
114
|
+
setLoading(false);
|
|
115
|
+
utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* If there is an error
|
|
120
|
+
*/
|
|
121
|
+
if (alert) {
|
|
122
|
+
return (react_1.default.createElement(material_1.Alert, { color: "error", onClose: () => setAlert(null) }, alert));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Renders the component (if not hidden by autoHide prop)
|
|
126
|
+
*/
|
|
127
|
+
if (!autoHide) {
|
|
128
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
129
|
+
react_1.default.createElement("input", { type: "file", onChange: handleUpload, ref: fileInput, hidden: true, accept: ".gif,.png,.jpg,.jpeg" }),
|
|
130
|
+
react_1.default.createElement(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), size: "small", variant: "contained", disabled: loading, onClick: () => fileInput.current.click(), loading: loading }, rest),
|
|
131
|
+
react_1.default.createElement(Icon_1.default, null, "photo_camera"))));
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
exports.default = ChangeGroupPicture;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCChangeGroupPictureButton";
|
|
@@ -16,7 +16,7 @@ export interface AttributesProps extends Omit<BoxProps, 'value' | 'onChange' | '
|
|
|
16
16
|
* @param value
|
|
17
17
|
* @default empty object
|
|
18
18
|
*/
|
|
19
|
-
onClick?: (attribute: 'categories' | 'addressing' | 'location') => void;
|
|
19
|
+
onClick?: (attribute: 'categories' | 'group' | 'addressing' | 'location') => void;
|
|
20
20
|
}
|
|
21
21
|
declare const _default: (props: AttributesProps) => JSX.Element;
|
|
22
22
|
export default _default;
|
|
@@ -26,6 +26,12 @@ exports.default = (props) => {
|
|
|
26
26
|
const handleClickCategory = (0, react_1.useCallback)(() => {
|
|
27
27
|
onClick && onClick('categories');
|
|
28
28
|
}, [onClick]);
|
|
29
|
+
const handleDeleteGroup = (0, react_1.useCallback)(() => {
|
|
30
|
+
onChange && onChange(Object.assign(Object.assign({}, value), { group: null }));
|
|
31
|
+
}, [value, onChange]);
|
|
32
|
+
const handleClickGroup = (0, react_1.useCallback)(() => {
|
|
33
|
+
onClick && onClick('group');
|
|
34
|
+
}, [onClick]);
|
|
29
35
|
const handleDeleteTag = (0, react_1.useCallback)((id) => () => {
|
|
30
36
|
onChange && onChange(Object.assign(Object.assign({}, value), { addressing: value.addressing.filter((tag) => tag.id !== id) }));
|
|
31
37
|
}, [value, onChange]);
|
|
@@ -41,6 +47,7 @@ exports.default = (props) => {
|
|
|
41
47
|
return (react_1.default.createElement(Root, { className: (0, classnames_1.default)(classes.root, className) },
|
|
42
48
|
((_a = value === null || value === void 0 ? void 0 : value.categories) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
|
|
43
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 })),
|
|
44
51
|
((_b = value === null || value === void 0 ? void 0 : value.addressing) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
|
|
45
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 })))),
|
|
46
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 }))));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SyntheticEvent } from 'react';
|
|
2
|
-
import { SCCategoryType, SCContributionType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
|
|
2
|
+
import { SCCategoryType, SCContributionType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCGroupType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
|
|
3
3
|
import { DialogProps } from '@mui/material';
|
|
4
4
|
import { EditorProps } from '../Editor';
|
|
5
5
|
import { SCMediaObjectType } from '../../types/media';
|
|
@@ -27,6 +27,7 @@ export interface ComposerProps extends Omit<DialogProps, 'defaultValue' | 'scrol
|
|
|
27
27
|
title?: string;
|
|
28
28
|
text?: string;
|
|
29
29
|
categories?: SCCategoryType[];
|
|
30
|
+
group?: SCGroupType;
|
|
30
31
|
audience?: string;
|
|
31
32
|
addressing?: SCTagType[];
|
|
32
33
|
medias?: SCMediaType[];
|
|
@@ -59,7 +59,9 @@ const COMPOSER_INITIAL_STATE = {
|
|
|
59
59
|
html: '',
|
|
60
60
|
htmlError: null,
|
|
61
61
|
categories: [],
|
|
62
|
+
group: null,
|
|
62
63
|
categoriesError: null,
|
|
64
|
+
groupsError: null,
|
|
63
65
|
addressing: null,
|
|
64
66
|
addressingError: null,
|
|
65
67
|
medias: [],
|
|
@@ -133,7 +135,7 @@ function Composer(inProps) {
|
|
|
133
135
|
const [isSubmitting, setIsSubmitting] = (0, react_1.useState)(false);
|
|
134
136
|
const [layer, setLayer] = (0, react_1.useState)();
|
|
135
137
|
const [state, dispatch] = (0, react_1.useReducer)(reducer, Object.assign(Object.assign(Object.assign({}, COMPOSER_INITIAL_STATE), defaultValue), { key: (0, utils_1.random)() }));
|
|
136
|
-
const { key, id, type, title, titleError, html, categories, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
138
|
+
const { key, id, type, title, titleError, html, categories, group, addressing, audience, medias, poll, pollError, location, error } = state;
|
|
137
139
|
const destructureFeedObject = (_feedObject) => {
|
|
138
140
|
if (_feedObject.type === types_1.SCContributionType.POST) {
|
|
139
141
|
_feedObject = _feedObject;
|
|
@@ -153,6 +155,7 @@ function Composer(inProps) {
|
|
|
153
155
|
title: _feedObject.title,
|
|
154
156
|
html: _feedObject.html,
|
|
155
157
|
categories: _feedObject.categories,
|
|
158
|
+
group: _feedObject.group,
|
|
156
159
|
addressing: _feedObject.addressing,
|
|
157
160
|
medias: _feedObject.medias,
|
|
158
161
|
poll: _feedObject.poll,
|
|
@@ -304,18 +307,23 @@ function Composer(inProps) {
|
|
|
304
307
|
}
|
|
305
308
|
}), [handleAddLayer, handleRemoveLayer, handleChangeCategories, categories]);
|
|
306
309
|
const handleChangeAudience = (0, react_1.useCallback)((value) => {
|
|
307
|
-
|
|
310
|
+
if (group || typeof value === 'object') {
|
|
311
|
+
dispatch({ type: 'group', value });
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
dispatch({ type: 'addressing', value });
|
|
315
|
+
}
|
|
308
316
|
setLayer(null);
|
|
309
|
-
}, []);
|
|
317
|
+
}, [group]);
|
|
310
318
|
const handleAddAudienceLayer = (0, react_1.useCallback)(() => handleAddLayer({
|
|
311
319
|
name: 'audience',
|
|
312
320
|
Component: AudienceLayer_1.default,
|
|
313
321
|
ComponentProps: {
|
|
314
322
|
onClose: handleRemoveLayer,
|
|
315
323
|
onSave: handleChangeAudience,
|
|
316
|
-
defaultValue: addressing
|
|
324
|
+
defaultValue: group || typeof addressing === 'object' ? group : addressing
|
|
317
325
|
}
|
|
318
|
-
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing]);
|
|
326
|
+
}), [handleAddLayer, handleRemoveLayer, handleChangeAudience, addressing, group]);
|
|
319
327
|
const handleChangeLocation = (0, react_1.useCallback)((value) => {
|
|
320
328
|
dispatch({ type: 'location', value });
|
|
321
329
|
setLayer(null);
|
|
@@ -406,6 +414,9 @@ function Composer(inProps) {
|
|
|
406
414
|
if (features.includes(types_1.SCFeatureName.TAGGING) && addressing !== null) {
|
|
407
415
|
data.addressing = addressing.map((t) => t.id);
|
|
408
416
|
}
|
|
417
|
+
if (features.includes(types_1.SCFeatureName.GROUPING) && group !== null) {
|
|
418
|
+
data.group = group.id;
|
|
419
|
+
}
|
|
409
420
|
setIsSubmitting(true);
|
|
410
421
|
// Finding right url
|
|
411
422
|
const _type = type === Composer_1.COMPOSER_TYPE_POLL ? types_1.SCContributionType.POST : type;
|
|
@@ -433,7 +444,7 @@ function Composer(inProps) {
|
|
|
433
444
|
dispatch({ type: 'multiple', value: (0, api_services_1.formatHttpErrorCode)(error) });
|
|
434
445
|
})
|
|
435
446
|
.then(() => setIsSubmitting(false));
|
|
436
|
-
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, addressing, audience, medias, poll, location, hasPoll]);
|
|
447
|
+
}, [scUserContext.user, feedObjectType, id, type, title, html, categories, group, addressing, audience, medias, poll, location, hasPoll]);
|
|
437
448
|
//edited here
|
|
438
449
|
const handleClose = (0, react_1.useCallback)((event, reason) => {
|
|
439
450
|
if (unloadRef.current) {
|
|
@@ -488,13 +499,29 @@ function Composer(inProps) {
|
|
|
488
499
|
}
|
|
489
500
|
switch (type) {
|
|
490
501
|
case Composer_1.COMPOSER_TYPE_POLL:
|
|
491
|
-
return (react_1.default.createElement(ContentPoll_1.default, { key: key, onChange: handleChangePoll, value: { html,
|
|
502
|
+
return (react_1.default.createElement(ContentPoll_1.default, { key: key, onChange: handleChangePoll, value: { html, group, addressing, medias, poll, location }, error: pollError, disabled: isSubmitting }));
|
|
492
503
|
case types_1.SCContributionType.DISCUSSION:
|
|
493
|
-
return (react_1.default.createElement(ContentDiscussion_1.default, { key: key, value: { title, html, categories, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) }));
|
|
504
|
+
return (react_1.default.createElement(ContentDiscussion_1.default, { key: key, value: { title, html, categories, group, addressing, medias, poll, location }, error: { titleError, error }, onChange: handleChangeDiscussion, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: true, uploadImage: true }, EditorProps) }));
|
|
494
505
|
default:
|
|
495
|
-
return (react_1.default.createElement(ContentPost_1.default, { key: key, value: { html, categories, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
|
|
506
|
+
return (react_1.default.createElement(ContentPost_1.default, { key: key, value: { html, categories, group, addressing, medias, poll, location }, error: { error }, onChange: handleChangePost, disabled: isSubmitting, EditorProps: Object.assign({ toolbar: false, uploadImage: false }, EditorProps) }));
|
|
496
507
|
}
|
|
497
|
-
}, [
|
|
508
|
+
}, [
|
|
509
|
+
key,
|
|
510
|
+
type,
|
|
511
|
+
title,
|
|
512
|
+
html,
|
|
513
|
+
categories,
|
|
514
|
+
group,
|
|
515
|
+
addressing,
|
|
516
|
+
medias,
|
|
517
|
+
poll,
|
|
518
|
+
pollError,
|
|
519
|
+
location,
|
|
520
|
+
error,
|
|
521
|
+
handleChangePoll,
|
|
522
|
+
handleChangePost,
|
|
523
|
+
isSubmitting
|
|
524
|
+
]);
|
|
498
525
|
if (!scUserContext.user && !(scUserContext.loading && open)) {
|
|
499
526
|
return null;
|
|
500
527
|
}
|
|
@@ -506,7 +533,7 @@ function Composer(inProps) {
|
|
|
506
533
|
react_1.default.createElement(LoadingButton_1.default, { size: "small", type: "submit", color: "secondary", variant: "contained", disabled: !canSubmit, loading: isSubmitting },
|
|
507
534
|
react_1.default.createElement(react_intl_1.FormattedMessage, { id: "ui.composer.submit", defaultMessage: "ui.composer.submit" }))),
|
|
508
535
|
react_1.default.createElement(material_1.DialogContent, { className: classes.content },
|
|
509
|
-
react_1.default.createElement(Attributes_1.default, { value: { categories, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
536
|
+
react_1.default.createElement(Attributes_1.default, { value: { categories, group, addressing, location }, className: classes.attributes, onChange: handleChangeAttributes, onClick: handleClickAttributes }),
|
|
510
537
|
content,
|
|
511
538
|
medias && medias.length > 0 && (react_1.default.createElement(material_1.Box, { className: classes.medias }, mediaObjectTypes.map((mediaObjectType) => {
|
|
512
539
|
if (mediaObjectType.previewComponent) {
|
|
@@ -526,7 +553,7 @@ function Composer(inProps) {
|
|
|
526
553
|
}),
|
|
527
554
|
react_1.default.createElement(material_1.IconButton, { disabled: isSubmitting, onClick: handleAddCategoryLayer },
|
|
528
555
|
react_1.default.createElement(Icon_1.default, null, "category")),
|
|
529
|
-
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), onClick: handleAddAudienceLayer }, addressing === null || addressing.length === 0 ? (react_1.default.createElement(Icon_1.default, null, "public")) : typeof addressing === 'object' ? (react_1.default.createElement(Icon_1.default, null, "groups")) : (react_1.default.createElement(Icon_1.default, null, "label"))),
|
|
530
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' },
|
|
531
558
|
react_1.default.createElement(Icon_1.default, null, "add_location_alt"))))),
|
|
532
559
|
layer && (react_1.default.createElement(LayerTransitionRoot, { className: classes.layerTransitionRoot, in: true, container: dialogRef.current, direction: "left" },
|
|
@@ -26,6 +26,7 @@ const Root = (0, styles_1.styled)(material_1.Box, {
|
|
|
26
26
|
const DEFAULT_DISCUSSION = {
|
|
27
27
|
title: '',
|
|
28
28
|
categories: [],
|
|
29
|
+
group: null,
|
|
29
30
|
medias: [],
|
|
30
31
|
html: '',
|
|
31
32
|
addressing: []
|
|
@@ -45,9 +46,12 @@ exports.default = (props) => {
|
|
|
45
46
|
}, [value]);
|
|
46
47
|
// RENDER
|
|
47
48
|
return (react_1.default.createElement(Root, { className: (0, classnames_1.default)(classes.root, className) },
|
|
48
|
-
generalError && react_1.default.createElement(material_1.Typography, { className: classes.generalError },
|
|
49
|
-
react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` })),
|
|
50
|
-
react_1.default.createElement(material_1.TextField, { className: classes.title, placeholder: intl.formatMessage({
|
|
49
|
+
generalError && (react_1.default.createElement(material_1.Typography, { className: classes.generalError },
|
|
50
|
+
react_1.default.createElement(react_intl_1.FormattedMessage, { id: `ui.composer.error.${generalError}`, defaultMessage: `ui.composer.error.${generalError}` }))),
|
|
51
|
+
react_1.default.createElement(material_1.TextField, { className: classes.title, placeholder: intl.formatMessage({
|
|
52
|
+
id: 'ui.composer.content.discussion.title.label',
|
|
53
|
+
defaultMessage: 'ui.composer.content.discussion.title.label'
|
|
54
|
+
}), autoFocus: true, fullWidth: true, variant: "outlined", value: value.title, multiline: true, onChange: handleChangeTitle, InputProps: {
|
|
51
55
|
endAdornment: react_1.default.createElement(material_1.Typography, { variant: "body2" }, Composer_1.COMPOSER_TITLE_MAX_LENGTH - value.title.length)
|
|
52
56
|
}, error: Boolean(titleError), helperText: titleError, disabled: disabled }),
|
|
53
57
|
react_1.default.createElement(Editor_1.default, Object.assign({}, EditorProps, { editable: !disabled, className: classes.editor, onChange: handleChangeHtml, defaultValue: value.html }))));
|