Commit 5c0860cc authored by Alexandros Georgantas's avatar Alexandros Georgantas

Merge branch 'global-teams' into 'staging'

Global teams

See merge request editoria/ucp!1
parents e144864b a65f20e7
.env.*
coverage/
config/*.env
node_modules/
npm-debug.log
_build/*
......
......@@ -81,10 +81,13 @@ class Navigation extends React.Component {
<NavItem>Books</NavItem>
</LinkContainer>
<Authorize operation="can view nav links" object="users">
<Authorize object="users" operation="can view nav links">
<LinkContainer to="/users">
<NavItem>Users</NavItem>
</LinkContainer>
<LinkContainer to="/globalTeams">
<NavItem>Global Teams</NavItem>
</LinkContainer>
</Authorize>
{BackToBooks}
......
......@@ -3,6 +3,7 @@ import { Redirect, Route, Switch } from 'react-router-dom'
// Users and Teams
import UsersManager from 'pubsweet-component-users-manager/UsersManagerContainer'
import GlobalTeamsManager from 'pubsweet-component-editoria-global-teams/src/GlobalTeamsManager'
// import TeamsManager from 'pubsweet-component-teams-manager/TeamsManagerContainer'
// Authentication
......@@ -108,6 +109,7 @@ export default (
path="/books/:bookId/fragments/:fragmentId"
/>
<PrivateRoute component={UsersManager} path="/users" />
<PrivateRoute component={GlobalTeamsManager} path="/globalTeams" />
</Manage>
</Switch>
)
......
export PUBSWEET_SECRET='dev_secret'
export POSTGRES_USER='dev'
export POSTGRES_PASSWORD='secretpassword'
export POSTGRES_HOST='localhost'
export POSTGRES_DB='editoria_dev'
export POSTGRES_PORT='5460'
export SERVER_PORT='3050'
export INK_ENDPOINT='http://inkdemo-api.coko.foundation/'
export INK_USERNAME='editoria@coko.foundation'
export INK_PASSWORD='editoria'
export INK_EDITORIA_TYPESCRIPT='2'
export MAILER_USER='xpub@sandbox9af3d5dc64334deca9759efe7056d6b3.mailgun.org'
export MAILER_PASSWORD='xpubpass'
export MAILER_SENDER='dev@example.com'
export MAILER_HOSTNAME='smtp.mailgun.org'
export PASSWORD_RESET_URL='http://localhost:3000/password-reset'
export PASSWORD_RESET_SENDER='dev@example.com'
export NODE_ENV='development'
export ADMIN_USERNAME='admin'
export ADMIN_EMAIL='admin@example.com'
export ADMIN_PASSWORD='adminadmin'
\ No newline at end of file
......@@ -55,7 +55,7 @@ class EditoriaMode {
team.object &&
team.object.id === object.id
} else {
membershipCondition = team => team.teamType === teamType
membershipCondition = team => team.teamType === teamType && team.global
}
const memberships = await Promise.all(
......@@ -79,9 +79,10 @@ class EditoriaMode {
collection = object
}
const membershipCondition = team => team.object.id === collection.id
const membershipCondition = team =>
!team.global && team.object.id === collection.id
const memberships = await Promise.all(
const memberships = await Promise.all(
this.user.teams.map(async teamId => {
const teamFound = await this.context.models.Team.find(teamId)
if (teamFound) {
......@@ -105,9 +106,10 @@ class EditoriaMode {
return this.isTeamMember('productionEditor', object)
}
isProductionEditor() {
async isGlobalProductionEditor() {
return this.isTeamMember('productionEditor')
}
async findCollectionByObject(object) {
let id
if (object.collection) {
......@@ -179,7 +181,7 @@ class EditoriaMode {
async canListTeams() {
this.user = await this.context.models.User.find(this.userId)
// if (await this.isProductionEditor()) {
// if (await this.isGlobalProductionEditor()) {
// return true
// }
......@@ -209,7 +211,7 @@ class EditoriaMode {
async canCreateTeam() {
this.user = await this.context.models.User.find(this.userId)
return this.isProductionEditor()
return this.isGlobalProductionEditor()
}
async canUpdateTeam() {
......@@ -227,7 +229,7 @@ class EditoriaMode {
async canCreateCollection() {
this.user = await this.context.models.User.find(this.userId)
return this.isProductionEditor()
return this.isGlobalProductionEditor()
}
async canInteractWithCollections() {
......
......@@ -26,4 +26,7 @@ module.exports = {
title: Joi.string().allow(null),
trackChanges: Joi.boolean(),
},
team: {
global: Joi.boolean().allow(null),
},
}
export PUBSWEET_SECRET='prod_secret'
export POSTGRES_USER='prod'
export POSTGRES_PASSWORD='secretpassword'
export POSTGRES_HOST='localhost'
export POSTGRES_DB='editoria_prod'
export POSTGRES_PORT='5465'
export SERVER_PORT='3000'
export INK_ENDPOINT='http://inkdemo-api.coko.foundation/'
export INK_USERNAME='editoria@coko.foundation'
export INK_PASSWORD='editoria'
export INK_EDITORIA_TYPESCRIPT='2'
export MAILER_USER='xpub@sandbox9af3d5dc64334deca9759efe7056d6b3.mailgun.org'
export MAILER_PASSWORD='xpubpass'
export MAILER_SENDER='prod@example.com'
export MAILER_HOSTNAME='smtp.mailgun.org'
export PASSWORD_RESET_URL='http://localhost:3000/password-reset'
export PASSWORD_RESET_SENDER='prod@example.com'
export NODE_ENV='production'
\ No newline at end of file
......@@ -34,8 +34,9 @@
"prop-types": "^15.6.0",
"pubsweet": "^2.2.8",
"pubsweet-client": "^2.5.5",
"pubsweet-component-bookbuilder": "^1.1.2",
"pubsweet-component-editoria-dashboard": "^0.1.1",
"pubsweet-component-bookbuilder": "^1.1.4",
"pubsweet-component-editoria-dashboard": "^0.1.2",
"pubsweet-component-editoria-global-teams": "^0.1.1",
"pubsweet-component-epub": "^0.5.2",
"pubsweet-component-epub-frontend": "^0.1.3",
"pubsweet-component-ink-backend": "^0.1.1",
......@@ -50,7 +51,7 @@
"pubsweet-component-theme-editoria": "^0.0.5",
"pubsweet-component-users-manager": "1.0.0",
"pubsweet-component-vivliostyle-viewer": "^1.0.0",
"pubsweet-component-wax": "^0.6.14",
"pubsweet-component-wax": "^0.6.15",
"pubsweet-server": "^7.2.0",
"pubsweet-theme-plugin": "^0.0.3",
"react": "^16.2.0",
......@@ -154,11 +155,12 @@
]
},
"scripts": {
"setupdb": "pubsweet setupdb ./",
"setupdb": "pubsweet setupdb && npm run seed",
"start": "pubsweet start",
"server": "pubsweet start",
"resetdb": "pubsweet setupdb --clobber ./",
"resetdb": "pubsweet setupdb --clobber && npm run seed",
"start:services": "docker-compose up postgres",
"seed": "node ./scripts/seedGlobalTeams.js",
"test": "NODE_ENV=test jest",
"test:watch": "NODE_ENV=test jest --watch",
"test:cover": "NODE_ENV=test jest --coverage",
......
#!/usr/bin/env node
const logger = require('@pubsweet/logger')
const { Team } = require('pubsweet-server/src/models')
const makeTeam = async type => {
const names = {
productionEditor: 'Production Editor',
}
logger.info(`Create ${names[type]} team`)
const team = new Team({
global: true,
members: [],
name: names[type],
teamType: type,
})
await team.save()
logger.info(`${names[type]} team successfully created`)
}
const seed = async () => {
logger.info('### RUNNING GLOBAL TEAMS SEED SCRIPTS ###')
logger.info('=> Checking if global teams exist...')
try {
const teams = await Team.findByField({ global: true })
const productionEditorTeam = teams.find(
t => t.teamType === 'productionEditor',
)
if (productionEditorTeam) {
logger.info('All global teams found, exiting...')
} else {
logger.warn('No Production Editor team found')
await makeTeam('productionEditor')
}
} catch (err) {
logger.warn('No global teams found')
await makeTeam('productionEditor')
}
logger.info('Team seed successfully finished')
}
seed()
......@@ -5404,6 +5404,17 @@ formatio@1.1.1:
dependencies:
samsam "~1.1"
formik@^0.11.11:
version "0.11.11"
resolved "https://registry.yarnpkg.com/formik/-/formik-0.11.11.tgz#4b02838133c0196b1ef443aa973766cd097ec4a5"
integrity sha1-SwKDgTPAGWse9EOqlzdmzQl+xKU=
dependencies:
lodash.clonedeep "^4.5.0"
lodash.isequal "4.5.0"
lodash.topath "4.5.2"
prop-types "^15.5.10"
warning "^3.0.0"
forwarded@~0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84"
......@@ -7793,7 +7804,7 @@ lodash.clonedeep@^3.0.0:
lodash._baseclone "^3.0.0"
lodash._bindcallback "^3.0.0"
lodash.clonedeep@^4.3.2:
lodash.clonedeep@^4.3.2, lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
......@@ -7853,7 +7864,7 @@ lodash.isarray@^3.0.0:
resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55"
integrity sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=
lodash.isequal@^4.5.0:
lodash.isequal@4.5.0, lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=
......@@ -7947,6 +7958,11 @@ lodash.toarray@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561"
integrity sha1-JMS/zWsvuji/0FlNsRedjptlZWE=
lodash.topath@4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.topath/-/lodash.topath-4.5.2.tgz#3616351f3bba61994a0931989660bd03254fd009"
integrity sha1-NhY1Hzu6YZlKCTGYlmC9AyVP0Ak=
lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
......@@ -10355,10 +10371,10 @@ pubsweet-client@^2.5.0, pubsweet-client@^2.5.5:
styled-components "^3.2.5"
styled-normalize "^3.0.1"
pubsweet-component-bookbuilder@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/pubsweet-component-bookbuilder/-/pubsweet-component-bookbuilder-1.1.2.tgz#50ded8fa44705c85c4d8c86b58992ca15f5f5342"
integrity sha512-bbhguWEpuumxGSon8SsPc4uok+m4q0m/s9mbW5i+mHPYl+5fdW039P42RvbxPNchIxNaDXPROhVnmqhf0JfUMg==
pubsweet-component-bookbuilder@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/pubsweet-component-bookbuilder/-/pubsweet-component-bookbuilder-1.1.4.tgz#76181feee30ff5b01c98b93309b6a4c551baaf52"
integrity sha512-9e8YSAUA0O9MZqzx/B4THDD7FPcp+curEBR3K7LyQyqkifHOaJBLqhhVRRt4SbB5KqBiwEG2GkD1LvudjlqjMQ==
dependencies:
axios "^0.17.1"
classnames "^2.2.5"
......@@ -10377,13 +10393,13 @@ pubsweet-component-bookbuilder@^1.1.2:
react-redux "5.0.4"
react-router-bootstrap "0.24.4"
react-router-dom "4.2.2"
react-select "^2.0.0"
react-select "^2.1.1"
redux "3.7.2"
pubsweet-component-editoria-dashboard@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/pubsweet-component-editoria-dashboard/-/pubsweet-component-editoria-dashboard-0.1.1.tgz#639173033cd2ddb6784e9388ed650bbc37075a17"
integrity sha512-wt54bOgE5Iy6KLAlCpBYwgTe9mFYhybLnsAprQRurHy4SqBba21At7TNHz58/LsLbEeJ3psvzMHrkQCd/sdZwQ==
pubsweet-component-editoria-dashboard@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/pubsweet-component-editoria-dashboard/-/pubsweet-component-editoria-dashboard-0.1.2.tgz#7d4d590cf855abddb8db88663c81de210f898562"
integrity sha512-/+ZoWrRx9Q93MtXOPWJevWAAXEPP+i55o4j/rgOMt0QXawpnhQrp548f4w1VxiOpelmL3oQRQ3j2RSyn0X9tOA==
dependencies:
editoria-common "^0.1.1"
lodash "4.17.4"
......@@ -10393,6 +10409,26 @@ pubsweet-component-editoria-dashboard@^0.1.1:
react-router-dom "4.2.2"
redux "3.6.0"
pubsweet-component-editoria-global-teams@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/pubsweet-component-editoria-global-teams/-/pubsweet-component-editoria-global-teams-0.1.1.tgz#215beba7b1b175e3c367091d17805f2efb63a570"
integrity sha512-CaXIfPtbHVNDMgDJjXbPbl7cuWwgFCF9POf1k7YBDsbTh+ct2VcJDYLu5c1fwZjW/3xdmBpWMWZYC1smGCD54w==
dependencies:
classnames "^2.2.5"
config "^1.27.0"
editoria-common "^0.1.1"
font-awesome "4.7.0"
formik "^0.11.11"
lodash "4.17.4"
pubsweet-client "^2.5.5"
react "^16.2.0"
react-dom "^16.2.0"
react-redux "5.0.4"
react-router-dom "4.2.2"
react-select "^2.1.1"
redux "3.7.2"
styled-components "^3.3.0"
pubsweet-component-epub-frontend@^0.1.3:
version "0.1.6"
resolved "https://registry.yarnpkg.com/pubsweet-component-epub-frontend/-/pubsweet-component-epub-frontend-0.1.6.tgz#31e8a48312bf29c80230c22b047591ff4cf67009"
......@@ -10530,10 +10566,10 @@ pubsweet-component-vivliostyle-viewer@^1.0.0:
extract-zip "1.6.6"
request "^2.81.0"
pubsweet-component-wax@^0.6.14:
version "0.6.14"
resolved "https://registry.yarnpkg.com/pubsweet-component-wax/-/pubsweet-component-wax-0.6.14.tgz#74ab04dedb96ce678854b7604a230e98e9c8debb"
integrity sha512-zkCG0SFbd4aBtRMfu09ze/vmVSjLNsV027JVwFr4CeGFyCSHSEPBr24yMYPEKP/+I7cPQM5fVIeW8BHxvLPwow==
pubsweet-component-wax@^0.6.15:
version "0.6.15"
resolved "https://registry.yarnpkg.com/pubsweet-component-wax/-/pubsweet-component-wax-0.6.15.tgz#da1caa8c04fe3984c054ea60b320c40705f3a868"
integrity sha512-rcRw7qKX6y+eKd3BoLgz7kGCEM7K1lrnHF/pQbaPFFsml+9wZvR8uEQBVwk8Ods6oeyedb/kjKWKvn/XxiUMig==
dependencies:
lodash "4.17.4"
pubsweet-client "^2.5.5"
......@@ -11083,7 +11119,7 @@ react-router@^4.2.0, react-router@^4.3.1:
prop-types "^15.6.1"
warning "^4.0.1"
react-select@^2.0.0:
react-select@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/react-select/-/react-select-2.1.1.tgz#762d0babd8c7c46a944db51cbb72e4ee117253f9"
integrity sha512-ukie2LJStNfJEJ7wtqA+crAfzYpkpPr86urvmJGisECwsWJob9boCM4zjmKCi5QR7G8uY9+v7ZoliJpeCz/4xw==
......@@ -12600,7 +12636,7 @@ style-search@^0.1.0:
resolved "https://registry.yarnpkg.com/style-search/-/style-search-0.1.0.tgz#7958c793e47e32e07d2b5cafe5c0bf8e12e77902"
integrity sha1-eVjHk+R+MuB9K1yv5cC/jhLneQI=
styled-components@^3.2.5:
styled-components@^3.2.5, styled-components@^3.3.0:
version "3.4.10"
resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-3.4.10.tgz#9a654c50ea2b516c36ade57ddcfa296bf85c96e1"
integrity sha512-TA8ip8LoILgmSAFd3r326pKtXytUUGu5YWuqZcOQVwVVwB6XqUMn4MHW2IuYJ/HAD81jLrdQed8YWfLSG1LX4Q==
......
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