mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	fix(strategy-create): Should be able to open the create strategy view
This commit is contained in:
		
							parent
							
								
									52b080306f
								
							
						
					
					
						commit
						f6c9d461b0
					
				| @ -10,6 +10,9 @@ The latest version of this document is always available in | ||||
| 
 | ||||
| ## [Unreleased] | ||||
| 
 | ||||
| ## [3.1.1] | ||||
| - fix(strategy-create): Should be able to open the create strategy view. | ||||
| 
 | ||||
| ## [3.1.0] | ||||
| - fix(react-router): Upgrade to react-router v4. | ||||
| - fix(feature-create): Default strategy should be chosen if strategy list is empty.  | ||||
|  | ||||
| @ -20,10 +20,6 @@ export default class App extends Component { | ||||
|         match: PropTypes.object.isRequired, | ||||
|     }; | ||||
| 
 | ||||
|     static contextTypes = { | ||||
|         router: PropTypes.object, | ||||
|     }; | ||||
| 
 | ||||
|     componentWillReceiveProps(nextProps) { | ||||
|         if (this.props.location.pathname !== nextProps.location.pathname) { | ||||
|             clearTimeout(this.timer); | ||||
|  | ||||
| @ -21,10 +21,6 @@ export default class FeatureListComponent extends React.Component { | ||||
|         history: PropTypes.object.isRequired, | ||||
|     }; | ||||
| 
 | ||||
|     static contextTypes = { | ||||
|         router: PropTypes.object, | ||||
|     }; | ||||
| 
 | ||||
|     componentDidMount() { | ||||
|         if (this.props.logout) { | ||||
|             this.props.logoutUser(); | ||||
|  | ||||
| @ -1,8 +1,8 @@ | ||||
| import React, { Component } from 'react'; | ||||
| import PropTypes from 'prop-types'; | ||||
| 
 | ||||
| import { Textfield, IconButton, Menu, MenuItem, Checkbox, Grid, Cell } from 'react-mdl'; | ||||
| import { FormButtons } from '../common'; | ||||
| import { Textfield, IconButton, Menu, MenuItem, Checkbox, CardTitle, Card, CardActions } from 'react-mdl'; | ||||
| import { styles as commonStyles, FormButtons } from '../common'; | ||||
| 
 | ||||
| const trim = value => { | ||||
|     if (value && value.trim) { | ||||
| @ -129,10 +129,12 @@ class AddStrategy extends Component { | ||||
|         const { input, setValue, updateInList, incValue, onCancel, editmode = false, onSubmit } = this.props; | ||||
| 
 | ||||
|         return ( | ||||
|             <Grid className="mdl-color--white"> | ||||
|                 <Cell col={12}> | ||||
|                     <form onSubmit={onSubmit(input)}> | ||||
|                         {editmode ? <EditHeader /> : <CreateHeader />} | ||||
|             <Card shadow={0} className={commonStyles.fullwidth} style={{ overflow: 'visible', paddingBottom: '10px' }}> | ||||
|                 <CardTitle style={{ paddingTop: '24px', wordBreak: 'break-all' }}> | ||||
|                     {editmode ? <EditHeader /> : <CreateHeader />} | ||||
|                 </CardTitle> | ||||
|                 <form onSubmit={onSubmit(input)}> | ||||
|                     <section style={{ padding: '16px' }}> | ||||
|                         <Textfield | ||||
|                             label="Strategy name" | ||||
|                             floatingLabel | ||||
| @ -163,12 +165,12 @@ class AddStrategy extends Component { | ||||
|                             }} | ||||
|                         />{' '} | ||||
|                          Add parameter | ||||
|                         <br /> | ||||
|                         <hr /> | ||||
|                     </section> | ||||
|                     <CardActions> | ||||
|                         <FormButtons submitText={editmode ? 'Update' : 'Create'} onCancel={onCancel} /> | ||||
|                     </form> | ||||
|                 </Cell> | ||||
|             </Grid> | ||||
|                     </CardActions> | ||||
|                 </form> | ||||
|             </Card> | ||||
|         ); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -21,7 +21,7 @@ const mapStateToProps = createMapper({ | ||||
|     }, | ||||
| }); | ||||
| 
 | ||||
| const prepare = (methods, dispatch) => { | ||||
| const prepare = (methods, dispatch, ownProps) => { | ||||
|     methods.onSubmit = input => e => { | ||||
|         e.preventDefault(); | ||||
|         // clean
 | ||||
| @ -40,14 +40,13 @@ const prepare = (methods, dispatch) => { | ||||
|             parameters, | ||||
|         })(dispatch) | ||||
|             .then(() => methods.clear()) | ||||
|             .then(() => this.props.history.push(`/strategies/view/${input.name}`)); | ||||
|             .then(() => ownProps.history.push(`/strategies/view/${input.name}`)); | ||||
|     }; | ||||
| 
 | ||||
|     methods.onCancel = e => { | ||||
|         e.preventDefault(); | ||||
|         methods.clear(); | ||||
|         // somewhat quickfix / hacky to go back..
 | ||||
|         window.history.back(); | ||||
|         ownProps.history.push(`/strategies/view/${ownProps.strategy.name}`); | ||||
|     }; | ||||
| 
 | ||||
|     return methods; | ||||
|  | ||||
| @ -10,10 +10,7 @@ class StrategiesListComponent extends Component { | ||||
|         strategies: PropTypes.array.isRequired, | ||||
|         fetchStrategies: PropTypes.func.isRequired, | ||||
|         removeStrategy: PropTypes.func.isRequired, | ||||
|     }; | ||||
| 
 | ||||
|     static contextTypes = { | ||||
|         router: PropTypes.object, | ||||
|         history: PropTypes.object.isRequired, | ||||
|     }; | ||||
| 
 | ||||
|     componentDidMount() { | ||||
| @ -32,7 +29,7 @@ class StrategiesListComponent extends Component { | ||||
|                             <IconButton | ||||
|                                 raised | ||||
|                                 name="add" | ||||
|                                 onClick={() => this.context.router.push('/strategies/create')} | ||||
|                                 onClick={() => this.props.history.push('/strategies/create')} | ||||
|                                 title="Add new strategy" | ||||
|                             /> | ||||
|                         } | ||||
|  | ||||
| @ -37,7 +37,7 @@ export default class StrategyDetails extends Component { | ||||
| 
 | ||||
|     getTabContent(activeTabId) { | ||||
|         if (activeTabId === TABS.edit) { | ||||
|             return <EditStrategy strategy={this.props.strategy} />; | ||||
|             return <EditStrategy strategy={this.props.strategy} history={this.props.history} />; | ||||
|         } else { | ||||
|             return ( | ||||
|                 <ShowStrategy | ||||
|  | ||||
| @ -1,4 +1,11 @@ | ||||
| import React from 'react'; | ||||
| import AddStrategies from '../../component/strategies/add-container'; | ||||
| import PropTypes from 'prop-types'; | ||||
| 
 | ||||
| export default () => <AddStrategies />; | ||||
| const render = ({ history }) => <AddStrategies history={history} />; | ||||
| 
 | ||||
| render.propTypes = { | ||||
|     history: PropTypes.object.isRequired, | ||||
| }; | ||||
| 
 | ||||
| export default render; | ||||
|  | ||||
| @ -1,4 +1,11 @@ | ||||
| import React from 'react'; | ||||
| import Strategies from '../../component/strategies/list-container'; | ||||
| import PropTypes from 'prop-types'; | ||||
| 
 | ||||
| export default () => <Strategies />; | ||||
| const render = ({ history }) => <Strategies history={history} />; | ||||
| 
 | ||||
| render.propTypes = { | ||||
|     history: PropTypes.object.isRequired, | ||||
| }; | ||||
| 
 | ||||
| export default render; | ||||
|  | ||||
| @ -2,12 +2,13 @@ import React from 'react'; | ||||
| import PropTypes from 'prop-types'; | ||||
| import ShowStrategy from '../../component/strategies/strategy-details-container'; | ||||
| 
 | ||||
| const render = ({ match: { params } }) => ( | ||||
|     <ShowStrategy strategyName={params.strategyName} activeTab={params.activeTab} /> | ||||
| const render = ({ match: { params }, history }) => ( | ||||
|     <ShowStrategy strategyName={params.strategyName} activeTab={params.activeTab} history={history} /> | ||||
| ); | ||||
| 
 | ||||
| render.propTypes = { | ||||
|     match: PropTypes.object.isRequired, | ||||
|     history: PropTypes.object.isRequired, | ||||
| }; | ||||
| 
 | ||||
| export default render; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user