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

fix(feature): display strategies tab as default

This commit is contained in:
Corinne Krych 2018-02-11 17:56:00 +01:00
parent 5e545765de
commit 4dd033c30e
5 changed files with 9 additions and 35 deletions

View File

@ -52,7 +52,7 @@ const Feature = ({
</span> </span>
<span className={['mdl-list__item-primary-content', styles.listItemLink].join(' ')}> <span className={['mdl-list__item-primary-content', styles.listItemLink].join(' ')}>
<Link <Link
to={`/features/view/${name}`} to={`/features/strategies/${name}`}
className={[commonStyles.listLink, commonStyles.truncate].join(' ')} className={[commonStyles.listLink, commonStyles.truncate].join(' ')}
> >
{name} {name}

View File

@ -37,7 +37,7 @@ const prepare = (methods, dispatch) => {
// TODO: should add error handling // TODO: should add error handling
requestUpdateFeatureToggle(input)(dispatch) requestUpdateFeatureToggle(input)(dispatch)
.then(() => methods.clear()) .then(() => methods.clear())
.then(() => hashHistory.push(`/features/view/${input.name}`)); .then(() => hashHistory.push(`/features/strategies/${input.name}`));
}; };
methods.onCancel = evt => { methods.onCancel = evt => {

View File

@ -5,14 +5,6 @@ import StrategiesSection from './strategies-section-container';
import { FormButtons } from '../../common'; import { FormButtons } from '../../common';
const trim = value => {
if (value && value.trim) {
return value.trim();
} else {
return value;
}
};
class AddFeatureToggleComponent extends Component { class AddFeatureToggleComponent extends Component {
componentWillMount() { componentWillMount() {
// TODO unwind this stuff // TODO unwind this stuff
@ -25,7 +17,6 @@ class AddFeatureToggleComponent extends Component {
const { const {
input, input,
setValue, setValue,
validateName,
addStrategy, addStrategy,
removeStrategy, removeStrategy,
updateStrategy, updateStrategy,
@ -35,29 +26,12 @@ class AddFeatureToggleComponent extends Component {
editmode = false, editmode = false,
} = this.props; } = this.props;
const { const { description, enabled } = input;
name, // eslint-disable-line
nameError,
description,
enabled,
} = input;
const configuredStrategies = input.strategies || []; const configuredStrategies = input.strategies || [];
return ( return (
<form onSubmit={onSubmit(input)}> <form onSubmit={onSubmit(input)}>
<section style={{ padding: '16px' }}> <section style={{ padding: '16px' }}>
<Textfield
floatingLabel
label="Name"
name="name"
disabled={editmode}
required
value={name}
error={nameError}
onBlur={v => validateName(v.target.value)}
onChange={v => setValue('name', trim(v.target.value))}
/>
<br />
<Textfield <Textfield
floatingLabel floatingLabel
style={{ width: '100%' }} style={{ width: '100%' }}

View File

@ -9,8 +9,8 @@ import EditFeatureToggle from './form-edit-container.jsx';
import { styles as commonStyles } from '../common'; import { styles as commonStyles } from '../common';
const TABS = { const TABS = {
view: 0, strategies: 0,
edit: 1, view: 1,
history: 2, history: 2,
}; };
@ -40,7 +40,7 @@ export default class ViewFeatureToggleComponent extends React.Component {
if (TABS[activeTab] === TABS.history) { if (TABS[activeTab] === TABS.history) {
return <HistoryComponent toggleName={featureToggleName} />; return <HistoryComponent toggleName={featureToggleName} />;
} else if (TABS[activeTab] === TABS.edit) { } else if (TABS[activeTab] === TABS.strategies) {
return <EditFeatureToggle featureToggle={featureToggle} />; return <EditFeatureToggle featureToggle={featureToggle} />;
} else { } else {
return <MetricComponent featureToggle={featureToggle} />; return <MetricComponent featureToggle={featureToggle} />;
@ -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 tabContent = this.getTabContent(activeTab);
const removeToggle = () => { const removeToggle = () => {
@ -125,8 +125,8 @@ export default class ViewFeatureToggleComponent extends React.Component {
tabBarProps={{ style: { width: '100%' } }} tabBarProps={{ style: { width: '100%' } }}
className="mdl-color--grey-100" className="mdl-color--grey-100"
> >
<Tab onClick={() => this.goToTab('strategies', featureToggleName)}>Strategies</Tab>
<Tab onClick={() => this.goToTab('view', featureToggleName)}>Metrics</Tab> <Tab onClick={() => this.goToTab('view', featureToggleName)}>Metrics</Tab>
<Tab onClick={() => this.goToTab('edit', featureToggleName)}>Edit</Tab>
<Tab onClick={() => this.goToTab('history', featureToggleName)}>History</Tab> <Tab onClick={() => this.goToTab('history', featureToggleName)}>History</Tab>
</Tabs> </Tabs>
{tabContent} {tabContent}

View File

@ -54,7 +54,7 @@ export default class StrategyDetails extends Component {
} }
render() { 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; const strategy = this.props.strategy;
if (!strategy) { if (!strategy) {
return <ProgressBar indeterminate />; return <ProgressBar indeterminate />;