Skip to content

Commit

Permalink
#57 code re-factoring and cleaning; add a common modals layout to be …
Browse files Browse the repository at this point in the history
…used across all application modals
  • Loading branch information
Salam Dalloul committed Jun 9, 2023
1 parent e5e8608 commit e408bdb
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 160 deletions.
130 changes: 39 additions & 91 deletions src/client/components/common/CondaSelectionDialog.js
Original file line number Diff line number Diff line change
@@ -1,107 +1,55 @@
import React from "react";
import {Box, Button, IconButton, Paper, Typography} from "@mui/material";
import { Button, Typography, Stack} from "@mui/material";
import {messageTypes} from "../../../messageTypes";
import vars from "../../assets/styles/variables";
import {CloseModalIcon} from "../views/visualiseView/icons/layoutIcons";
import {CustomSelect} from "./CustomSelect";
import {ModalsLayout} from "./ModalsLayout";

const {
lightBlack,
listItemActiveBg
} = vars;

export const CondaSelectionDialog = ({state, setState, getMenuItems}) => {

return <Paper
id='pnl-wall'
open={true}
sx={{
position: 'absolute',
top: 0,
left: 0,
width: 'calc(100VW)',
maxWidth: 'calc(100VW)',
height: 'calc(100Vh)',
border: '0px transparent',
background: 'rgba(0, 0, 0, 0.5)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Paper
elevation={4}
id='pnl-wall'
open={true}
hideBackdrop
sx={{
position: 'fixed',
background: "#fff",
borderRadius: '0.75rem',
zIndex: 1305,
width: '640px',
height: '640px',
}}
>
<IconButton
return (
<ModalsLayout hasClosingIcon={true}>
<Stack spacing={4}>
<Typography
sx={{
padding: 0,
margin: '1rem'
fontSize: '2.5rem',
fontWeight: 600,
color: lightBlack,
lineHeight: 1.2
}}
>
<CloseModalIcon />
</IconButton>
<Box
height={.895}
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'inherit',
justifyContent: 'space-between',
padding: '80px',
paddingTop: '25px'
}}
>
<Box>
<Typography
sx={{
fontSize: '2.5rem',
fontWeight: 600,
color: lightBlack,
marginBottom: '1.714rem',
lineHeight: 1.2
}}
>
{'Select conda environment:'}
</Typography>
<CustomSelect state={state} setState={(val) => setState(val)} getMenuItems={getMenuItems} />
</Box>
{'Select conda environment:'}
</Typography>
<CustomSelect state={state} setState={(val) => setState(val)} getMenuItems={getMenuItems} />
</Stack>

<Button
size="small"
variant="contained"
sx={{
width: '100%',
height: '2.5rem',
boxShadow: 'none',
backgroundColor: listItemActiveBg,
border: '2px solid rgba(0, 0, 0, 0.1)'
}}
onClick={() => {
window.api.send("toMain", {
type: messageTypes.CONDA_ENV_SELECTED,
payload: state.condaEnv
});
setState({
openCondaDialog: false,
dependenciesFound: true,
spinnerEnabled: true,
});
}}
>
Save conda environment
</Button>
</Box>
</Paper>
</Paper>
<Button
size="small"
variant="contained"
sx={{
width: '100%',
height: '2.5rem',
boxShadow: 'none',
backgroundColor: listItemActiveBg,
border: '2px solid rgba(0, 0, 0, 0.1)'
}}
onClick={() => {
window.api.send("toMain", {
type: messageTypes.CONDA_ENV_SELECTED,
payload: state.condaEnv
});
setState({
openCondaDialog: false,
dependenciesFound: true,
spinnerEnabled: true,
});
}}
>
Save conda environment
</Button>
</ModalsLayout>)
}
97 changes: 29 additions & 68 deletions src/client/components/common/DependenciesDialog.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from "react";
import {Box, Button, Paper, Typography, Stack} from "@mui/material";
import { Button, Typography, Stack} from "@mui/material";
import {messageTypes} from "../../../messageTypes";
import vars from "../../assets/styles/variables";
import {ModalsLayout} from "./ModalsLayout";

