Skip to content

Commit a0f98b2

Browse files
author
Benjamin Perez
committed
Migrated Watch page to mds
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent bbf4027 commit a0f98b2

File tree

3 files changed

+82
-138
lines changed

3 files changed

+82
-138
lines changed

portal-ui/src/screens/Console/Watch/Watch.tsx

Lines changed: 79 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -13,83 +13,33 @@
1313
//
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16-
import React, { useEffect, useState } from "react";
16+
17+
import React, { useEffect, useState, Fragment } from "react";
18+
import { IMessageEvent, w3cwebsocket as W3CWebSocket } from "websocket";
19+
import { useSelector } from "react-redux";
1720
import {
18-
FormControl,
21+
Box,
22+
Button,
23+
DataTable,
1924
Grid,
20-
InputBase,
21-
MenuItem,
25+
InputBox,
26+
InputLabel,
27+
PageLayout,
2228
Select,
23-
TextField,
24-
} from "@mui/material";
25-
import { IMessageEvent, w3cwebsocket as W3CWebSocket } from "websocket";
26-
import { useSelector } from "react-redux";
27-
import { Theme } from "@mui/material/styles";
28-
import { Button, PageLayout } from "mds";
29-
import createStyles from "@mui/styles/createStyles";
30-
import withStyles from "@mui/styles/withStyles";
29+
} from "mds";
3130
import { AppState, useAppDispatch } from "../../../store";
3231
import { Bucket, BucketList, EventInfo } from "./types";
3332
import { niceBytes, timeFromDate } from "../../../common/utils";
3433
import { wsProtocol } from "../../../utils/wsUtils";
35-
import {
36-
actionsTray,
37-
containerForHeader,
38-
searchField,
39-
tableStyles,
40-
} from "../Common/FormComponents/common/styleLibrary";
4134
import { ErrorResponseHandler } from "../../../common/types";
42-
import TableWrapper from "../Common/TableWrapper/TableWrapper";
43-
import api from "../../../common/api";
44-
import makeStyles from "@mui/styles/makeStyles";
4535
import { watchMessageReceived, watchResetMessages } from "./watchSlice";
36+
import { setHelpName } from "../../../systemSlice";
37+
import api from "../../../common/api";
4638
import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper";
4739
import HelpMenu from "../HelpMenu";
48-
import { setHelpName } from "../../../systemSlice";
49-
50-
const useStyles = makeStyles((theme: Theme) =>
51-
createStyles({
52-
searchPrefix: {
53-
flexGrow: 1,
54-
marginLeft: 15,
55-
},
56-
watchTableHeight: {
57-
height: "calc(100vh - 270px)",
58-
},
59-
bucketField: {
60-
flexGrow: 2,
61-
minWidth: 200,
62-
},
63-
...tableStyles,
64-
...actionsTray,
65-
...searchField,
66-
...containerForHeader,
67-
}),
68-
);
69-
70-
const SelectStyled = withStyles((theme: Theme) =>
71-
createStyles({
72-
root: {
73-
lineHeight: "50px",
74-
"label + &": {
75-
marginTop: theme.spacing(3),
76-
},
77-
"& .MuiSelect-select:focus": {
78-
backgroundColor: "transparent",
79-
},
80-
},
81-
input: {
82-
height: 50,
83-
fontSize: 13,
84-
lineHeight: "50px",
85-
},
86-
}),
87-
)(InputBase);
8840

8941
const Watch = () => {
9042
const dispatch = useAppDispatch();
91-
const classes = useStyles();
92-
9343
const messages = useSelector((state: AppState) => state.watch.messages);
9444

9545
const [start, setStart] = useState(false);
@@ -177,89 +127,83 @@ const Watch = () => {
177127
// eslint-disable-next-line react-hooks/exhaustive-deps
178128
}, []);
179129

