diff --git a/frontend/src/component/archive/archive-list-component.jsx b/frontend/src/component/archive/archive-list-component.jsx index 43069ec216..74cb4a171e 100644 --- a/frontend/src/component/archive/archive-list-component.jsx +++ b/frontend/src/component/archive/archive-list-component.jsx @@ -11,10 +11,10 @@ class ArchiveList extends React.PureComponent { name: PropTypes.string, archive: PropTypes.array.isRequired, fetchArchive: PropTypes.func, - featureMetrics: PropTypes.object.isRequired, - updateSetting: PropTypes.func.isRequired, + featureMetrics: PropTypes.object, + updateSetting: PropTypes.func, settings: PropTypes.object, - revive: PropTypes.func.optional, + revive: PropTypes.func, }; componentDidMount() { diff --git a/frontend/src/component/archive/view-container.js b/frontend/src/component/archive/view-container.js new file mode 100644 index 0000000000..f7517c9629 --- /dev/null +++ b/frontend/src/component/archive/view-container.js @@ -0,0 +1,18 @@ +import { connect } from 'react-redux'; +import { fetchArchive } from './../../store/archive-actions'; + +import ViewToggleComponent from './../feature/view-component'; + +export default connect( + (state, props) => ({ + features: state.archive.get('list').toArray(), + featureToggle: state.archive + .get('list') + .toArray() + .find(toggle => toggle.name === props.featureToggleName), + activeTab: props.activeTab, + }), + { + fetchArchive, + } +)(ViewToggleComponent); diff --git a/frontend/src/component/feature/feature-list-item-component.jsx b/frontend/src/component/feature/feature-list-item-component.jsx index 41dbc2b4a0..20f2ff0eb4 100644 --- a/frontend/src/component/feature/feature-list-item-component.jsx +++ b/frontend/src/component/feature/feature-list-item-component.jsx @@ -43,7 +43,7 @@ const Feature = ({ - {toggleFeature ? ( // display feature list + {toggleFeature ? ( // display feature list, toggleFeature is available ) : ( - // display archive + // display archive, toggleFeature is undefined )} - - {name} - {description} - + {toggleFeature ? ( // display feature list, toggleFeature is available + + {name} + + {description} + + + ) : ( + + {name} + + {description} + + + )} {strategyChips} diff --git a/frontend/src/component/feature/view-component.jsx b/frontend/src/component/feature/view-component.jsx index 4f2546fe33..06f4b250e6 100644 --- a/frontend/src/component/feature/view-component.jsx +++ b/frontend/src/component/feature/view-component.jsx @@ -15,24 +15,31 @@ const TABS = { }; export default class ViewFeatureToggleComponent extends React.Component { + isFeatureView; constructor(props) { super(props); + this.isFeatureView = !!props.fetchFeatureToggles; } static propTypes = { activeTab: PropTypes.string.isRequired, featureToggleName: PropTypes.string.isRequired, features: PropTypes.array.isRequired, - toggleFeature: PropTypes.func.isRequired, - removeFeatureToggle: PropTypes.func.isRequired, - fetchFeatureToggles: PropTypes.func.isRequired, - editFeatureToggle: PropTypes.func.isRequired, + toggleFeature: PropTypes.func, + removeFeatureToggle: PropTypes.func, + fetchArchive: PropTypes.func, + fetchFeatureToggles: PropTypes.func, + editFeatureToggle: PropTypes.func, featureToggle: PropTypes.object, }; componentWillMount() { if (this.props.features.length === 0) { - this.props.fetchFeatureToggles(); + if (this.isFeatureView) { + this.props.fetchFeatureToggles(); + } else { + this.props.fetchArchive(); + } } } @@ -42,14 +49,16 @@ export default class ViewFeatureToggleComponent extends React.Component { if (TABS[activeTab] === TABS.history) { return ; } else if (TABS[activeTab] === TABS.strategies) { - return ; + return + } else { return ; } } goToTab(tabName, featureToggleName) { - hashHistory.push(`/features/${tabName}/${featureToggleName}`); + let view = this.props.fetchFeatureToggles ? 'features' : 'archive'; + hashHistory.push(`/${view}/${tabName}/${featureToggleName}`); } render() { @@ -113,16 +122,28 @@ export default class ViewFeatureToggleComponent extends React.Component { {featureToggle.name} - setValue('description', v)} - onBlur={updateFeatureToggle} - /> + {this.isFeatureView ? ( + setValue('description', v)} + onBlur={updateFeatureToggle} + /> + ) : ( + + )} - toggleFeature(featureToggle.name)} - > - {featureToggle.enabled ? 'Enabled' : 'Disabled'} - + {this.isFeatureView ? ( + toggleFeature(featureToggle.name)} + > + {featureToggle.enabled ? 'Enabled' : 'Disabled'} + + ) : ( + toggleFeature(featureToggle.name)} + > + {featureToggle.enabled ? 'Enabled' : 'Disabled'} + + )} - + + {this.isFeatureView ? ( + + ) : ( + + )}
- + diff --git a/frontend/src/page/archive/show.js b/frontend/src/page/archive/show.js new file mode 100644 index 0000000000..674e303ac0 --- /dev/null +++ b/frontend/src/page/archive/show.js @@ -0,0 +1,14 @@ +import React, { PureComponent } from 'react'; +import PropTypes from 'prop-types'; +import ViewFeatureToggle from './../../component/archive/view-container'; + +export default class Features extends PureComponent { + static propTypes = { + params: PropTypes.object.isRequired, + }; + + render() { + const { params } = this.props; + return ; + } +}