1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-22 01:16:07 +02:00
unleash.unleash/frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureStatusCell/FeatureStatusCell.tsx
Tymoteusz Czech 859aa435e0 Refine Playground UI (#1217)
* fix playground border radius consistency

* improve playground alerts

* fix: playground segments constraint type logic

* fix: refactor segment execution

* fix: comments

* fix: add summary width

* align playground spacing and borders

* fix build - ts segment type in playground

* fix status cell logic

* update playground disabled env info

* fix playground filter by status and sort

Co-authored-by: Nuno Góis <github@nunogois.com>

Co-authored-by: Fredrik Oseberg <fredrik.no@gmail.com>
Co-authored-by: andreas-unleash <104830839+andreas-unleash@users.noreply.github.com>
Co-authored-by: Nuno Góis <github@nunogois.com>
2022-08-12 10:13:07 +00:00

43 lines
1.2 KiB
TypeScript

import React from 'react';
import { Box, styled } from '@mui/material';
import { PlaygroundResultChip } from '../PlaygroundResultChip/PlaygroundResultChip';
import { PlaygroundFeatureSchema } from '../../interfaces/playground.model';
interface IFeatureStatusCellProps {
feature: PlaygroundFeatureSchema;
}
const StyledCellBox = styled(Box)(({ theme }) => ({
display: 'flex',
alignItems: 'center',
padding: theme.spacing(1, 2),
}));
const StyledChipWrapper = styled(Box)(() => ({
marginRight: 'auto',
}));
export const FeatureStatusCell = ({ feature }: IFeatureStatusCellProps) => {
const [enabled, label]: [boolean | 'unknown', string] = (() => {
if (feature?.isEnabled) {
return [true, 'True'];
}
if (feature?.strategies?.result === 'unknown') {
return ['unknown', 'Unknown'];
}
return [false, 'False'];
})();
return (
<StyledCellBox>
<StyledChipWrapper data-loading>
<PlaygroundResultChip
enabled={enabled}
label={label}
showIcon={enabled !== 'unknown'}
/>
</StyledChipWrapper>
</StyledCellBox>
);
};