Skip to content

Commit

Permalink
fix: 🐛 fix new model page layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Pauline Didier committed Oct 25, 2024
1 parent 138e795 commit 30c4da8
Show file tree
Hide file tree
Showing 12 changed files with 297 additions and 284 deletions.
4 changes: 2 additions & 2 deletions app/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export default function App() {
sx={{
display: "flex",
flexDirection: "column",
height: "calc(100% - 64px)", // 64px is the height of Navbar
maxHeight: "calc(100% - 64px)",
height: isFramed ? "100%" : "calc(100% - 64px)", // 64px is the height of Navbar
maxHeight: isFramed ? "100%" : "calc(100% - 64px)", // 64px is the height of Navbar
width: "100%",
}}
>
Expand Down
16 changes: 7 additions & 9 deletions app/src/components/elements/CenteredPage.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import React from "react";
import { useIsFramed } from "../../hooks/useIsFramed";
import Grid from "@mui/material/Grid2";

export function CenteredPage({ children }) {
const isFramed = useIsFramed();
export function CenteredPage({ children, marginTop = true }) {
return (
<Grid
container
spacing={0}
columns={12}
spacing={2}
direction="row"
alignItems="center"
justifyContent="center"
marginTop={marginTop ? "20px" : ""}
marginX={"auto"}
maxWidth={"80%"}
>
<Grid width={"80%"} marginTop={isFramed ? "" : "84px"}>
{children}
</Grid>
{children}
</Grid>
);
}
80 changes: 37 additions & 43 deletions app/src/components/home/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,58 +21,52 @@ export default function Home() {

return (
<CenteredPage>
<Grid container spacing={2} columns={12}>
<Grid
size={6}
maxHeight="88vh"
sx={{ display: "flex", flexFlow: "column" }}
>
<Typography variant="h5">Recent Threat Models</Typography>
<Typography className="dimmed">
Threat models you recently interacted with
</Typography>
<ModelList models={recentModels} error={isError} pending={isLoading} />
</Grid>
{user?.teams?.length > 0 && (
<Grid
size={6}
columns={1}
maxHeight="88vh"
sx={{ display: "flex", flexFlow: "column" }}
>
<Typography variant="h5">Recent Threat Models</Typography>
<Typography variant="h5">Team Systems</Typography>
<Typography className="dimmed">
Threat models you recently interacted with
Systems owned by the accountable teams you're in
</Typography>
<ModelList
models={recentModels}
error={isError}
pending={isLoading}
/>
</Grid>
{user?.teams?.length > 0 && (
<Grid
<Box
size={6}
columns={1}
maxHeight="88vh"
sx={{ display: "flex", flexFlow: "column" }}
sx={{
overflow: "auto",
marginTop: "25px",
display: "flex",
flexDirection: "column",
}}
>
<Typography variant="h5">Team Systems</Typography>
<Typography className="dimmed">
Systems owned by the accountable teams you're in
</Typography>
<Box
size={6}
sx={{
overflow: "auto",
marginTop: "25px",
display: "flex",
flexDirection: "column",
}}
>
<Grid container spacing={2} columns={1} style={{ flex: "2" }}>
{user?.teams &&
user.teams.map((team, i) => (
<Grid size={1}>
<TeamSystemsPageList
key={team.id}
teamId={team.id}
pagesize={user?.teams.length > 1 ? 5 : 10}
/>
</Grid>
))}
</Grid>
</Box>
</Grid>
)}
</Grid>
<Grid container spacing={2} columns={1} style={{ flex: "2" }}>
{user?.teams &&
user.teams.map((team, i) => (
<Grid size={1}>
<TeamSystemsPageList
key={team.id}
teamId={team.id}
pagesize={user?.teams.length > 1 ? 5 : 10}
/>
</Grid>
))}
</Grid>
</Box>
</Grid>
)}
</CenteredPage>
);
}
9 changes: 7 additions & 2 deletions app/src/components/model/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ import { useSelector } from "react-redux";
function setGridArea(
leftPanelCollapsed,
rightPanelCollapsed,
bottomPanelCollapsed
bottomPanelCollapsed,
isFramed
) {
if (isFramed) {
return `'board board board' 'board board board'`;
}
// Add first row
let firstRow = `'${leftPanelCollapsed ? "board" : "left"} board ${
rightPanelCollapsed ? "board" : "right"
Expand Down Expand Up @@ -139,7 +143,8 @@ export function Model() {
gridTemplateAreas: setGridArea(
leftPanelCollapsed,
rightPanelCollapsed,
bottomPanelCollapsed
bottomPanelCollapsed,
isFramed
),
}}
>
Expand Down
14 changes: 9 additions & 5 deletions app/src/components/model/ModelPreview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Box } from "@mui/material";

export function ModelPreview({ modelId, ...props }) {
return (
<iframe
title="Model Preview"
{...props}
src={document.location.origin + "/model/" + modelId}
></iframe>
<Box>
<iframe
title="Model Preview"
{...props}
src={document.location.origin + "/model/" + modelId}
></iframe>
</Box>
);
}
Loading

0 comments on commit 30c4da8

Please sign in to comment.