const {
breadcrumbTextColor,
Expand All @@ -12,70 +13,31 @@ const {
} = vars;

export const DependenciesDialog = ({state, setState}) => {
return <Paper
id='pnl-wall'
open={true}
sx={{
position: 'absolute',
top: 0,
left: 0,
width: 'calc(100VW)',
maxWidth: 'calc(100VW)',
height: 'calc(100Vh)',
border: '0px transparent',
background: 'rgba(0, 0, 0, 0.5)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Paper
elevation={4}
id='pnl-wall'
open={true}
hideBackdrop
sx={{
position: 'fixed',
background: "#fff",
borderRadius: '0.75rem',
zIndex: 1305,
padding: '80px',
width: '640px',
height: '640px',
}}
>
<Box
height={1}
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
textAlign: 'left',
}}
>
<Stack spacing={2}>
<Typography
sx={{
fontSize: '2.5rem',
fontWeight: 600,
color: lightBlack,
lineHeight: 1.2
}}
>
We couldn’t find Psyneulink.
</Typography>
<Typography
sx={{
fontWeight: 500,
fontSize: '0.875rem',
color: breadcrumbTextColor,
}}
>
Psyneulink has not been found on this conda environment. You can switch environment or install Psyneulink on this one.
</Typography>
</Stack>
return (
<ModalsLayout>
<Stack spacing={2}>
<Typography
sx={{
fontSize: '2.5rem',
fontWeight: 600,
color: lightBlack,
lineHeight: 1.2
}}
>
We couldn’t find Psyneulink.
</Typography>
<Typography
sx={{
fontWeight: 500,
fontSize: '0.875rem',
color: breadcrumbTextColor,
}}
>
Psyneulink has not been found on this conda environment. You can switch environment or install Psyneulink on this one.
</Typography>
</Stack>

<Stack spacing={1}>
<Stack spacing={1}>
<Button
variant="contained"
sx={{
Expand Down Expand Up @@ -123,8 +85,7 @@ export const DependenciesDialog = ({state, setState}) => {
>
Install PsyNeuLink
</Button>
</Stack>
</Box>
</Paper>
</Paper>
</Stack>
</ModalsLayout>
)
}
2 changes: 1 addition & 1 deletion src/client/components/common/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Layout extends React.Component {
electronState: appStates.FRONTEND_STARTED,
condaEnv: '',
condaEnvs: undefined,
dependenciesFound: true,
dependenciesFound: false,
condaEnvSelection: false,
spinnerEnabled: !isFrontendDev,
};
Expand Down
66 changes: 66 additions & 0 deletions src/client/components/common/ModalsLayout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from "react";
import {Box, IconButton, Paper} from "@mui/material";
import {CloseModalIcon} from "../views/visualiseView/icons/layoutIcons";

export const ModalsLayout = ({children, hasClosingIcon = false}) => {

return <Paper
id='pnl-wall'
open={true}
sx={{
position: 'absolute',
top: 0,
left: 0,
width: 'calc(100VW)',
maxWidth: 'calc(100VW)',
height: 'calc(100Vh)',
border: '0px transparent',
background: 'rgba(0, 0, 0, 0.5)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Paper
elevation={4}
id='pnl-wall'
open={true}
hideBackdrop
sx={{
position: 'fixed',
background: "#fff",
borderRadius: '0.75rem',
zIndex: 1305,
width: '640px',
height: '640px',
top: 60,
}}
>
{
hasClosingIcon && <IconButton
sx={{
padding: 0,
margin: '1rem',
position: 'absolute',
top: '0',
}}
>
<CloseModalIcon />
</IconButton>
}

<Box
height={1}
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
textAlign: 'left',
padding: '80px',
}}
>
{children}
</Box>
</Paper>
</Paper>
}

0 comments on commit e408bdb

Please sign in to comment.