diff --git a/packages/admin-portal/src/components/keys-ceremony/TrusteeWizard.tsx b/packages/admin-portal/src/components/keys-ceremony/TrusteeWizard.tsx index 20b4b782bda..a872cd357c5 100644 --- a/packages/admin-portal/src/components/keys-ceremony/TrusteeWizard.tsx +++ b/packages/admin-portal/src/components/keys-ceremony/TrusteeWizard.tsx @@ -8,6 +8,7 @@ import { IKeysCeremonyExecutionStatus as EStatus, IKeysCeremonyTrusteeStatus as TStatus, IExecutionStatus, + isKeysCeremonyTerminal, } from "@/services/KeyCeremony" import {Sequent_Backend_Election_Event, Sequent_Backend_Keys_Ceremony} from "@/gql/graphql" import {Alert, CircularProgress} from "@mui/material" @@ -74,21 +75,18 @@ export const TrusteeWizard: React.FC = ({ status.public_key !== undefined && currentCeremony.execution_status === EStatus.IN_PROGRESS && !status.trustees.find((trustee) => trustee.status === TStatus.WAITING) + const ceremonyTerminal = isKeysCeremonyTerminal(currentCeremony.execution_status as EStatus) const calculateCurrentStep: () => WizardStep = () => { + if (ceremonyTerminal) { + return WizardStep.Status + } // If trustee is not participating, show status step if (!trusteeParticipating) { return WizardStep.Status - // If trustee is participating but is not started, show status step } else if (currentCeremony.execution_status === EStatus.USER_CONFIGURATION) { return WizardStep.Status - // If trustee is participating but is not started, show status step - } else if ( - currentCeremony.execution_status === EStatus.CANCELLED || - currentCeremony.execution_status === EStatus.SUCCESS - ) { - return WizardStep.Success - // if the trustee has not checked the key, then show the start screen + // If the trustee has not checked the key, then show the start screen } else if ( currentCeremony.execution_status === EStatus.IN_PROGRESS && !trusteeCheckedKeys @@ -102,14 +100,16 @@ export const TrusteeWizard: React.FC = ({ const [currentStep, setCurrentStep] = useState(calculateCurrentStep()) useEffect(() => { - if (!trusteeCheckedKeys && trusteeParticipating && keysGenerated) { + if (ceremonyTerminal) { + setCurrentStep(WizardStep.Status) + } else if (!trusteeCheckedKeys && trusteeParticipating && keysGenerated) { setCurrentStep(WizardStep.Start) } else if (!keysGenerated) { setCurrentStep(WizardStep.Not_Generated) } else { setCurrentStep(WizardStep.Status) } - }, [trusteeCheckedKeys, trusteeParticipating, keysGenerated]) + }, [ceremonyTerminal, trusteeCheckedKeys, trusteeParticipating, keysGenerated]) const checkKeysGenerated = () => { return !trusteeCheckedKeys && trusteeParticipating && !keysGenerated diff --git a/packages/admin-portal/src/services/KeyCeremony.ts b/packages/admin-portal/src/services/KeyCeremony.ts index 9e28602174d..56fc449430d 100644 --- a/packages/admin-portal/src/services/KeyCeremony.ts +++ b/packages/admin-portal/src/services/KeyCeremony.ts @@ -22,6 +22,10 @@ export enum IKeysCeremonyTrusteeStatus { KEY_CHECKED = "KEY_CHECKED", } +export const isKeysCeremonyTerminal = (status: IKeysCeremonyExecutionStatus): boolean => + status === IKeysCeremonyExecutionStatus.SUCCESS || + status === IKeysCeremonyExecutionStatus.CANCELLED + export interface IKeysCeremonyTrustee { name: string status: IKeysCeremonyTrusteeStatus diff --git a/packages/admin-portal/src/services/keysCeremonyTerminal.test.ts b/packages/admin-portal/src/services/keysCeremonyTerminal.test.ts new file mode 100644 index 00000000000..e031dd124fa --- /dev/null +++ b/packages/admin-portal/src/services/keysCeremonyTerminal.test.ts @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2026 Sequent Tech Inc +// +// SPDX-License-Identifier: AGPL-3.0-only + +import {IKeysCeremonyExecutionStatus as EStatus, isKeysCeremonyTerminal} from "./KeyCeremony" + +describe("isKeysCeremonyTerminal", () => { + it.each([EStatus.SUCCESS, EStatus.CANCELLED])("recognizes terminal status %s", (status) => { + expect(isKeysCeremonyTerminal(status)).toBe(true) + }) + + it.each([EStatus.USER_CONFIGURATION, EStatus.STARTED, EStatus.IN_PROGRESS])( + "rejects active status %s", + (status) => { + expect(isKeysCeremonyTerminal(status)).toBe(false) + } + ) +})