Skip to content

Commit

Permalink
Merge branch 'release-2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Dec 17, 2018
2 parents d95502c + ed478c3 commit 1e7f716
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 14 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.2] (2018-12-17)

### Changed

* [#650](https://github.com/dadi/publish/pull/650): enforce stricter validation on configuration files

### Fixed

* [#644](https://github.com/dadi/publish/issues/644): make Add filter popup respect default operator
* [#651](https://github.com/dadi/publish/pull/651): fix issue with the RichEditor component that would crash the app when unmounting

## [2.0.1] (2018-12-06)

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions app/config-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
apis: {
requireAuthentication: false,
doc: 'Connected APIs',
format: Array,
format: 'apis-block',
default: [],
publishId: {
type: String,
Expand Down Expand Up @@ -94,7 +94,6 @@ module.exports = {
}
},
server: {
requireAuthentication: false,
host: {
doc: 'The IP address or interface to bind to',
format: 'ipaddress',
Expand Down Expand Up @@ -147,6 +146,7 @@ module.exports = {
env: 'SSL_INTERMEDIATE_CERTIFICATE_PATHS'
},
healthcheck: {
requireAuthentication: false,
enabled: {
doc: 'Healthcheck is enabled',
format: Boolean,
Expand Down
23 changes: 23 additions & 0 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ const initialiseConfig = () => {
return config
}

convict.addFormat({
name: 'apis-block',
validate: value => {
if (!Array.isArray(value)) {
throw new Error('must be an array')
}

if (value.length > 1) {
throw new Error('only one API is currently supported')
}

value.forEach(api => {
if (typeof api.host !== 'string' || typeof api.port !== 'number') {
throw new Error('must contain elements with `host` and `port` properties')
}

if (api.credentials !== undefined) {
throw new Error('contains a legacy `credentials` block, exposing critical information to the public')
}
})
}
})

let config = initialiseConfig()

module.exports = config
Expand Down
6 changes: 3 additions & 3 deletions frontend/components/DocumentFilters/DocumentFilters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default class DocumentFilters extends Component {
})
}

handleSelectedFilterUpdate(field, event) {
handleSelectedFilterUpdate(field, defaultOperator, event) {
const {
selectedFilterIndex: index,
selectedFilterOperator: operator,
Expand All @@ -226,7 +226,7 @@ export default class DocumentFilters extends Component {
if (index === -1) {
this.filtersArray.push({
field,
operator,
operator: operator || defaultOperator,
value
})
} else {
Expand Down Expand Up @@ -461,7 +461,7 @@ export default class DocumentFilters extends Component {
<form
class={tooltipStyle.getClasses()}
onClick={this.handleClick.bind(this, true)}
onSubmit={this.handleSelectedFilterUpdate.bind(this, field)}
onSubmit={this.handleSelectedFilterUpdate.bind(this, field, selectedOperator)}
>
<div class={styles['tooltip-section']}>
<h3
Expand Down
25 changes: 17 additions & 8 deletions frontend/components/RichEditor/RichEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,14 +283,19 @@ export default class RichEditor extends Component {
this.linkInputElement.focus()
}

if (value !== text) {
if (this.getNormalisedValue(value) !== text) {
this.handleChange(value, {
needsConversion: true,
shouldPropagate: false
})
}
}

componentWillUnmount() {
this.editorElement.removeEventListener('keypress', this.keyPressHandler)
document.removeEventListener('selectionchange', this.selectionHandler)
}

deserialiseSelection(serialisedSelection) {
let nodes = serialisedSelection.split(',')
let parsedNodes = []
Expand Down Expand Up @@ -378,6 +383,14 @@ export default class RichEditor extends Component {
return this.turndownService.turndown(html)
}

getNormalisedValue(value) {
if (typeof value !== 'string' || value.length === 0) {
return null
}

return value
}

getTextFromHTML(html) {
const {format} = this.props

Expand Down Expand Up @@ -409,19 +422,15 @@ export default class RichEditor extends Component {
text = this.getTextFromHTML(value)
}

// An empty string is not the best representation of an empty field.
// We look for that case and broadcast a `null` instead.
let sanitisedText = text.length > 0 ?
text :
null
let normalisedValue = this.getNormalisedValue(text)

this.setState({
html,
text: sanitisedText
text: normalisedValue
})

if (shouldPropagate && typeof onChange === 'function') {
onChange(sanitisedText)
onChange(normalisedValue)
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dadi/publish",
"version": "2.0.1",
"version": "2.0.2",
"description": "DADI Publish",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 1e7f716

Please sign in to comment.