Skip to content

Commit b5b827a

Browse files
authored
connect-form: break out components (#432)
* connect-form: break out components * fix import order * lint * more lint * more linting
1 parent 3e84d2d commit b5b827a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+702
-562
lines changed

package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
188188
"@testing-library/jest-dom": "^6.2.0",
189189
"@testing-library/react": "^14.1.2",
190+
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
190191
"@types/enzyme": "^3.10.18",
191192
"@types/enzyme-adapter-react-16": "^1.0.9",
192193
"@types/history": "5.0.0",
@@ -311,7 +312,14 @@
311312
}
312313
}
313314
],
314-
"singleQuote": true
315+
"singleQuote": true,
316+
"plugins": [
317+
"@trivago/prettier-plugin-sort-imports"
318+
],
319+
"importOrder": [
320+
"^[./]"
321+
],
322+
"importOrderSeparation": true
315323
},
316324
"renovate": {
317325
"extends": [

src/App.tsx

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
import {
2+
CssBaseline,
3+
ThemeProvider,
4+
StyledEngineProvider,
5+
} from '@mui/material';
6+
import StylesProvider from '@mui/styles/StylesProvider';
7+
import jssPreset from '@mui/styles/jssPreset';
18
import { ipcRenderer } from 'electron';
9+
import { create } from 'jss';
10+
import { SnackbarProvider } from 'notistack';
211
import React, { FC, useEffect } from 'react';
312
import {
413
HashRouter,
@@ -9,22 +18,13 @@ import {
918
Navigate,
1019
} from 'react-router-dom';
1120

12-
import {
13-
CssBaseline,
14-
ThemeProvider,
15-
StyledEngineProvider,
16-
} from '@mui/material';
17-
import jssPreset from '@mui/styles/jssPreset';
18-
import StylesProvider from '@mui/styles/StylesProvider';
19-
import { create } from 'jss';
20-
import { SnackbarProvider } from 'notistack';
21+
import SnackbarCloseButton from './renderer/components/SnackbarCloseButton';
2122
import ConnectForm from './renderer/pages/ConnectForm';
22-
import ManageConnections from './renderer/pages/ManageConnections';
2323
import ConnectionView from './renderer/pages/ConnectionView';
24-
import SnackbarCloseButton from './renderer/components/SnackbarCloseButton';
24+
import Layout from './renderer/pages/Layout';
25+
import ManageConnections from './renderer/pages/ManageConnections';
2526
import { THEMES } from './shared/constants';
2627
import createCustomTheme, { ThemeConfig } from './shared/theme';
27-
import Layout from './renderer/pages/Layout';
2828

2929
const RouteListener: FC = () => {
3030
const navigate = useNavigate();

src/cli.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { ChildProcessWithoutNullStreams, spawn } from 'child_process';
2-
import * as Sentry from '@sentry/electron/main';
31
import { ChannelCredentials } from '@grpc/grpc-js';
2+
import * as Sentry from '@sentry/electron/main';
3+
import { ChildProcessWithoutNullStreams, spawn } from 'child_process';
44
import { createServer } from 'net';
55

66
import { pomeriumCli } from './main/binaries';

src/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { createRoot } from 'react-dom/client';
3+
34
import App from './App';
45
import './App.global.css';
56

src/main.dev.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint global-require: off, no-console: off */
2-
32
/**
43
* This module executes inside of electron's main process. You can start
54
* electron renderer process from here and communicate with the other processes
@@ -8,22 +7,24 @@
87
* When running `yarn build` or `yarn build-main`, this file is compiled to
98
* `./src/main.prod.js` using webpack. This gives us some performance wins.
109
*/
10+
import * as grpc from '@grpc/grpc-js';
11+
import * as Sentry from '@sentry/electron/main';
1112
import {
1213
app,
1314
BrowserWindow,
1415
dialog,
1516
ipcMain,
1617
MessageBoxOptions,
1718
} from 'electron';
18-
import * as grpc from '@grpc/grpc-js';
19-
import * as Sentry from '@sentry/electron/main';
19+
import contextMenu from 'electron-context-menu';
2020
import log from 'electron-log';
2121
import { autoUpdater } from 'electron-updater';
22+
import fs from 'fs';
2223
import { menubar } from 'menubar';
23-
import * as url from 'url';
2424
import path from 'path';
25-
import fs from 'fs';
26-
import contextMenu from 'electron-context-menu';
25+
import * as url from 'url';
26+
27+
import { start } from './cli';
2728
import createWindow from './renderer/window';
2829
import {
2930
isDev,
@@ -47,7 +48,6 @@ import {
4748
LISTENER_LOG,
4849
GET_ALL_RECORDS,
4950
} from './shared/constants';
50-
import Helper from './trayMenu/helper';
5151
import {
5252
ConnectionStatusUpdate,
5353
ExportRequest,
@@ -58,7 +58,7 @@ import {
5858
Selector,
5959
StatusUpdatesRequest,
6060
} from './shared/pb/api';
61-
import { start } from './cli';
61+
import Helper from './trayMenu/helper';
6262

6363
const SentryDSN =
6464
'https://[email protected]/6146413';
@@ -279,7 +279,7 @@ async function init(): Promise<void> {
279279
const bytes = fs.readFileSync(response.filePaths[0], null);
280280
configClient.import(
281281
{
282-
data: bytes,
282+
data: bytes as unknown as Uint8Array,
283283
} as ImportRequest,
284284
(err, res) => {
285285
evt?.sender?.send(IMPORT, { err, res });
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import {
2+
FormControlLabel,
3+
FormHelperText,
4+
Grid,
5+
Switch,
6+
Typography,
7+
} from '@mui/material';
8+
import React, { FC } from 'react';
9+
10+
import { Connection } from '../../shared/pb/api';
11+
import ClientCertSelection from './ClientCertSelection';
12+
import TextField from './TextField';
13+
14+
export type AdvancedConnectionSettingsProps = {
15+
connection: Connection;
16+
onChangeConnection: (connection: Connection) => void;
17+
};
18+
const AdvancedConnectionSettings: FC<AdvancedConnectionSettingsProps> = ({
19+
connection,
20+
onChangeConnection,
21+
}) => {
22+
const onToggleDisableTlsVerification = () => {
23+
onChangeConnection({
24+
...connection,
25+
disableTlsVerification: !connection?.disableTlsVerification,
26+
});
27+
};
28+
const onChangeUrl = (evt: React.ChangeEvent<HTMLInputElement>) => {
29+
onChangeConnection({
30+
...connection,
31+
pomeriumUrl: evt.target.value.trim() || undefined,
32+
});
33+
};
34+
35+
return (
36+
<Grid container spacing={2}>
37+
<Grid item xs={12}>
38+
<TextField
39+
fullWidth
40+
required
41+
label="Pomerium URL"
42+
value={connection?.pomeriumUrl || ''}
43+
onChange={onChangeUrl}
44+
variant="outlined"
45+
autoFocus
46+
helperText="URL of a Bastion host to use for the initial TLS connection"
47+
/>
48+
</Grid>
49+
<Grid item xs={12}>
50+
<FormControlLabel
51+
control={
52+
<Switch
53+
checked={connection?.disableTlsVerification}
54+
name="disable-tls-verification"
55+
color="primary"
56+
onChange={onToggleDisableTlsVerification}
57+
/>
58+
}
59+
label="Disable TLS Verification"
60+
/>
61+
<FormHelperText sx={{ pl: 2 }}>
62+
Skips TLS verification. No Cert Authority Needed.
63+
</FormHelperText>
64+
</Grid>
65+
<Grid item xs={12}>
66+
<Typography sx={{ fontWeight: 500, pt: 1 }}>
67+
Client certificates
68+
</Typography>
69+
</Grid>
70+
<ClientCertSelection
71+
connection={connection}
72+
onChangeConnection={onChangeConnection}
73+
/>
74+
</Grid>
75+
);
76+
};
77+
export default AdvancedConnectionSettings;

src/renderer/components/BeforeBackActionDialog.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import DialogContent from '@mui/material/DialogContent';
55
import DialogTitle from '@mui/material/DialogTitle';
66
import Divider from '@mui/material/Divider';
77
import Typography from '@mui/material/Typography';
8-
import React, { ReactElement } from 'react';
98
import { ipcRenderer } from 'electron';
9+
import React, { ReactElement } from 'react';
10+
1011
import { VIEW_CONNECTION_LIST } from '../../shared/constants';
1112

1213
interface Props {

src/renderer/components/CertDetails.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import Button from '@mui/material/Button';
12
import Container from '@mui/material/Container';
23
import Dialog from '@mui/material/Dialog';
4+
import DialogActions from '@mui/material/DialogActions';
35
import DialogContent from '@mui/material/DialogContent';
46
import DialogTitle from '@mui/material/DialogTitle';
57
import Divider from '@mui/material/Divider';
@@ -10,8 +12,6 @@ import Typography from '@mui/material/Typography';
1012
import moment from 'moment';
1113
import React, { ReactElement } from 'react';
1214

13-
import DialogActions from '@mui/material/DialogActions';
14-
import Button from '@mui/material/Button';
1515
import { Certificate } from '../../shared/pb/api';
1616

1717
interface DetailViewDialogProps {

src/renderer/components/CertFilter.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import MenuItem from '@mui/material/MenuItem';
66
import Select from '@mui/material/Select';
77
import Typography from '@mui/material/Typography';
88
import React, { useEffect, useId, useRef } from 'react';
9+
910
import TextField from './TextField';
1011

1112
interface Props {
@@ -30,7 +31,7 @@ const CertFilter: React.FC<Props> = ({ label, data, onChange, disabled }) => {
3031
onChange(attribute + '=' + newValue);
3132
};
3233

33-
const valueInputRef = useRef(null);
34+
const valueInputRef = useRef<HTMLInputElement>(null);
3435
useEffect(() => {
3536
valueInputRef.current?.focus();
3637
}, [attribute]);

0 commit comments

Comments
 (0)