Skip to content
Snippets Groups Projects
Commit aa835487 authored by cjenkscybercom's avatar cjenkscybercom
Browse files

CE-2200: remove tabs from log list view

parent b6495401
No related branches found
No related tags found
2 merge requests!407CE-2141: 3.0.0,!405Qa release tasks
import React, { useContext, useState, useCallback, useMemo } from "react"; import React, { useContext, useCallback, useMemo } from "react";
import { Grid, Container, TextField, Autocomplete } from "@mui/material"; import { Grid, TextField, Autocomplete } from "@mui/material";
import Tabs from "@mui/material/Tabs";
import Tab from "@mui/material/Tab";
import { RootPaper, useAPIMethod } from "@ess-ics/ce-ui-common"; import { RootPaper, useAPIMethod } from "@ess-ics/ce-ui-common";
import { initRequestParams } from "../../components/common/Helper"; import { initRequestParams } from "../../components/common/Helper";
import { useEffect } from "react"; import { useEffect } from "react";
...@@ -15,6 +13,13 @@ import { usePagination } from "../../hooks/pagination"; ...@@ -15,6 +13,13 @@ import { usePagination } from "../../hooks/pagination";
import { JobTable } from "../../components/Job/JobTable"; import { JobTable } from "../../components/Job/JobTable";
import { apiContext } from "../../api/DeployApi"; import { apiContext } from "../../api/DeployApi";
const jobTypeOptions = [
{ label: "Show all" },
{ label: "Only deployments", filter: "DEPLOYMENT" },
{ label: "Only commands", filter: "COMMAND" }
];
const defaultJobTypeOption = jobTypeOptions[0];
export function JobListView() { export function JobListView() {
const client = useContext(apiContext); const client = useContext(apiContext);
...@@ -31,7 +36,6 @@ export function JobListView() { ...@@ -31,7 +36,6 @@ export function JobListView() {
const [urlState, setUrlState] = useUrlState( const [urlState, setUrlState] = useUrlState(
{ {
tab: "0",
rows: "20", rows: "20",
page: "0", page: "0",
query: "", query: "",
...@@ -40,32 +44,6 @@ export function JobListView() { ...@@ -40,32 +44,6 @@ export function JobListView() {
{ navigateMode: "replace" } { navigateMode: "replace" }
); );
const [deploymentStatus, setDeploymentStatus] = useState(null);
const handleTabChange = (event, tab) => {
setUrlState((s) =>
serialize(s.tab) === serialize(tab)
? { tab: serialize(tab) }
: { tab: serialize(tab), page: "0" }
);
changeTab(tab);
};
const changeTab = (tab) => {
if (tab === 0) {
setDeploymentStatus(null);
} else if (tab === 1) {
setDeploymentStatus("ONGOING");
} else if (tab === 2) {
setDeploymentStatus("FINISHED");
}
};
useEffect(() => {
urlState.tab && changeTab(deserialize(urlState.tab));
}, [urlState]);
const urlPagination = useMemo(() => { const urlPagination = useMemo(() => {
return { return {
rows: deserialize(urlState.rows), rows: deserialize(urlState.rows),
...@@ -114,10 +92,6 @@ export function JobListView() { ...@@ -114,10 +92,6 @@ export function JobListView() {
deserialize(urlState.query) deserialize(urlState.query)
); );
if (deploymentStatus) {
requestParams.status = deploymentStatus;
}
if (urlState.job_type) { if (urlState.job_type) {
requestParams.type = deserialize(urlState.job_type); requestParams.type = deserialize(urlState.job_type);
} }
...@@ -127,14 +101,7 @@ export function JobListView() { ...@@ -127,14 +101,7 @@ export function JobListView() {
return () => { return () => {
abort(); abort();
}; };
}, [ }, [getOperations, urlPagination, urlState.query, urlState.job_type, abort]);
getOperations,
urlPagination,
urlState.query,
urlState.job_type,
deploymentStatus,
abort
]);
const setSearch = useCallback( const setSearch = useCallback(
(query) => { (query) => {
...@@ -165,12 +132,6 @@ export function JobListView() { ...@@ -165,12 +132,6 @@ export function JobListView() {
</SearchBar> </SearchBar>
); );
const jobTypeOptions = [
{ label: "Show all" },
{ label: "Only deployments", filter: "DEPLOYMENT" },
{ label: "Only commands", filter: "COMMAND" }
];
return ( return (
<RootPaper> <RootPaper>
<Grid <Grid
...@@ -180,21 +141,10 @@ export function JobListView() { ...@@ -180,21 +141,10 @@ export function JobListView() {
<Grid <Grid
container container
spacing={1} spacing={1}
component={Container} justifyContent="flex-end"
justifyContent="space-between"
alignItems="center" alignItems="center"
style={{ display: "flex" }} style={{ display: "flex" }}
> >
<Grid item>
<Tabs
value={deserialize(urlState.tab)}
onChange={handleTabChange}
>
<Tab label="All" />
<Tab label="Only Ongoing" />
<Tab label="Only Completed" />
</Tabs>
</Grid>
<Grid <Grid
item item
xs={3} xs={3}
...@@ -206,16 +156,13 @@ export function JobListView() { ...@@ -206,16 +156,13 @@ export function JobListView() {
urlState.job_type urlState.job_type
? jobTypeOptions.find( ? jobTypeOptions.find(
(o) => o.filter === urlState.job_type (o) => o.filter === urlState.job_type
) || { ) || defaultJobTypeOption
label: "Show all" : defaultJobTypeOption
}
: { label: "Show all" }
} }
getOptionLabel={(option) => option.label} getOptionLabel={(option) => option.label}
isOptionEqualToValue={(option, value) => isOptionEqualToValue={(option, value) =>
option.label === value.label option.label === value.label
} }
style={{ width: "100%" }}
renderInput={(params) => ( renderInput={(params) => (
<TextField <TextField
{...params} {...params}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment