Skip to content

Commit 61d3193

Browse files
authored
Migrated available mds components in Logs Page (#2998)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
1 parent 430ae66 commit 61d3193

File tree

2 files changed

+82
-154
lines changed

2 files changed

+82
-154
lines changed

portal-ui/src/screens/Console/Logs/ErrorLogs/ErrorLogs.tsx

Lines changed: 81 additions & 153 deletions
Original file line numberDiff line numberDiff line change
@@ -13,90 +13,34 @@
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+
1617
import React, { Fragment, useEffect, useState } from "react";
1718
import { IMessageEvent, w3cwebsocket as W3CWebSocket } from "websocket";
18-
import { Theme } from "@mui/material/styles";
19-
import { Button, PageLayout } from "mds";
20-
import createStyles from "@mui/styles/createStyles";
21-
import withStyles from "@mui/styles/withStyles";
19+
import { Box, Button, Grid, PageLayout, Select } from "mds";
2220
import { useSelector } from "react-redux";
23-
import { FormControl, Grid, InputBase, MenuItem, Select } from "@mui/material";
24-
25-
import { ErrorResponseHandler } from "../../../../../src/common/types";
26-
import api from "../../../../../src/common/api";
21+
import { ErrorResponseHandler } from "../../../../common/types";
2722
import { AppState, useAppDispatch } from "../../../../store";
28-
2923
import { wsProtocol } from "../../../../utils/wsUtils";
3024
import {
31-
actionsTray,
32-
containerForHeader,
33-
inlineCheckboxes,
34-
searchField,
35-
} from "../../Common/FormComponents/common/styleLibrary";
25+
logMessageReceived,
26+
logResetMessages,
27+
setLogsStarted,
28+
} from "../logsSlice";
29+
import { setHelpName } from "../../../../systemSlice";
3630
import SearchBox from "../../Common/SearchBox";
31+
import api from "../../../../../src/common/api";
3732
import Paper from "@mui/material/Paper";
3833
import Table from "@mui/material/Table";
3934
import TableBody from "@mui/material/TableBody";
4035
import TableContainer from "@mui/material/TableContainer";
4136
import LogLine from "./LogLine";
42-
import {
43-
logMessageReceived,
44-
logResetMessages,
45-
setLogsStarted,
46-
} from "../logsSlice";
47-
import makeStyles from "@mui/styles/makeStyles";
4837
import PageHeaderWrapper from "../../Common/PageHeaderWrapper/PageHeaderWrapper";
4938
import HelpMenu from "../../HelpMenu";
50-
import { setHelpName } from "../../../../systemSlice";
51-
52-
const useStyles = makeStyles((theme: Theme) =>
53-
createStyles({
54-
logList: {
55-
background: "#fff",
56-
minHeight: 400,
57-
height: "calc(100vh - 200px)",
58-
overflow: "auto",
59-
fontSize: 13,
60-
borderRadius: 4,
61-
},
62-
logerror_tab: {
63-
color: "#A52A2A",
64-
paddingLeft: 25,
65-
},
66-
nodeField: {
67-
width: "100%",
68-
},
69-
...actionsTray,
70-
actionsTray: {
71-
...actionsTray.actionsTray,
72-
marginBottom: 0,
73-
},
74-
...searchField,
75-
76-
...inlineCheckboxes,
77-
...containerForHeader,
78-
}),
79-
);
80-
81-
export const SelectStyled = withStyles((theme: Theme) =>
82-
createStyles({
83-
root: {
84-
lineHeight: "50px",
85-
"label + &": {
86-
marginTop: theme.spacing(3),
87-
},
88-
"& .MuiSelect-select:focus": {
89-
backgroundColor: "transparent",
90-
},
91-
},
92-
}),
93-
)(InputBase);
9439

9540
var c: any = null;
9641

