Skip to content
Snippets Groups Projects
Commit 2cd35886 authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

Merge branch 'develop' of gitlab.coko.foundation:xpub/xpub-faraday into develop

parents e393841d 577255af
No related branches found
No related tags found
1 merge request!10Sprint #12
Showing
with 99 additions and 25 deletions
......@@ -83,6 +83,24 @@ demo:qa:
- now --public --docker --token $NOW_TOKEN -e AWS_S3_ACCESS_KEY=$AWS_S3_ACCESS_KEY -e AWS_S3_SECRET_KEY=$AWS_S3_SECRET_KEY -e AWS_S3_REGION=$AWS_S3_REGION -e AWS_S3_BUCKET=$AWS_S3_BUCKET -e AWS_SES_SECRET_KEY=$AWS_SES_SECRET_KEY -e AWS_SES_ACCESS_KEY=$AWS_SES_ACCESS_KEY -e AWS_SES_REGION=$AWS_SES_REGION -e EMAIL_SENDER=$EMAIL_SENDER -e secret=$SECRET -e DATABASE=$DATABASE -e DB_USER=$DB_USER -e DB_PASS=$DB_PASS -e DB_HOST=$DB_HOST
- now alias $NOW_URL xpub-faraday-qa --token $NOW_TOKEN
demo:aws-qa:
image: $REPOSITORY_URL:latest
stage: demo
when: manual
variables:
PACKAGE_NAME: xpub-faraday
CLUSTER_NAME: faraday-cluster
environment:
name: qa/$PACKAGE_NAME
url: http://52.211.238.137/
script:
- export AWS_REGION="eu-west-1"
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
- apk --no-cache add --update python python-dev py-pip
- pip install ecs-deploy
- ecs deploy --region ${AWS_REGION} ${CLUSTER_NAME} ${IMAGE_REPO}:${CI_COMMIT_SHA} --tag ${CI_COMMIT_SHA}
demo:staging:
image: $IMAGE_ORG/$IMAGE_NAME:$CI_COMMIT_SHA
stage: demo
......
......@@ -30,7 +30,7 @@ export const currentUserIs = ({ currentUser: { user } }, role) => {
export const canInviteReviewers = ({ currentUser: { user } }, project) => {
const status = get(project, 'status')
if (!status || status === 'rejected') return false
if (!status || status === 'rejected' || status === 'published') return false
const handlingEditor = get(project, 'handlingEditor')
const isAdmin = get(user, 'admin')
......@@ -59,8 +59,23 @@ export const getHERecommendation = (state, collectionId, fragmentId) => {
export const canMakeDecision = (state, collection) => {
const status = get(collection, 'status')
if (!status || status === 'rejected') return false
if (!status || status === 'rejected' || status === 'published') return false
const isEIC = currentUserIs(state, 'adminEiC')
return isEIC && status
}
const editorialStatuses = [
'rejected',
'published',
'pendingApproval',
'revisionRequested',
]
export const canSeeEditorialComments = (state, collectionId) => {
const collection = state.collections.find(c => c.id === collectionId)
const isStaff = currentUserIs(state, 'staff')
if (!isStaff) return false
if (!editorialStatuses.includes(collection.status)) return false
return true
}
......@@ -26,14 +26,14 @@ const EditorialComment = ({
reason,
comments,
updatedOn,
handlingEditor: { name },
author: { name, role },
}) => (
<Root>
<Row>
<HeaderContainer>
<ReasonText>{reason}</ReasonText>
<CommentAuthor>{name}</CommentAuthor>
<RoleBadge>he</RoleBadge>
<RoleBadge>{role}</RoleBadge>
</HeaderContainer>
<DateParser timestamp={updatedOn}>
{t => <DefaultText>{t}</DefaultText>}
......@@ -50,10 +50,22 @@ const EditorialComment = ({
export default compose(
setDisplayName('EditorialComment'),
withProps(({ recommendation, comments = [] }) => ({
reason: parseRecommendationType(recommendation),
comments: parseRecommendationComments(comments),
})),
withProps(
({
userId,
editorInChief,
recommendation,
handlingEditor: { id: heId, name: heName },
comments = [],
}) => ({
reason: parseRecommendationType(recommendation),
comments: parseRecommendationComments(comments),
author: {
name: userId === heId ? heName : editorInChief,
role: userId === heId ? 'HE' : 'EiC',
},
}),
),
)(EditorialComment)
// #region styled-components
......@@ -84,7 +96,6 @@ const RoleBadge = styled.span`
margin-left: ${th('subGridUnit')};
padding: calc(${th('subGridUnit')} / 3);
text-align: center;
text-transform: uppercase;
`
const HeaderContainer = styled.div`
......
......@@ -7,11 +7,20 @@ import { setDisplayName, withProps, compose } from 'recompose'
import { Expandable } from '../molecules'
import { EditorialComment } from './'
const EditorialComments = ({ recommendations, handlingEditor }) => (
const EditorialComments = ({
recommendations,
handlingEditor,
editorInChief,
}) => (
<Root>
<Expandable label="Editorial comments" startExpanded>
{recommendations.map(r => (
<EditorialComment key={r.id} {...r} handlingEditor={handlingEditor} />
<EditorialComment
key={r.id}
{...r}
editorInChief={editorInChief}
handlingEditor={handlingEditor}
/>
))}
</Expandable>
</Root>
......
......@@ -59,6 +59,7 @@ const ManuscriptLayout = ({
editorialRecommendations.length > 0 && (
<EditorialComments
project={project}
editorInChief={editorInChief}
recommendations={editorialRecommendations}
/>
)}
......
......@@ -28,6 +28,7 @@ import {
import ManuscriptLayout from './ManuscriptLayout'
import { parseSearchParams, redirectToError } from './utils'
import { canSeeEditorialComments } from '../../../component-faraday-selectors'
export default compose(
setDisplayName('ManuscriptPage'),
......@@ -48,6 +49,10 @@ export default compose(
version: selectFragment(state, match.params.version),
project: selectCollection(state, match.params.project),
editorialRecommendations: selectEditorialRecommendations(state),
canSeeEditorialComments: canSeeEditorialComments(
state,
match.params.project,
),
}),
{
replace,
......
......@@ -58,7 +58,7 @@ export default compose(
const Root = styled.div`
border-bottom: ${th('borderDefault')};
display: flex;
justify-content: space-between;
justify-content: flex-end;
padding: ${th('subGridUnit')};
`
......
......@@ -102,10 +102,13 @@ const DashboardCard = ({
<Bottom>
<LeftDetails flex={3}>
<Status>{mapStatusToLabel(project)}</Status>
<DateParser timestamp={get(version, 'submitted')}>
<DateParser
durationThreshold={0}
timestamp={get(version, 'submitted')}
>
{(timestamp, daysAgo) => (
<DateField>
{timestamp} ({daysAgo})
{timestamp} ({daysAgo} ago)
</DateField>
)}
</DateParser>
......
......@@ -24,7 +24,7 @@ export const parseFormValues = ({ decision, messageToHE }) => {
recommendation: decision,
recommendationType: 'editorRecommendation',
}
return messageToHE
return decision === 'return-to-handling-editor'
? {
...recommendation,
comments: [
......
......@@ -52,7 +52,7 @@ const TR = ({
</DateParser>
<td>
<StatusText>
{`${r.status === 'accepted' ? 'Agreed: ' : r.status}`}
{`${r.status === 'accepted' ? 'Agreed: ' : `${r.status}: `}`}
</StatusText>
<DateParser timestamp={r.respondedOn}>
{timestamp => <DateText>{timestamp}</DateText>}
......
import moment from 'moment'
import { compose, withProps, withHandlers } from 'recompose'
import { string, instanceOf, number, oneOfType } from 'prop-types'
const getDuration = timestamp => {
const today = moment()
......@@ -7,17 +8,20 @@ const getDuration = timestamp => {
return moment.duration(today.diff(stamp))
}
const DateParser = ({ children, timestamp, daysAgo }) =>
children(timestamp, daysAgo)
const D = ({ children, timestamp, daysAgo }) => children(timestamp, daysAgo)
export default compose(
const DateParser = compose(
withHandlers({
renderTimestamp: ({ timestamp, dateFormat = 'DD.MM.YYYY' }) => () => {
renderTimestamp: ({
timestamp,
durationThreshold = 1,
dateFormat = 'DD.MM.YYYY',
}) => () => {
if (!timestamp) return ''
const duration = getDuration(timestamp)
if (duration.asDays() < 1) {
return `${duration.humanize()}`
if (duration.asDays() < durationThreshold) {
return `${duration.humanize()} ago`
}
return moment(timestamp).format(dateFormat)
},
......@@ -31,4 +35,12 @@ export default compose(
daysAgo: renderDaysAgo(),
timestamp: renderTimestamp(),
})),
)(DateParser)
)(D)
DateParser.propTypes = {
dateFormat: string,
durationThreshold: number,
timestamp: oneOfType([string, number, instanceOf(Date)]),
}
export default DateParser
......@@ -45,7 +45,7 @@ export const selectRecommendations = state =>
get(state, 'recommendations.recommendations') || []
export const selectEditorialRecommendations = state =>
selectRecommendations(state).filter(
r => r.recommendationType === 'editorRecommendation',
r => r.recommendationType === 'editorRecommendation' && r.comments,
)
// #endregion
......
......@@ -244,7 +244,7 @@ const authsomeMode = async (userId, operation, object, context) => {
const user = await context.models.User.find(userId)
// Admins and editor in chiefs can do anything
if (user && (user.admin === true || user.editorInChief === true)) return true
if (user && (user.admin || user.editorInChief)) return true
if (user) {
return authenticatedUser(user, operation, object, context)
......
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