2023-01-11 17:44:21 +01:00
|
|
|
import { FC } from 'react';
|
2022-12-12 16:32:38 +01:00
|
|
|
import { SvgIcon, useTheme } from '@mui/material';
|
2022-05-02 15:52:41 +02:00
|
|
|
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';
|
2022-07-27 12:00:15 +02:00
|
|
|
import CodeIcon from '@mui/icons-material/Code';
|
2022-05-31 10:50:24 +02:00
|
|
|
import { ReactComponent as RolloutIcon } from 'assets/icons/rollout.svg';
|
2022-03-09 14:59:24 +01:00
|
|
|
|
|
|
|
export const formatStrategyName = (strategyName: string): string => {
|
|
|
|
return formattedStrategyNames[strategyName] ?? strategyName;
|
|
|
|
};
|
|
|
|
|
2023-10-02 14:25:46 +02:00
|
|
|
const RolloutSvgIcon: FC = (props) => (
|
2022-07-28 12:05:48 +02:00
|
|
|
<SvgIcon
|
|
|
|
{...props}
|
2023-10-02 14:25:46 +02:00
|
|
|
component={(rest) => <RolloutIcon {...rest} />}
|
2022-07-28 12:05:48 +02:00
|
|
|
inheritViewBox
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
2023-01-11 17:44:21 +01:00
|
|
|
export const getFeatureStrategyIcon = (strategyName: string) => {
|
2022-03-09 14:59:24 +01:00
|
|
|
switch (strategyName) {
|
2022-07-27 12:00:15 +02:00
|
|
|
case 'default':
|
|
|
|
return PowerSettingsNewIcon;
|
2022-03-09 14:59:24 +01:00
|
|
|
case 'remoteAddress':
|
|
|
|
return LanguageIcon;
|
|
|
|
case 'flexibleRollout':
|
2022-07-28 12:05:48 +02:00
|
|
|
return RolloutSvgIcon;
|
2022-03-09 14:59:24 +01:00
|
|
|
case 'userWithId':
|
|
|
|
return PeopleIcon;
|
|
|
|
case 'applicationHostname':
|
|
|
|
return LocationOnIcon;
|
|
|
|
default:
|
2022-07-27 12:00:15 +02:00
|
|
|
return CodeIcon;
|
2022-03-09 14:59:24 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-10-26 09:45:24 +02:00
|
|
|
export const GetFeatureStrategyIcon: FC<{ strategyName: string }> = ({
|
|
|
|
strategyName,
|
|
|
|
}) => {
|
2022-12-12 16:32:38 +01:00
|
|
|
const theme = useTheme();
|
2022-10-26 09:45:24 +02:00
|
|
|
const Icon = getFeatureStrategyIcon(strategyName);
|
2022-12-12 16:32:38 +01:00
|
|
|
return <Icon style={{ color: theme.palette.neutral.main }} />;
|
2022-10-26 09:45:24 +02:00
|
|
|
};
|
|
|
|
|
2022-08-12 12:13:07 +02:00
|
|
|
export const formattedStrategyNames: Record<string, string> = {
|
2022-03-09 14:59:24 +01:00
|
|
|
applicationHostname: 'Hosts',
|
|
|
|
default: 'Standard',
|
|
|
|
flexibleRollout: 'Gradual rollout',
|
|
|
|
gradualRolloutRandom: 'Randomized',
|
|
|
|
gradualRolloutSessionId: 'Sessions',
|
|
|
|
gradualRolloutUserId: 'Users',
|
|
|
|
remoteAddress: 'IPs',
|
|
|
|
userWithId: 'UserIDs',
|
|
|
|
};
|