@@ -14,6 +14,7 @@ import { PageBody, PageContainer } from "~/components/layout/AppLayout";
1414import { Badge } from "~/components/primitives/Badge" ;
1515import { Button , LinkButton } from "~/components/primitives/Buttons" ;
1616import { Callout } from "~/components/primitives/Callout" ;
17+ import { ClipboardField } from "~/components/primitives/ClipboardField" ;
1718import {
1819 Dialog ,
1920 DialogContent ,
@@ -1114,6 +1115,23 @@ function DirectorySyncSection({
11141115 ) ;
11151116}
11161117
1118+ // The portal is hosted by our SSO vendor, so the friendly name is derived from
1119+ // the link's host (e.g. setup.workos.com -> WorkOS). Falls back to the
1120+ // capitalized root label, then to a generic label if the URL can't be parsed.
1121+ const KNOWN_PORTAL_PROVIDERS : Record < string , string > = { workos : "WorkOS" } ;
1122+
1123+ function portalProviderName ( url : string | null ) : string | null {
1124+ if ( ! url ) return null ;
1125+ try {
1126+ const labels = new URL ( url ) . hostname . split ( "." ) . filter ( Boolean ) ;
1127+ const root = labels . length >= 2 ? labels [ labels . length - 2 ] : labels [ 0 ] ;
1128+ if ( ! root ) return null ;
1129+ return KNOWN_PORTAL_PROVIDERS [ root . toLowerCase ( ) ] ?? root [ 0 ] . toUpperCase ( ) + root . slice ( 1 ) ;
1130+ } catch {
1131+ return null ;
1132+ }
1133+ }
1134+
11171135function PortalLinkDialog ( {
11181136 url,
11191137 intent,
@@ -1125,50 +1143,37 @@ function PortalLinkDialog({
11251143} ) {
11261144 const purpose =
11271145 intent === "domain_verification"
1128- ? "This single -use link opens domain verification . Share it with whoever manages your DNS to confirm you own the domains ."
1146+ ? "Single -use link to verify your email domains . Share it with whoever manages your DNS."
11291147 : intent === "sso"
1130- ? "This single -use link opens identity provider setup . Share it with whoever manages your identity provider to connect it."
1148+ ? "Single -use link to connect your identity provider. Share it with whoever manages it."
11311149 : intent === "dsync"
1132- ? "This single-use link opens Directory Sync (SCIM) setup. Share it with whoever manages your identity provider to connect your directory."
1133- : "This single-use link opens your SSO setup." ;
1150+ ? "Single-use link to set up Directory Sync over SCIM. Share it with whoever manages your identity provider."
1151+ : "Single-use link to set up SSO." ;
1152+ const providerName = portalProviderName ( url ) ;
11341153 return (
11351154 < Dialog open = { url !== null } onOpenChange = { ( open ) => ( open ? undefined : onClose ( ) ) } >
11361155 < DialogContent className = "sm:max-w-md" >
11371156 < DialogHeader > Admin portal link</ DialogHeader >
1138- < DialogDescription >
1139- { purpose } The link expires 5 minutes after this dialog opens.
1157+ < DialogDescription className = "text-sm" >
1158+ { purpose } It expires 5 minutes after this dialog opens.
11401159 </ DialogDescription >
1141- < div className = "mt-4 break-all rounded-md border border-grid-bright bg-charcoal-800 p-3 font-mono text-xs" >
1142- { url ?? "" }
1143- </ div >
1160+ < ClipboardField value = { url ?? "" } variant = "secondary/medium" />
11441161 < DialogFooter >
11451162 < Button variant = "secondary/small" onClick = { onClose } >
11461163 Cancel
11471164 </ Button >
1148- < div className = "flex items-center gap-2" >
1149- < Button
1150- variant = "secondary/small"
1151- onClick = { ( ) => {
1152- if ( url ) {
1153- navigator . clipboard ?. writeText ( url ) ;
1154- }
1155- } }
1156- >
1157- Copy link
1158- </ Button >
1159- < Button
1160- variant = "primary/small"
1161- TrailingIcon = { ArrowUpRightIcon }
1162- onClick = { ( ) => {
1163- if ( ! url ) return ;
1164- // Single-use link; `noopener,noreferrer` isolates the new tab.
1165- window . open ( url , "_blank" , "noopener,noreferrer" ) ;
1166- onClose ( ) ;
1167- } }
1168- >
1169- Open in new tab
1170- </ Button >
1171- </ div >
1165+ < Button
1166+ variant = "primary/small"
1167+ TrailingIcon = { ArrowUpRightIcon }
1168+ onClick = { ( ) => {
1169+ if ( ! url ) return ;
1170+ // Single-use link; `noopener,noreferrer` isolates the new tab.
1171+ window . open ( url , "_blank" , "noopener,noreferrer" ) ;
1172+ onClose ( ) ;
1173+ } }
1174+ >
1175+ { providerName ? `Open in ${ providerName } ` : "Open in new tab" }
1176+ </ Button >
11721177 </ DialogFooter >
11731178 </ DialogContent >
11741179 </ Dialog >
0 commit comments