Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update style on the forms #29

Merged
merged 3 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
update style on the forms
  • Loading branch information
nhayfield committed Sep 8, 2021
commit c8fcaa474e2e9f1f24ac1f4d6e7c3a6dd5a61274
Binary file added assets/bin/pomerium-cli
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
"menubar": "^9.0.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-feather": "^2.0.9",
"react-router": "5.2.0",
"react-router-dom": "5.2.0",
"regenerator-runtime": "^0.13.9",
Expand Down
72 changes: 72 additions & 0 deletions src/components/FieldWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {
Grid,
makeStyles,
Typography,
SvgIcon,
Divider,
Container,
Tooltip,
} from '@material-ui/core';
import React, { FC, ReactNode } from 'react';
import { HelpCircle } from 'react-feather';
import { Theme } from '../utils/theme';

const useStyles = makeStyles((theme: Theme) => ({
container: {
padding: theme.spacing(2),
},
innerContainer: {
marginBottom: theme.spacing(1),
},
labelGridItem: {
width: '260px',
paddingRight: theme.spacing(2),
display: `flex`,
flexFlow: `row wrap`,
},
questionMark: {
marginLeft: theme.spacing(1),
},
}));

type FieldWrapperProps = {
label: string;
description: string;
children: ReactNode;
};

const FieldWrapper: FC<FieldWrapperProps> = ({
label,
description,
children,
}: FieldWrapperProps): JSX.Element => {
const classes = useStyles();

return (
<Container maxWidth={false} disableGutters className={classes.container}>
<Grid container className={classes.innerContainer}>
<Grid
item
xs={4}
className={classes.labelGridItem}
alignItems="flex-start"
>
<Typography variant="body1">{label}</Typography>
<sub className={classes.questionMark}>
<Tooltip title={description}>
<SvgIcon color="primary">
<HelpCircle width="16px" height="16px" fontSize="1em" />
</SvgIcon>
</Tooltip>
</sub>
</Grid>
<Grid item xs alignItems="flex-start">
{children}
</Grid>
</Grid>
<Divider />
</Container>
);
};

