You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
import { bindActionCreators } from 'redux';
|
|
import { connect } from 'react-redux';
|
|
|
|
import {
|
|
currentProjectSelector,
|
|
currentUserSelector,
|
|
isCurrentUserManagerForCurrentProjectSelector,
|
|
notificationsForCurrentUserSelector,
|
|
} from '../selectors';
|
|
import {
|
|
deleteNotification,
|
|
logout,
|
|
openProjectSettingsModal,
|
|
openUserSettingsModal,
|
|
openUsersModal,
|
|
} from '../actions/entry';
|
|
import Header from '../components/Header';
|
|
|
|
const mapStateToProps = (state) => {
|
|
const currentUser = currentUserSelector(state);
|
|
const currentProject = currentProjectSelector(state);
|
|
const notifications = notificationsForCurrentUserSelector(state);
|
|
const isCurrentUserManager = isCurrentUserManagerForCurrentProjectSelector(state);
|
|
|
|
return {
|
|
notifications,
|
|
project: currentProject,
|
|
user: currentUser,
|
|
canEditProject: isCurrentUserManager,
|
|
canEditUsers: currentUser.isAdmin,
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = (dispatch) =>
|
|
bindActionCreators(
|
|
{
|
|
onProjectSettingsClick: openProjectSettingsModal,
|
|
onUsersClick: openUsersModal,
|
|
onNotificationDelete: deleteNotification,
|
|
onUserSettingsClick: openUserSettingsModal,
|
|
onLogout: logout,
|
|
},
|
|
dispatch,
|
|
);
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Header);
|