mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	feat: boolean strategy paramters (#178)
feat: boolean strategy paramters
This commit is contained in:
		
						commit
						9ebaa90b21
					
				| @ -1,6 +1,18 @@ | ||||
| import React from 'react'; | ||||
| import PropTypes from 'prop-types'; | ||||
| import { Textfield, Button, Card, CardTitle, CardText, CardActions, CardMenu, IconButton, Icon } from 'react-mdl'; | ||||
| import { | ||||
|     Textfield, | ||||
|     Button, | ||||
|     Card, | ||||
|     CardTitle, | ||||
|     CardText, | ||||
|     CardActions, | ||||
|     CardMenu, | ||||
|     IconButton, | ||||
|     Icon, | ||||
|     Switch, | ||||
|     Tooltip, | ||||
| } from 'react-mdl'; | ||||
| import { DragSource, DropTarget } from 'react-dnd'; | ||||
| import { Link } from 'react-router-dom'; | ||||
| import StrategyInputPercentage from './strategy-input-percentage'; | ||||
| @ -60,6 +72,11 @@ class StrategyConfigure extends React.Component { | ||||
|         this.setConfig(key, e.target.value); | ||||
|     }; | ||||
| 
 | ||||
|     handleSwitchChange = (key, currentValue) => { | ||||
|         const value = currentValue === 'false' ? 'true' : 'false'; | ||||
|         this.setConfig(key, value); | ||||
|     }; | ||||
| 
 | ||||
|     setConfig = (key, value) => { | ||||
|         const parameters = this.props.strategy.parameters || {}; | ||||
|         parameters[key] = value; | ||||
| @ -130,6 +147,25 @@ class StrategyConfigure extends React.Component { | ||||
|                             {description && <p className={styles.helpText}>{description}</p>} | ||||
|                         </div> | ||||
|                     ); | ||||
|                 } else if (type === 'boolean') { | ||||
|                     if (!value) { | ||||
|                         this.handleSwitchChange(name, value); | ||||
|                     } | ||||
|                     return ( | ||||
|                         <div key={name}> | ||||
|                             <Switch | ||||
|                                 onChange={this.handleSwitchChange.bind(this, name, value)} | ||||
|                                 checked={value === 'true'} | ||||
|                             > | ||||
|                                 {name}{' '} | ||||
|                                 {description && ( | ||||
|                                     <Tooltip label={description}> | ||||
|                                         <Icon name="info" style={{ color: 'rgba(0, 0, 0, 0.7)', fontSize: '1em' }} /> | ||||
|                                     </Tooltip> | ||||
|                                 )} | ||||
|                             </Switch> | ||||
|                         </div> | ||||
|                     ); | ||||
|                 } else { | ||||
|                     return ( | ||||
|                         <div key={name}> | ||||
|  | ||||
| @ -47,6 +47,7 @@ const Parameter = ({ set, input = {}, index }) => ( | ||||
|                 <MenuItem onClick={() => set({ type: 'percentage' })}>percentage</MenuItem> | ||||
|                 <MenuItem onClick={() => set({ type: 'list' })}>list</MenuItem> | ||||
|                 <MenuItem onClick={() => set({ type: 'number' })}>number</MenuItem> | ||||
|                 <MenuItem onClick={() => set({ type: 'boolean' })}>boolean</MenuItem> | ||||
|             </Menu> | ||||
|         </div> | ||||
|         <Textfield | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user