@selfcommunity/react-ui 0.8.0-alpha.3 → 0.8.0-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/BottomNavigation/BottomNavigation.js +11 -2
- package/lib/cjs/components/Composer/Composer.js +10 -2
- package/lib/cjs/components/Composer/Layer/AudienceLayer/AudienceLayer.js +12 -3
- package/lib/cjs/components/CreateEventButton/CreateEventButton.js +5 -1
- package/lib/cjs/components/CreateEventWidget/CreateEventWidget.js +5 -1
- package/lib/cjs/components/EventForm/EventForm.d.ts +1 -1
- package/lib/cjs/components/EventForm/EventForm.js +72 -54
- package/lib/cjs/components/EventForm/constants.d.ts +4 -0
- package/lib/cjs/components/EventForm/constants.js +5 -1
- package/lib/cjs/components/EventForm/types.d.ts +1 -2
- package/lib/cjs/components/EventForm/utils.d.ts +4 -0
- package/lib/cjs/components/EventForm/utils.js +28 -0
- package/lib/cjs/components/EventInfoWidget/EventInfoWidget.js +24 -1
- package/lib/cjs/components/Events/Events.js +17 -7
- package/lib/cjs/components/Events/LocationEventsFilter.d.ts +14 -0
- package/lib/cjs/components/Events/LocationEventsFilter.js +45 -0
- package/lib/cjs/components/Events/PastEventsFilter.js +1 -2
- package/lib/cjs/components/Feed/Feed.js +12 -3
- package/lib/cjs/components/GroupActionsMenu/index.d.ts +57 -0
- package/lib/cjs/components/GroupActionsMenu/index.js +157 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.d.ts +6 -0
- package/lib/cjs/components/GroupHeader/GroupHeader.js +8 -4
- package/lib/cjs/components/Groups/Groups.js +26 -0
- package/lib/cjs/components/MyEventsWidget/MyEventsWidget.js +6 -2
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +35 -0
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuDrawer.js +68 -0
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +9 -20
- package/lib/cjs/components/NavigationMenuIconButton/NavigationMenuIconButton.js +8 -27
- package/lib/cjs/components/NavigationMenuIconButton/index.d.ts +2 -1
- package/lib/cjs/components/NavigationMenuIconButton/index.js +3 -1
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.d.ts +5 -0
- package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +14 -5
- package/lib/cjs/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
- package/lib/cjs/components/Notification/Event/Event.js +4 -0
- package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.d.ts +10 -1
- package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +69 -26
- package/lib/cjs/components/OnBoardingWidget/Steps/Appearance/Appearance.js +8 -4
- package/lib/cjs/components/OnBoardingWidget/Steps/Invite/Invite.js +56 -12
- package/lib/cjs/components/PlatformWidget/constants.d.ts +0 -4
- package/lib/cjs/components/PlatformWidget/constants.js +1 -5
- package/lib/cjs/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +7 -2
- package/lib/cjs/constants/GroupActionsMenu.d.ts +5 -0
- package/lib/cjs/constants/GroupActionsMenu.js +8 -0
- package/lib/cjs/constants/PubSub.d.ts +16 -1
- package/lib/cjs/constants/PubSub.js +11 -1
- package/lib/cjs/index.d.ts +4 -2
- package/lib/cjs/index.js +12 -5
- package/lib/cjs/shared/ContributionActionsMenu/index.js +6 -6
- package/lib/cjs/shared/InfiniteScroll/index.js +3 -3
- package/lib/cjs/shared/Media/Link/DisplayComponent.js +21 -5
- package/lib/cjs/utils/formatRelativeTime.js +2 -2
- package/lib/esm/components/BottomNavigation/BottomNavigation.js +11 -2
- package/lib/esm/components/Composer/Composer.js +10 -2
- package/lib/esm/components/Composer/Layer/AudienceLayer/AudienceLayer.js +13 -4
- package/lib/esm/components/CreateEventButton/CreateEventButton.js +5 -1
- package/lib/esm/components/CreateEventWidget/CreateEventWidget.js +5 -1
- package/lib/esm/components/EventForm/EventForm.d.ts +1 -1
- package/lib/esm/components/EventForm/EventForm.js +74 -56
- package/lib/esm/components/EventForm/constants.d.ts +4 -0
- package/lib/esm/components/EventForm/constants.js +4 -0
- package/lib/esm/components/EventForm/types.d.ts +1 -2
- package/lib/esm/components/EventForm/utils.d.ts +4 -0
- package/lib/esm/components/EventForm/utils.js +21 -0
- package/lib/esm/components/EventInfoWidget/EventInfoWidget.js +25 -2
- package/lib/esm/components/Events/Events.js +18 -8
- package/lib/esm/components/Events/LocationEventsFilter.d.ts +14 -0
- package/lib/esm/components/Events/LocationEventsFilter.js +41 -0
- package/lib/esm/components/Events/PastEventsFilter.js +1 -2
- package/lib/esm/components/Feed/Feed.js +14 -5
- package/lib/esm/components/GroupActionsMenu/index.d.ts +57 -0
- package/lib/esm/components/GroupActionsMenu/index.js +154 -0
- package/lib/esm/components/GroupHeader/GroupHeader.d.ts +6 -0
- package/lib/esm/components/GroupHeader/GroupHeader.js +9 -5
- package/lib/esm/components/Groups/Groups.js +27 -1
- package/lib/esm/components/MyEventsWidget/MyEventsWidget.js +7 -3
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.d.ts +35 -0
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuDrawer.js +65 -0
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.d.ts +9 -20
- package/lib/esm/components/NavigationMenuIconButton/NavigationMenuIconButton.js +11 -30
- package/lib/esm/components/NavigationMenuIconButton/index.d.ts +2 -1
- package/lib/esm/components/NavigationMenuIconButton/index.js +2 -1
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.d.ts +5 -0
- package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +14 -5
- package/lib/esm/components/NavigationToolbarMobile/NavigationToolbarMobile.js +11 -2
- package/lib/esm/components/Notification/Event/Event.js +4 -0
- package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.d.ts +10 -1
- package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +71 -28
- package/lib/esm/components/OnBoardingWidget/Steps/Appearance/Appearance.js +9 -5
- package/lib/esm/components/OnBoardingWidget/Steps/Invite/Invite.js +59 -14
- package/lib/esm/components/PlatformWidget/constants.d.ts +0 -4
- package/lib/esm/components/PlatformWidget/constants.js +0 -4
- package/lib/esm/components/UserSubscribedGroupsWidget/UserSubscribedGroupsWidget.js +8 -3
- package/lib/esm/constants/GroupActionsMenu.d.ts +5 -0
- package/lib/esm/constants/GroupActionsMenu.js +5 -0
- package/lib/esm/constants/PubSub.d.ts +16 -1
- package/lib/esm/constants/PubSub.js +10 -0
- package/lib/esm/index.d.ts +4 -2
- package/lib/esm/index.js +5 -3
- package/lib/esm/shared/ContributionActionsMenu/index.js +6 -6
- package/lib/esm/shared/InfiniteScroll/index.js +3 -3
- package/lib/esm/shared/Media/Link/DisplayComponent.js +21 -5
- package/lib/esm/utils/formatRelativeTime.js +2 -2
- package/lib/umd/148.js +2 -0
- package/lib/umd/react-ui.js +1 -1
- package/package.json +7 -7
- package/lib/umd/99.js +0 -2
- /package/lib/umd/{99.js.LICENSE.txt → 148.js.LICENSE.txt} +0 -0
|
@@ -1,33 +1,23 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import { useCallback
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
|
-
import {
|
|
5
|
+
import { Icon, IconButton } from '@mui/material';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
import { useThemeProps } from '@mui/system';
|
|
8
|
-
import ScrollContainer from '../../shared/ScrollContainer';
|
|
9
|
-
import DefaultDrawerContent from './DefaultDrawerContent';
|
|
10
|
-
import DefaultHeaderContent from './DefaultHeaderContent';
|
|
11
8
|
import { SCPreferences, useSCPreferences, useSCUser } from '@selfcommunity/react-core';
|
|
9
|
+
import NavigationMenuDrawer from './NavigationMenuDrawer';
|
|
10
|
+
import PubSub from 'pubsub-js';
|
|
11
|
+
import { SCLayoutEventType, SCTopicType } from '../../constants/PubSub';
|
|
12
12
|
const PREFIX = 'SCNavigationMenuIconButton';
|
|
13
13
|
const classes = {
|
|
14
|
-
root: `${PREFIX}-root
|
|
15
|
-
logo: `${PREFIX}-logo`,
|
|
16
|
-
drawerRoot: `${PREFIX}-drawer-root`,
|
|
17
|
-
drawerHeader: `${PREFIX}-drawer-header`,
|
|
18
|
-
drawerHeaderAction: `${PREFIX}-drawer-header-action`,
|
|
19
|
-
drawerContent: `${PREFIX}-drawer-content`
|
|
14
|
+
root: `${PREFIX}-root`
|
|
20
15
|
};
|
|
21
16
|
const Root = styled(IconButton, {
|
|
22
17
|
name: PREFIX,
|
|
23
18
|
slot: 'Root',
|
|
24
19
|
overridesResolver: (props, styles) => styles.root
|
|
25
20
|
})(({ theme }) => ({}));
|
|
26
|
-
const DrawerRoot = styled(Drawer, {
|
|
27
|
-
name: PREFIX,
|
|
28
|
-
slot: 'Root',
|
|
29
|
-
overridesResolver: (props, styles) => styles.drawerRoot
|
|
30
|
-
})(({ theme }) => ({}));
|
|
31
21
|
/**
|
|
32
22
|
* > API documentation for the Community-JS Navigation Menu Icon Button component. Learn about the available props and the CSS API.
|
|
33
23
|
|
|
@@ -47,10 +37,6 @@ const DrawerRoot = styled(Drawer, {
|
|
|
47
37
|
|Rule Name|Global class|Description|
|
|
48
38
|
|---|---|---|
|
|
49
39
|
|root|.SCNavigationMenuIconButton-root|Styles applied to the root element.|
|
|
50
|
-
|drawerRoot|.SCNavigationMenuIconButton-drawer-root|Styles applied to the drawer root element.|
|
|
51
|
-
|drawerHeader|.SCNavigationMenuIconButton-drawer-header|Styles applied to the drawer header.|
|
|
52
|
-
|drawerHeaderAction|.SCNavigationMenuIconButton-drawer-header-action|Styles applied to the drawer header action element.|
|
|
53
|
-
|drawerContent|.SCNavigationMenuIconButton-drawer-content|Styles applied to the drawer content.|
|
|
54
40
|
|
|
55
41
|
* @param inProps
|
|
56
42
|
*/
|
|
@@ -61,21 +47,16 @@ export default function NavigationMenuIconButton(inProps) {
|
|
|
61
47
|
props: inProps,
|
|
62
48
|
name: PREFIX
|
|
63
49
|
});
|
|
64
|
-
const { className = null, DrawerProps = {
|
|
65
|
-
// STATE
|
|
66
|
-
const [anchorEl, setAnchorEl] = useState(null);
|
|
50
|
+
const { className = null, DrawerProps = {}, onMenuIconClick = null, showDrawer = true } = props, rest = __rest(props, ["className", "DrawerProps", "onMenuIconClick", "showDrawer"]);
|
|
67
51
|
// CONTEXT
|
|
68
52
|
const { preferences } = useSCPreferences();
|
|
69
53
|
const scUserContext = useSCUser();
|
|
70
54
|
// HANDLERS
|
|
71
|
-
const handleOpen = useCallback((
|
|
72
|
-
|
|
73
|
-
}, []);
|
|
74
|
-
const handleClose = useCallback(() => {
|
|
75
|
-
setAnchorEl(null);
|
|
55
|
+
const handleOpen = useCallback(() => {
|
|
56
|
+
PubSub.publish(`${SCTopicType.LAYOUT}.${SCLayoutEventType.TOGGLE_DRAWER}`);
|
|
76
57
|
}, []);
|
|
77
58
|
if (!preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value && !((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
78
59
|
return null;
|
|
79
60
|
}
|
|
80
|
-
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { onClick:
|
|
61
|
+
return (_jsxs(_Fragment, { children: [_jsx(Root, Object.assign({ className: classNames(classes.root, className) }, rest, { onClick: onMenuIconClick !== null && onMenuIconClick !== void 0 ? onMenuIconClick : handleOpen }, { children: _jsx(Icon, { children: "menu" }) })), showDrawer && _jsx(NavigationMenuDrawer, Object.assign({}, DrawerProps))] }));
|
|
81
62
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import NavigationMenuIconButton, { NavigationMenuIconButtonProps } from './NavigationMenuIconButton';
|
|
2
2
|
import DefaultHeaderContent from './DefaultHeaderContent';
|
|
3
3
|
import DefaultDrawerContent from './DefaultDrawerContent';
|
|
4
|
+
import NavigationMenuDrawer, { NavigationMenuDrawerProps } from './NavigationMenuDrawer';
|
|
4
5
|
export default NavigationMenuIconButton;
|
|
5
|
-
export { NavigationMenuIconButtonProps, DefaultDrawerContent as NavigationMenuContent, DefaultHeaderContent as NavigationMenuHeader };
|
|
6
|
+
export { NavigationMenuIconButtonProps, DefaultDrawerContent as NavigationMenuContent, DefaultHeaderContent as NavigationMenuHeader, NavigationMenuDrawer, NavigationMenuDrawerProps };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import NavigationMenuIconButton from './NavigationMenuIconButton';
|
|
2
2
|
import DefaultHeaderContent from './DefaultHeaderContent';
|
|
3
3
|
import DefaultDrawerContent from './DefaultDrawerContent';
|
|
4
|
+
import NavigationMenuDrawer from './NavigationMenuDrawer';
|
|
4
5
|
export default NavigationMenuIconButton;
|
|
5
|
-
export { DefaultDrawerContent as NavigationMenuContent, DefaultHeaderContent as NavigationMenuHeader };
|
|
6
|
+
export { DefaultDrawerContent as NavigationMenuContent, DefaultHeaderContent as NavigationMenuHeader, NavigationMenuDrawer };
|
|
@@ -34,6 +34,11 @@ export interface NavigationToolbarProps extends ToolbarProps {
|
|
|
34
34
|
* Component for Navigation Menu Icon Button
|
|
35
35
|
*/
|
|
36
36
|
NavigationMenuIconButtonComponent?: (inProps: NavigationMenuIconButtonProps) => JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* Props to spread to the NavigationMenuIconButtonComponent
|
|
39
|
+
* @default {}
|
|
40
|
+
*/
|
|
41
|
+
NavigationMenuIconButtonComponentProps?: NavigationMenuIconButtonProps;
|
|
37
42
|
/**
|
|
38
43
|
* Component for Navigation Settings
|
|
39
44
|
*/
|
|
@@ -96,7 +96,7 @@ export default function NavigationToolbar(inProps) {
|
|
|
96
96
|
props: inProps,
|
|
97
97
|
name: PREFIX
|
|
98
98
|
});
|
|
99
|
-
const { value = '', className = '', disableSearch = false, disableComposer = false, SearchAutocompleteProps = {}, startActions = null, endActions = null, NavigationSettingsIconButtonComponent = NavigationSettingsIconButton, NavigationMenuIconButtonComponent = NavigationMenuIconButton, children = null, NotificationMenuProps = {}, ComposerIconButtonProps = {}, onOpenNotificationMenu, onCloseNotificationMenu } = props, rest = __rest(props, ["value", "className", "disableSearch", "disableComposer", "SearchAutocompleteProps", "startActions", "endActions", "NavigationSettingsIconButtonComponent", "NavigationMenuIconButtonComponent", "children", "NotificationMenuProps", "ComposerIconButtonProps", "onOpenNotificationMenu", "onCloseNotificationMenu"]);
|
|
99
|
+
const { value = '', className = '', disableSearch = false, disableComposer = false, SearchAutocompleteProps = {}, startActions = null, endActions = null, NavigationSettingsIconButtonComponent = NavigationSettingsIconButton, NavigationMenuIconButtonComponentProps = {}, NavigationMenuIconButtonComponent = NavigationMenuIconButton, children = null, NotificationMenuProps = {}, ComposerIconButtonProps = {}, onOpenNotificationMenu, onCloseNotificationMenu } = props, rest = __rest(props, ["value", "className", "disableSearch", "disableComposer", "SearchAutocompleteProps", "startActions", "endActions", "NavigationSettingsIconButtonComponent", "NavigationMenuIconButtonComponentProps", "NavigationMenuIconButtonComponent", "children", "NotificationMenuProps", "ComposerIconButtonProps", "onOpenNotificationMenu", "onCloseNotificationMenu"]);
|
|
100
100
|
// CONTEXT
|
|
101
101
|
const scUserContext = useSCUser();
|
|
102
102
|
const scRoutingContext = useSCRouting();
|
|
@@ -108,12 +108,21 @@ export default function NavigationToolbar(inProps) {
|
|
|
108
108
|
return _preferences;
|
|
109
109
|
}, [scPreferences.preferences]);
|
|
110
110
|
const privateMessagingEnabled = useMemo(() => scPreferences.features.includes(SCFeatureName.PRIVATE_MESSAGING), [scPreferences.features]);
|
|
111
|
-
const groupsEnabled = useMemo(() => scPreferences.
|
|
112
|
-
|
|
111
|
+
const groupsEnabled = useMemo(() => scPreferences.preferences &&
|
|
112
|
+
scPreferences.features &&
|
|
113
|
+
scPreferences.features.includes(SCFeatureName.TAGGING) &&
|
|
114
|
+
scPreferences.features.includes(SCFeatureName.GROUPING) &&
|
|
115
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in scPreferences.preferences &&
|
|
116
|
+
scPreferences.preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
|
|
117
|
+
const eventsEnabled = useMemo(() => scPreferences.preferences &&
|
|
118
|
+
scPreferences.features &&
|
|
119
|
+
scPreferences.features.includes(SCFeatureName.TAGGING) &&
|
|
120
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in scPreferences.preferences &&
|
|
121
|
+
scPreferences.preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [scPreferences.preferences, scPreferences.features]);
|
|
113
122
|
const showComposer = useMemo(() => {
|
|
114
123
|
return (!disableComposer &&
|
|
115
124
|
(!scPreferences.preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value || UserUtils.isStaff(scUserContext.user)));
|
|
116
|
-
}, [
|
|
125
|
+
}, [preferences, disableComposer, scUserContext.user]);
|
|
117
126
|
// STATE
|
|
118
127
|
const [anchorNotification, setAnchorNotification] = React.useState(null);
|
|
119
128
|
// HANDLERS
|
|
@@ -136,7 +145,7 @@ export default function NavigationToolbar(inProps) {
|
|
|
136
145
|
}), "aria-label": "Groups", to: scRoutingContext.url(SCRoutes.GROUPS_SUBSCRIBED_ROUTE_NAME, {}), component: Link }, { children: _jsx(Icon, { children: "groups" }) }))), eventsEnabled && (_jsx(IconButton, Object.assign({ className: classNames(classes.events, {
|
|
137
146
|
[classes.active]: value.startsWith(scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, {}))
|
|
138
147
|
}), "aria-label": "Groups", to: scRoutingContext.url(SCRoutes.EVENTS_ROUTE_NAME, {}), component: Link }, { children: _jsx(Icon, { children: "CalendarIcon" }) })))] })));
|
|
139
|
-
return (_jsxs(Root, Object.assign({ className: classNames(className, classes.root) }, rest, { children: [_jsx(NavigationMenuIconButtonComponent, {}), _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo }, { children: _jsx("img", { src: preferences[SCPreferences.LOGO_NAVBAR_LOGO], alt: "logo" }) })), !scUserContext.user && !preferences[SCPreferences.ADDONS_CLOSED_COMMUNITY] && (_jsx(Button, Object.assign({ color: "inherit", component: Link, to: scRoutingContext.url(SCRoutes.SIGNUP_ROUTE_NAME, {}), className: classes.register }, { children: _jsx(FormattedMessage, { id: "ui.appBar.navigation.register", defaultMessage: "ui.appBar.navigation.register" }) }))), preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED] && (_jsx(_Fragment, { children: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] ? (_jsx(Tooltip, Object.assign({ title: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] }, { children: _jsx(Link, Object.assign({ target: "blank", to: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: _jsx("img", { src: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) })) }))) : (_jsx(Link, Object.assign({ target: "blank", to: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: _jsx("img", { src: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) }))) })), _children, (preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY] || scUserContext.user) && !disableSearch ? (_jsx(SearchAutocomplete, Object.assign({ className: classes.search, blurOnSelect: true }, SearchAutocompleteProps))) : (_jsx(Box, { className: classes.search })), startActions, scUserContext.user ? (_jsxs(_Fragment, { children: [showComposer && _jsx(ComposerIconButton, Object.assign({ className: classes.composer }, ComposerIconButtonProps)), _jsx(Tooltip, Object.assign({ title: scUserContext.user.username }, { children: _jsx(IconButton, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scUserContext.user), "aria-label": "Profile", className: classes.profile }, { children: _jsx(Avatar, { alt: scUserContext.user.username, src: scUserContext.user.avatar }) })) })), _jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ className: classNames(classes.notification, {
|
|
148
|
+
return (_jsxs(Root, Object.assign({ className: classNames(className, classes.root) }, rest, { children: [_jsx(NavigationMenuIconButtonComponent, Object.assign({}, NavigationMenuIconButtonComponentProps)), _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.HOME_ROUTE_NAME, {}), className: classes.logo }, { children: _jsx("img", { src: preferences[SCPreferences.LOGO_NAVBAR_LOGO], alt: "logo" }) })), !scUserContext.user && !preferences[SCPreferences.ADDONS_CLOSED_COMMUNITY] && (_jsx(Button, Object.assign({ color: "inherit", component: Link, to: scRoutingContext.url(SCRoutes.SIGNUP_ROUTE_NAME, {}), className: classes.register }, { children: _jsx(FormattedMessage, { id: "ui.appBar.navigation.register", defaultMessage: "ui.appBar.navigation.register" }) }))), preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_ENABLED] && (_jsx(_Fragment, { children: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] ? (_jsx(Tooltip, Object.assign({ title: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_TEXT] }, { children: _jsx(Link, Object.assign({ target: "blank", to: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: _jsx("img", { src: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) })) }))) : (_jsx(Link, Object.assign({ target: "blank", to: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_URL], className: classes.customItem }, { children: _jsx("img", { src: preferences[SCPreferences.CONFIGURATIONS_CUSTOM_NAVBAR_ITEM_IMAGE], alt: "custom_item" }) }))) })), _children, (preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY] || scUserContext.user) && !disableSearch ? (_jsx(SearchAutocomplete, Object.assign({ className: classes.search, blurOnSelect: true }, SearchAutocompleteProps))) : (_jsx(Box, { className: classes.search })), startActions, scUserContext.user ? (_jsxs(_Fragment, { children: [showComposer && _jsx(ComposerIconButton, Object.assign({ className: classes.composer }, ComposerIconButtonProps)), _jsx(Tooltip, Object.assign({ title: scUserContext.user.username }, { children: _jsx(IconButton, Object.assign({ component: Link, to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, scUserContext.user), "aria-label": "Profile", className: classes.profile }, { children: _jsx(Avatar, { alt: scUserContext.user.username, src: scUserContext.user.avatar }) })) })), _jsxs(_Fragment, { children: [_jsx(IconButton, Object.assign({ className: classNames(classes.notification, {
|
|
140
149
|
[classes.active]: value.startsWith(scRoutingContext.url(SCRoutes.USER_NOTIFICATIONS_ROUTE_NAME, {}))
|
|
141
150
|
}), "aria-label": "Notification", onClick: handleOpenNotificationMenu }, { children: _jsx(Badge, Object.assign({ badgeContent: scUserContext.user.unseen_notification_banners_counter + scUserContext.user.unseen_interactions_counter, color: "secondary" }, { children: _jsx(Icon, { children: "notifications_active" }) })) })), _jsx(NotificationMenu, Object.assign({ className: classes.notificationsMenu, id: "notification-menu", anchorEl: anchorNotification, open: Boolean(anchorNotification), onClose: handleCloseNotificationMenu, onClick: handleCloseNotificationMenu, transformOrigin: { horizontal: 'right', vertical: 'top' }, anchorOrigin: { horizontal: 'right', vertical: 'bottom' } }, NotificationMenuProps))] }), privateMessagingEnabled && (_jsx(IconButton, Object.assign({ className: classNames(classes.messages, {
|
|
142
151
|
[classes.active]: value.startsWith(scRoutingContext.url(SCRoutes.USER_PRIVATE_MESSAGES_ROUTE_NAME, {}))
|
|
@@ -78,8 +78,17 @@ export default function NavigationToolbarMobile(inProps) {
|
|
|
78
78
|
// STATE
|
|
79
79
|
const [searchOpen, setSearchOpen] = useState(false);
|
|
80
80
|
// MEMO
|
|
81
|
-
const groupsEnabled = useMemo(() =>
|
|
82
|
-
|
|
81
|
+
const groupsEnabled = useMemo(() => preferences &&
|
|
82
|
+
features &&
|
|
83
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
84
|
+
features.includes(SCFeatureName.GROUPING) &&
|
|
85
|
+
SCPreferences.CONFIGURATIONS_GROUPS_ENABLED in preferences &&
|
|
86
|
+
preferences[SCPreferences.CONFIGURATIONS_GROUPS_ENABLED].value, [preferences, features]);
|
|
87
|
+
const eventsEnabled = useMemo(() => preferences &&
|
|
88
|
+
features &&
|
|
89
|
+
features.includes(SCFeatureName.TAGGING) &&
|
|
90
|
+
SCPreferences.CONFIGURATIONS_EVENTS_ENABLED in preferences &&
|
|
91
|
+
preferences[SCPreferences.CONFIGURATIONS_EVENTS_ENABLED].value, [preferences, features]);
|
|
83
92
|
const exploreStreamEnabled = preferences[SCPreferences.CONFIGURATIONS_EXPLORE_STREAM_ENABLED].value;
|
|
84
93
|
const postOnlyStaffEnabled = preferences[SCPreferences.CONFIGURATIONS_POST_ONLY_STAFF_ENABLED].value;
|
|
85
94
|
const contentAvailable = preferences[SCPreferences.CONFIGURATIONS_CONTENT_AVAILABILITY].value;
|
|
@@ -51,6 +51,8 @@ export default function EventNotification(props) {
|
|
|
51
51
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar, classes: { root: classes.avatar } }) })) })), primary: _jsxs(Box, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
52
52
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
53
53
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.event.${notificationObject.type}`, defaultMessage: `ui.notification.event.${notificationObject.type}`, values: {
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
55
|
+
// @ts-ignore
|
|
54
56
|
icon: (...chunks) => _jsx(Icon, { children: chunks }),
|
|
55
57
|
event: notificationObject.event.name,
|
|
56
58
|
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|
|
@@ -69,6 +71,8 @@ export default function EventNotification(props) {
|
|
|
69
71
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null }, { children: _jsx(UserAvatar, Object.assign({ hide: !notificationObject.user.community_badge, smaller: true }, { children: _jsx(Avatar, { className: classes.avatar, alt: notificationObject.user.username, variant: "circular", src: notificationObject.user.avatar }) })) })), primary: _jsxs(_Fragment, { children: [_jsx(Link, Object.assign({}, (!notificationObject.user.deleted && {
|
|
70
72
|
to: scRoutingContext.url(SCRoutes.USER_PROFILE_ROUTE_NAME, notificationObject.user)
|
|
71
73
|
}), { onClick: notificationObject.user.deleted ? () => setOpenAlert(true) : null, className: classes.username }, { children: notificationObject.user.username })), ' ', _jsx(FormattedMessage, { id: `ui.notification.${notificationObject.type}`, defaultMessage: `ui.notification.${notificationObject.type}`, values: {
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
75
|
+
// @ts-ignore
|
|
72
76
|
icon: (...chunks) => _jsx(Icon, { children: chunks }),
|
|
73
77
|
event: notificationObject.event.name,
|
|
74
78
|
link: (...chunks) => _jsx(Link, Object.assign({ to: scRoutingContext.url(SCRoutes.EVENT_ROUTE_NAME, notificationObject.event) }, { children: chunks }))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StartStepParams } from '@selfcommunity/api-services';
|
|
2
|
-
import { SCFeedObjectType } from '@selfcommunity/types';
|
|
2
|
+
import { SCFeedObjectType, SCOnBoardingStepType } from '@selfcommunity/types';
|
|
3
3
|
import { VirtualScrollerItemProps } from '../../types/virtualScroller';
|
|
4
4
|
export interface OnBoardingWidgetProps extends VirtualScrollerItemProps {
|
|
5
5
|
/**
|
|
@@ -18,6 +18,15 @@ export interface OnBoardingWidgetProps extends VirtualScrollerItemProps {
|
|
|
18
18
|
* @default null
|
|
19
19
|
*/
|
|
20
20
|
onGeneratedContent?: (feedObjs: SCFeedObjectType[]) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Force widget expanded
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
forceExpanded?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The initial step to display
|
|
28
|
+
*/
|
|
29
|
+
initialStep?: SCOnBoardingStepType;
|
|
21
30
|
}
|
|
22
31
|
declare const OnBoardingWidget: (inProps: OnBoardingWidgetProps) => JSX.Element;
|
|
23
32
|
export default OnBoardingWidget;
|
|
@@ -8,7 +8,7 @@ import classNames from 'classnames';
|
|
|
8
8
|
import { useThemeProps } from '@mui/system';
|
|
9
9
|
import Category from './Steps/Category';
|
|
10
10
|
import { PREFIX } from './constants';
|
|
11
|
-
import { getTheme, usePreviousValue, UserUtils, useSCContext, useSCPreferences, useSCTheme, useSCUser } from '@selfcommunity/react-core';
|
|
11
|
+
import { getTheme, usePreviousValue, UserUtils, useSCContext, useSCFetchCategories, useSCPreferences, useSCTheme, useSCUser } from '@selfcommunity/react-core';
|
|
12
12
|
import Appearance from './Steps/Appearance';
|
|
13
13
|
import Profile from './Steps/Profile';
|
|
14
14
|
import Invite from './Steps/Invite';
|
|
@@ -17,13 +17,13 @@ import HiddenPlaceholder from '../../shared/HiddenPlaceholder';
|
|
|
17
17
|
import Widget from '../Widget';
|
|
18
18
|
import Content from './Steps/Content';
|
|
19
19
|
import { SCOPE_SC_UI } from '../../constants/Errors';
|
|
20
|
-
import { OnBoardingService, PreferenceService } from '@selfcommunity/api-services';
|
|
20
|
+
import { Endpoints, http, OnBoardingService, PreferenceService } from '@selfcommunity/api-services';
|
|
21
21
|
import { Logger } from '@selfcommunity/utils';
|
|
22
22
|
import { SCOnBoardingStepStatusType, SCOnBoardingStepType } from '@selfcommunity/types';
|
|
23
23
|
import OnBoardingWidgetSkeleton from './Skeleton';
|
|
24
24
|
import { closeSnackbar, useSnackbar } from 'notistack';
|
|
25
|
-
import { CONSOLE_PROD, CONSOLE_STAGE } from '../PlatformWidget/constants';
|
|
26
25
|
import HeaderPlaceholder from '../../assets/onBoarding/header';
|
|
26
|
+
import BaseDialog from '../../shared/BaseDialog';
|
|
27
27
|
const classes = {
|
|
28
28
|
root: `${PREFIX}-root`,
|
|
29
29
|
content: `${PREFIX}-content`,
|
|
@@ -50,24 +50,25 @@ const OnBoardingWidget = (inProps) => {
|
|
|
50
50
|
props: inProps,
|
|
51
51
|
name: PREFIX
|
|
52
52
|
});
|
|
53
|
-
const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange } = props, rest = __rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange"]);
|
|
53
|
+
const { className, GenerateContentsParams = {}, onGeneratedContent = null, onHeightChange, onStateChange, forceExpanded = false, initialStep } = props, rest = __rest(props, ["className", "GenerateContentsParams", "onGeneratedContent", "onHeightChange", "onStateChange", "forceExpanded", "initialStep"]);
|
|
54
54
|
// STATE
|
|
55
|
-
const [
|
|
55
|
+
const [loading, setLoading] = useState(true);
|
|
56
56
|
const [initialized, setInitialized] = useState(false);
|
|
57
57
|
const [steps, setSteps] = useState([]);
|
|
58
58
|
const nextStep = useMemo(() => {
|
|
59
|
-
const step = steps === null || steps === void 0 ? void 0 : steps.find((step) => step.status === 'in_progress' || step.status === 'not_started');
|
|
59
|
+
const step = steps === null || steps === void 0 ? void 0 : steps.find((step) => (initialStep ? step.step === initialStep : step.status === 'in_progress' || step.status === 'not_started'));
|
|
60
60
|
return step || (steps === null || steps === void 0 ? void 0 : steps[0]);
|
|
61
61
|
}, [steps]);
|
|
62
62
|
const allStepsDone = useMemo(() => {
|
|
63
63
|
return steps === null || steps === void 0 ? void 0 : steps.every((step) => step.status === SCOnBoardingStepStatusType.COMPLETED);
|
|
64
64
|
}, [steps]);
|
|
65
|
-
const [expanded, setExpanded] = useState(!allStepsDone);
|
|
65
|
+
const [expanded, setExpanded] = useState(!allStepsDone || forceExpanded);
|
|
66
66
|
const [_step, setStep] = useState(nextStep);
|
|
67
67
|
const currentContentsStep = steps === null || steps === void 0 ? void 0 : steps.find((s) => s.step === SCOnBoardingStepType.CONTENTS);
|
|
68
68
|
const prevContentsStep = usePreviousValue(currentContentsStep);
|
|
69
69
|
const currentCategoriesStep = steps === null || steps === void 0 ? void 0 : steps.find((s) => s.step === SCOnBoardingStepType.CATEGORIES);
|
|
70
70
|
const prevCategoriesStep = usePreviousValue(currentCategoriesStep);
|
|
71
|
+
const [showCategoriesModal, setShowCategoriesModal] = useState(false);
|
|
71
72
|
// CONTEXT
|
|
72
73
|
const scUserContext = useSCUser();
|
|
73
74
|
const isAdmin = useMemo(() => UserUtils.isCommunityCreator(scUserContext.user), [scUserContext.user]);
|
|
@@ -75,12 +76,21 @@ const OnBoardingWidget = (inProps) => {
|
|
|
75
76
|
const scPreferencesContext = useSCPreferences();
|
|
76
77
|
const scThemeContext = useSCTheme();
|
|
77
78
|
const { enqueueSnackbar } = useSnackbar();
|
|
78
|
-
const isStage = scContext.settings.portal.includes('stage');
|
|
79
79
|
const [isGenerating, setIsGenerating] = useState(false);
|
|
80
80
|
// HOOKS
|
|
81
81
|
const theme = useTheme();
|
|
82
82
|
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
83
|
+
const { categories, isLoading } = useSCFetchCategories();
|
|
83
84
|
// HANDLERS
|
|
85
|
+
/**
|
|
86
|
+
* Notify changes to Feed if the Widget is contained
|
|
87
|
+
*/
|
|
88
|
+
const notifyLayoutChanges = useMemo(() => (state) => {
|
|
89
|
+
if (onStateChange && state) {
|
|
90
|
+
onStateChange(state);
|
|
91
|
+
}
|
|
92
|
+
onHeightChange && onHeightChange();
|
|
93
|
+
}, [onStateChange, onHeightChange]);
|
|
84
94
|
const completeStep = (s) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
95
|
if (s.status !== SCOnBoardingStepStatusType.COMPLETED) {
|
|
86
96
|
yield OnBoardingService.completeAStep(s.id)
|
|
@@ -98,10 +108,30 @@ const OnBoardingWidget = (inProps) => {
|
|
|
98
108
|
}
|
|
99
109
|
s.step === SCOnBoardingStepType.APPEARANCE && handlePreferencesUpdate();
|
|
100
110
|
});
|
|
111
|
+
/**
|
|
112
|
+
* Fetches platform url
|
|
113
|
+
*/
|
|
114
|
+
function fetchPlatform(query) {
|
|
115
|
+
http
|
|
116
|
+
.request({
|
|
117
|
+
url: Endpoints.Platform.url(),
|
|
118
|
+
method: Endpoints.Platform.method,
|
|
119
|
+
params: {
|
|
120
|
+
next: query
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
.then((res) => {
|
|
124
|
+
const platformUrl = res.data.platform_url;
|
|
125
|
+
window.open(platformUrl, '_blank').focus();
|
|
126
|
+
})
|
|
127
|
+
.catch((error) => {
|
|
128
|
+
console.log(error);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
101
131
|
const showSuccessAlert = (step) => {
|
|
102
132
|
setIsGenerating(false);
|
|
103
133
|
enqueueSnackbar(_jsx(FormattedMessage, { id: `ui.onBoardingWidget.step.${step.step}.success`, defaultMessage: `ui.onBoardingWidget.step.${step.step}.success` }), {
|
|
104
|
-
action: (snackbarId) => (_jsxs(_Fragment, { children: [step.step === SCOnBoardingStepType.CATEGORIES && (_jsx(Button, Object.assign({ sx: { textTransform: 'uppercase', color: 'white' }, size: "small", variant: "text",
|
|
134
|
+
action: (snackbarId) => (_jsxs(_Fragment, { children: [step.step === SCOnBoardingStepType.CATEGORIES && (_jsx(Button, Object.assign({ sx: { textTransform: 'uppercase', color: 'white' }, size: "small", variant: "text", onClick: () => fetchPlatform('/contents/interests/') }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.categories.success.link", defaultMessage: "ui.onBoardingWidget.step.categories.success.link" }) }))), _jsx(IconButton, Object.assign({ sx: { color: 'white' }, onClick: () => closeSnackbar(snackbarId) }, { children: _jsx(Icon, { children: "close" }) }))] })),
|
|
105
135
|
variant: 'success',
|
|
106
136
|
autoHideDuration: 7000
|
|
107
137
|
});
|
|
@@ -112,35 +142,41 @@ const OnBoardingWidget = (inProps) => {
|
|
|
112
142
|
const contentStep = res.results.find((step) => step.step === SCOnBoardingStepType.CONTENTS);
|
|
113
143
|
setIsGenerating(res.results.some((step) => step.status === 'in_progress'));
|
|
114
144
|
setSteps(res.results);
|
|
115
|
-
|
|
145
|
+
setLoading(false);
|
|
116
146
|
if (contentStep.status === SCOnBoardingStepStatusType.IN_PROGRESS && contentStep.results.length !== 0 && onGeneratedContent) {
|
|
117
147
|
onGeneratedContent(contentStep.results);
|
|
118
148
|
}
|
|
119
149
|
})
|
|
120
150
|
.catch((error) => {
|
|
121
151
|
Logger.error(SCOPE_SC_UI, error);
|
|
122
|
-
|
|
152
|
+
setLoading(false);
|
|
123
153
|
});
|
|
124
154
|
});
|
|
125
155
|
const handleChange = (newStep) => {
|
|
126
156
|
setStep(newStep);
|
|
127
157
|
};
|
|
128
158
|
const handleExpand = () => {
|
|
129
|
-
|
|
130
|
-
|
|
159
|
+
const _expanded = !expanded;
|
|
160
|
+
setExpanded(_expanded);
|
|
161
|
+
notifyLayoutChanges({ forceExpanded: _expanded });
|
|
131
162
|
};
|
|
132
163
|
const generateContent = (stepId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
164
|
+
if (!isLoading && !categories.length) {
|
|
165
|
+
setShowCategoriesModal(true);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
yield OnBoardingService.startAStep(stepId, GenerateContentsParams)
|
|
169
|
+
.then(() => {
|
|
170
|
+
setIsGenerating(true);
|
|
171
|
+
})
|
|
172
|
+
.catch((error) => {
|
|
173
|
+
Logger.error(SCOPE_SC_UI, error);
|
|
174
|
+
enqueueSnackbar(_jsx(FormattedMessage, { id: "ui.common.error.action", defaultMessage: "ui.common.error.action" }), {
|
|
175
|
+
variant: 'error',
|
|
176
|
+
autoHideDuration: 3000
|
|
177
|
+
});
|
|
142
178
|
});
|
|
143
|
-
}
|
|
179
|
+
}
|
|
144
180
|
});
|
|
145
181
|
const handlePreferencesUpdate = () => {
|
|
146
182
|
PreferenceService.getAllPreferences().then((preferences) => {
|
|
@@ -149,10 +185,14 @@ const OnBoardingWidget = (inProps) => {
|
|
|
149
185
|
scThemeContext.setTheme(getTheme(scContext.settings.theme, prefs));
|
|
150
186
|
});
|
|
151
187
|
};
|
|
188
|
+
const handleCategoriesClick = () => {
|
|
189
|
+
fetchPlatform('/contents/interests/');
|
|
190
|
+
setShowCategoriesModal(false);
|
|
191
|
+
};
|
|
152
192
|
// EFFECTS
|
|
153
193
|
useEffect(() => {
|
|
154
194
|
if (prevContentsStep &&
|
|
155
|
-
|
|
195
|
+
prevContentsStep.status === SCOnBoardingStepStatusType.IN_PROGRESS &&
|
|
156
196
|
(currentContentsStep === null || currentContentsStep === void 0 ? void 0 : currentContentsStep.status) === SCOnBoardingStepStatusType.COMPLETED) {
|
|
157
197
|
showSuccessAlert(currentContentsStep);
|
|
158
198
|
}
|
|
@@ -168,11 +208,13 @@ const OnBoardingWidget = (inProps) => {
|
|
|
168
208
|
if (!initialized && nextStep) {
|
|
169
209
|
setStep(nextStep);
|
|
170
210
|
setInitialized(true);
|
|
211
|
+
notifyLayoutChanges({ forceExpanded: expanded });
|
|
171
212
|
}
|
|
172
213
|
}, [initialized, nextStep]);
|
|
173
214
|
useEffect(() => {
|
|
174
|
-
|
|
175
|
-
|
|
215
|
+
const _expanded = !allStepsDone;
|
|
216
|
+
setExpanded(_expanded);
|
|
217
|
+
notifyLayoutChanges({ forceExpanded: _expanded });
|
|
176
218
|
}, [allStepsDone]);
|
|
177
219
|
useEffect(() => {
|
|
178
220
|
if (isAdmin) {
|
|
@@ -232,7 +274,8 @@ const OnBoardingWidget = (inProps) => {
|
|
|
232
274
|
b: (chunks) => _jsx("strong", { children: chunks }),
|
|
233
275
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
234
276
|
// @ts-ignore
|
|
235
|
-
|
|
236
|
-
|
|
277
|
+
// eslint-disable-next-line prettier/prettier
|
|
278
|
+
icon: (...chunks) => _jsx(Icon, Object.assign({ color: "secondary", fontSize: "medium" }, { children: chunks }))
|
|
279
|
+
} }) }))) }) })), _jsx(AccordionDetails, { children: _jsx(Widget, Object.assign({ className: classes.content, elevation: 0 }, { children: loading ? (_jsx(OnBoardingWidgetSkeleton, {})) : (_jsxs(CardContent, { children: [_jsx(List, Object.assign({ className: isMobile ? classes.stepsMobile : classes.steps }, { children: steps === null || steps === void 0 ? void 0 : steps.map((step) => (_jsx(ListItem, { children: isMobile ? (_jsx(Chip, { size: "small", label: _jsxs(_Fragment, { children: [_jsx(FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }), ' ', step.status === SCOnBoardingStepStatusType.COMPLETED && (_jsx(Icon, Object.assign({ color: (step === null || step === void 0 ? void 0 : step.status) === SCOnBoardingStepStatusType.COMPLETED && (step === null || step === void 0 ? void 0 : step.step) !== (_step === null || _step === void 0 ? void 0 : _step.step) ? 'success' : 'inherit' }, { children: "check" })))] }), onClick: () => handleChange(step), variant: step.step === (_step === null || _step === void 0 ? void 0 : _step.step) ? 'filled' : 'outlined', color: step.status === SCOnBoardingStepStatusType.COMPLETED ? 'success' : 'default' })) : (_jsxs(ListItemButton, Object.assign({ onClick: () => handleChange(step), selected: (step === null || step === void 0 ? void 0 : step.step) === (_step === null || _step === void 0 ? void 0 : _step.step) }, { children: [_jsx(ListItemIcon, { children: _jsx(Checkbox, { edge: "start", checked: step.status === SCOnBoardingStepStatusType.COMPLETED, tabIndex: -1, disableRipple: true, inputProps: { 'aria-labelledby': step.step }, size: 'small' }) }), _jsx(ListItemText, { primary: _jsx(FormattedMessage, { id: `ui.onBoardingWidget.${step.step}`, defaultMessage: `ui.onBoardingWidget.${step.step}` }) })] }))) }, step.id))) })), _jsxs(Box, Object.assign({ className: classes.stepContent }, { children: [_jsx(Fade, Object.assign({ in: true, timeout: 2400 }, { children: _jsx(Box, { children: getStepContent() }) })), showCategoriesModal && (_jsx(BaseDialog, Object.assign({ title: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories", defaultMessage: "ui.onBoardingWidget.ai.no.categories" }), DialogContentProps: { dividers: false }, open: showCategoriesModal, onClose: () => setShowCategoriesModal(false), actions: _jsx(Button, Object.assign({ color: "secondary", onClick: () => setShowCategoriesModal(false) }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories.cancel", defaultMessage: "ui.onBoardingWidget.ai.no.categories.cancel" }) })) }, { children: _jsx(Button, Object.assign({ color: "primary", onClick: handleCategoriesClick, startIcon: _jsx(Icon, Object.assign({ fontSize: "small" }, { children: "edit" })) }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.ai.no.categories.link", defaultMessage: "ui.onBoardingWidget.ai.no.categories.link" }) })) })))] }))] })) })) })] })) })));
|
|
237
280
|
};
|
|
238
281
|
export default OnBoardingWidget;
|
|
@@ -7,7 +7,7 @@ import { useThemeProps } from '@mui/system';
|
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import { Preferences } from '@selfcommunity/react-core';
|
|
9
9
|
import { PREFIX } from '../../constants';
|
|
10
|
-
import { Button, Drawer, IconButton, Tab, Tabs, TextField, Typography } from '@mui/material';
|
|
10
|
+
import { Button, CircularProgress, Drawer, IconButton, Tab, Tabs, TextField, Typography } from '@mui/material';
|
|
11
11
|
import { MuiColorInput } from 'mui-color-input';
|
|
12
12
|
import { actionTypes } from './reducer';
|
|
13
13
|
import { getInitialState, reducer } from './reducer';
|
|
@@ -33,7 +33,9 @@ const classes = {
|
|
|
33
33
|
root: `${PREFIX}-appearance-root`,
|
|
34
34
|
title: `${PREFIX}-appearance-title`,
|
|
35
35
|
summary: `${PREFIX}-appearance-summary`,
|
|
36
|
+
colorContainer: `${PREFIX}-appearance-color-container`,
|
|
36
37
|
color: `${PREFIX}-appearance-color`,
|
|
38
|
+
colorProgress: `${PREFIX}-appearance-color-progress`,
|
|
37
39
|
logoContainer: `${PREFIX}-appearance-logo-container`,
|
|
38
40
|
logo: `${PREFIX}-appearance-logo`,
|
|
39
41
|
uploadButton: `${PREFIX}-appearance-upload-button`,
|
|
@@ -66,6 +68,7 @@ export default function Appearance(inProps) {
|
|
|
66
68
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
67
69
|
const [tab, setTab] = useState(0);
|
|
68
70
|
const [updating, setUpdating] = useState(false);
|
|
71
|
+
const [updatingColor, setUpdatingColor] = useState('');
|
|
69
72
|
// INTL
|
|
70
73
|
const intl = useIntl();
|
|
71
74
|
// HANDLERS
|
|
@@ -138,6 +141,7 @@ export default function Appearance(inProps) {
|
|
|
138
141
|
}
|
|
139
142
|
finally {
|
|
140
143
|
setUpdating(false);
|
|
144
|
+
setUpdatingColor('');
|
|
141
145
|
onCompleteAction();
|
|
142
146
|
}
|
|
143
147
|
});
|
|
@@ -193,15 +197,15 @@ export default function Appearance(inProps) {
|
|
|
193
197
|
}, []);
|
|
194
198
|
// HANDLERS
|
|
195
199
|
const handleColorChange = (color, name) => {
|
|
200
|
+
setUpdatingColor(name);
|
|
196
201
|
const currentColor = state.colors.find((col) => col.name === name);
|
|
197
202
|
if (currentColor && currentColor.value !== color) {
|
|
203
|
+
setUpdating(true);
|
|
198
204
|
dispatch({
|
|
199
205
|
type: actionTypes.SET_COLORS,
|
|
200
206
|
payload: { colors: state.colors.map((col) => (col.name === name ? Object.assign(Object.assign({}, col), { value: color }) : col)) }
|
|
201
207
|
});
|
|
202
|
-
|
|
203
|
-
updatePreference({ [`${name}`]: color });
|
|
204
|
-
}, 2000);
|
|
208
|
+
updatePreference({ [`${name}`]: color });
|
|
205
209
|
}
|
|
206
210
|
};
|
|
207
211
|
const handleChange = (event) => {
|
|
@@ -211,7 +215,7 @@ export default function Appearance(inProps) {
|
|
|
211
215
|
payload: { slogans: state.slogans.map((s) => (s.name === name ? Object.assign(Object.assign({}, s), { value: value }) : s)) }
|
|
212
216
|
});
|
|
213
217
|
};
|
|
214
|
-
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title, alignSelf: "self-start" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.appearance", defaultMessage: "ui.onBoardingWidget.appearance" }) })), _jsx(Typography, Object.assign({ className: classes.summary }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.summary", defaultMessage: "ui.onBoardingWidget.step.appearance.summary" }) })), _jsx(Button, Object.assign({ variant: "outlined", size: "small", color: "primary", onClick: handleOpen }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.button", defaultMessage: "ui.onBoardingWidget.step.appearance.button" }) })), _jsxs(DrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "right", open: Boolean(anchorEl), onClose: handleClose }, { children: [_jsxs(Box, Object.assign({ className: classes.drawerHeader }, { children: [_jsx(Typography, Object.assign({ variant: "h4", color: "primary" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.header.title", defaultMessage: "ui.onBoardingWidget.step.appearance.header.title" }) })), _jsx(IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: handleClose }, { children: _jsx(Icon, { children: "close" }) }))] })), _jsxs(Tabs, Object.assign({ value: tab, onChange: handleTabChange, variant: "scrollable", scrollButtons: "auto", "aria-label": "scrollable-tabs" }, { children: [_jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.colors.title", defaultMessage: "ui.onBoardingWidget.step.appearance.colors.title" }) }), _jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.logo.title", defaultMessage: "ui.onBoardingWidget.step.appearance.logo.title" }) }), _jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.titleSlogan.title", defaultMessage: "ui.onBoardingWidget.step.appearance.titleSlogan.title" }) })] })), _jsx(ScrollContainer, { children: _jsxs(Box, Object.assign({ className: classes.drawerContent }, { children: [tab === 0 && (_jsx(_Fragment, { children: state.colors.map((color) => (_jsxs(React.Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6" }, { children: formatColorLabel(color) })), _jsx(MuiColorInput, { className: classes.color, format: "hex", value: color.value, onChange: (newColor) => handleColorChange(newColor, color.name) })] }, color.id))) })), tab === 1 && (_jsx(_Fragment, { children: state.logos.map((logo) => (_jsxs(React.Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6" }, { children: formatLogoLabel(logo.name) })), _jsxs(Box, Object.assign({ className: classes.logoContainer }, { children: [_jsx("img", { src: logo.value, className: classes.logo }), _jsx("input", { type: "file", onChange: (event) => handleUpload(event, logo.name), ref: fileInput, hidden: true, accept: ".gif,.png,.jpg,.jpeg" }), _jsx(LoadingButton, Object.assign({ className: classes.uploadButton, onClick: () => fileInput.current.click(), loading: loadingLogo, disabled: loadingLogo }, { children: _jsx(Icon, { children: "upload" }) }))] }))] }, logo.id))) })), tab === 2 && (_jsxs(Box, { children: [_jsx(TextField, { multiline: true, fullWidth: true,
|
|
218
|
+
return (_jsxs(Root, Object.assign({ className: classNames(classes.root, className) }, { children: [_jsx(Typography, Object.assign({ variant: "h4", className: classes.title, alignSelf: "self-start" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.appearance", defaultMessage: "ui.onBoardingWidget.appearance" }) })), _jsx(Typography, Object.assign({ className: classes.summary }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.summary", defaultMessage: "ui.onBoardingWidget.step.appearance.summary" }) })), _jsx(Button, Object.assign({ variant: "outlined", size: "small", color: "primary", onClick: handleOpen }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.button", defaultMessage: "ui.onBoardingWidget.step.appearance.button" }) })), _jsxs(DrawerRoot, Object.assign({ className: classes.drawerRoot, anchor: "right", open: Boolean(anchorEl), onClose: handleClose }, { children: [_jsxs(Box, Object.assign({ className: classes.drawerHeader }, { children: [_jsx(Typography, Object.assign({ variant: "h4", color: "primary" }, { children: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.header.title", defaultMessage: "ui.onBoardingWidget.step.appearance.header.title" }) })), _jsx(IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: handleClose }, { children: _jsx(Icon, { children: "close" }) }))] })), _jsxs(Tabs, Object.assign({ value: tab, onChange: handleTabChange, variant: "scrollable", scrollButtons: "auto", "aria-label": "scrollable-tabs" }, { children: [_jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.colors.title", defaultMessage: "ui.onBoardingWidget.step.appearance.colors.title" }) }), _jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.logo.title", defaultMessage: "ui.onBoardingWidget.step.appearance.logo.title" }) }), _jsx(Tab, { label: _jsx(FormattedMessage, { id: "ui.onBoardingWidget.step.appearance.titleSlogan.title", defaultMessage: "ui.onBoardingWidget.step.appearance.titleSlogan.title" }) })] })), _jsx(ScrollContainer, { children: _jsxs(Box, Object.assign({ className: classes.drawerContent }, { children: [tab === 0 && (_jsx(_Fragment, { children: state.colors.map((color) => (_jsxs(React.Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6" }, { children: formatColorLabel(color) })), _jsxs(Box, Object.assign({ className: classes.colorContainer }, { children: [_jsx(MuiColorInput, { className: classes.color, format: "hex", value: color.value, onChange: (newColor) => handleColorChange(newColor, color.name) }), updatingColor && updatingColor === color.name && (_jsx(CircularProgress, { className: classes.colorProgress, color: "secondary", size: 24 }))] }))] }, color.id))) })), tab === 1 && (_jsx(_Fragment, { children: state.logos.map((logo) => (_jsxs(React.Fragment, { children: [_jsx(Typography, Object.assign({ variant: "h6" }, { children: formatLogoLabel(logo.name) })), _jsxs(Box, Object.assign({ className: classes.logoContainer }, { children: [_jsx("img", { src: logo.value, className: classes.logo }), _jsx("input", { type: "file", onChange: (event) => handleUpload(event, logo.name), ref: fileInput, hidden: true, accept: ".gif,.png,.jpg,.jpeg" }), _jsx(LoadingButton, Object.assign({ className: classes.uploadButton, onClick: () => fileInput.current.click(), loading: loadingLogo, disabled: loadingLogo }, { children: _jsx(Icon, { children: "upload" }) }))] }))] }, logo.id))) })), tab === 2 && (_jsxs(Box, { children: [_jsx(TextField, { multiline: true, fullWidth: true,
|
|
215
219
|
//className={classes.field}
|
|
216
220
|
label: `${intl.formatMessage(messages.titleField)}`, margin: "normal", value: (_a = state === null || state === void 0 ? void 0 : state.slogans[0]) === null || _a === void 0 ? void 0 : _a.value, name: "application_slogan1", onChange: handleChange, InputProps: {
|
|
217
221
|
endAdornment: _jsx(Typography, Object.assign({ variant: "body2" }, { children: ((_b = state.slogans[0].value) === null || _b === void 0 ? void 0 : _b.length) ? 50 - ((_c = state.slogans[0].value) === null || _c === void 0 ? void 0 : _c.length) : 50 }))
|