diff --git a/src/components/App/__snapshots__/App.test.js.snap b/src/components/App/__snapshots__/App.test.js.snap index ad6c059..b7878f8 100644 --- a/src/components/App/__snapshots__/App.test.js.snap +++ b/src/components/App/__snapshots__/App.test.js.snap @@ -3229,22 +3229,6 @@ exports[`App Route /package-deploy authenticated 1`] = `
-
- -
@@ -5270,6 +5254,29 @@ exports[`App Route /packages authenticated 1`] = ` + + + SUMS + + + 1.0 + @@ -5451,7 +5461,7 @@ exports[`App Route /packages authenticated 1`] = ` >
{ 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} diff --git a/src/components/Contexts/__mocks__/CarUpdatesContext.jsx b/src/components/Contexts/__mocks__/CarUpdatesContext.jsx index 1e32093..ca78516 100644 --- a/src/components/Contexts/__mocks__/CarUpdatesContext.jsx +++ b/src/components/Contexts/__mocks__/CarUpdatesContext.jsx @@ -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
{children}
; }; @@ -77,4 +81,6 @@ export const useCarUpdatesContext = () => ({ startMonitor: jest.fn(), stopMonitor: jest.fn(), approveUpdate: jest.fn(), -}); + getSUMSVersions: jest.fn(() => sumsVersions), + updateSUMSVersion: jest.fn(), +}); \ No newline at end of file diff --git a/src/components/Manifest/Deploy/index.jsx b/src/components/Manifest/Deploy/index.jsx index 5e8b4e4..8a84d56 100644 --- a/src/components/Manifest/Deploy/index.jsx +++ b/src/components/Manifest/Deploy/index.jsx @@ -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 = () => { - + {sumsVersion.length === 0 && + + }