mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
Merge pull request #126 from corinnekrych/feature.view.with.disable.toggle
fix(feature): toggle correctly display for list and update feature
This commit is contained in:
commit
57a19f1455
@ -22,7 +22,7 @@ exports[`renders correctly with one feature 1`] = `
|
|||||||
>
|
>
|
||||||
<react-mdl-Switch
|
<react-mdl-Switch
|
||||||
checked={false}
|
checked={false}
|
||||||
disabled={true}
|
disabled={false}
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
title="Toggle Another"
|
title="Toggle Another"
|
||||||
/>
|
/>
|
||||||
|
@ -42,7 +42,7 @@ const Feature = ({
|
|||||||
</span>
|
</span>
|
||||||
<span className={styles.listItemToggle}>
|
<span className={styles.listItemToggle}>
|
||||||
<Switch
|
<Switch
|
||||||
disabled={toggleFeature !== undefined}
|
disabled={toggleFeature === undefined}
|
||||||
title={`Toggle ${name}`}
|
title={`Toggle ${name}`}
|
||||||
key="left-actions"
|
key="left-actions"
|
||||||
onChange={() => toggleFeature(name)}
|
onChange={() => toggleFeature(name)}
|
||||||
|
@ -27,6 +27,7 @@ ShallowWrapper {
|
|||||||
"name": "feature",
|
"name": "feature",
|
||||||
"nameError": Object {},
|
"nameError": Object {},
|
||||||
},
|
},
|
||||||
|
undefined,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -14,15 +14,23 @@ class UpdateFeatureComponent extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { input, addStrategy, removeStrategy, updateStrategy, moveStrategy, onSubmit, onCancel } = this.props;
|
const {
|
||||||
|
input,
|
||||||
|
features,
|
||||||
|
addStrategy,
|
||||||
|
removeStrategy,
|
||||||
|
updateStrategy,
|
||||||
|
moveStrategy,
|
||||||
|
onSubmit,
|
||||||
|
onCancel,
|
||||||
|
} = this.props;
|
||||||
const {
|
const {
|
||||||
name, // eslint-disable-line
|
name, // eslint-disable-line
|
||||||
} = input;
|
} = input;
|
||||||
const configuredStrategies = input.strategies || [];
|
const configuredStrategies = input.strategies || [];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={onSubmit(input)}>
|
<form onSubmit={onSubmit(input, features)}>
|
||||||
<section style={{ padding: '16px' }}>
|
<section style={{ padding: '16px' }}>
|
||||||
<StrategiesSection
|
<StrategiesSection
|
||||||
configuredStrategies={configuredStrategies}
|
configuredStrategies={configuredStrategies}
|
||||||
@ -42,6 +50,7 @@ class UpdateFeatureComponent extends Component {
|
|||||||
|
|
||||||
UpdateFeatureComponent.propTypes = {
|
UpdateFeatureComponent.propTypes = {
|
||||||
input: PropTypes.object,
|
input: PropTypes.object,
|
||||||
|
features: PropTypes.array,
|
||||||
setValue: PropTypes.func.isRequired,
|
setValue: PropTypes.func.isRequired,
|
||||||
addStrategy: PropTypes.func.isRequired,
|
addStrategy: PropTypes.func.isRequired,
|
||||||
removeStrategy: PropTypes.func.isRequired,
|
removeStrategy: PropTypes.func.isRequired,
|
||||||
|
@ -26,7 +26,7 @@ const mapStateToProps = createMapper({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const prepare = (methods, dispatch) => {
|
const prepare = (methods, dispatch) => {
|
||||||
methods.onSubmit = input => e => {
|
methods.onSubmit = (input, features) => e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (Array.isArray(input.strategies)) {
|
if (Array.isArray(input.strategies)) {
|
||||||
@ -35,6 +35,9 @@ const prepare = (methods, dispatch) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
delete input.description;
|
delete input.description;
|
||||||
|
// take the status of the feature toggles from the central store in case `toggleFeature` function was called
|
||||||
|
const feat = features.find(f => f.name === input.name);
|
||||||
|
input.enabled = feat.enabled;
|
||||||
|
|
||||||
// TODO: should add error handling
|
// TODO: should add error handling
|
||||||
requestUpdateFeatureToggle(input)(dispatch)
|
requestUpdateFeatureToggle(input)(dispatch)
|
||||||
|
@ -46,13 +46,13 @@ export default class ViewFeatureToggleComponent extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTabContent(activeTab) {
|
getTabContent(activeTab) {
|
||||||
const { featureToggle, featureToggleName } = this.props;
|
const { features, featureToggle, featureToggleName } = this.props;
|
||||||
|
|
||||||
if (TABS[activeTab] === TABS.history) {
|
if (TABS[activeTab] === TABS.history) {
|
||||||
return <HistoryComponent toggleName={featureToggleName} />;
|
return <HistoryComponent toggleName={featureToggleName} />;
|
||||||
} else if (TABS[activeTab] === TABS.strategies) {
|
} else if (TABS[activeTab] === TABS.strategies) {
|
||||||
if (this.isFeatureView) {
|
if (this.isFeatureView) {
|
||||||
return <EditFeatureToggle featureToggle={featureToggle} />;
|
return <EditFeatureToggle featureToggle={featureToggle} features={features} />;
|
||||||
}
|
}
|
||||||
return <ViewFeatureToggle featureToggle={featureToggle} />;
|
return <ViewFeatureToggle featureToggle={featureToggle} />;
|
||||||
} else {
|
} else {
|
||||||
@ -165,7 +165,7 @@ export default class ViewFeatureToggleComponent extends React.Component {
|
|||||||
>
|
>
|
||||||
<span style={{ paddingRight: '24px' }}>
|
<span style={{ paddingRight: '24px' }}>
|
||||||
<Switch
|
<Switch
|
||||||
disabled={this.isFeatureView}
|
disabled={!this.isFeatureView}
|
||||||
ripple
|
ripple
|
||||||
checked={featureToggle.enabled}
|
checked={featureToggle.enabled}
|
||||||
onChange={() => toggleFeature(featureToggle.name)}
|
onChange={() => toggleFeature(featureToggle.name)}
|
||||||
|
Loading…
Reference in New Issue
Block a user