Commit d6424dd9 authored by Jure's avatar Jure

Merge branch 'feat/apply-prettier' into 'master'

Feat/apply prettier

See merge request !115
parents 2bdca5ca ad164f3a
Pipeline #2736 passed with stage
in 1 minute and 47 seconds
{ {
"extends": [ "extends": [
"standard", "standard",
"plugin:react/recommended" "plugin:react/recommended",
"prettier",
"prettier/standard",
"prettier/react",
], ],
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
...@@ -12,9 +15,6 @@ ...@@ -12,9 +15,6 @@
"env": { "env": {
"browser": true "browser": true
}, },
"plugins": [
"react"
],
"globals": { "globals": {
"PUBSWEET_COMPONENTS": true "PUBSWEET_COMPONENTS": true
} }
......
{
"*.{js, jsx}": ["prettier --write", "eslint --fix", "git add"]
}
{
"singleQuote": true,
"semi": false,
"printWidth": 80,
"trailingComma": "all"
}
language: node_js
env:
- CXX=g++-4.8
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.8
before_install:
- export JOBS=max
node_js:
- "4.0"
- "4"
- "5"
- "stable"
sudo: false
module.exports = { module.exports = {
'pubsweet-client': { 'pubsweet-client': {
'API_ENDPOINT': 'http://localhost:3000/api' API_ENDPOINT: 'http://localhost:3000/api',
} },
} }
module.exports = { module.exports = {
'pubsweet-client': { 'pubsweet-client': {
'API_ENDPOINT': 'http://example.com', API_ENDPOINT: 'http://example.com',
'update-subscriber': { 'update-subscriber': {
visible: true visible: true,
} },
} },
} }
...@@ -5,22 +5,27 @@ ...@@ -5,22 +5,27 @@
"scripts": { "scripts": {
"compile": "babel -d lib/ src/", "compile": "babel -d lib/ src/",
"lint": "eslint --ext js,jsx src test", "lint": "eslint --ext js,jsx src test",
"precommit": "lint-staged",
"test": "jest", "test": "jest",
"testci": "gitlab-ci-multi-runner exec docker test" "testci": "gitlab-ci-multi-runner exec docker test"
}, },
"engines": { "engines": {
"node": ">=7.7.0", "node": ">=8.6.0",
"npm": ">=3.0.0" "npm": ">=5.0.0"
}, },
"author": "Collaborative Knowledge Foundation", "author": "Collaborative Knowledge Foundation",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"authsome": "0.0.9", "authsome": "0.0.9",
"config": "^1.21.0", "config": "^1.21.0",
"eslint-config-prettier": "^2.6.0",
"event-source-polyfill": "^0.0.10", "event-source-polyfill": "^0.0.10",
"global": "^4.3.1", "global": "^4.3.1",
"husky": "^0.14.3",
"isomorphic-fetch": "^2.1.1", "isomorphic-fetch": "^2.1.1",
"lint-staged": "^4.2.3",
"lodash": "^4.0.0", "lodash": "^4.0.0",
"prettier": "^1.7.4",
"prop-types": "^15.5.8", "prop-types": "^15.5.8",
"pubsweet-component-login": "^0.5.2", "pubsweet-component-login": "^0.5.2",
"react": "^15.4.4", "react": "^15.4.4",
......
...@@ -11,28 +11,28 @@ const collectionUrl = (collection, suffix) => { ...@@ -11,28 +11,28 @@ const collectionUrl = (collection, suffix) => {
return url return url
} }
function getCollectionsRequest () { function getCollectionsRequest() {
return { return {
type: T.GET_COLLECTIONS_REQUEST type: T.GET_COLLECTIONS_REQUEST,
} }
} }
function getCollectionsFailure (error) { function getCollectionsFailure(error) {
return { return {
type: T.GET_COLLECTIONS_FAILURE, type: T.GET_COLLECTIONS_FAILURE,
error: error error: error,
} }
} }
function getCollectionsSuccess (collections) { function getCollectionsSuccess(collections) {
return { return {
type: T.GET_COLLECTIONS_SUCCESS, type: T.GET_COLLECTIONS_SUCCESS,
collections: collections, collections: collections,
receivedAt: Date.now() receivedAt: Date.now(),
} }
} }
export function getCollections (options) { export function getCollections(options) {
return dispatch => { return dispatch => {
dispatch(getCollectionsRequest()) dispatch(getCollectionsRequest())
...@@ -42,191 +42,203 @@ export function getCollections (options) { ...@@ -42,191 +42,203 @@ export function getCollections (options) {
url += '?fields=' + encodeURIComponent(options.fields.join(',')) url += '?fields=' + encodeURIComponent(options.fields.join(','))
} }
return api.get(url).then( return api
collections => dispatch(getCollectionsSuccess(collections)), .get(url)
err => dispatch(getCollectionsFailure(err)) .then(
) collections => dispatch(getCollectionsSuccess(collections)),
err => dispatch(getCollectionsFailure(err)),
)
} }
} }
function getCollectionTeamsRequest () { function getCollectionTeamsRequest() {
return { return {
type: T.GET_COLLECTION_TEAMS_REQUEST type: T.GET_COLLECTION_TEAMS_REQUEST,
} }
} }
function getCollectionTeamsFailure (error) { function getCollectionTeamsFailure(error) {
return { return {
type: T.GET_COLLECTION_TEAMS_FAILURE, type: T.GET_COLLECTION_TEAMS_FAILURE,
error: error error: error,
} }
} }
function getCollectionTeamsSuccess (teams) { function getCollectionTeamsSuccess(teams) {
return { return {
type: T.GET_COLLECTION_TEAMS_SUCCESS, type: T.GET_COLLECTION_TEAMS_SUCCESS,
teams, teams,
receivedAt: Date.now() receivedAt: Date.now(),
} }
} }
export function getCollectionTeams (collection) { export function getCollectionTeams(collection) {
return dispatch => { return dispatch => {
dispatch(getCollectionTeamsRequest()) dispatch(getCollectionTeamsRequest())
let url = collectionUrl(collection, 'teams') let url = collectionUrl(collection, 'teams')
return api.get(url).then( return api
teams => dispatch(getCollectionTeamsSuccess(teams)), .get(url)
err => dispatch(getCollectionTeamsFailure(err)) .then(
) teams => dispatch(getCollectionTeamsSuccess(teams)),
err => dispatch(getCollectionTeamsFailure(err)),
)
} }
} }
function createCollectionRequest (collection) { function createCollectionRequest(collection) {
return { return {
type: T.CREATE_COLLECTION_REQUEST, type: T.CREATE_COLLECTION_REQUEST,
collection: collection collection: collection,
} }
} }
function createCollectionSuccess (collection) { function createCollectionSuccess(collection) {
return { return {
type: T.CREATE_COLLECTION_SUCCESS, type: T.CREATE_COLLECTION_SUCCESS,
collection: collection collection: collection,
} }
} }
function createCollectionFailure (collection, error) { function createCollectionFailure(collection, error) {
return { return {
type: T.CREATE_COLLECTION_FAILURE, type: T.CREATE_COLLECTION_FAILURE,
isFetching: false, isFetching: false,
collection: collection, collection: collection,
error: error error: error,
} }
} }
export function createCollection (collection) { export function createCollection(collection) {
return (dispatch) => { return dispatch => {
dispatch(createCollectionRequest(collection)) dispatch(createCollectionRequest(collection))
const url = collectionUrl() const url = collectionUrl()
return api.create(url, collection).then( return api
collection => dispatch(createCollectionSuccess(collection)), .create(url, collection)
err => dispatch(createCollectionFailure(collection, err)) .then(
) collection => dispatch(createCollectionSuccess(collection)),
err => dispatch(createCollectionFailure(collection, err)),
)
} }
} }
function getCollectionRequest (collection) { function getCollectionRequest(collection) {
return { return {
type: T.GET_COLLECTION_REQUEST, type: T.GET_COLLECTION_REQUEST,
collection: collection collection: collection,
} }
} }
function getCollectionSuccess (collection) { function getCollectionSuccess(collection) {
return { return {
type: T.GET_COLLECTION_SUCCESS, type: T.GET_COLLECTION_SUCCESS,
collection: collection, collection: collection,
receivedAt: Date.now() receivedAt: Date.now(),
} }
} }
function getCollectionFailure (collection, error) { function getCollectionFailure(collection, error) {
return { return {
type: T.GET_COLLECTION_FAILURE, type: T.GET_COLLECTION_FAILURE,
isFetching: false, isFetching: false,
collection: collection, collection: collection,
error: error error: error,
} }
} }
export function getCollection (collection) { export function getCollection(collection) {
return dispatch => { return dispatch => {
dispatch(getCollectionRequest(collection)) dispatch(getCollectionRequest(collection))
const url = collectionUrl(collection) const url = collectionUrl(collection)
return api.get(url).then( return api
collection => dispatch(getCollectionSuccess(collection)), .get(url)
err => dispatch(getCollectionFailure(collection, err)) .then(
) collection => dispatch(getCollectionSuccess(collection)),
err => dispatch(getCollectionFailure(collection, err)),
)
} }
} }
function updateCollectionRequest (collection) { function updateCollectionRequest(collection) {
return { return {
type: T.UPDATE_COLLECTION_REQUEST, type: T.UPDATE_COLLECTION_REQUEST,
collection: collection collection: collection,
} }
} }
function updateCollectionSuccess (collection, update) { function updateCollectionSuccess(collection, update) {
return { return {
type: T.UPDATE_COLLECTION_SUCCESS, type: T.UPDATE_COLLECTION_SUCCESS,
collection: collection, collection: collection,
update: update, update: update,
receivedAt: Date.now() receivedAt: Date.now(),
} }
} }
function updateCollectionFailure (collection, error) { function updateCollectionFailure(collection, error) {
return { return {
type: T.UPDATE_COLLECTION_FAILURE, type: T.UPDATE_COLLECTION_FAILURE,
isFetching: false, isFetching: false,
collection: collection, collection: collection,
error: error error: error,
} }
} }
export function updateCollection (collection) { export function updateCollection(collection) {
return (dispatch) => { return dispatch => {
dispatch(updateCollectionRequest(collection)) dispatch(updateCollectionRequest(collection))
const url = collectionUrl(collection) const url = collectionUrl(collection)
return api.update(url, collection).then( return api
update => dispatch(updateCollectionSuccess(collection, update)), .update(url, collection)
err => dispatch(updateCollectionFailure(collection, err)) .then(
) update => dispatch(updateCollectionSuccess(collection, update)),
err => dispatch(updateCollectionFailure(collection, err)),
)
} }
} }
function deleteCollectionRequest (collection) { function deleteCollectionRequest(collection) {
return { return {
type: T.DELETE_COLLECTION_REQUEST, type: T.DELETE_COLLECTION_REQUEST,
collection: collection, collection: collection,
update: {deleted: true} update: { deleted: true },
} }
} }
function deleteCollectionSuccess (collection) { function deleteCollectionSuccess(collection) {
return { return {
type: T.DELETE_COLLECTION_SUCCESS, type: T.DELETE_COLLECTION_SUCCESS,
collection: collection collection: collection,
} }
} }
function deleteCollectionFailure (collection, error) { function deleteCollectionFailure(collection, error) {
return { return {
type: T.DELETE_COLLECTION_FAILURE, type: T.DELETE_COLLECTION_FAILURE,
collection: collection, collection: collection,
update: {deleted: undefined}, update: { deleted: undefined },
error: error error: error,
} }
} }
export function deleteCollection (collection) { export function deleteCollection(collection) {
return (dispatch) => { return dispatch => {
dispatch(deleteCollectionRequest(collection)) dispatch(deleteCollectionRequest(collection))
const url = collectionUrl(collection) const url = collectionUrl(collection)
return api.remove(url).then( return api
() => dispatch(deleteCollectionSuccess(collection)), .remove(url)
err => dispatch(deleteCollectionFailure(collection, err)) .then(
) () => dispatch(deleteCollectionSuccess(collection)),
err => dispatch(deleteCollectionFailure(collection, err)),
)
} }
} }
import * as api from '../helpers/api' import * as api from '../helpers/api'
import * as T from './types' import * as T from './types'
function getCurrentUserRequest () { function getCurrentUserRequest() {
return { return {
type: T.GET_CURRENT_USER_REQUEST type: T.GET_CURRENT_USER_REQUEST,
} }
} }
function getCurrentUserSuccess (user) { function getCurrentUserSuccess(user) {
return { return {
type: T.GET_CURRENT_USER_SUCCESS, type: T.GET_CURRENT_USER_SUCCESS,
user user,
} }
} }
function getCurrentUserFailure (error) { function getCurrentUserFailure(error) {
return { return {
type: T.GET_CURRENT_USER_FAILURE, type: T.GET_CURRENT_USER_FAILURE,
error error,
} }
} }
export function getCurrentUser () { export function getCurrentUser() {
return dispatch => { return dispatch => {
dispatch(getCurrentUserRequest()) dispatch(getCurrentUserRequest())
return api.get('/users/authenticate').then( return api
user => dispatch(getCurrentUserSuccess(user)) .get('/users/authenticate')
).catch( .then(user => dispatch(getCurrentUserSuccess(user)))
err => dispatch(getCurrentUserFailure(err)) .catch(err => dispatch(getCurrentUserFailure(err)))
)
} }
} }
import request from '../helpers/api' import request from '../helpers/api'
import * as T from './types' import * as T from './types'
function fileUploadRequest () { function fileUploadRequest() {
return { return {
type: T.FILE_UPLOAD_REQUEST, type: T.FILE_UPLOAD_REQUEST,
isFetching: true isFetching: true,
} }
} }
function fileUploadSuccess (file) { function fileUploadSuccess(file) {
return { return {
type: T.FILE_UPLOAD_SUCCESS, type: T.FILE_UPLOAD_SUCCESS,
isFetching: false, isFetching: false,
file: file file: file,
} }
} }
function fileUploadFailure (message) { function fileUploadFailure(message) {
return { return {
type: T.FILE_UPLOAD_FAILURE, type: T.FILE_UPLOAD_FAILURE,
isFetching: false, isFetching: false,
error: message error: message,
} }
} }
export function fileUpload (file) { export function fileUpload(file) {
return (dispatch) => { return dispatch => {
dispatch(fileUploadRequest()) dispatch(fileUploadRequest())
const data = new FormData() const data = new FormData()
...@@ -34,16 +34,15 @@ export function fileUpload (file) { ...@@ -34,16 +34,15 @@ export function fileUpload (file) {
let opts = { let opts = {
method: 'POST', method: 'POST',
headers: { 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 // TODO: set the Location header of the response instead
}, },
body: data body: data,
} }
return request('/upload', opts) return request('/upload', opts).then(
.then( file => dispatch(fileUploadSuccess(file)),
file => dispatch(fileUploadSuccess(file)), err => dispatch(fileUploadFailure(err)),
err => dispatch(fileUploadFailure(err)) )
)
} }
} }
...@@ -19,31 +19,31 @@ export const collectionUrl = (collection, suffix) => { ...@@ -19,31 +19,31 @@ export const collectionUrl = (collection, suffix) => {
return url return url
} }
function getFragmentsRequest (collection) { function getFragmentsRequest(collection) {
return { return {
type: T.GET_FRAGMENTS_REQUEST, type: T.GET_FRAGMENTS_REQUEST,
collection: collection collection: collection,
} }
} }
function getFragmentsSuccess (collection, fragments) { function getFragmentsSuccess(collection, fragments) {
return { return {
type: T.GET_FRAGMENTS_SUCCESS, type: T.GET_FRAGMENTS_SUCCESS,
collection: collection, collection: collection,
fragments: fragments, fragments: fragments,
receivedAt: Date.now() receivedAt: Date.now(),
} }
} }