From 4dd033c30e7bc9293a8d1ee344cb32cd36c18de2 Mon Sep 17 00:00:00 2001 From: Corinne Krych Date: Sun, 11 Feb 2018 17:56:00 +0100 Subject: [PATCH] fix(feature): display strategies tab as default --- .../feature/feature-list-item-component.jsx | 2 +- .../component/feature/form-edit-container.jsx | 2 +- frontend/src/component/feature/form/index.jsx | 28 +------------------ .../src/component/feature/view-component.jsx | 10 +++---- .../strategies/strategy-details-component.jsx | 2 +- 5 files changed, 9 insertions(+), 35 deletions(-) diff --git a/frontend/src/component/feature/feature-list-item-component.jsx b/frontend/src/component/feature/feature-list-item-component.jsx index 23991b5479..6d4a831f8a 100644 --- a/frontend/src/component/feature/feature-list-item-component.jsx +++ b/frontend/src/component/feature/feature-list-item-component.jsx @@ -52,7 +52,7 @@ const Feature = ({ {name} diff --git a/frontend/src/component/feature/form-edit-container.jsx b/frontend/src/component/feature/form-edit-container.jsx index ee3d9e7e6c..21681a77b8 100644 --- a/frontend/src/component/feature/form-edit-container.jsx +++ b/frontend/src/component/feature/form-edit-container.jsx @@ -37,7 +37,7 @@ const prepare = (methods, dispatch) => { // TODO: should add error handling requestUpdateFeatureToggle(input)(dispatch) .then(() => methods.clear()) - .then(() => hashHistory.push(`/features/view/${input.name}`)); + .then(() => hashHistory.push(`/features/strategies/${input.name}`)); }; methods.onCancel = evt => { diff --git a/frontend/src/component/feature/form/index.jsx b/frontend/src/component/feature/form/index.jsx index 366227d139..07217e4550 100644 --- a/frontend/src/component/feature/form/index.jsx +++ b/frontend/src/component/feature/form/index.jsx @@ -5,14 +5,6 @@ import StrategiesSection from './strategies-section-container'; import { FormButtons } from '../../common'; -const trim = value => { - if (value && value.trim) { - return value.trim(); - } else { - return value; - } -}; - class AddFeatureToggleComponent extends Component { componentWillMount() { // TODO unwind this stuff @@ -25,7 +17,6 @@ class AddFeatureToggleComponent extends Component { const { input, setValue, - validateName, addStrategy, removeStrategy, updateStrategy, @@ -35,29 +26,12 @@ class AddFeatureToggleComponent extends Component { editmode = false, } = this.props; - const { - name, // eslint-disable-line - nameError, - description, - enabled, - } = input; + const { description, enabled } = input; const configuredStrategies = input.strategies || []; return (
- validateName(v.target.value)} - onChange={v => setValue('name', trim(v.target.value))} - /> -
; - } else if (TABS[activeTab] === TABS.edit) { + } else if (TABS[activeTab] === TABS.strategies) { return ; } else { return ; @@ -80,7 +80,7 @@ export default class ViewFeatureToggleComponent extends React.Component { ); } - const activeTabId = TABS[this.props.activeTab] ? TABS[this.props.activeTab] : TABS.view; + const activeTabId = TABS[this.props.activeTab] ? TABS[this.props.activeTab] : TABS.strategies; const tabContent = this.getTabContent(activeTab); const removeToggle = () => { @@ -125,8 +125,8 @@ export default class ViewFeatureToggleComponent extends React.Component { tabBarProps={{ style: { width: '100%' } }} className="mdl-color--grey-100" > + this.goToTab('strategies', featureToggleName)}>Strategies this.goToTab('view', featureToggleName)}>Metrics - this.goToTab('edit', featureToggleName)}>Edit this.goToTab('history', featureToggleName)}>History {tabContent} diff --git a/frontend/src/component/strategies/strategy-details-component.jsx b/frontend/src/component/strategies/strategy-details-component.jsx index 967830be70..c9762b8e05 100644 --- a/frontend/src/component/strategies/strategy-details-component.jsx +++ b/frontend/src/component/strategies/strategy-details-component.jsx @@ -54,7 +54,7 @@ export default class StrategyDetails extends Component { } render() { - const activeTabId = TABS[this.props.activeTab] ? TABS[this.props.activeTab] : TABS.view; + const activeTabId = TABS[this.props.activeTab] ? TABS[this.props.activeTab] : TABS.strategies; const strategy = this.props.strategy; if (!strategy) { return ;