diff --git a/plugins/lime-plugin-mesh-wide-upgrade/src/containers/meshWideUpgradeStatus.tsx b/plugins/lime-plugin-mesh-wide-upgrade/src/containers/meshWideUpgradeStatus.tsx index 8588d8d1..62ca7825 100644 --- a/plugins/lime-plugin-mesh-wide-upgrade/src/containers/meshWideUpgradeStatus.tsx +++ b/plugins/lime-plugin-mesh-wide-upgrade/src/containers/meshWideUpgradeStatus.tsx @@ -9,9 +9,8 @@ import { NoNewVersionAvailable } from "plugins/lime-plugin-mesh-wide-upgrade/src import { TransactionStarted } from "plugins/lime-plugin-mesh-wide-upgrade/src/components/upgradeState/TransactionStarted"; import { UpgradeScheduled } from "plugins/lime-plugin-mesh-wide-upgrade/src/components/upgradeState/UpgradeScheduled"; import { useMeshUpgrade } from "plugins/lime-plugin-mesh-wide-upgrade/src/hooks/meshWideUpgradeProvider"; -import { CenterFlex } from "plugins/lime-plugin-mesh-wide-upgrade/src/utils/divs"; -const MeshWideUpgradeStatusState = () => { +export const MeshWideUpgradeStatus = () => { const { stepperState, meshWideError } = useMeshUpgrade(); switch (stepperState) { @@ -71,11 +70,3 @@ const MeshWideUpgradeStatusState = () => { return ; } }; - -export const MeshWideUpgradeStatus = () => { - return ( - - - - ); -}; diff --git a/plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradePage.tsx b/plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradePage.tsx index 923008a3..116d6915 100644 --- a/plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradePage.tsx +++ b/plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradePage.tsx @@ -1,75 +1,21 @@ import { Trans } from "@lingui/macro"; -import { useState } from "preact/hooks"; import { StatusIcon } from "components/icons/status"; -import Loading from "components/loading"; +import WizardWrapper from "components/mesh-wide-wizard/WizardWrapper"; import Notification from "components/notifications/notification"; -import Tabs from "components/tabs"; import NextStepFooter from "plugins/lime-plugin-mesh-wide-upgrade/src/components/nextStepFooter"; -import { ErrorState } from "plugins/lime-plugin-mesh-wide-upgrade/src/components/upgradeState/ErrorState"; import { MeshWideUpgradeStatus } from "plugins/lime-plugin-mesh-wide-upgrade/src/containers/meshWideUpgradeStatus"; import { NodesList } from "plugins/lime-plugin-mesh-wide-upgrade/src/containers/nodesList"; import { MeshWideUpgradeProvider, useMeshUpgrade, } from "plugins/lime-plugin-mesh-wide-upgrade/src/hooks/meshWideUpgradeProvider"; -import { CenterFlex } from "plugins/lime-plugin-mesh-wide-upgrade/src/utils/divs"; - -const MeshWideUpgrade = () => { - const { - data: meshWideNodes, - isLoading, - thisNode, - isError, - error, - } = useMeshUpgrade(); - const [showNodeList, setShowNodeList] = useState(0); - - if (isError) { - return ( - - - Errors found getting mesh info! - {error &&
{error.toString()}
} - - } - /> -
- ); - } - - if (isLoading || meshWideNodes === undefined || thisNode === undefined) { - return ( - - - - ); - } - - const tabs = [ - { - key: 0, - repr: ( -
- Show state -
- ), - }, - { - key: 1, - repr: ( -
- Show nodes -
- ), - }, - ]; +const BannerNotification = () => { + const { thisNode } = useMeshUpgrade(); return ( -
+ <> Upgrade all network nodes at once. This proces will take a @@ -86,19 +32,34 @@ const MeshWideUpgrade = () => { This node aborted successfully
)} -
- -
- {showNodeList === 0 && } - {showNodeList === 1 && } -
-
- - + + ); +}; + +const MeshWideUpgrade = () => { + const { + data: meshWideNodes, + isLoading: meshUpgradeLoading, + thisNode, + isError, + error, + } = useMeshUpgrade(); + + const isLoading = + meshUpgradeLoading || + meshWideNodes === undefined || + thisNode === undefined; + + return ( + ); }; diff --git a/src/components/mesh-wide-wizard/WizardWrapper.tsx b/src/components/mesh-wide-wizard/WizardWrapper.tsx new file mode 100644 index 00000000..af59b4b4 --- /dev/null +++ b/src/components/mesh-wide-wizard/WizardWrapper.tsx @@ -0,0 +1,98 @@ +import { Trans } from "@lingui/macro"; +import { ComponentType } from "preact"; +import { useState } from "preact/hooks"; + +import Loading from "components/loading"; +import Tabs from "components/tabs"; + +import { ErrorState } from "plugins/lime-plugin-mesh-wide-upgrade/src/components/upgradeState/ErrorState"; +import { NodesList } from "plugins/lime-plugin-mesh-wide-upgrade/src/containers/nodesList"; +import { CenterFlex } from "plugins/lime-plugin-mesh-wide-upgrade/src/utils/divs"; + +interface WrapperProps { + isError: boolean; + error: unknown; + isLoading: boolean; + banner: ComponentType; + statusPage: ComponentType; + nodesList: ComponentType; + footer: ComponentType; +} + +const WizardWrapper = ({ + isError, + error, + isLoading, + banner: Banner, + statusPage: StatusPage, + nodesList: NodesList, + footer: Footer, +}: WrapperProps) => { + const [showNodeList, setShowNodeList] = useState(0); + + if (isError) { + return ( + + + Errors found getting info! + {error &&
{error.toString()}
} + + } + /> +
+ ); + } + + if (isLoading) { + return ( + + + + ); + } + + const tabs = [ + { + key: 0, + repr: ( +
+ Show state +
+ ), + }, + { + key: 1, + repr: ( +
+ Show nodes +
+ ), + }, + ]; + + return ( +
+ +
+ +
+ {showNodeList === 0 && ( + + + + )} + {showNodeList === 1 && } +
+
+
+ ); +}; + +export default WizardWrapper;