mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Strategy view: added used in toggles
This commit is contained in:
		
							parent
							
								
									420bd99d1e
								
							
						
					
					
						commit
						57bbdedc04
					
				| @ -57,3 +57,16 @@ export const SwitchWithLabel = ({ onChange, children, checked }) => ( | |||||||
|     </span> |     </span> | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
|  | export const TogglesLinkList = ({ toggles }) => ( | ||||||
|  |     <List style={{ textAlign: 'left' }}> | ||||||
|  |     {toggles.length > 0 && toggles.map(({ name, description = '-', icon = 'toggle' }) => ( | ||||||
|  |         <ListItem twoLine key={name}> | ||||||
|  |             <ListItemContent avatar={icon} subtitle={description}> | ||||||
|  |                 <Link key={name} to={`/features/edit//${name}`}> | ||||||
|  |                     {name} | ||||||
|  |                 </Link> | ||||||
|  |             </ListItemContent> | ||||||
|  |         </ListItem> | ||||||
|  |     ))} | ||||||
|  |     </List> | ||||||
|  | ); | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import React, { Component } from 'react'; | import React, { Component } from 'react'; | ||||||
| import { Grid, Cell } from 'react-mdl'; | import { Grid, Cell } from 'react-mdl'; | ||||||
| 
 | 
 | ||||||
| import { AppsLinkList, HeaderTitle } from '../common'; | import { AppsLinkList, TogglesLinkList, HeaderTitle } from '../common'; | ||||||
| 
 | 
 | ||||||
| class ShowStrategyComponent extends Component { | class ShowStrategyComponent extends Component { | ||||||
|     componentDidMount () { |     componentDidMount () { | ||||||
| @ -11,6 +11,9 @@ class ShowStrategyComponent extends Component { | |||||||
|         if (!this.props.applications || this.props.applications.length === 0) { |         if (!this.props.applications || this.props.applications.length === 0) { | ||||||
|             this.props.fetchApplications(); |             this.props.fetchApplications(); | ||||||
|         } |         } | ||||||
|  |         if (!this.props.toggles || this.props.toggles.length === 0) { | ||||||
|  |             this.props.fetchFeatureToggles(); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     renderParameters (parametersTemplate) { |     renderParameters (parametersTemplate) { | ||||||
| @ -28,6 +31,7 @@ class ShowStrategyComponent extends Component { | |||||||
|             strategy, |             strategy, | ||||||
|             strategyName, |             strategyName, | ||||||
|             applications, |             applications, | ||||||
|  |             toggles, | ||||||
|         } = this.props; |         } = this.props; | ||||||
| 
 | 
 | ||||||
|         if (!strategy) { |         if (!strategy) { | ||||||
| @ -40,12 +44,11 @@ class ShowStrategyComponent extends Component { | |||||||
|             parametersTemplate = {}, |             parametersTemplate = {}, | ||||||
|         } = strategy; |         } = strategy; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|         return ( |         return ( | ||||||
|             <div> |             <div> | ||||||
|                 <HeaderTitle title={name} subtitle={description} /> |                 <HeaderTitle title={name} subtitle={description} /> | ||||||
|                 <Grid> |                 <Grid> | ||||||
|                     <Cell col={6}> |                     <Cell col={4}> | ||||||
|                         <h6>Parameters</h6> |                         <h6>Parameters</h6> | ||||||
|                         <hr /> |                         <hr /> | ||||||
|                         <ol className="demo-list-item mdl-list"> |                         <ol className="demo-list-item mdl-list"> | ||||||
| @ -53,11 +56,17 @@ class ShowStrategyComponent extends Component { | |||||||
|                         </ol> |                         </ol> | ||||||
|                     </Cell> |                     </Cell> | ||||||
| 
 | 
 | ||||||
|                     <Cell col={6}> |                     <Cell col={4}> | ||||||
|                         <h6>Applications using this strategy</h6> |                         <h6>Applications using this strategy</h6> | ||||||
|                         <hr /> |                         <hr /> | ||||||
|                         <AppsLinkList apps={applications} /> |                         <AppsLinkList apps={applications} /> | ||||||
|                     </Cell> |                     </Cell> | ||||||
|  | 
 | ||||||
|  |                     <Cell col={4}> | ||||||
|  |                         <h6>Toggles using this strategy</h6> | ||||||
|  |                         <hr /> | ||||||
|  |                         <TogglesLinkList toggles={toggles} /> | ||||||
|  |                     </Cell> | ||||||
|                 </Grid> |                 </Grid> | ||||||
|             </div> |             </div> | ||||||
|         ); |         ); | ||||||
|  | |||||||
| @ -2,6 +2,7 @@ import { connect } from 'react-redux'; | |||||||
| import ShowStrategy from './show-strategy-component'; | import ShowStrategy from './show-strategy-component'; | ||||||
| import { fetchStrategies } from '../../store/strategy/actions'; | import { fetchStrategies } from '../../store/strategy/actions'; | ||||||
| import { fetchAll } from '../../store/application/actions'; | import { fetchAll } from '../../store/application/actions'; | ||||||
|  | import { fetchFeatureToggles } from '../../store/feature-actions'; | ||||||
| 
 | 
 | ||||||
| const mapStateToProps = (state, props) => { | const mapStateToProps = (state, props) => { | ||||||
|     let strategy = state.strategies |     let strategy = state.strategies | ||||||
| @ -10,16 +11,21 @@ const mapStateToProps = (state, props) => { | |||||||
|     const applications = state.applications |     const applications = state.applications | ||||||
|         .get('list') |         .get('list') | ||||||
|         .filter(app => app.strategies.includes(props.strategyName)); |         .filter(app => app.strategies.includes(props.strategyName)); | ||||||
|  |     const toggles = state.features | ||||||
|  |         .filter(toggle => | ||||||
|  |             toggle.get('strategies').findIndex(s => s.name === props.strategyName) > -1); | ||||||
| 
 | 
 | ||||||
|     return { |     return { | ||||||
|         strategy, |         strategy, | ||||||
|         applications: applications && applications.toJS(), |         applications: applications && applications.toJS(), | ||||||
|  |         toggles: toggles && toggles.toJS(), | ||||||
|     }; |     }; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const Constainer = connect(mapStateToProps, { | const Constainer = connect(mapStateToProps, { | ||||||
|     fetchStrategies, |     fetchStrategies, | ||||||
|     fetchApplications: fetchAll, |     fetchApplications: fetchAll, | ||||||
|  |     fetchFeatureToggles, | ||||||
| })(ShowStrategy); | })(ShowStrategy); | ||||||
| 
 | 
 | ||||||
| export default Constainer; | export default Constainer; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user