Skip to content

Commit ab9acc7

Browse files
fix(web): flatten environment routes and permission details
1 parent 4b67a6d commit ab9acc7

4 files changed

Lines changed: 92 additions & 68 deletions

File tree

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

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,6 +1494,7 @@ function SavedBackendListRow({
14941494
onAddRoute,
14951495
}: SavedBackendListRowProps) {
14961496
const [routesOpen, setRoutesOpen] = useState(false);
1497+
const [permissionsOpen, setPermissionsOpen] = useState(false);
14971498
const environmentId = environment.environmentId;
14981499
const unsupported = environment.connection.phase === "unsupported";
14991500
const enabled = environment.entry.enabled && !unsupported;
@@ -1661,6 +1662,25 @@ function SavedBackendListRow({
16611662
)}
16621663
/>
16631664
</button>
1665+
<span aria-hidden className="shrink-0">
1666+
·
1667+
</span>
1668+
<button
1669+
type="button"
1670+
aria-expanded={permissionsOpen}
1671+
aria-controls={`remote-permissions-${environmentId}`}
1672+
onClick={() => setPermissionsOpen((open) => !open)}
1673+
className="inline-flex shrink-0 items-center gap-0.5 rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring"
1674+
>
1675+
Permissions
1676+
<ChevronRightIcon
1677+
aria-hidden
1678+
className={cn(
1679+
"size-3 shrink-0 transition-transform duration-150 motion-reduce:transition-none",
1680+
permissionsOpen && "rotate-90",
1681+
)}
1682+
/>
1683+
</button>
16641684
</span>
16651685
}
16661686
below={
@@ -1671,12 +1691,26 @@ function SavedBackendListRow({
16711691
) : null
16721692
}
16731693
detail={
1674-
routesOpen ? (
1675-
<EnvironmentRoutesList
1676-
environment={environment}
1677-
onAddRoute={() => onAddRoute(environment)}
1678-
/>
1679-
) : null
1694+
<>
1695+
{routesOpen && (
1696+
<EnvironmentRoutesList
1697+
environment={environment}
1698+
onAddRoute={() => onAddRoute(environment)}
1699+
/>
1700+
)}
1701+
{permissionsOpen && (
1702+
<div
1703+
id={`remote-permissions-${environmentId}`}
1704+
className="mt-2 border-t border-border/50"
1705+
>
1706+
<SessionPermissions
1707+
environmentId={environmentId}
1708+
connected={isConnected}
1709+
routeContext
1710+
/>
1711+
</div>
1712+
)}
1713+
</>
16801714
}
16811715
>
16821716
{unsupported &&
@@ -3682,16 +3716,23 @@ export function ConnectionsSettings() {
36823716
) : null}
36833717
</>
36843718
) : null}
3719+
{primaryEnvironment ? (
3720+
<details className="group px-3 sm:px-4">
3721+
<summary className="flex min-h-11 cursor-pointer list-none items-center gap-2 rounded-md text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-ring [&::-webkit-details-marker]:hidden">
3722+
Permissions
3723+
<ChevronRightIcon
3724+
aria-hidden
3725+
className="size-3 text-muted-foreground group-open:rotate-90"
3726+
/>
3727+
</summary>
3728+
<SessionPermissions
3729+
environmentId={primaryEnvironment.environmentId}
3730+
connected={primaryEnvironment.connection.phase === "connected"}
3731+
/>
3732+
</details>
3733+
) : null}
36853734
</SettingsSection>
36863735

