diff --git a/src/components/Dashboard/Management/AppUpdates/AppUpdateProgress.jsx b/src/components/Dashboard/Management/AppUpdates/AppUpdateProgress.jsx index c456edf..170c546 100644 --- a/src/components/Dashboard/Management/AppUpdates/AppUpdateProgress.jsx +++ b/src/components/Dashboard/Management/AppUpdates/AppUpdateProgress.jsx @@ -4,6 +4,7 @@ import { Button, Flex, Modal, Progress, Typography, theme } from 'antd' import CloudIcon from '../../../Icons/CloudIcon' import HostIcon from '../../../Icons/HostIcon' +import ReloadIcon from '../../../Icons/ReloadIcon' import CheckCircleIcon from '../../../Icons/CheckCircleIcon' import XMarkCircleIcon from '../../../Icons/XMarkCircleIcon' @@ -45,6 +46,15 @@ const STAGE_CONFIG = { complete: 'Installed', error: 'Install failed' } + }, + restart: { + icon: ReloadIcon, + labels: { + pending: 'Restart', + active: 'Restarting...', + complete: 'Restarted', + error: 'Restart failed' + } } } @@ -62,20 +72,25 @@ const getDownloadStageStatus = (phase, isError) => { return 'pending' } +const isInstallComplete = (phase, message) => + phase === 'installing' && + String(message || '') + .toLowerCase() + .includes('complete') + const getInstallStageStatus = (phase, isError, message) => { if (isError && ['downloaded', 'installing'].includes(phase)) return 'error' - if ( - phase === 'installing' && - String(message || '') - .toLowerCase() - .includes('complete') - ) { - return 'complete' - } + if (isInstallComplete(phase, message)) return 'complete' if (phase === 'installing') return 'active' return 'pending' } +const getRestartStageStatus = (phase, isError, message) => { + if (isError && isInstallComplete(phase, message)) return 'error' + if (isInstallComplete(phase, message)) return 'active' + return 'pending' +} + const getProgressStatus = (stageStatus) => { if (stageStatus === 'error') return 'exception' if (stageStatus === 'complete') return 'success' @@ -101,25 +116,19 @@ const UpdateStage = ({ stage, status, percent, detail }) => { : StageIcon return ( - - - - - {config.labels[resolvedStatus]} - + + + + {config.labels[resolvedStatus]} {showProgress && ( - + - {detail && ( - - {detail} - - )} + {detail && {detail}} )} @@ -128,7 +137,7 @@ const UpdateStage = ({ stage, status, percent, detail }) => { } UpdateStage.propTypes = { - stage: PropTypes.oneOf(['download', 'install']).isRequired, + stage: PropTypes.oneOf(['download', 'install', 'restart']).isRequired, status: PropTypes.oneOf(['pending', 'active', 'complete', 'error']) .isRequired, percent: PropTypes.number, @@ -150,6 +159,7 @@ const AppUpdateProgress = ({ progress, update, onClose }) => { const downloadStatus = getDownloadStageStatus(phase, isError) const installStatus = getInstallStageStatus(phase, isError, message) + const restartStatus = getRestartStageStatus(phase, isError, message) const downloadPercent = downloadStatus === 'active' ? (phase === 'preparing' ? 0 : percent) : null @@ -163,6 +173,8 @@ const AppUpdateProgress = ({ progress, update, onClose }) => { const installDetail = installStatus === 'active' ? message : null + const restartDetail = restartStatus === 'active' ? message : null + return ( @@ -185,6 +197,11 @@ const AppUpdateProgress = ({ progress, update, onClose }) => { percent={installPercent} detail={installDetail} /> +