Skip to content

Commit

Permalink
Merge branch 'develop' into feat/local-api-address
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmoses committed Jun 24, 2019
2 parents b1f4ae4 + 3d3a202 commit c1329d3
Show file tree
Hide file tree
Showing 49 changed files with 1,767 additions and 536 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@dadi"
}
7 changes: 1 addition & 6 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
{
"bracketSpacing": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2
}
"@dadi/prettier-config"
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ notifications:
node_js:
- '8'
- '10'
- 'lts/*'
16 changes: 16 additions & 0 deletions app/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true
},
"plugins": ["react"],
"rules": {
"react/jsx-uses-react": "error",
"react/jsx-uses-vars": "error"
}
}
30 changes: 17 additions & 13 deletions app/actions/documentActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ export function fetchDocumentList({
dispatch(
setDocumentList({
contentKey,
metadata: metadata,
results: results,
metadata,
results,
timestamp: currentTs
})
)
Expand Down Expand Up @@ -457,7 +457,7 @@ export function saveDocument({contentKey, collection, documentId}) {
!payload[field] ||
!['Media', 'Reference'].includes(schema.type)
) {
return
return null
}

const schemaSettings = schema.settings || {}
Expand All @@ -478,14 +478,16 @@ export function saveDocument({contentKey, collection, documentId}) {
// that must be uploaded first. When the upload is complete, this array
// can be used to reconstruct `referencedDocuments` with the result of
// the uploads.
let uploadIndexes = []
let documentsToUpload = referencedDocuments.filter(
const uploadIndexes = []
const documentsToUpload = referencedDocuments.filter(
(document, index) => {
if (document._id === undefined) {
uploadIndexes.push(index)

return true
}

return false
}
)
let uploadJob = Promise.resolve(referencedDocuments)
Expand Down Expand Up @@ -520,13 +522,15 @@ export function saveDocument({contentKey, collection, documentId}) {
.then(reference => {
payload[field] = referenceLimit > 1 ? reference : reference[0]
})
} else {
const reference = referencedDocuments
.map(document => document._id)
.filter(Boolean)

payload[field] = referenceLimit > 1 ? reference : reference[0]
}

const reference = referencedDocuments
.map(document => document._id)
.filter(Boolean)

payload[field] = referenceLimit > 1 ? reference : reference[0]

return null
})

Promise.all(referenceQueue)
Expand Down Expand Up @@ -562,8 +566,8 @@ export function saveDocument({contentKey, collection, documentId}) {
type: Types.SAVE_DOCUMENT_FAILURE
})

let dataUpdate = {}
let errorUpdate = {}
const dataUpdate = {}
const errorUpdate = {}

errors.forEach(error => {
if (error.field) {
Expand Down
10 changes: 5 additions & 5 deletions app/actions/userActions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'unfetch/polyfill'
import * as Constants from 'lib/constants'
import * as Types from 'actions/actionTypes'
import {batchActions} from 'lib/redux'
import apiBridgeClient from 'lib/api-bridge-client'
import {batchActions} from 'lib/redux'

/**
* Registers a successful authentication.
Expand Down Expand Up @@ -38,9 +38,9 @@ export function saveUser() {
return (dispatch, getState) => {
dispatch(setUserStatus(Constants.STATUS_SAVING))

let {api} = getState().app.config
let update = getState().user.local
let apiBridge = apiBridgeClient({
const {api} = getState().app.config
const update = getState().user.local
const apiBridge = apiBridgeClient({
accessToken: getState().user.accessToken,
api
})
Expand Down Expand Up @@ -70,7 +70,7 @@ export function saveUser() {
dispatch(setRemoteUser(results[0]))
})
.catch(error => {
let actions = [setUserStatus(Constants.STATUS_FAILED, error)]
const actions = [setUserStatus(Constants.STATUS_FAILED, error)]

// The operation failed because the current secret was missing
// or invalid, so we must create a validation error accordingly.
Expand Down
10 changes: 6 additions & 4 deletions app/components/ColorPicker/util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable prefer-const */

/**
* Convert HSV representation to RGB HEX string.
* Credits to raphaeljs
Expand All @@ -17,11 +19,11 @@ function hsv2rgb(hsv) {
G += [X, C, C, X, 0, 0][h]
B += [0, 0, X, C, C, X][h]

let r = Math.floor(R * 255)
let g = Math.floor(G * 255)
let b = Math.floor(B * 255)
const r = Math.floor(R * 255)
const g = Math.floor(G * 255)
const b = Math.floor(B * 255)

let hex = (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1)
const hex = (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1)

return {r, g, b, hex} // eslint-disable-line
}
Expand Down
2 changes: 1 addition & 1 deletion app/components/FieldNumber/FieldNumberEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export default class FieldNumberEdit extends React.Component {
onFocus={this.handleFocusChange.bind(this, true)}
readOnly={publishBlock.readonly === true}
type="number"
value={internalValue || (value && value.toString())}
value={(internalValue || value || '').toString()}
/>
</Label>
)
Expand Down
2 changes: 1 addition & 1 deletion app/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {applyMiddleware, compose, createStore} from 'redux'
import App from './containers/App/App'
import {enableBatching} from './lib/redux'
import {Provider} from 'react-redux'
import App from './containers/App/App'
import React from 'react'
import ReactDOM from 'react-dom'
import reducers from './reducers'
Expand Down
2 changes: 1 addition & 1 deletion app/lib/api-bridge-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const apiBridgeFactory = function({
const {database, version} = collection

const callback = requestObject => {
let augmentedRequestObject = Object.assign({}, requestObject, {
const augmentedRequestObject = Object.assign({}, requestObject, {
headers: {
Authorization: `Bearer ${accessToken}`
}
Expand Down
6 changes: 3 additions & 3 deletions app/lib/datetime.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ export default class DateTime {
// as a timestamp.
if (intDate.toString() === date) {
return new Date(intDate)
} else {
// We assume the input string is in ISO8601 format.
return this._parse(date, FORMAT_ISO8601)
}

// We assume the input string is in ISO8601 format.
return this._parse(date, FORMAT_ISO8601)
}
}
}
Expand Down
13 changes: 0 additions & 13 deletions app/lib/field-components.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/lib/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getFieldType(schema) {

export function getVisibleFields({fields = {}, viewType}) {
let foundDisplayProperty = false
let enabledFields = Object.keys(fields).reduce((enabledFields, field) => {
const enabledFields = Object.keys(fields).reduce((enabledFields, field) => {
// Is there a publish block with a display property defined fro this view
// type?
if (
Expand Down
1 change: 1 addition & 0 deletions app/lib/hot-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class HotKeys {
}

_capture(allowDefaultHandlers, event) {
// eslint-disable-next-line array-callback-return
Object.keys(this.handlers).some(key => {
if (this.handlers[key].hotKey(event)) {
if (!allowDefaultHandlers) {
Expand Down
2 changes: 1 addition & 1 deletion app/lib/redux.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function batchActions(...args) {
const actions = args.length === 1 ? args[0] : args

return {
actions: actions,
actions,
type: Types.BATCH_ACTIONS
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/lib/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {decodeSearch} from 'lib/util/url'
import {withRouter} from 'react-router'
import React from 'react'
import {withRouter} from 'react-router'

export function connectRouter(WrappedComponent) {
class Extractor extends React.Component {
Expand Down
15 changes: 8 additions & 7 deletions app/lib/util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function arrayToObject(arr, keyField) {
{},
...arr
.map(obj => {
if (!obj.value || !obj[keyField]) return
if (!obj.value || !obj[keyField]) return null

return {[obj[keyField] || 'key']: obj.value}
})
Expand All @@ -45,9 +45,9 @@ export function isValidJSON(string) {

return /^[\],:{}\s]*$/.test(
string
.replace(/\\["\\\/bfnrtu]/g, '@')
.replace(/\\["\\/bfnrtu]/g, '@')
.replace(
/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,
']'
)
.replace(/(?:^|:|,)(?:\s*\[)+/g, '')
Expand All @@ -60,13 +60,14 @@ export function debounce(func, wait, immediate) {
// Must return standard function.
// An arrow function here would not use arguments.
return function() {
let context = this
let args = arguments
let later = () => {
const context = this
const args = arguments
const later = () => {
timeout = null
if (!immediate) func.apply(context, args)
}
let callNow = immediate && !timeout

const callNow = immediate && !timeout

clearTimeout(timeout)
timeout = setTimeout(later, wait)
Expand Down
6 changes: 4 additions & 2 deletions app/lib/util/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function decodeSearch(searchString) {
try {
// Trying to parse valid JSON parameters.
parameters[key] = JSON.parse(parameters[key])
} catch (err) {}
} catch (err) {
// noop
}
})

return parameters
Expand All @@ -34,7 +36,7 @@ export function encodeSearch(searchObject) {
})

if (!hasSetKeys) {
return
return ''
}

try {
Expand Down
Loading

0 comments on commit c1329d3

Please sign in to comment.