FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
LicensesDialog.tsx
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2// Copyright (c) 2026-present FERS Contributors (see AUTHORS.md).
3
4import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
5import {
6 Accordion,
7 AccordionDetails,
8 AccordionSummary,
9 Box,
10 Button,
11 Dialog,
12 DialogActions,
13 DialogContent,
14 DialogTitle,
15 Tab,
16 Tabs,
17 Typography,
18} from '@mui/material';
19import { useState } from 'react';
20import catch2License from '../../../../THIRD_PARTY_LICENSES/catch2-LICENSE.txt?raw';
21import geoLibLicense from '../../../../THIRD_PARTY_LICENSES/GeographicLib-LICENSE.txt?raw';
22import highFiveLicense from '../../../../THIRD_PARTY_LICENSES/HighFive-LICENSE.txt?raw';
23import jsLicenses from '../../../../THIRD_PARTY_LICENSES/js-licenses.txt?raw';
24import hdf5License from '../../../../THIRD_PARTY_LICENSES/libhdf5-LICENSE.txt?raw';
25import libxml2License from '../../../../THIRD_PARTY_LICENSES/libxml2-LICENSE.txt?raw';
26import nlohmannLicense from '../../../../THIRD_PARTY_LICENSES/nlohmann-json-LICENSE.txt?raw';
27import rustLicenses from '../../../../THIRD_PARTY_LICENSES/rust-licenses.html?raw';
28
29interface LicensesDialogProps {
30 open: boolean;
31 onClose: () => void;
32}
33
34const cppLibraries = [
35 { name: 'Catch2', content: catch2License },
36 { name: 'GeographicLib', content: geoLibLicense },
37 { name: 'HDF5', content: hdf5License },
38 { name: 'HighFive', content: highFiveLicense },
39 { name: 'libxml2', content: libxml2License },
40 { name: 'nlohmann/json', content: nlohmannLicense },
41];
42
43const licensePreStyle: React.CSSProperties = {
44 margin: 0,
45 whiteSpace: 'pre-wrap',
46 wordBreak: 'break-word',
47 fontSize: '0.75rem',
48};
49
50export default function LicensesDialog({ open, onClose }: LicensesDialogProps) {
51 const [tab, setTab] = useState(0);
52
53 return (
54 <Dialog
55 open={open}
56 onClose={onClose}
57 maxWidth="md"
58 fullWidth
59 PaperProps={{ sx: { height: '80vh' } }}
60 >
61 <DialogTitle>Third-Party Licenses</DialogTitle>
62 <DialogContent
63 sx={{
64 display: 'flex',
65 flexDirection: 'column',
66 p: 0,
67 overflow: 'hidden',
68 }}
69 >
70 <Tabs
71 value={tab}
72 onChange={(_e, v: number) => setTab(v)}
73 sx={{ borderBottom: 1, borderColor: 'divider', px: 2 }}
74 >
75 <Tab label="JavaScript" />
76 <Tab label="Rust" />
77 <Tab label="C++" />
78 </Tabs>
79 {tab === 0 && (
80 <Box sx={{ flex: 1, overflow: 'auto', p: 1 }}>
81 <pre style={licensePreStyle}>{jsLicenses}</pre>
82 </Box>
83 )}
84 {tab === 1 && (
85 <Box sx={{ flex: 1, overflow: 'hidden' }}>
86 <iframe
87 srcDoc={rustLicenses}
88 style={{
89 width: '100%',
90 height: '100%',
91 border: 'none',
92 }}
93 sandbox="allow-same-origin"
94 title="Rust third-party licenses"
95 />
96 </Box>
97 )}
98 {tab === 2 && (
99 <Box sx={{ flex: 1, overflow: 'auto' }}>
100 {cppLibraries.map(({ name, content }) => (
101 <Accordion
102 key={name}
103 disableGutters
104 elevation={0}
105 square
106 >
107 <AccordionSummary
108 expandIcon={<ExpandMoreIcon />}
109 >
110 <Typography variant="body2">
111 {name}
112 </Typography>
113 </AccordionSummary>
114 <AccordionDetails>
115 <pre style={licensePreStyle}>{content}</pre>
116 </AccordionDetails>
117 </Accordion>
118 ))}
119 </Box>
120 )}
121 </DialogContent>
122 <DialogActions>
123 <Button onClick={onClose}>Close</Button>
124 </DialogActions>
125 </Dialog>
126 );
127}