diff --git a/packages/component-faraday-ui/src/AppBar.js b/packages/component-faraday-ui/src/AppBar.js index d4bf4f10897dba913898c391a6ab7a21c752a578..bca602b1cbb7b7e7df0730b95263d32dd29f81d9 100644 --- a/packages/component-faraday-ui/src/AppBar.js +++ b/packages/component-faraday-ui/src/AppBar.js @@ -1,13 +1,19 @@ import React from 'react' -import { th } from '@pubsweet/ui-toolkit' -import { H2 } from '@pubsweet/ui' +import { get } from 'lodash' import styled from 'styled-components' -import { compose, setDisplayName } from 'recompose' +import { H2, Button } from '@pubsweet/ui' +import { th } from '@pubsweet/ui-toolkit' +import { compose, setDisplayName, withProps } from 'recompose' +import { Item } from 'pubsweet-component-faraday-ui' const AppBar = ({ logo: Logo, menu: Menu, + createDraft, + canCreateDraft, + currentUser = {}, fixed = true, + isSubmit, autosave: Autosave, journal: { metadata: { backgroundImage, nameText } }, }) => ( @@ -17,7 +23,24 @@ const AppBar = ({ <Logo /> </LogoContainer> <RightContainer> - <Autosave /> + <Item mr={2}> + <Autosave /> + </Item> + {createDraft && + !isSubmit && + currentUser.user && ( + <Button + data-test="new-manuscript" + disabled={!canCreateDraft} + ml={2} + mr={5} + onClick={createDraft} + primary + size="small" + > + SUBMIT + </Button> + )} <Menu /> </RightContainer> </Root> @@ -29,7 +52,12 @@ AppBar.defaultProps = { menu: () => <div />, } -export default compose(setDisplayName('AppBar'))(AppBar) +export default compose( + withProps(({ location = {}, submitPath = '/submit' }) => ({ + isSubmit: get(location, 'pathname', '').includes(submitPath), + })), + setDisplayName('AppBar'), +)(AppBar) // #region styles const RightContainer = styled.div` diff --git a/packages/component-faraday-ui/src/AppBar.md b/packages/component-faraday-ui/src/AppBar.md index 6ff9d430f4648ba85490279ee164983cf0085df6..1c1b61c6d055c07bd71995d536f977f0304ad0af 100644 --- a/packages/component-faraday-ui/src/AppBar.md +++ b/packages/component-faraday-ui/src/AppBar.md @@ -6,43 +6,47 @@ const currentUser = { admin: true, username: 'cocojambo', firstName: 'Alex', - lastName: 'Munteanu' - } -}; + lastName: 'Munteanu', + }, +} const autosave = { - isFetching: true -}; + isFetching: true, +} -const HindawiLogo = () => <Logo - onClick={() => console.log('Hindawi best publish!')} - title="Hindawi" - src="https://upload.wikimedia.org/wikipedia/en/thumb/c/ca/Hindawi.svg/1200px-Hindawi.svg.png" -/>; +const HindawiLogo = () => ( + <Logo + onClick={() => console.log('Hindawi best publish!')} + title="Hindawi" + src="https://upload.wikimedia.org/wikipedia/en/thumb/c/ca/Hindawi.svg/1200px-Hindawi.svg.png" + /> +) -const MenuComponent = () => <AppBarMenu +const MenuComponent = () => ( + <AppBarMenu currentUser={currentUser} goTo={path => console.log(`navigating to ${path}`)} logout={() => console.log('logging out')} - />; + /> +) -const AutosaveComponent = () => <AutosaveIndicator - isVisible - autosave={autosave} - />; +const AutosaveComponent = () => ( + <AutosaveIndicator isVisible autosave={autosave} /> +) -<AppBar +;<AppBar autosave={AutosaveComponent} logo={HindawiLogo} menu={MenuComponent} journal={{ metadata: { - nameText:'Chemistry Awesomeness', - backgroundImage: 'https://images.hindawi.com/journals/jchem/jchem.banner.jpg' + nameText: 'Chemistry Awesomeness', + backgroundImage: + 'https://images.hindawi.com/journals/jchem/jchem.banner.jpg', }, }} fixed={false} - /> +/> ``` Without a journal background. @@ -53,41 +57,95 @@ const currentUser = { admin: true, username: 'cocojambo', firstName: 'Alex', - lastName: 'Munteanu' - } -}; + lastName: 'Munteanu', + }, +} -const HindawiLogo = () => <Logo - onClick={() => console.log('Hindawi best publish!')} - title="Hindawi" - src="https://upload.wikimedia.org/wikipedia/en/thumb/c/ca/Hindawi.svg/1200px-Hindawi.svg.png" -/>; +const HindawiLogo = () => ( + <Logo + onClick={() => console.log('Hindawi best publish!')} + title="Hindawi" + src="https://upload.wikimedia.org/wikipedia/en/thumb/c/ca/Hindawi.svg/1200px-Hindawi.svg.png" + /> +) const autosave = { isFetching: false, lastUpdate: new Date(), -}; +} -const MenuComponent = () => <AppBarMenu - currentUser={currentUser} - goTo={path => console.log(`navigating to ${path}`)} - logout={() => console.log('logging out')} - />; +const MenuComponent = () => ( + <AppBarMenu + currentUser={currentUser} + goTo={path => console.log(`navigating to ${path}`)} + logout={() => console.log('logging out')} + /> +) -const AutosaveComponent = () => <AutosaveIndicator - isVisible - autosave={autosave} - />; +const AutosaveComponent = () => ( + <AutosaveIndicator isVisible autosave={autosave} /> +) -<AppBar +;<AppBar autosave={AutosaveComponent} logo={HindawiLogo} menu={MenuComponent} journal={{ metadata: { - nameText:'Chemistry Awesomeness', + nameText: 'Chemistry Awesomeness', }, }} fixed={false} +/> +``` + +With submit manuscript button + +```js +const currentUser = { + user: { + admin: true, + username: 'cocojambo', + firstName: 'Alex', + lastName: 'Munteanu', + }, +} + +const HindawiLogo = () => ( + <Logo + onClick={() => console.log('Hindawi best publish!')} + title="Hindawi" + src="https://upload.wikimedia.org/wikipedia/en/thumb/c/ca/Hindawi.svg/1200px-Hindawi.svg.png" /> +) + +const autosave = { + isFetching: false, + lastUpdate: new Date(), +} + +const MenuComponent = () => ( + <AppBarMenu + currentUser={currentUser} + goTo={path => console.log(`navigating to ${path}`)} + logout={() => console.log('logging out')} + /> +) + +const AutosaveComponent = () => ( + <AutosaveIndicator isVisible autosave={autosave} /> +) + +;<AppBar + autosave={AutosaveComponent} + logo={HindawiLogo} + menu={MenuComponent} + createDraft={() => alert('Submit manuscript')} + journal={{ + metadata: { + nameText: 'Chemistry Awesomeness', + }, + }} + fixed={false} +/> ``` diff --git a/packages/components-faraday/src/components/Dashboard/Dashboard.js b/packages/components-faraday/src/components/Dashboard/Dashboard.js index 7fa751167fd6ab1fb54285d015341471bcb56dab..e61e16d1d13b48c562f9d5850111e41ca70b4440 100644 --- a/packages/components-faraday/src/components/Dashboard/Dashboard.js +++ b/packages/components-faraday/src/components/Dashboard/Dashboard.js @@ -1,30 +1,16 @@ import React, { Fragment } from 'react' -import { Button } from '@pubsweet/ui' import { compose, withProps } from 'recompose' -import { Row } from 'pubsweet-component-faraday-ui' import { DashboardItems, DashboardFilters } from './' const Dashboard = ({ deleteProject, dashboardItems, - canCreateDraft, getFilterOptions, changeFilterValue, - createDraftSubmission, getDefaultFilterValue, }) => ( <Fragment> - <Row alignItems="center" justify="flex-end"> - <Button - data-test="new-manuscript" - disabled={!canCreateDraft} - onClick={createDraftSubmission} - primary - > - Submit - </Button> - </Row> <DashboardFilters changeFilterValue={changeFilterValue} getDefaultFilterValue={getDefaultFilterValue} diff --git a/packages/components-faraday/src/components/Dashboard/DashboardItems.js b/packages/components-faraday/src/components/Dashboard/DashboardItems.js index 428d5dd06c7d95e3205557ceec68052145079b0f..b43ac428736411b1d1c3a19f26ab995912941767 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardItems.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardItems.js @@ -55,6 +55,7 @@ export default compose( const Root = styled.div` height: calc(100vh - 204px); overflow-y: auto; + overflow-x: hidden; div[open] { width: auto; } diff --git a/packages/components-faraday/src/components/Dashboard/DashboardPage.js b/packages/components-faraday/src/components/Dashboard/DashboardPage.js index ee51f5000102853721063b5c7666f4e7db5365ac..944329379b27e97f83a5d770b1a50ea49142eaa7 100644 --- a/packages/components-faraday/src/components/Dashboard/DashboardPage.js +++ b/packages/components-faraday/src/components/Dashboard/DashboardPage.js @@ -6,12 +6,8 @@ import { ConnectPage } from 'xpub-connect' import { withRouter } from 'react-router-dom' import { compose, withContext } from 'recompose' import { newestFirst, selectCurrentUser } from 'xpub-selectors' -import { createDraftSubmission } from 'pubsweet-component-wizard/src/redux/conversion' -import { - userNotConfirmed, - getUserPermissions, -} from 'pubsweet-component-faraday-selectors' +import { getUserPermissions } from 'pubsweet-component-faraday-selectors' import { Dashboard } from './' import { priorityFilter, orderFilter, withFiltersHOC } from '../Filters' @@ -22,7 +18,6 @@ export default compose( state => { const { collections, conversion } = state const currentUser = selectCurrentUser(state) - const canCreateDraft = !userNotConfirmed(state) const sortedCollections = newestFirst(collections) const dashboard = { @@ -47,14 +42,12 @@ export default compose( conversion, collections, currentUser, - canCreateDraft, userPermissions, } }, - (dispatch, { history }) => ({ + dispatch => ({ deleteProject: collection => dispatch(actions.deleteCollection(collection)), - createDraftSubmission: () => dispatch(createDraftSubmission(history)), }), ), withRouter, diff --git a/packages/hindawi-theme/src/index.js b/packages/hindawi-theme/src/index.js index e57df75591d312012d60dae33fff06001446ea1c..f2d28cd1770c809434faff5aa55eb519f1b5c9a9 100644 --- a/packages/hindawi-theme/src/index.js +++ b/packages/hindawi-theme/src/index.js @@ -57,7 +57,7 @@ const hindawiTheme = { appBar: { boxShadow: '0 2px 3px 0 rgba(25, 102, 141, 0.19)', colorBackground: '#ffffff', - height: '60px', + height: '70px', zIndex: 1000, }, @@ -94,7 +94,7 @@ const hindawiTheme = { defaultHeight: '40px', mediumHeight: '30px', - smallHeight: '20px', + smallHeight: '24px', minWidth: '120px', mediumMinWidth: '100px', diff --git a/packages/xpub-faraday/app/FaradayApp.js b/packages/xpub-faraday/app/FaradayApp.js index e8065ef3d8a774edbb3a6f577f1c6ce512c6239e..68d625269c053530aded27bb8de7e6740c6c1464 100644 --- a/packages/xpub-faraday/app/FaradayApp.js +++ b/packages/xpub-faraday/app/FaradayApp.js @@ -13,6 +13,8 @@ import { AppBarMenu, AutosaveIndicator, } from 'pubsweet-component-faraday-ui' +import { userNotConfirmed } from 'pubsweet-component-faraday-selectors' +import { createDraftSubmission } from 'pubsweet-component-wizard/src/redux/conversion' const App = ({ autosave, @@ -21,6 +23,7 @@ const App = ({ children, logout, currentUser, + ...rest }) => ( <Root className="faraday-root"> <AppBar @@ -31,9 +34,11 @@ const App = ({ successText="Progress Saved" /> )} + currentUser={currentUser} journal={journal} logo={() => ( <Logo + height={54} onClick={() => goTo('/')} src={get(journal, 'metadata.logo')} title="Hindawi" @@ -42,21 +47,26 @@ const App = ({ menu={() => ( <AppBarMenu currentUser={currentUser} goTo={goTo} logout={logout} /> )} + {...rest} /> <MainContainer className="faraday-main">{children}</MainContainer> </Root> ) export default compose( + withRouter, + withJournal, connect( state => ({ autosave: state.autosave, currentUser: state.currentUser, + canCreateDraft: !userNotConfirmed(state), + }), + (dispatch, { history }) => ({ + logout: () => dispatch(actions.logoutUser()), + createDraft: () => dispatch(createDraftSubmission(history)), }), - { logout: actions.logoutUser }, ), - withJournal, - withRouter, withHandlers({ goTo: ({ history }) => path => { history.push(path) @@ -77,7 +87,7 @@ const MainContainer = styled.div` display: flex; flex-direction: column; overflow-y: auto; - padding: calc(${th('appBar.height')} + ${th('gridUnit')} * 3) + padding: calc(${th('appBar.height')} + ${th('gridUnit')} * 2.5) calc(${th('gridUnit')} * 12) calc(${th('gridUnit')} * 2); ` // #endregion diff --git a/packages/xpub-faraday/app/config/journal/metadata.js b/packages/xpub-faraday/app/config/journal/metadata.js index d55bc4c7f12a2f1ec9261a26c0df1843aa4ae636..c01df20fbf88e1478f284e6c957ed7108ef2f3b6 100644 --- a/packages/xpub-faraday/app/config/journal/metadata.js +++ b/packages/xpub-faraday/app/config/journal/metadata.js @@ -1,6 +1,6 @@ export default { issn: '2474-7394', - logo: '/assets/hindawi-logo.png', + logo: '/assets/logo-hindawi@2x.png', nameText: 'Faraday Journal', email: 'faraday@hindawi.com', mts: { diff --git a/packages/xpub-faraday/static/logo-hindawi@2x.png b/packages/xpub-faraday/static/logo-hindawi@2x.png new file mode 100755 index 0000000000000000000000000000000000000000..ab4bf2641c10d5233b11627fc39c3f43cae41de7 Binary files /dev/null and b/packages/xpub-faraday/static/logo-hindawi@2x.png differ