Commit 37175d76 authored by Alexandros Georgantas's avatar Alexandros Georgantas

Merge branch 'dashboard-global-teams' into 'master'

Dashboard global teams

See merge request !110
parents 9cef86c2 40a8e48a
{
"name": "pubsweet-component-editoria-dashboard",
"version": "0.1.1",
"version": "0.1.2",
"description": "The application dashboard for the Editoria project.",
"main": "index.js",
"scripts": {
......
......@@ -23,7 +23,8 @@ export class Dashboard extends React.Component {
this.removeBook = this.removeBook.bind(this)
this.removeTeamsForBook = this.removeTeamsForBook.bind(this)
this.toggleModal = this.toggleModal.bind(this)
this.isProductionEditor = this.isProductionEditor.bind(this)
this.isGlobalProductionEditor = this.isGlobalProductionEditor.bind(this)
this.isGlobalAuthor = this.isGlobalAuthor.bind(this)
this.state = {
showModal: false,
......@@ -158,11 +159,12 @@ export class Dashboard extends React.Component {
// })
// }
isProductionEditor(userId) {
isGlobalProductionEditor(userId) {
const { teams, user } = this.props
if (!user.admin) {
const productionEditorTeams = filter(teams, {
teamType: 'productionEditor',
global: true,
})
const membership = productionEditorTeams.map(team =>
......@@ -174,6 +176,21 @@ export class Dashboard extends React.Component {
return false
}
isGlobalAuthor(userId) {
const { teams, user } = this.props
if (!user.admin) {
const authorTeams = filter(teams, {
teamType: 'author',
global: true,
})
const membership = authorTeams.map(team => team.members.includes(userId))
return membership.includes(true)
}
return false
}
/*
Create the teams found in the config file for the given book.
This should run either when a new book is created,
......@@ -188,11 +205,13 @@ export class Dashboard extends React.Component {
for (let i = 0; i < teamTypes.length; i += 1) {
const teamType = teamTypes[i]
const members = []
const isGlobalPE = this.isGlobalProductionEditor(user.id)
const isGlobalAuthor = this.isGlobalAuthor(user.id)
if (!user.admin) {
if (
this.isProductionEditor(user.id) &&
teamType === 'productionEditor'
) {
if (isGlobalPE && teamType === 'productionEditor') {
members.push(user.id)
}
if (isGlobalAuthor && teamType === 'author') {
members.push(user.id)
}
}
......@@ -346,4 +365,7 @@ function mapDispatchToProps(dispatch) {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Dashboard)
export default connect(
mapStateToProps,
mapDispatchToProps,
)(Dashboard)
{
"name": "pubsweet-component-wax",
"description": "PubSweet component for the Wax collaborative document editor",
"version": "0.6.14",
"version": "0.6.15",
"main": "index.js",
"keywords": [
"wax",
......
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