Skip to content

Commit 0fef40b

Browse files
fix(web): show device versions on their corresponding settings rows
1 parent 49a29a6 commit 0fef40b

2 files changed

Lines changed: 57 additions & 26 deletions

File tree

‎apps/web/src/components/device/DeviceToolVersions.tsx‎

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,66 @@
11
import type { DeviceToolVersions as ToolVersions } from "@t3tools/contracts";
22
import { Popover, PopoverPopup, PopoverTitle, PopoverTrigger } from "~/components/ui/popover";
33

4-
export function DeviceToolVersions({ tools }: { tools: ToolVersions | undefined }) {
4+
export function DeviceToolVersions({
5+
tools,
6+
kind,
7+
}: {
8+
tools: ToolVersions | undefined;
9+
kind?: keyof ToolVersions;
10+
}) {
11+
const selected = kind ? tools?.[kind] : undefined;
12+
const version =
13+
selected?.runningVersion ??
14+
(selected?.installedVersions.includes(selected.requiredVersion)
15+
? selected.requiredVersion
16+
: selected?.installedVersions
17+
.toSorted((a, b) => a.localeCompare(b, undefined, { numeric: true }))
18+
.at(-1));
19+
const label = kind === "hub" ? "Device hub" : "Agent device";
520
return (
621
<Popover>
7-
<PopoverTrigger className="rounded text-xs text-muted-foreground underline decoration-muted-foreground/40 underline-offset-4 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring">
8-
Versions
22+
<PopoverTrigger
23+
aria-label={
24+
kind
25+
? `${label}: ${version ? `version ${version}` : selected ? "not installed" : "version unknown"}. Show details`
26+
: undefined
27+
}
28+
className="rounded text-xs text-muted-foreground underline decoration-muted-foreground/40 underline-offset-4 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"
29+
>
30+
{kind
31+
? version
32+
? `v${version}`
33+
: selected
34+
? "Not installed"
35+
: "Version unknown"
36+
: "Versions"}
937
</PopoverTrigger>
1038
<PopoverPopup align="end" className="w-80">
11-
<PopoverTitle className="text-sm">Device tools</PopoverTitle>
39+
<PopoverTitle className="text-sm">{kind ? label : "Device tools"}</PopoverTitle>
1240
{tools ? (
1341
<div className="mt-4 divide-y divide-border/50">
1442
{(
1543
[
1644
["Device hub", tools.hub],
1745
["Agent device", tools.agent],
1846
] as const
19-
).map(([name, tool]) => (
20-
<div key={name} className="space-y-2 py-3 first:pt-0 last:pb-0">
21-
<p className="text-xs font-medium">{name}</p>
22-
<dl className="grid grid-cols-[auto_1fr] gap-x-6 gap-y-1 text-xs">
23-
<dt className="text-muted-foreground">Running</dt>
24-
<dd className="text-right font-mono">{tool.runningVersion ?? "Not running"}</dd>
25-
<dt className="text-muted-foreground">Required</dt>
26-
<dd className="text-right font-mono">{tool.requiredVersion}</dd>
27-
<dt className="text-muted-foreground">Installed</dt>
28-
<dd className="text-right font-mono break-words">
29-
{tool.installedVersions.join(", ") || "None"}
30-
</dd>
31-
</dl>
32-
</div>
33-
))}
47+
)
48+
.filter(([name]) => !kind || name === label)
49+
.map(([name, tool]) => (
50+
<div key={name} className="space-y-2 py-3 first:pt-0 last:pb-0">
51+
<p className="text-xs font-medium">{name}</p>
52+
<dl className="grid grid-cols-[auto_1fr] gap-x-6 gap-y-1 text-xs">
53+
<dt className="text-muted-foreground">Running</dt>
54+
<dd className="text-right font-mono">{tool.runningVersion ?? "Not running"}</dd>
55+
<dt className="text-muted-foreground">Required</dt>
56+
<dd className="text-right font-mono">{tool.requiredVersion}</dd>
57+
<dt className="text-muted-foreground">Installed</dt>
58+
<dd className="text-right font-mono break-words">
59+
{tool.installedVersions.join(", ") || "None"}
60+
</dd>
61+
</dl>
62+
</div>
63+
))}
3464
</div>
3565
) : (
3666
<p className="mt-3 text-xs text-muted-foreground">Versions have not been checked.</p>

‎apps/web/src/components/settings/IntegrationsSettings.tsx‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ function DeviceIntegrationControls({
693693
description={deviceHubDescription}
694694
control={
695695
<>
696+
<DeviceToolVersions
697+
kind="hub"
698+
tools={state.hosts.find((host) => host.kind === "local")?.tools}
699+
/>
696700
{pending === "hub" ? <DeviceHubSetupStatus state={state} pending compact /> : null}
697701
<ScopedSwitch
698702
settingKeys={["enableDeviceSupport"]}
@@ -752,6 +756,10 @@ function DeviceIntegrationControls({
752756
description={agentDeviceDescription}
753757
control={
754758
<>
759+
<DeviceToolVersions
760+
kind="agent"
761+
tools={state.hosts.find((host) => host.kind === "local")?.tools}
762+
/>
755763
{pending === "agent" ? <AgentDeviceSetupStatus state={state} pending compact /> : null}
756764
<ScopedSwitch
757765
settingKeys={["enableAgentDeviceAccess"]}
@@ -776,13 +784,6 @@ function DeviceIntegrationControls({
776784
{state.hostStatusDetail}
777785
</p>
778786
) : null}
779-
<SettingsRow
780-
title="Device tool versions"
781-
description="Versions required by this environment's server."
782-
control={
783-
<DeviceToolVersions tools={state.hosts.find((host) => host.kind === "local")?.tools} />
784-
}
785-
/>
786787
<DeviceHostsSettings environmentId={environmentId} />
787788
</>
788789
);

0 commit comments

Comments
 (0)