1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00
unleash.unleash/frontend/src/utils/strategyNames.ts
olav f4d02e37b7 refactor: rewrite feature strategy icons list (#1039)
* refactor: fix strategy action icon layout

* refactor: use a custom SVG for the rollout strategy icon

* refactor: rewrite feature strategy icons list
2022-05-31 10:50:24 +02:00

37 lines
1.2 KiB
TypeScript

import LocationOnIcon from '@mui/icons-material/LocationOn';
import PeopleIcon from '@mui/icons-material/People';
import LanguageIcon from '@mui/icons-material/Language';
import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew';
import { ReactComponent as RolloutIcon } from 'assets/icons/rollout.svg';
import { ElementType } from 'react';
export const formatStrategyName = (strategyName: string): string => {
return formattedStrategyNames[strategyName] ?? strategyName;
};
export const getFeatureStrategyIcon = (strategyName: string): ElementType => {
switch (strategyName) {
case 'remoteAddress':
return LanguageIcon;
case 'flexibleRollout':
return RolloutIcon;
case 'userWithId':
return PeopleIcon;
case 'applicationHostname':
return LocationOnIcon;
default:
return PowerSettingsNewIcon;
}
};
const formattedStrategyNames: Record<string, string> = {
applicationHostname: 'Hosts',
default: 'Standard',
flexibleRollout: 'Gradual rollout',
gradualRolloutRandom: 'Randomized',
gradualRolloutSessionId: 'Sessions',
gradualRolloutUserId: 'Users',
remoteAddress: 'IPs',
userWithId: 'UserIDs',
};