Commit 3a3cac73 authored by Alexandros Georgantas's avatar Alexandros Georgantas

chore(app): conflicts fix

parents 259aae57 781bc8df
{
"presets": [
"env",
"react",
"stage-2"
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-function-sent",
"@babel/plugin-proposal-export-namespace-from",
"@babel/plugin-proposal-numeric-separator",
"@babel/plugin-proposal-throw-expressions",
"@babel/plugin-proposal-class-properties"
]
}
\ No newline at end of file
}
.env
.env.*
coverage/
config/*.env
......@@ -11,3 +12,4 @@ tmp/
uploads/*
yarn-error.log
data
scripts/link.sh
const logger = require('@pubsweet/logger')
const startServer = require('pubsweet-server')
const { startServer } = require('pubsweet-server')
startServer().catch(err => {
logger.error('FATAL ERROR, SHUTTING DOWN:', err)
......
......@@ -2,38 +2,51 @@ import 'regenerator-runtime/runtime'
import React from 'react'
import ReactDOM from 'react-dom'
import { hot } from 'react-hot-loader'
import { configureStore, Root } from 'pubsweet-client'
import { AppContainer } from 'react-hot-loader'
import createHistory from 'history/createBrowserHistory'
import { Root } from 'pubsweet-client'
// Modals
import ModalProvider from 'editoria-common/src/ModalProvider'
import AddBookModal from 'pubsweet-component-editoria-dashboard/src/modals/AddBookModal'
import DeleteBookModal from 'pubsweet-component-editoria-dashboard/src/modals/DeleteBookModal'
import ArchiveBookModal from 'pubsweet-component-editoria-dashboard/src/modals/ArchiveBookModal'
import DeleteBookComponentModal from 'pubsweet-component-bookbuilder/src/ui/src/modals/DeleteBookComponentModal'
import BookTeamManagerModal from 'pubsweet-component-bookbuilder/src/TeamManager/ConnectedTeamManager'
import WarningModal from 'pubsweet-component-bookbuilder/src/ui/src/modals/WarningModal'
import ErrorModal from 'pubsweet-component-bookbuilder/src/ui/src/modals/ErrorModal'
import UnlockModal from 'pubsweet-component-bookbuilder/src/ui/src/modals/UnlockModal'
import MetadataModal from 'pubsweet-component-bookbuilder/src/ui/src/modals/MetadataModal'
import WorkflowModal from 'pubsweet-component-bookbuilder/src/ui/src/modals/WorkflowModal'
import UnlockedModal from 'pubsweet-component-wax/src/modals/UnlockedModal'
import theme from './theme'
import routes from './routes'
const history = createHistory()
const store = configureStore(history, {})
const modals = {
addBook: AddBookModal,
deleteBook: DeleteBookModal,
archiveBook: ArchiveBookModal,
deleteBookComponent: DeleteBookComponentModal,
bookTeamManager: BookTeamManagerModal,
warningModal: WarningModal,
unlockModal: UnlockModal,
metadataModal: MetadataModal,
workflowModal: WorkflowModal,
errorModal: ErrorModal,
unlockedModal: UnlockedModal,
}
const rootEl = document.getElementById('root')
ReactDOM.render(
<AppContainer>
<Root history={history} routes={routes} store={store} theme={theme} />
</AppContainer>,
<ModalProvider modals={modals}>
<Root history={history} routes={routes} theme={theme} />
</ModalProvider>,
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,
)
})
}
export default hot(module)(Root)
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 pathnameSplitted = pathname.split('/')
this.collectionId = pathnameSplitted[2] // eslint-disable-line
}
}
render() {
const { logoutUser, currentUser } = this.props
let logoutButtonIfAuthenticated
if (currentUser.user === null) return null
if (currentUser.isAuthenticated) {
logoutButtonIfAuthenticated = (
<NavbarUser
onLogoutClick={() => logoutUser('/login')}
user={currentUser.user}
/>
)
}
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 object="users" operation="can view nav links">
<LinkContainer to="/users">
<NavItem>Users</NavItem>
</LinkContainer>
<LinkContainer to="/globalTeams">
<NavItem>Global Teams</NavItem>
</LinkContainer>
</Authorize>
{BackToBooks}
</Nav>
{logoutButtonIfAuthenticated}
</Navbar>
)
}
}
Navigation.propTypes = {
currentUser: PropTypes.any, // eslint-disable-line
history: PropTypes.any.isRequired, // eslint-disable-line
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, // eslint-disable-line
}
export default withRouter(
connect(
state => ({
currentUser: state.currentUser,
}),
{
getCurrentUser: actions.getCurrentUser,
},
)(PrivateRoute),
)
import { css } from 'styled-components'
export default css`
color: #404040;
font-size: 16px;
margin-bottom: 0px;
text-decoration: none;
&:hover {
color: #404040;
text-decoration: none;
}
&:focus,
&:active {
color: #555;
font-weight: bold;
text-decoration: none;
}
`
import { css } from 'styled-components'
// This is not necessary is just a quick
// fix and should be deleted, is done
// temporary so not to mess around with pubsweet
export default css`
display: flex;
`
import { css } from 'styled-components'
export default css`
background-color: #404040;
background-image: none;
border: 1px solid transparent;
border-radius: 0;
color: #fff;
cursor: pointer;
display: block;
font-size: 14px;
font-weight: normal;
line-height: 1.42857;
margin-bottom: 20px;
padding: 6px 12px;
text-align: center;
touch-action: manipulation;
vertical-align: middle;
white-space: nowrap;
width: 100%;
&:hover {
background-color: #404040;
}
`
import { css } from 'styled-components'
export default css`
border-left: 4px solid #404040;
border-right: 4px solid #d8d8d8;
padding-left: 40px !important;
padding-right: 40px !important;
`
import { css } from 'styled-components'
export default {
H1: css`
color: #404040;
margin-bottom: 5px;
margin-top: 5px;
padding-bottom: 20px;
padding-top: 0;
`,
}
import { css } from 'styled-components'
export default css`
margin-left: auto;
margin-right: auto;
width: 150px;
img {
filter: grayscale(100%);
margin-bottom: 30px;
margin-top: 30px;
max-width: 100%;
}
`
import styled from 'styled-components'
import { fadeIn, th } from '@pubsweet/ui-toolkit'
const Page = styled.div`
flex: auto;
/* font-family: ${th('fontInterface')}; */
height: 100%;
overflow-y: auto;
/* padding: calc(${th('gridUnit')} * 2); */
> div {
animation: ${fadeIn} 0.5s;
}
`
export default Page
// import React from 'react'
import styled from 'styled-components'
// HACK -- figure out why this is needed
// injectGlobal`
// html {
// height: 100%;
// }
// body {
// height: 100%;
// overflow: hidden;
// }
// `
const PageLayout = styled.div`
display: flex;
flex-direction: column;
height: 100%;
`
export default PageLayout
import { css } from 'styled-components'
import { th } from '@pubsweet/ui-toolkit'
export default {
// TODO
// -- input padding: breaking the grid?
// -- small placeholder text? maybe by default?
Label: css`
color: #404040;
margin-bottom: 5px;
`,
Input: css`
border: 2px solid #b0b0b0;
border-right: 4px solid #484848;
box-sizing: border-box;
color: ${props => {
switch (props.validationStatus) {
case 'success':
return props.theme.colorSuccess
case 'warning':
return props.theme.colorWarning
case 'error':
return props.theme.colorError
default:
return 'inherit'
}
}};
height: 34px;
padding: 6px 12px;
transition: ${th('transitionDuration')} ${th('transitionTimingFunction')};
&:focus {
border-color: ${th('colorPrimary')};
color: inherit;
}
&::placeholder {
font-size: ${th('fontSizeBaseSmall')};
line-height: ${th('lineHeightBaseSmall')};
}
`,
}
export { default as Action } from './Action'
export { default as AppBar } from './AppBar'
export { default as FormContainer } from './FormContainer'
export { default as TextField } from './TextField'
export { default as Heading } from './Heading'
export { default as Button } from './Button'
export { default as Logo } from './Logo'
import React from 'react'
import React, { Fragment } from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'
import { createGlobalStyle } from 'styled-components'
// 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'
// import UsersManager from 'pubsweet-component-users-manager/src/UsersManager'
import GlobalTeamsManager from 'pubsweet-component-editoria-global-teams/src/ConnectedGlobalTeams'
// Authentication
import Login from 'pubsweet-component-login/LoginContainer'
import Signup from 'pubsweet-component-signup/SignupContainer'
import Login from 'editoria-component-login/src/LoginContainer'
import Signup from 'editoria-component-signup/src/SignupContainer'
import PasswordReset from 'pubsweet-component-password-reset-frontend/PasswordReset'
// Editor
import Wax from 'pubsweet-component-wax/src/WaxPubsweet'
import Wax from 'pubsweet-component-wax/src/ConnectedWax'
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 BookBuilder from 'pubsweet-component-bookbuilder/src/ConnectedBookBuilder'
import Dashboard from 'pubsweet-component-editoria-dashboard/src/ConnectedDashboard'
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'
import Navigation from 'pubsweet-component-editoria-navigation/src/Navigation'
import PrivateRoute from 'pubsweet-component-editoria-navigation/src/PrivateRoute'
import Connected from 'pubsweet-component-editoria-navigation/src/ConnectedNavigation'
import PageLayout from './elements/PageLayout'
import Page from './elements/Page'
// Pass configuration to editor
const Editor = WithConfig(Wax, {
......@@ -30,106 +33,80 @@ const Editor = WithConfig(Wax, {
lockWhenEditing: true,
pollingTimer: 1500,
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',
],
menus: {
topToolBar: 'topDefault',
sideToolBar: 'sideDefault',
overlay: 'defaultOverlay',
},
})
// 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>
// )
//
const ConnectedNavigation = Connected(Navigation)
const GlobalStyle = createGlobalStyle`
html {
height: 100%;
}
body {
height: 100%;
overflow: hidden;
#root,
#root > div {
height: 100%;
}
#root > div > div {
height: 100%;
}
}
`
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"
<Fragment>
<GlobalStyle />
<Switch>
<Redirect exact path="/" to="/books" />
<Route
path="/login"
render={props => (
<Login {...props} logo="/assets/pubsweet-rgb-small.jpg" />
)}
/>
<PrivateRoute component={BookBuilder} path="/books/:id/book-builder" />
<PrivateRoute
component={Editor}
path="/books/:bookId/fragments/:fragmentId"
<Route
path="/signup"
render={props => (
<Signup {...props} logo="/assets/pubsweet-rgb-small.jpg" />
)}
/>
<PrivateRoute component={UsersManager} path="/users" />
<PrivateRoute component={GlobalTeamsManager} path="/globalTeams" />
</Manage>
</Switch>
<Route component={PasswordReset} path="/password-reset" />
<PageLayout>
<ConnectedNavigation />
<Page>
<Switch>
<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/bookComponents/:bookComponentId"
/>
<PrivateRoute
component={Editor}
exact
path="/books/:bookId/bookComponents/:bookComponentId/preview"
/>
{/* <PrivateRoute component={UsersManager} path="/users" /> */}
<PrivateRoute component={GlobalTeamsManager} path="/globalTeams" />
</Switch>
</Page>
</PageLayout>
</Switch>
</Fragment>
)
// 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'
import theme from '@pubsweet/coko-theme'
import { clone } from 'lodash'
import {
FormContainer,
TextField,
Heading,
Button,
Logo,
Action,
AppBar,
} from './elements'
import 'typeface-fira-sans'
export default {
/* Text variables */