diff --git a/packages/component-faraday-selectors/src/index.js b/packages/component-faraday-selectors/src/index.js index d2f4e508dffc1d7b58f9afebdb77a530d06253d1..95f9a5b80adf044e2ed228d636c9ce8d793869be 100644 --- a/packages/component-faraday-selectors/src/index.js +++ b/packages/component-faraday-selectors/src/index.js @@ -96,6 +96,7 @@ export const getUserPermissions = ({ currentUser }) => role: t.teamType.permissions, })) -export const isAuthorConfirmed = ({ currentUser }) => +export const userNotConfirmed = ({ currentUser }) => + get(currentUser, 'isAuthenticated') && !currentUserIs({ currentUser }, 'staff') && - get(currentUser, 'user.isConfirmed') + !get(currentUser, 'user.isConfirmed') diff --git a/packages/components-faraday/src/components/AppBar/AppBar.js b/packages/components-faraday/src/components/AppBar/AppBar.js index a20f4ad342b4feba5771ee379e06da0b075b67bc..d03ed85d76d597adb0b2c46f208342e5c6879b07 100644 --- a/packages/components-faraday/src/components/AppBar/AppBar.js +++ b/packages/components-faraday/src/components/AppBar/AppBar.js @@ -4,9 +4,9 @@ import { connect } from 'react-redux' import { Icon, th } from '@pubsweet/ui' import { withRouter } from 'react-router-dom' import styled, { withTheme } from 'styled-components' -import { withState, withHandlers, withProps, compose } from 'recompose' +import { withState, withHandlers, compose } from 'recompose' -import { currentUserIs } from '../../../../component-faraday-selectors/src' +import { userNotConfirmed } from 'pubsweet-component-faraday-selectors' const AppBar = ({ goTo, @@ -65,7 +65,7 @@ export default compose( withTheme, connect(state => ({ currentUser: get(state, 'currentUser.user'), - isStaff: currentUserIs(state, 'staff'), + shouldShowConfirmation: userNotConfirmed(state), })), withState('expanded', 'setExpanded', false), withHandlers({ @@ -77,10 +77,6 @@ export default compose( history.push(path) }, }), - withProps(({ isStaff, currentUser, isAuthenticated }) => ({ - shouldShowConfirmation: - isAuthenticated && !isStaff && !get(currentUser, 'isConfirmed'), - })), )(AppBar) // #region styled-components diff --git a/packages/components-faraday/src/components/Dashboard/Dashboard.js b/packages/components-faraday/src/components/Dashboard/Dashboard.js index f21a7ffca292aaa34d5ca3bce7d87c62cce81468..1135e8474de374b1509ee458de56ed92167289fe 100644 --- a/packages/components-faraday/src/components/Dashboard/Dashboard.js +++ b/packages/components-faraday/src/components/Dashboard/Dashboard.js @@ -1,5 +1,4 @@ import React from 'react' -import { get } from 'lodash' import styled from 'styled-components' import { Button, th } from '@pubsweet/ui' import { compose, withProps } from 'recompose' @@ -7,7 +6,6 @@ import { compose, withProps } from 'recompose' import { DashboardItems, DashboardFilters } from './' const Dashboard = ({ - isStaff, dashboard, currentUser, filterItems, @@ -44,9 +42,8 @@ const Dashboard = ({ ) export default compose( - withProps(({ isStaff, dashboard, filterItems, currentUser }) => ({ + withProps(({ dashboard, filterItems }) => ({ dashboardItems: filterItems(dashboard.all), - canCreateDraft: isStaff || get(currentUser, 'isConfirmed'), })), )(Dashboard) diff --git a/packages/components-faraday/src/components/Dashboard/DashboardPage.js b/packages/components-faraday/src/components/Dashboard/DashboardPage.js index 8e1224e4081cb8fb918281d83d3c044842ee314c..dce45132340db9e88b54fd63e0f61dc1fada9446 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardPage.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardPage.js @@ -9,13 +9,13 @@ import { compose, withContext } from 'recompose' import { newestFirst, selectCurrentUser } from 'xpub-selectors' import { createDraftSubmission } from 'pubsweet-component-wizard/src/redux/conversion' -import { Dashboard } from './' -import { getHandlingEditors } from '../../redux/editors' import { - currentUserIs, + userNotConfirmed, getUserPermissions, -} from '../../../../component-faraday-selectors/src' +} from 'pubsweet-component-faraday-selectors' +import { Dashboard } from './' +import { getHandlingEditors } from '../../redux/editors' import { priorityFilter, importanceSort, withFiltersHOC } from '../Filters' export default compose( @@ -24,7 +24,7 @@ export default compose( state => { const { collections, conversion } = state const currentUser = selectCurrentUser(state) - const isStaff = currentUserIs(state, 'staff') + const canCreateDraft = !userNotConfirmed(state) const sortedCollections = newestFirst(collections) const dashboard = { @@ -45,11 +45,11 @@ export default compose( } const userPermissions = getUserPermissions(state) return { - isStaff, dashboard, conversion, collections, currentUser, + canCreateDraft, userPermissions, } },