diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap index 8bea8d3..7da957e 100644 --- a/src/components/App/__snapshots__/App.test.js.snap +++ b/src/components/App/__snapshots__/App.test.js.snap @@ -3515,7 +3515,7 @@ exports[`App Route /issues authenticated 1`] = ` @@ -3529,11 +3529,11 @@ exports[`App Route /issues authenticated 1`] = ` - sorted ascending + sorted descending VIN - - sorted ascending - Updated + + sorted descending + @@ -5552,11 +5552,11 @@ exports[`App Route /package-status authenticated 1`] = ` - sorted ascending + sorted descending @@ -6758,11 +6758,11 @@ exports[`App Route /packages authenticated 1`] = ` - sorted ascending + sorted descending VIN - - sorted ascending - Updated + + sorted descending + VIN - - sorted ascending - Updated + + sorted descending + VIN - - sorted ascending - Updated + + sorted descending + {manifest.name}) : `This manifest`} is incomplete, and cannot be deployed without all required fields filled out. + +
+ handleManifestField("sums", e.target.value)} + error={!satisfiesRequiredFields[0]} + fullWidth + /> + handleManifestField("max_attempts", value)} + error={!satisfiesRequiredFields[1]} + /> + handleManifestField("update_duration", value)} + error={!satisfiesRequiredFields[2]} + /> + handleManifestField("release_notes", value)} + fullWidth + /> + + + + + ); +} + +function kebab(str) { + return str.replaceAll(" ", "-").toLowerCase(); +} + +function ConfigureInput({ + name, + description, + value = 0, + setValue = () => { }, + error, +}) { + const inputId = `deploy-configure-${kebab(name)}`; + const descriptionId = `deploy-configure-${kebab(name)}-explain`; + + const handleChange = (event) => { + setValue(event.target.value); + } + return ( + + + {name} + + {description} + + + ); +} diff --git a/src/components/Manifest/Deploy/index.jsx b/src/components/Manifest/Deploy/index.jsx index 7bb7abd..ded0190 100644 --- a/src/components/Manifest/Deploy/index.jsx +++ b/src/components/Manifest/Deploy/index.jsx @@ -1,13 +1,11 @@ -import { Button, Checkbox, FormControlLabel, Grid, MenuItem, Switch, Typography } from "@material-ui/core"; -import clsx from "clsx"; -import SendIcon from "@material-ui/icons/Send"; +import { Checkbox, FormControlLabel, Grid, MenuItem, Switch, Typography, Box } from "@material-ui/core"; import React, { useEffect, useState } from "react"; import { Redirect, useParams } from "react-router"; import { logger } from "../../../services/monitoring"; import { LocalDateTimeString } from "../../../utils/dates"; import { Permissions } from "../../../utils/roles"; -import { CarUpdatesProvider, SELECT_VERSION, useCarUpdatesContext } from "../../Contexts/CarUpdatesContext"; +import { CarUpdatesProvider, useCarUpdatesContext } from "../../Contexts/CarUpdatesContext"; import { FleetProvider } from "../../Contexts/FleetContext"; import { ManifestsProvider, useManifestsContext } from "../../Contexts/ManifestsContext"; import { useStatusContext } from "../../Contexts/StatusContext"; @@ -15,11 +13,11 @@ import { useUserContext } from "../../Contexts/UserContext"; import { VehicleProvider } from "../../Contexts/VehicleContext"; import CarSelectionTable from "../../Controls/CarSelectionTable"; import OptionsDropdown from "../../Controls/OptionsDropdown"; -import { DropDownList } from "../../Controls/DropDownList"; import FleetSelectionTable from "../../Controls/FleetSelectionTable"; import { RoleWrap } from "../../Controls/RoleWrap"; import SearchField from "../../Controls/SearchField"; import useStyles from "../../useStyles"; +import Configure from "./Configure"; const CAR_UPDATE = false; const FLEET_UPDATE = true; @@ -28,7 +26,7 @@ const MainForm = () => { const [updateType, setUpdateType] = useState(CAR_UPDATE); const { manifest_id } = useParams(); const { getManifests, manifests, busy } = useManifestsContext(); - const { deployCarUpdates, deployFleetUpdates, getSUMSVersions, versions, updateSUMSVersion } = useCarUpdatesContext(); + const { deployCarUpdates, deployFleetUpdates, getSUMSVersions, versions } = useCarUpdatesContext(); const { groups, providers, @@ -37,15 +35,11 @@ const MainForm = () => { }, } = useUserContext(); const { setMessage, setTitle, setSitePath } = useStatusContext(); - const [manifestName, setManifestName] = useState(""); - const [version, setVersion] = useState(""); - const [sumsVersion, setSUMSersion] = useState(""); - const [createDate, setCreateDate] = useState(""); + const [manifest, setManifest] = useState({}); const [selected, setSelected] = useState([]); const [search, setSearch] = useState(""); const [online, setOnline] = useState(false); const [onlineHMI, setOnlineHMI] = useState(false); - const [softwareVersion, setSoftwareVersion] = useState(SELECT_VERSION); const [redirect, setRedirect] = useState(""); const classes = useStyles(); @@ -86,15 +80,11 @@ const MainForm = () => { } }; - const onSubmit = async (event) => { + const onSubmit = async () => { try { - event.preventDefault(); const data = { manifest_id: parseInt(manifest_id), } - if (sumsVersion.length === 0) { - await updateSUMSVersion(manifest_id, softwareVersion, token); - } if (updateType === CAR_UPDATE) { data.vins = selected; @@ -104,7 +94,7 @@ const MainForm = () => { await deployFleetUpdates(data, token); } setMessage( - `Deployed ${manifestName} ${version} to ${selected.length} cars` + `Deployed ${manifest.name} ${manifest.version} to ${selected.length} cars` ); setRedirect(`/package-status/${manifest_id}`); } catch (e) { @@ -113,65 +103,77 @@ const MainForm = () => { } }; - const getData = async () => { - try { - await getManifests({ id: parseInt(manifest_id) }, token); - await getSUMSVersions(token); - } catch (e) { - setMessage(e.message); - logger.warn(e.stack); + useEffect(() => { + const control = new AbortController(); + + const fetchData = async () => { + try { + await getManifests({ + id: parseInt(manifest_id), + signal: control.signal, + }, token); + await getSUMSVersions(token); + } catch (e) { + setMessage(e.message); + logger.warn(e.stack); + } + } + fetchData(); + return () => { + control.abort(); } - }; - - const changeVersion = (e) => { - setSoftwareVersion(e.target.value); - } - - useEffect(() => { - getData(); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [token]); + }, [manifest_id, token]); useEffect(() => { - const title = `Deploy ${manifestName} ${version}`; - setTitle(title); - setSitePath([ - { - label: "Deployments", - link: "/packages", - }, - { - label: title, - }, - ]); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [manifestName, version]); - - useEffect(() => { - if (!manifests || manifests.length === 0) return; - const data = manifests[0]; - - setManifestName(data.name); - setVersion(data.version); - setSUMSersion(data.sums || ""); - setCreateDate(LocalDateTimeString(data.created)); + if (manifests && manifests.length !== 0) { + setManifest(manifests[0]); + } }, [manifests]); + useEffect(() => { + if (manifest) { + const title = `Deploy ${manifest.name} ${manifest.version}`; + setTitle(title); + setSitePath([ + { + label: "Deployments", + link: "/packages", + }, + { + label: title, + }, + ]); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [manifest]); + if (redirect.length > 0) { return ; } + if (!manifest && !manifest?.name) { + return ( +
Loading...
+ ); + } + return (
-
- Created {createDate}. - - + + Created {LocalDateTimeString(manifest.created)}. + +
{`${selected.length} Selected`}
- + + { />} label="Car(default) or Fleet" /> - - + + + + + + + } + label="Only online" + /> + + + + } + label="Only online HMI" + /> + + + - - - - } - label="Only online" - /> - - - - } - label="Only online HMI" - /> - - - - - {sumsVersion.length === 0 && - - } - + + + {updateType === CAR_UPDATE ? diff --git a/src/components/Manifest/List/index.jsx b/src/components/Manifest/List/index.jsx index 74d1871..b8a9638 100644 --- a/src/components/Manifest/List/index.jsx +++ b/src/components/Manifest/List/index.jsx @@ -112,7 +112,7 @@ const MainForm = () => { const [pageSize, setPageSize] = useLocalStorage(PAGE_SIZE, 10); const [pageIndex, setPageIndex] = useState(0); const [orderBy, setOrderBy] = useState("id"); - const [order, setOrder] = useState("asc"); + const [order, setOrder] = useState("desc"); const [search, setSearch] = useLocalStorage("DEPLOYMENT_SEARCH", ""); const [active, setActive] = useLocalStorage("DEPLOYMENT_TAB_TOGGLE", "software"); diff --git a/src/components/Manifest/Status/index.jsx b/src/components/Manifest/Status/index.jsx index 1482679..e5c5983 100644 --- a/src/components/Manifest/Status/index.jsx +++ b/src/components/Manifest/Status/index.jsx @@ -63,7 +63,7 @@ const MainForm = () => { const [pageSize, setPageSize] = useLocalStorage(PAGE_SIZE, 10); const [pageIndex, setPageIndex] = useState(0); const [orderBy, setOrderBy] = useState("id"); - const [order, setOrder] = useState("asc"); + const [order, setOrder] = useState("desc"); const [ids, setIds] = useState([]); const { getManifests, manifests } = useManifestsContext(); const { diff --git a/src/components/Manifest/Update/__snapshots__/index.test.jsx.snap b/src/components/Manifest/Update/__snapshots__/index.test.jsx.snap index 9874fa0..8fce96e 100644 --- a/src/components/Manifest/Update/__snapshots__/index.test.jsx.snap +++ b/src/components/Manifest/Update/__snapshots__/index.test.jsx.snap @@ -112,6 +112,43 @@ exports[`Manifest Details Component Render 1`] = `
+
+ +
+ + +
+
@@ -334,6 +371,68 @@ exports[`Manifest Details Component Render 1`] = `
+
+
+ +
+ +
+

+

+
+
+
+ +
+ +
+

+

+