From 4091d59622c78b8446ebc0803ba0558d227238ff Mon Sep 17 00:00:00 2001 From: Tamlyn Rhodes <tamlyn@tamlyn.org> Date: Tue, 21 Nov 2017 15:05:51 +0000 Subject: [PATCH] Merge "My Manuscripts" and "Assign" Previously submitted but unassigned manuscripts were displayed in their own section on the dashboard. Now they are grouped together with manuscripts that are assigned to the current user. --- .../src/components/Dashboard.js | 9 ---- .../src/components/DashboardPage.js | 54 ++++++++++++------- 2 files changed, 34 insertions(+), 29 deletions(-) diff --git a/packages/component-dashboard/src/components/Dashboard.js b/packages/component-dashboard/src/components/Dashboard.js index 228e9261f..acc01832a 100644 --- a/packages/component-dashboard/src/components/Dashboard.js +++ b/packages/component-dashboard/src/components/Dashboard.js @@ -56,15 +56,6 @@ const Dashboard = ({ </div> )} - {!!dashboard.assign.length && ( - <div className={classes.section}> - <div className={classes.heading}>Assign</div> - {dashboard.assign.map(project => ( - <EditorItemWithVersion key={project.id} project={project} AssignEditor={AssignEditor} /> - ))} - </div> - )} - {!!dashboard.editor.length && ( <div className={classes.section}> <div className={classes.heading}>My Manuscripts</div> diff --git a/packages/component-dashboard/src/components/DashboardPage.js b/packages/component-dashboard/src/components/DashboardPage.js index d4c674cfe..b2dcfe4fe 100644 --- a/packages/component-dashboard/src/components/DashboardPage.js +++ b/packages/component-dashboard/src/components/DashboardPage.js @@ -33,27 +33,41 @@ export default compose( const sortedCollections = newestFirst(collections) + const unassignedCollections = sortedCollections.filter( + collection => + collection.status === 'submitted' && + !teams.some( + team => + team.object.type === 'collection' && + team.object.id === collection.id && + team.teamType.name === 'handlingEditor' + ) + ) + const myCollections = teams + .filter( + team => + team.group === 'editor' && + team.object.type === 'collection' && + team.members.includes(currentUser.id) + ) + .map(team => + collections.find(collection => collection.id === team.object.id) + ) + const dashboard = { - owner: sortedCollections - .filter(collection => collection.owners - && collection.owners.some(owner => owner.id === currentUser.id)), - assign: sortedCollections - .filter(collection => collection.status === 'submitted' - && !teams.some(team => - team.object.type === 'collection' - && team.object.id === collection.id - && team.teamType.name === 'handlingEditor' - )), - editor: newestFirst(teams - .filter(team => team.group === 'editor' - && team.object.type === 'collection' - && team.members.includes(currentUser.id)) - .map(team => team.object.id) - .filter((id, index, items) => items.indexOf(id) === index) // unique - .map(id => collections.find( - collection => collection.id === id - ))) - .filter(collection => collection), + owner: sortedCollections.filter( + collection => + collection.owners && + collection.owners.some(owner => owner.id === currentUser.id) + ), + editor: newestFirst( + unassignedCollections + .concat(myCollections) + .filter( + (collection, index, items) => + items.findIndex(item => item.id === collection.id) === index + ) + ), // reviewer: newestFirst(teams // .filter(team => team.group === 'reviewer' // && team.object.type === 'collection' -- GitLab