1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

fixt(feature): move description outside of strategies block

This commit is contained in:
Corinne Krych 2018-02-15 17:09:00 +01:00
parent 4dfddd6615
commit 35bfc3f869
5 changed files with 54 additions and 14 deletions

View File

@ -31,7 +31,7 @@ const prepare = (methods, dispatch) => {
createFeatureToggles(input)(dispatch) createFeatureToggles(input)(dispatch)
.then(() => methods.clear()) .then(() => methods.clear())
.then(() => hashHistory.push(`/features/edit/${input.name}`)); .then(() => hashHistory.push(`/features/strategies/${input.name}`));
}; };
methods.onCancel = evt => { methods.onCancel = evt => {

View File

@ -34,6 +34,10 @@ const prepare = (methods, dispatch) => {
delete s.id; delete s.id;
}); });
} }
if (input.editmode) {
delete input.description;
}
// TODO: should add error handling // TODO: should add error handling
requestUpdateFeatureToggle(input)(dispatch) requestUpdateFeatureToggle(input)(dispatch)
.then(() => methods.clear()) .then(() => methods.clear())

View File

@ -42,7 +42,7 @@ class AddFeatureToggleComponent extends Component {
enabled, enabled,
} = input; } = input;
const configuredStrategies = input.strategies || []; const configuredStrategies = input.strategies || [];
input.editmode = editmode;
return ( return (
<form onSubmit={onSubmit(input)}> <form onSubmit={onSubmit(input)}>
<section style={{ padding: '16px' }}> <section style={{ padding: '16px' }}>
@ -59,16 +59,17 @@ class AddFeatureToggleComponent extends Component {
onChange={v => setValue('name', trim(v.target.value))} onChange={v => setValue('name', trim(v.target.value))}
/> />
)} )}
<Textfield {!editmode && (
floatingLabel <Textfield
style={{ width: '100%' }} floatingLabel
rows={1} style={{ width: '100%' }}
label="Description" rows={1}
required label="Description"
value={description} required
onChange={v => setValue('description', v.target.value)} value={description}
/> onChange={v => setValue('description', v.target.value)}
/>
)}
{!editmode && ( {!editmode && (
<div> <div>
<br /> <br />

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Tabs, Tab, ProgressBar, Button, Card, CardTitle, CardActions, Switch } from 'react-mdl'; import { Tabs, Tab, ProgressBar, Button, Card, CardText, CardTitle, CardActions, Textfield, Switch } from 'react-mdl';
import { hashHistory, Link } from 'react-router'; import { hashHistory, Link } from 'react-router';
import HistoryComponent from '../history/history-list-toggle-container'; import HistoryComponent from '../history/history-list-toggle-container';
@ -26,6 +26,7 @@ export default class ViewFeatureToggleComponent extends React.Component {
toggleFeature: PropTypes.func.isRequired, toggleFeature: PropTypes.func.isRequired,
removeFeatureToggle: PropTypes.func.isRequired, removeFeatureToggle: PropTypes.func.isRequired,
fetchFeatureToggles: PropTypes.func.isRequired, fetchFeatureToggles: PropTypes.func.isRequired,
editFeatureToggle: PropTypes.func.isRequired,
featureToggle: PropTypes.object, featureToggle: PropTypes.object,
}; };
@ -56,6 +57,7 @@ export default class ViewFeatureToggleComponent extends React.Component {
featureToggle, featureToggle,
features, features,
activeTab, activeTab,
// setValue,
featureToggleName, featureToggleName,
toggleFeature, toggleFeature,
removeFeatureToggle, removeFeatureToggle,
@ -92,10 +94,37 @@ export default class ViewFeatureToggleComponent extends React.Component {
hashHistory.push('/features'); hashHistory.push('/features');
} }
}; };
const updateFeatureToggle = () => {
let feature = { ...featureToggle };
if (Array.isArray(feature.strategies)) {
feature.strategies.forEach(s => {
delete s.id;
});
}
this.props.editFeatureToggle(feature);
};
const setValue = (v, event) => {
featureToggle[v] = event.target.value;
this.forceUpdate();
};
return ( return (
<Card shadow={0} className={commonStyles.fullwidth} style={{ overflow: 'visible' }}> <Card shadow={0} className={commonStyles.fullwidth} style={{ overflow: 'visible' }}>
<CardTitle style={{ paddingTop: '24px', wordBreak: 'break-all' }}>{featureToggle.name}</CardTitle> <CardTitle style={{ paddingTop: '24px', wordBreak: 'break-all' }}>{featureToggle.name}</CardTitle>
<CardText>
<Textfield
floatingLabel
style={{ width: '100%' }}
rows={1}
label="Description"
required
value={featureToggle.description}
onChange={v => setValue('description', v)}
onBlur={updateFeatureToggle}
/>
</CardText>
<CardActions <CardActions
border border
style={{ style={{

View File

@ -1,6 +1,11 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { fetchFeatureToggles, toggleFeature, removeFeatureToggle } from '../../store/feature-actions'; import {
fetchFeatureToggles,
toggleFeature,
removeFeatureToggle,
editFeatureToggle,
} from '../../store/feature-actions';
import ViewToggleComponent from './view-component'; import ViewToggleComponent from './view-component';
@ -14,5 +19,6 @@ export default connect(
fetchFeatureToggles, fetchFeatureToggles,
toggleFeature, toggleFeature,
removeFeatureToggle, removeFeatureToggle,
editFeatureToggle,
} }
)(ViewToggleComponent); )(ViewToggleComponent);