Skip to content

Commit a9490e6

Browse files
authored
chore: admin menu main layout tweaks (#9671)
1 parent 1bef63f commit a9490e6

File tree

2 files changed

+50
-13
lines changed

2 files changed

+50
-13
lines changed

frontend/src/component/admin/AdminHome.tsx

+50-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
import { Box, Button, Grid, Paper, styled, Typography } from '@mui/material';
1+
import {
2+
Box,
3+
Button,
4+
Grid,
5+
Paper,
6+
styled,
7+
Typography,
8+
useMediaQuery,
9+
useTheme,
10+
} from '@mui/material';
211
import { useInstanceStats } from 'hooks/api/getters/useInstanceStats/useInstanceStats';
3-
import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus';
412
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
513
import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward';
614
import { formatAssetPath } from 'utils/formatPath';
715
import easyToDeploy from 'assets/img/easyToDeploy.png';
816
import { useNavigate } from 'react-router-dom';
917

18+
const UI_SWITCH_WIDGET_RATIO_BREAKPOINT = 1505;
19+
1020
const StyledContainer = styled(Grid)(({ theme }) => ({
1121
display: 'flex',
1222
flexDirection: 'column',
@@ -21,6 +31,12 @@ const StyledInstanceWidget = styled(Paper)(({ theme }) => ({
2131
color: 'white',
2232
backgroundColor: theme.palette.web.main,
2333
overflow: 'hidden',
34+
[theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT)]: {
35+
height: theme.spacing(24),
36+
},
37+
[theme.breakpoints.down(800)]: {
38+
height: theme.spacing(30),
39+
},
2440
}));
2541

2642
const StyledWidget = styled(Paper)(({ theme }) => ({
@@ -43,6 +59,9 @@ const StyledHeader = styled(Typography)(({ theme }) => ({
4359

4460
const StyledLicenseSection = styled('div')(({ theme }) => ({
4561
marginBottom: theme.spacing(6),
62+
[theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT)]: {
63+
marginBottom: theme.spacing(2),
64+
},
4665
}));
4766

4867
const StyledParagraph = styled(Typography)(({ theme }) => ({
@@ -53,6 +72,13 @@ const StyledParagraph = styled(Typography)(({ theme }) => ({
5372
display: 'flex',
5473
gap: theme.spacing(1),
5574
justifyContent: 'space-between',
75+
[theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT)]: {
76+
maxWidth: theme.spacing(65),
77+
},
78+
[theme.breakpoints.down(800)]: {
79+
flexDirection: 'column',
80+
justifyContent: 'start',
81+
},
5682
}));
5783

5884
const StyledParamName = styled('div')(({ theme }) => ({
@@ -117,6 +143,10 @@ const ImageContainer = styled('div')(({ theme }) => ({
117143
justifyContent: 'flex-end',
118144
marginTop: theme.spacing(-6),
119145
marginRight: theme.spacing(-10),
146+
[theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT)]: {
147+
marginTop: theme.spacing(-22),
148+
marginRight: theme.spacing(-12),
149+
},
120150
}));
121151

122152
const StyledImg = styled('img')(({ theme }) => ({
@@ -218,6 +248,12 @@ const InstanceStatsWidget = ({
218248

219249
export const AdminHome = () => {
220250
const stats = useInstanceStats();
251+
const theme = useTheme();
252+
const isBreakpoint = useMediaQuery(
253+
theme.breakpoints.down(UI_SWITCH_WIDGET_RATIO_BREAKPOINT),
254+
);
255+
const breakpointedInstanceStatsWidgetSize = isBreakpoint ? 12 : 7;
256+
const breakpointedInstanceWidgetSize = isBreakpoint ? 12 : 5;
221257
const { isOss, isPro, isEnterprise } = useUiConfig();
222258
const plan = isOss()
223259
? 'Open source'
@@ -226,12 +262,16 @@ export const AdminHome = () => {
226262
: isEnterprise()
227263
? 'Enterprise'
228264
: 'Unknown';
229-
const { instanceStatus } = useInstanceStatus();
230265
return (
231266
<StyledContainer>
232267
{stats && !stats.loading && (
233268
<Grid container spacing={3}>
234-
<Grid item md={5} sm={12} xs={12}>
269+
<Grid
270+
item
271+
md={breakpointedInstanceWidgetSize}
272+
sm={12}
273+
xs={12}
274+
>
235275
<InstanceWidget
236276
plan={plan}
237277
instanceId={stats.stats?.instanceId ?? 'unknown'}
@@ -240,7 +280,12 @@ export const AdminHome = () => {
240280
}
241281
/>
242282
</Grid>
243-
<Grid item md={7} sm={12} xs={12}>
283+
<Grid
284+
item
285+
md={breakpointedInstanceStatsWidgetSize}
286+
sm={12}
287+
xs={12}
288+
>
244289
<InstanceStatsWidget
245290
environments={stats.stats?.environments ?? 0}
246291
featureToggles={stats.stats?.featureToggles ?? 0}

frontend/src/component/layout/MainLayout/AdminMenu/AdminMenu.tsx

-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const breakpointLgMinusPaddingAdmin = 1550;
99
const breakpointXlMinusPadding = 1512;
1010
const breakpointXlAdmin = 1812;
1111
const breakpointXxl = 1856;
12-
const breakpointXxlAdmin = 2156;
1312

1413
const MainLayoutContent = styled(Grid)(({ theme }) => ({
1514
minWidth: 0, // this is a fix for overflowing flex
@@ -73,13 +72,6 @@ const StyledAdminMainGrid = styled(Grid)(({ theme }) => ({
7372
margin: '0 auto',
7473
paddingLeft: theme.spacing(2),
7574
paddingRight: theme.spacing(2),
76-
[theme.breakpoints.up(breakpointXxlAdmin)]: {
77-
width: '100%',
78-
},
79-
[theme.breakpoints.down(breakpointXxlAdmin)]: {
80-
marginLeft: 0,
81-
marginRight: 0,
82-
},
8375
[theme.breakpoints.down('lg')]: {
8476
maxWidth: `${breakpointLgMinusPaddingAdmin}px`,
8577
paddingLeft: theme.spacing(1),

0 commit comments

Comments
 (0)