mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-17 01:17:29 +02:00
chore: admin menu main layout tweaks (#9671)
This commit is contained in:
parent
1bef63ff10
commit
a9490e6fe4
@ -1,12 +1,22 @@
|
|||||||
import { Box, Button, Grid, Paper, styled, Typography } from '@mui/material';
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Grid,
|
||||||
|
Paper,
|
||||||
|
styled,
|
||||||
|
Typography,
|
||||||
|
useMediaQuery,
|
||||||
|
useTheme,
|
||||||
|
} from '@mui/material';
|
||||||
import { useInstanceStats } from 'hooks/api/getters/useInstanceStats/useInstanceStats';
|
import { useInstanceStats } from 'hooks/api/getters/useInstanceStats/useInstanceStats';
|
||||||
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
|
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward';
|
import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward';
|
||||||
import { formatAssetPath } from 'utils/formatPath';
|
import { formatAssetPath } from 'utils/formatPath';
|
||||||
import easyToDeploy from 'assets/img/easyToDeploy.png';
|
import easyToDeploy from 'assets/img/easyToDeploy.png';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
const UI_SWITCH_WIDGET_RATIO_BREAKPOINT = 1505;
|
||||||
|
|
||||||
const StyledContainer = styled(Grid)(({ theme }) => ({
|
const StyledContainer = styled(Grid)(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
@ -21,6 +31,12 @@ const StyledInstanceWidget = styled(Paper)(({ theme }) => ({
|
|||||||
color: 'white',
|
color: 'white',
|
||||||
backgroundColor: theme.palette.web.main,
|
backgroundColor: theme.palette.web.main,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
|
[theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT)]: {
|
||||||
|
height: theme.spacing(24),
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down(800)]: {
|
||||||
|
height: theme.spacing(30),
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const StyledWidget = styled(Paper)(({ theme }) => ({
|
const StyledWidget = styled(Paper)(({ theme }) => ({
|
||||||
@ -43,6 +59,9 @@ const StyledHeader = styled(Typography)(({ theme }) => ({
|
|||||||
|
|
||||||
const StyledLicenseSection = styled('div')(({ theme }) => ({
|
const StyledLicenseSection = styled('div')(({ theme }) => ({
|
||||||
marginBottom: theme.spacing(6),
|
marginBottom: theme.spacing(6),
|
||||||
|
[theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT)]: {
|
||||||
|
marginBottom: theme.spacing(2),
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const StyledParagraph = styled(Typography)(({ theme }) => ({
|
const StyledParagraph = styled(Typography)(({ theme }) => ({
|
||||||
@ -53,6 +72,13 @@ const StyledParagraph = styled(Typography)(({ theme }) => ({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
gap: theme.spacing(1),
|
gap: theme.spacing(1),
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
|
[theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT)]: {
|
||||||
|
maxWidth: theme.spacing(65),
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down(800)]: {
|
||||||
|
flexDirection: 'column',
|
||||||
|
justifyContent: 'start',
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const StyledParamName = styled('div')(({ theme }) => ({
|
const StyledParamName = styled('div')(({ theme }) => ({
|
||||||
@ -117,6 +143,10 @@ const ImageContainer = styled('div')(({ theme }) => ({
|
|||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
marginTop: theme.spacing(-6),
|
marginTop: theme.spacing(-6),
|
||||||
marginRight: theme.spacing(-10),
|
marginRight: theme.spacing(-10),
|
||||||
|
[theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT)]: {
|
||||||
|
marginTop: theme.spacing(-22),
|
||||||
|
marginRight: theme.spacing(-12),
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const StyledImg = styled('img')(({ theme }) => ({
|
const StyledImg = styled('img')(({ theme }) => ({
|
||||||
@ -218,6 +248,12 @@ const InstanceStatsWidget = ({
|
|||||||
|
|
||||||
export const AdminHome = () => {
|
export const AdminHome = () => {
|
||||||
const stats = useInstanceStats();
|
const stats = useInstanceStats();
|
||||||
|
const theme = useTheme();
|
||||||
|
const isBreakpoint = useMediaQuery(
|
||||||
|
theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT),
|
||||||
|
);
|
||||||
|
const breakpointedInstanceStatsWidgetSize = isBreakpoint ? 12 : 7;
|
||||||
|
const breakpointedInstanceWidgetSize = isBreakpoint ? 12 : 5;
|
||||||
const { isOss, isPro, isEnterprise } = useUiConfig();
|
const { isOss, isPro, isEnterprise } = useUiConfig();
|
||||||
const plan = isOss()
|
const plan = isOss()
|
||||||
? 'Open source'
|
? 'Open source'
|
||||||
@ -226,12 +262,16 @@ export const AdminHome = () => {
|
|||||||
: isEnterprise()
|
: isEnterprise()
|
||||||
? 'Enterprise'
|
? 'Enterprise'
|
||||||
: 'Unknown';
|
: 'Unknown';
|
||||||
const { instanceStatus } = useInstanceStatus();
|
|
||||||
return (
|
return (
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
{stats && !stats.loading && (
|
{stats && !stats.loading && (
|
||||||
<Grid container spacing={3}>
|
<Grid container spacing={3}>
|
||||||
<Grid item md={5} sm={12} xs={12}>
|
<Grid
|
||||||
|
item
|
||||||
|
md={breakpointedInstanceWidgetSize}
|
||||||
|
sm={12}
|
||||||
|
xs={12}
|
||||||
|
>
|
||||||
<InstanceWidget
|
<InstanceWidget
|
||||||
plan={plan}
|
plan={plan}
|
||||||
instanceId={stats.stats?.instanceId ?? 'unknown'}
|
instanceId={stats.stats?.instanceId ?? 'unknown'}
|
||||||
@ -240,7 +280,12 @@ export const AdminHome = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item md={7} sm={12} xs={12}>
|
<Grid
|
||||||
|
item
|
||||||
|
md={breakpointedInstanceStatsWidgetSize}
|
||||||
|
sm={12}
|
||||||
|
xs={12}
|
||||||
|
>
|
||||||
<InstanceStatsWidget
|
<InstanceStatsWidget
|
||||||
environments={stats.stats?.environments ?? 0}
|
environments={stats.stats?.environments ?? 0}
|
||||||
featureToggles={stats.stats?.featureToggles ?? 0}
|
featureToggles={stats.stats?.featureToggles ?? 0}
|
||||||
|
@ -9,7 +9,6 @@ const breakpointLgMinusPaddingAdmin = 1550;
|
|||||||
const breakpointXlMinusPadding = 1512;
|
const breakpointXlMinusPadding = 1512;
|
||||||
const breakpointXlAdmin = 1812;
|
const breakpointXlAdmin = 1812;
|
||||||
const breakpointXxl = 1856;
|
const breakpointXxl = 1856;
|
||||||
const breakpointXxlAdmin = 2156;
|
|
||||||
|
|
||||||
const MainLayoutContent = styled(Grid)(({ theme }) => ({
|
const MainLayoutContent = styled(Grid)(({ theme }) => ({
|
||||||
minWidth: 0, // this is a fix for overflowing flex
|
minWidth: 0, // this is a fix for overflowing flex
|
||||||
@ -73,13 +72,6 @@ const StyledAdminMainGrid = styled(Grid)(({ theme }) => ({
|
|||||||
margin: '0 auto',
|
margin: '0 auto',
|
||||||
paddingLeft: theme.spacing(2),
|
paddingLeft: theme.spacing(2),
|
||||||
paddingRight: theme.spacing(2),
|
paddingRight: theme.spacing(2),
|
||||||
[theme.breakpoints.up(breakpointXxlAdmin)]: {
|
|
||||||
width: '100%',
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down(breakpointXxlAdmin)]: {
|
|
||||||
marginLeft: 0,
|
|
||||||
marginRight: 0,
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down('lg')]: {
|
[theme.breakpoints.down('lg')]: {
|
||||||
maxWidth: `${breakpointLgMinusPaddingAdmin}px`,
|
maxWidth: `${breakpointLgMinusPaddingAdmin}px`,
|
||||||
paddingLeft: theme.spacing(1),
|
paddingLeft: theme.spacing(1),
|
||||||
|
Loading…
Reference in New Issue
Block a user