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