2023-11-28 13:15:19 -05:00
|
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
2023-11-15 16:04:44 -05:00
|
|
|
|
import React from "react"
|
2023-12-06 00:26:34 -05:00
|
|
|
|
import { VersionInfo } from "src/types"
|
2023-12-04 15:20:38 -05:00
|
|
|
|
import Button from "src/ui/button"
|
2023-12-07 20:00:36 -05:00
|
|
|
|
import Card from "src/ui/card"
|
2023-12-04 15:20:38 -05:00
|
|
|
|
import { useLocation } from "wouter"
|
2023-11-15 16:04:44 -05:00
|
|
|
|
|
|
|
|
|
export function UpdateAvailableNotification({
|
|
|
|
|
details,
|
|
|
|
|
}: {
|
|
|
|
|
details: VersionInfo
|
|
|
|
|
}) {
|
2023-12-04 15:20:38 -05:00
|
|
|
|
const [, setLocation] = useLocation()
|
|
|
|
|
|
2023-11-15 16:04:44 -05:00
|
|
|
|
return (
|
2023-12-07 20:00:36 -05:00
|
|
|
|
<Card>
|
2023-11-15 16:04:44 -05:00
|
|
|
|
<h2 className="mb-2">
|
|
|
|
|
Update available{" "}
|
|
|
|
|
{details.LatestVersion && `(v${details.LatestVersion})`}
|
|
|
|
|
</h2>
|
|
|
|
|
<p className="text-sm mb-1 mt-1">
|
|
|
|
|
{details.LatestVersion
|
|
|
|
|
? `Version ${details.LatestVersion}`
|
|
|
|
|
: "A new update"}{" "}
|
|
|
|
|
is now available. <ChangelogText version={details.LatestVersion} />
|
|
|
|
|
</p>
|
2023-12-04 15:20:38 -05:00
|
|
|
|
<Button
|
|
|
|
|
className="mt-3 inline-block"
|
|
|
|
|
sizeVariant="small"
|
|
|
|
|
onClick={() => setLocation("/update")}
|
2023-11-15 16:04:44 -05:00
|
|
|
|
>
|
|
|
|
|
Update now
|
2023-12-04 15:20:38 -05:00
|
|
|
|
</Button>
|
2023-12-07 20:00:36 -05:00
|
|
|
|
</Card>
|
2023-11-15 16:04:44 -05:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// isStableTrack takes a Tailscale version string
|
|
|
|
|
// of form X.Y.Z (or vX.Y.Z) and returns whether
|
|
|
|
|
// it is a stable release (even value of Y)
|
|
|
|
|
// or unstable (odd value of Y).
|
|
|
|
|
// eg. isStableTrack("1.48.0") === true
|
|
|
|
|
// eg. isStableTrack("1.49.112") === false
|
|
|
|
|
function isStableTrack(ver: string): boolean {
|
|
|
|
|
const middle = ver.split(".")[1]
|
|
|
|
|
if (middle && Number(middle) % 2 === 0) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function ChangelogText({ version }: { version?: string }) {
|
|
|
|
|
if (!version || !isStableTrack(version)) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
Check out the{" "}
|
|
|
|
|
<a href="https://tailscale.com/changelog/" className="link">
|
|
|
|
|
release notes
|
|
|
|
|
</a>{" "}
|
2024-02-08 10:09:26 -08:00
|
|
|
|
to find out what’s new!
|
2023-11-15 16:04:44 -05:00
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|