3687-
{primaryEnvironment ? (
3688-
<SessionPermissions
3689-
environmentId={primaryEnvironment.environmentId}
3690-
label={primaryEnvironment.label}
3691-
connected={primaryEnvironment.connection.phase === "connected"}
3692-
/>
3693-
) : null}
3694-
36953736
{canReadAccess || canWriteAccess ? (
36963737
<FoldedSettingsSection
36973738
id="authorized-clients"

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

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { SessionPermissions } from "./SessionPermissions";
21
import {
32
DndContext,
43
type DragEndEvent,
@@ -104,13 +103,7 @@ export function EnvironmentRoutesList({
104103
};
105104

106105
return (
107-
<div className="mt-2 rounded-md border border-border/70">
108-
<SessionPermissions
109-
environmentId={environment.environmentId}
110-
label={environment.label}
111-
connected={activeRouteId !== null}
112-
routeContext
113-
/>
106+
<div className="mt-2 border-t border-border/50 py-2">
114107
<DndContext
115108
sensors={sensors}
116109
collisionDetection={closestCenter}
@@ -135,7 +128,7 @@ export function EnvironmentRoutesList({
135128
</ol>
136129
</SortableContext>
137130
</DndContext>
138-
<div className="border-t border-border/70 px-1 py-1">
131+
<div className="-ml-1.5 pt-1">
139132
<Button size="xs" variant="ghost-muted" onClick={onAddRoute}>
140133
<PlusIcon className="size-3" />
141134
Add route
@@ -176,20 +169,10 @@ function SortableRouteRow({
176169
ref={setNodeRef}
177170
style={{ transform: CSS.Translate.toString(transform), transition }}
178171
className={cn(
179-
"flex items-center gap-2 border-b border-border/70 px-1 py-1.5 last:border-b-0",
172+
"flex items-center gap-2 py-2",
180173
isDragging && "relative z-10 rounded-md bg-background shadow-md",
181174
)}
182175
>
183-
<button
184-
type="button"
185-
ref={setActivatorNodeRef}
186-
{...attributes}
187-
{...listeners}
188-
aria-label={`Reorder ${label}, position ${position}`}
189-
className="flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground/70 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing"
190-
>
191-
<GripVerticalIcon className="size-3.5" />
192-
</button>
193176
<div className="min-w-0 flex-1">
194177
<p className="flex items-center gap-1.5 text-xs font-medium text-foreground">
195178
{label}
@@ -206,6 +189,16 @@ function SortableRouteRow({
206189
</p>
207190
) : null}
208191
</div>
192+
<button
193+
type="button"
194+
ref={setActivatorNodeRef}
195+
{...attributes}
196+
{...listeners}
197+
aria-label={`Reorder ${label}, position ${position}`}
198+
className="flex size-6 shrink-0 cursor-grab touch-none items-center justify-center rounded text-muted-foreground/70 outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring active:cursor-grabbing"
199+
>
200+
<GripVerticalIcon className="size-3.5" />
201+
</button>
209202
{removable ? (
210203
<Tooltip>
211204
<TooltipTrigger
Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,38 @@
11
import { type EnvironmentId, sessionGrantsScope } from "@t3tools/contracts";
22
import { AUTH_SCOPE_OPTIONS } from "@t3tools/shared/authScopeOptions";
33
import { useEnvironmentSessionState } from "~/state/session";
4-
import { FoldedSettingsSection } from "./FoldedSettingsSection";
54

65
export function SessionPermissions({
76
environmentId,
8-
label,
97
connected,
108
routeContext = false,
119
}: {
1210
readonly environmentId: EnvironmentId;
13-
readonly label: string;
1411
readonly connected: boolean;
1512
readonly routeContext?: boolean;
1613
}) {
1714
const session = useEnvironmentSessionState(environmentId);
18-
return (
19-
<FoldedSettingsSection
20-
id={`session-permissions-${environmentId}`}
21-
title="Your permissions"
22-
summary={label}
23-
>
24-
{connected && !session.hasError && !session.isPending && session.data?.authenticated ? (
25-
<div className="space-y-3 px-4 py-3 text-xs">
26-
<p className="text-muted-foreground">
27-
{routeContext
28-
? "Applies to the route marked In use. Other routes may have different permissions and have not been checked."
29-
: "These permissions apply to this client’s current connection."}
30-
</p>
31-
<ul className="grid gap-x-6 gap-y-2 sm:grid-cols-2">
32-
{AUTH_SCOPE_OPTIONS.map(({ scope, title }) => (
33-
<li key={scope} className="flex items-start justify-between gap-3">
34-
<span>{title}</span>
35-
<span className="shrink-0 text-muted-foreground">
36-
{sessionGrantsScope(session.data!, scope) ? "Allowed" : "Not granted"}
37-
</span>
38-
</li>
39-
))}
40-
</ul>
41-
</div>
42-
) : (
43-
<p className="px-4 py-3 text-xs text-muted-foreground">
44-
Permissions not checked. Connect to this environment to view this session’s permissions.
45-
</p>
46-
)}
47-
</FoldedSettingsSection>
15+
return connected && !session.hasError && !session.isPending && session.data?.authenticated ? (
16+
<div className="space-y-3 py-3 text-xs">
17+
<p className="text-muted-foreground">
18+
{routeContext
19+
? "These permissions apply to your active route. Other routes may have different permissions."
20+
: "These permissions apply to this client’s current connection."}
21+
</p>
22+
<ul className="grid gap-x-6 gap-y-2 sm:grid-cols-2">
23+
{AUTH_SCOPE_OPTIONS.map(({ scope, title }) => (
24+
<li key={scope} className="flex items-start justify-between gap-3">
25+
<span>{title}</span>
26+
<span className="shrink-0 text-muted-foreground">
27+
{sessionGrantsScope(session.data!, scope) ? "Allowed" : "Not granted"}
28+
</span>
29+
</li>
30+
))}
31+
</ul>
32+
</div>
33+
) : (
34+
<p className="py-3 text-xs text-muted-foreground">
35+
Permissions not checked. Connect to this environment to view this session’s permissions.
36+
</p>
4837
);
4938
}

‎docs/user/remote-access.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ or remove it. On mobile, open the machine under **Settings → Environments** an
9191
choose **Edit**. Signing out of T3 Connect removes only that route; a machine
9292
you can still reach another way stays saved.
9393

94-
Open **Your permissions** to see what your current connection can do on that
94+
Open **Permissions** next to **Routes** in web or desktop, or **Your permissions**
95+
in the mobile route details, to see what your current connection can do on that
9596
environment. For a remote environment, this is in its route details. Permissions
9697
shown there apply only to the route marked **In use**; other routes are not
9798
checked. Direct pairing and T3 Connect have separate sessions and may grant

0 commit comments

Comments
 (0)