export default FieldWrapper;
2 changes: 1 addition & 1 deletion src/components/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const TextField = (props: TextFieldProps): JSX.Element => {
const classes = useStyles();
return (
<MuiTextField
{...props} //
{...props}
variant="outlined"
size="small"
color="primary"
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8" />
<title>Pomerium TCP Connector</title>
<title>Pomerium Desktop</title>
<meta
name="description"
content="Pomerium is a beyond-corp inspired, zero trust, open source identity-aware access proxy."
Expand Down
255 changes: 134 additions & 121 deletions src/pages/ConnectForm.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {
Button,
FormControlLabel,
FormGroup,
Button, Container,
Grid,
List,
ListItem,
makeStyles,
Switch,
Typography,
} from '@material-ui/core';
Typography
} from "@material-ui/core";
import { ipcRenderer } from 'electron';
import React, { FC, useEffect, useState } from 'react';
import { v4 as uuidv4 } from 'uuid';
Expand All @@ -22,11 +20,12 @@ import {
DISCONNECT,
} from '../utils/constants';
import TextField from '../components/TextField';
import FieldWrapper from '../components/FieldWrapper';
import { Theme } from '../utils/theme';

const useStyles = makeStyles((theme: Theme) => ({
container: {
padding: theme.spacing(3),
padding: theme.spacing(2),
},
red: {
color: 'red',
Expand Down Expand Up @@ -169,127 +168,141 @@ const ConnectForm: FC<Props> = () => {
};

return (
<>
<Container>
<form onSubmit={handleSubmit}>
<Grid className={classes.container}>
<Grid container spacing={2} alignItems="center">
<Grid container alignItems="flex-start">
<Grid item xs={12}>
<Typography variant="h3" color="textPrimary">
Pomerium TCP Connector
{connectionData.channelID ? 'Edit' : 'Add'} TCP Connection
</Typography>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
required
label="Destination Url"
value={connectionData.destinationUrl}
onChange={(evt): void => saveDestination(evt.target.value)}
variant="outlined"
autoFocus
/>
</Grid>
<Grid item xs={12}>
<FormGroup>
<FormControlLabel
label="Disable TLS Verification"
control={
<Switch
checked={connectionData.disableTLS}
name="disable-tls-verification"
color="primary"
onChange={saveDisableTLS}
/>
}
/>
</FormGroup>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
label="Local Address"
error={errors.localAddress}
value={connectionData.localAddress}
onChange={(evt): void => saveLocal(evt.target.value)}
variant="outlined"
/>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
label="Alternate Pomerium Url"
error={errors.pomeriumUrl}
value={connectionData.pomeriumUrl}
onChange={(evt): void => savePomeriumUrl(evt.target.value)}
variant="outlined"
/>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
label="CA File Path"
error={errors.caFilePath}
value={connectionData.caFilePath}
onChange={(evt): void => saveCaFilePath(evt.target.value)}
variant="outlined"
/>
</Grid>
<Grid item xs={12}>
<TextField
fullWidth
label="CA File Text"
error={errors.caFileText}
value={connectionData.caFileText}
onChange={(evt): void => saveCaFileText(evt.target.value)}
variant="outlined"
multiline
rows={4}
/>
</Grid>
<Grid
container
spacing={4}
alignItems="center"
justifyContent="center"
className={classes.buttonWrapper}
</Grid>
</Grid>

<FieldWrapper
description="REQUIRED. The url to connect to. The FROM field in a pomerium route."
label="Destination Url"
>
<TextField
fullWidth
required
value={connectionData.destinationUrl}
onChange={(evt): void => saveDestination(evt.target.value)}
variant="outlined"
autoFocus
/>
</FieldWrapper>

<FieldWrapper
description="Skips TLS verification. No Cert Authority Needed."
label="Disable TLS Verification"
>
<Switch
checked={connectionData.disableTLS}
name="disable-tls-verification"
color="primary"
onChange={saveDisableTLS}
/>
</FieldWrapper>

<FieldWrapper
description="OPTIONAL. The port or local address you want to connect to. Ex. :8888 or 127.0.0.1:8888"
label="Local Address"
>
<TextField
fullWidth
error={errors.localAddress}
value={connectionData.localAddress}
onChange={(evt): void => saveLocal(evt.target.value)}
variant="outlined"
/>
</FieldWrapper>

<FieldWrapper
description={
"OPTIONAL. Pomerium Proxy Url. Useful if the Destination URL isn't publicly resolvable"
}
label="Alternate Pomerium Url"
>
<TextField
fullWidth
error={errors.pomeriumUrl}
value={connectionData.pomeriumUrl}
onChange={(evt): void => savePomeriumUrl(evt.target.value)}
variant="outlined"
/>
</FieldWrapper>

<FieldWrapper
label="CA File Path"
description="OPTIONAL. If Pomerium is using a CA in your system's trusted keychain you can provide the path to it here."
>
<TextField
fullWidth
error={errors.caFilePath}
value={connectionData.caFilePath}
onChange={(evt): void => saveCaFilePath(evt.target.value)}
variant="outlined"
/>
</FieldWrapper>

<FieldWrapper
label="CA File Text"
description="OPTIONAL. If Pomerium is using a CA in your system's trusted keychain you can copy/paste it here."
>
<TextField
fullWidth
error={errors.caFileText}
value={connectionData.caFileText}
onChange={(evt): void => saveCaFileText(evt.target.value)}
variant="outlined"
multiline
rows={4}
/>
</FieldWrapper>
<Grid
container
spacing={4}
alignItems="center"
justifyContent="center"
className={classes.buttonWrapper}
>
<Grid item xs={12} sm={4}>
<Button
fullWidth
type="button"
variant="contained"
onClick={() => disconnect(connectionData.channelID)}
disabled={!connected}
color="primary"
>
<Grid item xs={12} sm={4}>
<Button
fullWidth
type="button"
variant="contained"
onClick={() => disconnect(connectionData.channelID)}
disabled={!connected}
color="primary"
>
Disconnect
</Button>
</Grid>
<Grid item xs={12} sm={4}>
<Button
fullWidth
type="button"
variant="contained"
disabled={Object.values(errors).some(Boolean)}
color="primary"
onClick={connect}
>
Save/Connect
</Button>
</Grid>
<Grid item xs={12} sm={4}>
<Button
fullWidth
variant="contained"
color="primary"
type="button"
onClick={clear}
disabled={!connected}
>
New Connection
</Button>
</Grid>
</Grid>
Disconnect
</Button>
</Grid>
<Grid item xs={12} sm={4}>
<Button
fullWidth
type="button"
variant="contained"
disabled={Object.values(errors).some(Boolean)}
color="primary"
onClick={connect}
>
Save/Connect
</Button>
</Grid>
<Grid item xs={12} sm={4}>
<Button
fullWidth
variant="contained"
color="primary"
type="button"
onClick={clear}
disabled={!connected}
>
New Connection
</Button>
</Grid>
</Grid>
</form>
Expand All @@ -308,7 +321,7 @@ const ConnectForm: FC<Props> = () => {
</List>
</Grid>
)}
</>
</Container>
);
};

Expand Down
Loading