diff --git a/messages/en-US.json b/messages/en-US.json index 58552e197..d731de318 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -2526,6 +2526,7 @@ "pangolinUpdateAvailableReleaseNotes": "View Release Notes", "newtUpdateAvailable": "Update Available", "newtUpdateAvailableInfo": "A new version of Newt is available. Please update to the latest version for the best experience.", + "cliUpdateAvailableInfo": "A new version of the Pangolin CLI is available. Please update to the latest version for the best experience.", "pangolinNodeUpdateAvailableInfo": "A new version of Pangolin Node is available. Please update to the latest version for the best experience.", "domainPickerEnterDomain": "Domain", "domainPickerPlaceholder": "myapp.example.com", diff --git a/src/components/SitesTable.tsx b/src/components/SitesTable.tsx index 6e125d1bd..aa9fd2d2d 100644 --- a/src/components/SitesTable.tsx +++ b/src/components/SitesTable.tsx @@ -133,8 +133,6 @@ export default function SitesTable({ productUpdatesQueries.latestVersion(true) ); - const latestNewtVersion = latestVersions?.data?.newt?.latestVersion; - const booleanSearchFilterSchema = z .enum(["true", "false"]) .optional() @@ -378,13 +376,6 @@ export default function SitesTable({ cell: ({ row }) => { const originalRow = row.original; - const updateAvailable = Boolean( - latestNewtVersion && - originalRow.newtVersion && - semver.valid(originalRow.newtVersion) && - semver.lt(originalRow.newtVersion, latestNewtVersion) - ); - if (originalRow.type === "newt") { if (!originalRow.agent && !originalRow.newtVersion) { // it has not checked in yet @@ -394,25 +385,42 @@ export default function SitesTable({ // site still running an older Newt reports only newtVersion. // Without these fallbacks the badge renders with no label and // no version at all. - const agentLabel = - originalRow.agent == "cli" - ? "Pangolin CLI" - : "Newt"; - const agentVersion = + const isCli = originalRow.agent === "cli"; + const agentLabel = isCli ? "Pangolin CLI" : "Newt"; + const displayedVersion = originalRow.agentVersion ?? originalRow.newtVersion; + // CLI sites report their own version in agentVersion. Older + // Newt installs only have newtVersion. + const comparedVersion = isCli + ? originalRow.agentVersion + : displayedVersion; + const latestVersion = isCli + ? latestVersions?.data?.cli?.latestVersion + : latestVersions?.data?.newt?.latestVersion; + const updateAvailable = Boolean( + latestVersion && + comparedVersion && + semver.valid(comparedVersion) && + semver.valid(latestVersion) && + semver.lt(comparedVersion, latestVersion) + ); return (