2023-06-15 11:29:31 +02:00
|
|
|
import { ConditionallyRender } from '../../../../common/ConditionallyRender/ConditionallyRender';
|
2023-06-15 14:11:04 +02:00
|
|
|
import {
|
|
|
|
Box,
|
|
|
|
IconButton,
|
|
|
|
Popover,
|
|
|
|
styled,
|
|
|
|
Typography,
|
|
|
|
useTheme,
|
|
|
|
} from '@mui/material';
|
2023-06-15 11:29:31 +02:00
|
|
|
import { flexRow } from '../../../../../themes/themeStyles';
|
|
|
|
import { PlaygroundResultChip } from '../../PlaygroundResultsTable/PlaygroundResultChip/PlaygroundResultChip';
|
|
|
|
import { InfoOutlined } from '@mui/icons-material';
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { AdvancedPlaygroundEnvironmentFeatureSchema } from 'openapi';
|
|
|
|
import { PlaygroundEnvironmentTable } from '../../PlaygroundEnvironmentTable/PlaygroundEnvironmentTable';
|
|
|
|
|
|
|
|
const StyledContainer = styled(
|
|
|
|
'div',
|
|
|
|
{}
|
|
|
|
)(({ theme }) => ({
|
|
|
|
flexGrow: 0,
|
|
|
|
...flexRow,
|
|
|
|
justifyContent: 'flex-start',
|
|
|
|
margin: theme.spacing(0, 1.5),
|
|
|
|
}));
|
|
|
|
|
|
|
|
const StyledPlaygroundChipContainer = styled(Box)(({ theme }) => ({
|
|
|
|
display: 'flex',
|
|
|
|
flexDirection: 'row',
|
|
|
|
gap: theme.spacing(1),
|
|
|
|
}));
|
|
|
|
|
|
|
|
export interface IAdvancedPlaygroundEnvironmentCellProps {
|
|
|
|
value: AdvancedPlaygroundEnvironmentFeatureSchema[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export const AdvancedPlaygroundEnvironmentCell = ({
|
|
|
|
value,
|
|
|
|
}: IAdvancedPlaygroundEnvironmentCellProps) => {
|
|
|
|
const theme = useTheme();
|
|
|
|
const [anchor, setAnchorEl] = useState<null | Element>(null);
|
|
|
|
|
|
|
|
const onOpen = (event: React.FormEvent<HTMLButtonElement>) =>
|
|
|
|
setAnchorEl(event.currentTarget);
|
|
|
|
|
|
|
|
const onClose = () => setAnchorEl(null);
|
|
|
|
|
|
|
|
const open = Boolean(anchor);
|
|
|
|
|
|
|
|
const enabled = (value || []).filter(evaluation => evaluation.isEnabled);
|
|
|
|
const disabled = (value || []).filter(evaluation => !evaluation.isEnabled);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<StyledContainer>
|
|
|
|
<StyledPlaygroundChipContainer>
|
|
|
|
<ConditionallyRender
|
|
|
|
condition={enabled.length > 0}
|
|
|
|
show={
|
|
|
|
<PlaygroundResultChip
|
|
|
|
enabled={true}
|
|
|
|
label={`${enabled.length}`}
|
|
|
|
showIcon={true}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<ConditionallyRender
|
|
|
|
condition={disabled.length > 0}
|
|
|
|
show={
|
|
|
|
<PlaygroundResultChip
|
|
|
|
enabled={false}
|
|
|
|
label={`${disabled.length}`}
|
|
|
|
showIcon={true}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</StyledPlaygroundChipContainer>
|
|
|
|
<>
|
|
|
|
<IconButton onClick={onOpen}>
|
|
|
|
<InfoOutlined />
|
|
|
|
</IconButton>
|
|
|
|
|
|
|
|
<Popover
|
|
|
|
open={open}
|
|
|
|
id={`${value}-result-details`}
|
|
|
|
PaperProps={{
|
|
|
|
sx: {
|
|
|
|
borderRadius: `${theme.shape.borderRadiusLarge}px`,
|
2023-06-15 14:11:04 +02:00
|
|
|
padding: theme.spacing(3),
|
2023-06-15 11:29:31 +02:00
|
|
|
},
|
|
|
|
}}
|
|
|
|
onClose={onClose}
|
|
|
|
anchorEl={anchor}
|
|
|
|
anchorOrigin={{
|
|
|
|
vertical: 'bottom',
|
|
|
|
horizontal: -320,
|
|
|
|
}}
|
|
|
|
>
|
2023-06-15 14:11:04 +02:00
|
|
|
<Typography variant="subtitle2" sx={{ mb: 3 }}>
|
|
|
|
{value[0].environment}
|
|
|
|
</Typography>
|
2023-06-15 11:29:31 +02:00
|
|
|
<PlaygroundEnvironmentTable features={value} />
|
|
|
|
</Popover>
|
|
|
|
</>
|
|
|
|
</StyledContainer>
|
|
|
|
);
|
|
|
|
};
|