Commit 9df95838 authored by Yannis Barlas's avatar Yannis Barlas

feat(dashboard): order articles by last updated

parent 1f556f20
......@@ -10,6 +10,7 @@ const GET_DASHBOARD_ARTICLES = gql`
query GetDashboardArticles($currentUserId: ID!) {
dashboardArticles(currentUserId: $currentUserId) {
author {
created
id
status {
decision {
......@@ -33,12 +34,14 @@ const GET_DASHBOARD_ARTICLES = gql`
}
}
title
updated
}
editor {
assignedEditor {
id
username
}
created
id
status {
decision {
......@@ -62,6 +65,7 @@ const GET_DASHBOARD_ARTICLES = gql`
}
}
title
updated
}
isGlobal
reviewer {
......@@ -71,6 +75,7 @@ const GET_DASHBOARD_ARTICLES = gql`
name
}
comments
created
datatype
funding
geneExpression {
......@@ -176,6 +181,7 @@ const GET_DASHBOARD_ARTICLES = gql`
references
reviewerStatus
title
updated
}
}
}
......
/* eslint-disable react/prop-types */
import React from 'react'
import styled from 'styled-components'
import { DateParser } from '@pubsweet/ui'
import { th } from '@pubsweet/ui-toolkit'
const Wrapper = styled.span`
font-family: ${th('fontInterface')};
font-size: ${th('fontSizeBaseSmall')};
line-height: ${th('lineHeighBaseSmall')};
`
const Label = styled.span`
color: ${th('colorBorder')};
margin-right: calc(${th('gridUnit')} / 2);
text-transform: capitalize;
&:before {
content: '\\2014';
padding: 0 ${th('gridUnit')};
}
&:after {
content: ':';
}
`
const Date = props => {
const { label, value } = props
return (
<Wrapper>
<Label>{label}</Label>
<DateParser humanizeThreshold={3} timestamp={value}>
{timestamp => <span>{timestamp}</span>}
</DateParser>
</Wrapper>
)
}
export default Date
......@@ -2,34 +2,35 @@
import React from 'react'
import styled from 'styled-components'
import { uniqueId } from 'lodash'
import { th } from '@pubsweet/ui-toolkit'
import { SectionItem, StatusItem } from './index'
import DashboardItemDate from './DashboardItemDate'
import StatusItem from './StatusItem'
import SectionItem from './SectionItem'
const StatusRow = styled.div`
const StatusRowWrapper = styled.div`
display: flex;
margin-bottom: calc(${th('gridUnit')});
`
const SectionItemWithStatus = props => {
const { actionsComponent, status, title } = props
const StatusRow = props => {
const { status, updated } = props
// const event = { date: new Date() }
const event = null
const statusItems = [status, event]
return (
<StatusRowWrapper>
<StatusItem status={status} />
{updated && <DashboardItemDate label="Last updated" value={updated} />}
</StatusRowWrapper>
)
}
const SectionItemWithStatus = props => {
const { actionsComponent, status, title, updated } = props
return (
<React.Fragment>
<StatusRow>
{statusItems.map(i => {
if (!i) return null
if (!i.date) return <StatusItem key={uniqueId()} status={i} />
return <StatusItem key={uniqueId()} label={i.date.toString()} />
})}
</StatusRow>
<StatusRow status={status} updated={updated} />
<SectionItem rightComponent={actionsComponent} title={title} />
</React.Fragment>
)
......
......@@ -7,6 +7,7 @@ import { th } from '@pubsweet/ui-toolkit'
import { getCurrentStatus } from '../../helpers/status'
const StatusLabel = styled.span`
align-self: center;
color: ${props => {
if (props.decision) {
const { accepted, rejected, revise } = props.decision
......@@ -17,10 +18,8 @@ const StatusLabel = styled.span`
return th('colorFurniture')
}};
font-size: ${th('fontSizeBaseSmall')};
line-height: ${th('lineHeightBaseSmall')};
margin: 0 calc(${th('gridUnit')}) 0 0;
text-transform: uppercase;
`
......
......@@ -162,7 +162,7 @@ const resolvers = {
async dashboardArticles(_, { currentUserId }, context) {
const { connectors } = context
const articles = await Manuscript.query()
const articles = await Manuscript.query().orderBy('updated', 'desc')
const currentUser = await User.find(currentUserId)
const reviews = await Review.all()
const teams = await Team.all()
......
......@@ -21,16 +21,20 @@ const typeDefs = `
}
type AuthorArticle {
created: String
id: ID
status: Status
title: String
updated: String
}
type EditorArticle {
assignedEditor: User
created: String
id: ID
status: Status
title: String
updated: String
}
type HistoryEntry {
......
......@@ -46,6 +46,7 @@ const typeDefs = `
acknowledgements: String
authors: [Author]
comments: String
created: String
datatype: String
funding: String
geneExpression: GeneExpression
......@@ -57,6 +58,7 @@ const typeDefs = `
references: String
reviewerStatus: String
title: String
updated: String
}
extend type DashboardArticles {
......
Markdown is supported
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