fixes from review

This commit is contained in:
padamsen_fisker
2024-01-31 10:46:32 -05:00
parent 0a886904d6
commit 78108e3d9c
6 changed files with 45 additions and 29 deletions

View File

@@ -77,8 +77,9 @@ export const CarUpdatesProvider = ({ children }) => {
try { try {
setBusy(true); setBusy(true);
result = await api.cancelCarUpdate(id, token); result = await api.cancelCarUpdate(id, token);
if (result.error) if (result.error) {
throw new Error(`Cancel car update error. ${result.message}`); throw new Error(`Cancel car update error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -92,8 +93,9 @@ export const CarUpdatesProvider = ({ children }) => {
try { try {
setBusy(true); setBusy(true);
result = await api.deployCarUpdate(id, token); result = await api.deployCarUpdate(id, token);
if (result.error) if (result.error) {
throw new Error(`Retry car update error. ${result.message}`); throw new Error(`Retry car update error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -108,8 +110,9 @@ export const CarUpdatesProvider = ({ children }) => {
setBusy(true); setBusy(true);
validateDeployCarUpdates(data); validateDeployCarUpdates(data);
result = await api.createCarUpdates(data, token); result = await api.createCarUpdates(data, token);
if (result.error) if (result.error) {
throw new Error(`Deploy car updates error. ${result.message}`); throw new Error(`Deploy car updates error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -124,8 +127,9 @@ export const CarUpdatesProvider = ({ children }) => {
setBusy(true); setBusy(true);
validateDeployFleetUpdates(data); validateDeployFleetUpdates(data);
result = await api.createFleetUpdates(data, token); result = await api.createFleetUpdates(data, token);
if (result.error) if (result.error) {
throw new Error(`Deploy fleet updates error. ${result.message}`); throw new Error(`Deploy fleet updates error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -163,8 +167,9 @@ export const CarUpdatesProvider = ({ children }) => {
try { try {
setBusy(true); setBusy(true);
result = await api.getVINUpdates(vin, token); result = await api.getVINUpdates(vin, token);
if (result.error) if (result.error) {
throw new Error(`Get VIN updates error. ${result.message}`); throw new Error(`Get VIN updates error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -230,8 +235,9 @@ export const CarUpdatesProvider = ({ children }) => {
carupdateids.join(","), carupdateids.join(","),
token token
); );
if (result.error) if (result.error) {
throw new Error(`Get update progress error. ${result.message}`); throw new Error(`Get update progress error. ${result.message}`);
}
applyProgressStatuses(result.statuses); applyProgressStatuses(result.statuses);
} catch (e) { } catch (e) {
@@ -272,8 +278,9 @@ export const CarUpdatesProvider = ({ children }) => {
try { try {
setBusy(true); setBusy(true);
result = await api.getCarUpdateLog(query, token); result = await api.getCarUpdateLog(query, token);
if (result.error) if (result.error) {
throw new Error(`Get car update log error. ${result.message}`); throw new Error(`Get car update log error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -288,8 +295,9 @@ export const CarUpdatesProvider = ({ children }) => {
setBusy(true); setBusy(true);
result = await api.getSUMSVersions(null, token); result = await api.getSUMSVersions(null, token);
if (result.error) if (result.error) {
throw new Error(`Get software versions error. ${result.message}`); throw new Error(`Get software versions error. ${result.message}`);
}
result.data.unshift(SELECT_VERSION_OBJ) result.data.unshift(SELECT_VERSION_OBJ)
setVersions(result.data); setVersions(result.data);
@@ -307,8 +315,9 @@ export const CarUpdatesProvider = ({ children }) => {
setBusy(true); setBusy(true);
result = await api.getSUMSVersions(options, token); result = await api.getSUMSVersions(options, token);
if (result.error) if (result.error) {
throw new Error(`Get software versions error. ${result.message}`); throw new Error(`Get software versions error. ${result.message}`);
}
setVersions(result.data); setVersions(result.data);
if (options && options.offset === 0 && result.total) { if (options && options.offset === 0 && result.total) {
@@ -339,8 +348,9 @@ export const CarUpdatesProvider = ({ children }) => {
} }
result = await api.addSUMSVersion(data, token); result = await api.addSUMSVersion(data, token);
if (result.error) if (result.error) {
throw new Error(`Add SUMS version error. ${result.message}`); throw new Error(`Add SUMS version error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -355,8 +365,9 @@ export const CarUpdatesProvider = ({ children }) => {
setBusy(true); setBusy(true);
result = await api.deleteSUMSVersion(version, token); result = await api.deleteSUMSVersion(version, token);
if (result.error) if (result.error) {
throw new Error(`Delete software version error. ${result.message}`); throw new Error(`Delete software version error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -373,8 +384,9 @@ export const CarUpdatesProvider = ({ children }) => {
if (!validateSoftwareVersion(version)) throw new Error(`invalid version ${version}`); if (!validateSoftwareVersion(version)) throw new Error(`invalid version ${version}`);
result = await api.updateSUMSVersion(id, version, token); result = await api.updateSUMSVersion(id, version, token);
if (result.error) if (result.error) {
throw new Error(`Update manifest version error. ${result.message}`); throw new Error(`Update manifest version error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -410,8 +422,9 @@ export const CarUpdatesProvider = ({ children }) => {
setBusy(true); setBusy(true);
result = await api.deleteSUMSVersionRxSwins(sums_version, rxswin, token); result = await api.deleteSUMSVersionRxSwins(sums_version, rxswin, token);
if (result.error) if (result.error) {
throw new Error(`Delete software version rxswin error. ${result.message}`); throw new Error(`Delete software version rxswin error. ${result.message}`);
}
} finally { } finally {
setBusy(false); setBusy(false);
} }
@@ -423,8 +436,9 @@ export const CarUpdatesProvider = ({ children }) => {
try { try {
setBusy(true); setBusy(true);
const result = await api.addSUMSVersionRxSwins(sums_version, data, token); const result = await api.addSUMSVersionRxSwins(sums_version, data, token);
if (result.error) if (result.error) {
throw new Error(`Add software version rxswin error. ${result.message}`); throw new Error(`Add software version rxswin error. ${result.message}`);
}
return result; return result;
} finally { } finally {
setBusy(false); setBusy(false);

View File

@@ -156,6 +156,8 @@ export const useCarUpdatesContext = () => ({
stopMonitor: jest.fn(), stopMonitor: jest.fn(),
approveUpdate: jest.fn(), approveUpdate: jest.fn(),
getSUMSVersions: jest.fn(() => sumsVersions), getSUMSVersions: jest.fn(() => sumsVersions),
addSUMSVersion: jest.fn(),
deleteSUMSVersion: jest.fn(),
getSUMSVersionRxSwins: jest.fn(() => sumsVersionRxSwins), getSUMSVersionRxSwins: jest.fn(() => sumsVersionRxSwins),
deleteSUMSVersionRxSwins: jest.fn(), deleteSUMSVersionRxSwins: jest.fn(),
addSUMSVersionRxSwins: jest.fn(), addSUMSVersionRxSwins: jest.fn(),

View File

@@ -48,19 +48,25 @@ exports[`SUMSList Render 1`] = `
class="MuiTableRow-root MuiTableRow-head" class="MuiTableRow-root MuiTableRow-head"
> >
<th <th
aria-sort="descending"
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter" class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
scope="col" scope="col"
> >
<span <span
aria-disabled="false" aria-disabled="false"
class="MuiButtonBase-root MuiTableSortLabel-root" class="MuiButtonBase-root MuiTableSortLabel-root MuiTableSortLabel-active"
role="button" role="button"
tabindex="0" tabindex="0"
> >
SUMS Version SUMS Version
<span
class="makeStyles-hiddenSortSpan-0"
>
sorted descending
</span>
<svg <svg
aria-hidden="true" aria-hidden="true"
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc" class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc"
focusable="false" focusable="false"
viewBox="0 0 24 24" viewBox="0 0 24 24"
> >
@@ -94,25 +100,19 @@ exports[`SUMSList Render 1`] = `
</span> </span>
</th> </th>
<th <th
aria-sort="descending"
class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter" class="MuiTableCell-root MuiTableCell-head MuiTableCell-alignCenter"
scope="col" scope="col"
> >
<span <span
aria-disabled="false" aria-disabled="false"
class="MuiButtonBase-root MuiTableSortLabel-root MuiTableSortLabel-active" class="MuiButtonBase-root MuiTableSortLabel-root"
role="button" role="button"
tabindex="0" tabindex="0"
> >
Created Created
<span
class="makeStyles-hiddenSortSpan-0"
>
sorted descending
</span>
<svg <svg
aria-hidden="true" aria-hidden="true"
class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc" class="MuiSvgIcon-root MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc"
focusable="false" focusable="false"
viewBox="0 0 24 24" viewBox="0 0 24 24"
> >

View File

@@ -49,7 +49,7 @@ const PAGE_SIZE = "SUMS_VERSIONS_TABLE_PAGE_SIZE";
const MainForm = () => { const MainForm = () => {
const classes = useStyles(); const classes = useStyles();
const { setMessage, setTitle, setSitePath } = useStatusContext(); const { setMessage, setTitle, setSitePath } = useStatusContext();
const [orderBy, setOrderBy] = useState("created_at"); const [orderBy, setOrderBy] = useState("version");
const [order, setOrder] = useState("desc"); const [order, setOrder] = useState("desc");
const [showDeleteModal, setShowDeleteModal] = useState(false); const [showDeleteModal, setShowDeleteModal] = useState(false);
const [rowToDelete, setRowToDelete] = useState({}); const [rowToDelete, setRowToDelete] = useState({});

View File

@@ -47,7 +47,7 @@ exports[`SUMSNew Render 1`] = `
aria-invalid="false" aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input" class="MuiInputBase-input MuiOutlinedInput-input"
id="sums_version" id="sums_version"
maxlength="255" maxlength="15"
name="sums_version" name="sums_version"
required="" required=""
type="text" type="text"
@@ -93,7 +93,7 @@ exports[`SUMSNew Render 1`] = `
aria-invalid="false" aria-invalid="false"
class="MuiInputBase-input MuiOutlinedInput-input" class="MuiInputBase-input MuiOutlinedInput-input"
id="os_version" id="os_version"
maxlength="255" maxlength="20"
name="os_version" name="os_version"
required="" required=""
type="text" type="text"

View File

@@ -81,7 +81,7 @@ const MainForm = () => {
variant="outlined" variant="outlined"
margin="normal" margin="normal"
inputProps={{ inputProps={{
maxLength: "255", maxLength: "15",
}} }}
required required
fullWidth fullWidth
@@ -96,7 +96,7 @@ const MainForm = () => {
variant="outlined" variant="outlined"
margin="normal" margin="normal"
inputProps={{ inputProps={{
maxLength: "255", maxLength: "20",
}} }}
required required
fullWidth fullWidth