CEC-4044 update manifest form (#312)
* CEC-4044 update manifest form * Show env input if there are options
This commit is contained in:
@@ -218,6 +218,122 @@ exports[`Manifest Details Component Render 1`] = `
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="MuiFormControl-root MuiFormControl-marginNormal"
|
||||
>
|
||||
<label
|
||||
class="MuiFormLabel-root MuiInputLabel-root makeStyles-whiteBackground-0 MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-outlined"
|
||||
data-shrink="false"
|
||||
>
|
||||
Rollback
|
||||
</label>
|
||||
<div
|
||||
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-formControl"
|
||||
>
|
||||
<select
|
||||
aria-invalid="false"
|
||||
class="MuiSelect-root MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input"
|
||||
>
|
||||
<option
|
||||
value="true"
|
||||
>
|
||||
True
|
||||
</option>
|
||||
<option
|
||||
value="false"
|
||||
>
|
||||
False
|
||||
</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>
|
||||
<div
|
||||
class="MuiFormControl-root MuiFormControl-marginNormal"
|
||||
>
|
||||
<label
|
||||
class="MuiFormLabel-root MuiInputLabel-root makeStyles-whiteBackground-0 MuiInputLabel-formControl MuiInputLabel-animated MuiInputLabel-shrink MuiInputLabel-outlined MuiFormLabel-filled"
|
||||
data-shrink="true"
|
||||
>
|
||||
ECC Keys
|
||||
</label>
|
||||
<div
|
||||
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-formControl"
|
||||
>
|
||||
<select
|
||||
aria-invalid="false"
|
||||
class="MuiSelect-root MuiSelect-select MuiSelect-outlined MuiInputBase-input MuiOutlinedInput-input"
|
||||
>
|
||||
<option
|
||||
value="current"
|
||||
>
|
||||
local
|
||||
</option>
|
||||
<option
|
||||
value="dev"
|
||||
>
|
||||
dev
|
||||
</option>
|
||||
<option
|
||||
value="stage"
|
||||
>
|
||||
stage
|
||||
</option>
|
||||
<option
|
||||
value="prod"
|
||||
>
|
||||
prod
|
||||
</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"
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Button, FormControl, TextField } from "@material-ui/core";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Redirect } from "react-router";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { ENVS } from "../../../utils/key-envs";
|
||||
import { ManifestsProvider, useManifestsContext } from "../../Contexts/ManifestsContext";
|
||||
import { useStatusContext } from "../../Contexts/StatusContext";
|
||||
import { useUserContext } from "../../Contexts/UserContext";
|
||||
@@ -18,6 +19,11 @@ const activeStates = [
|
||||
{value: false, label: "Archived" },
|
||||
];
|
||||
|
||||
const booleanStates = [
|
||||
{value: true, label: "True" },
|
||||
{value: false, label: "False" },
|
||||
];
|
||||
|
||||
const emptyManifest = {
|
||||
name: "",
|
||||
version: "",
|
||||
@@ -43,7 +49,8 @@ const MainForm = () => {
|
||||
const [name, setName] = useState("");
|
||||
const [type, setType] = useState("");
|
||||
const [active, setActive] = useState(true); // So !active = archived
|
||||
|
||||
const [rollback, setRollback] = useState(true);
|
||||
const [env, setEnv] = useState("current");
|
||||
|
||||
const changeName = (e) => {
|
||||
setName(e.target.value);
|
||||
@@ -57,10 +64,18 @@ const MainForm = () => {
|
||||
setActive(e.target.value === 'true')
|
||||
}
|
||||
|
||||
const changeRollback = (e) => {
|
||||
setRollback(e.target.value === 'true')
|
||||
}
|
||||
|
||||
const changeEnv = (e) => {
|
||||
setEnv(e.target.value)
|
||||
}
|
||||
|
||||
const onSubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
try {
|
||||
const result = await updateManifest(manifest_id, { name, type, active }, token);
|
||||
const result = await updateManifest(manifest_id, { name, type, active, rollback, env }, token);
|
||||
if (!result || result.error) return;
|
||||
|
||||
setMessage(`Updated manifest ${manifest_id}`);
|
||||
@@ -81,7 +96,9 @@ const MainForm = () => {
|
||||
setManifest(result);
|
||||
setName(result.name);
|
||||
setType(result.type);
|
||||
setActive(result.active)
|
||||
setActive(result.active);
|
||||
setRollback(result.rollback);
|
||||
setEnv(result.env ?? "current");
|
||||
}
|
||||
} catch (e) {
|
||||
setMessage(e.message);
|
||||
@@ -146,6 +163,10 @@ const MainForm = () => {
|
||||
/>
|
||||
<DropDownList label="Type" data={manifestTypes} classes={classes} onChange={changeType} value={type} />
|
||||
<DropDownList label="Active" data={activeStates} classes={classes} onChange={changeActive} value={active}/>
|
||||
<DropDownList label="Rollback" data={booleanStates} classes={classes} onChange={changeRollback} value={rollback}/>
|
||||
{
|
||||
ENVS.length > 1 && <DropDownList label="ECC Keys" data={ENVS} classes={classes} onChange={changeEnv} value={env}/>
|
||||
}
|
||||
<Button
|
||||
type="submit"
|
||||
aria-label="send command"
|
||||
|
||||
Reference in New Issue
Block a user