ConnectedAppModal

OAuth consent modal for a third-party app requesting access, with the app's identity, requested scopes, and approve/deny actions.

Installation

pnpm add @wandercom/design-system-web

Usage

Loading example...
21 lines
import { ConnectedAppModal } from '@wandercom/design-system-web/blocks/connected-app-modal';

export function Example() {
  return (
    <ConnectedAppModal
      open={!!requestId}
      onOpenChange={(open) => !open && clearRequestId()}
      isLoading={isLoading}
      connectionDetails={details}
      title={`Allow ${details?.client_name} to access ${organization.name}?`}
      description={`Signed in as ${user.email}. ${details?.client_name} will be able to:`}
      manageAccess={
        <Link className="text-primary hover:underline" href="/settings/connected-apps">
          Settings → Connected apps
        </Link>
      }
      onApprove={() => decide('approved')}
      onDeny={() => decide('denied')}
    />
  );
}

onApprove and onDeny return a Promise: the pressed button shows a loading state while it is pending, the modal closes on resolve, and on reject an error toast is shown unless onApproveError / onDenyError handle it.

Scopes come as name:permission (e.g. bookings:read) or a bare name, and are grouped by name. Contacts are free-form strings set by the third-party app: only emails, phone numbers and http(s) URLs become links. The same helpers are exported as groupConnectedAppScopes and parseConnectedAppContact.

Props

open:

boolean
Controlled open state of the modal.

onOpenChange:

(open: boolean) => void
Called with false on dismiss and after a successful approve or deny.

isLoading?:

boolean
Shows a spinner instead of the content. Defaults to false.

connectionDetails:

ConnectedAppDetails | undefined
The connection request to show. When undefined (and not loading), notFound is shown.

title?:

ReactNode
Heading of the permissions panel. Strings render as a headline.

description?:

ReactNode
Text under the title. Strings render as secondary body text.

organizationPicker?:

ReactNode
Rendered under the description, e.g. an organization select when the request has no organization_id.

notFound?:

ReactNode
Content shown when connectionDetails is undefined.

manageAccess?:

ReactNode
Link to the page where access can be revoked (e.g. your router's Link), shown after the reviewed notice. Falls back to the manageAccessLabel label as plain text when omitted.

onApprove:

() => Promise<void>
Called on "Allow access". The modal closes on resolve.

onDeny:

() => Promise<void>
Called on "Deny". The modal closes on resolve.

onApproveError?:

(error: unknown) => void
Called when onApprove rejects. Defaults to an error toast.

onDenyError?:

(error: unknown) => void
Called when onDeny rejects. Defaults to an error toast.

labels?:

Partial<ConnectedAppModalLabels>
Override any subset of the default labels (see DEFAULT_CONNECTED_APP_MODAL_LABELS).

slots?:

ModalSlots
ClassName overrides for the underlying Modal.
ConnectedAppModal