diff --git a/web/src/js/components/Modal/OptionModal.jsx b/web/src/js/components/Modal/OptionModal.jsx index 5741ee8cd..2a95f43b1 100644 --- a/web/src/js/components/Modal/OptionModal.jsx +++ b/web/src/js/components/Modal/OptionModal.jsx @@ -2,6 +2,7 @@ import React, { Component } from "react" import { connect } from "react-redux" import * as modalAction from "../../ducks/ui/modal" import Option from "./Option" +import _ from "lodash" function PureOptionHelp({help}){ return
{help}
; @@ -18,6 +19,31 @@ const OptionError = connect((state, {name}) => ({ error: state.ui.optionsEditor[name] && state.ui.optionsEditor[name].error }))(PureOptionError); +function PureOptionDefault({value, defaultVal}){ + if( value === defaultVal ) { + return null + } else { + if (typeof(defaultVal) === 'boolean') { + defaultVal = defaultVal ? 'true' : 'false' + } else if (Array.isArray(defaultVal)){ + if (_.isEmpty(_.compact(value)) && // filter the empty string in array + _.isEmpty(defaultVal)){ + return null + } + defaultVal = '[ ]' + } else if (defaultVal === ''){ + defaultVal = '\"\"' + } else if (defaultVal === null){ + defaultVal = 'null' + } + return
Default: {defaultVal}
+ } +} +const OptionDefault = connect((state, {name}) => ({ + value: state.options[name].value, + defaultVal: state.options[name].default +}))(PureOptionDefault) + class PureOptionModal extends Component { constructor(props, context) { @@ -53,6 +79,7 @@ class PureOptionModal extends Component {
)