|
1 | | -import { Box, Button, Grid, IconButton, Menu, Tooltip } from "@mui/material"; |
| 1 | +import { Box } from "@mui/material"; |
2 | 2 | import { DataGrid } from "@mui/x-data-grid"; |
3 | 3 | import { darken, lighten } from "@mui/material/styles"; |
4 | 4 | import { TransitionTableProps } from "./props/TransitionTableProps"; |
5 | | -import { RowModel } from "../models"; |
6 | 5 | import { useState } from "react"; |
7 | 6 | import { MaxNumberOfStates } from "../consts/MaxNumberOfStates"; |
8 | | -import MoreIcon from "@mui/icons-material/MoreVert"; |
9 | | -import { Download } from "./Download"; |
10 | | -import { Upload } from "./Upload"; |
11 | 7 |
|
12 | 8 | const getBackgroundColor = (color: string, mode: string) => |
13 | 9 | mode === "dark" ? darken(color, 0) : lighten(color, 0); |
14 | 10 |
|
15 | 11 | const TransitionTable = (props: TransitionTableProps) => { |
16 | 12 | console.log("re rendering TransitionTable: props", props); |
17 | 13 |
|
18 | | - const [anchorElUser, setAnchorElUser] = useState<null | HTMLElement>(null); |
19 | | - |
20 | | - const handleOpenUserMenu = (event: React.MouseEvent<HTMLElement>) => { |
21 | | - setAnchorElUser(event.currentTarget); |
22 | | - }; |
23 | | - |
24 | | - const handleCloseToolsMenu = () => { |
25 | | - setAnchorElUser(null); |
26 | | - }; |
27 | | - |
28 | 14 | return ( |
29 | | - <> |
30 | | - {/* <Grid container alignItems={"center"}> |
31 | | - <Grid item xs={11}> |
32 | | - <Button |
33 | | - size="small" |
34 | | - onClick={() => |
35 | | - props.handleAddRow( |
36 | | - new RowModel( |
37 | | - props.rowId, |
38 | | - `q${props.rowId}`, |
39 | | - "", |
40 | | - "", |
41 | | - "", |
42 | | - false, |
43 | | - false |
44 | | - ) |
45 | | - ) |
46 | | - } |
47 | | - > |
48 | | - Add a row |
49 | | - </Button> |
50 | | - </Grid> |
51 | | -
|
52 | | - <Grid item xs={1}> |
53 | | - <Box> |
54 | | - <Tooltip title="Tools"> |
55 | | - <IconButton |
56 | | - size="large" |
57 | | - aria-label="tools" |
58 | | - aria-controls="menu-appbar-tools" |
59 | | - aria-haspopup="true" |
60 | | - onClick={handleOpenUserMenu} |
61 | | - color="inherit" |
62 | | - > |
63 | | - <MoreIcon /> |
64 | | - </IconButton> |
65 | | - </Tooltip> |
66 | | - <Menu |
67 | | - id="menu-appbar-tools" |
68 | | - anchorEl={anchorElUser} |
69 | | - anchorOrigin={{ |
70 | | - vertical: "bottom", |
71 | | - horizontal: "left", |
72 | | - }} |
73 | | - keepMounted |
74 | | - transformOrigin={{ |
75 | | - vertical: "top", |
76 | | - horizontal: "left", |
77 | | - }} |
78 | | - open={Boolean(anchorElUser)} |
79 | | - onClose={handleCloseToolsMenu} |
80 | | - > |
81 | | - <Download handleCloseToolsMenu={handleCloseToolsMenu} /> |
82 | | - <Upload handleCloseToolsMenu={handleCloseToolsMenu} /> |
83 | | - </Menu> |
84 | | - </Box> |
85 | | - </Grid> |
86 | | - </Grid> */} |
87 | | - |
88 | | - <Box |
89 | | - sx={{ |
90 | | - "& .super-app-theme--Both": { |
91 | | - bgcolor: (theme) => |
92 | | - `${getBackgroundColor( |
93 | | - theme.palette.info.light, |
94 | | - theme.palette.mode |
95 | | - )} !important`, |
96 | | - }, |
97 | | - |
98 | | - "& .super-app-theme--Initial": { |
99 | | - bgcolor: (theme) => |
100 | | - `${getBackgroundColor( |
101 | | - theme.palette.warning.light, |
102 | | - theme.palette.mode |
103 | | - )} !important`, |
104 | | - }, |
105 | | - |
106 | | - "& .super-app-theme--Final": { |
107 | | - bgcolor: (theme) => |
108 | | - `${getBackgroundColor( |
109 | | - theme.palette.success.light, |
110 | | - theme.palette.mode |
111 | | - )} !important`, |
112 | | - }, |
113 | | - }} |
114 | | - > |
115 | | - <DataGrid |
116 | | - rows={props.rows} |
117 | | - columns={props.columns} |
118 | | - autoHeight |
119 | | - hideFooter |
120 | | - experimentalFeatures={{ newEditingApi: true }} |
121 | | - pageSize={MaxNumberOfStates} |
122 | | - getRowClassName={(params) => |
123 | | - `super-app-theme--${ |
124 | | - params?.row?.isInitial && params?.row?.isFinal |
125 | | - ? "Both" |
126 | | - : params?.row?.isInitial |
127 | | - ? "Initial" |
128 | | - : params?.row?.isFinal && "Final" |
129 | | - }` |
130 | | - } |
131 | | - ></DataGrid> |
132 | | - </Box> |
133 | | - </> |
| 15 | + <Box |
| 16 | + sx={{ |
| 17 | + "& .super-app-theme--Both": { |
| 18 | + bgcolor: (theme) => |
| 19 | + `${getBackgroundColor( |
| 20 | + theme.palette.info.light, |
| 21 | + theme.palette.mode |
| 22 | + )} !important`, |
| 23 | + }, |
| 24 | + |
| 25 | + "& .super-app-theme--Initial": { |
| 26 | + bgcolor: (theme) => |
| 27 | + `${getBackgroundColor( |
| 28 | + theme.palette.warning.light, |
| 29 | + theme.palette.mode |
| 30 | + )} !important`, |
| 31 | + }, |
| 32 | + |
| 33 | + "& .super-app-theme--Final": { |
| 34 | + bgcolor: (theme) => |
| 35 | + `${getBackgroundColor( |
| 36 | + theme.palette.success.light, |
| 37 | + theme.palette.mode |
| 38 | + )} !important`, |
| 39 | + }, |
| 40 | + }} |
| 41 | + > |
| 42 | + <DataGrid |
| 43 | + rows={props.rows} |
| 44 | + columns={props.columns} |
| 45 | + autoHeight |
| 46 | + hideFooter |
| 47 | + experimentalFeatures={{ newEditingApi: true }} |
| 48 | + pageSize={MaxNumberOfStates} |
| 49 | + getRowClassName={(params) => |
| 50 | + `super-app-theme--${ |
| 51 | + params?.row?.isInitial && params?.row?.isFinal |
| 52 | + ? "Both" |
| 53 | + : params?.row?.isInitial |
| 54 | + ? "Initial" |
| 55 | + : params?.row?.isFinal && "Final" |
| 56 | + }` |
| 57 | + } |
| 58 | + ></DataGrid> |
| 59 | + </Box> |
134 | 60 | ); |
135 | 61 | }; |
136 | 62 | export default TransitionTable; |
0 commit comments