Skip to content

Commit ba95d1d

Browse files
fix(web): keep version checks with device settings
1 parent 18a7e74 commit ba95d1d

2 files changed

Lines changed: 24 additions & 26 deletions

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
import type { ReactNode } from "react";
12
import type { DeviceToolVersions as ToolVersions } from "@t3tools/contracts";
23
import { Popover, PopoverPopup, PopoverTitle, PopoverTrigger } from "~/components/ui/popover";
34

45
export function DeviceToolVersions({
56
tools,
7+
action,
68
kind,
79
owner,
810
error,
911
}: {
1012
tools: ToolVersions | undefined;
13+
action?: ReactNode;
1114
kind?: keyof ToolVersions;
1215
owner?: string | undefined;
1316
error?: string | undefined;
@@ -37,7 +40,9 @@ export function DeviceToolVersions({
3740
: selected
3841
? "Not installed"
3942
: "Version unknown"
40-
: "Versions"}
43+
: error
44+
? "Versions unavailable"
45+
: "Versions"}
4146
</PopoverTrigger>
4247
<PopoverPopup align="end" className="w-80">
4348
<PopoverTitle className="text-sm">{kind ? label : "Device tools"}</PopoverTitle>
@@ -77,6 +82,7 @@ export function DeviceToolVersions({
7782
{error}
7883
</p>
7984
) : null}
85+
{action ? <div className="mt-3">{action}</div> : null}
8086
</PopoverPopup>
8187
</Popover>
8288
);

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

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,21 @@ function DeviceIntegrationControls({
685685
}
686686
};
687687

688+
const checkVersions = state.supportsToolInspection ? (
689+
<Button
690+
size="sm"
691+
variant="outline"
692+
disabled={!environmentId || pending !== null || busy}
693+
onClick={() => {
694+
if (!environmentId) return;
695+
setPending("check");
696+
void list({ environmentId, input: { inspectOnly: true } }).finally(() => setPending(null));
697+
}}
698+
>
699+
{pending === "check" ? "Checking…" : "Check versions"}
700+
</Button>
701+
) : null;
702+
688703
return (
689704
<>
690705
<SettingsRow
@@ -695,6 +710,7 @@ function DeviceIntegrationControls({
695710
control={
696711
<>
697712
<DeviceToolVersions
713+
action={checkVersions}
698714
kind="hub"
699715
tools={state.hosts.find((host) => host.kind === "local")?.tools}
700716
/>
@@ -758,6 +774,7 @@ function DeviceIntegrationControls({
758774
control={
759775
<>
760776
<DeviceToolVersions
777+
action={checkVersions}
761778
kind="agent"
762779
tools={state.hosts.find((host) => host.kind === "local")?.tools}
763780
/>
@@ -780,31 +797,6 @@ function DeviceIntegrationControls({
780797
</>
781798
}
782799
/>
783-
<SettingsRow
784-
title="Device tools"
785-
description="Managed by this environment. Updates install automatically when needed."
786-
control={
787-
<div className="flex items-center gap-4">
788-
<DeviceToolVersions tools={state.hosts.find((host) => host.kind === "local")?.tools} />
789-
{state.supportsToolInspection ? (
790-
<Button
791-
size="sm"
792-
variant="outline"
793-
disabled={!environmentId || pending !== null || busy}
794-
onClick={() => {
795-
if (!environmentId) return;
796-
setPending("check");
797-
void list({ environmentId, input: { inspectOnly: true } }).finally(() =>
798-
setPending(null),
799-
);
800-
}}
801-
>
802-
{pending === "check" ? "Checking…" : "Check versions"}
803-
</Button>
804-
) : null}
805-
</div>
806-
}
807-
/>
808800
{environmentId ? (
809801
<DeviceHostUpdates
810802
state={{ ...state, hosts: state.hosts.filter((host) => host.kind === "local") }}

0 commit comments

Comments
 (0)