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

clean(feature-list): remove ternary if in jsx

This commit is contained in:
Corinne Krych 2018-03-20 19:07:17 +01:00
parent aaf4243b24
commit a7a7201590
2 changed files with 15 additions and 46 deletions

View File

@ -22,6 +22,7 @@ exports[`renders correctly with one feature 1`] = `
> >
<react-mdl-Switch <react-mdl-Switch
checked={false} checked={false}
disabled={true}
onChange={[Function]} onChange={[Function]}
title="Toggle Another" title="Toggle Another"
/> />

View File

@ -16,10 +16,8 @@ const Feature = ({
revive, revive,
}) => { }) => {
const { name, description, enabled, strategies } = feature; const { name, description, enabled, strategies } = feature;
const { showLastHour = false } = settings; const { showLastHour = false } = settings;
const isStale = showLastHour ? metricsLastHour.isFallback : metricsLastMinute.isFallback; const isStale = showLastHour ? metricsLastHour.isFallback : metricsLastMinute.isFallback;
const percent = const percent =
1 * 1 *
(showLastHour (showLastHour
@ -28,7 +26,6 @@ const Feature = ({
const strategiesToShow = Math.min(strategies.length, 3); const strategiesToShow = Math.min(strategies.length, 3);
const remainingStrategies = strategies.length - strategiesToShow; const remainingStrategies = strategies.length - strategiesToShow;
const strategyChips = const strategyChips =
strategies && strategies &&
strategies.slice(0, strategiesToShow).map((s, i) => ( strategies.slice(0, strategiesToShow).map((s, i) => (
@ -37,55 +34,26 @@ const Feature = ({
</Chip> </Chip>
)); ));
const summaryChip = remainingStrategies > 0 && <Chip className={styles.strategyChip}>+{remainingStrategies}</Chip>; const summaryChip = remainingStrategies > 0 && <Chip className={styles.strategyChip}>+{remainingStrategies}</Chip>;
const featureUrl = toggleFeature === undefined ? `/archive/strategies/${name}` : `/features/strategies/${name}`;
return ( return (
<ListItem twoLine> <ListItem twoLine>
<span className={styles.listItemMetric}> <span className={styles.listItemMetric}>
<Progress strokeWidth={15} percentage={percent} isFallback={isStale} /> <Progress strokeWidth={15} percentage={percent} isFallback={isStale} />
</span> </span>
{toggleFeature ? ( // display feature list, toggleFeature is available <span className={styles.listItemToggle}>
<span className={styles.listItemToggle}> <Switch
<Switch disabled={toggleFeature !== undefined}
title={`Toggle ${name}`} title={`Toggle ${name}`}
key="left-actions" key="left-actions"
onChange={() => toggleFeature(name)} onChange={() => toggleFeature(name)}
checked={enabled} checked={enabled}
/> />
</span> </span>
) : (
// display archive, toggleFeature is undefined
<span className={styles.listItemToggle}>
<Switch
disabled
title={`Toggle ${name}`}
key="left-actions"
onChange={() => toggleFeature(name)}
checked={enabled}
/>
</span>
)}
<span className={['mdl-list__item-primary-content', styles.listItemLink].join(' ')}> <span className={['mdl-list__item-primary-content', styles.listItemLink].join(' ')}>
{toggleFeature ? ( // display feature list, toggleFeature is available <Link to={featureUrl} className={[commonStyles.listLink, commonStyles.truncate].join(' ')}>
<Link {name}
to={`/features/strategies/${name}`} <span className={['mdl-list__item-sub-title', commonStyles.truncate].join(' ')}>{description}</span>
className={[commonStyles.listLink, commonStyles.truncate].join(' ')} </Link>
>
{name}
<span className={['mdl-list__item-sub-title', commonStyles.truncate].join(' ')}>
{description}
</span>
</Link>
) : (
<Link
to={`/archive/strategies/${name}`}
className={[commonStyles.listLink, commonStyles.truncate].join(' ')}
>
{name}
<span className={['mdl-list__item-sub-title', commonStyles.truncate].join(' ')}>
{description}
</span>
</Link>
)}
</span> </span>
<span className={[styles.listItemStrategies, commonStyles.hideLt920].join(' ')}> <span className={[styles.listItemStrategies, commonStyles.hideLt920].join(' ')}>
{strategyChips} {strategyChips}