130+
const optionsArray = bucketNames.map((option) => ({
131+
label: option.label,
132+
value: option.value,
133+
}));
134+
180135
return (
181-
<React.Fragment>
136+
<Fragment>
182137
<PageHeaderWrapper label="Watch" actions={<HelpMenu />} />
183-
184138
<PageLayout>
185-
<Grid container spacing={1} item xs={12}>
186-
<Grid item xs={12} className={classes.actionsTray}>
187-
<FormControl variant="outlined" className={classes.bucketField}>
139+
<Grid container>
140+
<Grid
141+
item
142+
xs={12}
143+
sx={{
144+
display: "flex",
145+
gap: 10,
146+
marginBottom: 15,
147+
alignItems: "center",
148+
}}
149+
>
150+
<Box sx={{ flexGrow: 1 }}>
151+
<InputLabel>Bucket</InputLabel>
188152
<Select
189153
id="bucket-name"
190154
name="bucket-name"
191155
value={bucketName}
192-
onChange={(e) => {
193-
setBucketName(e.target.value as string);
156+
onChange={(value) => {
157+
setBucketName(value as string);
194158
}}
195-
className={classes.searchField}
196159
disabled={start}
197-
input={<SelectStyled />}
198-
>
199-
<MenuItem
200-
value={bucketName}
201-
key={`select-bucket-name-default`}
202-
disabled={true}
203-
>
204-
Select Bucket
205-
</MenuItem>
206-
{bucketNames.map((option) => (
207-
<MenuItem
208-
value={option.value}
209-
key={`select-bucket-name-${option.label}`}
210-
>
211-
{option.label}
212-
</MenuItem>
213-
))}
214-
</Select>
215-
</FormControl>
216-
<TextField
217-
className={`${classes.searchField} ${classes.searchPrefix}`}
218-
id="prefix-resource"
219-
label="Prefix"
220-
disabled={start}
221-
InputProps={{
222-
disableUnderline: true,
223-
}}
224-
onChange={(e) => {
225-
setPrefix(e.target.value);
226-
}}
227-
variant="standard"
228-
/>
229-
<TextField
230-
className={`${classes.searchField} ${classes.searchPrefix}`}
231-
id="suffix-resource"
232-
label="Suffix"
233-
disabled={start}
234-
InputProps={{
235-
disableUnderline: true,
236-
}}
237-
onChange={(e) => {
238-
setSuffix(e.target.value);
239-
}}
240-
variant="standard"
241-
/>
242-
{start ? (
243-
<Button
244-
id={"stop-watch"}
245-
type="submit"
246-
variant="callAction"
247-
onClick={() => setStart(false)}
248-
label={"Stop"}
160+
options={optionsArray}
161+
placeholder={"Select Bucket"}
249162
/>
250-
) : (
251-
<Button
252-
id={"start-watch"}
253-
type="submit"
254-
variant="callAction"
255-
onClick={() => setStart(true)}
256-
label={"Start"}
163+
</Box>
164+
<Box sx={{ flexGrow: 1 }}>
165+
<InputLabel>Prefix</InputLabel>
166+
<InputBox
167+
id="prefix-resource"
168+
disabled={start}
169+
onChange={(e) => {
170+
setPrefix(e.target.value);
171+
}}
172+
/>
173+
</Box>
174+
<Box sx={{ flexGrow: 1 }}>
175+
<InputLabel>Suffix</InputLabel>
176+
<InputBox
177+
id="suffix-resource"
178+
disabled={start}
179+
onChange={(e) => {
180+
setSuffix(e.target.value);
181+
}}
257182
/>
258-
)}
183+
</Box>
184+
<Box sx={{ alignSelf: "flex-end", paddingBottom: 4 }}>
185+
{start ? (
186+
<Button
187+
id={"stop-watch"}
188+
type="submit"
189+
variant="callAction"
190+
onClick={() => setStart(false)}
191+
label={"Stop"}
192+
/>
193+
) : (
194+
<Button
195+
id={"start-watch"}
196+
type="submit"
197+
variant="callAction"
198+
onClick={() => setStart(true)}
199+
label={"Start"}
200+
/>
201+
)}
202+
</Box>
259203
</Grid>
260204

261-
<Grid item xs={12} className={classes.tableBlock}>
262-
<TableWrapper
205+
<Grid item xs={12}>
206+
<DataTable
263207
columns={[
264208
{
265209
label: "Time",
@@ -279,12 +223,12 @@ const Watch = () => {
279223
customEmptyMessage={"No Changes at this time"}
280224
idField={"watch_table"}
281225
isLoading={false}
282-
customPaperHeight={classes.watchTableHeight}
226+
customPaperHeight={"calc(100vh - 270px)"}
283227
/>
284228
</Grid>
285229
</Grid>
286230
</PageLayout>
287-
</React.Fragment>
231+
</Fragment>
288232
);
289233
};
290234

portal-ui/tests/permissions-4/watch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ test
5353
// using the specific role we use in this module
5454
.useRole(roles.watch)
5555
.navigateTo("http://localhost:9090/tools/watch")
56-
.click(elements.bucketNameInput)
56+
.click(elements.watchBucketNameInput)
5757
.click(bucketDropdownOptionFor("watch"))
5858
.click(elements.startButton);
5959
})

portal-ui/tests/utils/elements.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const deleteAllVersions =
5959
//----------------------------------------------------
6060
// Inputs
6161
//----------------------------------------------------
62+
export const watchBucketNameInput = Selector("#bucket-name-select");
6263
export const bucketNameInput = Selector("#bucket-name");
6364
export const bucketsPrefixInput = Selector("#prefix");
6465
export const bucketsAccessInput = Selector("div.selectContainer");
@@ -85,8 +86,7 @@ export const groupUserCheckbox = Selector(".ReactVirtualized__Table__row input")
8586
// Dropdowns and options
8687
//----------------------------------------------------
8788
export const bucketDropdownOptionFor = (modifier) => {
88-
return Selector("li").withAttribute(
89-
"data-value",
89+
return Selector("#bucket-name-options-selector li").withText(
9090
`${constants.TEST_BUCKET_NAME}-${modifier}`,
9191
);
9292
};

0 commit comments

Comments
 (0)