Skip to content
This repository has been archived by the owner on Dec 1, 2020. It is now read-only.

Commit

Permalink
fix: checks if flags are custom on render to check 'Edit' checkbox (#111
Browse files Browse the repository at this point in the history
)

* fix: checks if flags are custom on render to check 'Edit' checkbox. also, resets flags to generated on uncheck of checkbox

* chore: update label to 'Use custom flags'
  • Loading branch information
ryanio committed Jul 22, 2019
1 parent 9ccaab3 commit 82f76ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class FlagPreview extends Component {
style={{ marginLeft: 10 }}
/>
}
label="Edit"
label="Use custom flags"
/>
</FormGroup>
)
Expand Down
17 changes: 15 additions & 2 deletions src/components/Nodes/ClientConfig/DynamicConfigForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,39 @@ import PropTypes from 'prop-types'
import Grid from '@material-ui/core/Grid'
import FormItem from './FormItem'
import FlagPreview from './FlagPreview'
import { setFlags, getGeneratedFlags } from '../../../../store/client/actions'

class DynamicConfigForm extends Component {
static propTypes = {
settings: PropTypes.array,
clientName: PropTypes.string,
client: PropTypes.object,
isClientRunning: PropTypes.bool,
handleClientConfigChanged: PropTypes.func
handleClientConfigChanged: PropTypes.func,
dispatch: PropTypes.func
}

constructor(props) {
super(props)

const { client } = props
const clientPlugin = window.Grid.PluginHost.getPluginByName(client.selected)
const { config, flags } = client[client.selected]
const generatedFlags = getGeneratedFlags(clientPlugin, config)
const flagsIsCustom = !flags.every(f => generatedFlags.includes(f))
this.state = {
editGeneratedFlags: false
editGeneratedFlags: flagsIsCustom
}
}

toggleEditGeneratedFlags = checked => {
const { client, dispatch } = this.props
const { config } = client[client.selected]
const clientPlugin = window.Grid.PluginHost.getPluginByName(client.selected)
this.setState({ editGeneratedFlags: checked })
if (!checked) {
dispatch(setFlags(clientPlugin, config))
}
}

wrapGridItem = (el, index) => {
Expand Down

0 comments on commit 82f76ca

Please sign in to comment.