1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/frontend/src/utils/strategy-names.js
Youssef Khedher 165170cd5c fix/breadcrumb (#533)
* fix: remove features2 from breadcrumb

* fix: strategy names

Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
2021-11-29 14:29:58 +01:00

73 lines
2.3 KiB
JavaScript

import LocationOnIcon from '@material-ui/icons/LocationOn';
import PeopleIcon from '@material-ui/icons/People';
import LanguageIcon from '@material-ui/icons/Language';
import MapIcon from '@material-ui/icons/Map';
import RolloutIcon from '../component/common/RolloutIcon/RolloutIcon';
const nameMapping = {
applicationHostname: {
name: 'Hosts',
description: 'Enable the feature for a specific set of hostnames',
},
default: {
name: 'Standard',
description:
'The standard strategy is strictly on / off for your entire userbase.',
},
flexibleRollout: {
name: 'Gradual rollout',
description:
'Roll out to a percentage of your userbase, and ensure that the experience is the same for the user on each visit.',
},
gradualRolloutRandom: {
name: 'Randomized',
description:
'Roll out to a percentage of your userbase and randomly enable the feature on a per request basis',
},
gradualRolloutSessionId: {
name: 'Sessions',
description:
'Roll out to a percentage of your userbase and configure stickiness based on sessionId',
},
gradualRolloutUserId: {
name: 'Users',
description:
'Roll out to a percentage of your userbase and configure stickiness based on userId',
},
remoteAddress: {
name: 'IPs',
description: 'Enable the feature for a specific set of IP addresses',
},
userWithId: {
name: 'UserIDs',
description: 'Enable the feature for a specific set of userIds',
},
};
export const getHumanReadbleStrategy = strategyName =>
nameMapping[strategyName];
export const getHumanReadableStrategyName = strategyName => {
const humanReadableStrategy = nameMapping[strategyName];
if (humanReadableStrategy) {
return humanReadableStrategy.name;
}
return strategyName;
};
export const getFeatureStrategyIcon = strategyName => {
switch (strategyName) {
case 'remoteAddress':
return LanguageIcon;
case 'flexibleRollout':
return RolloutIcon;
case 'userWithId':
return PeopleIcon;
case 'applicationHostname':
return LocationOnIcon;
default:
return MapIcon;
}
};