Commit 53f136c8 authored by Tamlyn Rhodes's avatar Tamlyn Rhodes

Fix various issues

Reinstate missing Navigation header when logged in
Fix errors about missing `require` by switching webpack test target to `web`
Fix multiple issues on startup by defaulting NODE_ENV to `development`
Ensure db folder exists
Update pubsweet-client
parent 605ff208
Pipeline #2323 failed with stage
in 24 minutes and 35 seconds
......@@ -89,3 +89,4 @@ _build
coverage/
yarn-error.log
package-lock.json
config/local*.*
import React from 'react'
import config from 'config'
import AuthenticatedComponent from 'pubsweet-client/src/components/AuthenticatedComponent'
import Manage from 'pubsweet-component-manage/Manage'
import Navigation from '../Navigation/Navigation'
export default ({children, ...props}) => (
<AuthenticatedComponent
authsome={config.authsome}
operation='create'
selector={(state) => state.collections[0]}
{...props}
>
<Manage nav={<Navigation />}>
{children}
</Manage>
</AuthenticatedComponent>
)
import React from 'react'
import PropTypes from 'prop-types'
import { LinkContainer } from 'react-router-bootstrap'
import { Navbar, Nav, NavItem, NavbarBrand } from 'react-bootstrap'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import Authorize from 'pubsweet-client/src/helpers/Authorize'
import NavbarUser from 'pubsweet-component-navigation/NavbarUser'
import actions from 'pubsweet-client/src/actions'
export default class Navigation extends React.Component {
export class Navigation extends React.Component {
render () {
const { actions, currentUser } = this.props
let logoutButtonIfAuthenticated
......@@ -45,6 +48,20 @@ export default class Navigation extends React.Component {
}
Navigation.propTypes = {
actions: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object
actions: PropTypes.object.isRequired,
currentUser: PropTypes.object
}
function mapState (state) {
return {
currentUser: state.currentUser
}
}
function mapDispatch (dispatch) {
return {
actions: bindActionCreators(actions, dispatch)
}
}
export default connect(mapState, mapDispatch)(Navigation)
import React from 'react'
import { Route, Switch } from 'react-router-dom'
// import { Connected}
import { requireAuthentication } from 'pubsweet-client/src/components/AuthenticatedComponent'
// Manage
import Manage from 'pubsweet-component-manage/Manage'
import AuthenticatedManage from './components/AuthenticatedManage/AuthenticatedManage'
import PostsManager from 'pubsweet-component-posts-manager/PostsManagerContainer'
import UsersManager from 'pubsweet-component-users-manager/UsersManagerContainer'
import TeamsManager from 'pubsweet-component-teams-manager/TeamsManagerContainer'
......@@ -20,10 +18,6 @@ import HTML from 'pubsweet-component-html/HTMLContainer'
import Login from 'pubsweet-component-login/LoginContainer'
import Signup from 'pubsweet-component-signup/SignupContainer'
const AuthenticatedManage = requireAuthentication(
Manage, 'create', (state) => state.collections[0]
)
class Managed extends React.Component {
render () {
return <AuthenticatedManage>
......
......@@ -12,11 +12,11 @@
"@pubsweet/logger": "^0.0.1",
"jest": "^21.1.0",
"pubsweet": "git+https://git@gitlab.coko.foundation/yld/pubsweet-cli.git#refactor/db-manager",
"pubsweet-client": "1.0.0-beta.2",
"pubsweet-client": "^1.0.0-beta.3",
"pubsweet-component-blog": "^0.3.1",
"pubsweet-component-html": "^0.2.0",
"pubsweet-component-login": "^0.5.1",
"pubsweet-component-manage": "^0.1.10",
"pubsweet-component-manage": "^0.1.11",
"pubsweet-component-medium-draft": "^0.2.0",
"pubsweet-component-navigation": "^0.2.7",
"pubsweet-component-pepper-theme": "^0.0.3",
......@@ -74,7 +74,6 @@
"webpack-hot-middleware": "^2.18.0"
},
"scripts": {
"pretest": "npm run lint",
"lint": "eslint app test webpack",
"start": "node src/scripts/start.js",
"setupdb": "pubsweet setupdb",
......@@ -85,11 +84,6 @@
"testMatch": [
"**/test/*.js"
],
"collectCoverage": true,
"collectCoverageFrom": [
"**/src/scripts/*.js",
"**/app/**/*.js"
],
"modulePaths": [
"<rootDir>/node_modules"
],
......
require('app-module-path').addPath(process.cwd())
const path = require('path')
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'development'
}
const dotenvPath = path.join(process.cwd(), `.env.${process.env.NODE_ENV}`)
require('dotenv').config({ path: dotenvPath })
......@@ -24,10 +28,6 @@ const webpackconfig = require(path.join(
process.cwd(), 'webpack', `webpack.${process.env.NODE_ENV}.config.js`
))
if (process.env.NODE_ENV === 'test') {
webpackconfig.target = 'electron-main'
}
const registerDevtools = (app, compiler, cb) => {
app.use(require(
path.join(process.cwd(), 'node_modules', 'webpack-dev-middleware')
......@@ -137,7 +137,7 @@ const runapp = (err, stats, cb) => {
logger.info(`PubSweet is listening on port ${port}`)
serverListening = true
if (cb) cb(server) // used to enable testing
if (process.env.NODE_ENV === 'dev' && !watcher) startWatcher()
if (process.env.NODE_ENV === 'development' && !watcher) startWatcher()
}
server.on('error', onError)
......@@ -146,7 +146,7 @@ const runapp = (err, stats, cb) => {
server.listen(port)
}
if (process.env.NODE_ENV === 'dev') {
if (process.env.NODE_ENV === 'development') {
registerDevtools(rawapp, compiler, postcompile)
} else {
compiler.run(postcompile)
......
const path = require('path')
const webpack = require('webpack')
const ThemePlugin = require('pubsweet-theme-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const CompressionPlugin = require('compression-webpack-plugin')
const config = require('../config/client-test')
module.exports = [
{
// The configuration for the client
name: 'app',
target: 'electron-main',
target: 'web',
context: path.join(__dirname, '..', 'app'),
entry: {
app: [
......
This diff is collapsed.
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