Commit ad164f3a authored by Sam Galson's avatar Sam Galson

apply prettier

parent 1109360b
{
"extends": [
"standard",
"plugin:react/recommended"
"plugin:react/recommended",
"prettier",
"prettier/standard",
"prettier/react",
......
{
"*.{js, jsx}": ["prettier --write", "eslint --fix", "git add"]
}
{
"singleQuote": true,
"semi": false,
"printWidth": 100,
"printWidth": 80,
"trailingComma": "all"
}
module.exports = {
'pubsweet-client': {
'API_ENDPOINT': 'http://localhost:3000/api'
}
API_ENDPOINT: 'http://localhost:3000/api',
},
}
module.exports = {
'pubsweet-client': {
'API_ENDPOINT': 'http://example.com',
API_ENDPOINT: 'http://example.com',
'update-subscriber': {
visible: true
}
}
visible: true,
},
},
}
......@@ -5,6 +5,7 @@
"scripts": {
"compile": "babel -d lib/ src/",
"lint": "eslint --ext js,jsx src test",
"precommit": "lint-staged",
"test": "jest",
"testci": "gitlab-ci-multi-runner exec docker test"
},
......
......@@ -11,28 +11,28 @@ const collectionUrl = (collection, suffix) => {
return url
}
function getCollectionsRequest () {
function getCollectionsRequest() {
return {
type: T.GET_COLLECTIONS_REQUEST
type: T.GET_COLLECTIONS_REQUEST,
}
}
function getCollectionsFailure (error) {
function getCollectionsFailure(error) {
return {
type: T.GET_COLLECTIONS_FAILURE,
error: error
error: error,
}
}
function getCollectionsSuccess (collections) {
function getCollectionsSuccess(collections) {
return {
type: T.GET_COLLECTIONS_SUCCESS,
collections: collections,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
export function getCollections (options) {
export function getCollections(options) {
return dispatch => {
dispatch(getCollectionsRequest())
......@@ -42,191 +42,203 @@ export function getCollections (options) {
url += '?fields=' + encodeURIComponent(options.fields.join(','))
}
return api.get(url).then(
collections => dispatch(getCollectionsSuccess(collections)),
err => dispatch(getCollectionsFailure(err))
)
return api
.get(url)
.then(
collections => dispatch(getCollectionsSuccess(collections)),
err => dispatch(getCollectionsFailure(err)),
)
}
}
function getCollectionTeamsRequest () {
function getCollectionTeamsRequest() {
return {
type: T.GET_COLLECTION_TEAMS_REQUEST
type: T.GET_COLLECTION_TEAMS_REQUEST,
}
}
function getCollectionTeamsFailure (error) {
function getCollectionTeamsFailure(error) {
return {
type: T.GET_COLLECTION_TEAMS_FAILURE,
error: error
error: error,
}
}
function getCollectionTeamsSuccess (teams) {
function getCollectionTeamsSuccess(teams) {
return {
type: T.GET_COLLECTION_TEAMS_SUCCESS,
teams,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
export function getCollectionTeams (collection) {
export function getCollectionTeams(collection) {
return dispatch => {
dispatch(getCollectionTeamsRequest())
let url = collectionUrl(collection, 'teams')
return api.get(url).then(
teams => dispatch(getCollectionTeamsSuccess(teams)),
err => dispatch(getCollectionTeamsFailure(err))
)
return api
.get(url)
.then(
teams => dispatch(getCollectionTeamsSuccess(teams)),
err => dispatch(getCollectionTeamsFailure(err)),
)
}
}
function createCollectionRequest (collection) {
function createCollectionRequest(collection) {
return {
type: T.CREATE_COLLECTION_REQUEST,
collection: collection
collection: collection,
}
}
function createCollectionSuccess (collection) {
function createCollectionSuccess(collection) {
return {
type: T.CREATE_COLLECTION_SUCCESS,
collection: collection
collection: collection,
}
}
function createCollectionFailure (collection, error) {
function createCollectionFailure(collection, error) {
return {
type: T.CREATE_COLLECTION_FAILURE,
isFetching: false,
collection: collection,
error: error
error: error,
}
}
export function createCollection (collection) {
return (dispatch) => {
export function createCollection(collection) {
return dispatch => {
dispatch(createCollectionRequest(collection))
const url = collectionUrl()
return api.create(url, collection).then(
collection => dispatch(createCollectionSuccess(collection)),
err => dispatch(createCollectionFailure(collection, err))
)
return api
.create(url, collection)
.then(
collection => dispatch(createCollectionSuccess(collection)),
err => dispatch(createCollectionFailure(collection, err)),
)
}
}
function getCollectionRequest (collection) {
function getCollectionRequest(collection) {
return {
type: T.GET_COLLECTION_REQUEST,
collection: collection
collection: collection,
}
}
function getCollectionSuccess (collection) {
function getCollectionSuccess(collection) {
return {
type: T.GET_COLLECTION_SUCCESS,
collection: collection,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function getCollectionFailure (collection, error) {
function getCollectionFailure(collection, error) {
return {
type: T.GET_COLLECTION_FAILURE,
isFetching: false,
collection: collection,
error: error
error: error,
}
}
export function getCollection (collection) {
export function getCollection(collection) {
return dispatch => {
dispatch(getCollectionRequest(collection))
const url = collectionUrl(collection)
return api.get(url).then(
collection => dispatch(getCollectionSuccess(collection)),
err => dispatch(getCollectionFailure(collection, err))
)
return api
.get(url)
.then(
collection => dispatch(getCollectionSuccess(collection)),
err => dispatch(getCollectionFailure(collection, err)),
)
}
}
function updateCollectionRequest (collection) {
function updateCollectionRequest(collection) {
return {
type: T.UPDATE_COLLECTION_REQUEST,
collection: collection
collection: collection,
}
}
function updateCollectionSuccess (collection, update) {
function updateCollectionSuccess(collection, update) {
return {
type: T.UPDATE_COLLECTION_SUCCESS,
collection: collection,
update: update,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function updateCollectionFailure (collection, error) {
function updateCollectionFailure(collection, error) {
return {
type: T.UPDATE_COLLECTION_FAILURE,
isFetching: false,
collection: collection,
error: error
error: error,
}
}
export function updateCollection (collection) {
return (dispatch) => {
export function updateCollection(collection) {
return dispatch => {
dispatch(updateCollectionRequest(collection))
const url = collectionUrl(collection)
return api.update(url, collection).then(
update => dispatch(updateCollectionSuccess(collection, update)),
err => dispatch(updateCollectionFailure(collection, err))
)
return api
.update(url, collection)
.then(
update => dispatch(updateCollectionSuccess(collection, update)),
err => dispatch(updateCollectionFailure(collection, err)),
)
}
}
function deleteCollectionRequest (collection) {
function deleteCollectionRequest(collection) {
return {
type: T.DELETE_COLLECTION_REQUEST,
collection: collection,
update: {deleted: true}
update: { deleted: true },
}
}
function deleteCollectionSuccess (collection) {
function deleteCollectionSuccess(collection) {
return {
type: T.DELETE_COLLECTION_SUCCESS,
collection: collection
collection: collection,
}
}
function deleteCollectionFailure (collection, error) {
function deleteCollectionFailure(collection, error) {
return {
type: T.DELETE_COLLECTION_FAILURE,
collection: collection,
update: {deleted: undefined},
error: error
update: { deleted: undefined },
error: error,
}
}
export function deleteCollection (collection) {
return (dispatch) => {
export function deleteCollection(collection) {
return dispatch => {
dispatch(deleteCollectionRequest(collection))
const url = collectionUrl(collection)
return api.remove(url).then(
() => dispatch(deleteCollectionSuccess(collection)),
err => dispatch(deleteCollectionFailure(collection, err))
)
return api
.remove(url)
.then(
() => dispatch(deleteCollectionSuccess(collection)),
err => dispatch(deleteCollectionFailure(collection, err)),
)
}
}
import * as api from '../helpers/api'
import * as T from './types'
function getCurrentUserRequest () {
function getCurrentUserRequest() {
return {
type: T.GET_CURRENT_USER_REQUEST
type: T.GET_CURRENT_USER_REQUEST,
}
}
function getCurrentUserSuccess (user) {
function getCurrentUserSuccess(user) {
return {
type: T.GET_CURRENT_USER_SUCCESS,
user
user,
}
}
function getCurrentUserFailure (error) {
function getCurrentUserFailure(error) {
return {
type: T.GET_CURRENT_USER_FAILURE,
error
error,
}
}
export function getCurrentUser () {
export function getCurrentUser() {
return dispatch => {
dispatch(getCurrentUserRequest())
return api.get('/users/authenticate').then(
user => dispatch(getCurrentUserSuccess(user))
).catch(
err => dispatch(getCurrentUserFailure(err))
)
return api
.get('/users/authenticate')
.then(user => dispatch(getCurrentUserSuccess(user)))
.catch(err => dispatch(getCurrentUserFailure(err)))
}
}
import request from '../helpers/api'
import * as T from './types'
function fileUploadRequest () {
function fileUploadRequest() {
return {
type: T.FILE_UPLOAD_REQUEST,
isFetching: true
isFetching: true,
}
}
function fileUploadSuccess (file) {
function fileUploadSuccess(file) {
return {
type: T.FILE_UPLOAD_SUCCESS,
isFetching: false,
file: file
file: file,
}
}
function fileUploadFailure (message) {
function fileUploadFailure(message) {
return {
type: T.FILE_UPLOAD_FAILURE,
isFetching: false,
error: message
error: message,
}
}
export function fileUpload (file) {
return (dispatch) => {
export function fileUpload(file) {
return dispatch => {
dispatch(fileUploadRequest())
const data = new FormData()
......@@ -34,16 +34,15 @@ export function fileUpload (file) {
let opts = {
method: 'POST',
headers: {
'Accept': 'text/plain' // the response is a URL
Accept: 'text/plain', // the response is a URL
// TODO: set the Location header of the response instead
},
body: data
body: data,
}
return request('/upload', opts)
.then(
file => dispatch(fileUploadSuccess(file)),
err => dispatch(fileUploadFailure(err))
)
return request('/upload', opts).then(
file => dispatch(fileUploadSuccess(file)),
err => dispatch(fileUploadFailure(err)),
)
}
}
......@@ -19,31 +19,31 @@ export const collectionUrl = (collection, suffix) => {
return url
}
function getFragmentsRequest (collection) {
function getFragmentsRequest(collection) {
return {
type: T.GET_FRAGMENTS_REQUEST,
collection: collection
collection: collection,
}
}
function getFragmentsSuccess (collection, fragments) {
function getFragmentsSuccess(collection, fragments) {
return {
type: T.GET_FRAGMENTS_SUCCESS,
collection: collection,
fragments: fragments,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function getFragmentsFailure (error) {
function getFragmentsFailure(error) {
return {
type: T.GET_FRAGMENTS_FAILURE,
error: error
error: error,
}
}
export function getFragments (collection, options) {
return (dispatch) => {
export function getFragments(collection, options) {
return dispatch => {
dispatch(getFragmentsRequest(collection))
let url = collectionUrl(collection, 'fragments')
......@@ -52,159 +52,169 @@ export function getFragments (collection, options) {
url += '?fields=' + encodeURIComponent(options.fields.join(','))
}
return api.get(url).then(
fragments => dispatch(getFragmentsSuccess(collection, fragments)),
err => dispatch(getFragmentsFailure(err))
)
return api
.get(url)
.then(
fragments => dispatch(getFragmentsSuccess(collection, fragments)),
err => dispatch(getFragmentsFailure(err)),
)
}
}
function createFragmentRequest (fragment) {
function createFragmentRequest(fragment) {
return {
type: T.CREATE_FRAGMENT_REQUEST,
fragment: fragment
fragment: fragment,
}
}
function createFragmentSuccess (collection, fragment) {
function createFragmentSuccess(collection, fragment) {
return {
type: T.CREATE_FRAGMENT_SUCCESS,
collection: collection,
fragment: fragment
fragment: fragment,
}
}
function createFragmentFailure (fragment, error) {
function createFragmentFailure(fragment, error) {
return {
type: T.CREATE_FRAGMENT_FAILURE,
isFetching: false,
fragment: fragment,
error: error
error: error,
}
}
export function createFragment (collection, fragment) {
return (dispatch) => {
export function createFragment(collection, fragment) {
return dispatch => {
dispatch(createFragmentRequest(fragment))
const url = fragmentUrl(collection, fragment)
return api.create(url, fragment).then(
fragment => dispatch(createFragmentSuccess(collection, fragment)),
err => dispatch(createFragmentFailure(fragment, err))
)
return api
.create(url, fragment)
.then(
fragment => dispatch(createFragmentSuccess(collection, fragment)),
err => dispatch(createFragmentFailure(fragment, err)),
)
}
}
function getFragmentRequest (fragment) {
function getFragmentRequest(fragment) {
return {
type: T.GET_FRAGMENT_REQUEST,
fragment: fragment
fragment: fragment,
}
}
function getFragmentSuccess (fragment) {
function getFragmentSuccess(fragment) {
return {
type: T.GET_FRAGMENT_SUCCESS,
fragment: fragment,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function getFragmentFailure (fragment, error) {
function getFragmentFailure(fragment, error) {
return {
type: T.GET_FRAGMENT_FAILURE,
isFetching: false,
fragment: fragment,
error: error
error: error,
}
}
export function getFragment (collection, fragment) {
export function getFragment(collection, fragment) {
return dispatch => {
dispatch(getFragmentRequest(fragment))
const url = fragmentUrl(collection, fragment)
return api.get(url).then(
fragment => dispatch(getFragmentSuccess(fragment)),
err => dispatch(getFragmentFailure(fragment, err))
)
return api
.get(url)
.then(
fragment => dispatch(getFragmentSuccess(fragment)),
err => dispatch(getFragmentFailure(fragment, err)),
)
}
}
function updateFragmentRequest (fragment) {
function updateFragmentRequest(fragment) {
return {
type: T.UPDATE_FRAGMENT_REQUEST,
fragment: fragment
fragment: fragment,
}
}
function updateFragmentSuccess (fragment, update) {
function updateFragmentSuccess(fragment, update) {
return {
type: T.UPDATE_FRAGMENT_SUCCESS,
fragment: fragment,
update: update,
receivedAt: Date.now()
receivedAt: Date.now(),
}
}
function updateFragmentFailure (fragment, error) {
function updateFragmentFailure(fragment, error) {
return {
type: T.UPDATE_FRAGMENT_FAILURE,
isFetching: false,
fragment: fragment,
error: error
error: error,
}
}
export function updateFragment (collection, fragment) {
return (dispatch) => {
export function updateFragment(collection, fragment) {
return dispatch => {
dispatch(updateFragmentRequest(fragment))
const url = fragmentUrl(collection, fragment)
return api.update(url, fragment).then(
update => dispatch(updateFragmentSuccess(fragment, update)),
err => dispatch(updateFragmentFailure(fragment, err))
)
return api
.update(url, fragment)
.then(
update => dispatch(updateFragmentSuccess(fragment, update)),
err => dispatch(updateFragmentFailure(fragment, err)),
)
}
}
function deleteFragmentRequest (fragment) {
function deleteFragmentRequest(fragment) {
return {
type: T.DELETE_FRAGMENT_REQUEST,
fragment: fragment,
update: { deleted: true }
update: { deleted: true },
}
}
function deleteFragmentSuccess (collection, fragment) {
function deleteFragmentSuccess(collection, fragment) {
return {
type: T.DELETE_FRAGMENT_SUCCESS,
collection: collection,
fragment: fragment
fragment: fragment,
}
}
function deleteFragmentFailure (fragment, error) {
function deleteFragmentFailure(fragment, error) {
return {
type: T.DELETE_FRAGMENT_FAILURE,
fragment: fragment,
update: { deleted: undefined },
error: error
error: error,
}
}
export function deleteFragment (collection, fragment) {
return (dispatch) => {
export function deleteFragment(collection, fragment) {
return dispatch => {
dispatch(deleteFragmentRequest(fragment))
const url = fragmentUrl(collection, fragment)
return api.remove(url).then(
json => dispatch(deleteFragmentSuccess(collection, fragment)),
err => dispatch(deleteFragmentFailure(fragment, err))
)
return api
.remove(url)
.then(