diff --git a/frontend/src/component/feature/form-edit-container.jsx b/frontend/src/component/feature/form-edit-container.jsx
index b9264f7b82..0c0b71e7cf 100644
--- a/frontend/src/component/feature/form-edit-container.jsx
+++ b/frontend/src/component/feature/form-edit-container.jsx
@@ -7,22 +7,13 @@ import FormComponent from './form';
const ID = 'edit-feature-toggle';
function getId (props) {
- return [ID, props.featureToggleName];
+ return [ID, props.featureToggle.name];
}
// TODO: need to scope to the active featureToggle
// best is to emulate the "input-storage"?
const mapStateToProps = createMapper({
id: getId,
- getDefault: (state, ownProps) => {
- if (ownProps.featureToggleName) {
- const match = state.features.findEntry((entry) => entry.get('name') === ownProps.featureToggleName);
-
- if (match && match[1]) {
- return match[1].toJS();
- }
- }
- return {};
- },
+ getDefault: (state, ownProps) => ownProps.featureToggle,
prepare: (props) => {
props.editmode = true;
return props;
diff --git a/frontend/src/component/feature/form-edit-wrap.jsx b/frontend/src/component/feature/form-edit-wrap.jsx
new file mode 100644
index 0000000000..793b0c45ff
--- /dev/null
+++ b/frontend/src/component/feature/form-edit-wrap.jsx
@@ -0,0 +1,41 @@
+import React, { PropTypes } from 'react';
+
+import { connect } from 'react-redux';
+import EditFeatureToggle from './form-edit-container.jsx';
+import { fetchFeatureToggles } from '../../store/feature-actions';
+
+class EditFeatureToggleWrapper extends React.Component {
+
+ static propTypes () {
+ return {
+ featureToggleName: PropTypes.string.isRequired,
+ features: PropTypes.array.isRequired,
+ fetchFeatureToggles: PropTypes.array.isRequired,
+ };
+ }
+
+ componentWillMount () {
+ if (this.props.features.length === 0) {
+ this.props.fetchFeatureToggles();
+ }
+ }
+
+ render () {
+ const { features, featureToggleName } = this.props;
+
+ const featureToggle = features.find(toggle => toggle.name === featureToggleName);
+
+ if (featureToggle) {
+ return ;
+ } else if (features.length === 0 ) {
+ return Loading;
+ } else {
+ return Could not find {this.props.featureToggleName};
+ }
+ }
+}
+
+
+export default connect((state) => ({
+ features: state.features.toJS(),
+}), { fetchFeatureToggles })(EditFeatureToggleWrapper);
diff --git a/frontend/src/page/features/edit.js b/frontend/src/page/features/edit.js
index fed77e7f18..b1626986cd 100644
--- a/frontend/src/page/features/edit.js
+++ b/frontend/src/page/features/edit.js
@@ -1,5 +1,5 @@
import React, { Component, PropTypes } from 'react';
-import EditFeatureToggleForm from '../../component/feature/form-edit-container';
+import EditFeatureToggleForm from '../../component/feature/form-edit-wrap';
export default class Features extends Component {
static propTypes () {