Commit 8bfc2568 authored by Alexandros Georgantas's avatar Alexandros Georgantas

Merge branch 'global-teams' into 'master'

Global teams

See merge request !107
parents 4fab3aad 5eaaf2bb
{
"name": "pubsweet-component-bookbuilder",
"version": "1.1.1",
"version": "1.1.4",
"description": "",
"main": "index.js",
"scripts": {
......@@ -32,7 +32,7 @@
"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"
},
"devDependencies": {
......
......@@ -474,7 +474,12 @@ function mapStateToProps(state, { match }) {
'index',
)
if (book) {
teams = _.filter(state.teams, t => t.object.id === book.id)
teams = _.filter(state.teams, t => {
if (!t.global) {
return t.object.id === book.id
}
return false
})
}
const { error, currentUser: user, users } = state
......
......@@ -2,6 +2,7 @@ import { flow } from 'lodash'
import React from 'react'
import PropTypes from 'prop-types'
import { DragSource, DropTarget } from 'react-dnd'
import config from 'config'
import Authorize from 'pubsweet-client/src/helpers/Authorize'
import FirstRow from './Chapter/FirstRow'
import SecondRow from './Chapter/SecondRow'
......@@ -32,9 +33,15 @@ class Chapter extends React.PureComponent {
const { book, update, chapter } = this.props
// SHOULD BE REMOVED. This automaticaly sets track changes on for the case
// or review in progress
if (patch.progress) {
if (patch.progress.review === 0 && chapter.trackChanges === false) {
patch.trackChanges = true
if (
config.bookBuilder &&
config.bookBuilder.instance &&
config.bookBuilder.instance === 'UCP'
) {
if (patch.progress) {
if (patch.progress.review === 0 && chapter.trackChanges === false) {
patch.trackChanges = true
}
}
}
update(book, patch)
......
import { get, includes } from 'lodash'
import { get } from 'lodash'
import React from 'react'
import PropTypes from 'prop-types'
import withLink from 'editoria-common/src/withLink'
......
{
"presets": [
"env",
"react",
"stage-2"
]
}
\ No newline at end of file
node_modules
\ No newline at end of file
**/_build
**/node_modules
**/coverage
{
"parser": "babel-eslint",
"env": {
"es6": true,
"browser": true
},
"extends": ["pubsweet"],
"rules": {
"import/no-dynamic-require": 0,
"import/no-extraneous-dependencies": 0,
"sort-keys": 0
},
"overrides": [
{
"files": ["test/**/*.test.js"],
"globals": {
"fixture": true,
"text": true
}
}
]
}
# Created by https://www.gitignore.io/api/osx,node
### OSX ###
*.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Node ###
# Logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# IDEs
.idea
# pubsweet-specific
myapp
testapp
api/db/*
/data
!api/db/.gitkeep
.vscode
.wallaby.js
logs
.env.*
_build
coverage/
yarn-error.log
package-lock.json
config/local*.*
config/*.env
### Editoria 1.0, July 2017
Editoria was started as a collaboration between UCP and Coko, initial funding came from the Mellon Foundation.
Those involved in conceptualising, designing, and building Editoria (including the Wax Editor) from 0 to 1.0 include:
* Erich van Rijn
* Catherine Mitchell
* Kate Warne
* Cindy Fulton
* Lisa Schiff
* Justin Gonder
* Juliana Froggatt
* Adam Hyde
* Kristen Ratan
* Yannis Barlas
* Christos Kokosias
* Julien Taquet
* Alex Theg
* Alexandros Georgantas
* Giannis Kopanas
MIT License
Copyright (c) 2017 University of California Press
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
\ No newline at end of file
const logger = require('@pubsweet/logger')
const startServer = require('pubsweet-server')
startServer().catch(err => {
logger.error('FATAL ERROR, SHUTTING DOWN:', err)
process.exit(1)
})
import 'regenerator-runtime/runtime'
import React from 'react'
import ReactDOM from 'react-dom'
import { configureStore, Root } from 'pubsweet-client'
import theme from './theme'
import { AppContainer } from 'react-hot-loader'
import createHistory from 'history/createBrowserHistory'
import routes from './routes'
const history = createHistory()
const store = configureStore(history, {})
const rootEl = document.getElementById('root')
ReactDOM.render(
<AppContainer>
<Root history={history} routes={routes} store={store} theme={theme} />
</AppContainer>,
rootEl,
)
if (module.hot) {
module.hot.accept('pubsweet-client/src/components/Root', () => {
// eslint-disable-next-line global-require
const NextRoot = require('pubsweet-client/src/components/Root').default
ReactDOM.render(
<AppContainer>
<NextRoot history={history} routes={routes} store={store} />
</AppContainer>,
rootEl,
)
})
}
import React from 'react'
import PropTypes from 'prop-types'
import { withRouter } from 'react-router-dom'
import { LinkContainer } from 'react-router-bootstrap'
import { Navbar, Nav, NavItem, NavbarBrand } from 'react-bootstrap'
import { connect } from 'react-redux'
import Authorize from 'pubsweet-client/src/helpers/Authorize'
import NavbarUser from 'pubsweet-component-navigation/NavbarUser'
import actions from 'pubsweet-client/src/actions'
// TODO -- break into smaller components
class Navigation extends React.Component {
constructor(props) {
super(props)
this.collectionId = ''
this.inEditor = null
this.inPaged = null
}
componentDidMount() {
this.shouldAddBookLink()
}
componentWillUpdate() {
this.shouldAddBookLink()
}
shouldAddBookLink() {
const { history } = this.props
const { location } = history
const { pathname } = location
this.collectionId = ''
this.inEditor = null
this.inPaged = null
this.inEditor = pathname.match(/fragments/g)
this.inPaged = pathname.match(/pagedPreviewer\/paged/g)
if (this.inEditor || this.inPaged) {
const pathnameSplited = pathname.split('/')
this.collectionId = pathnameSplited[2]
}
}
render() {
const { logoutUser, currentUser } = this.props
let logoutButtonIfAuthenticated
if (currentUser.user === null) return null
if (currentUser.isAuthenticated) {
logoutButtonIfAuthenticated = (
<NavbarUser
user={currentUser.user}
onLogoutClick={() => logoutUser('/login')}
/>
)
}
let BackToBooks
if (this.inEditor || this.inPaged) {
BackToBooks = (
<LinkContainer to={`/books/${this.collectionId}/book-builder`}>
<NavItem>Back to book</NavItem>
</LinkContainer>
)
}
// TODO -- fix object properties underneath
return (
<Navbar fluid>
<Navbar.Header>
<NavbarBrand>
<a href="/">Editoria</a>
</NavbarBrand>
</Navbar.Header>
<Nav>
<LinkContainer to="/books">
<NavItem>Books</NavItem>
</LinkContainer>
<Authorize operation="can view nav links" object="users">
<LinkContainer to="/users">
<NavItem>Users</NavItem>
</LinkContainer>
</Authorize>
{BackToBooks}
</Nav>
{logoutButtonIfAuthenticated}
</Navbar>
)
}
}
Navigation.propTypes = {
currentUser: PropTypes.any,
history: PropTypes.any.isRequired,
logoutUser: PropTypes.func.isRequired,
}
export default withRouter(
connect(
state => ({
currentUser: state.currentUser,
}),
{
logoutUser: actions.logoutUser,
},
)(Navigation),
)
.root {
font-style: italic;
}
\ No newline at end of file
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { Route, Redirect, withRouter } from 'react-router-dom'
import { actions } from 'pubsweet-client'
class PrivateRoute extends React.Component {
constructor(props) {
super(props)
this.state = {
complete: false,
}
}
componentDidMount() {
const onComplete = () => {
this.setState({
complete: true,
})
}
this.props.getCurrentUser().then(onComplete, onComplete)
}
render() {
const {
currentUser,
getCurrentUser,
component: Component,
...rest
} = this.props
return (
<Route
render={props => {
// complete, authenticated
if (currentUser.isAuthenticated) {
return <Component {...props} />
}
// complete, not authenticated
if (this.state.complete) {
return (
<Redirect
to={{
pathname: '/login',
state: { from: props.location },
}}
/>
)
}
// incomplete, loading
if (currentUser.isFetching) {
return <div>loading…</div>
}
// incomplete, not yet loading
return null
}}
{...rest}
/>
)
}
}
PrivateRoute.propTypes = {
component: PropTypes.func.isRequired,
currentUser: PropTypes.shape({
isAuthenticated: PropTypes.bool.isRequired,
isFetching: PropTypes.bool.isRequired,
}).isRequired,
getCurrentUser: PropTypes.func.isRequired,
location: PropTypes.object.isRequired,
}
export default withRouter(
connect(
state => ({
currentUser: state.currentUser,
}),
{
getCurrentUser: actions.getCurrentUser,
},
)(PrivateRoute),
)
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<div id="root"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<div id="root"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="root"></div>
<script type="text/javascript" charset="utf-8" src="/assets/app.js"></script>
</body>
</html>
import React from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'
// Users and Teams
import UsersManager from 'pubsweet-component-users-manager/UsersManagerContainer'
// import TeamsManager from 'pubsweet-component-teams-manager/TeamsManagerContainer'
// Authentication
import Login from 'pubsweet-component-login/LoginContainer'
import Signup from 'pubsweet-component-signup/SignupContainer'
import PasswordReset from 'pubsweet-component-password-reset-frontend/PasswordReset'
// Editor
import Wax from 'pubsweet-component-wax/src/WaxPubsweet'
import WithConfig from 'pubsweet-component-wax/src/WithConfig'
// Editoria
import BookBuilder from 'pubsweet-component-bookbuilder/src/BookBuilder'
import Dashboard from 'pubsweet-component-editoria-dashboard/src/Dashboard'
import PagedStyler from 'pubsweet-component-bookbuilder/src/PagedStyler/PagedStyler'
import Manage from 'pubsweet-component-manage/Manage'
import Navigation from './components/Navigation/Navigation'
import PrivateRoute from './components/PrivateRoute'
// import AuthenticatedManage from './components/AuthenticatedManage/AuthenticatedManage'
// Pass configuration to editor
const Editor = WithConfig(Wax, {
layout: 'editoria',
lockWhenEditing: true,
pollingTimer: 1000,
autoSave: false,
tools: [
'document',
'annotations',
'note',
'inline-note',
'ornament',
'diacritics-tool',
'find-and-replace-tool',
'track-change',
'spell-check',
'highlighter',
'full-screen-control',
'shortcuts-modal',
'track-change-controls',
],
})
// export default (
// <Manage nav={<Navigation />}>
// <Switch>
// <Redirect exact path='/' to='/books' />
// <PrivateRoute exact path='/books' component={Dashboard} />
// <PrivateRoute path='/books/:id/book-builder' component={BookBuilder} />
// <PrivateRoute path='/books/:bookId/fragments/:fragmentId' component={Editor} />
// <PrivateRoute path='/teams' component={TeamsManager} />
// <PrivateRoute path='/users' component={UsersManager} />
// <Route path='/login' component={Login} />
// <Route path='/signup' component={Signup} />
// <Route path='/password-reset' component={PasswordReset} />
// </Switch>
// </Manage>
// )
// export default (
// <Switch>
// <Redirect exact path="/" to="/books" />
// <Route path="/login" component={Login} />
// <Route path="/signup" component={Signup} />
// <Route path="/password-reset" component={PasswordReset} />
// <div>
// <Navigation />
// <PrivateRoute exact path="/books" component={Dashboard} />
// <PrivateRoute path="/books/:id/book-builder" component={BookBuilder} />
// <PrivateRoute
// path="/books/:bookId/fragments/:fragmentId"
// component={Editor}
// />
// <PrivateRoute path="/teams" component={TeamsManager} />
// <PrivateRoute path="/users" component={UsersManager} />
// </div>
// </Switch>
// )
export default (
<Switch>
<Redirect exact path="/" to="/books" />
<Route component={Login} path="/login" />
<Route component={Signup} path="/signup" />
<Route component={PasswordReset} path="/password-reset" />
<Manage nav={<Navigation />}>
<PrivateRoute component={Dashboard} exact path="/books" />
<PrivateRoute
component={PagedStyler}
path="/books/:id/pagedPreviewer/paged/:hashed"
/>
<PrivateRoute component={BookBuilder} path="/books/:id/book-builder" />
<PrivateRoute
component={Editor}
path="/books/:bookId/fragments/:fragmentId"
/>
<PrivateRoute component={UsersManager} path="/users" />
</Manage>
</Switch>
)
// const Managed = () => (
// <AuthenticatedManage>
// <Switch>
// <Route component={Dashboard} path="/manage/books" />
// <Route component={UsersManager} path="/manage/users" />
// <Route component={TeamsManager} path="/manage/teams" />
// <Route component={BookBuilder} path="/manage/books/:id/book-builder" />
// </Switch>
// </AuthenticatedManage>
// )
// export default (
// <Switch>
// <Route component={Managed} path="/manage" />
// <Route component={Login} path="/login" />
// <Route component={Signup} path="/signup" />
// </Switch>
// )
/* eslint-disable import/extensions */
import 'typeface-fira-sans'
export default {
/* Text variables */
// fonts
fontInterface: "'Fira Sans'",
}
[
"pubsweet-component-epub",
"pubsweet-component-epub-frontend",
"pubsweet-component-ink-backend",
"pubsweet-component-ink-frontend",
"pubsweet-component-login",
"pubsweet-component-password-reset-backend",
"pubsweet-component-password-reset-frontend",
"pubsweet-component-signup",
"pubsweet-component-vivliostyle-viewer",
"pubsweet-component-pagedjs-viewer",
"pubsweet-component-wax",
"@pubsweet/component-polling-client",
"@pubsweet/component-polling-server",
"pubsweet-component-theme-editoria"
]