MCPcopy Index your code
hub / github.com/coder/coder / ExternalAuthButtons

Function ExternalAuthButtons

site/src/modules/tasks/TaskPrompt/TaskPrompt.tsx:435–488  ·  view source on GitHub ↗
({
	versionId,
	missedExternalAuth,
})

Source from the content-addressed store, hash-verified

433};
434
435const ExternalAuthButtons: FC<ExternalAuthButtonProps> = ({
436 versionId,
437 missedExternalAuth,
438}) => {
439 const { startPollingExternalAuth, externalAuthPollingState } =
440 useExternalAuth(versionId);
441
442 return missedExternalAuth.map((auth) => {
443 const isPollingExternalAuth =
444 externalAuthPollingState[auth.id] === "polling";
445 const shouldRetry = externalAuthPollingState[auth.id] === "abandoned";
446
447 return (
448 <div className="flex items-center gap-2" key={auth.id}>
449 <Button
450 className="bg-surface-tertiary hover:bg-surface-quaternary rounded-full text-content-primary"
451 size="sm"
452 disabled={isPollingExternalAuth || auth.authenticated}
453 onClick={() => {
454 window.open(
455 auth.authenticate_url,
456 "_blank",
457 "width=900,height=600",
458 );
459 startPollingExternalAuth(auth.id);
460 }}
461 >
462 <Spinner loading={isPollingExternalAuth}>
463 <ExternalImage src={auth.display_icon} />
464 </Spinner>
465 Connect to {auth.display_name}
466 </Button>
467
468 {shouldRetry && !auth.authenticated && (
469 <Tooltip>
470 <TooltipTrigger asChild>
471 <Button
472 variant="outline"
473 size="icon"
474 onClick={() => startPollingExternalAuth(auth.id)}
475 >
476 <RedoIcon />
477 <span className="sr-only">Refresh external auth</span>
478 </Button>
479 </TooltipTrigger>
480 <TooltipContent>
481 Retry connecting to {auth.display_name}
482 </TooltipContent>
483 </Tooltip>
484 )}
485 </div>
486 );
487 });
488};
489
490function sortByDefault(a: Preset, b: Preset) {
491 // Default preset should come first

Callers

nothing calls this directly

Calls 2

useExternalAuthFunction · 0.90
openMethod · 0.80

Tested by

no test coverage detected