CEC-3672 Use SUMS version instead of Version (#279)
This commit is contained in:
@@ -3229,22 +3229,6 @@ exports[`App Route /package-deploy authenticated 1`] = `
|
||||
<main
|
||||
class="MuiContainer-root MuiContainer-maxWidthLg"
|
||||
>
|
||||
<div
|
||||
class="MuiSnackbar-root MuiSnackbar-anchorOriginTopCenter"
|
||||
>
|
||||
<div
|
||||
class="MuiPaper-root MuiSnackbarContent-root MuiPaper-elevation6"
|
||||
direction="down"
|
||||
role="alert"
|
||||
style="opacity: 1; transform: scale(1, 1); transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms,transform 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;"
|
||||
>
|
||||
<div
|
||||
class="MuiSnackbarContent-message"
|
||||
>
|
||||
getSoftwareVersions is not a function
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
data-testid="mocked-manifestsprovider"
|
||||
>
|
||||
@@ -5270,6 +5254,29 @@ exports[`App Route /packages authenticated 1`] = `
|
||||
</svg>
|
||||
</span>
|
||||
</th>
|
||||
<th
|
||||
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
|
||||
scope="col"
|
||||
>
|
||||
<span
|
||||
aria-disabled="false"
|
||||
class="MuiButtonBase-root MuiTableSortLabel-root"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
SUMS
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
|
||||
focusable="false"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</th>
|
||||
<th
|
||||
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
|
||||
scope="col"
|
||||
@@ -5368,6 +5375,9 @@ exports[`App Route /packages authenticated 1`] = `
|
||||
>
|
||||
1.0
|
||||
</td>
|
||||
<td
|
||||
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
|
||||
/>
|
||||
<td
|
||||
class="MuiTableCell-root MuiTableCell-body MuiTableCell-alignCenter"
|
||||
>
|
||||
@@ -5451,7 +5461,7 @@ exports[`App Route /packages authenticated 1`] = `
|
||||
>
|
||||
<td
|
||||
class="MuiTableCell-root MuiTableCell-footer MuiTablePagination-root"
|
||||
colspan="6"
|
||||
colspan="8"
|
||||
>
|
||||
<div
|
||||
class="MuiToolbar-root MuiToolbar-regular MuiTablePagination-toolbar MuiToolbar-gutters"
|
||||
|
||||
@@ -242,13 +242,13 @@ export const CarUpdatesProvider = ({ children }) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
const getSoftwareVersions = async (token) => {
|
||||
const getSUMSVersions = async (token) => {
|
||||
let result;
|
||||
|
||||
try {
|
||||
setBusy(true);
|
||||
|
||||
result = await api.getSoftwareVersions(token);
|
||||
result = await api.getSUMSVersions(token);
|
||||
if (result.error)
|
||||
throw new Error(`Get software versions error. ${result.message}`);
|
||||
|
||||
@@ -261,7 +261,7 @@ export const CarUpdatesProvider = ({ children }) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
const updateManifestVersion = async (id, version, token) => {
|
||||
const updateSUMSVersion = async (id, version, token) => {
|
||||
let result;
|
||||
|
||||
try {
|
||||
@@ -269,7 +269,7 @@ export const CarUpdatesProvider = ({ children }) => {
|
||||
|
||||
if (!validateSoftwareVersion(version)) throw new Error(`invalid version ${version}`);
|
||||
|
||||
result = await api.updateManifestVersion(id, version, token);
|
||||
result = await api.updateSUMSVersion(id, version, token);
|
||||
if (result.error)
|
||||
throw new Error(`Update manifest version error. ${result.message}`);
|
||||
} finally {
|
||||
@@ -291,11 +291,11 @@ export const CarUpdatesProvider = ({ children }) => {
|
||||
deployFleetUpdates,
|
||||
getCarUpdates,
|
||||
getLog,
|
||||
getSoftwareVersions,
|
||||
getSUMSVersions,
|
||||
getVINUpdates,
|
||||
startMonitor,
|
||||
stopMonitor,
|
||||
updateManifestVersion,
|
||||
updateSUMSVersion,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -60,6 +60,10 @@ let carUpdateLog = {
|
||||
total: 3,
|
||||
};
|
||||
|
||||
let sumsVersions = {
|
||||
"data": ["2023.02.01.0.0.A", "2023.02.01.0.0.B"]
|
||||
}
|
||||
|
||||
export const CarUpdatesProvider = ({ children }) => {
|
||||
return <div data-testid="mocked-carupdatesprovider">{children}</div>;
|
||||
};
|
||||
@@ -77,4 +81,6 @@ export const useCarUpdatesContext = () => ({
|
||||
startMonitor: jest.fn(),
|
||||
stopMonitor: jest.fn(),
|
||||
approveUpdate: jest.fn(),
|
||||
});
|
||||
getSUMSVersions: jest.fn(() => sumsVersions),
|
||||
updateSUMSVersion: jest.fn(),
|
||||
});
|
||||
@@ -26,7 +26,7 @@ const MainForm = () => {
|
||||
const [updateType, setUpdateType] = useState(CAR_UPDATE);
|
||||
const {manifest_id} = useParams();
|
||||
const {getManifests, manifests, busy} = useManifestsContext();
|
||||
const {deployCarUpdates, deployFleetUpdates, getSoftwareVersions, versions, updateManifestVersion} = useCarUpdatesContext();
|
||||
const {deployCarUpdates, deployFleetUpdates, getSUMSVersions, versions, updateSUMSVersion} = useCarUpdatesContext();
|
||||
const {
|
||||
groups,
|
||||
providers,
|
||||
@@ -37,6 +37,7 @@ const MainForm = () => {
|
||||
const {setMessage, setTitle, setSitePath} = useStatusContext();
|
||||
const [manifestName, setManifestName] = useState("");
|
||||
const [version, setVersion] = useState("");
|
||||
const [sumsVersion, setSUMSersion] = useState("");
|
||||
const [createDate, setCreateDate] = useState("");
|
||||
const [selected, setSelected] = useState([]);
|
||||
const [search, setSearch] = useState("");
|
||||
@@ -79,7 +80,9 @@ const MainForm = () => {
|
||||
const data = {
|
||||
manifest_id: parseInt(manifest_id),
|
||||
}
|
||||
await updateManifestVersion(manifest_id, softwareVersion, token);
|
||||
if (sumsVersion.length === 0) {
|
||||
await updateSUMSVersion(manifest_id, softwareVersion, token);
|
||||
}
|
||||
|
||||
if (updateType === CAR_UPDATE) {
|
||||
data.vins = selected;
|
||||
@@ -101,7 +104,7 @@ const MainForm = () => {
|
||||
const getData = async () => {
|
||||
try {
|
||||
await getManifests({id: parseInt(manifest_id)}, token);
|
||||
await getSoftwareVersions(token);
|
||||
await getSUMSVersions(token);
|
||||
} catch (e) {
|
||||
setMessage(e.message);
|
||||
logger.warn(e.stack);
|
||||
@@ -138,6 +141,7 @@ const MainForm = () => {
|
||||
|
||||
setManifestName(data.name);
|
||||
setVersion(data.version);
|
||||
setSUMSersion(data.sums || "");
|
||||
setCreateDate(LocalDateTimeString(data.created));
|
||||
}, [manifests]);
|
||||
|
||||
@@ -172,17 +176,19 @@ const MainForm = () => {
|
||||
<SearchField classes={classes} onSearch={handleSearch}/>
|
||||
</Grid>
|
||||
<Grid item md={4} container justifyContent="flex-end">
|
||||
<DropDownList
|
||||
label="Software Version"
|
||||
labelField="version"
|
||||
valueField="version"
|
||||
value={softwareVersion}
|
||||
data={versions}
|
||||
classes={classes}
|
||||
onChange={changeVersion} />
|
||||
{sumsVersion.length === 0 &&
|
||||
<DropDownList
|
||||
label="Software Version"
|
||||
labelField="version"
|
||||
valueField="version"
|
||||
value={softwareVersion}
|
||||
data={versions}
|
||||
classes={classes}
|
||||
onChange={changeVersion} />
|
||||
}
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={busy || selected.length === 0 || softwareVersion === SELECT_VERSION}
|
||||
disabled={busy || selected.length === 0 || (sumsVersion.length === 0 && softwareVersion === SELECT_VERSION)}
|
||||
color="primary"
|
||||
onClick={onSubmit}
|
||||
>
|
||||
@@ -225,4 +231,4 @@ const ManifestDeployForm = () => (
|
||||
</ManifestsProvider>
|
||||
);
|
||||
|
||||
export default ManifestDeployForm;
|
||||
export default ManifestDeployForm;
|
||||
@@ -6,15 +6,15 @@ import {
|
||||
TableFooter,
|
||||
TablePagination,
|
||||
TableRow,
|
||||
Tooltip,
|
||||
Tooltip
|
||||
} from "@material-ui/core";
|
||||
import {
|
||||
ToggleButton,
|
||||
ToggleButtonGroup
|
||||
} from "@mui/material"
|
||||
import DeleteIcon from "@material-ui/icons/Delete";
|
||||
import SendIcon from "@material-ui/icons/Send";
|
||||
import VisibilityIcon from "@material-ui/icons/Visibility";
|
||||
import {
|
||||
ToggleButton,
|
||||
ToggleButtonGroup
|
||||
} from "@mui/material";
|
||||
import clsx from "clsx";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
@@ -26,7 +26,7 @@ import { TYPE_MANIFEST_SOFTWARE } from "../../../utils/manifest_types";
|
||||
import { hasRole, Permissions } from "../../../utils/roles";
|
||||
import {
|
||||
ManifestsProvider,
|
||||
useManifestsContext,
|
||||
useManifestsContext
|
||||
} from "../../Contexts/ManifestsContext";
|
||||
import { useStatusContext } from "../../Contexts/StatusContext";
|
||||
import { useUserContext } from "../../Contexts/UserContext";
|
||||
@@ -50,6 +50,10 @@ const tableColumns = [
|
||||
id: "version",
|
||||
label: "Version",
|
||||
},
|
||||
{
|
||||
id: "sums",
|
||||
label: "SUMS",
|
||||
},
|
||||
{
|
||||
id: "type",
|
||||
label: "Type",
|
||||
@@ -280,6 +284,7 @@ const MainForm = () => {
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell align="center">{row.version}</TableCell>
|
||||
<TableCell align="center">{row.sums}</TableCell>
|
||||
<TableCell align="center">
|
||||
{formatManifestType(row.type)}
|
||||
</TableCell>
|
||||
@@ -297,7 +302,7 @@ const MainForm = () => {
|
||||
<TableRow>
|
||||
<TablePagination
|
||||
rowsPerPageOptions={[5, 10, 25, 100]}
|
||||
colSpan={6}
|
||||
colSpan={8}
|
||||
count={totalManifests}
|
||||
rowsPerPage={pageSize}
|
||||
page={pageIndex}
|
||||
@@ -327,4 +332,4 @@ const ManifestsList = () => (
|
||||
</ManifestsProvider>
|
||||
);
|
||||
|
||||
export default ManifestsList;
|
||||
export default ManifestsList;
|
||||
@@ -27,13 +27,13 @@ const updatesAPI = {
|
||||
return { message: "OK" };
|
||||
},
|
||||
|
||||
getSoftwareVersions: async (token) => {
|
||||
getSUMSVersions: async (token) => {
|
||||
return {
|
||||
"data": ["2023.02.01.0.0.A", "2023.02.01.0.0.B"]
|
||||
};
|
||||
},
|
||||
|
||||
updateManifestVersion: async (_id, version) => {
|
||||
updateSUMSVersion: async (_id, version) => {
|
||||
return { version };
|
||||
},
|
||||
};
|
||||
|
||||
@@ -87,8 +87,8 @@ const updatesAPI = {
|
||||
.catch(errorHandler);
|
||||
},
|
||||
|
||||
getSoftwareVersions: async (token) => {
|
||||
return fetch(`${API_ENDPOINT}/manifest/versions`, {
|
||||
getSUMSVersions: async (token) => {
|
||||
return fetch(`${API_ENDPOINT}/manifest/sums`, {
|
||||
method: "GET",
|
||||
headers: Object.assign(
|
||||
{ "Content-Type": "application/json" },
|
||||
@@ -99,8 +99,8 @@ const updatesAPI = {
|
||||
.catch(errorHandler);
|
||||
},
|
||||
|
||||
updateManifestVersion: async (id, version, token) => {
|
||||
return fetch(`${API_ENDPOINT}/manifests/${id}/version`, {
|
||||
updateSUMSVersion: async (id, version, token) => {
|
||||
return fetch(`${API_ENDPOINT}/manifests/${id}/sums`, {
|
||||
method: "PUT",
|
||||
headers: Object.assign(
|
||||
{ "Content-Type": "application/json" },
|
||||
@@ -113,4 +113,4 @@ const updatesAPI = {
|
||||
}
|
||||
};
|
||||
|
||||
export default updatesAPI;
|
||||
export default updatesAPI;
|
||||
Reference in New Issue
Block a user