@@ -72,13 +79,10 @@ export default class ViewFeatureToggleComponent extends React.Component {
{featureToggle.description}
-
this.setState({ activeTab: tabId })}
- ripple
- style={{ marginBottom: '10px' }}>
- Metrics
- Edit
- History
+
+ this.goToTab('view', featureToggleName)}>Metrics
+ this.goToTab('edit', featureToggleName)}>Edit
+ this.goToTab('history', featureToggleName)}>History
{tabContent}
diff --git a/frontend/src/component/feature/view-container.jsx b/frontend/src/component/feature/view-container.jsx
new file mode 100644
index 0000000000..47bedf154a
--- /dev/null
+++ b/frontend/src/component/feature/view-container.jsx
@@ -0,0 +1,14 @@
+
+import { connect } from 'react-redux';
+
+import { fetchFeatureToggles } from '../../store/feature-actions';
+
+import ViewToggleComponent from './view-component';
+
+export default connect((state, props) => ({
+ features: state.features.toJS(),
+ featureToggle: state.features.toJS().find(toggle => toggle.name === props.featureToggleName),
+ activeTab: props.activeTab,
+}), {
+ fetchFeatureToggles,
+})(ViewToggleComponent);
diff --git a/frontend/src/component/feature/view-edit-container.jsx b/frontend/src/component/feature/view-edit-container.jsx
deleted file mode 100644
index 5fbb9b6b65..0000000000
--- a/frontend/src/component/feature/view-edit-container.jsx
+++ /dev/null
@@ -1,57 +0,0 @@
-
-import { connect } from 'react-redux';
-
-import { fetchFeatureToggles, toggleFeature } from '../../store/feature-actions';
-import { fetchFeatureMetrics, fetchSeenApps } from '../../store/feature-metrics-actions';
-import { fetchHistoryForToggle } from '../../store/history-actions';
-
-import ViewToggleComponent from './view-component';
-
-function getMetricsForToggle (state, toggleName) {
- if (!toggleName) {
- return;
- }
- const result = {};
-
- if (state.featureMetrics.hasIn(['seenApps', toggleName])) {
- result.seenApps = state.featureMetrics.getIn(['seenApps', toggleName]);
- }
- if (state.featureMetrics.hasIn(['lastHour', toggleName])) {
- result.lastHour = state.featureMetrics.getIn(['lastHour', toggleName]);
- result.lastMinute = state.featureMetrics.getIn(['lastMinute', toggleName]);
- }
- return result;
-}
-
-function getHistoryFromToggle (state, toggleName) {
- if (!toggleName) {
- return [];
- }
-
- if (state.history.hasIn(['toggles', toggleName])) {
- return state.history
- .getIn(['toggles', toggleName])
- .slice(0, 10)
- .toJS()
- .map(({ createdAt, createdBy, type }) => ({
- createdAt: new Date(createdAt).toLocaleString('nb-NO'),
- createdBy,
- type,
- }));
- }
-
- return [];
-}
-
-
-export default connect((state, props) => ({
- features: state.features.toJS(),
- metrics: getMetricsForToggle(state, props.featureToggleName),
- history: getHistoryFromToggle(state, props.featureToggleName),
-}), {
- fetchFeatureMetrics,
- fetchFeatureToggles,
- toggleFeature,
- fetchSeenApps,
- fetchHistoryForToggle,
-})(ViewToggleComponent);
diff --git a/frontend/src/index.jsx b/frontend/src/index.jsx
index 35ea590100..4d14854bc9 100644
--- a/frontend/src/index.jsx
+++ b/frontend/src/index.jsx
@@ -11,7 +11,7 @@ import App from './component/app';
import Features from './page/features';
import CreateFeatureToggle from './page/features/create';
-import EditFeatureToggle from './page/features/edit';
+import ViewFeatureToggle from './page/features/show';
import Strategies from './page/strategies';
import StrategyView from './page/strategies/show';
import CreateStrategies from './page/strategies/create';
@@ -39,7 +39,7 @@ ReactDOM.render(
-
+
diff --git a/frontend/src/page/features/edit.js b/frontend/src/page/features/edit.js
deleted file mode 100644
index 5f0cd3a4b3..0000000000
--- a/frontend/src/page/features/edit.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import React, { Component, PropTypes } from 'react';
-import EditFeatureToggleForm from '../../component/feature/view-edit-container';
-
-export default class Features extends Component {
- static propTypes () {
- return {
- params: PropTypes.object.isRequired,
- };
- }
-
- render () {
- return (
-
- );
- }
-};
diff --git a/frontend/src/page/features/show.js b/frontend/src/page/features/show.js
new file mode 100644
index 0000000000..7cff11b9f1
--- /dev/null
+++ b/frontend/src/page/features/show.js
@@ -0,0 +1,17 @@
+import React, { PureComponent, PropTypes } from 'react';
+import ViewFeatureToggle from '../../component/feature/view-container';
+
+export default class Features extends PureComponent {
+ static propTypes () {
+ return {
+ params: PropTypes.object.isRequired,
+ };
+ }
+
+ render () {
+ const { params } = this.props;
+ return (
+
+ );
+ }
+};