CEC-2385 Only show software updates (#193)
* CEC-2385 Only show software updates * Update browser list * update threshold * Clean up
This commit is contained in:
@@ -1,157 +0,0 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { Redirect } from "react-router";
|
||||
import { Button, TextField, Typography } from "@material-ui/core";
|
||||
|
||||
import { useUserContext } from "../../Contexts/UserContext";
|
||||
import { useStatusContext } from "../../Contexts/StatusContext";
|
||||
import {
|
||||
ManifestCreateProvider,
|
||||
useManifestCreateContext,
|
||||
} from "../../Contexts/ManifestCreateContext";
|
||||
import useStyles from "../../useStyles";
|
||||
import { logger } from "../../../services/monitoring";
|
||||
import ManifestECUList from "../../Controls/ManifestECUList";
|
||||
import ManifestUploadProgress from "../../Controls/ManifestUploadProgress";
|
||||
|
||||
const MainForm = () => {
|
||||
const { createManifest, cancelUpload, busy } = useManifestCreateContext();
|
||||
const { token } = useUserContext();
|
||||
const { setMessage, setTitle, setSitePath } = useStatusContext();
|
||||
const [redirect, setRedirect] = useState(null);
|
||||
const classes = useStyles();
|
||||
const packagenameEl = useRef(null);
|
||||
const versionEl = useRef(null);
|
||||
const descEl = useRef(null);
|
||||
const releasenotesEl = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
setTitle("Create Deployments");
|
||||
setSitePath([
|
||||
{
|
||||
label: "Deployments",
|
||||
link: "/packages",
|
||||
},
|
||||
{
|
||||
label: "Create Deployments",
|
||||
},
|
||||
]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const onSubmit = async (event) => {
|
||||
try {
|
||||
event.preventDefault();
|
||||
const {
|
||||
idToken: { jwtToken: authToken },
|
||||
} = token;
|
||||
const formData = {
|
||||
name: packagenameEl.current.value,
|
||||
version: versionEl.current.value,
|
||||
description: descEl.current.value,
|
||||
release_notes: releasenotesEl.current.value,
|
||||
};
|
||||
const manifest = await createManifest(formData, authToken);
|
||||
|
||||
if (!manifest || manifest.error) return;
|
||||
|
||||
cancelUpload();
|
||||
setMessage(`Package uploaded`);
|
||||
setRedirect(`/package-deploy/${manifest.id}`);
|
||||
} catch (e) {
|
||||
setMessage(e.message);
|
||||
logger.warn(e.stack);
|
||||
}
|
||||
};
|
||||
|
||||
if (redirect && redirect.length > 0) {
|
||||
return <Redirect to={redirect} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classes.paper}>
|
||||
<form className={classes.form} noValidate action="{onSubmit}">
|
||||
<TextField
|
||||
id="packagename"
|
||||
name="packagename"
|
||||
label="Package name"
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
inputProps={{
|
||||
maxLength: "255",
|
||||
}}
|
||||
required
|
||||
fullWidth
|
||||
inputRef={packagenameEl}
|
||||
/>
|
||||
<TextField
|
||||
id="version"
|
||||
name="version"
|
||||
label="Version"
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
inputProps={{
|
||||
maxLength: "255",
|
||||
}}
|
||||
required
|
||||
fullWidth
|
||||
inputRef={versionEl}
|
||||
/>
|
||||
<TextField
|
||||
id="description"
|
||||
name="description"
|
||||
label="Description"
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
inputProps={{
|
||||
maxLength: "5120",
|
||||
}}
|
||||
required
|
||||
fullWidth
|
||||
multiline
|
||||
minRows={4}
|
||||
placeholder="Package description"
|
||||
inputRef={descEl}
|
||||
/>
|
||||
<TextField
|
||||
id="release_notes"
|
||||
name="release_notes"
|
||||
label="Release Notes URL"
|
||||
variant="outlined"
|
||||
margin="normal"
|
||||
inputProps={{
|
||||
maxLength: "1024",
|
||||
}}
|
||||
required
|
||||
fullWidth
|
||||
placeholder="Release Notes URL"
|
||||
inputRef={releasenotesEl}
|
||||
/>
|
||||
<Typography variant="h6">ECU Files</Typography>
|
||||
<ManifestECUList />
|
||||
{busy ? (
|
||||
<ManifestUploadProgress onCancel={cancelUpload} />
|
||||
) : (
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={busy}
|
||||
fullWidth
|
||||
variant="contained"
|
||||
color="primary"
|
||||
className={classes.submit}
|
||||
onClick={onSubmit}
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
)}
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default function FileUploadForm() {
|
||||
return (
|
||||
<ManifestCreateProvider>
|
||||
<MainForm />
|
||||
</ManifestCreateProvider>
|
||||
);
|
||||
}
|
||||
@@ -28,7 +28,8 @@ import SearchField from "../../Controls/SearchField";
|
||||
import { logger } from "../../../services/monitoring";
|
||||
import ECUList from "../../Controls/ECUList";
|
||||
import { Roles, hasRole } from "../../../utils/roles";
|
||||
import {useLocalStorage} from "../../useLocalStorage";
|
||||
import { useLocalStorage } from "../../useLocalStorage";
|
||||
import { TYPE_MANIFEST_SOFTWARE } from "../../../utils/manifest_types";
|
||||
|
||||
const tableColumns = [
|
||||
{
|
||||
@@ -57,7 +58,7 @@ const tableColumns = [
|
||||
},
|
||||
];
|
||||
|
||||
const PAGE_SIZE="MANIFEST_LIST_PAGE_SIZE";
|
||||
const PAGE_SIZE = "MANIFEST_LIST_PAGE_SIZE";
|
||||
|
||||
const MainForm = () => {
|
||||
const classes = useStyles();
|
||||
@@ -103,6 +104,7 @@ const MainForm = () => {
|
||||
limit: pageSize,
|
||||
offset: pageSize * pageIndex,
|
||||
order: `${orderBy} ${order}`,
|
||||
manifest_type: TYPE_MANIFEST_SOFTWARE,
|
||||
search,
|
||||
},
|
||||
token
|
||||
|
||||
Reference in New Issue
Block a user