9742
const ErrorLogs = () => {
9843
const dispatch = useAppDispatch();
99-
const classes = useStyles();
10044

10145
const messages = useSelector((state: AppState) => state.logs.logMessages);
10246
const logsStarted = useSelector((state: AppState) => state.logs.logsStarted);
@@ -223,9 +167,6 @@ const ErrorLogs = () => {
223167
.invoke("GET", `/api/v1/nodes`)
224168
.then((res: string[]) => {
225169
setNodes(res);
226-
// if (res.length > 0) {
227-
// setSelectedNode(res[0]);
228-
// }
229170
setLoadingNodes(false);
230171
})
231172
.catch((err: ErrorResponseHandler) => {
@@ -243,97 +184,64 @@ const ErrorLogs = () => {
243184
<PageHeaderWrapper label="Logs" actions={<HelpMenu />} />
244185

245186
<PageLayout>
246-
<Grid container spacing={1}>
247-
<Grid item xs={4}>
187+
<Grid container sx={{ gap: 15 }}>
188+
<Grid item xs={3}>
248189
{!loadingNodes ? (
249-
<FormControl variant="outlined" className={classes.nodeField}>
250-
<Select
251-
id="node"
252-
name="node"
253-
data-test-id="node-selector"
254-
value={selectedNode}
255-
onChange={(e) => {
256-
setSelectedNode(e.target.value as string);
257-
}}
258-
className={classes.searchField}
259-
disabled={loadingNodes || logsStarted}
260-
input={<SelectStyled />}
261-
placeholder={"Select Node"}
262-
>
263-
<MenuItem value={"all"} key={`select-node-all`}>
264-
All Nodes
265-
</MenuItem>
266-
{nodes.map((aNode) => (
267-
<MenuItem value={aNode} key={`select-node-name-${aNode}`}>
268-
{aNode}
269-
</MenuItem>
270-
))}
271-
</Select>
272-
</FormControl>
190+
<Select
191+
id="node-selector"
192+
name="node"
193+
data-test-id="node-selector"
194+
value={selectedNode}
195+
onChange={(value) => {
196+
setSelectedNode(value as string);
197+
}}
198+
disabled={loadingNodes || logsStarted}
199+
options={[
200+
{ label: "All Nodes", value: "all" },
201+
...nodes.map((aNode) => ({ label: aNode, value: aNode })),
202+
]}
203+
/>
273204
) : (
274205
<h3> Loading nodes</h3>
275206
)}
276207
</Grid>
277208

278209
<Grid item xs={3}>
279-
<FormControl variant="outlined" className={classes.nodeField}>
280-
<Select
281-
id="logType"
282-
name="logType"
283-
data-test-id="log-type"
284-
value={logType}
285-
onChange={(e) => {
286-
setLogType(e.target.value as string);
287-
}}
288-
className={classes.searchField}
289-
disabled={loadingNodes || logsStarted}
290-
input={<SelectStyled />}
291-
placeholder={"Select Log Type"}
292-
>
293-
<MenuItem value="all" key="all-log-types">
294-
All Log Types
295-
</MenuItem>
296-
<MenuItem value="minio" key="minio-log-type">
297-
MinIO
298-
</MenuItem>
299-
<MenuItem value="application" key="app-log-type">
300-
Application
301-
</MenuItem>
302-
</Select>
303-
</FormControl>
210+
<Select
211+
id="logType"
212+
name="logType"
213+
data-test-id="log-type"
214+
value={logType}
215+
onChange={(value) => {
216+
setLogType(value as string);
217+
}}
218+
disabled={loadingNodes || logsStarted}
219+
options={[
220+
{ value: "all", label: "All Log Types" },
221+
{
222+
value: "minio",
223+
label: "MinIO",
224+
},
225+
{ value: "application", label: "Application" },
226+
]}
227+
/>
304228
</Grid>
305229
<Grid item xs={3}>
306230
{userAgents.length > 1 && (
307-
<FormControl variant="outlined" className={classes.nodeField}>
308-
<Select
309-
id="userAgent"
310-
name="userAgent"
311-
data-test-id="user-agent"
312-
value={selectedUserAgent}
313-
onChange={(e) => {
314-
setSelectedUserAgent(e.target.value as string);
315-
}}
316-
className={classes.searchField}
317-
disabled={userAgents.length < 1 || logsStarted}
318-
input={<SelectStyled />}
319-
>
320-
<MenuItem
321-
value={selectedUserAgent}
322-
key={`select-user-agent-default`}
323-
disabled={true}
324-
>
325-
Select User Agent
326-
</MenuItem>
327-
{userAgents.map((anAgent) => (
328-
<MenuItem
329-
value={anAgent}
330-
key={`select-user-agent-${anAgent}`}
331-
>
332-
{anAgent}
333-
</MenuItem>
334-
))}
335-
</Select>
336-
</FormControl>
231+
<Select
232+
id="userAgent"
233+
name="userAgent"
234+
data-test-id="user-agent"
235+
value={selectedUserAgent}
236+
onChange={(value) => {
237+
setSelectedUserAgent(value as string);
238+
}}
239+
disabled={userAgents.length < 1 || logsStarted}
240+
options={userAgents.map((anAgent) => ({
241+
label: anAgent,
242+
value: anAgent,
243+
}))}
244+
/>
337245
)}
338246
</Grid>
339247
<Grid
@@ -361,7 +269,21 @@ const ErrorLogs = () => {
361269
/>
362270
)}
363271
</Grid>
364-
<Grid item xs={12} className={classes.actionsTray}>
272+
<Grid
273+
item
274+
xs={12}
275+
sx={{
276+
display: "flex" as const,
277+
justifyContent: "space-between" as const,
278+
alignItems: "center",
279+
marginBottom: "1rem",
280+
"& button": {
281+
flexGrow: 0,
282+
marginLeft: 8,
283+
marginBottom: 0,
284+
},
285+
}}
286+
>
365287
<SearchBox
366288
placeholder="Filter"
367289
onChange={(e) => {
@@ -371,10 +293,16 @@ const ErrorLogs = () => {
371293
/>
372294
</Grid>
373295
<Grid item xs={12}>
374-
<div
296+
<Box
375297
id="logs-container"
376-
className={classes.logList}
377298
data-test-id="logs-list-container"
299+
sx={{
300+
minHeight: 400,
301+
height: "calc(100vh - 200px)",
302+
overflow: "auto",
303+
fontSize: 13,
304+
borderRadius: 4,
305+
}}
378306
>
379307
<TableContainer component={Paper}>
380308
<Table aria-label="collapsible table">
@@ -390,7 +318,7 @@ const ErrorLogs = () => {
390318
</div>
391319
)}
392320
</TableContainer>
393-
</div>
321+
</Box>
394322
</Grid>
395323
</Grid>
396324
</PageLayout>

portal-ui/tests/utils/elements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export const settingsAuditKafkaTab = Selector("button").withAttribute(
165165
//----------------------------------------------------
166166
export const logWindow = Selector('[data-test-id="logs-list-container"]');
167167
//Node selector
168-
export const nodeSelector = Selector('[data-test-id="node-selector"]');
168+
export const nodeSelector = Selector("#node-selector-select");
169169
//----------------------------------------------------
170170
// User Details
171171
//----------------------------------------------------

0 commit comments

Comments
 (0)