Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
a02e218
chore(meshupgrade): bootstrap mes wide upgrade
selankon Jul 11, 2023
4227a95
chore(meshupgrade): create list component
selankon Jul 11, 2023
27d59eb
chore(meshupgrade): implement notification
selankon Jul 12, 2023
35d2e15
chore(meshupgrade): refactor to rehuse the footer component
selankon Jul 14, 2023
a947912
chore(meshupgrade): create next step footer
selankon Jul 14, 2023
80b3e61
chore(meshupgrade): add mocks
selankon Jul 14, 2023
4700c6f
chore(meshupgrade): create node upgrade detail
selankon Jul 17, 2023
a315896
chore(meshupgrade): fix rebase
selankon Dec 11, 2023
ec4cd82
chore(meshupgrade): implement get upgrade status query
selankon Jan 10, 2024
dcdfe8f
chore(meshupgrade): wip update of status messages
selankon Jan 12, 2024
c656af4
chore(meshupgrade): create status page
selankon Jan 15, 2024
995b22a
chore(meshupgrade): hide release banner
selankon Jan 15, 2024
60efaf0
chore(meshupgrade): implement no new version available
selankon Jan 15, 2024
f414e4d
chore(meshupgrade): wrap logic into mes wide provider
selankon Jan 16, 2024
a50c706
chore(meshupgrade): create stepper status
selankon Jan 23, 2024
e9a7d10
chore(meshupgrade): create mesh up. mutations
selankon Jan 23, 2024
73c8d96
chore(meshupgrade): implement footer steps
selankon Jan 23, 2024
52db76c
chore(meshupgrade): implement _meshUpgradeApiCall
selankon Jan 25, 2024
a3398c8
chore(meshupgrade): implement become_main_node
selankon Jan 25, 2024
50c07c7
chore(meshupgrade): fix bad parse
selankon Jan 25, 2024
2075eb9
chore(meshupgrade): implement download status interval
selankon Feb 1, 2024
c3ab75d
chore(meshupgrade): refactor with new types
selankon Feb 2, 2024
cbd289a
chore(meshupgrade): implement some steps
selankon Feb 5, 2024
dc37561
chore(meshupgrade): expose startFwUpgradeTransaction
selankon Feb 5, 2024
bf3e38a
chore(meshupgrade): implement error page
selankon Feb 6, 2024
aa353d7
chore(meshupgrade): fix error message
selankon Feb 7, 2024
14c334a
chore(meshupgrade): Update translation messages
selankon Feb 7, 2024
cd20194
chore(meshupgrade): invalidate queries after mutation
selankon Feb 7, 2024
fa2faaa
chore(meshupgrade): implement TRANSACTION_STARTED state
selankon Feb 16, 2024
6e57cb8
chore(meshupgrade): improve info messages
selankon Feb 19, 2024
8031dbc
chore(meshupgrade): create schedule modal
selankon Feb 19, 2024
cd0e4ba
chore(mesh-upgrade): implement parallel mutations
selankon Feb 27, 2024
a214647
chore(meshupgrade): extract mesh wide sync calls
selankon Feb 28, 2024
10752da
chore(meshupgrade): fix lint
selankon Feb 28, 2024
7255300
chore(meshupgrade): refactor function places
selankon Feb 28, 2024
086a295
chore(meshupgrade): refactor file names
selankon Feb 28, 2024
411a686
chore(meshupgrade): extrapolate stepper logic
selankon Feb 28, 2024
0ed7bb1
chore(meshupgrade): implement cache for useMeshWideSyncCall
selankon Feb 28, 2024
f2f8f3b
chore(meshupgrade): cache isLoading state
selankon Mar 1, 2024
8c982b9
chore(meshupgrade): implement SENDING_START_SCHEDULE state
selankon Mar 1, 2024
93f3ff0
chore(meshupgrade): avoid multiple mutatoin results calls
selankon Mar 1, 2024
d10efca
chore(meshupgrade): Implement upgrade scheduled
selankon Mar 1, 2024
7ba04ba
chore(meshupgrade): Fix layout problems
selankon Mar 4, 2024
c431814
chore(meshupgrade): Refactor useStepper name
selankon Mar 4, 2024
1356e61
chore(meshupgrade): Improve error messages
selankon Mar 4, 2024
681b3f5
chore(meshupgrade): Fix null aware
selankon Mar 5, 2024
831d12f
chore(meshupgrade): Refactor query name
selankon Mar 5, 2024
9526dbb
chore(meshupgrade): Fix error messages
selankon Mar 5, 2024
0c21868
chore(meshupgrade): Implement confirmation
selankon Mar 5, 2024
cda725d
chore(meshupgrade): minor fixes
selankon Mar 5, 2024
6ef3a57
chore(meshupgrade): minor fixes
selankon Mar 6, 2024
f114ca1
chore(meshupgrade): Add error state
selankon Mar 6, 2024
30ba134
chore(meshupgrade): use util div layout
selankon Mar 6, 2024
87a6f35
chore(meshupgrade): show error message
selankon Mar 6, 2024
fb8c1bc
chore(meshupgrade): create nodes downloading state
selankon Mar 6, 2024
93a5b81
chore(meshupgrade): close modal after run
selankon Mar 6, 2024
204e89a
chore(meshupgrade): add missing ConfirmationPending component
selankon Mar 6, 2024
35e7f95
chore(meshupgrade): fix modal callbacks
selankon Mar 6, 2024
e916dd6
chore(meshupgrade): fix node upgrade
selankon Mar 12, 2024
9a3de41
chore(meshupgrade): fix eupgrade timer
selankon Mar 12, 2024
35da32c
chore(meshupgrade): update confirmation messages
selankon Mar 12, 2024
a50aab9
chore(meshupgrade): filter ips by status
selankon Mar 13, 2024
fc5898f
chore(meshupgrade): move to util
selankon Mar 13, 2024
b4d1d30
chore(meshupgrade): separate query keys
selankon Mar 13, 2024
b1cd9e6
chore(meshupgrade): implement upgrading state
selankon Mar 13, 2024
0d6c0ef
chore(meshupgrade): implement re login after upgrade
selankon Mar 13, 2024
4cf3849
chore(meshupgrade): fix confirmation pending
selankon Mar 22, 2024
cadf709
chore(meshupgrade): show download-error
selankon Mar 22, 2024
b39f7ea
chore(meshupgrade): fix some names
selankon Mar 22, 2024
d795b2f
chore(meshupgrade): implement aborted
selankon Mar 25, 2024
faf8f30
chore(meshupgrade): improve aborted banner
selankon Mar 26, 2024
a588ccd
chore(meshupgrade): migrate to shared state async
selankon May 6, 2024
a0d3a94
chore(meshupgrade): multiple fix
selankon May 6, 2024
246c225
chore(meshupgrade): fix rebase
selankon May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/lime-plugin-firmware/src/upgradeAvailable.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const UpgradeAvailableBanner = () => {
// @ts-ignore
<Match>
{({ path }) =>
!["firmware", "releaseInfo"].includes(
!["firmware", "releaseInfo", "meshwideupgrade"].includes(
path.replace("/", "")
) && (
<div
Expand Down
7 changes: 7 additions & 0 deletions plugins/lime-plugin-mesh-wide-upgrade/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import MeshUpgradePage from "plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradePage";

export default {
name: "MeshWideUpgrade",
page: MeshUpgradePage,
isCommunityProtected: true,
} as LimePlugin;
96 changes: 96 additions & 0 deletions plugins/lime-plugin-mesh-wide-upgrade/src/components/modals.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { Trans } from "@lingui/macro";
import { VNode } from "preact";
import { useCallback } from "react";

import { useModal } from "components/Modal/Modal";

export const useScheduleUpgradeModal = ({
allNodesReady,
cb,
}: IUseParallelQueriesModalProps) => {
let title = <Trans>All nodes are ready</Trans>;
let content = (
<Trans>Schedule a firmware upgrade for all nodes on the network</Trans>
);
if (!allNodesReady) {
title = <Trans>Some nodes are not ready</Trans>;
content = (
<Trans>
Are you sure you want to start mesh wide upgrade? <br />
Check node list to see the network status
</Trans>
);
}

return useParallelQueriesModal({
allNodesReady,
cb,
title,
content,
});
};

export const useConfirmModal = ({
allNodesReady,
cb,
}: IUseParallelQueriesModalProps) => {
let title = <Trans>All nodes are upgraded successfully</Trans>;
let content = (
<Trans>Confirm mesh wide upgrade for all nodes on the network</Trans>
);
if (!allNodesReady) {
title = <Trans>Some nodes don't upgraded properly</Trans>;
content = (
<Trans>
Are you sure you want to confirm the upgrade? <br />
Check node list to see the network status
</Trans>
);
}
return useParallelQueriesModal({
allNodesReady,
cb,
title,
content,
});
};

interface IUseParallelQueriesModalProps {
allNodesReady: boolean;
cb?: (e) => void;
title?: VNode;
content?: VNode;
}

const useParallelQueriesModal = ({
allNodesReady,
cb,
title,
content,
}: IUseParallelQueriesModalProps) => {
const { toggleModal, setModalState } = useModal();
const runAndClose = useCallback(() => {
cb(null);
toggleModal();
}, [cb, toggleModal]);

const showModal = useCallback(() => {
setModalState({
content,
title,
successCb: allNodesReady ? runAndClose : undefined,
deleteCb: !allNodesReady ? runAndClose : undefined,
successBtnText: <Trans>Schedule</Trans>,
deleteBtnText: <Trans>Schedule</Trans>,
});
toggleModal();
}, [
setModalState,
content,
title,
allNodesReady,
runAndClose,
toggleModal,
]);
return { showModal, toggleModal };
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { FooterStatus } from "components/status/footer";

import { useStep } from "plugins/lime-plugin-mesh-wide-upgrade/src/hooks/useStepper";

const NextStepFooter = () => {
const { step, showFooter } = useStep();

return <>{showFooter && <FooterStatus {...step} fixed={false} />}</>;
};

export default NextStepFooter;
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Trans } from "@lingui/macro";
import { ComponentChildren } from "preact";

import { StatusIcon, StatusIcons } from "components/icons/status";
import { ListItemCollapsible } from "components/list-material";

import { MeshWideNodeUpgradeInfo } from "plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeTypes";
import {
InfoStatusMessageMap,
detailedInfoStatusMessageMap,
mainNodeStatusMessageMap,
} from "plugins/lime-plugin-mesh-wide-upgrade/src/utils/upgradeStatusMessages";

export interface INodeInfoBodyItemProps {
title: ComponentChildren;
description: ComponentChildren;
}

const NodeInfoBodyItem = ({ title, description }: INodeInfoBodyItemProps) => (
<div className="flex flex-col">
<div className="font-semibold">{title}</div>
<div className="text-gray-600">{description}</div>
</div>
);

const NodeUpgradeInfoItem = ({
info,
name,
}: {
info: MeshWideNodeUpgradeInfo;
name: string;
}) => {
const status: StatusIcons =
info.upgrade_state === "ERROR" ? "warning" : "success";

const nodeStatusInfo =
detailedInfoStatusMessageMap(info)[info.upgrade_state] ??
detailedInfoStatusMessageMap()["DEFAULT"];

const mainNodeStatusInfo = mainNodeStatusMessageMap[info.main_node];
let descriptionMsg = InfoStatusMessageMap[info.upgrade_state] ?? (
<Trans>Error retrieving the status, is this node outdated?</Trans>
);
if (mainNodeStatusInfo) {
descriptionMsg = <Trans>(Main Node) {descriptionMsg}</Trans>;
}
return (
<ListItemCollapsible
title={name}
description={descriptionMsg}
leftComponent={<StatusIcon status={status} />}
rightText={"Info"}
>
<NodeInfoBodyItem {...nodeStatusInfo} />
{mainNodeStatusInfo && <NodeInfoBodyItem {...mainNodeStatusInfo} />}
<NodeInfoBodyItem
title={<Trans>Board</Trans>}
description={<Trans>{info.board_name}</Trans>}
/>
<NodeInfoBodyItem
title={<Trans>Firmware version</Trans>}
description={<Trans>{info.current_fw}</Trans>}
/>
<NodeInfoBodyItem
title={<Trans>Ip</Trans>}
description={<Trans>{info.node_ip}</Trans>}
/>
</ListItemCollapsible>
);
};

export default NodeUpgradeInfoItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Trans } from "@lingui/macro";

import { ParallelErrors } from "plugins/lime-plugin-mesh-wide-upgrade/src/components/upgradeState/ParallelErrors";
import { useParallelConfirmUpgrade } from "plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeQueries";

export const ConfirmationPending = () => {
const { errors } = useParallelConfirmUpgrade();

return (
<>
<div className="text-4xl mb-4">
<Trans>Upgrade done</Trans>
</div>
<div className="text-2xl mb-6">
<Trans>
Check if network is working properly and confirm the upgrade
<br />
If not confirmed, the upgrade will be rolled back after a
while
</Trans>
</div>
{errors?.length > 0 && <ParallelErrors errors={errors} />}
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Trans } from "@lingui/macro";
import { VNode } from "preact";

export const ErrorState = ({ msg }: { msg: string | VNode }) => {
return (
<div className="text-center ">
<div className="w-32 h-32 text-9xl rounded-full border-2 border-danger text-danger flex items-center justify-center mx-auto">
!
</div>
<div className="text-4xl">
<Trans>Error!</Trans>
</div>
<div className="text-2xl">{msg}</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { VNode } from "preact";

import Loading from "components/loading";

export const LoadingPage = ({
title,
description,
}: {
title: VNode;
description?: VNode;
}) => {
return (
<div className="text-center">
<Loading />
<div className="text-4xl">{title}</div>
{description && <div className="text-2xl">{description}</div>}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Trans } from "@lingui/macro";

import { useNewVersion } from "plugins/lime-plugin-firmware/src/firmwareQueries";

import { useBoardData } from "utils/queries";

export const NewVersionAvailable = ({
readyForUpgrade,
}: {
readyForUpgrade?: boolean;
}) => {
const { data: boardData } = useBoardData();
const { data: newVersion } = useNewVersion();

return (
<div className="text-center">
<div className="text-4xl">
{readyForUpgrade ? (
<Trans>Start Mesh Wide Transaction</Trans>
) : (
<Trans>New version available!</Trans>
)}
</div>
<div className="text-2xl">
<Trans>This node version:</Trans>
<br />
{boardData && boardData.release.description}
</div>
<div className="text-2xl">
<Trans>New available version:</Trans>
<br />
{newVersion && newVersion.version}
</div>
{readyForUpgrade && (
<div className="text-2xl">
<Trans>Is ready for upgrade!</Trans>
<br />
</div>
)}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Trans } from "@lingui/macro";

import { useNewVersion } from "plugins/lime-plugin-firmware/src/firmwareQueries";

import { useBoardData } from "utils/queries";

export const NoNewVersionAvailable = () => {
const { data: boardData } = useBoardData();
const { data: newVersion } = useNewVersion();

return (
<div className="text-center ">
<div className="text-9xl text-primary-light">✓</div>
<div className="text-4xl">
<Trans>No new version available!</Trans>
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Trans } from "@lingui/macro";

import { StatusMessage } from "components/status/statusMessage";

import { ParallelMutationError, SyncCallErrors } from "utils/meshWideSyncCall";

export const ParallelErrors = ({ errors }: { errors: SyncCallErrors }) => {
return (
// Important to not add any style to this fragment because could add errors on growing on long lists
<>
<StatusMessage status={"warning"}>
<Trans>Some nodes have errors:</Trans>
</StatusMessage>
<div className={"flex flex-col gap-3 mt-4 overflow-auto gap-4"}>
{errors.map((error, key) => {
if (error instanceof ParallelMutationError) {
return (
<div key={key}>
<strong>{error.ip}</strong>: {error.message}
</div>
);
}
return <div key={key}>{error.toString()}</div>;
})}
</div>
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { useMeshUpgrade } from "plugins/lime-plugin-mesh-wide-upgrade/src/hooks/meshWideUpgradeProvider";

export const TransactionStarted = () => {
const { someNodeDownloading } = useMeshUpgrade();

return (
<div>
Transaction started!
{someNodeDownloading && (
<div>
Some nodes seems to be downloading, check network page for
more information
</div>
)}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Trans } from "@lingui/macro";

import { ParallelErrors } from "plugins/lime-plugin-mesh-wide-upgrade/src/components/upgradeState/ParallelErrors";
import { useMeshUpgrade } from "plugins/lime-plugin-mesh-wide-upgrade/src/hooks/meshWideUpgradeProvider";
import { useParallelScheduleUpgrade } from "plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeQueries";

export const UpgradeScheduled = () => {
const { totalNodes } = useMeshUpgrade();
const { errors, results } = useParallelScheduleUpgrade();
const nodesToBeUpgraded = results.length;

return (
<>
<div className="text-4xl mb-4">
<Trans>Upgrade is scheduled!</Trans>
</div>
<div className="text-2xl mb-6">
<Trans>
{nodesToBeUpgraded} of {totalNodes} will be upgraded
</Trans>
</div>
{errors?.length > 0 && <ParallelErrors errors={errors} />}
</>
);
};
Loading