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 styled, { css } from 'styled-components'
import { Button, th } from '@pubsweet/ui'
import { compose, withHandlers } from 'recompose'
import { withModal } from 'pubsweet-component-modal/src/components'
import HEModal from './AssignHEModal'
const AssignEditor = ({ assign }) => <button onClick={assign}>ASSIGN</button>
const AssignEditor = ({ assign }) => (
<ActionButtons onClick={assign}>ASSIGN</ActionButtons>
)
export default compose(
withModal({
......@@ -18,3 +22,20 @@ export default compose(
},
}),
)(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 { get } from 'lodash'
import { Button } from '@pubsweet/ui'
import styled from 'styled-components'
import { compose, withHandlers } from 'recompose'
......@@ -60,16 +59,11 @@ export default compose(
currentUser,
dashboard,
filterItems,
}) => () => {
const userItems = get(currentUser, 'admin')
? dashboard.all
: dashboard.owner
return filterItems(userItems).sort((a, b) => {
}) => () =>
filterItems(dashboard.all).sort((a, b) => {
if (sortOrder === 'newest') return a.created - b.created < 0
return a.created - b.created > 0
})
},
}),
}),
)(Dashboard)
......
import React from 'react'
import PropTypes from 'prop-types'
import { get, head } from 'lodash'
import { Icon, th } from '@pubsweet/ui'
import styled, { css, withTheme } from 'styled-components'
import { compose, getContext } from 'recompose'
import { compose, withHandlers } from 'recompose'
import AssignEditor from './AssignEditor'
const HandlingEditorActions = ({ project, theme }) => (
<Root>
<HEActions>
<Icon color={theme.colorPrimary}>refresh-cw</Icon>
<Icon color={theme.colorPrimary}>x-circle</Icon>
<AssignEditor collectionId={project.id} />
</HEActions>
</Root>
)
const HandlingEditorActions = ({ project, theme, getHandlingEditor }) => {
const handlingEditor = getHandlingEditor()
return (
<Root>
<HEActions>
{handlingEditor ? (
<HEActions>
<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)(
HandlingEditorActions,
)
export default compose(
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
const defaultText = css`
......@@ -26,11 +53,17 @@ const defaultText = css`
font-size: ${th('fontSizeBaseSmall')};
`
const Root = styled.div``
const Root = styled.div`
margin-left: ${th('gridUnit')};
`
const HEName = styled.div``
const HEActions = styled.div`
${defaultText};
text-transform: uppercase;
display: flex;
align-items: center;
cursor: pointer;
margin-left: ${th('subGridUnit')};
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