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

Merge branch 'master' into improve-application-list-view-layout

This commit is contained in:
Vegard Sandvold 2017-02-14 12:52:34 +01:00 committed by GitHub
commit 1b37348b72
2 changed files with 35 additions and 33 deletions

View File

@ -66,7 +66,7 @@ export default class FeatureListComponent extends React.PureComponent {
</FABButton> </FABButton>
</Link> </Link>
</div> </div>
<Card shadow={0} className={commonStyles.fullwidth}> <Card shadow={0} className={commonStyles.fullwidth} style={{ overflow: 'visible' }}>
<CardActions> <CardActions>
<DropdownButton id="metric" label={`Last ${settings.showLastHour ? 'hour' : 'minute'}`}/> <DropdownButton id="metric" label={`Last ${settings.showLastHour ? 'hour' : 'minute'}`}/>
<Menu target="metric" onClick={() => this.toggleMetrics()} <Menu target="metric" onClick={() => this.toggleMetrics()}
@ -79,7 +79,7 @@ export default class FeatureListComponent extends React.PureComponent {
<DropdownButton id="sorting" label={`By ${settings.sort}`}/> <DropdownButton id="sorting" label={`By ${settings.sort}`}/>
<Menu target="sorting" onClick={(e) => this.setSort(e.target.getAttribute('data-target'))} <Menu target="sorting" onClick={(e) => this.setSort(e.target.getAttribute('data-target'))}
style={{ width: '168px' }}> style={{ width: '168px' }}>
<MenuItem disabled={!settings.sort || settings.sort === 'name'} data-target="name">Name</MenuItem> <MenuItem disabled={settings.sort === 'name'} data-target="name">Name</MenuItem>
<MenuItem disabled={settings.sort === 'enabled'} data-target="enabled">Enabled</MenuItem> <MenuItem disabled={settings.sort === 'enabled'} data-target="enabled">Enabled</MenuItem>
<MenuItem disabled={settings.sort === 'created'} data-target="created">Created</MenuItem> <MenuItem disabled={settings.sort === 'created'} data-target="created">Created</MenuItem>
<MenuItem disabled={settings.sort === 'strategies'} data-target="strategies">Strategies</MenuItem> <MenuItem disabled={settings.sort === 'strategies'} data-target="strategies">Strategies</MenuItem>

View File

@ -21,38 +21,40 @@ const mapStateToProps = (state) => {
); );
} }
if (settings.sort) { if (!settings.sort) {
if (settings.sort === 'enabled') { settings.sort = 'name';
features = features.sort((a, b) => ( }
// eslint-disable-next-line
a.enabled === b.enabled ? 0 : a.enabled ? -1 : 1
));
} else if (settings.sort === 'created') {
features = features.sort((a, b) => (
new Date(a.createdAt) > new Date(b.createdAt) ? -1 : 1
));
} else if (settings.sort === 'name') {
features = features.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
} else if (settings.sort === 'strategies') {
features = features.sort((a, b) => (
a.strategies.length > b.strategies.length ? -1 : 1
));
} else if (settings.sort === 'metrics') {
const target = settings.showLastHour ? featureMetrics.lastHour : featureMetrics.lastMinute;
features = features.sort((a, b) => { if (settings.sort === 'enabled') {
if (!target[a.name]) { return 1; } features = features.sort((a, b) => (
if (!target[b.name]) { return -1; } // eslint-disable-next-line
if (target[a.name].yes > target[b.name].yes) { a.enabled === b.enabled ? 0 : a.enabled ? -1 : 1
return -1; ));
} } else if (settings.sort === 'created') {
return 1; features = features.sort((a, b) => (
}); new Date(a.createdAt) > new Date(b.createdAt) ? -1 : 1
} ));
} else if (settings.sort === 'name') {
features = features.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
} else if (settings.sort === 'strategies') {
features = features.sort((a, b) => (
a.strategies.length > b.strategies.length ? -1 : 1
));
} else if (settings.sort === 'metrics') {
const target = settings.showLastHour ? featureMetrics.lastHour : featureMetrics.lastMinute;
features = features.sort((a, b) => {
if (!target[a.name]) { return 1; }
if (!target[b.name]) { return -1; }
if (target[a.name].yes > target[b.name].yes) {
return -1;
}
return 1;
});
} }
return { return {