Skip to content
Snippets Groups Projects
Commit fd823948 authored by Bogdan Cochior's avatar Bogdan Cochior
Browse files

feat(HEactions): move actions to HEActions.js

parent 06bad58b
No related branches found
No related tags found
No related merge requests found
import React from 'react' import React from 'react'
import styled, { css } from 'styled-components'
import { Button, th } from '@pubsweet/ui'
import { compose, withHandlers } from 'recompose' import { compose, withHandlers } from 'recompose'
import { withModal } from 'pubsweet-component-modal/src/components' import { withModal } from 'pubsweet-component-modal/src/components'
import HEModal from './AssignHEModal' import HEModal from './AssignHEModal'
const AssignEditor = ({ assign }) => <button onClick={assign}>ASSIGN</button> const AssignEditor = ({ assign }) => (
<ActionButtons onClick={assign}>ASSIGN</ActionButtons>
)
export default compose( export default compose(
withModal({ withModal({
...@@ -18,3 +22,20 @@ export default compose( ...@@ -18,3 +22,20 @@ export default compose(
}, },
}), }),
)(AssignEditor) )(AssignEditor)
// #region styled-components
const defaultText = css`
color: ${th('colorText')};
font-family: ${th('fontReading')};
font-size: ${th('fontSizeBaseSmall')};
`
const ActionButtons = styled(Button)`
${defaultText};
align-items: center;
background-color: ${th('colorPrimary')};
color: ${th('colorTextReverse')};
text-align: center;
height: calc(${th('subGridUnit')}*5);
`
// #endregion
import React from 'react' import React from 'react'
import { get } from 'lodash'
import { Button } from '@pubsweet/ui' import { Button } from '@pubsweet/ui'
import styled from 'styled-components' import styled from 'styled-components'
import { compose, withHandlers } from 'recompose' import { compose, withHandlers } from 'recompose'
...@@ -60,16 +59,11 @@ export default compose( ...@@ -60,16 +59,11 @@ export default compose(
currentUser, currentUser,
dashboard, dashboard,
filterItems, filterItems,
}) => () => { }) => () =>
const userItems = get(currentUser, 'admin') filterItems(dashboard.all).sort((a, b) => {
? dashboard.all
: dashboard.owner
return filterItems(userItems).sort((a, b) => {
if (sortOrder === 'newest') return a.created - b.created < 0 if (sortOrder === 'newest') return a.created - b.created < 0
return a.created - b.created > 0 return a.created - b.created > 0
}) }),
},
}), }),
)(Dashboard) )(Dashboard)
......
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import { get, head } from 'lodash'
import { Icon, th } from '@pubsweet/ui' import { Icon, th } from '@pubsweet/ui'
import styled, { css, withTheme } from 'styled-components' import styled, { css, withTheme } from 'styled-components'
import { compose, getContext } from 'recompose' import { compose, withHandlers } from 'recompose'
import AssignEditor from './AssignEditor' import AssignEditor from './AssignEditor'
const HandlingEditorActions = ({ project, theme }) => ( const HandlingEditorActions = ({ project, theme, getHandlingEditor }) => {
<Root> const handlingEditor = getHandlingEditor()
<HEActions> return (
<Icon color={theme.colorPrimary}>refresh-cw</Icon> <Root>
<Icon color={theme.colorPrimary}>x-circle</Icon> <HEActions>
<AssignEditor collectionId={project.id} /> {handlingEditor ? (
</HEActions> <HEActions>
</Root> <HEName>{get(handlingEditor, 'name')}</HEName>
) {!handlingEditor.hasAnswer && (
<HEActions>
<Icon color={theme.colorPrimary}>refresh-cw</Icon>
<Icon color={theme.colorPrimary}>x-circle</Icon>
</HEActions>
)}
</HEActions>
) : (
<AssignEditor collectionId={project.id} />
)}
</HEActions>
</Root>
)
}
export default compose(getContext({ journal: PropTypes.object }), withTheme)( export default compose(
HandlingEditorActions, withTheme,
) withHandlers({
getHandlingEditor: ({ project }) => () => {
const assignedEditors = get(project, 'assignedPeople')
if (assignedEditors && assignedEditors.length) {
return head(
assignedEditors.filter(
editor =>
!editor.hasAnswer || (editor.hasAnswer && editor.isAccepted),
),
)
}
return null
},
}),
)(HandlingEditorActions)
// #region styled-components // #region styled-components
const defaultText = css` const defaultText = css`
...@@ -26,11 +53,17 @@ const defaultText = css` ...@@ -26,11 +53,17 @@ const defaultText = css`
font-size: ${th('fontSizeBaseSmall')}; font-size: ${th('fontSizeBaseSmall')};
` `
const Root = styled.div`` const Root = styled.div`
margin-left: ${th('gridUnit')};
`
const HEName = styled.div``
const HEActions = styled.div` const HEActions = styled.div`
${defaultText}; ${defaultText};
text-transform: uppercase; text-transform: uppercase;
display: flex;
align-items: center;
cursor: pointer; cursor: pointer;
margin-left: ${th('subGridUnit')}; margin-left: ${th('subGridUnit')};
span { span {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment