CEC-1369 Fix display of update error (#139)

* CEC-1369 Fix display of update error

* Update snapshot
This commit is contained in:
John Wu
2022-04-18 16:22:22 -07:00
committed by GitHub
parent b4d06cf52f
commit 81aeedc521
4 changed files with 84 additions and 267 deletions

View File

@@ -4,78 +4,65 @@ import Typography from "@material-ui/core/Typography";
import clsx from "clsx";
import CircularProgress from "../CircularProgress";
import s from "./Statuses";
const AwaitStatus = -1;
const ErrorStatus = -100;
const PHASES = [
{
label: "Pending",
events: ["pending"],
events: [s.Pending],
progress: () => 100,
},
{
label: "Received",
events: ["manifest_accepted", "manifest_received"],
events: [s.ManifestAccepted, s.ManifestReceived, s.ManifestRejected],
progress: () => 100,
},
{
label: "Precondition",
events: ["requirements_succeeded"],
events: [s.PreconditionAwait, s.PreconditionSuceeded],
progress: () => 100,
},
{
label: "Download",
events: [
"downloading",
"download_start",
"download_complete",
"download_error",
"package_download_start",
s.Downloading,
s.DownloadStarted,
s.DownloadCompleted,
s.DownloadFailed,
s.PackageDownloadStarted,
],
progress: (msg, progress) =>
[
"package_download_start",
"downloading",
"download_start",
"download_complete",
].indexOf(msg) > -1
? progress
: -100,
progress: (msg, progress) => {
if (msg === s.DownloadFailed) return ErrorStatus;
return progress;
},
},
{
label: "Approved",
events: ["package_download_complete", "install_approval_await"],
progress: () => -1,
events: [s.PackageDownloadCompleted, s.InstallApprovalAwait],
progress: () => AwaitStatus,
},
{
label: "Install",
events: [
"install_approval_received",
"install_start",
"installing",
"install_complete",
"install_error",
s.InstallApprovalReceived,
s.InstallStarted,
s.Installing,
s.InstallSucceeded,
s.InstallFailed,
],
progress: (msg, progress) =>
[
"install_approval_received",
"install_start",
"installing",
"install_complete",
].indexOf(msg) > -1
? progress
: -100,
},
{
label: "Clean up",
events: ["package_install_complete", "cleanup_failed"],
progress: (msg, progress) => {
if (msg === "package_install_complete") return -1;
return -100;
if (msg === s.InstallFailed) return ErrorStatus;
if (msg === s.PackageInstallCompleted) return 100;
return progress;
},
},
{
label: "Updated",
events: ["cleanup_success", "manifest_succeeded"],
progress: (msg, progress) => 100,
events: [s.ManifestSucceeded],
progress: (_msg, _progress) => 100,
},
];