@selfcommunity/react-ui 0.7.9-alpha.3 → 0.7.9-alpha.30
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/ChangeGroupCover/ChangeGroupCover.js +24 -1
- package/lib/cjs/components/ChangeGroupPicture/ChangeGroupPicture.js +32 -11
- package/lib/cjs/components/Composer/Attributes/Attributes.d.ts +1 -1
- package/lib/cjs/components/Composer/Attributes/Attributes.js +9 -2
- 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 +2 -2
- package/lib/cjs/components/CreateGroupButton/CreateGroupButton.js +5 -6
- package/lib/cjs/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/cjs/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
- 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/FeedObject/Actions/Follow/Follow.js +18 -0
- package/lib/cjs/components/FeedObject/Actions/Share/Share.js +18 -0
- package/lib/cjs/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/cjs/components/FeedObject/FeedObject.js +43 -9
- package/lib/cjs/components/Group/Group.d.ts +4 -3
- package/lib/cjs/components/Group/Group.js +5 -4
- package/lib/cjs/components/Group/Skeleton.js +1 -1
- 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/{CreateGroup → GroupForm}/constants.js +1 -1
- 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 +6 -5
- package/lib/cjs/components/GroupHeader/GroupHeader.js +21 -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 +12 -8
- package/lib/cjs/components/GroupInviteButton/GroupInviteButton.js +7 -6
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/cjs/components/GroupMembersButton/GroupMembersButton.js +3 -2
- package/lib/cjs/components/GroupMembersWidget/GroupMembersWidget.js +36 -16
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +0 -5
- package/lib/cjs/components/GroupRequestsWidget/GroupRequestsWidget.js +17 -7
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/cjs/components/GroupSettingsIconButton/GroupSettingsIconButton.js +132 -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 +24 -9
- package/lib/cjs/components/Groups/Groups.d.ts +16 -16
- package/lib/cjs/components/Groups/Groups.js +47 -96
- package/lib/cjs/components/Groups/Skeleton.d.ts +14 -2
- package/lib/cjs/components/Groups/Skeleton.js +12 -5
- package/lib/cjs/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
- 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 +79 -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 +32 -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 +10 -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/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/VoteButton/VoteButton.js +19 -0
- package/lib/cjs/index.d.ts +7 -4
- package/lib/cjs/index.js +13 -6
- 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.d.ts +1 -1
- package/lib/esm/components/Composer/Attributes/Attributes.js +9 -2
- 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 +2 -2
- package/lib/esm/components/CreateGroupButton/CreateGroupButton.js +5 -6
- package/lib/esm/components/CustomAdv/CustomAdv.d.ts +4 -0
- package/lib/esm/components/{CreateGroup/CreateGroup.d.ts → EditGroupButton/EditGroupButton.d.ts} +11 -16
- 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/FeedObject/Actions/Follow/Follow.js +20 -2
- package/lib/esm/components/FeedObject/Actions/Share/Share.js +20 -2
- package/lib/esm/components/FeedObject/FeedObject.d.ts +1 -0
- package/lib/esm/components/FeedObject/FeedObject.js +45 -11
- package/lib/esm/components/Group/Group.d.ts +4 -3
- package/lib/esm/components/Group/Group.js +5 -4
- package/lib/esm/components/Group/Skeleton.js +1 -1
- 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 +6 -5
- package/lib/esm/components/GroupHeader/GroupHeader.js +21 -11
- 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 +12 -8
- package/lib/esm/components/GroupInviteButton/GroupInviteButton.js +7 -6
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.d.ts +5 -0
- package/lib/esm/components/GroupMembersButton/GroupMembersButton.js +4 -3
- package/lib/esm/components/GroupMembersWidget/GroupMembersWidget.js +38 -18
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.d.ts +0 -5
- package/lib/esm/components/GroupRequestsWidget/GroupRequestsWidget.js +17 -7
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.d.ts +48 -0
- package/lib/esm/components/GroupSettingsIconButton/GroupSettingsIconButton.js +129 -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 +25 -10
- package/lib/esm/components/Groups/Groups.d.ts +16 -16
- package/lib/esm/components/Groups/Groups.js +52 -101
- package/lib/esm/components/Groups/Skeleton.d.ts +14 -2
- package/lib/esm/components/Groups/Skeleton.js +13 -5
- package/lib/esm/components/InlineComposerWidget/InlineComposerWidget.d.ts +2 -1
- 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 +76 -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 +32 -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 +11 -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/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/VoteButton/VoteButton.js +20 -1
- package/lib/esm/index.d.ts +7 -4
- package/lib/esm/index.js +8 -5
- package/lib/umd/react-ui.js +1 -1
- package/package.json +6 -6
- package/lib/cjs/components/CreateGroup/CreateGroup.js +0 -187
- package/lib/cjs/components/CreateGroup/constants.d.ts +0 -1
- package/lib/cjs/components/CreateGroup/index.d.ts +0 -3
- package/lib/cjs/components/CreateGroup/index.js +0 -5
- package/lib/esm/components/CreateGroup/CreateGroup.js +0 -184
- package/lib/esm/components/CreateGroup/constants.d.ts +0 -1
- package/lib/esm/components/CreateGroup/constants.js +0 -1
- package/lib/esm/components/CreateGroup/index.d.ts +0 -3
- package/lib/esm/components/CreateGroup/index.js +0 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BaseDialogProps } from '../../shared/BaseDialog';
|
|
2
|
+
import { SCGroupType } from '@selfcommunity/types';
|
|
3
|
+
export interface GroupFormProps extends BaseDialogProps {
|
|
4
|
+
/**
|
|
5
|
+
* Overrides or extends the styles applied to the component.
|
|
6
|
+
* @default null
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Open dialog
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
open?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* On dialog close callback function
|
|
16
|
+
* @default null
|
|
17
|
+
*/
|
|
18
|
+
onClose?: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Group Object
|
|
21
|
+
* @default null
|
|
22
|
+
*/
|
|
23
|
+
group?: SCGroupType;
|
|
24
|
+
/**
|
|
25
|
+
* On success callback function
|
|
26
|
+
* @default null
|
|
27
|
+
*/
|
|
28
|
+
onSuccess?: (data: SCGroupType) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Any other properties
|
|
31
|
+
*/
|
|
32
|
+
[p: string]: any;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
*> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
|
|
36
|
+
*
|
|
37
|
+
#### Import
|
|
38
|
+
```jsx
|
|
39
|
+
import {GroupForm} from '@selfcommunity/react-ui';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### Component Name
|
|
43
|
+
The name `SCGroupForm` can be used when providing style overrides in the theme.
|
|
44
|
+
|
|
45
|
+
#### CSS
|
|
46
|
+
|
|
47
|
+
|Rule Name|Global class|Description|
|
|
48
|
+
|---|---|---|
|
|
49
|
+
|root|.SCGroupForm-root|Styles applied to the root element.|
|
|
50
|
+
|active|.SCGroupForm-active|Styles applied to the active element.|
|
|
51
|
+
|title|.SCGroupForm-title|Styles applied to the title element.|
|
|
52
|
+
|header|.SCGroupForm-header|Styles applied to the header element.|
|
|
53
|
+
|cover|.SCGroupForm-cover|Styles applied to the cover field.|
|
|
54
|
+
|avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
|
|
55
|
+
|form|.SCGroupForm-form|Styles applied to the form element.|
|
|
56
|
+
|switch|.SCGroupForm-switch|Styles applied to the switch element.|
|
|
57
|
+
|switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
|
|
58
|
+
|name|.SCGroupForm-name|Styles applied to the name field.|
|
|
59
|
+
|description|.SCGroupForm-description|Styles applied to the description field.|
|
|
60
|
+
|content|.SCGroupForm-content|Styles applied to the element.|
|
|
61
|
+
|privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
|
|
62
|
+
|privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
|
|
63
|
+
|visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
|
|
64
|
+
|visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
|
|
65
|
+
|inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
|
|
66
|
+
|error|.SCGroupForm-error|Styles applied to the error elements.|
|
|
67
|
+
|
|
68
|
+
* @param inProps
|
|
69
|
+
*/
|
|
70
|
+
export default function GroupForm(inProps: GroupFormProps): JSX.Element;
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { useThemeProps } from '@mui/system';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { Avatar, Box, Divider, FormGroup, Icon, Paper, Stack, Switch, TextField, Typography } from '@mui/material';
|
|
6
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
7
|
+
import { SCPreferences, useSCPreferences } from '@selfcommunity/react-core';
|
|
8
|
+
import classNames from 'classnames';
|
|
9
|
+
import { PREFIX } from './constants';
|
|
10
|
+
import BaseDialog from '../../shared/BaseDialog';
|
|
11
|
+
import { LoadingButton } from '@mui/lab';
|
|
12
|
+
import ChangeGroupPicture from '../ChangeGroupPicture';
|
|
13
|
+
import ChangeGroupCover from '../ChangeGroupCover';
|
|
14
|
+
import { GROUP_DESCRIPTION_MAX_LENGTH, GROUP_TITLE_MAX_LENGTH } from '../../constants/Group';
|
|
15
|
+
import GroupInviteButton from '../GroupInviteButton';
|
|
16
|
+
import { SCGroupPrivacyType } from '@selfcommunity/types';
|
|
17
|
+
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
18
|
+
import { formatHttpErrorCode, GroupService } from '@selfcommunity/api-services';
|
|
19
|
+
import { Logger } from '@selfcommunity/utils';
|
|
20
|
+
const messages = defineMessages({
|
|
21
|
+
name: {
|
|
22
|
+
id: 'ui.groupForm.name.placeholder',
|
|
23
|
+
defaultMessage: 'ui.groupForm.name.placeholder'
|
|
24
|
+
},
|
|
25
|
+
description: {
|
|
26
|
+
id: 'ui.groupForm.description.placeholder',
|
|
27
|
+
defaultMessage: 'ui.groupForm.description.placeholder'
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
const classes = {
|
|
31
|
+
root: `${PREFIX}-root`,
|
|
32
|
+
active: `${PREFIX}-active`,
|
|
33
|
+
title: `${PREFIX}-title`,
|
|
34
|
+
header: `${PREFIX}-header`,
|
|
35
|
+
cover: `${PREFIX}-cover`,
|
|
36
|
+
avatar: `${PREFIX}-avatar`,
|
|
37
|
+
form: `${PREFIX}-form`,
|
|
38
|
+
switch: `${PREFIX}-switch`,
|
|
39
|
+
switchLabel: `${PREFIX}-switch-label`,
|
|
40
|
+
name: `${PREFIX}-name`,
|
|
41
|
+
description: `${PREFIX}-description`,
|
|
42
|
+
content: `${PREFIX}-content`,
|
|
43
|
+
privacySection: `${PREFIX}-privacy-section`,
|
|
44
|
+
privacySectionInfo: `${PREFIX}-privacy-section-info`,
|
|
45
|
+
visibilitySection: `${PREFIX}-visibility-section`,
|
|
46
|
+
visibilitySectionInfo: `${PREFIX}-visibility-section-info`,
|
|
47
|
+
inviteSection: `${PREFIX}-invite-section`,
|
|
48
|
+
error: `${PREFIX}-error`
|
|
49
|
+
};
|
|
50
|
+
const Root = styled(BaseDialog, {
|
|
51
|
+
name: PREFIX,
|
|
52
|
+
slot: 'Root'
|
|
53
|
+
})(() => ({}));
|
|
54
|
+
/**
|
|
55
|
+
*> API documentation for the Community-JS Group Form component. Learn about the available props and the CSS API.
|
|
56
|
+
*
|
|
57
|
+
#### Import
|
|
58
|
+
```jsx
|
|
59
|
+
import {GroupForm} from '@selfcommunity/react-ui';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Component Name
|
|
63
|
+
The name `SCGroupForm` can be used when providing style overrides in the theme.
|
|
64
|
+
|
|
65
|
+
#### CSS
|
|
66
|
+
|
|
67
|
+
|Rule Name|Global class|Description|
|
|
68
|
+
|---|---|---|
|
|
69
|
+
|root|.SCGroupForm-root|Styles applied to the root element.|
|
|
70
|
+
|active|.SCGroupForm-active|Styles applied to the active element.|
|
|
71
|
+
|title|.SCGroupForm-title|Styles applied to the title element.|
|
|
72
|
+
|header|.SCGroupForm-header|Styles applied to the header element.|
|
|
73
|
+
|cover|.SCGroupForm-cover|Styles applied to the cover field.|
|
|
74
|
+
|avatar|.SCGroupForm-avatar|Styles applied to the avatar field.|
|
|
75
|
+
|form|.SCGroupForm-form|Styles applied to the form element.|
|
|
76
|
+
|switch|.SCGroupForm-switch|Styles applied to the switch element.|
|
|
77
|
+
|switchLabel|.SCGroupForm-switch-label|Styles applied to the switchLabel element.|
|
|
78
|
+
|name|.SCGroupForm-name|Styles applied to the name field.|
|
|
79
|
+
|description|.SCGroupForm-description|Styles applied to the description field.|
|
|
80
|
+
|content|.SCGroupForm-content|Styles applied to the element.|
|
|
81
|
+
|privacySection|.SCGroupForm-privacy-section|Styles applied to the privacy section.|
|
|
82
|
+
|privacySectionInfo|.SCGroupForm-privacy-section-info|Styles applied to the privacy info section.|
|
|
83
|
+
|visibilitySection|.SCGroupForm-visibility-section|Styles applied to the visibility section.|
|
|
84
|
+
|visibilitySectionInfo|.SCGroupForm-visibility-section-info|Styles applied to the visibility section info.|
|
|
85
|
+
|inviteSection|.SCGroupForm-invite-section|Styles applied to the invite section.|
|
|
86
|
+
|error|.SCGroupForm-error|Styles applied to the error elements.|
|
|
87
|
+
|
|
88
|
+
* @param inProps
|
|
89
|
+
*/
|
|
90
|
+
export default function GroupForm(inProps) {
|
|
91
|
+
//PROPS
|
|
92
|
+
const props = useThemeProps({
|
|
93
|
+
props: inProps,
|
|
94
|
+
name: PREFIX
|
|
95
|
+
});
|
|
96
|
+
const { className, open = true, onClose, onSuccess, group = null } = props, rest = __rest(props, ["className", "open", "onClose", "onSuccess", "group"]);
|
|
97
|
+
const initialFieldState = {
|
|
98
|
+
imageOriginal: group ? group.image_medium : '',
|
|
99
|
+
imageOriginalFile: '',
|
|
100
|
+
emotionalImageOriginal: group ? group.emotional_image : '',
|
|
101
|
+
emotionalImageOriginalFile: '',
|
|
102
|
+
name: group ? group.name : '',
|
|
103
|
+
description: group ? group.description : '',
|
|
104
|
+
isPublic: group && group.privacy === SCGroupPrivacyType.PUBLIC,
|
|
105
|
+
isVisible: group ? group.visible : true,
|
|
106
|
+
invitedUsers: null,
|
|
107
|
+
isSubmitting: false
|
|
108
|
+
};
|
|
109
|
+
// STATE
|
|
110
|
+
const [field, setField] = useState(initialFieldState);
|
|
111
|
+
const [error, setError] = useState({});
|
|
112
|
+
// INTL
|
|
113
|
+
const intl = useIntl();
|
|
114
|
+
// PREFERENCES
|
|
115
|
+
const scPreferences = useSCPreferences();
|
|
116
|
+
const _backgroundCover = Object.assign({}, (field.emotionalImageOriginal
|
|
117
|
+
? { background: `url('${field.emotionalImageOriginal}') center / cover` }
|
|
118
|
+
: { background: `url('${scPreferences.preferences[SCPreferences.IMAGES_USER_DEFAULT_COVER].value}') center / cover` }));
|
|
119
|
+
function handleChangeAvatar(avatar) {
|
|
120
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginalFile']: avatar })));
|
|
121
|
+
const reader = new FileReader();
|
|
122
|
+
reader.onloadend = () => {
|
|
123
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['imageOriginal']: reader.result })));
|
|
124
|
+
};
|
|
125
|
+
reader.readAsDataURL(avatar);
|
|
126
|
+
if (error.imageOriginalError) {
|
|
127
|
+
delete error.imageOriginalError;
|
|
128
|
+
setError(error);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function handleChangeCover(cover) {
|
|
132
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginalFile']: cover })));
|
|
133
|
+
const reader = new FileReader();
|
|
134
|
+
reader.onloadend = () => {
|
|
135
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['emotionalImageOriginal']: reader.result })));
|
|
136
|
+
};
|
|
137
|
+
reader.readAsDataURL(cover);
|
|
138
|
+
if (error.emotionalImageOriginalError) {
|
|
139
|
+
delete error.emotionalImageOriginalError;
|
|
140
|
+
setError(error);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const handleSubmit = () => {
|
|
144
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: true })));
|
|
145
|
+
const formData = new FormData();
|
|
146
|
+
formData.append('name', field.name);
|
|
147
|
+
formData.append('description', field.description);
|
|
148
|
+
formData.append('privacy', field.isPublic ? SCGroupPrivacyType.PUBLIC : SCGroupPrivacyType.PRIVATE);
|
|
149
|
+
formData.append('visible', field.isVisible);
|
|
150
|
+
if (field.imageOriginalFile) {
|
|
151
|
+
formData.append('image_original', field.imageOriginalFile);
|
|
152
|
+
}
|
|
153
|
+
if (field.emotionalImageOriginalFile) {
|
|
154
|
+
formData.append('emotional_image_original', field.emotionalImageOriginalFile);
|
|
155
|
+
}
|
|
156
|
+
for (const key in field.invitedUsers) {
|
|
157
|
+
formData.append(key, field.invitedUsers[key]);
|
|
158
|
+
}
|
|
159
|
+
let groupService;
|
|
160
|
+
if (group) {
|
|
161
|
+
groupService = GroupService.updateGroup(group.id, formData, { headers: { 'Content-Type': 'multipart/form-data' } });
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
groupService = GroupService.createGroup(formData, { headers: { 'Content-Type': 'multipart/form-data' } });
|
|
165
|
+
}
|
|
166
|
+
groupService
|
|
167
|
+
.then((data) => {
|
|
168
|
+
onSuccess && onSuccess(data);
|
|
169
|
+
onClose && onClose();
|
|
170
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
171
|
+
})
|
|
172
|
+
.catch((e) => {
|
|
173
|
+
setError(Object.assign(Object.assign({}, error), formatHttpErrorCode(e)));
|
|
174
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
|
|
175
|
+
Logger.error(SCOPE_SC_UI, e);
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
const handleInviteSection = (data) => {
|
|
179
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { ['invitedUsers']: data })));
|
|
180
|
+
};
|
|
181
|
+
const handleChange = (event) => {
|
|
182
|
+
const { name, value } = event.target;
|
|
183
|
+
setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
|
|
184
|
+
if (error[`${name}Error`]) {
|
|
185
|
+
delete error[`${name}Error`];
|
|
186
|
+
setError(error);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* Renders root object
|
|
191
|
+
*/
|
|
192
|
+
return (React.createElement(Root, Object.assign({ DialogContentProps: { dividers: false }, title: group ? (React.createElement(FormattedMessage, { id: "ui.groupForm.title.edit", defaultMessage: "ui.groupForm.title.edit" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.title", defaultMessage: "ui.groupForm.title" })), open: open, onClose: onClose, className: classNames(classes.root, className), actions: React.createElement(LoadingButton, { loading: field.isSubmitting, disabled: !field.name || Object.keys(error).length !== 0, variant: "contained", onClick: handleSubmit, color: "secondary" }, group ? (React.createElement(FormattedMessage, { id: "ui.groupForm.button.edit", defaultMessage: "ui.groupForm.button.edit" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.button.create", defaultMessage: "ui.groupForm.button.create" }))) }, rest),
|
|
193
|
+
React.createElement(React.Fragment, null,
|
|
194
|
+
React.createElement(React.Fragment, null,
|
|
195
|
+
React.createElement(Paper, { style: _backgroundCover, classes: { root: classes.cover } },
|
|
196
|
+
React.createElement(Box, { className: classes.avatar },
|
|
197
|
+
React.createElement(Avatar, null, field.imageOriginal ? React.createElement("img", { src: field.imageOriginal, alt: "avatar" }) : React.createElement(Icon, null, "icon_image"))),
|
|
198
|
+
React.createElement(React.Fragment, null,
|
|
199
|
+
React.createElement(ChangeGroupPicture, { isCreationMode: true, onChange: handleChangeAvatar }),
|
|
200
|
+
React.createElement(ChangeGroupCover, { isCreationMode: true, onChange: handleChangeCover }))),
|
|
201
|
+
React.createElement(Typography, { className: classNames(classes.header, { [classes.error]: error.emotionalImageOriginalError || error.imageOriginalError }), align: "center" }, error.emotionalImageOriginalError || error.imageOriginalError ? (React.createElement(FormattedMessage, { id: "ui.groupForm.header.error", defaultMessage: "ui.groupForm.header.error" })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.header", defaultMessage: "ui.groupForm.header" })))),
|
|
202
|
+
React.createElement(FormGroup, { className: classes.form },
|
|
203
|
+
React.createElement(TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
|
|
204
|
+
endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_TITLE_MAX_LENGTH - field.name.length)
|
|
205
|
+
} }),
|
|
206
|
+
React.createElement(TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
|
|
207
|
+
endAdornment: React.createElement(Typography, { variant: "body2" }, GROUP_DESCRIPTION_MAX_LENGTH - field.description.length)
|
|
208
|
+
} }),
|
|
209
|
+
React.createElement(Box, { className: classes.privacySection },
|
|
210
|
+
React.createElement(Typography, { variant: "h4" },
|
|
211
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.title", defaultMessage: "ui.groupForm.privacy.title", values: { b: (chunks) => React.createElement("strong", null, chunks) } })),
|
|
212
|
+
React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
213
|
+
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !field.isPublic }) },
|
|
214
|
+
React.createElement(Icon, null, "private"),
|
|
215
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private", defaultMessage: "ui.groupForm.privacy.private" })),
|
|
216
|
+
React.createElement(Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: group && group.privacy === SCGroupPrivacyType.PRIVATE }),
|
|
217
|
+
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: field.isPublic }) },
|
|
218
|
+
React.createElement(Icon, null, "public"),
|
|
219
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public", defaultMessage: "ui.groupForm.privacy.public" }))),
|
|
220
|
+
React.createElement(Typography, { variant: "body2", className: classes.privacySectionInfo }, field.isPublic ? (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.public.info", defaultMessage: "ui.groupForm.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })) : (React.createElement(React.Fragment, null, group && group.privacy === SCGroupPrivacyType.PRIVATE ? (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info.edit", defaultMessage: "ui.groupForm.private.public.info.edit", values: { b: (chunks) => React.createElement("strong", null, chunks) } })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.privacy.private.info", defaultMessage: "ui.groupForm.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))))),
|
|
221
|
+
React.createElement(Box, { className: classes.visibilitySection }, ((!field.isPublic && !group) || (group && !field.isPublic)) && (React.createElement(React.Fragment, null,
|
|
222
|
+
React.createElement(Typography, { variant: "h4" },
|
|
223
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.title", defaultMessage: "ui.groupForm.visibility.title", values: { b: (chunks) => React.createElement("strong", null, chunks) } })),
|
|
224
|
+
React.createElement(Stack, { direction: "row", spacing: 1, alignItems: "center" },
|
|
225
|
+
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: !field.isVisible }) },
|
|
226
|
+
React.createElement(Icon, null, "visibility_off"),
|
|
227
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
|
|
228
|
+
React.createElement(Switch, { className: classes.switch, checked: field.isVisible, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isVisible']: !field.isVisible }))) }),
|
|
229
|
+
React.createElement(Typography, { className: classNames(classes.switchLabel, { [classes.active]: field.isVisible }) },
|
|
230
|
+
React.createElement(Icon, null, "visibility"),
|
|
231
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" }))),
|
|
232
|
+
React.createElement(Typography, { variant: "body2", className: classes.visibilitySectionInfo }, !field.isVisible ? (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })) : (React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))))),
|
|
233
|
+
React.createElement(Divider, null),
|
|
234
|
+
React.createElement(Box, { className: classes.inviteSection },
|
|
235
|
+
React.createElement(GroupInviteButton, { handleInvitations: handleInviteSection })))));
|
|
236
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PREFIX = "SCGroupForm";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const PREFIX = 'SCGroupForm';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { SCGroupType } from '@selfcommunity/types';
|
|
3
2
|
import { ChangeGroupCoverProps } from '../ChangeGroupCover';
|
|
4
3
|
import { ChangeGroupPictureProps } from '../ChangeGroupPicture';
|
|
5
4
|
import { GroupMembersButtonProps } from '../GroupMembersButton';
|
|
5
|
+
import { GroupSubscribeButtonProps } from '../GroupSubscribeButton';
|
|
6
6
|
export interface GroupHeaderProps {
|
|
7
7
|
/**
|
|
8
8
|
* Id of group object
|
|
@@ -35,14 +35,15 @@ export interface GroupHeaderProps {
|
|
|
35
35
|
*/
|
|
36
36
|
ChangeCoverProps?: ChangeGroupCoverProps;
|
|
37
37
|
/**
|
|
38
|
-
* Props to spread
|
|
38
|
+
* Props to spread group button followed
|
|
39
39
|
* @default {}
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
GroupSubscribeButtonProps?: GroupSubscribeButtonProps;
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
43
|
+
* Props to spread to the group memebers button
|
|
44
|
+
* @default {}
|
|
44
45
|
*/
|
|
45
|
-
|
|
46
|
+
GroupMembersButtonProps?: GroupMembersButtonProps;
|
|
46
47
|
/**
|
|
47
48
|
* Any other properties
|
|
48
49
|
*/
|
|
@@ -13,6 +13,9 @@ import { FormattedMessage } from 'react-intl';
|
|
|
13
13
|
import Bullet from '../../shared/Bullet';
|
|
14
14
|
import ChangeGroupPicture from '../ChangeGroupPicture';
|
|
15
15
|
import GroupMembersButton from '../GroupMembersButton';
|
|
16
|
+
import EditGroupButton from '../EditGroupButton';
|
|
17
|
+
import GroupSubscribeButton from '../GroupSubscribeButton';
|
|
18
|
+
import GroupInviteButton from '../GroupInviteButton';
|
|
16
19
|
const classes = {
|
|
17
20
|
root: `${PREFIX}-root`,
|
|
18
21
|
cover: `${PREFIX}-cover`,
|
|
@@ -63,13 +66,13 @@ const Root = styled(Box, {
|
|
|
63
66
|
* @param inProps
|
|
64
67
|
*/
|
|
65
68
|
export default function GroupHeader(inProps) {
|
|
66
|
-
var _a
|
|
69
|
+
var _a;
|
|
67
70
|
// PROPS
|
|
68
71
|
const props = useThemeProps({
|
|
69
72
|
props: inProps,
|
|
70
73
|
name: PREFIX
|
|
71
74
|
});
|
|
72
|
-
const { id = null, className = null, group, groupId = null, ChangePictureProps = {}, ChangeCoverProps = {},
|
|
75
|
+
const { id = null, className = null, group, groupId = null, ChangePictureProps = {}, ChangeCoverProps = {}, GroupSubscribeButtonProps = {}, GroupMembersButtonProps = {} } = props, rest = __rest(props, ["id", "className", "group", "groupId", "ChangePictureProps", "ChangeCoverProps", "GroupSubscribeButtonProps", "GroupMembersButtonProps"]);
|
|
73
76
|
// PREFERENCES
|
|
74
77
|
const scPreferences = useSCPreferences();
|
|
75
78
|
// CONTEXT
|
|
@@ -77,14 +80,14 @@ export default function GroupHeader(inProps) {
|
|
|
77
80
|
// HOOKS
|
|
78
81
|
const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
|
|
79
82
|
// CONST
|
|
80
|
-
const
|
|
83
|
+
const isGroupAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
81
84
|
/**
|
|
82
85
|
* Handles Change Avatar
|
|
83
86
|
* @param avatar
|
|
84
87
|
*/
|
|
85
88
|
function handleChangeAvatar(avatar) {
|
|
86
|
-
if (
|
|
87
|
-
setSCGroup(Object.assign({}, scGroup, {
|
|
89
|
+
if (isGroupAdmin) {
|
|
90
|
+
setSCGroup(Object.assign({}, scGroup, { image_big: avatar }));
|
|
88
91
|
}
|
|
89
92
|
}
|
|
90
93
|
/**
|
|
@@ -92,10 +95,16 @@ export default function GroupHeader(inProps) {
|
|
|
92
95
|
* @param cover
|
|
93
96
|
*/
|
|
94
97
|
function handleChangeCover(cover) {
|
|
95
|
-
if (
|
|
98
|
+
if (isGroupAdmin) {
|
|
96
99
|
setSCGroup(Object.assign({}, scGroup, { emotional_image: cover }));
|
|
97
100
|
}
|
|
98
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Handles callback subscribe/unsubscribe group
|
|
104
|
+
*/
|
|
105
|
+
const handleSubscribe = (group, status) => {
|
|
106
|
+
setSCGroup(Object.assign(Object.assign({}, group), { subscribers_counter: group.subscribers_counter + (status ? 1 : -1) }));
|
|
107
|
+
};
|
|
99
108
|
// RENDER
|
|
100
109
|
if (!scGroup) {
|
|
101
110
|
return React.createElement(GroupHeaderSkeleton, null);
|
|
@@ -107,12 +116,13 @@ export default function GroupHeader(inProps) {
|
|
|
107
116
|
React.createElement(Paper, { style: _backgroundCover, classes: { root: classes.cover } },
|
|
108
117
|
React.createElement(Box, { className: classes.avatar },
|
|
109
118
|
React.createElement(Avatar, null,
|
|
110
|
-
React.createElement("img", { alt: "group", src: scGroup.
|
|
111
|
-
|
|
119
|
+
React.createElement("img", { alt: "group", src: scGroup.image_big ? scGroup.image_big : '' }))),
|
|
120
|
+
isGroupAdmin && (React.createElement(React.Fragment, null,
|
|
112
121
|
React.createElement(ChangeGroupPicture, Object.assign({ groupId: scGroup.id, onChange: handleChangeAvatar, className: classes.changePicture }, ChangePictureProps)),
|
|
113
122
|
React.createElement("div", { className: classes.changeCover },
|
|
114
123
|
React.createElement(ChangeGroupCover, Object.assign({ groupId: scGroup.id, onChange: handleChangeCover }, ChangeCoverProps)))))),
|
|
115
124
|
React.createElement(Box, { className: classes.info },
|
|
125
|
+
isGroupAdmin && React.createElement(EditGroupButton, { group: scGroup, groupId: scGroup.id, onEditSuccess: (data) => setSCGroup(data) }),
|
|
116
126
|
React.createElement(Typography, { variant: "h5", className: classes.name }, scGroup.name),
|
|
117
127
|
React.createElement(Box, { className: classes.visibility },
|
|
118
128
|
scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(Typography, { className: classes.visibilityItem },
|
|
@@ -126,9 +136,9 @@ export default function GroupHeader(inProps) {
|
|
|
126
136
|
React.createElement(FormattedMessage, { id: "ui.groupHeader.visibility.visible", defaultMessage: "ui.groupHeader.visibility.visible" }))) : (React.createElement(Typography, { className: classes.visibilityItem },
|
|
127
137
|
React.createElement(Icon, null, "visibility_off"),
|
|
128
138
|
React.createElement(FormattedMessage, { id: "ui.groupHeader.visibility.hidden", defaultMessage: "ui.groupHeader.visibility.hidden" })))),
|
|
129
|
-
React.createElement(Box, { className: classes.members },
|
|
139
|
+
React.createElement(React.Fragment, null, ((scGroup && scGroup.privacy === SCGroupPrivacyType.PUBLIC) || isGroupAdmin) && (React.createElement(Box, { className: classes.members },
|
|
130
140
|
React.createElement(Typography, { className: classes.membersCounter, component: "div" },
|
|
131
141
|
React.createElement(FormattedMessage, { id: "ui.groupHeader.members", defaultMessage: "ui.groupHeader.members", values: { total: scGroup.subscribers_counter } })),
|
|
132
|
-
React.createElement(GroupMembersButton, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup }, GroupMembersButtonProps))),
|
|
133
|
-
|
|
142
|
+
React.createElement(GroupMembersButton, Object.assign({ groupId: scGroup === null || scGroup === void 0 ? void 0 : scGroup.id, group: scGroup, autoHide: !isGroupAdmin }, GroupMembersButtonProps))))),
|
|
143
|
+
isGroupAdmin ? (React.createElement(GroupInviteButton, { group: scGroup, groupId: scGroup.id })) : (React.createElement(GroupSubscribeButton, Object.assign({ group: scGroup, onSubscribe: handleSubscribe }, GroupSubscribeButtonProps))))));
|
|
134
144
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* > API documentation for the Community-JS Group
|
|
2
|
+
* > API documentation for the Community-JS Group Header Skeleton component. Learn about the available props and the CSS API.
|
|
3
3
|
|
|
4
4
|
#### Import
|
|
5
5
|
|
|
@@ -18,9 +18,7 @@
|
|
|
18
18
|
|root|.SCGroupHeader-skeleton-root|Styles applied to the root element.|
|
|
19
19
|
|avatar|.SCGroupHeader-avatar|Styles applied to the avatar element.|
|
|
20
20
|
|cover|.SCGroupHeader-cover|Styles applied to the cover element.|
|
|
21
|
-
|
|
|
22
|
-
|section|.SCGroupHeader-section|Styles applied to the info section.|
|
|
23
|
-
|username|.SCGroupHeader-username|Styles applied to the username element.|
|
|
21
|
+
|info|.SCGroupHeader-info|Styles applied to the info info.|
|
|
24
22
|
*
|
|
25
23
|
*/
|
|
26
24
|
declare function GroupHeaderSkeleton(): JSX.Element;
|
|
@@ -7,16 +7,14 @@ const classes = {
|
|
|
7
7
|
root: `${PREFIX}-skeleton-root`,
|
|
8
8
|
cover: `${PREFIX}-cover`,
|
|
9
9
|
avatar: `${PREFIX}-avatar`,
|
|
10
|
-
|
|
11
|
-
section: `${PREFIX}-section`,
|
|
12
|
-
username: `${PREFIX}-username`
|
|
10
|
+
info: `${PREFIX}-info`
|
|
13
11
|
};
|
|
14
12
|
const Root = styled(Box, {
|
|
15
13
|
name: PREFIX,
|
|
16
14
|
slot: 'SkeletonRoot'
|
|
17
15
|
})(() => ({}));
|
|
18
16
|
/**
|
|
19
|
-
* > API documentation for the Community-JS Group
|
|
17
|
+
* > API documentation for the Community-JS Group Header Skeleton component. Learn about the available props and the CSS API.
|
|
20
18
|
|
|
21
19
|
#### Import
|
|
22
20
|
|
|
@@ -35,9 +33,7 @@ const Root = styled(Box, {
|
|
|
35
33
|
|root|.SCGroupHeader-skeleton-root|Styles applied to the root element.|
|
|
36
34
|
|avatar|.SCGroupHeader-avatar|Styles applied to the avatar element.|
|
|
37
35
|
|cover|.SCGroupHeader-cover|Styles applied to the cover element.|
|
|
38
|
-
|
|
|
39
|
-
|section|.SCGroupHeader-section|Styles applied to the info section.|
|
|
40
|
-
|username|.SCGroupHeader-username|Styles applied to the username element.|
|
|
36
|
+
|info|.SCGroupHeader-info|Styles applied to the info info.|
|
|
41
37
|
*
|
|
42
38
|
*/
|
|
43
39
|
function GroupHeaderSkeleton() {
|
|
@@ -46,8 +42,12 @@ function GroupHeaderSkeleton() {
|
|
|
46
42
|
React.createElement(Skeleton, { className: classes.cover, animation: "wave", variant: "rectangular" }),
|
|
47
43
|
React.createElement(Box, { className: classes.avatar },
|
|
48
44
|
React.createElement(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.group.avatar.sizeLarge, height: theme.selfcommunity.group.avatar.sizeLarge })),
|
|
49
|
-
React.createElement(Box, { className: classes.
|
|
50
|
-
React.createElement(Typography, { variant: "h5"
|
|
51
|
-
React.createElement(Skeleton, { animation: "wave", sx: { height: 30, width:
|
|
45
|
+
React.createElement(Box, { className: classes.info },
|
|
46
|
+
React.createElement(Typography, { variant: "h5" },
|
|
47
|
+
React.createElement(Skeleton, { animation: "wave", sx: { height: 30, width: 200 } })),
|
|
48
|
+
React.createElement(Typography, null,
|
|
49
|
+
React.createElement(Skeleton, { animation: "wave", sx: { height: 20, width: 150 } })),
|
|
50
|
+
React.createElement(Typography, null,
|
|
51
|
+
React.createElement(Skeleton, { animation: "wave", sx: { height: 20, width: 100 } })))));
|
|
52
52
|
}
|
|
53
53
|
export default GroupHeaderSkeleton;
|
|
@@ -9,6 +9,7 @@ import { PREFIX } from './constants';
|
|
|
9
9
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
10
10
|
import { SCGroupPrivacyType } from '@selfcommunity/types';
|
|
11
11
|
import { useSCFetchGroup } from '@selfcommunity/react-core';
|
|
12
|
+
import GroupInfoWidgetSkeleton from './Skeleton';
|
|
12
13
|
const classes = {
|
|
13
14
|
root: `${PREFIX}-root`,
|
|
14
15
|
title: `${PREFIX}-title`,
|
|
@@ -62,6 +63,9 @@ export default function GroupInfoWidget(inProps) {
|
|
|
62
63
|
const { scGroup } = useSCFetchGroup({ id: groupId, group });
|
|
63
64
|
// INTL
|
|
64
65
|
const intl = useIntl();
|
|
66
|
+
if (!scGroup) {
|
|
67
|
+
return React.createElement(GroupInfoWidgetSkeleton, null);
|
|
68
|
+
}
|
|
65
69
|
/**
|
|
66
70
|
* Renders root object
|
|
67
71
|
*/
|
|
@@ -73,25 +77,25 @@ export default function GroupInfoWidget(inProps) {
|
|
|
73
77
|
React.createElement(Typography, { component: "div", className: classes.privacy }, scGroup.privacy === SCGroupPrivacyType.PUBLIC ? (React.createElement(React.Fragment, null,
|
|
74
78
|
React.createElement(Typography, { className: classes.privacyTitle },
|
|
75
79
|
React.createElement(Icon, null, "public"),
|
|
76
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
80
|
+
React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.privacy.public", defaultMessage: "ui.groupInfoWidget.privacy.public" })),
|
|
77
81
|
React.createElement(Typography, { variant: "body2" },
|
|
78
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
82
|
+
React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.privacy.public.info", defaultMessage: "ui.groupInfoWidget.privacy.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
|
|
79
83
|
React.createElement(Typography, { className: classes.privacyTitle },
|
|
80
84
|
React.createElement(Icon, null, "private"),
|
|
81
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
85
|
+
React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.privacy.private", defaultMessage: "ui.groupInfoWidget.privacy.private" })),
|
|
82
86
|
React.createElement(Typography, { variant: "body2" },
|
|
83
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
87
|
+
React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.privacy.private.info", defaultMessage: "ui.groupInfoWidget.private.public.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } }))))),
|
|
84
88
|
scGroup.privacy === SCGroupPrivacyType.PRIVATE && (React.createElement(Typography, { component: "div", className: classes.visibility }, scGroup.visible ? (React.createElement(React.Fragment, null,
|
|
85
89
|
React.createElement(Typography, { className: classes.visibilityTitle },
|
|
86
90
|
React.createElement(Icon, null, "visibility"),
|
|
87
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
91
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible", defaultMessage: "ui.groupForm.visibility.visible" })),
|
|
88
92
|
React.createElement(Typography, { variant: "body2" },
|
|
89
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
93
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.visible.info", defaultMessage: "ui.groupForm.visibility.visible.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))) : (React.createElement(React.Fragment, null,
|
|
90
94
|
React.createElement(Typography, { className: classes.visibilityTitle },
|
|
91
95
|
React.createElement(Icon, null, "visibility_off"),
|
|
92
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
96
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden", defaultMessage: "ui.groupForm.visibility.hidden" })),
|
|
93
97
|
React.createElement(Typography, { variant: "body2" },
|
|
94
|
-
React.createElement(FormattedMessage, { id: "ui.
|
|
98
|
+
React.createElement(FormattedMessage, { id: "ui.groupForm.visibility.hidden.info", defaultMessage: "ui.groupForm.visibility.hidden.info", values: { b: (chunks) => React.createElement("strong", null, chunks) } })))))),
|
|
95
99
|
React.createElement(Typography, { variant: "body2", className: classes.date },
|
|
96
100
|
React.createElement(FormattedMessage, { id: "ui.groupInfoWidget.date", defaultMessage: "ui.groupInfoWidget.date", values: { date: intl.formatDate(scGroup.created_at, { day: 'numeric', year: 'numeric', month: 'long' }) } })))));
|
|
97
101
|
}
|
|
@@ -71,6 +71,7 @@ const DialogRoot = styled(BaseDialog, {
|
|
|
71
71
|
* @param inProps
|
|
72
72
|
*/
|
|
73
73
|
export default function GroupInviteButton(inProps) {
|
|
74
|
+
var _a;
|
|
74
75
|
//PROPS
|
|
75
76
|
const props = useThemeProps({
|
|
76
77
|
props: inProps,
|
|
@@ -105,10 +106,9 @@ export default function GroupInviteButton(inProps) {
|
|
|
105
106
|
}
|
|
106
107
|
return [invited];
|
|
107
108
|
}, [invited]);
|
|
108
|
-
// CONST
|
|
109
|
-
const authUserId = scUserContext.user ? scUserContext.user.id : null;
|
|
110
109
|
// HOOKS
|
|
111
110
|
const { scGroup } = useSCFetchGroup({ id: groupId, group });
|
|
111
|
+
const isGroupAdmin = useMemo(() => { var _a; return scUserContext.user && ((_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scGroup === null || scGroup === void 0 ? void 0 : scGroup.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
|
|
112
112
|
// INTL
|
|
113
113
|
const intl = useIntl();
|
|
114
114
|
function fetchResults() {
|
|
@@ -179,6 +179,7 @@ export default function GroupInviteButton(inProps) {
|
|
|
179
179
|
.then(() => {
|
|
180
180
|
setIsSending(false);
|
|
181
181
|
setOpen(false);
|
|
182
|
+
setInvited([]);
|
|
182
183
|
})
|
|
183
184
|
.catch((error) => {
|
|
184
185
|
setOpen(false);
|
|
@@ -223,23 +224,23 @@ export default function GroupInviteButton(inProps) {
|
|
|
223
224
|
setList((prev) => [...prev, option]);
|
|
224
225
|
};
|
|
225
226
|
/**
|
|
226
|
-
* If
|
|
227
|
+
* If in group edit mode and logged-in user is not also the group manager, the component is hidden.
|
|
227
228
|
// */
|
|
228
|
-
if (!
|
|
229
|
+
if (group && !isGroupAdmin) {
|
|
229
230
|
return null;
|
|
230
231
|
}
|
|
231
232
|
/**
|
|
232
233
|
* Renders root object
|
|
233
234
|
*/
|
|
234
235
|
return (React.createElement(React.Fragment, null,
|
|
235
|
-
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose,
|
|
236
|
+
React.createElement(Root, Object.assign({ className: classNames(classes.root, className), onClick: handleClose, variant: scGroup ? 'contained' : 'outlined', color: scGroup ? 'secondary' : 'inherit', startIcon: React.createElement(Icon, { fontSize: "small" }, "add") }, rest),
|
|
236
237
|
React.createElement(FormattedMessage, { id: "ui.groupInviteButton", defaultMessage: "ui.groupInviteButton" })),
|
|
237
238
|
open && (React.createElement(DialogRoot, { DialogContentProps: { dividers: false }, open: true, className: classes.dialogRoot, title: React.createElement(React.Fragment, null,
|
|
238
239
|
React.createElement(IconButton, { onClick: handleClose },
|
|
239
240
|
React.createElement(Icon, { fontSize: "medium" }, "arrow_back")),
|
|
240
241
|
React.createElement(Typography, { className: classes.dialogTitle },
|
|
241
242
|
React.createElement(FormattedMessage, { id: "ui.groupInviteButton.dialog.title", defaultMessage: "ui.groupInviteButton.dialog.title" })),
|
|
242
|
-
React.createElement(LoadingButton, { size: "small", color: "secondary", variant: "contained", onClick: handleSendInvitations, loading: isSending },
|
|
243
|
+
React.createElement(LoadingButton, { size: "small", color: "secondary", variant: "contained", onClick: handleSendInvitations, loading: isSending, disabled: !invited.length },
|
|
243
244
|
React.createElement(FormattedMessage, { id: "ui.groupInviteButton.dialog.button.end", defaultMessage: "ui.groupInviteButton.dialog.button.end" }))) },
|
|
244
245
|
React.createElement(Box, { className: classes.dialogContent },
|
|
245
246
|
React.createElement(Autocomplete, { className: classes.autocomplete, loading: loading, size: "small", multiple: true, freeSolo: true, disableClearable: true, options: suggested, onChange: handleChange, onInputChange: handleInputChange, inputValue: value, value: invited, getOptionLabel: (option) => (option ? option.username : '...'), isOptionEqualToValue: (option, value) => (option ? value.id === option.id : false), renderTags: () => null, renderOption: (props, option) => (React.createElement(Box, Object.assign({ component: "li" }, props),
|
|
@@ -17,6 +17,11 @@ export interface GroupMembersButtonProps extends Pick<ButtonProps, Exclude<keyof
|
|
|
17
17
|
* @default {}
|
|
18
18
|
*/
|
|
19
19
|
DialogProps?: BaseDialogProps;
|
|
20
|
+
/**
|
|
21
|
+
* Hides this component
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
autoHide?: boolean;
|
|
20
25
|
/**
|
|
21
26
|
* Any other properties
|
|
22
27
|
*/
|