-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathupgradeAvailable.js
More file actions
106 lines (96 loc) · 3.43 KB
/
upgradeAvailable.js
File metadata and controls
106 lines (96 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { Trans } from "@lingui/macro";
import { Fragment } from "preact";
import { route } from "preact-router";
import Match from "preact-router/match";
import Loading from "components/loading";
import { useBoardData } from "utils/queries";
import { useNewVersion } from "./firmwareQueries";
export const UpgradeAvailableBanner = () => {
const { data: newVersion } = useNewVersion();
const hideReleaseBannerPlease = localStorage.getItem(
"hideReleaseBannerPlease"
);
const versionName = newVersion?.version;
if (!newVersion || hideReleaseBannerPlease === versionName) return;
return (
// @ts-ignore
<Match>
{({ path }) =>
!["firmware", "releaseInfo", "meshwideupgrade"].includes(
path.replace("/", "")
) && (
<div
className="subheader-notification"
style={{ backgroundColor: "#923853", color: "#fff" }}
>
<Trans>{versionName} is now available</Trans>
<button onClick={() => route("releaseInfo")}>
<Trans>See More</Trans>
</button>
</div>
)
}
</Match>
);
};
export const UpgradeAvailabeInfo = () => {
const { data: boardData } = useBoardData();
const { data: newVersion, isLoading } = useNewVersion();
const hideReleaseBannerPlease = localStorage.getItem(
"hideReleaseBannerPlease"
);
if (isLoading) {
return (
<div className="container container-center">
<Loading />
</div>
);
}
function onNotShowAgain(e) {
const value = e.target.checked ? newVersion.version : "show";
localStorage.setItem("hideReleaseBannerPlease", value);
}
return (
<div className="container container-padded">
<p>
<h5>
<Trans>A new firmware version has been released</Trans>
</h5>
<Trans>Currently your node has version:</Trans>
<br />
{boardData && boardData.release.description}
<br />
<Trans>You can upgrade to:</Trans>
<br />
{newVersion.version}
{newVersion["release-info-url"] && (
<Fragment>
<br />
<Trans>
More details on the release can be found at:
</Trans>
<br />
<a href={newVersion["release-info-url"]}>
{" "}
{newVersion["release-info-url"]}{" "}
</a>
</Fragment>
)}
</p>
<label>
<input
type="checkbox"
name="not-show-again"
onInput={onNotShowAgain}
checked={hideReleaseBannerPlease === newVersion.version}
/>
<Trans>Don't show this message again</Trans>
</label>
<div style={{ textAlign: "center" }}>
<button onClick={() => route("firmware")}>
<Trans>Upgrade Now</Trans>
</button>
</div>
</div>
);
};