CEC-3149: Archive Manifest option (#241)

Co-authored-by: Alexander Andrews <aandrews@fiskerinc.com>
This commit is contained in:
Alexander Andrews
2022-11-29 13:44:44 -05:00
committed by GitHub
parent eb82c178ca
commit 8e33ca6b7d
9 changed files with 693 additions and 139 deletions

View File

@@ -168,6 +168,62 @@ exports[`Manifest Details Component Render 1`] = `
</fieldset>
</div>
</div>
<div
class="MuiFormControl-root makeStyles-form-0 MuiFormControl-marginNormal MuiFormControl-fullWidth"
>
<label
class="MuiFormLabel-root MuiInputLabel-root makeStyles-whiteBackground-0 MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled"
data-shrink="true"
for="manifest-active"
>
Type
</label>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-formControl"
>
<select
aria-invalid="false"
class="MuiSelect-root MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input"
id="send-manifest-active"
name="manifest-active"
>
<option
value="true"
>
active
</option>
<option
value="false"
>
archived
</option>
</select>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSelect-icon MuiSelect-iconOutlined"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M7 10l5 5 5-5z"
/>
</svg>
<fieldset
aria-hidden="true"
class="PrivateNotchedOutline-root-0 MuiOutlinedInput-notchedOutline"
style="padding-left: 8px;"
>
<legend
class="PrivateNotchedOutline-legend-0"
style="width: 0.01px;"
>
<span>
</span>
</legend>
</fieldset>
</div>
</div>
<button
aria-label="send command"
class="MuiButtonBase-root MuiButton-root MuiButton-contained makeStyles-submit-0 MuiButton-containedPrimary MuiButton-fullWidth"

View File

@@ -1,15 +1,15 @@
import React, {useEffect, useState} from "react";
import {useParams} from "react-router-dom";
import React, { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { Redirect } from "react-router";
import useStyles from "../../useStyles";
import {ManifestsProvider, useManifestsContext} from "../../Contexts/ManifestsContext";
import {useUserContext} from "../../Contexts/UserContext";
import {useStatusContext} from "../../Contexts/StatusContext";
import {Button, FormControl, InputLabel, Select, TextField} from "@material-ui/core";
import { ManifestsProvider, useManifestsContext } from "../../Contexts/ManifestsContext";
import { useUserContext } from "../../Contexts/UserContext";
import { useStatusContext } from "../../Contexts/StatusContext";
import { Button, FormControl, InputLabel, Select, TextField } from "@material-ui/core";
const manifestTypes = [
{value: "standard", label: "Standard"},
{value: "forced", label: "Forced"},
{ value: "standard", label: "Standard" },
{ value: "forced", label: "Forced" },
];
const emptyManifest = {
@@ -19,23 +19,24 @@ const emptyManifest = {
const MainForm = () => {
const {manifest_id} = useParams();
const { manifest_id } = useParams();
const classes = useStyles();
const [manifest, setManifest] = useState(null);
const [redirect, setRedirect] = useState(null);
const {getManifest, busy, updateManifest} = useManifestsContext();
const { getManifest, busy, updateManifest } = useManifestsContext();
const {
token: {
idToken: {jwtToken: token},
idToken: { jwtToken: token },
},
} = useUserContext();
const {setMessage, setTitle, setSitePath} = useStatusContext();
const { setMessage, setTitle, setSitePath } = useStatusContext();
const [name, setName] = useState("");
const [type, setType] = useState("");
const [active, setActive] = useState(true); // So !active = archived
const changeName = (e) => {
@@ -46,10 +47,14 @@ const MainForm = () => {
setType(e.target.value);
};
const changeActive = (e) => {
setActive(e.target.value === 'true')
}
const onSubmit = async (e) => {
e.preventDefault();
try {
const result = await updateManifest(manifest_id, {name, type}, token);
const result = await updateManifest(manifest_id, { name, type, active }, token);
if (!result || result.error) return;
setMessage(`Updated manifest ${manifest_id}`);
@@ -70,6 +75,7 @@ const MainForm = () => {
setManifest(result);
setName(result.name);
setType(result.type);
setActive(result.active)
}
} catch (e) {
setMessage(e.message);
@@ -156,6 +162,29 @@ const MainForm = () => {
))}
</Select>
</FormControl>
<FormControl
className={classes.form}
variant="outlined"
fullWidth
margin="normal"
>
<InputLabel htmlFor="manifest-active" className={classes.whiteBackground}>
Type
</InputLabel>
<Select
native
value={active}
variant="outlined"
inputProps={{
name: "manifest-active",
id: "send-manifest-active",
}}
onChange={changeActive}
>
<option key={0} value={true}>active</option>
<option key={1} value={false}>archived</option>
</Select>
</FormControl>
<Button
type="submit"
aria-label="send command"
@@ -176,7 +205,7 @@ const MainForm = () => {
const ManifestUpdate = () => (
<ManifestsProvider>
<MainForm/>
<MainForm />
</ManifestsProvider>
);