Skip to content

Commit 322f654

Browse files
feat(web): show a newly created pairing link without expanding the client list (pingdotgg#30498)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 66e6217 commit 322f654

3 files changed

Lines changed: 43 additions & 15 deletions

File tree

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function endpointRowClassName(isAvailable: boolean) {
123123
type PairingLinkListRowProps = {
124124
pairingLink: ServerPairingLinkRecord;
125125
credential: string | undefined;
126+
defaultShareOpen: boolean;
126127
endpointUrl: string | null | undefined;
127128
endpoints: ReadonlyArray<AdvertisedEndpoint>;
128129
defaultEndpointKey: string | null;
@@ -134,6 +135,7 @@ type PairingLinkListRowProps = {
134135
const PairingLinkListRow = memo(function PairingLinkListRow({
135136
pairingLink,
136137
credential,
138+
defaultShareOpen,
137139
endpointUrl,
138140
endpoints,
139141
defaultEndpointKey,
@@ -144,7 +146,7 @@ const PairingLinkListRow = memo(function PairingLinkListRow({
144146
const nowMs = useNowSecond();
145147
const expiresAtMs = new Date(pairingLink.expiresAt).getTime();
146148
const [isRevealDialogOpen, setIsRevealDialogOpen] = useState(false);
147-
const [isQrPanelOpen, setIsQrPanelOpen] = useState(false);
149+
const [isQrPanelOpen, setIsQrPanelOpen] = useState(defaultShareOpen);
148150
const [qrEndpointId, setQrEndpointId] = useState<string | null>(null);
149151
const qrPanelId = useId();
150152

@@ -791,6 +793,7 @@ type PairingClientsListProps = {
791793
isLoading: boolean;
792794
pairingLinks: ReadonlyArray<ServerPairingLinkRecord>;
793795
createdPairingCredentials: ReadonlyMap<string, string>;
796+
sharedPairingLinkId: string | null;
794797
clientSessions: ReadonlyArray<ServerClientSessionRecord>;
795798
revokingPairingLinkId: string | null;
796799
revokingClientSessionId: string | null;
@@ -806,6 +809,7 @@ export const PairingClientsList = memo(function PairingClientsList({
806809
isLoading,
807810
pairingLinks,
808811
createdPairingCredentials,
812+
sharedPairingLinkId,
809813
clientSessions,
810814
revokingPairingLinkId,
811815
revokingClientSessionId,
@@ -820,6 +824,7 @@ export const PairingClientsList = memo(function PairingClientsList({
820824
key={pairingLink.id}
821825
pairingLink={pairingLink}
822826
credential={createdPairingCredentials.get(pairingLink.id)}
827+
defaultShareOpen={pairingLink.id === sharedPairingLinkId}
823828
endpointUrl={endpointUrl}
824829
endpoints={endpoints}
825830
defaultEndpointKey={defaultEndpointKey}

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

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ export function ConnectionsSettings({ view }: { readonly view: "environments" |
226226
const [createdPairingCredentials, setCreatedPairingCredentials] = useState<
227227
ReadonlyMap<string, string>
228228
>(() => new Map());
229+
const [newestPairingLinkId, setNewestPairingLinkId] = useState<string | null>(null);
229230
const handlePairingLinkCreated = (created: AuthPairingCredentialResult) => {
230231
setCreatedPairingCredentials((current) => new Map(current).set(created.id, created.credential));
232+
setNewestPairingLinkId(created.id);
231233
};
232234
const [revokingDesktopPairingLinkId, setRevokingDesktopPairingLinkId] = useState<string | null>(
233235
null,
@@ -928,27 +930,37 @@ export function ConnectionsSettings({ view }: { readonly view: "environments" |
928930
managed={tailscaleHttpsEndpoint?.status === "available" ? undefined : remoteClientsDenial}
929931
/>
930932
);
933+
const newestPairingLink = visibleDesktopPairingLinks.find(
934+
(pairingLink) => pairingLink.id === newestPairingLinkId,
935+
);
936+
const renderPairingClientsList = (
937+
pairingLinks: typeof visibleDesktopPairingLinks,
938+
clientSessions: typeof desktopClientSessions,
939+
) => (
940+
<PairingClientsList
941+
endpointUrl={desktopServerExposureState?.endpointUrl}
942+
endpoints={visibleDesktopAdvertisedEndpoints}
943+
defaultEndpointKey={defaultDesktopAdvertisedEndpointKey}
944+
isLoading={isLoadingDesktopAccessManagement}
945+
pairingLinks={pairingLinks}
946+
createdPairingCredentials={createdPairingCredentials}
947+
sharedPairingLinkId={newestPairingLinkId}
948+
clientSessions={clientSessions}
949+
revokingPairingLinkId={revokingDesktopPairingLinkId}
950+
revokingClientSessionId={revokingDesktopClientSessionId}
951+
onRevokePairingLink={handleRevokeDesktopPairingLink}
952+
onRevokeClientSession={handleRevokeDesktopClientSession}
953+
canRevoke={canWriteAccess}
954+
/>
955+
);
931956
const renderAuthorizedClients = () => (
932957
<>
933958
{desktopAccessManagementError ? (
934959
<div className={ITEM_ROW_CLASSNAME}>
935960
<p className="text-xs text-destructive">{desktopAccessManagementError}</p>
936961
</div>
937962
) : null}
938-
<PairingClientsList
939-
endpointUrl={desktopServerExposureState?.endpointUrl}
940-
endpoints={visibleDesktopAdvertisedEndpoints}
941-
defaultEndpointKey={defaultDesktopAdvertisedEndpointKey}
942-
isLoading={isLoadingDesktopAccessManagement}
943-
pairingLinks={visibleDesktopPairingLinks}
944-
createdPairingCredentials={createdPairingCredentials}
945-
clientSessions={desktopClientSessions}
946-
revokingPairingLinkId={revokingDesktopPairingLinkId}
947-
revokingClientSessionId={revokingDesktopClientSessionId}
948-
onRevokePairingLink={handleRevokeDesktopPairingLink}
949-
onRevokeClientSession={handleRevokeDesktopClientSession}
950-
canRevoke={canWriteAccess}
951-
/>
963+
{renderPairingClientsList(visibleDesktopPairingLinks, desktopClientSessions)}
952964
</>
953965
);
954966
const renderNetworkAccessRow = () => (
@@ -1153,6 +1165,11 @@ export function ConnectionsSettings({ view }: { readonly view: "environments" |
11531165
<FoldedSettingsSection
11541166
id="authorized-clients"
11551167
title="Authorized clients"
1168+
collapsedContent={
1169+
canReadAccess && newestPairingLink
1170+
? renderPairingClientsList([newestPairingLink], [])
1171+
: undefined
1172+
}
11561173
summary={summarizeAuthorizedClients(
11571174
desktopClientSessions,
11581175
visibleDesktopPairingLinks,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ export function FoldedSettingsSection({
1212
summary,
1313
control,
1414
headerPlacement = "inside",
15+
collapsedContent,
1516
children,
1617
}: {
1718
readonly id: string;
1819
readonly title: ReactNode;
1920
readonly summary?: string | null;
2021
readonly control?: ReactNode;
2122
readonly headerPlacement?: "inside" | "outside";
23+
/** Shown under the header only while folded. */
24+
readonly collapsedContent?: ReactNode;
2225
readonly children: ReactNode;
2326
}) {
2427
const [open, setOpen] = useState(false);
@@ -82,6 +85,9 @@ export function FoldedSettingsSection({
8285
</CollapsibleTrigger>
8386
{control ? <div className="flex shrink-0 items-center">{control}</div> : null}
8487
</div>
88+
{!open && collapsedContent ? (
89+
<div className="border-t border-border/50 empty:hidden">{collapsedContent}</div>
90+
) : null}
8591
<CollapsiblePanel>
8692
<div className="border-t border-border/50 [&>*+*]:border-t [&>*+*]:border-border/50">
8793
{children}

0 commit comments

Comments
 (0)