Web: People: Move from redux to mobx completely
This commit is contained in:
parent
4029233d32
commit
ca166e3c66
@ -26,14 +26,10 @@
|
||||
"react-device-detect": "^1.15.0",
|
||||
"react-dom": "^16.14.0",
|
||||
"react-i18next": "11.3.0",
|
||||
"react-redux": "7.1.3",
|
||||
"react-router": "5.1.2",
|
||||
"react-router-dom": "5.1.2",
|
||||
"react-virtualized-auto-sizer": "^1.0.3",
|
||||
"react-window": "^1.8.6",
|
||||
"redux": "4.0.5",
|
||||
"redux-thunk": "2.3.0",
|
||||
"reselect": "^4.0.0",
|
||||
"styled-components": "^5.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -42,7 +38,6 @@
|
||||
"prettier": "2.1.2",
|
||||
"react-app-rewired": "^2.1.8",
|
||||
"react-scripts": "4.0.1",
|
||||
"redux-devtools-extension": "^2.13.8",
|
||||
"rimraf": "3.0.2",
|
||||
"webpack-bundle-analyzer": "^3.9.0",
|
||||
"workbox-build": "^5.1.4"
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React, { Suspense, useEffect } from "react";
|
||||
// import { connect } from "react-redux";
|
||||
import { Router, Switch, Redirect } from "react-router-dom";
|
||||
import Home from "./components/pages/Home";
|
||||
import Profile from "./components/pages/Profile";
|
||||
@ -15,29 +14,13 @@ import {
|
||||
Error520,
|
||||
Offline,
|
||||
utils,
|
||||
// store as commonStore,
|
||||
NavMenu,
|
||||
Main,
|
||||
toastr,
|
||||
} from "asc-web-common";
|
||||
// import { getFilterByLocation } from "./helpers/converters";
|
||||
// import { fetchGroups, fetchPeople } from "./store/people/actions";
|
||||
import config from "../package.json";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
// const {
|
||||
// setIsLoaded,
|
||||
// getUser,
|
||||
// getPortalSettings,
|
||||
// getModules,
|
||||
// setCurrentProductId,
|
||||
// setCurrentProductHomePage,
|
||||
// getPortalPasswordSettings,
|
||||
// getPortalCultures,
|
||||
// getIsAuthenticated,
|
||||
// } = commonStore.auth.actions;
|
||||
// const { userStore, settingsStore } = commonStore;
|
||||
|
||||
// const Profile = lazy(() => import("./components/pages/Profile"));
|
||||
// const ProfileAction = lazy(() => import("./components/pages/ProfileAction"));
|
||||
// const GroupAction = lazy(() => import("./components/pages/GroupAction"));
|
||||
@ -51,7 +34,7 @@ const App = (props) => {
|
||||
} catch (err) {
|
||||
toastr.error(err);
|
||||
}
|
||||
}, []);
|
||||
}, [loadBaseInfo]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoaded) utils.updateTempContent();
|
||||
@ -115,162 +98,6 @@ const App = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
/*class App extends React.Component {
|
||||
async componentDidMount() {
|
||||
const {
|
||||
// setModuleInfo,
|
||||
// getUser,
|
||||
// getPortalSettings,
|
||||
//getModules,
|
||||
// getPortalPasswordSettings,
|
||||
// getPortalCultures,
|
||||
// fetchGroups,
|
||||
// fetchPeople,
|
||||
// setIsLoaded,
|
||||
// getIsAuthenticated,
|
||||
loadBaseInfo,
|
||||
isLoaded,
|
||||
// loadBasePeopleInfo,
|
||||
} = this.props;
|
||||
try {
|
||||
// const isAuthenticated = await getIsAuthenticated();
|
||||
|
||||
// if (isAuthenticated) utils.updateTempContent(isAuthenticated);
|
||||
|
||||
await loadBaseInfo();
|
||||
utils.updateTempContent();
|
||||
// setIsLoaded();
|
||||
} catch (e) {
|
||||
toastr.error(e);
|
||||
}
|
||||
|
||||
//setModuleInfo();
|
||||
// getIsAuthenticated().then((isAuthenticated) => {
|
||||
// if (!isAuthenticated) {
|
||||
// utils.updateTempContent();
|
||||
// return setIsLoaded();
|
||||
// } else {
|
||||
// utils.updateTempContent(isAuthenticated);
|
||||
// }
|
||||
|
||||
// const requests = [
|
||||
//getUser(),
|
||||
//getPortalSettings(),
|
||||
//getModules(),
|
||||
// getPortalPasswordSettings(),
|
||||
// getPortalCultures(),
|
||||
// fetchGroups(),
|
||||
// fetchPeople(),
|
||||
// ];
|
||||
|
||||
// Promise.all(requests)
|
||||
// .catch((e) => {
|
||||
// toastr.error(e);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// utils.updateTempContent();
|
||||
// setIsLoaded();
|
||||
// });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { homepage } = this.props;
|
||||
console.log("People App render", this.props);
|
||||
return navigator.onLine ? (
|
||||
<Router history={history}>
|
||||
<NavMenu />
|
||||
<Main>
|
||||
<Suspense fallback={null}>
|
||||
<Switch>
|
||||
<Redirect exact from="/" to={`${homepage}`} />
|
||||
<PrivateRoute
|
||||
exact
|
||||
path={`${homepage}/view/:userId`}
|
||||
component={Profile}
|
||||
/>
|
||||
<PrivateRoute
|
||||
path={`${homepage}/edit/:userId`}
|
||||
restricted
|
||||
allowForMe
|
||||
component={ProfileAction}
|
||||
/>
|
||||
<PrivateRoute
|
||||
path={`${homepage}/create/:type`}
|
||||
restricted
|
||||
component={ProfileAction}
|
||||
/>
|
||||
<PrivateRoute
|
||||
path={[
|
||||
`${homepage}/group/edit/:groupId`,
|
||||
`${homepage}/group/create`,
|
||||
]}
|
||||
restricted
|
||||
component={GroupAction}
|
||||
/>
|
||||
<PrivateRoute
|
||||
path={`${homepage}/reassign/:userId`}
|
||||
restricted
|
||||
component={Reassign}
|
||||
/>
|
||||
<PrivateRoute exact path={homepage} component={Home} />
|
||||
<PrivateRoute path={`${homepage}/filter`} component={Home} />
|
||||
<PublicRoute
|
||||
exact
|
||||
path={[
|
||||
"/login",
|
||||
"/login/error=:error",
|
||||
"/login/confirmed-email=:confirmedEmail",
|
||||
]}
|
||||
component={Login}
|
||||
/>
|
||||
<PrivateRoute exact path={`/error=:error`} component={Error520} />
|
||||
<PrivateRoute component={Error404} />
|
||||
</Switch>
|
||||
</Suspense>
|
||||
</Main>
|
||||
</Router>
|
||||
) : (
|
||||
<Offline />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// const mapStateToProps = (state) => {
|
||||
// const { settings } = state.auth;
|
||||
// const { homepage } = settings;
|
||||
// return {
|
||||
// homepage: homepage || config.homepage,
|
||||
// };
|
||||
// };
|
||||
|
||||
// const mapDispatchToProps = (dispatch) => {
|
||||
// return {
|
||||
//getIsAuthenticated: () => getIsAuthenticated(dispatch),
|
||||
// setModuleInfo: () => {
|
||||
// dispatch(setCurrentProductHomePage(config.homepage));
|
||||
// dispatch(setCurrentProductId("f4d98afd-d336-4332-8778-3c6945c81ea0"));
|
||||
// },
|
||||
//getUser: () => getUser(dispatch),
|
||||
//getPortalSettings: () => getPortalSettings(dispatch),
|
||||
//getModules: () => getModules(dispatch),
|
||||
// getPortalPasswordSettings: () => getPortalPasswordSettings(dispatch),
|
||||
// getPortalCultures: () => getPortalCultures(dispatch),
|
||||
// fetchGroups: () => fetchGroups(dispatch),
|
||||
// fetchPeople: () => {
|
||||
// var re = new RegExp(`${config.homepage}((/?)$|/filter)`, "gm");
|
||||
// const match = window.location.pathname.match(re);
|
||||
|
||||
// if (match && match.length > 0) {
|
||||
// const newFilter = getFilterByLocation(window.location);
|
||||
// return fetchPeople(newFilter, dispatch);
|
||||
// }
|
||||
|
||||
// return Promise.resolve();
|
||||
// },
|
||||
// setIsLoaded: () => dispatch(setIsLoaded(true)),
|
||||
// };
|
||||
// };
|
||||
*/
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
homepage: auth.settingsStore.homepage || config.homepage,
|
||||
loadBaseInfo: () => {
|
||||
|
@ -1,19 +1,11 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { utils, TreeMenu, TreeNode, Icons, Link } from "asc-web-components";
|
||||
import { setIsLoading } from "../../../store/people/actions";
|
||||
import { getSelectedGroup } from "../../../store/people/selectors";
|
||||
import { withTranslation, I18nextProvider } from "react-i18next";
|
||||
import {
|
||||
history,
|
||||
utils as commonUtils,
|
||||
store as initStore,
|
||||
Loaders,
|
||||
} from "asc-web-common";
|
||||
import { history, utils as commonUtils, Loaders } from "asc-web-common";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import styled, { css } from "styled-components";
|
||||
import { setDocumentTitle } from "../../../helpers/utils";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { getSelectedGroup } from "../../../helpers/people-helpers";
|
||||
|
||||
const i18n = createI18N({
|
||||
page: "Article",
|
||||
@ -21,7 +13,6 @@ const i18n = createI18N({
|
||||
});
|
||||
|
||||
const { changeLanguage } = commonUtils;
|
||||
const { isAdmin } = initStore.auth.selectors;
|
||||
|
||||
const StyledTreeMenu = styled(TreeMenu)`
|
||||
${(props) =>
|
||||
@ -80,7 +71,7 @@ class ArticleBodyContent extends React.Component {
|
||||
}
|
||||
|
||||
changeTitleDocument(data = null) {
|
||||
const { groups, selectedKeys } = this.props;
|
||||
const { groups, selectedKeys, setDocumentTitle } = this.props;
|
||||
|
||||
const currentGroup = getSelectedGroup(
|
||||
groups,
|
||||
@ -237,6 +228,7 @@ export default inject(({ auth, peopleStore }) => {
|
||||
? [peopleStore.selectedGroupStore.selectedGroup]
|
||||
: ["root"];
|
||||
return {
|
||||
setDocumentTitle: auth.setDocumentTitle,
|
||||
isLoaded: auth.isLoaded,
|
||||
isAdmin: auth.isAdmin,
|
||||
groups,
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React, { memo } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router";
|
||||
import PropTypes from "prop-types";
|
||||
import {
|
||||
@ -15,13 +14,8 @@ import AutoSizer from "react-virtualized-auto-sizer";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import { utils, toastr, constants } from "asc-web-common";
|
||||
import ModalDialogContainer from "../ModalDialogContainer";
|
||||
import { updateUserStatus, setSelected } from "../../../store/people/actions";
|
||||
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import {
|
||||
getUsersToActivateIds,
|
||||
getUsersToDisableIds,
|
||||
} from "../../../store/people/selectors";
|
||||
import { inject, observer } from "mobx-react";
|
||||
const i18n = createI18N({
|
||||
page: "ChangeUserStatusDialog",
|
||||
@ -196,31 +190,12 @@ ChangeUserStatusDialog.propTypes = {
|
||||
selectedUsers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
// const { selection } = state.people;
|
||||
const { userStatus } = ownProps;
|
||||
|
||||
return {
|
||||
// userIds:
|
||||
// userStatus === EmployeeStatus.Active
|
||||
// ? getUsersToActivateIds(state)
|
||||
// : getUsersToDisableIds(state),
|
||||
//selectedUsers: selection,
|
||||
};
|
||||
};
|
||||
|
||||
// export default connect(mapStateToProps, { updateUserStatus, setSelected })(
|
||||
// withRouter(ChangeUserStatusDialog)
|
||||
// );
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ peopleStore }) => ({
|
||||
export default inject(({ peopleStore }, ownProps) => ({
|
||||
updateUserStatus: peopleStore.usersStore.updateUserStatus,
|
||||
selectedUsers: peopleStore.selectionStore.selection,
|
||||
setSelected: peopleStore.selectionStore.setSelected,
|
||||
userIds:
|
||||
"userStatus" === EmployeeStatus.Active
|
||||
ownProps.userStatus === EmployeeStatus.Active
|
||||
? peopleStore.selectionStore.getUsersToActivateIds
|
||||
: peopleStore.selectionStore.getUsersToDisableIds,
|
||||
}))(observer(withRouter(ChangeUserStatusDialog)))
|
||||
);
|
||||
}))(observer(withRouter(ChangeUserStatusDialog)));
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React, { memo } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router";
|
||||
import PropTypes from "prop-types";
|
||||
import {
|
||||
@ -15,12 +14,8 @@ import { FixedSizeList as List, areEqual } from "react-window";
|
||||
import AutoSizer from "react-virtualized-auto-sizer";
|
||||
import { utils, toastr, constants } from "asc-web-common";
|
||||
import ModalDialogContainer from "../ModalDialogContainer";
|
||||
import { updateUserType, setSelected } from "../../../store/people/actions";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import {
|
||||
getUsersToMakeEmployeesIds,
|
||||
getUsersToMakeGuestsIds,
|
||||
} from "../../../store/people/selectors";
|
||||
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const i18n = createI18N({
|
||||
@ -190,28 +185,13 @@ ChangeUserTypeDialog.propTypes = {
|
||||
selectedUsers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
// const { selection } = state.people;
|
||||
const { userType } = ownProps;
|
||||
|
||||
return {
|
||||
// userIds:
|
||||
// userType === EmployeeType.User
|
||||
// ? getUsersToMakeEmployeesIds(state)
|
||||
// : getUsersToMakeGuestsIds(state),
|
||||
//selectedUsers: selection,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ peopleStore }) => ({
|
||||
export default inject(({ peopleStore }, ownProps) => ({
|
||||
filter: peopleStore.filterStore.filter,
|
||||
updateUserType: peopleStore.usersStore.updateUserType,
|
||||
selectedUsers: peopleStore.selectionStore.selection,
|
||||
setSelected: peopleStore.selectionStore.setSelected,
|
||||
userIds:
|
||||
"userType" === EmployeeType.User
|
||||
ownProps.userType === EmployeeType.User
|
||||
? peopleStore.selectionStore.getUsersToMakeEmployeesIds
|
||||
: peopleStore.selectionStore.getUsersToMakeGuestsIds,
|
||||
}))(observer(withRouter(ChangeUserTypeDialog)))
|
||||
);
|
||||
}))(observer(withRouter(ChangeUserTypeDialog)));
|
||||
|
@ -1,15 +1,10 @@
|
||||
import React from "react";
|
||||
// import { connect } from "react-redux";
|
||||
import PropTypes from "prop-types";
|
||||
import { ModalDialog, Button, Text } from "asc-web-components";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import { utils } from "asc-web-common";
|
||||
import ModalDialogContainer from "../ModalDialogContainer";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
// import {
|
||||
// setIsVisibleDataLossDialog,
|
||||
// setIsEditingForm,
|
||||
// } from "../../../store/people/actions";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const i18n = createI18N({
|
||||
|
@ -1,11 +1,10 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router";
|
||||
import PropTypes from "prop-types";
|
||||
import { ModalDialog, Button, Text } from "asc-web-components";
|
||||
import { withTranslation, Trans } from "react-i18next";
|
||||
import { api, utils, toastr, store } from "asc-web-common";
|
||||
import { fetchPeople } from "../../../store/people/actions";
|
||||
import { api, utils, toastr } from "asc-web-common";
|
||||
|
||||
import ModalDialogContainer from "../ModalDialogContainer";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import { inject, observer } from "mobx-react";
|
||||
@ -15,10 +14,9 @@ const i18n = createI18N({
|
||||
localesPath: "dialogs/DeleteProfileEverDialog",
|
||||
});
|
||||
|
||||
const { deleteUser } = api.people;
|
||||
const { deleteUser } = api.people; //TODO: Move to action
|
||||
const { Filter } = api;
|
||||
const { changeLanguage } = utils;
|
||||
const { settingsStore } = store;
|
||||
|
||||
class DeleteProfileEverDialogComponent extends React.Component {
|
||||
constructor(props) {
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React, { memo } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router";
|
||||
import PropTypes from "prop-types";
|
||||
import {
|
||||
@ -14,10 +13,8 @@ import { FixedSizeList as List, areEqual } from "react-window";
|
||||
import AutoSizer from "react-virtualized-auto-sizer";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import { api, utils, toastr } from "asc-web-common";
|
||||
import { removeUser, setSelected } from "../../../store/people/actions";
|
||||
import ModalDialogContainer from "../ModalDialogContainer";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import { getUsersToRemoveIds } from "../../../store/people/selectors";
|
||||
import { inject, observer } from "mobx-react";
|
||||
const i18n = createI18N({
|
||||
page: "DeleteUsersDialog",
|
||||
@ -188,28 +185,10 @@ DeleteUsersDialog.propTypes = {
|
||||
removeUser: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
// const { filter, selection } = state.people;
|
||||
|
||||
// const usersToRemoveIds = getUsersToRemoveIds(state);
|
||||
|
||||
return {
|
||||
//filter,
|
||||
// userIds: usersToRemoveIds,
|
||||
//selectedUsers: selection,
|
||||
};
|
||||
};
|
||||
|
||||
// export default connect(mapStateToProps, { removeUser, setSelected })(
|
||||
// withRouter(DeleteUsersDialog)
|
||||
// );
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ peopleStore }) => ({
|
||||
export default inject(({ peopleStore }) => ({
|
||||
filter: peopleStore.filterStore.filter,
|
||||
removeUser: peopleStore.usersStore.removeUser,
|
||||
selectedUsers: peopleStore.selectionStore.selection,
|
||||
setSelected: peopleStore.selectionStore.setSelected,
|
||||
userIds: peopleStore.selectionStore.getUsersToRemoveIds,
|
||||
}))(observer(withRouter(DeleteUsersDialog)))
|
||||
);
|
||||
}))(observer(withRouter(DeleteUsersDialog)));
|
||||
|
@ -1,5 +1,4 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import PropTypes from "prop-types";
|
||||
import {
|
||||
ModalDialog,
|
||||
@ -12,9 +11,8 @@ import {
|
||||
import { withTranslation } from "react-i18next";
|
||||
import ModalDialogContainer from "../ModalDialogContainer";
|
||||
import copy from "copy-to-clipboard";
|
||||
import { api, utils, store } from "asc-web-common";
|
||||
import { api, utils } from "asc-web-common";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import { getPortalInviteLinks } from "../../../store/portal/actions";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const i18n = createI18N({
|
||||
@ -23,7 +21,6 @@ const i18n = createI18N({
|
||||
});
|
||||
const { getShortenedLink } = api.portal;
|
||||
const { changeLanguage } = utils;
|
||||
const { settingsStore } = store;
|
||||
|
||||
const textAreaName = "link-textarea";
|
||||
|
||||
@ -211,21 +208,6 @@ class InviteDialogComponent extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
//settings: state.auth.settings.hasShortenService,
|
||||
// userInvitationLink: state.portal.inviteLinks.userLink,
|
||||
// guestInvitationLink: state.portal.inviteLinks.guestLink,
|
||||
//guestsCaption: state.auth.settings.customNames.guestsCaption,
|
||||
};
|
||||
};
|
||||
|
||||
// const mapDispatchToProps = (dispatch) => {
|
||||
// return {
|
||||
// getPortalInviteLinks: () => dispatch(getPortalInviteLinks()),
|
||||
// };
|
||||
// };
|
||||
|
||||
const InviteDialogTranslated = withTranslation()(InviteDialogComponent);
|
||||
|
||||
const InviteDialog = (props) => (
|
||||
@ -238,30 +220,10 @@ InviteDialog.propTypes = {
|
||||
onCloseButton: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
// const InviteDialogWrapper = observer((props) => {
|
||||
// return (
|
||||
// <InviteDialog
|
||||
// settings={settingsStore.hasShortenService}
|
||||
// guestsCaption={settingsStore.customNames.guestsCaption}
|
||||
// {...props}
|
||||
// />
|
||||
// );
|
||||
// });
|
||||
|
||||
export default connect(
|
||||
mapStateToProps
|
||||
//mapDispatchToProps
|
||||
)(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
settings: auth.settingsStore,
|
||||
guestsCaption: auth.settingsStore.customNames.guestsCaption,
|
||||
getPortalInviteLinks: peopleStore.inviteLinksStore.getPortalInviteLinks,
|
||||
userInvitationLink: peopleStore.inviteLinksStore.inviteLinks.userLink,
|
||||
guestInvitationLink: peopleStore.inviteLinksStore.inviteLinks.guestLink,
|
||||
}))(observer(InviteDialog))
|
||||
);
|
||||
|
||||
// export default connect(
|
||||
// mapStateToProps,
|
||||
// mapDispatchToProps
|
||||
// )(InviteDialogWrapper);
|
||||
}))(observer(InviteDialog));
|
||||
|
@ -15,9 +15,6 @@ import { withTranslation } from "react-i18next";
|
||||
import { api, utils, toastr } from "asc-web-common";
|
||||
import ModalDialogContainer from "../ModalDialogContainer";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import { connect } from "react-redux";
|
||||
import { getUsersToInviteIds } from "../../../store/people/selectors";
|
||||
import { setSelected } from "../../../store/people/actions";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const i18n = createI18N({
|
||||
@ -176,20 +173,8 @@ SendInviteDialog.propTypes = {
|
||||
setSelected: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
// const { selection } = state.people;
|
||||
// const usersToInviteIds = getUsersToInviteIds(state);
|
||||
|
||||
return {
|
||||
// userIds: usersToInviteIds,
|
||||
//selectedUsers: selection,
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ peopleStore }) => ({
|
||||
export default inject(({ peopleStore }) => ({
|
||||
selectedUsers: peopleStore.selectionStore.selection,
|
||||
setSelected: peopleStore.selectionStore.setSelected,
|
||||
userIds: peopleStore.selectionStore.getUsersToInviteIds,
|
||||
}))(observer(withRouter(SendInviteDialog)))
|
||||
);
|
||||
}))(observer(withRouter(SendInviteDialog)));
|
||||
|
@ -8,36 +8,15 @@ import {
|
||||
TextInput,
|
||||
utils,
|
||||
} from "asc-web-components";
|
||||
import {
|
||||
PeopleSelector,
|
||||
store as initStore,
|
||||
toastr,
|
||||
Loaders,
|
||||
} from "asc-web-common";
|
||||
import {
|
||||
createGroup,
|
||||
resetGroup,
|
||||
updateGroup,
|
||||
} from "../../../../../store/group/actions";
|
||||
import { selectGroup, setFilter } from "../../../../../store/people/actions";
|
||||
|
||||
import { PeopleSelector, toastr, Loaders } from "asc-web-common";
|
||||
import { GUID_EMPTY } from "../../../../../helpers/constants";
|
||||
import PropTypes from "prop-types";
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { withRouter } from "react-router";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const {
|
||||
getCurrentProductName,
|
||||
//getSettings,
|
||||
getCurrentUser,
|
||||
} = initStore.auth.selectors;
|
||||
|
||||
const { settingsStore } = initStore;
|
||||
|
||||
const MainContainer = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -492,39 +471,7 @@ const convertGroups = (groups) => {
|
||||
: [];
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
//const currentModuleName = getCurrentProductName(state);
|
||||
//const settings = getSettings(state);
|
||||
// const {
|
||||
// groupHeadCaption,
|
||||
// groupsCaption,
|
||||
// groupCaption,
|
||||
// } = settings.customNames;
|
||||
//const { isLoaded } = state.auth;
|
||||
|
||||
return {
|
||||
//settings,
|
||||
//group: state.group.targetGroup,
|
||||
//groups: convertGroups(state.people.groups),
|
||||
// users: convertUsers(state.people.selector.users), //TODO: replace to api requests with search
|
||||
// groupHeadCaption,
|
||||
// groupsCaption,
|
||||
// groupCaption,
|
||||
//me: getCurrentUser(state),
|
||||
//currentModuleName,
|
||||
//filter: state.people.filter,
|
||||
// isLoaded,
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, {
|
||||
// resetGroup,
|
||||
//createGroup,
|
||||
//updateGroup,
|
||||
// selectGroup,
|
||||
// setFilter,
|
||||
})(
|
||||
inject(({ auth, peopleStore }) => {
|
||||
export default inject(({ auth, peopleStore }) => {
|
||||
const groups = convertGroups(peopleStore.groupsStore.groups);
|
||||
return {
|
||||
settings: auth.settingsStore,
|
||||
@ -543,13 +490,4 @@ export default connect(mapStateToProps, {
|
||||
group: peopleStore.selectedGroupStore.targetedGroup,
|
||||
resetGroup: peopleStore.selectedGroupStore.resetGroup,
|
||||
};
|
||||
})(observer(withRouter(withTranslation()(SectionBodyContent))))
|
||||
);
|
||||
|
||||
// export default connect(mapStateToProps, {
|
||||
// resetGroup,
|
||||
// createGroup,
|
||||
// updateGroup,
|
||||
// selectGroup,
|
||||
// setFilter,
|
||||
// })(withRouter(withTranslation()(SectionBodyContentWrapper)));
|
||||
})(observer(withRouter(withTranslation()(SectionBodyContent))));
|
||||
|
@ -1,17 +1,12 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router";
|
||||
import PropTypes from "prop-types";
|
||||
import { IconButton } from "asc-web-components";
|
||||
import { Headline, store } from "asc-web-common";
|
||||
import { Headline } from "asc-web-common";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import { resetGroup } from "../../../../../store/group/actions";
|
||||
// import { setFilter } from "../../../../../store/people/actions";
|
||||
import styled from "styled-components";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const { settingsStore } = store;
|
||||
|
||||
const Wrapper = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr auto auto;
|
||||
@ -76,34 +71,10 @@ SectionHeaderContent.defaultProps = {
|
||||
group: null,
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
//settings: state.auth.settings,
|
||||
//group: state.group.targetGroup,
|
||||
//groupCaption: state.auth.settings.customNames.groupCaption,
|
||||
//filter: state.people.filter,
|
||||
};
|
||||
}
|
||||
|
||||
// const SectionHeaderContentWrapper = observer((props) => {
|
||||
// return (
|
||||
// <SectionHeaderContent
|
||||
// groupCaption={settingsStore.customNames.groupCaption}
|
||||
// {...props}
|
||||
// />
|
||||
// );
|
||||
// });
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
groupCaption: auth.settingsStore.customNames.groupCaption,
|
||||
filter: peopleStore.filterStore.filter,
|
||||
setFilter: peopleStore.filterStore.setFilterParams,
|
||||
group: peopleStore.selectedGroupStore.targetedGroup,
|
||||
resetGroup: peopleStore.selectedGroupStore.resetGroup,
|
||||
}))(observer(withRouter(withTranslation()(SectionHeaderContent))))
|
||||
);
|
||||
|
||||
// export default connect(mapStateToProps, { resetGroup, setFilter })(
|
||||
// withTranslation()(withRouter(SectionHeaderContentWrapper))
|
||||
// );
|
||||
}))(observer(withRouter(withTranslation()(SectionHeaderContent))));
|
||||
|
@ -9,7 +9,6 @@ import {
|
||||
import { SectionHeaderContent, SectionBodyContent } from "./Section";
|
||||
import { I18nextProvider, withTranslation } from "react-i18next";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import { setDocumentTitle } from "../../../helpers/utils";
|
||||
import { withRouter } from "react-router";
|
||||
import { inject, observer } from "mobx-react";
|
||||
const i18n = createI18N({
|
||||
@ -20,7 +19,7 @@ const { changeLanguage } = utils;
|
||||
|
||||
class GroupAction extends React.Component {
|
||||
componentDidMount() {
|
||||
const { match, fetchGroup, t } = this.props;
|
||||
const { match, fetchGroup, t, setDocumentTitle } = this.props;
|
||||
const { groupId } = match.params;
|
||||
|
||||
setDocumentTitle(t("GroupAction"));
|
||||
@ -111,15 +110,8 @@ const GroupActionContainer = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
//settings: state.auth.settings,
|
||||
//group: state.group.targetGroup,
|
||||
// isAdmin: isAdmin(state),
|
||||
};
|
||||
}
|
||||
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
setDocumentTitle: auth.setDocumentTitle,
|
||||
isAdmin: auth.isAdmin,
|
||||
fetchGroup: peopleStore.selectedGroupStore.setTargetedGroup,
|
||||
group: peopleStore.selectedGroupStore.targetedGroup,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React from "react";
|
||||
import { withRouter } from "react-router";
|
||||
import { connect } from "react-redux";
|
||||
import { withTranslation, Trans } from "react-i18next";
|
||||
import {
|
||||
Row,
|
||||
@ -15,7 +14,7 @@ import {
|
||||
} from "asc-web-components";
|
||||
import UserContent from "./userContent";
|
||||
import equal from "fast-deep-equal/react";
|
||||
import { store, api, constants, toastr, Loaders } from "asc-web-common";
|
||||
import { api, constants, toastr, Loaders } from "asc-web-common";
|
||||
import {
|
||||
ChangeEmailDialog,
|
||||
ChangePasswordDialog,
|
||||
@ -32,8 +31,6 @@ const i18n = createI18N({
|
||||
});
|
||||
const { Consumer } = utils.context;
|
||||
const { isArrayEqual } = utils.array;
|
||||
const { getIsLoadedSection } = store.auth.selectors;
|
||||
const { setIsLoadedSection } = store.auth.actions;
|
||||
const { resendUserInvites } = api.people;
|
||||
const { EmployeeStatus } = constants;
|
||||
|
||||
@ -51,28 +48,21 @@ class SectionBodyContent extends React.PureComponent {
|
||||
deleteProfileEver: false,
|
||||
},
|
||||
isEmailValid: false,
|
||||
isLoadedSection: true,
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {
|
||||
isLoaded,
|
||||
fetchPeople,
|
||||
filter,
|
||||
setIsLoadedSection,
|
||||
peopleList,
|
||||
} = this.props;
|
||||
if (!isLoaded) return;
|
||||
if (peopleList.length <= 0) {
|
||||
const { isLoaded, fetchPeople, filter, peopleList } = this.props;
|
||||
if (!isLoaded || peopleList.length > 0) return;
|
||||
|
||||
this.setState({ isLoadedSection: false });
|
||||
|
||||
fetchPeople(filter)
|
||||
.then(() =>
|
||||
isLoaded ? setIsLoadedSection(true) : setIsLoadedSection()
|
||||
)
|
||||
.catch((error) => {
|
||||
isLoaded ? setIsLoadedSection(true) : setIsLoadedSection();
|
||||
toastr.error(error);
|
||||
});
|
||||
}
|
||||
})
|
||||
.finally(() => this.setState({ isLoadedSection: isLoaded }));
|
||||
}
|
||||
|
||||
findUserById = (id) => this.props.peopleList.find((man) => man.id === id);
|
||||
@ -363,7 +353,6 @@ class SectionBodyContent extends React.PureComponent {
|
||||
//console.log("Home SectionBodyContent render()");
|
||||
const {
|
||||
isLoaded,
|
||||
isLoadedSection,
|
||||
peopleList,
|
||||
history,
|
||||
settings,
|
||||
@ -377,7 +366,7 @@ class SectionBodyContent extends React.PureComponent {
|
||||
currentUserId,
|
||||
} = this.props;
|
||||
|
||||
const { dialogsVisible, user } = this.state;
|
||||
const { dialogsVisible, user, isLoadedSection } = this.state;
|
||||
|
||||
return !isLoaded || (isMobile && isLoading) || !isLoadedSection ? (
|
||||
<Loaders.Rows isRectangle={false} />
|
||||
@ -523,26 +512,18 @@ class SectionBodyContent extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
isLoadedSection: getIsLoadedSection(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, { setIsLoadedSection })(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
settings: auth.settingsStore,
|
||||
isLoaded: auth.isLoaded,
|
||||
isAdmin: auth.isAdmin,
|
||||
currentUserId: auth.userStore.user.id,
|
||||
fetchPeople: peopleStore.usersStore.getUsersList,
|
||||
peopleList: peopleStore.usersStore.composePeopleList(),
|
||||
peopleList: peopleStore.usersStore.peopleList,
|
||||
filter: peopleStore.filterStore.filter,
|
||||
resetFilter: peopleStore.filterStore.resetFilter,
|
||||
resetFilter: peopleStore.resetFilter,
|
||||
selectUser: peopleStore.selectionStore.selectUser,
|
||||
deselectUser: peopleStore.selectionStore.deselectUser,
|
||||
selectGroup: peopleStore.selectedGroupStore.selectGroup,
|
||||
updateUserStatus: peopleStore.usersStore.updateUserStatus,
|
||||
isLoading: peopleStore.isLoading,
|
||||
}))(observer(withRouter(withTranslation()(SectionBodyContent))))
|
||||
);
|
||||
}))(observer(withRouter(withTranslation()(SectionBodyContent))));
|
||||
|
@ -81,8 +81,8 @@ class SectionFilterContent extends React.Component {
|
||||
};
|
||||
|
||||
getData = () => {
|
||||
const { groups, t, settings, isAdmin } = this.props;
|
||||
const { guestCaption, userCaption, groupCaption } = settings.customNames;
|
||||
const { groups, t, customNames, isAdmin } = this.props;
|
||||
const { guestCaption, userCaption, groupCaption } = customNames;
|
||||
|
||||
const options = !isAdmin
|
||||
? []
|
||||
@ -181,6 +181,7 @@ class SectionFilterContent extends React.Component {
|
||||
|
||||
getSelectedFilterData = () => {
|
||||
const { filter } = this.props;
|
||||
|
||||
const selectedFilterData = {
|
||||
filterValues: [],
|
||||
sortDirection: filter.sortOrder === "ascending" ? "asc" : "desc",
|
||||
@ -230,6 +231,7 @@ class SectionFilterContent extends React.Component {
|
||||
render() {
|
||||
const selectedFilterData = this.getSelectedFilterData();
|
||||
const { t, language, isLoaded, sectionWidth } = this.props;
|
||||
|
||||
return isLoaded ? (
|
||||
<FilterInput
|
||||
sectionWidth={sectionWidth}
|
||||
@ -253,7 +255,7 @@ class SectionFilterContent extends React.Component {
|
||||
|
||||
export default inject(({ auth, peopleStore }) => {
|
||||
return {
|
||||
settings: auth.settingsStore,
|
||||
customNames: auth.settingsStore.customNames,
|
||||
isLoaded: auth.isLoaded,
|
||||
isAdmin: auth.isAdmin,
|
||||
language: auth.language,
|
||||
|
@ -8,16 +8,6 @@ import {
|
||||
utils,
|
||||
} from "asc-web-components";
|
||||
import { Headline, toastr, Loaders, constants } from "asc-web-common";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
hasAnybodySelected,
|
||||
hasUsersToMakeEmployees,
|
||||
hasUsersToMakeGuests,
|
||||
hasUsersToActivate,
|
||||
hasUsersToDisable,
|
||||
hasUsersToInvite,
|
||||
hasUsersToRemove,
|
||||
} from "../../../../../store/people/selectors";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import {
|
||||
InviteDialog,
|
||||
@ -494,20 +484,7 @@ const SectionHeaderContent = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
// hasAnybodySelected: hasAnybodySelected(state),
|
||||
// hasUsersToMakeEmployees: hasUsersToMakeEmployees(state),
|
||||
// hasUsersToMakeGuests: hasUsersToMakeGuests(state),
|
||||
// hasUsersToActivate: hasUsersToActivate(state),
|
||||
// hasUsersToDisable: hasUsersToDisable(state),
|
||||
// hasUsersToInvite: hasUsersToInvite(state),
|
||||
// hasUsersToRemove: hasUsersToRemove(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
customNames: auth.settingsStore.customNames,
|
||||
homepage: auth.settingsStore.homepage,
|
||||
isLoaded: auth.isLoaded,
|
||||
@ -531,5 +508,4 @@ export default connect(mapStateToProps)(
|
||||
removeUser: peopleStore.usersStore.removeUser,
|
||||
updateUserStatus: peopleStore.usersStore.updateUserStatus,
|
||||
group: peopleStore.selectedGroupStore.group,
|
||||
}))(observer(withTranslation()(withRouter(SectionHeaderContent))))
|
||||
);
|
||||
}))(observer(withTranslation()(withRouter(SectionHeaderContent))));
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
HelpButton,
|
||||
} from "asc-web-components";
|
||||
import styled from "styled-components";
|
||||
import { api, toastr, Loaders, store } from "asc-web-common";
|
||||
import { api, toastr, Loaders } from "asc-web-common";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const { resendUserInvites } = api.people;
|
||||
@ -327,15 +327,6 @@ class ProfileInfo extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
// updateProfileCulture: (id, culture) =>
|
||||
// dispatch(updateProfileCulture(id, culture)),
|
||||
//fetchPeople: (filter) => dispatch(fetchPeople(filter)),
|
||||
//setIsLoading: (isLoading) => dispatch(setIsLoading(isLoading)),
|
||||
};
|
||||
};
|
||||
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
settings: auth.settingsStore,
|
||||
groupCaption: auth.settingsStore.customNames.groupCaption,
|
||||
@ -348,5 +339,3 @@ export default inject(({ auth, peopleStore }) => ({
|
||||
setIsLoading: peopleStore.setIsLoading,
|
||||
updateProfileCulture: peopleStore.targetUserStore.updateProfileCulture,
|
||||
}))(observer(ProfileInfo));
|
||||
|
||||
//export default connect(mapStateToProps, mapDispatchToProps)(ProfileInfoWrapper);
|
||||
|
@ -6,21 +6,20 @@ import {
|
||||
ToggleContent,
|
||||
Link,
|
||||
} from "asc-web-components";
|
||||
import {
|
||||
getUserContacts,
|
||||
getUserRole,
|
||||
} from "../../../../../store/people/selectors";
|
||||
|
||||
import ProfileInfo from "./ProfileInfo/ProfileInfo";
|
||||
import React from "react";
|
||||
import { store } from "asc-web-common";
|
||||
import { utils } from "asc-web-common";
|
||||
import styled from "styled-components";
|
||||
|
||||
import { withRouter } from "react-router";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import {
|
||||
getUserContacts,
|
||||
getUserRole,
|
||||
} from "../../../../../helpers/people-helpers";
|
||||
|
||||
const { isMe } = store.auth.selectors;
|
||||
const { isMe } = utils;
|
||||
|
||||
const ProfileWrapper = styled.div`
|
||||
display: flex;
|
||||
@ -91,6 +90,14 @@ const stringFormat = (string, data) =>
|
||||
string.replace(/\{(\d+)\}/g, (m, n) => data[n] || m);
|
||||
|
||||
class SectionBodyContent extends React.PureComponent {
|
||||
componentDidMount() {
|
||||
const { cultures, getPortalCultures, profile, viewer } = this.props;
|
||||
const isSelf = isMe(viewer, profile.userName);
|
||||
if (isSelf && !cultures.length) {
|
||||
getPortalCultures();
|
||||
}
|
||||
}
|
||||
|
||||
onEditSubscriptionsClick = () => console.log("Edit subscriptions onClick()");
|
||||
|
||||
onEditProfileClick = () =>
|
||||
@ -99,7 +106,7 @@ class SectionBodyContent extends React.PureComponent {
|
||||
);
|
||||
|
||||
render() {
|
||||
const { profile, settings, isAdmin, viewer, t } = this.props;
|
||||
const { profile, cultures, culture, isAdmin, viewer, t } = this.props;
|
||||
|
||||
const contacts = profile.contacts && getUserContacts(profile.contacts);
|
||||
const role = getUserRole(profile);
|
||||
@ -112,6 +119,8 @@ class SectionBodyContent extends React.PureComponent {
|
||||
const infoContacts = contacts && createContacts(contacts.contact);
|
||||
const isSelf = isMe(viewer, profile.userName);
|
||||
|
||||
console.log("Profile", cultures, culture);
|
||||
|
||||
return (
|
||||
<ProfileWrapper>
|
||||
<AvatarWrapper>
|
||||
@ -138,8 +147,8 @@ class SectionBodyContent extends React.PureComponent {
|
||||
isSelf={isSelf}
|
||||
isAdmin={isAdmin}
|
||||
t={t}
|
||||
cultures={settings.cultures}
|
||||
culture={settings.culture}
|
||||
cultures={cultures}
|
||||
culture={culture}
|
||||
/>
|
||||
{isSelf && false && (
|
||||
<ToggleWrapper isSelf={true}>
|
||||
@ -181,26 +190,13 @@ class SectionBodyContent extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
//settings: state.auth.settings,
|
||||
// profile: state.profile.targetUser,
|
||||
// isAdmin: isAdmin(state),
|
||||
//viewer: state.auth.user,
|
||||
};
|
||||
};
|
||||
|
||||
// const SectionBodyContentWrapper = observer((props) => {
|
||||
// return <SectionBodyContent settings={settingsStore.settings} {...props} />;
|
||||
// });
|
||||
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
settings: auth.settingsStore,
|
||||
homepage: auth.settingsStore.homepage,
|
||||
cultures: auth.settingsStore.cultures,
|
||||
culture: auth.settingsStore.culture,
|
||||
getPortalCultures: auth.settingsStore.getPortalCultures,
|
||||
isAdmin: auth.isAdmin,
|
||||
profile: peopleStore.targetUserStore.targetUser,
|
||||
viewer: auth.userStore.user,
|
||||
}))(observer(withRouter(withTranslation()(SectionBodyContent))));
|
||||
|
||||
// export default connect(mapStateToProps)(
|
||||
// withRouter(withTranslation()(SectionBodyContentWrapper))
|
||||
// );
|
||||
|
@ -6,13 +6,9 @@ import {
|
||||
} from "asc-web-components";
|
||||
import { Headline, toastr } from "asc-web-common";
|
||||
import { withRouter } from "react-router";
|
||||
import {
|
||||
getUserStatus,
|
||||
toEmployeeWrapper,
|
||||
} from "../../../../../store/people/selectors";
|
||||
import { withTranslation, Trans } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { store, api, constants } from "asc-web-common";
|
||||
import { store, utils, api, constants } from "asc-web-common";
|
||||
import {
|
||||
DeleteSelfProfileDialog,
|
||||
ChangePasswordDialog,
|
||||
@ -21,12 +17,16 @@ import {
|
||||
} from "../../../../dialogs";
|
||||
import { createI18N } from "../../../../../helpers/i18n";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import {
|
||||
getUserStatus,
|
||||
toEmployeeWrapper,
|
||||
} from "../../../../../helpers/people-helpers";
|
||||
|
||||
const i18n = createI18N({
|
||||
page: "Profile",
|
||||
localesPath: "pages/Profile",
|
||||
});
|
||||
const { isAdmin, isMe } = store.auth.selectors;
|
||||
const { isMe } = utils;
|
||||
const {
|
||||
resendUserInvites,
|
||||
createThumbnailsAvatar,
|
||||
@ -294,7 +294,7 @@ class SectionHeaderContent extends React.PureComponent {
|
||||
|
||||
getUserContextOptions = (user, viewer) => {
|
||||
let status = "";
|
||||
const { t } = this.props;
|
||||
const { t, isAdmin } = this.props;
|
||||
|
||||
if (isAdmin || (!isAdmin && isMe(user, viewer.userName))) {
|
||||
status = getUserStatus(user);
|
||||
@ -495,20 +495,6 @@ class SectionHeaderContent extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
//settings: state.auth.settings,
|
||||
// profile: state.profile.targetUser,
|
||||
//viewer: state.auth.user,
|
||||
// isAdmin: isAdmin(state),
|
||||
//filter: state.people.filter,
|
||||
};
|
||||
};
|
||||
|
||||
// const SectionHeaderContentWrapper = observer((props) => {
|
||||
// return <SectionHeaderContent settings={settingsStore.settings} {...props} />;
|
||||
// });
|
||||
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
settings: auth.settingsStore,
|
||||
isAdmin: auth.isAdmin,
|
||||
@ -522,10 +508,3 @@ export default inject(({ auth, peopleStore }) => ({
|
||||
updateProfile: peopleStore.targetUserStore.updateProfile,
|
||||
getUserPhoto: peopleStore.targetUserStore.getUserPhoto,
|
||||
}))(observer(withRouter(withTranslation()(SectionHeaderContent))));
|
||||
|
||||
// export default connect(mapStateToProps, {
|
||||
// updateUserStatus,
|
||||
// fetchProfile,
|
||||
// updateProfile,
|
||||
// setFilter,
|
||||
// })(withRouter(withTranslation()(SectionHeaderContentWrapper)));
|
||||
|
@ -1,18 +1,14 @@
|
||||
import React, { Profiler, useEffect } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import React, { useEffect } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import { Loader } from "asc-web-components";
|
||||
import { PageLayout, utils, store, toastr, Loaders } from "asc-web-common";
|
||||
import { PageLayout, utils, toastr, Loaders } from "asc-web-common";
|
||||
import {
|
||||
ArticleHeaderContent,
|
||||
ArticleMainButtonContent,
|
||||
ArticleBodyContent,
|
||||
} from "../../Article";
|
||||
import { SectionHeaderContent, SectionBodyContent } from "./Section";
|
||||
import { fetchProfile, resetProfile } from "../../../store/profile/actions";
|
||||
import { I18nextProvider, withTranslation } from "react-i18next";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import { setDocumentTitle } from "../../../helpers/utils";
|
||||
import { withRouter } from "react-router";
|
||||
import { isChrome, isAndroid } from "react-device-detect";
|
||||
import { inject, observer } from "mobx-react";
|
||||
@ -21,11 +17,17 @@ const i18n = createI18N({
|
||||
localesPath: "pages/Profile",
|
||||
});
|
||||
const { changeLanguage } = utils;
|
||||
const { isAdmin, isVisitor, getLanguage } = store.auth.selectors;
|
||||
|
||||
class PureProfile extends React.Component {
|
||||
componentDidMount() {
|
||||
const { match, fetchProfile, profile, location, t } = this.props;
|
||||
const {
|
||||
match,
|
||||
fetchProfile,
|
||||
profile,
|
||||
location,
|
||||
t,
|
||||
setDocumentTitle,
|
||||
} = this.props;
|
||||
const { userId } = match.params;
|
||||
isChrome && isAndroid && window && window.scroll(0, 0);
|
||||
setDocumentTitle(t("Profile"));
|
||||
@ -117,14 +119,8 @@ Profile.propTypes = {
|
||||
language: PropTypes.string,
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
//isVisitor: isVisitor(state),
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
setDocumentTitle: auth.setDocumentTitle,
|
||||
isVisitor: auth.userStore.user.isVisitor,
|
||||
isLoaded: auth.isLoaded,
|
||||
isAdmin: auth.isAdmin,
|
||||
@ -132,5 +128,4 @@ export default connect(mapStateToProps)(
|
||||
resetProfile: peopleStore.targetUserStore.resetTargetUser,
|
||||
fetchProfile: peopleStore.targetUserStore.getTargetUser,
|
||||
profile: peopleStore.targetUserStore.targetUser,
|
||||
}))(observer(Profile))
|
||||
);
|
||||
}))(observer(Profile));
|
||||
|
@ -1,15 +1,12 @@
|
||||
import React from "react";
|
||||
import { withRouter } from "react-router";
|
||||
import { connect } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import { AvatarEditor, utils, Loader } from "asc-web-components";
|
||||
import { api, toastr } from "asc-web-common";
|
||||
|
||||
import { toEmployeeWrapper } from "../../../../../store/people/selectors";
|
||||
import { setDocumentTitle } from "../../../../../helpers/utils";
|
||||
import { isMobile } from "react-device-detect";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { toEmployeeWrapper } from "../../../../../helpers/people-helpers";
|
||||
|
||||
const { createThumbnailsAvatar, loadAvatar, deleteAvatar } = api.people;
|
||||
const { isTablet } = utils.device;
|
||||
@ -31,7 +28,7 @@ class AvatarEditorPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { match, fetchProfile, t, profile } = this.props;
|
||||
const { match, fetchProfile, t, profile, setDocumentTitle } = this.props;
|
||||
const { avatar } = this.state;
|
||||
const { userId } = match.params;
|
||||
|
||||
@ -309,15 +306,8 @@ class AvatarEditorPage extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
// profile: state.profile.targetUser,
|
||||
// avatarMax: state.profile.avatarMax,
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
setDocumentTitle: auth.setDocumentTitle,
|
||||
toggleAvatarEditor: peopleStore.avatarEditorStore.toggleAvatarEditor,
|
||||
fetchProfile: peopleStore.targetUserStore.getTargetUser,
|
||||
profile: peopleStore.targetUserStore.targetUser,
|
||||
@ -325,5 +315,4 @@ export default connect(mapStateToProps)(
|
||||
setAvatarMax: peopleStore.avatarEditorStore.setAvatarMax,
|
||||
updateProfile: peopleStore.targetUserStore.updateProfile,
|
||||
getUserPhoto: peopleStore.targetUserStore.getUserPhoto,
|
||||
}))(observer(withRouter(withTranslation()(AvatarEditorPage))))
|
||||
);
|
||||
}))(observer(withRouter(withTranslation()(AvatarEditorPage))));
|
||||
|
@ -1,29 +1,12 @@
|
||||
import React from "react";
|
||||
import { withRouter } from "react-router";
|
||||
import { connect } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { withTranslation } from "react-i18next";
|
||||
import { AvatarEditor, utils, Loader } from "asc-web-components";
|
||||
import { api, toastr } from "asc-web-common";
|
||||
import {
|
||||
fetchProfile,
|
||||
updateProfile,
|
||||
// getUserPhoto,
|
||||
setAvatarMax,
|
||||
updateCreatedAvatar,
|
||||
setCreatedAvatar,
|
||||
setCroppedAvatar,
|
||||
resetProfile,
|
||||
} from "../../../../../store/profile/actions";
|
||||
import { toEmployeeWrapper } from "../../../../../store/people/selectors";
|
||||
import {
|
||||
toggleAvatarEditor,
|
||||
updateProfileInUsers,
|
||||
setIsEditingForm,
|
||||
} from "../../../../../store/people/actions";
|
||||
import { setDocumentTitle } from "../../../../../helpers/utils";
|
||||
import { isMobile } from "react-device-detect";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { toEmployeeWrapper } from "../../../../../helpers/people-helpers";
|
||||
|
||||
const { createThumbnailsAvatar, loadAvatar } = api.people;
|
||||
const { isTablet } = utils.device;
|
||||
@ -48,7 +31,7 @@ class CreateAvatarEditorPage extends React.PureComponent {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { match, fetchProfile, t, profile } = this.props;
|
||||
const { match, fetchProfile, t, profile, setDocumentTitle } = this.props;
|
||||
const { avatar } = this.state;
|
||||
const { userId } = match.params;
|
||||
|
||||
@ -290,30 +273,8 @@ class CreateAvatarEditorPage extends React.PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
// profile: state.profile.targetUser,
|
||||
// avatarMax: state.profile.avatarMax,
|
||||
// createdAvatar: state.profile.createdAvatar,
|
||||
// croppedAvatar: state.profile.croppedAvatar,
|
||||
//settings: state.auth.settings,
|
||||
//editingForm: state.people.editingForm,
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, {
|
||||
// fetchProfile,
|
||||
// updateProfile,
|
||||
//toggleAvatarEditor,
|
||||
//setAvatarMax,
|
||||
// updateCreatedAvatar,
|
||||
// updateProfileInUsers,
|
||||
// setCreatedAvatar,
|
||||
// setCroppedAvatar,
|
||||
// resetProfile,
|
||||
//setIsEditingForm,
|
||||
})(
|
||||
inject(({ peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
setDocumentTitle: auth.setDocumentTitle,
|
||||
setIsEditingForm: peopleStore.editingFormStore.setIsEditingForm,
|
||||
toggleAvatarEditor: peopleStore.avatarEditorStore.toggleAvatarEditor,
|
||||
resetProfile: peopleStore.targetUserStore.resetTargetUser,
|
||||
@ -327,18 +288,4 @@ export default connect(mapStateToProps, {
|
||||
createdAvatar: peopleStore.avatarEditorStore.createdAvatar,
|
||||
avatarMax: peopleStore.avatarEditorStore.avatarMax,
|
||||
croppedAvatar: peopleStore.avatarEditorStore.croppedAvatar,
|
||||
}))(observer(withRouter(withTranslation()(CreateAvatarEditorPage))))
|
||||
);
|
||||
|
||||
// export default connect(mapStateToProps, {
|
||||
// fetchProfile,
|
||||
// updateProfile,
|
||||
// toggleAvatarEditor,
|
||||
// setAvatarMax,
|
||||
// updateCreatedAvatar,
|
||||
// updateProfileInUsers,
|
||||
// setCreatedAvatar,
|
||||
// setCroppedAvatar,
|
||||
// resetProfile,
|
||||
// setIsEditingForm,
|
||||
// })(withTranslation()(withRouter(CreateAvatarEditorPage)));
|
||||
}))(observer(withRouter(withTranslation()(CreateAvatarEditorPage))));
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React from "react";
|
||||
import { withRouter } from "react-router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
Avatar,
|
||||
Button,
|
||||
@ -10,29 +9,6 @@ import {
|
||||
utils,
|
||||
} from "asc-web-components";
|
||||
import { withTranslation, Trans } from "react-i18next";
|
||||
import {
|
||||
toEmployeeWrapper,
|
||||
getUserRole,
|
||||
getUserContactsPattern,
|
||||
getUserContacts,
|
||||
mapGroupsToGroupSelectorOptions,
|
||||
mapGroupSelectorOptionsToGroups,
|
||||
filterGroupSelectorOptions,
|
||||
} from "../../../../../store/people/selectors";
|
||||
import {
|
||||
createProfile,
|
||||
updateCreatedAvatar,
|
||||
setCreatedAvatar,
|
||||
setCroppedAvatar,
|
||||
resetProfile,
|
||||
} from "../../../../../store/profile/actions";
|
||||
import {
|
||||
setFilter,
|
||||
updateProfileInUsers,
|
||||
setIsVisibleDataLossDialog,
|
||||
setIsEditingForm,
|
||||
toggleAvatarEditor,
|
||||
} from "../../../../../store/people/actions";
|
||||
import {
|
||||
MainContainer,
|
||||
AvatarContainer,
|
||||
@ -47,13 +23,21 @@ import DepartmentField from "./FormFields/DepartmentField";
|
||||
import ContactsField from "./FormFields/ContactsField";
|
||||
import InfoFieldContainer from "./FormFields/InfoFieldContainer";
|
||||
import { DataLossWarningDialog } from "../../../../dialogs";
|
||||
import { api, toastr, store } from "asc-web-common";
|
||||
import { api, toastr } from "asc-web-common";
|
||||
import { isMobile } from "react-device-detect";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import {
|
||||
toEmployeeWrapper,
|
||||
getUserRole,
|
||||
getUserContactsPattern,
|
||||
getUserContacts,
|
||||
mapGroupsToGroupSelectorOptions,
|
||||
mapGroupSelectorOptionsToGroups,
|
||||
filterGroupSelectorOptions,
|
||||
} from "../../../../../helpers/people-helpers";
|
||||
|
||||
const { createThumbnailsAvatar, loadAvatar } = api.people;
|
||||
const { isTablet } = utils.device;
|
||||
const { settingsStore } = store;
|
||||
|
||||
class CreateUserForm extends React.Component {
|
||||
constructor(props) {
|
||||
@ -654,37 +638,7 @@ class CreateUserForm extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
//const { settings } = state.auth;
|
||||
// const { groups, filter, editingForm } = state.people;
|
||||
// const { createdAvatar, croppedAvatar } = state.profile;
|
||||
return {
|
||||
//settings,
|
||||
//groups,
|
||||
//filter,
|
||||
//editingForm,
|
||||
// createdAvatar,
|
||||
// croppedAvatar,
|
||||
};
|
||||
};
|
||||
|
||||
// const CreateUserFormWrapper = observer((props) => {
|
||||
// return <CreateUserForm settings={settingsStore.settings} {...props} />;
|
||||
// });
|
||||
|
||||
export default connect(mapStateToProps, {
|
||||
// createProfile,
|
||||
// updateCreatedAvatar,
|
||||
//setFilter,
|
||||
// updateProfileInUsers,
|
||||
// setIsVisibleDataLossDialog,
|
||||
// setIsEditingForm,
|
||||
// toggleAvatarEditor,
|
||||
// setCreatedAvatar,
|
||||
// setCroppedAvatar,
|
||||
// resetProfile,
|
||||
})(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
settings: auth.settingsStore,
|
||||
isEdit: peopleStore.editingFormStore.isEdit,
|
||||
groups: peopleStore.groupsStore.groups,
|
||||
@ -702,18 +656,4 @@ export default connect(mapStateToProps, {
|
||||
setCroppedAvatar: peopleStore.avatarEditorStore.setCroppedAvatar,
|
||||
updateProfileInUsers: peopleStore.usersStore.updateProfileInUsers,
|
||||
updateCreatedAvatar: peopleStore.targetUserStore.updateCreatedAvatar,
|
||||
}))(observer(withRouter(withTranslation()(CreateUserForm))))
|
||||
);
|
||||
|
||||
// export default connect(mapStateToProps, {
|
||||
// createProfile,
|
||||
// updateCreatedAvatar,
|
||||
// setFilter,
|
||||
// updateProfileInUsers,
|
||||
// setIsVisibleDataLossDialog,
|
||||
// setIsEditingForm,
|
||||
// toggleAvatarEditor,
|
||||
// setCreatedAvatar,
|
||||
// setCroppedAvatar,
|
||||
// resetProfile,
|
||||
// })(withRouter(withTranslation()(CreateUserFormWrapper)));
|
||||
}))(observer(withRouter(withTranslation()(CreateUserForm))));
|
||||
|
@ -1,6 +1,5 @@
|
||||
import React from "react";
|
||||
import { withRouter } from "react-router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
Avatar,
|
||||
Button,
|
||||
@ -11,29 +10,7 @@ import {
|
||||
utils,
|
||||
} from "asc-web-components";
|
||||
import { withTranslation, Trans } from "react-i18next";
|
||||
import {
|
||||
toEmployeeWrapper,
|
||||
getUserRole,
|
||||
getUserContactsPattern,
|
||||
getUserContacts,
|
||||
mapGroupsToGroupSelectorOptions,
|
||||
mapGroupSelectorOptionsToGroups,
|
||||
filterGroupSelectorOptions,
|
||||
} from "../../../../../store/people/selectors";
|
||||
import {
|
||||
updateProfile,
|
||||
// getUserPhoto,
|
||||
fetchProfile,
|
||||
setAvatarMax,
|
||||
} from "../../../../../store/profile/actions";
|
||||
import {
|
||||
// setFilter,
|
||||
updateProfileInUsers,
|
||||
setIsVisibleDataLossDialog,
|
||||
setIsEditingForm,
|
||||
toggleAvatarEditor,
|
||||
} from "../../../../../store/people/actions";
|
||||
import { getDisableProfileType } from "../../../../../store/profile/selectors";
|
||||
|
||||
import {
|
||||
MainContainer,
|
||||
AvatarContainer,
|
||||
@ -48,7 +25,7 @@ import ContactsField from "./FormFields/ContactsField";
|
||||
import InfoFieldContainer from "./FormFields/InfoFieldContainer";
|
||||
import styled from "styled-components";
|
||||
import { DataLossWarningDialog } from "../../../../dialogs";
|
||||
import { api, toastr, store } from "asc-web-common";
|
||||
import { api, toastr } from "asc-web-common";
|
||||
import {
|
||||
ChangeEmailDialog,
|
||||
ChangePasswordDialog,
|
||||
@ -56,11 +33,18 @@ import {
|
||||
} from "../../../../dialogs";
|
||||
import { isMobile } from "react-device-detect";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import {
|
||||
filterGroupSelectorOptions,
|
||||
getUserContacts,
|
||||
getUserContactsPattern,
|
||||
getUserRole,
|
||||
mapGroupSelectorOptionsToGroups,
|
||||
mapGroupsToGroupSelectorOptions,
|
||||
toEmployeeWrapper,
|
||||
} from "../../../../../helpers/people-helpers";
|
||||
|
||||
const { createThumbnailsAvatar, loadAvatar, deleteAvatar } = api.people;
|
||||
const { isTablet } = utils.device;
|
||||
const { isAdmin } = store.auth.selectors;
|
||||
const { settingsStore } = store;
|
||||
|
||||
const dialogsDataset = {
|
||||
changeEmail: "changeEmail",
|
||||
@ -913,21 +897,7 @@ class UpdateUserForm extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
// profile: state.profile.targetUser,
|
||||
//avatarMax: state.profile.avatarMax,
|
||||
//settings: state.auth.settings,
|
||||
//groups: state.people.groups,
|
||||
//editingForm: state.people.editingForm,
|
||||
//filter: state.people.filter,
|
||||
// disableProfileType: getDisableProfileType(state),
|
||||
// isAdmin: isAdmin(state),
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
settings: auth.settingsStore,
|
||||
isAdmin: auth.isAdmin,
|
||||
groups: peopleStore.groupsStore.groups,
|
||||
@ -946,5 +916,4 @@ export default connect(mapStateToProps)(
|
||||
updateProfile: peopleStore.targetUserStore.updateProfile,
|
||||
getUserPhoto: peopleStore.targetUserStore.getUserPhoto,
|
||||
disableProfileType: peopleStore.targetUserStore.getDisableProfileType,
|
||||
}))(observer(withRouter(withTranslation()(UpdateUserForm))))
|
||||
);
|
||||
}))(observer(withRouter(withTranslation()(UpdateUserForm))));
|
||||
|
@ -1,20 +1,11 @@
|
||||
import React, { useCallback } from "react";
|
||||
import styled from "styled-components";
|
||||
import { connect } from "react-redux";
|
||||
import { withRouter } from "react-router";
|
||||
import { IconButton } from "asc-web-components";
|
||||
import { Headline, store } from "asc-web-common";
|
||||
import { Headline } from "asc-web-common";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
//setFilter,
|
||||
setIsVisibleDataLossDialog,
|
||||
toggleAvatarEditor,
|
||||
} from "../../../../../store/people/actions";
|
||||
import { resetProfile } from "../../../../../store/profile/actions";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const { settingsStore } = store;
|
||||
|
||||
const Wrapper = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr auto auto;
|
||||
@ -67,15 +58,18 @@ const SectionHeaderContent = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const setFilterAndReset = (filter) => {
|
||||
const setFilterAndReset = useCallback(
|
||||
(filter) => {
|
||||
props.resetProfile();
|
||||
setFilter(filter);
|
||||
};
|
||||
},
|
||||
[props, setFilter]
|
||||
);
|
||||
|
||||
const goBackAndReset = () => {
|
||||
const goBackAndReset = useCallback(() => {
|
||||
props.resetProfile();
|
||||
history.goBack();
|
||||
};
|
||||
}, [history, props]);
|
||||
|
||||
const onClickBack = useCallback(() => {
|
||||
avatarEditorIsOpen
|
||||
@ -84,12 +78,12 @@ const SectionHeaderContent = (props) => {
|
||||
? setFilterAndReset(filter)
|
||||
: goBackAndReset();
|
||||
}, [
|
||||
history,
|
||||
profile,
|
||||
setFilter,
|
||||
filter,
|
||||
//settings.homepage,
|
||||
avatarEditorIsOpen,
|
||||
toggleAvatarEditor,
|
||||
profile,
|
||||
setFilterAndReset,
|
||||
filter,
|
||||
goBackAndReset,
|
||||
]);
|
||||
return (
|
||||
<Wrapper>
|
||||
@ -109,27 +103,7 @@ const SectionHeaderContent = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
// profile: state.profile.targetUser,
|
||||
//settings: state.auth.settings,
|
||||
//filter: state.people.filter,
|
||||
//editingForm: state.people.editingForm,
|
||||
// avatarEditorIsOpen: state.people.avatarEditorIsOpen,
|
||||
};
|
||||
}
|
||||
|
||||
// const SectionHeaderContentWrapper = observer((props) => {
|
||||
// return <SectionHeaderContent settings={settingsStore.settings} {...props} />;
|
||||
// });
|
||||
|
||||
export default connect(mapStateToProps, {
|
||||
//setFilter,
|
||||
//setIsVisibleDataLossDialog,
|
||||
// toggleAvatarEditor,
|
||||
// resetProfile,
|
||||
})(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
settings: auth.settingsStore,
|
||||
isEdit: peopleStore.editingFormStore.isEdit,
|
||||
setIsVisibleDataLossDialog:
|
||||
@ -140,12 +114,4 @@ export default connect(mapStateToProps, {
|
||||
resetProfile: peopleStore.targetUserStore.resetTargetUser,
|
||||
profile: peopleStore.targetUserStore.targetUser,
|
||||
avatarEditorIsOpen: peopleStore.avatarEditorStore.visible,
|
||||
}))(observer(withRouter(SectionHeaderContent)))
|
||||
);
|
||||
|
||||
// export default connect(mapStateToProps, {
|
||||
// setFilter,
|
||||
// setIsVisibleDataLossDialog,
|
||||
// toggleAvatarEditor,
|
||||
// resetProfile,
|
||||
// })(withRouter(SectionHeaderContentWrapper));
|
||||
}))(observer(withRouter(SectionHeaderContent)));
|
||||
|
@ -1,7 +1,5 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import PropTypes from "prop-types";
|
||||
import { Loader } from "asc-web-components";
|
||||
import { PageLayout, utils, store, Loaders } from "asc-web-common";
|
||||
import {
|
||||
ArticleHeaderContent,
|
||||
@ -15,11 +13,8 @@ import {
|
||||
AvatarEditorPage,
|
||||
CreateAvatarEditorPage,
|
||||
} from "./Section";
|
||||
import { fetchProfile } from "../../../store/profile/actions";
|
||||
import { setIsEditingForm } from "../../../store/people/actions";
|
||||
import { I18nextProvider, withTranslation } from "react-i18next";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
import { setDocumentTitle } from "../../../helpers/utils";
|
||||
import { withRouter } from "react-router";
|
||||
import { inject, observer } from "mobx-react";
|
||||
const i18n = createI18N({
|
||||
@ -27,11 +22,17 @@ const i18n = createI18N({
|
||||
localesPath: "pages/ProfileAction",
|
||||
});
|
||||
const { changeLanguage } = utils;
|
||||
const { isAdmin } = store.auth.selectors;
|
||||
|
||||
class ProfileAction extends React.Component {
|
||||
componentDidMount() {
|
||||
const { match, fetchProfile, isEdit, setIsEditingForm, t } = this.props;
|
||||
const {
|
||||
match,
|
||||
fetchProfile,
|
||||
isEdit,
|
||||
setIsEditingForm,
|
||||
t,
|
||||
setDocumentTitle,
|
||||
} = this.props;
|
||||
const { userId } = match.params;
|
||||
|
||||
setDocumentTitle(t("ProfileAction"));
|
||||
@ -140,21 +141,8 @@ const ProfileActionContainer = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
// isVisitor: state.auth.user.isVisitor,
|
||||
// profile: state.profile.targetUser,
|
||||
// isAdmin: isAdmin(state),
|
||||
//isEdit: state.people.editingForm.isEdit,
|
||||
// avatarEditorIsOpen: state.people.avatarEditorIsOpen,
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, {
|
||||
/*fetchProfile*/
|
||||
/*setIsEditingForm*/
|
||||
})(
|
||||
inject(({ auth, peopleStore }) => ({
|
||||
export default inject(({ auth, peopleStore }) => ({
|
||||
setDocumentTitle: auth.setDocumentTitle,
|
||||
isAdmin: auth.isAdmin,
|
||||
isVisitor: auth.userStore.user.isVisitor,
|
||||
isEdit: peopleStore.editingFormStore.isEdit,
|
||||
@ -162,5 +150,4 @@ export default connect(mapStateToProps, {
|
||||
fetchProfile: peopleStore.targetUserStore.getTargetUser,
|
||||
profile: peopleStore.targetUserStore.targetUser,
|
||||
avatarEditorIsOpen: peopleStore.avatarEditorStore.visible,
|
||||
}))(observer(ProfileActionContainer))
|
||||
);
|
||||
}))(observer(ProfileActionContainer));
|
||||
|
@ -1,7 +1,6 @@
|
||||
import React from "react";
|
||||
import { withRouter } from "react-router";
|
||||
// import { useTranslation } from 'react-i18next';
|
||||
import { connect } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
|
||||
const InfoContainer = styled.div`
|
||||
@ -14,8 +13,4 @@ const SectionBodyContent = (props) => {
|
||||
return <InfoContainer>See this feature in next version!</InfoContainer>;
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(withRouter(SectionBodyContent));
|
||||
export default withRouter(SectionBodyContent);
|
||||
|
@ -1,14 +1,11 @@
|
||||
import React, { useCallback } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import { IconButton } from "asc-web-components";
|
||||
import { Headline, store } from "asc-web-common";
|
||||
import { Headline } from "asc-web-common";
|
||||
import { withRouter } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import styled from "styled-components";
|
||||
import { inject, observer } from "mobx-react";
|
||||
|
||||
const { settingsStore } = store;
|
||||
|
||||
const Wrapper = styled.div`
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr auto auto;
|
||||
@ -57,23 +54,6 @@ const SectionHeaderContent = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
// profile: state.profile.targetUser,
|
||||
//settings: state.auth.settings,
|
||||
};
|
||||
}
|
||||
|
||||
// const SectionHeaderContentWrapper = observer((props) => {
|
||||
// return <SectionHeaderContent settings={settingsStore.settings} {...props} />;
|
||||
// });
|
||||
|
||||
export default connect(mapStateToProps)(
|
||||
inject(({ auth }) => ({
|
||||
export default inject(({ auth }) => ({
|
||||
settings: auth.settingsStore,
|
||||
}))(observer(withRouter(SectionHeaderContent)))
|
||||
);
|
||||
|
||||
// export default connect(mapStateToProps)(
|
||||
// withRouter(SectionHeaderContentWrapper)
|
||||
// );
|
||||
}))(observer(withRouter(SectionHeaderContent)));
|
||||
|
@ -1,14 +1,12 @@
|
||||
import React from "react";
|
||||
import { connect } from "react-redux";
|
||||
// import PropTypes from "prop-types";
|
||||
import { PageLayout, store } from "asc-web-common";
|
||||
import { PageLayout } from "asc-web-common";
|
||||
import {
|
||||
ArticleHeaderContent,
|
||||
ArticleMainButtonContent,
|
||||
ArticleBodyContent,
|
||||
} from "../../Article";
|
||||
// import { SectionHeaderContent } from './Section';
|
||||
// import { fetchProfile } from '../../../store/profile/actions';
|
||||
import { I18nextProvider } from "react-i18next";
|
||||
import { SectionHeaderContent, SectionBodyContent } from "./Section";
|
||||
import { createI18N } from "../../../helpers/i18n";
|
||||
@ -17,7 +15,6 @@ const i18n = createI18N({
|
||||
page: "Reassign",
|
||||
localesPath: "pages/Reassign",
|
||||
});
|
||||
const { isAdmin } = store.auth.selectors;
|
||||
|
||||
class Reassign extends React.Component {
|
||||
componentDidMount() {
|
||||
@ -87,15 +84,6 @@ Reassign.propTypes = {
|
||||
// fetchProfile: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
// function mapStateToProps(state) {
|
||||
// return {
|
||||
// isAdmin: isAdmin(state),
|
||||
// profile: state.profile.targetUser
|
||||
// };
|
||||
// }
|
||||
|
||||
// export default connect(mapStateToProps, {})(Reassign);
|
||||
|
||||
export default inject(({ auth }) => ({
|
||||
isAdmin: auth.isAdmin,
|
||||
}))(observer(Reassign));
|
||||
|
140
products/ASC.People/Client/src/helpers/people-helpers.js
Normal file
140
products/ASC.People/Client/src/helpers/people-helpers.js
Normal file
@ -0,0 +1,140 @@
|
||||
import { find, cloneDeep } from "lodash";
|
||||
import { constants, utils } from "asc-web-common";
|
||||
const { isAdmin } = utils;
|
||||
|
||||
const { EmployeeActivationStatus, EmployeeStatus } = constants;
|
||||
|
||||
export const getUserStatus = (user) => {
|
||||
if (
|
||||
user.status === EmployeeStatus.Active &&
|
||||
user.activationStatus === EmployeeActivationStatus.Activated
|
||||
) {
|
||||
return "normal";
|
||||
} else if (
|
||||
user.status === EmployeeStatus.Active &&
|
||||
user.activationStatus === EmployeeActivationStatus.Pending
|
||||
) {
|
||||
return "pending";
|
||||
} else if (user.status === EmployeeStatus.Disabled) {
|
||||
return "disabled";
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
};
|
||||
|
||||
export const getUserRole = (user) => {
|
||||
if (user.isOwner) return "owner";
|
||||
else if (isAdmin(user, "f4d98afd-d336-4332-8778-3c6945c81ea0"))
|
||||
//TODO: Change to People Product Id const
|
||||
return "admin";
|
||||
//TODO: Need refactoring
|
||||
else if (user.isVisitor) return "guest";
|
||||
else return "user";
|
||||
};
|
||||
|
||||
export const getUserContactsPattern = () => {
|
||||
return {
|
||||
contact: [
|
||||
{ type: "mail", icon: "MailIcon", link: "mailto:{0}" },
|
||||
{ type: "phone", icon: "PhoneIcon", link: "tel:{0}" },
|
||||
{ type: "mobphone", icon: "MobileIcon", link: "tel:{0}" },
|
||||
{ type: "gmail", icon: "GmailIcon", link: "mailto:{0}" },
|
||||
{ type: "skype", icon: "SkypeIcon", link: "skype:{0}?userinfo" },
|
||||
{ type: "msn", icon: "WindowsMsnIcon" },
|
||||
{ type: "icq", icon: "IcqIcon", link: "https://www.icq.com/people/{0}" },
|
||||
{ type: "jabber", icon: "JabberIcon" },
|
||||
{ type: "aim", icon: "AimIcon" },
|
||||
],
|
||||
social: [
|
||||
{
|
||||
type: "facebook",
|
||||
icon: "ShareFacebookIcon",
|
||||
link: "https://facebook.com/{0}",
|
||||
},
|
||||
{
|
||||
type: "livejournal",
|
||||
icon: "LivejournalIcon",
|
||||
link: "https://{0}.livejournal.com",
|
||||
},
|
||||
{ type: "myspace", icon: "MyspaceIcon", link: "https://myspace.com/{0}" },
|
||||
{
|
||||
type: "twitter",
|
||||
icon: "ShareTwitterIcon",
|
||||
link: "https://twitter.com/{0}",
|
||||
},
|
||||
{
|
||||
type: "blogger",
|
||||
icon: "BloggerIcon",
|
||||
link: "https://{0}.blogspot.com",
|
||||
},
|
||||
{ type: "yahoo", icon: "YahooIcon", link: "mailto:{0}@yahoo.com" },
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
export const getUserContacts = (contacts) => {
|
||||
const mapContacts = (a, b) => {
|
||||
return a
|
||||
.map((a) => ({ ...a, ...b.find(({ type }) => type === a.type) }))
|
||||
.filter((c) => c.icon);
|
||||
};
|
||||
|
||||
const info = {};
|
||||
const pattern = getUserContactsPattern();
|
||||
|
||||
info.contact = mapContacts(contacts, pattern.contact);
|
||||
info.social = mapContacts(contacts, pattern.social);
|
||||
|
||||
return info;
|
||||
};
|
||||
|
||||
export function getSelectedGroup(groups, selectedGroupId) {
|
||||
return find(groups, (group) => group.id === selectedGroupId);
|
||||
}
|
||||
|
||||
export function toEmployeeWrapper(profile) {
|
||||
const emptyData = {
|
||||
id: "",
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
password: "",
|
||||
birthday: "",
|
||||
sex: "male",
|
||||
workFrom: "",
|
||||
location: "",
|
||||
title: "",
|
||||
groups: [],
|
||||
notes: "",
|
||||
contacts: [],
|
||||
};
|
||||
|
||||
return cloneDeep({ ...emptyData, ...profile });
|
||||
}
|
||||
|
||||
export function mapGroupsToGroupSelectorOptions(groups) {
|
||||
return groups.map((group) => {
|
||||
return {
|
||||
key: group.id,
|
||||
label: group.name,
|
||||
manager: group.manager,
|
||||
total: 0,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function mapGroupSelectorOptionsToGroups(options) {
|
||||
return options.map((option) => {
|
||||
return {
|
||||
id: option.key,
|
||||
name: option.label,
|
||||
manager: option.manager,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function filterGroupSelectorOptions(options, template) {
|
||||
return options.filter((option) => {
|
||||
return template ? option.label.indexOf(template) > -1 : true;
|
||||
});
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
import { store as commonStore } from "asc-web-common";
|
||||
import store from "../store/store";
|
||||
|
||||
const { getCurrentProduct } = commonStore.auth.selectors;
|
||||
|
||||
export const setDocumentTitle = (subTitle = null) => {
|
||||
const state = store.getState();
|
||||
const { auth: commonState } = state;
|
||||
|
||||
const { isAuthenticated, settings } = commonState;
|
||||
const { organizationName } = settings;
|
||||
|
||||
let title;
|
||||
|
||||
const currentModule = getCurrentProduct(state);
|
||||
|
||||
if (subTitle) {
|
||||
if (isAuthenticated && currentModule) {
|
||||
title = subTitle + " - " + currentModule.title;
|
||||
} else {
|
||||
title = subTitle + " - " + organizationName;
|
||||
}
|
||||
} else if (currentModule && organizationName) {
|
||||
title = currentModule.title + " - " + organizationName;
|
||||
} else {
|
||||
title = organizationName;
|
||||
}
|
||||
|
||||
document.title = title;
|
||||
};
|
@ -1,24 +1,21 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import { Provider } from "react-redux";
|
||||
import store from "./store/store";
|
||||
import "./custom.scss";
|
||||
import App from "./App";
|
||||
import * as serviceWorker from "./serviceWorker";
|
||||
import { ErrorBoundary, store as commonStore } from "asc-web-common";
|
||||
import { Provider as MobxProvider } from "mobx-react";
|
||||
import { peopleStore } from "./store/";
|
||||
import PeopleStore from "./store/PeopleStore";
|
||||
|
||||
const { authStore } = commonStore;
|
||||
const peopleStore = new PeopleStore();
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<MobxProvider auth={authStore} peopleStore={peopleStore}>
|
||||
<ErrorBoundary>
|
||||
<App />
|
||||
</ErrorBoundary>
|
||||
</MobxProvider>
|
||||
</Provider>,
|
||||
</MobxProvider>,
|
||||
document.getElementById("root")
|
||||
);
|
||||
|
||||
|
@ -25,6 +25,7 @@ class FilterStore {
|
||||
setFilterParams: action,
|
||||
setFilterUrl: action,
|
||||
resetFilter: action,
|
||||
setFilter: action,
|
||||
});
|
||||
}
|
||||
|
||||
@ -68,11 +69,15 @@ class FilterStore {
|
||||
|
||||
setFilterParams = (data) => {
|
||||
this.setFilterUrl(data);
|
||||
return (this.filter = data);
|
||||
this.setFilter(data);
|
||||
};
|
||||
|
||||
resetFilter = () => {
|
||||
return (this.filter = Filter.getDefault());
|
||||
this.setFilter(Filter.getDefault());
|
||||
};
|
||||
|
||||
setFilter = (filter) => {
|
||||
this.filter = filter;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@ class InviteLinksStore {
|
||||
if (!isViewerAdmin) return Promise.resolve();
|
||||
|
||||
const res = await api.portal.getInvitationLinks();
|
||||
debugger;
|
||||
this.inviteLinks.userLink = res.userLink;
|
||||
this.inviteLinks.guestLink = res.guestLink;
|
||||
console.log(this.inviteLinks);
|
||||
|
@ -31,32 +31,23 @@ class PeopleStore {
|
||||
isLoading = false;
|
||||
|
||||
constructor() {
|
||||
this.setGroupsStore(new GroupsStore(this));
|
||||
this.setUsersStore(new UsersStore(this));
|
||||
this.setTargetUserStore(new TargetUserStore(this));
|
||||
this.setSelectedGroupStore(new SelectedGroupStore(this));
|
||||
this.setEditingFormStore(new EditingFormStore(this));
|
||||
this.setFilterStore(new FilterStore(this));
|
||||
this.setSelectionStore(new SelectionStore(this));
|
||||
this.setHeaderMenuStore(new HeaderMenuStore(this));
|
||||
this.setAvatarEditorStore(new AvatarEditorStore(this));
|
||||
this.setInviteLinksStore(new InviteLinksStore(this));
|
||||
this.groupsStore = new GroupsStore(this);
|
||||
this.usersStore = new UsersStore(this);
|
||||
this.targetUserStore = new TargetUserStore(this);
|
||||
this.selectedGroupStore = new SelectedGroupStore(this);
|
||||
this.editingFormStore = new EditingFormStore(this);
|
||||
this.filterStore = new FilterStore();
|
||||
this.selectionStore = new SelectionStore(this);
|
||||
this.headerMenuStore = new HeaderMenuStore(this);
|
||||
this.avatarEditorStore = new AvatarEditorStore(this);
|
||||
this.inviteLinksStore = new InviteLinksStore(this);
|
||||
|
||||
makeObservable(this, {
|
||||
isLoading: observable,
|
||||
setIsLoading: action,
|
||||
setGroupsStore: action,
|
||||
setUsersStore: action,
|
||||
setTargetUserStore: action,
|
||||
setSelectedGroupStore: action,
|
||||
setEditingFormStore: action,
|
||||
setFilterStore: action,
|
||||
setSelectionStore: action,
|
||||
setHeaderMenuStore: action,
|
||||
setAvatarEditorStore: action,
|
||||
setInviteLinksStore: action,
|
||||
init: action,
|
||||
isPeoplesAdmin: computed,
|
||||
resetFilter: action,
|
||||
});
|
||||
}
|
||||
|
||||
@ -89,36 +80,20 @@ class PeopleStore {
|
||||
this.isLoading = loading;
|
||||
};
|
||||
|
||||
setGroupsStore = (store) => {
|
||||
this.groupsStore = store;
|
||||
};
|
||||
setUsersStore = (store) => {
|
||||
this.usersStore = store;
|
||||
};
|
||||
setTargetUserStore = (store) => {
|
||||
this.targetUserStore = store;
|
||||
};
|
||||
setSelectedGroupStore = (store) => {
|
||||
this.selectedGroupStore = store;
|
||||
};
|
||||
setEditingFormStore = (store) => {
|
||||
this.editingFormStore = store;
|
||||
};
|
||||
setFilterStore = (store) => {
|
||||
this.filterStore = store;
|
||||
};
|
||||
setSelectionStore = (store) => {
|
||||
this.selectionStore = store;
|
||||
};
|
||||
setHeaderMenuStore = (store) => {
|
||||
this.headerMenuStore = store;
|
||||
};
|
||||
setAvatarEditorStore = (store) => {
|
||||
this.avatarEditorStore = store;
|
||||
};
|
||||
setInviteLinksStore = (store) => {
|
||||
this.inviteLinksStore = store;
|
||||
resetFilter = (withoutGroup = false) => {
|
||||
const { filter } = this.filterStore;
|
||||
const { getUsersList } = this.usersStore;
|
||||
let newFilter;
|
||||
|
||||
if (withoutGroup) {
|
||||
const { group } = filter;
|
||||
newFilter = filter.reset(group);
|
||||
} else {
|
||||
newFilter = filter.clone(true);
|
||||
}
|
||||
|
||||
return getUsersList(newFilter);
|
||||
};
|
||||
}
|
||||
|
||||
export default new PeopleStore();
|
||||
export default PeopleStore;
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { action, computed, makeObservable, observable } from "mobx";
|
||||
import { constants, store } from "asc-web-common";
|
||||
import { getUserStatus } from "../helpers/people-helpers";
|
||||
|
||||
const { EmployeeStatus, EmployeeActivationStatus } = constants;
|
||||
const { authStore } = store;
|
||||
@ -16,6 +17,7 @@ class SelectionStore {
|
||||
selectUser: action,
|
||||
deselectUser: action,
|
||||
selectAll: action,
|
||||
setSelection: action,
|
||||
clearSelection: action,
|
||||
selectByStatus: action,
|
||||
setSelected: action,
|
||||
@ -35,6 +37,10 @@ class SelectionStore {
|
||||
});
|
||||
}
|
||||
|
||||
setSelection = (selection) => {
|
||||
this.selection = selection;
|
||||
};
|
||||
|
||||
selectUser = (user) => {
|
||||
const u = user;
|
||||
return this.selection.push(u);
|
||||
@ -46,24 +52,55 @@ class SelectionStore {
|
||||
};
|
||||
|
||||
selectAll = () => {
|
||||
const list = this.peopleStore.usersStore.composePeopleList();
|
||||
this.selection = list;
|
||||
const list = this.peopleStore.usersStore.peopleList;
|
||||
this.setSelection(list);
|
||||
};
|
||||
|
||||
clearSelection = () => {
|
||||
return (this.selection = []);
|
||||
return this.setSelection([]);
|
||||
};
|
||||
|
||||
selectByStatus = (status) => {
|
||||
const list = this.peopleStore.usersStore
|
||||
.composePeopleList()
|
||||
.filter((u) => u.status === status);
|
||||
const list = this.peopleStore.usersStore.peopleList.filter(
|
||||
(u) => u.status === status
|
||||
);
|
||||
|
||||
return (this.selection = list);
|
||||
};
|
||||
|
||||
getUserChecked = (user, selected) => {
|
||||
const status = getUserStatus(user);
|
||||
switch (selected) {
|
||||
case "all":
|
||||
return true;
|
||||
case "active":
|
||||
return status === "normal";
|
||||
case "disabled":
|
||||
return status === "disabled";
|
||||
case "invited":
|
||||
return status === "pending";
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
getUsersBySelected = (users, selected) => {
|
||||
let newSelection = [];
|
||||
users.forEach((user) => {
|
||||
const checked = this.getUserChecked(user, selected);
|
||||
|
||||
if (checked) newSelection.push(user);
|
||||
});
|
||||
|
||||
return newSelection;
|
||||
};
|
||||
|
||||
setSelected = (selected) => {
|
||||
return (this.selected = selected);
|
||||
this.selected = selected;
|
||||
const list = this.peopleStore.usersStore.peopleList;
|
||||
this.setSelection(this.getUsersBySelected(list, selected));
|
||||
|
||||
return selected;
|
||||
};
|
||||
|
||||
get hasAnybodySelected() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { action, makeObservable, observable } from "mobx";
|
||||
import { action, computed, makeObservable, observable } from "mobx";
|
||||
import { api, constants, store } from "asc-web-common";
|
||||
import { isMobileOnly } from "react-device-detect";
|
||||
|
||||
@ -19,6 +19,7 @@ class UsersStore {
|
||||
updateUserStatus: action,
|
||||
updateUserType: action,
|
||||
updateProfileInUsers: action,
|
||||
peopleList: computed,
|
||||
});
|
||||
}
|
||||
|
||||
@ -37,7 +38,6 @@ class UsersStore {
|
||||
this.peopleStore.selectedGroupStore.setSelectedGroup(filterData.group);
|
||||
|
||||
this.users = res.items;
|
||||
console.log("user: ", this.users.length);
|
||||
};
|
||||
|
||||
setUsers = (users) => {
|
||||
@ -201,7 +201,7 @@ class UsersStore {
|
||||
return this.peopleStore.selectionStore.selection.some((el) => el.id === id);
|
||||
};
|
||||
|
||||
composePeopleList = () => {
|
||||
get peopleList() {
|
||||
const list = this.users.map((user) => {
|
||||
const {
|
||||
id,
|
||||
@ -251,7 +251,7 @@ class UsersStore {
|
||||
});
|
||||
|
||||
return list;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default UsersStore;
|
||||
|
@ -1,76 +0,0 @@
|
||||
// import { setGroups, fetchPeople } from "../people/actions";
|
||||
// import { api } from "asc-web-common";
|
||||
|
||||
// export const SET_GROUP = "SET_GROUP";
|
||||
// export const CLEAN_GROUP = "CLEAN_GROUP";
|
||||
|
||||
// export function setGroup(targetGroup) {
|
||||
// return {
|
||||
// type: SET_GROUP,
|
||||
// targetGroup,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function resetGroup() {
|
||||
// return {
|
||||
// type: CLEAN_GROUP,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function fetchGroup(groupId) {
|
||||
// return (dispatch) => {
|
||||
// api.groups
|
||||
// .getGroup(groupId)
|
||||
// .then((group) => dispatch(setGroup(group || null)));
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function createGroup(groupName, groupManager, members) {
|
||||
// return (dispatch, getState) => {
|
||||
// const { people } = getState();
|
||||
// const { groups } = people;
|
||||
|
||||
// return api.groups
|
||||
// .createGroup(groupName, groupManager, members)
|
||||
// .then((newGroup) => {
|
||||
// dispatch(resetGroup());
|
||||
// dispatch(setGroups([...groups, newGroup]));
|
||||
// return Promise.resolve(newGroup);
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function updateGroup(id, groupName, groupManager, members) {
|
||||
// return (dispatch, getState) => {
|
||||
// const { people } = getState();
|
||||
// const { groups } = people;
|
||||
|
||||
// return api.groups
|
||||
// .updateGroup(id, groupName, groupManager, members)
|
||||
// .then((newGroup) => {
|
||||
// dispatch(resetGroup());
|
||||
// const newGroups = groups.map((g) =>
|
||||
// g.id === newGroup.id ? newGroup : g
|
||||
// );
|
||||
// dispatch(setGroups(newGroups));
|
||||
// return Promise.resolve(newGroup);
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function deleteGroup(id) {
|
||||
// return (dispatch, getState) => {
|
||||
// const { people } = getState();
|
||||
// const { groups, filter } = people;
|
||||
|
||||
// return api.groups
|
||||
// .deleteGroup(id)
|
||||
// .then((res) => {
|
||||
// return dispatch(setGroups(groups.filter((g) => g.id !== id)));
|
||||
// })
|
||||
// .then(() => {
|
||||
// const newFilter = filter.clone(true);
|
||||
// return fetchPeople(newFilter, dispatch);
|
||||
// });
|
||||
// };
|
||||
// }
|
@ -1,20 +0,0 @@
|
||||
// import { SET_GROUP, CLEAN_GROUP } from "./actions";
|
||||
|
||||
// const initialState = {
|
||||
// targetGroup: null,
|
||||
// };
|
||||
|
||||
// const groupReducer = (state = initialState, action) => {
|
||||
// switch (action.type) {
|
||||
// case SET_GROUP:
|
||||
// return Object.assign({}, state, {
|
||||
// targetGroup: action.targetGroup,
|
||||
// });
|
||||
// case CLEAN_GROUP:
|
||||
// return initialState;
|
||||
// default:
|
||||
// return state;
|
||||
// }
|
||||
// };
|
||||
|
||||
// export default groupReducer;
|
@ -1,4 +0,0 @@
|
||||
import { store } from "asc-web-common";
|
||||
import peopleStore from "./PeopleStore";
|
||||
|
||||
export { store, peopleStore };
|
@ -1,318 +0,0 @@
|
||||
// import { api, /*history,*/ constants } from "asc-web-common";
|
||||
// import config from "../../../package.json";
|
||||
// import {
|
||||
// EMPLOYEE_STATUS,
|
||||
// ACTIVATION_STATUS,
|
||||
// ROLE,
|
||||
// GROUP,
|
||||
// SEARCH,
|
||||
// SORT_BY,
|
||||
// SORT_ORDER,
|
||||
// PAGE,
|
||||
// PAGE_COUNT,
|
||||
// } from "../../helpers/constants";
|
||||
// import { getUserByUserName } from "../people/selectors";
|
||||
|
||||
// const { EmployeeStatus } = constants;
|
||||
// const { Filter } = api;
|
||||
|
||||
// export const SET_GROUPS = "SET_GROUPS";
|
||||
// export const SET_USERS = "SET_USERS";
|
||||
// export const SET_USER = "SET_USER";
|
||||
// export const SET_SELECTION = "SET_SELECTION";
|
||||
// export const SELECT_USER = "SELECT_USER";
|
||||
// export const DESELECT_USER = "DESELECT_USER";
|
||||
// export const SET_SELECTED = "SET_SELECTED";
|
||||
// export const SET_FILTER = "SET_FILTER";
|
||||
// export const SELECT_GROUP = "SELECT_GROUP";
|
||||
// export const SET_SELECTOR_USERS = "SET_SELECTOR_USERS";
|
||||
// export const SET_IS_VISIBLE_DATA_LOSS_DIALOG =
|
||||
// "SET_IS_VISIBLE_DATA_LOSS_DIALOG";
|
||||
// export const SET_IS_EDITING_FORM = "SET_IS_EDITING_FORM";
|
||||
// export const SET_IS_LOADING = "SET_IS_LOADING";
|
||||
// export const TOGGLE_AVATAR_EDITOR = "TOGGLE_AVATAR_EDITOR";
|
||||
|
||||
// export function setIsLoading(isLoading) {
|
||||
// return {
|
||||
// type: SET_IS_LOADING,
|
||||
// isLoading,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setUser(user) {
|
||||
// return {
|
||||
// type: SET_USER,
|
||||
// user,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setUsers(users) {
|
||||
// return {
|
||||
// type: SET_USERS,
|
||||
// users,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setGroups(groups) {
|
||||
// return {
|
||||
// type: SET_GROUPS,
|
||||
// groups,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setSelection(selection) {
|
||||
// return {
|
||||
// type: SET_SELECTION,
|
||||
// selection,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setSelected(selected) {
|
||||
// return {
|
||||
// type: SET_SELECTED,
|
||||
// selected,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function selectGroup(groupId) {
|
||||
// return (dispatch, getState) => {
|
||||
// const { people } = getState();
|
||||
// const { filter } = people;
|
||||
|
||||
// let newFilter = filter.clone();
|
||||
// newFilter.group = groupId;
|
||||
|
||||
// return fetchPeople(newFilter, dispatch);
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function selectUser(user) {
|
||||
// return {
|
||||
// type: SELECT_USER,
|
||||
// user,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function deselectUser(user) {
|
||||
// return {
|
||||
// type: DESELECT_USER,
|
||||
// user,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function toggleAvatarEditor(avatarEditorIsOpen) {
|
||||
// return {
|
||||
// type: TOGGLE_AVATAR_EDITOR,
|
||||
// avatarEditorIsOpen,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setFilterUrl(filter) {
|
||||
// const defaultFilter = Filter.getDefault();
|
||||
// const params = [];
|
||||
|
||||
// if (filter.employeeStatus) {
|
||||
// params.push(`${EMPLOYEE_STATUS}=${filter.employeeStatus}`);
|
||||
// }
|
||||
|
||||
// if (filter.activationStatus) {
|
||||
// params.push(`${ACTIVATION_STATUS}=${filter.activationStatus}`);
|
||||
// }
|
||||
|
||||
// if (filter.role) {
|
||||
// params.push(`${ROLE}=${filter.role}`);
|
||||
// }
|
||||
|
||||
// if (filter.group) {
|
||||
// params.push(`${GROUP}=${filter.group}`);
|
||||
// }
|
||||
|
||||
// if (filter.search) {
|
||||
// params.push(`${SEARCH}=${filter.search.trim()}`);
|
||||
// }
|
||||
|
||||
// if (filter.pageCount !== defaultFilter.pageCount) {
|
||||
// params.push(`${PAGE_COUNT}=${filter.pageCount}`);
|
||||
// }
|
||||
|
||||
// params.push(`${PAGE}=${filter.page + 1}`);
|
||||
// params.push(`${SORT_BY}=${filter.sortBy}`);
|
||||
// params.push(`${SORT_ORDER}=${filter.sortOrder}`);
|
||||
|
||||
// //const isProfileView = history.location.pathname.includes('/people/view') || history.location.pathname.includes('/people/edit');
|
||||
// //if (params.length > 0 && !isProfileView) {
|
||||
// history.push(`${config.homepage}/filter?${params.join("&")}`);
|
||||
// //}
|
||||
// }
|
||||
|
||||
// export function setFilter(filter) {
|
||||
// setFilterUrl(filter);
|
||||
// return {
|
||||
// type: SET_FILTER,
|
||||
// filter,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setSelectorUsers(users) {
|
||||
// return {
|
||||
// type: SET_SELECTOR_USERS,
|
||||
// users,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setIsVisibleDataLossDialog(isVisible, callback) {
|
||||
// return {
|
||||
// type: SET_IS_VISIBLE_DATA_LOSS_DIALOG,
|
||||
// isVisible,
|
||||
// callback,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setIsEditingForm(isEdit) {
|
||||
// return {
|
||||
// type: SET_IS_EDITING_FORM,
|
||||
// isEdit,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function fetchSelectorUsers() {
|
||||
// return (dispatch) => {
|
||||
// api.people.getSelectorUserList().then((data) => {
|
||||
// const users = data.items;
|
||||
// return dispatch(setSelectorUsers(users));
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function fetchGroups(dispatchFunc = null) {
|
||||
// return api.groups.getGroupList().then((groups) => {
|
||||
// return dispatchFunc
|
||||
// ? dispatchFunc(setGroups(groups))
|
||||
// : Promise.resolve((dispatch) => dispatch(setGroups(groups)));
|
||||
// });
|
||||
// }
|
||||
|
||||
// export function fetchPeople(filter, dispatchFunc = null) {
|
||||
// return dispatchFunc
|
||||
// ? fetchPeopleByFilter(dispatchFunc, filter)
|
||||
// : (dispatch, getState) => {
|
||||
// if (filter) {
|
||||
// return fetchPeopleByFilter(dispatch, filter);
|
||||
// } else {
|
||||
// const { people } = getState();
|
||||
// const { filter } = people;
|
||||
// return fetchPeopleByFilter(dispatch, filter);
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function removeUser(userId, filter) {
|
||||
// return (dispatch) => {
|
||||
// return api.people
|
||||
// .deleteUsers(userId)
|
||||
// .then(() => fetchPeople(filter, dispatch));
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function updateUserList(dispatch, filter) {
|
||||
// let filterData = filter && filter.clone();
|
||||
// if (!filterData) {
|
||||
// filterData = Filter.getDefault();
|
||||
// filterData.employeeStatus = EmployeeStatus.Active;
|
||||
// }
|
||||
// return api.people.getUserList(filterData).then((data) => {
|
||||
// return dispatch(setUsers(data.items));
|
||||
// });
|
||||
// }
|
||||
|
||||
// function fetchPeopleByFilter(dispatch, filter) {
|
||||
// let filterData = filter && filter.clone();
|
||||
|
||||
// if (!filterData) {
|
||||
// filterData = Filter.getDefault();
|
||||
// filterData.employeeStatus = EmployeeStatus.Active;
|
||||
// }
|
||||
|
||||
// return api.people.getUserList(filterData).then((data) => {
|
||||
// filterData.total = data.total;
|
||||
// dispatch(setFilter(filterData));
|
||||
// dispatch({
|
||||
// type: SELECT_GROUP,
|
||||
// groupId: filterData.group,
|
||||
// });
|
||||
// return dispatch(setUsers(data.items));
|
||||
// });
|
||||
// }
|
||||
|
||||
// export function updateUserStatus(status, userIds, isRefetchPeople = false) {
|
||||
// return (dispatch, getState) => {
|
||||
// return api.people.updateUserStatus(status, userIds).then((users) => {
|
||||
// const { people } = getState();
|
||||
// const { filter } = people;
|
||||
// return isRefetchPeople
|
||||
// ? fetchPeople(filter, dispatch)
|
||||
// : Promise.resolve();
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function updateUserType(type, userIds) {
|
||||
// return (dispatch) => {
|
||||
// return api.people.updateUserType(type, userIds).then((users) => {
|
||||
// users.forEach((user) => {
|
||||
// dispatch(setUser(user));
|
||||
// });
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function resetFilter() {
|
||||
// return (dispatch, getState) => {
|
||||
// const { people } = getState();
|
||||
// const { filter } = people;
|
||||
|
||||
// const newFilter = filter.clone(true);
|
||||
|
||||
// return fetchPeople(newFilter, dispatch);
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function updateProfileInUsers(updatedProfile) {
|
||||
// return (dispatch, getState) => {
|
||||
// const { people } = getState();
|
||||
// const { users } = people;
|
||||
|
||||
// if (!users) {
|
||||
// return updateUserList(dispatch);
|
||||
// }
|
||||
|
||||
// if (!updatedProfile) {
|
||||
// const { profile } = getState();
|
||||
// updatedProfile = profile.targetUser;
|
||||
// }
|
||||
|
||||
// const { userName } = updatedProfile;
|
||||
// const oldProfile = getUserByUserName(users, userName);
|
||||
// const newProfile = {};
|
||||
|
||||
// for (let key in oldProfile) {
|
||||
// if (
|
||||
// updatedProfile.hasOwnProperty(key) &&
|
||||
// updatedProfile[key] !== oldProfile[key]
|
||||
// ) {
|
||||
// newProfile[key] = updatedProfile[key];
|
||||
// } else {
|
||||
// newProfile[key] = oldProfile[key];
|
||||
// }
|
||||
// }
|
||||
|
||||
// const updatedUsers = users.map((user) => {
|
||||
// if (user.id === newProfile.id) {
|
||||
// return newProfile;
|
||||
// } else {
|
||||
// return user;
|
||||
// }
|
||||
// });
|
||||
// return dispatch(setUsers(updatedUsers));
|
||||
// };
|
||||
// }
|
@ -1,117 +0,0 @@
|
||||
// import {
|
||||
// SET_GROUPS,
|
||||
// SET_USERS,
|
||||
// SET_SELECTION,
|
||||
// SELECT_USER,
|
||||
// DESELECT_USER,
|
||||
// SET_SELECTED,
|
||||
// SET_FILTER,
|
||||
// SELECT_GROUP,
|
||||
// SET_USER,
|
||||
// SET_SELECTOR_USERS,
|
||||
// SET_IS_VISIBLE_DATA_LOSS_DIALOG,
|
||||
// SET_IS_EDITING_FORM,
|
||||
// SET_IS_LOADING,
|
||||
// TOGGLE_AVATAR_EDITOR,
|
||||
// } from "./actions";
|
||||
// import { isUserSelected, skipUser, getUsersBySelected } from "./selectors";
|
||||
import { api } from "asc-web-common";
|
||||
const { Filter } = api;
|
||||
|
||||
const initialState = {
|
||||
users: null,
|
||||
groups: [],
|
||||
selection: [],
|
||||
selected: "none",
|
||||
selectedGroup: null,
|
||||
filter: Filter.getDefault(),
|
||||
avatarEditorIsOpen: false,
|
||||
selector: {
|
||||
users: [],
|
||||
},
|
||||
editingForm: {
|
||||
isEdit: false,
|
||||
isVisibleDataLossDialog: false,
|
||||
},
|
||||
isLoading: false,
|
||||
};
|
||||
const peopleReducer = (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
// case SET_GROUPS:
|
||||
// return Object.assign({}, state, {
|
||||
// groups: action.groups,
|
||||
// });
|
||||
// case SET_USERS:
|
||||
// return Object.assign({}, state, {
|
||||
// users: action.users,
|
||||
// });
|
||||
// case SET_USER:
|
||||
// return Object.assign({}, state, {
|
||||
// users: state.users.map((user) =>
|
||||
// user.id === action.user.id ? action.user : user
|
||||
// ),
|
||||
// });
|
||||
// case SET_SELECTION:
|
||||
// return Object.assign({}, state, {
|
||||
// selection: action.selection,
|
||||
// });
|
||||
// case SELECT_USER:
|
||||
// if (!isUserSelected(state.selection, action.user.id)) {
|
||||
// return Object.assign({}, state, {
|
||||
// selection: [...state.selection, action.user],
|
||||
// });
|
||||
// } else return state;
|
||||
// case DESELECT_USER:
|
||||
// if (isUserSelected(state.selection, action.user.id)) {
|
||||
// return Object.assign({}, state, {
|
||||
// selection: skipUser(state.selection, action.user.id),
|
||||
// });
|
||||
// } else return state;
|
||||
// case SET_SELECTED:
|
||||
// return Object.assign({}, state, {
|
||||
// selected: action.selected,
|
||||
// selection: getUsersBySelected(state.users, action.selected),
|
||||
// });
|
||||
// case SET_FILTER:
|
||||
// return Object.assign({}, state, {
|
||||
// filter: action.filter,
|
||||
// });
|
||||
// case SELECT_GROUP:
|
||||
// return Object.assign({}, state, {
|
||||
// selectedGroup: action.groupId,
|
||||
// });
|
||||
// case SET_SELECTOR_USERS:
|
||||
// return Object.assign({}, state, {
|
||||
// selector: Object.assign({}, state.selector, {
|
||||
// users: action.users,
|
||||
// }),
|
||||
// });
|
||||
// case SET_IS_VISIBLE_DATA_LOSS_DIALOG:
|
||||
// return Object.assign({}, state, {
|
||||
// editingForm: {
|
||||
// ...state.editingForm,
|
||||
// isVisibleDataLossDialog: action.isVisible,
|
||||
// callback: action.callback,
|
||||
// },
|
||||
// });
|
||||
// case SET_IS_EDITING_FORM:
|
||||
// return Object.assign({}, state, {
|
||||
// editingForm: {
|
||||
// ...state.editingForm,
|
||||
// isEdit: action.isEdit,
|
||||
// },
|
||||
// });
|
||||
// case TOGGLE_AVATAR_EDITOR:
|
||||
// return Object.assign({}, state, {
|
||||
// avatarEditorIsOpen: action.avatarEditorIsOpen,
|
||||
// });
|
||||
// case SET_IS_LOADING:
|
||||
// return Object.assign({}, state, {
|
||||
// isLoading: action.isLoading,
|
||||
// });
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default peopleReducer;
|
@ -1,440 +0,0 @@
|
||||
import { find, filter, cloneDeep } from "lodash";
|
||||
import { createSelector } from "reselect";
|
||||
import { store, constants } from "asc-web-common";
|
||||
import { isMobileOnly } from "react-device-detect";
|
||||
const { isAdmin, isMe, getCurrentUser } = store.auth.selectors;
|
||||
const { EmployeeActivationStatus, EmployeeStatus } = constants;
|
||||
|
||||
// export function getSelectedUser(selection, userId) {
|
||||
// return find(selection, function (obj) {
|
||||
// return obj.id === userId;
|
||||
// });
|
||||
// }
|
||||
|
||||
// export function getUserByUserName(users, userName) {
|
||||
// return find(users, function (obj) {
|
||||
// return obj.userName === userName;
|
||||
// });
|
||||
// }
|
||||
|
||||
// export function isUserSelected(selection, userId) {
|
||||
// return getSelectedUser(selection, userId) !== undefined;
|
||||
// }
|
||||
|
||||
// export function skipUser(selection, userId) {
|
||||
// return filter(selection, function (obj) {
|
||||
// return obj.id !== userId;
|
||||
// });
|
||||
// }
|
||||
|
||||
export const getUserStatus = (user) => {
|
||||
if (
|
||||
user.status === EmployeeStatus.Active &&
|
||||
user.activationStatus === EmployeeActivationStatus.Activated
|
||||
) {
|
||||
return "normal";
|
||||
} else if (
|
||||
user.status === EmployeeStatus.Active &&
|
||||
user.activationStatus === EmployeeActivationStatus.Pending
|
||||
) {
|
||||
return "pending";
|
||||
} else if (user.status === EmployeeStatus.Disabled) {
|
||||
return "disabled";
|
||||
} else {
|
||||
return "unknown";
|
||||
}
|
||||
};
|
||||
|
||||
export const getUserRole = (user) => {
|
||||
if (user.isOwner) return "owner";
|
||||
else if (isAdmin({ auth: { user } })) return "admin";
|
||||
//TODO: Need refactoring
|
||||
else if (user.isVisitor) return "guest";
|
||||
else return "user";
|
||||
};
|
||||
|
||||
export const getUserContactsPattern = () => {
|
||||
return {
|
||||
contact: [
|
||||
{ type: "mail", icon: "MailIcon", link: "mailto:{0}" },
|
||||
{ type: "phone", icon: "PhoneIcon", link: "tel:{0}" },
|
||||
{ type: "mobphone", icon: "MobileIcon", link: "tel:{0}" },
|
||||
{ type: "gmail", icon: "GmailIcon", link: "mailto:{0}" },
|
||||
{ type: "skype", icon: "SkypeIcon", link: "skype:{0}?userinfo" },
|
||||
{ type: "msn", icon: "WindowsMsnIcon" },
|
||||
{ type: "icq", icon: "IcqIcon", link: "https://www.icq.com/people/{0}" },
|
||||
{ type: "jabber", icon: "JabberIcon" },
|
||||
{ type: "aim", icon: "AimIcon" },
|
||||
],
|
||||
social: [
|
||||
{
|
||||
type: "facebook",
|
||||
icon: "ShareFacebookIcon",
|
||||
link: "https://facebook.com/{0}",
|
||||
},
|
||||
{
|
||||
type: "livejournal",
|
||||
icon: "LivejournalIcon",
|
||||
link: "https://{0}.livejournal.com",
|
||||
},
|
||||
{ type: "myspace", icon: "MyspaceIcon", link: "https://myspace.com/{0}" },
|
||||
{
|
||||
type: "twitter",
|
||||
icon: "ShareTwitterIcon",
|
||||
link: "https://twitter.com/{0}",
|
||||
},
|
||||
{
|
||||
type: "blogger",
|
||||
icon: "BloggerIcon",
|
||||
link: "https://{0}.blogspot.com",
|
||||
},
|
||||
{ type: "yahoo", icon: "YahooIcon", link: "mailto:{0}@yahoo.com" },
|
||||
],
|
||||
};
|
||||
};
|
||||
|
||||
export const getUserContacts = (contacts) => {
|
||||
const mapContacts = (a, b) => {
|
||||
return a
|
||||
.map((a) => ({ ...a, ...b.find(({ type }) => type === a.type) }))
|
||||
.filter((c) => c.icon);
|
||||
};
|
||||
|
||||
const info = {};
|
||||
const pattern = getUserContactsPattern();
|
||||
|
||||
info.contact = mapContacts(contacts, pattern.contact);
|
||||
info.social = mapContacts(contacts, pattern.social);
|
||||
|
||||
return info;
|
||||
};
|
||||
|
||||
// const getUserChecked = (user, selected) => {
|
||||
// const status = getUserStatus(user);
|
||||
// switch (selected) {
|
||||
// case "all":
|
||||
// return true;
|
||||
// case "active":
|
||||
// return status === "normal";
|
||||
// case "disabled":
|
||||
// return status === "disabled";
|
||||
// case "invited":
|
||||
// return status === "pending";
|
||||
// default:
|
||||
// return false;
|
||||
// }
|
||||
// };
|
||||
|
||||
// export function getUsersBySelected(users, selected) {
|
||||
// let newSelection = [];
|
||||
// users.forEach((user) => {
|
||||
// const checked = getUserChecked(user, selected);
|
||||
|
||||
// if (checked) newSelection.push(user);
|
||||
// });
|
||||
|
||||
// return newSelection;
|
||||
// }
|
||||
|
||||
// export function isUserDisabled(user) {
|
||||
// return getUserStatus(user) === "disabled";
|
||||
// }
|
||||
|
||||
export function getSelectedGroup(groups, selectedGroupId) {
|
||||
return find(groups, (group) => group.id === selectedGroupId);
|
||||
}
|
||||
|
||||
export function toEmployeeWrapper(profile) {
|
||||
const emptyData = {
|
||||
id: "",
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
password: "",
|
||||
birthday: "",
|
||||
sex: "male",
|
||||
workFrom: "",
|
||||
location: "",
|
||||
title: "",
|
||||
groups: [],
|
||||
notes: "",
|
||||
contacts: [],
|
||||
};
|
||||
|
||||
return cloneDeep({ ...emptyData, ...profile });
|
||||
}
|
||||
|
||||
export function mapGroupsToGroupSelectorOptions(groups) {
|
||||
return groups.map((group) => {
|
||||
return {
|
||||
key: group.id,
|
||||
label: group.name,
|
||||
manager: group.manager,
|
||||
total: 0,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function mapGroupSelectorOptionsToGroups(options) {
|
||||
return options.map((option) => {
|
||||
return {
|
||||
id: option.key,
|
||||
name: option.label,
|
||||
manager: option.manager,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function filterGroupSelectorOptions(options, template) {
|
||||
return options.filter((option) => {
|
||||
return template ? option.label.indexOf(template) > -1 : true;
|
||||
});
|
||||
}
|
||||
|
||||
// export const getIsLoading = (state) => {
|
||||
// return state.people.isLoading;
|
||||
// };
|
||||
|
||||
// export const getUsers = (state) => state.people.users || [];
|
||||
|
||||
// export const getSelection = (state) => state.people.selection;
|
||||
|
||||
// const getUserContextOptions = (
|
||||
// isMySelf,
|
||||
// isOwner,
|
||||
// statusType,
|
||||
// status,
|
||||
// hasMobileNumber
|
||||
// ) => {
|
||||
// const options = [];
|
||||
|
||||
// switch (statusType) {
|
||||
// case "normal":
|
||||
// case "unknown":
|
||||
// options.push("send-email");
|
||||
|
||||
// if (hasMobileNumber && isMobileOnly) {
|
||||
// options.push("send-message");
|
||||
// }
|
||||
|
||||
// options.push("separator");
|
||||
// options.push("edit");
|
||||
// options.push("change-password");
|
||||
// options.push("change-email");
|
||||
|
||||
// if (isMySelf) {
|
||||
// if (!isOwner) {
|
||||
// options.push("delete-self-profile");
|
||||
// }
|
||||
// } else {
|
||||
// options.push("disable");
|
||||
// }
|
||||
|
||||
// break;
|
||||
// case "disabled":
|
||||
// options.push("enable");
|
||||
// //TODO: Need implementation
|
||||
// /*options.push("reassign-data");
|
||||
// options.push("delete-personal-data");*/
|
||||
// options.push("delete-profile");
|
||||
// break;
|
||||
// case "pending":
|
||||
// options.push("edit");
|
||||
// options.push("invite-again");
|
||||
|
||||
// if (isMySelf) {
|
||||
// options.push("delete-profile");
|
||||
// } else {
|
||||
// if (status === EmployeeStatus.Active) {
|
||||
// options.push("disable");
|
||||
// } else {
|
||||
// options.push("enable");
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
// return options;
|
||||
// };
|
||||
|
||||
// export const getPeopleList = createSelector(
|
||||
// [getUsers, getSelection, isAdmin, getCurrentUser],
|
||||
// (users, selection, isViewerAdmin, viewer) => {
|
||||
// return users.map((user) => {
|
||||
// const {
|
||||
// id,
|
||||
// displayName,
|
||||
// avatar,
|
||||
// email,
|
||||
// isOwner,
|
||||
// isAdmin: isAdministrator,
|
||||
// isVisitor,
|
||||
// mobilePhone,
|
||||
// userName,
|
||||
// activationStatus,
|
||||
// status,
|
||||
// groups,
|
||||
// } = user;
|
||||
// const statusType = getUserStatus(user);
|
||||
// const role = getUserRole(user);
|
||||
// const isMySelf = isMe(user, viewer.userName);
|
||||
|
||||
// const options = getUserContextOptions(
|
||||
// isMySelf,
|
||||
// isOwner,
|
||||
// statusType,
|
||||
// status,
|
||||
// !!mobilePhone
|
||||
// );
|
||||
|
||||
// return {
|
||||
// id,
|
||||
// checked: isViewerAdmin ? isUserSelected(selection, user.id) : undefined,
|
||||
// status,
|
||||
// activationStatus,
|
||||
// statusType,
|
||||
// role,
|
||||
// isOwner,
|
||||
// isAdmin: isAdministrator,
|
||||
// isVisitor,
|
||||
// displayName,
|
||||
// avatar,
|
||||
// email,
|
||||
// userName,
|
||||
// mobilePhone,
|
||||
// options,
|
||||
// groups,
|
||||
// };
|
||||
// });
|
||||
// }
|
||||
// );
|
||||
|
||||
// const getUsersIds = (users) => {
|
||||
// return users.map((user) => {
|
||||
// return user.id;
|
||||
// });
|
||||
// };
|
||||
|
||||
// const hasAny = (users) => users && users.length > 0;
|
||||
|
||||
// export const hasAnybodySelected = createSelector([getSelection], hasAny);
|
||||
|
||||
// export const getUsersToMakeEmployees = createSelector(
|
||||
// [getSelection, getCurrentUser],
|
||||
// (selection, user) => {
|
||||
// //console.log("getUsersToMakeEmployees", selection, user);
|
||||
// return selection.filter(
|
||||
// (x) =>
|
||||
// !x.isAdmin &&
|
||||
// !x.isOwner &&
|
||||
// x.isVisitor &&
|
||||
// x.status !== EmployeeStatus.Disabled &&
|
||||
// x.id !== user.id
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
|
||||
// export const getUsersToMakeEmployeesIds = createSelector(
|
||||
// [getUsersToMakeEmployees],
|
||||
// getUsersIds
|
||||
// );
|
||||
|
||||
// export const hasUsersToMakeEmployees = createSelector(
|
||||
// [getUsersToMakeEmployees],
|
||||
// hasAny
|
||||
// );
|
||||
|
||||
// export const getUsersToMakeGuests = createSelector(
|
||||
// [getSelection, getCurrentUser],
|
||||
// (selection, user) => {
|
||||
// //console.log("getUsersToMakeGuests", selection, user);
|
||||
// return selection.filter(
|
||||
// (x) =>
|
||||
// !x.isAdmin &&
|
||||
// !x.isOwner &&
|
||||
// !x.isVisitor &&
|
||||
// x.status !== EmployeeStatus.Disabled &&
|
||||
// x.id !== user.id
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
|
||||
// export const getUsersToMakeGuestsIds = createSelector(
|
||||
// [getUsersToMakeGuests],
|
||||
// getUsersIds
|
||||
// );
|
||||
|
||||
// export const hasUsersToMakeGuests = createSelector(
|
||||
// [getUsersToMakeGuests],
|
||||
// hasAny
|
||||
// );
|
||||
|
||||
// export const getUsersToActivate = createSelector(
|
||||
// [getSelection, getCurrentUser],
|
||||
// (selection, user) => {
|
||||
//console.log("getUsersToActivate", selection, user);
|
||||
// return selection.filter(
|
||||
// (x) =>
|
||||
// !x.isOwner && x.status !== EmployeeStatus.Active && x.id !== user.id
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
|
||||
// export const getUsersToActivateIds = createSelector(
|
||||
// [getUsersToActivate],
|
||||
// getUsersIds
|
||||
// );
|
||||
|
||||
// export const hasUsersToActivate = createSelector([getUsersToActivate], hasAny);
|
||||
|
||||
// export const getUsersToDisable = createSelector(
|
||||
// [getSelection, getCurrentUser],
|
||||
// (selection, user) => {
|
||||
//console.log("getUsersToDisable", selection, user);
|
||||
// return selection.filter(
|
||||
// (x) =>
|
||||
// !x.isOwner && x.status !== EmployeeStatus.Disabled && x.id !== user.id
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
|
||||
// export const getUsersToDisableIds = createSelector(
|
||||
// [getUsersToDisable],
|
||||
// getUsersIds
|
||||
// );
|
||||
|
||||
// export const hasUsersToDisable = createSelector([getUsersToDisable], hasAny);
|
||||
|
||||
// export const getUsersToInvite = createSelector([getSelection], (selection) => {
|
||||
//console.log("getUsersToInvite", selection);
|
||||
// return selection.filter(
|
||||
// (x) =>
|
||||
// x.activationStatus === EmployeeActivationStatus.Pending &&
|
||||
// x.status === EmployeeStatus.Active
|
||||
// );
|
||||
// });
|
||||
|
||||
// export const getUsersToInviteIds = createSelector(
|
||||
// [getUsersToInvite],
|
||||
// getUsersIds
|
||||
// );
|
||||
|
||||
// export const hasUsersToInvite = createSelector([getUsersToInvite], hasAny);
|
||||
|
||||
// export const getUsersToRemove = createSelector([getSelection], (selection) => {
|
||||
//console.log("getUsersToRemove", selection);
|
||||
// return selection.filter((x) => x.status === EmployeeStatus.Disabled);
|
||||
// });
|
||||
|
||||
// export const getUsersToRemoveIds = createSelector(
|
||||
// [getUsersToRemove],
|
||||
// getUsersIds
|
||||
// );
|
||||
|
||||
// export const hasUsersToRemove = createSelector([getUsersToRemove], hasAny);
|
||||
|
||||
// export const getFilter = (state) => state.people.filter;
|
||||
|
||||
// export const getGroups = (state) => state.people.groups;
|
@ -1,24 +0,0 @@
|
||||
// import { api } from "asc-web-common";
|
||||
|
||||
// export const SET_INVITE_LINKS = "SET_INVITE_LINKS";
|
||||
|
||||
// export function setInviteLinks(userLink, guestLink) {
|
||||
// return {
|
||||
// type: SET_INVITE_LINKS,
|
||||
// payload: {
|
||||
// userLink,
|
||||
// guestLink,
|
||||
// },
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function getPortalInviteLinks() {
|
||||
// return (dispatch, getState) => {
|
||||
// const { auth } = getState();
|
||||
// if (!auth.user.isAdmin) return Promise.resolve();
|
||||
|
||||
// return api.portal.getInvitationLinks().then((data) => {
|
||||
// dispatch(setInviteLinks(data.userLink, data.guestLink));
|
||||
// });
|
||||
// };
|
||||
// }
|
@ -1,18 +0,0 @@
|
||||
// import { SET_INVITE_LINKS } from "./actions";
|
||||
|
||||
// const initialState = {
|
||||
// inviteLinks: {},
|
||||
// };
|
||||
|
||||
// const profileReducer = (state = initialState, action) => {
|
||||
// switch (action.type) {
|
||||
// case SET_INVITE_LINKS:
|
||||
// return Object.assign({}, state, {
|
||||
// inviteLinks: action.payload,
|
||||
// });
|
||||
// default:
|
||||
// return state;
|
||||
// }
|
||||
// };
|
||||
|
||||
// export default profileReducer;
|
@ -1,152 +0,0 @@
|
||||
// import { updateUserList } from "../people/actions";
|
||||
// import { store, api } from "asc-web-common";
|
||||
// const { setCurrentUser } = store.auth.actions;
|
||||
// const { isMe } = store.auth.selectors;
|
||||
|
||||
// export const SET_PROFILE = "SET_PROFILE";
|
||||
// export const CLEAN_PROFILE = "CLEAN_PROFILE";
|
||||
// export const SET_AVATAR_MAX = "SET_AVATAR_MAX";
|
||||
// export const SET_CREATED_AVATAR = "SET_CREATED_AVATAR";
|
||||
// export const SET_CROPPED_AVATAR = "SET_CROPPED_AVATAR";
|
||||
|
||||
// export function setProfile(targetUser) {
|
||||
// return {
|
||||
// type: SET_PROFILE,
|
||||
// targetUser,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function resetProfile() {
|
||||
// return {
|
||||
// type: CLEAN_PROFILE,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function employeeWrapperToMemberModel(profile) {
|
||||
// const comment = profile.notes;
|
||||
// const department = profile.groups
|
||||
// ? profile.groups.map((group) => group.id)
|
||||
// : [];
|
||||
// const worksFrom = profile.workFrom;
|
||||
|
||||
// return { ...profile, comment, department, worksFrom };
|
||||
// }
|
||||
|
||||
// export function fetchProfile(userName) {
|
||||
// return (dispatch, getState) => {
|
||||
// const { auth } = getState();
|
||||
|
||||
// if (isMe(auth.user, userName)) {
|
||||
// dispatch(setProfile(auth.user));
|
||||
// } else {
|
||||
// api.people.getUser(userName).then((user) => {
|
||||
// dispatch(setProfile(user));
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function createProfile(profile) {
|
||||
// return (dispatch, getState) => {
|
||||
// const { people } = getState();
|
||||
// const { filter } = people;
|
||||
// const member = employeeWrapperToMemberModel(profile);
|
||||
// let result;
|
||||
|
||||
// return api.people
|
||||
// .createUser(member)
|
||||
// .then((user) => {
|
||||
// result = user;
|
||||
// return dispatch(setProfile(user));
|
||||
// })
|
||||
// .then(() => {
|
||||
// return updateUserList(dispatch, filter);
|
||||
// })
|
||||
// .then(() => {
|
||||
// return Promise.resolve(result);
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function updateProfile(profile) {
|
||||
// debugger;
|
||||
// return (dispatch) => {
|
||||
// const member = employeeWrapperToMemberModel(profile);
|
||||
// let result;
|
||||
|
||||
// return api.people
|
||||
// .updateUser(member)
|
||||
// .then((user) => {
|
||||
// result = user;
|
||||
// return Promise.resolve(dispatch(setProfile(user)));
|
||||
// })
|
||||
// .then(() => {
|
||||
// return Promise.resolve(result);
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
// export function updateProfileCulture(id, culture) {
|
||||
// return (dispatch, getState) => {
|
||||
// return api.people
|
||||
// .updateUserCulture(id, culture)
|
||||
// .then((user) => {
|
||||
// dispatch(setCurrentUser(user));
|
||||
// return dispatch(setProfile(user));
|
||||
// })
|
||||
// .then(() => caches.delete("api-cache"))
|
||||
// .then(() => {
|
||||
// const { getCurrentCustomSchema, getModules } = store.auth.actions;
|
||||
// const state = getState();
|
||||
// const { nameSchemaId } = state.auth.settings;
|
||||
|
||||
// if (!nameSchemaId) return getModules();
|
||||
|
||||
// const requests = [
|
||||
// getModules(dispatch),
|
||||
// getCurrentCustomSchema(dispatch, nameSchemaId),
|
||||
// ];
|
||||
|
||||
// return Promise.all(requests);
|
||||
// });
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function getUserPhoto(id) {
|
||||
// return api.people.getUserPhoto(id);
|
||||
// }
|
||||
|
||||
// export function updateCreatedAvatar(avatar) {
|
||||
// return (dispatch, getState) => {
|
||||
// const { big, max, medium, small } = avatar;
|
||||
// const { profile } = getState();
|
||||
// const newProfile = {
|
||||
// ...profile.targetUser,
|
||||
// avatarMax: max,
|
||||
// avatarMedium: medium,
|
||||
// avatar: big,
|
||||
// avatarSmall: small,
|
||||
// };
|
||||
// return dispatch(setProfile(newProfile));
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setAvatarMax(avatarMax) {
|
||||
// return {
|
||||
// type: SET_AVATAR_MAX,
|
||||
// avatarMax,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setCreatedAvatar(avatar) {
|
||||
// return {
|
||||
// type: SET_CREATED_AVATAR,
|
||||
// avatar,
|
||||
// };
|
||||
// }
|
||||
|
||||
// export function setCroppedAvatar(croppedAvatar) {
|
||||
// return {
|
||||
// type: SET_CROPPED_AVATAR,
|
||||
// croppedAvatar,
|
||||
// };
|
||||
// }
|
@ -1,50 +0,0 @@
|
||||
// import {
|
||||
// SET_PROFILE,
|
||||
// CLEAN_PROFILE,
|
||||
// SET_AVATAR_MAX,
|
||||
// SET_CREATED_AVATAR,
|
||||
// SET_CROPPED_AVATAR,
|
||||
// } from "./actions";
|
||||
|
||||
// const initialState = {
|
||||
// targetUser: null,
|
||||
// avatarMax: null,
|
||||
// createdAvatar: {
|
||||
// tmpFile: "",
|
||||
// image: null,
|
||||
// defaultWidth: 0,
|
||||
// defaultHeight: 0,
|
||||
// x: 0,
|
||||
// y: 0,
|
||||
// width: 0,
|
||||
// height: 0,
|
||||
// },
|
||||
// croppedAvatar: null,
|
||||
// };
|
||||
|
||||
// const profileReducer = (state = initialState, action) => {
|
||||
// switch (action.type) {
|
||||
// case SET_PROFILE:
|
||||
// return Object.assign({}, state, {
|
||||
// targetUser: action.targetUser,
|
||||
// });
|
||||
// case CLEAN_PROFILE:
|
||||
// return initialState;
|
||||
// case SET_AVATAR_MAX:
|
||||
// return Object.assign({}, state, {
|
||||
// avatarMax: action.avatarMax,
|
||||
// });
|
||||
// case SET_CREATED_AVATAR:
|
||||
// return Object.assign({}, state, {
|
||||
// createdAvatar: action.avatar,
|
||||
// });
|
||||
// case SET_CROPPED_AVATAR:
|
||||
// return Object.assign({}, state, {
|
||||
// croppedAvatar: action.croppedAvatar,
|
||||
// });
|
||||
// default:
|
||||
// return state;
|
||||
// }
|
||||
// };
|
||||
|
||||
// export default profileReducer;
|
@ -1,19 +0,0 @@
|
||||
// import { createSelector } from "reselect";
|
||||
// import { store } from "asc-web-common";
|
||||
// const { isAdmin, getCurrentUserId } = store.auth.selectors;
|
||||
|
||||
// const getProfileId = (state) =>
|
||||
// state.profile.targetUser && state.profile.targetUser.id;
|
||||
|
||||
// const getIsAdminProfile = (state) =>
|
||||
// state.profile.targetUser.listAdminModules &&
|
||||
//state.profile.targetUser.listAdminModules.includes("people");
|
||||
|
||||
// export const getDisableProfileType = createSelector(
|
||||
// [isAdmin, getCurrentUserId, getProfileId, getIsAdminProfile],
|
||||
// (isAdmin, currentUserId, profileId, isAdminProfile) => {
|
||||
// return currentUserId === profileId || !isAdmin || isAdminProfile
|
||||
// ? true
|
||||
// : false;
|
||||
// }
|
||||
// );
|
@ -1,17 +0,0 @@
|
||||
import { combineReducers } from "redux";
|
||||
import peopleReducer from "./people/reducers";
|
||||
import profileReducer from "./profile/reducers";
|
||||
import groupReducer from "./group/reducers";
|
||||
import portalReducer from "./portal/reducers";
|
||||
import { store } from "asc-web-common";
|
||||
const { reducer: authReducer } = store.auth;
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
auth: authReducer,
|
||||
people: peopleReducer,
|
||||
profile: profileReducer,
|
||||
group: groupReducer,
|
||||
portal: portalReducer,
|
||||
});
|
||||
|
||||
export default rootReducer;
|
@ -1,21 +0,0 @@
|
||||
import { createStore, applyMiddleware } from "redux";
|
||||
import { composeWithDevTools } from "redux-devtools-extension/logOnlyInProduction";
|
||||
import rootReducer from "./rootReducer";
|
||||
import thunk from "redux-thunk";
|
||||
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
const composeEnhancers = composeWithDevTools({
|
||||
// options like actionSanitizer, stateSanitizer
|
||||
});
|
||||
|
||||
const configureStore = (prelodedState) =>
|
||||
createStore(
|
||||
rootReducer,
|
||||
prelodedState,
|
||||
composeEnhancers(applyMiddleware(thunk))
|
||||
);
|
||||
/* eslint-enable */
|
||||
|
||||
const store = configureStore({});
|
||||
|
||||
export default store;
|
File diff suppressed because it is too large
Load Diff
@ -3,16 +3,10 @@ import React from "react";
|
||||
import { Redirect, Route } from "react-router-dom";
|
||||
//import { Loader } from "asc-web-components";
|
||||
import PageLayout from "../PageLayout";
|
||||
import {
|
||||
//getCurrentUser,
|
||||
//getIsLoaded,
|
||||
//isAdmin,
|
||||
//isAuthenticated,
|
||||
isMe,
|
||||
} from "../../store/auth/selectors.js";
|
||||
import { Error401, Error404 } from "../../pages/errors";
|
||||
import RectangleLoader from "../Loaders/RectangleLoader/RectangleLoader";
|
||||
import { inject, observer } from "mobx-react";
|
||||
import { isMe } from "../../utils";
|
||||
|
||||
const PrivateRoute = ({ component: Component, ...rest }) => {
|
||||
const {
|
||||
|
@ -6,6 +6,7 @@ import ModuleStore from "./ModuleStore";
|
||||
import SettingsStore from "./SettingsStore";
|
||||
import UserStore from "./UserStore";
|
||||
import { logout as logoutDesktop, desktopConstants } from "../desktop";
|
||||
import { isAdmin } from "../utils";
|
||||
|
||||
class AuthStore {
|
||||
userStore = null;
|
||||
@ -80,30 +81,12 @@ class AuthStore {
|
||||
}
|
||||
|
||||
get isAdmin() {
|
||||
const { user: currentUser } = this.userStore;
|
||||
const { user } = this.userStore;
|
||||
const { currentProductId } = this.settingsStore;
|
||||
|
||||
if (!currentUser || !currentUser.id) return false;
|
||||
if (!user || !user.id) return false;
|
||||
|
||||
let productName = null;
|
||||
|
||||
switch (currentProductId) {
|
||||
case "f4d98afd-d336-4332-8778-3c6945c81ea0":
|
||||
productName = "people";
|
||||
break;
|
||||
case "e67be73d-f9ae-4ce1-8fec-1880cb518cb4":
|
||||
productName = "documents";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const isProductAdmin =
|
||||
currentUser.listAdminModules && productName
|
||||
? currentUser.listAdminModules.includes(productName)
|
||||
: false;
|
||||
|
||||
return currentUser.isAdmin || currentUser.isOwner || isProductAdmin;
|
||||
return isAdmin(user, currentProductId);
|
||||
}
|
||||
|
||||
get product() {
|
||||
@ -215,6 +198,27 @@ class AuthStore {
|
||||
return promise;
|
||||
});
|
||||
};
|
||||
|
||||
setDocumentTitle = (subTitle = null) => {
|
||||
let title;
|
||||
|
||||
const currentModule = this.settingsStore.product;
|
||||
const organizationName = this.settingsStore.organizationName;
|
||||
|
||||
if (subTitle) {
|
||||
if (this.isAuthenticated && currentModule) {
|
||||
title = subTitle + " - " + currentModule.title;
|
||||
} else {
|
||||
title = subTitle + " - " + organizationName;
|
||||
}
|
||||
} else if (currentModule && organizationName) {
|
||||
title = currentModule.title + " - " + organizationName;
|
||||
} else {
|
||||
title = organizationName;
|
||||
}
|
||||
|
||||
document.title = title;
|
||||
};
|
||||
}
|
||||
|
||||
export default new AuthStore();
|
||||
|
@ -54,12 +54,12 @@ export function setIsLoaded(isLoaded) {
|
||||
};
|
||||
}
|
||||
|
||||
export function setIsLoadedSection(isLoadedSection) {
|
||||
return {
|
||||
type: SET_IS_LOADED_SECTION,
|
||||
isLoadedSection,
|
||||
};
|
||||
}
|
||||
// export function setIsLoadedSection(isLoadedSection) {
|
||||
// return {
|
||||
// type: SET_IS_LOADED_SECTION,
|
||||
// isLoadedSection,
|
||||
// };
|
||||
// }
|
||||
|
||||
export function setLogout() {
|
||||
return {
|
||||
|
@ -1,12 +1,6 @@
|
||||
import { createSelector } from "reselect";
|
||||
import isEmpty from "lodash/isEmpty";
|
||||
|
||||
export function isMe(user, userName) {
|
||||
return (
|
||||
user && user.id && (userName === "@self" || user.userName === userName)
|
||||
);
|
||||
}
|
||||
|
||||
const toModuleWrapper = (item, iconName) => {
|
||||
return {
|
||||
id: item.id,
|
||||
|
@ -125,3 +125,31 @@ export function tryRedirectTo(page) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function isMe(user, userName) {
|
||||
return (
|
||||
user && user.id && (userName === "@self" || user.userName === userName)
|
||||
);
|
||||
}
|
||||
|
||||
export function isAdmin(currentUser, currentProductId) {
|
||||
let productName = null;
|
||||
|
||||
switch (currentProductId) {
|
||||
case "f4d98afd-d336-4332-8778-3c6945c81ea0":
|
||||
productName = "people";
|
||||
break;
|
||||
case "e67be73d-f9ae-4ce1-8fec-1880cb518cb4":
|
||||
productName = "documents";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const isProductAdmin =
|
||||
currentUser.listAdminModules && productName
|
||||
? currentUser.listAdminModules.includes(productName)
|
||||
: false;
|
||||
|
||||
return currentUser.isAdmin || currentUser.isOwner || isProductAdmin;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user