MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / AccountRow

Function AccountRow

packages/react/src/components/accounts-section.tsx:63–200  ·  view source on GitHub ↗
(props: {
  readonly connection: Connection;
  /** The integration declares scopes this connection was not granted — it must
   *  reconnect to grant the newly-needed access (e.g. after a service was added). */
  readonly needsReconsent: boolean;
  readonly showOwnerLabel: boolean;
  readonly onEdit: () => void;
  readonly onReconnect: () => void;
  readonly onRemove: () => void;
})

Source from the content-addressed store, hash-verified

61const OWNERS: readonly Owner[] = ["org", "user"];
62
63function AccountRow(props: {
64 readonly connection: Connection;
65 /** The integration declares scopes this connection was not granted — it must
66 * reconnect to grant the newly-needed access (e.g. after a service was added). */
67 readonly needsReconsent: boolean;
68 readonly showOwnerLabel: boolean;
69 readonly onEdit: () => void;
70 readonly onReconnect: () => void;
71 readonly onRemove: () => void;
72}) {
73 const { connection, needsReconsent } = props;
74 const [checking, setChecking] = useState(false);
75
76 // The status renders WITHOUT any clicking: every checkHealth run persists its
77 // verdict on the connection row, so the list answers "has this expired?" at a
78 // glance. A live check from this session takes precedence. We deliberately do
79 // NOT derive expiry from the stored `expiresAt`: that's the access-token
80 // lifetime, which refreshes, so a passive countdown means nothing.
81 //
82 // Health checks are AUTOMATIC: the hook revalidates on mount, stale-while-
83 // revalidate style (shared with the integrations-list summary), and the
84 // persisted verdict renders instantly while the probe corrects it in place.
85 const { probe, status, runCheck } = useConnectionHealth(connection);
86 const indicator = HEALTH_INDICATOR_COLOR[status];
87
88 // Prefer the stored label from the connection row, then a probed identity,
89 // then the connection name. OAuth labels come from the grant's OIDC claims,
90 // while health identities remain useful for non-OAuth probes.
91 const identity =
92 (connection.identityLabel && connection.identityLabel.length > 0
93 ? connection.identityLabel
94 : null) ?? (probe?.identity && probe.identity.length > 0 ? probe.identity : null);
95 const displayLabel = identity ?? String(connection.name);
96
97 const expired = status === "expired";
98 const missingOAuthScopes = connection.missingOAuthScopes ?? [];
99
100 const handleCheck = async () => {
101 if (checking) return;
102 setChecking(true);
103 const exit = await runCheck();
104 setChecking(false);
105 if (Exit.isFailure(exit)) {
106 toast.error(messageFromExit(exit, "Health check failed"));
107 return;
108 }
109 // The hook already folded the fresh probe into the live state.
110 if (exit.value.status === "healthy") {
111 toast.success(
112 exit.value.identity ? `Healthy: ${exit.value.identity}` : "Connection is healthy",
113 );
114 } else if (exit.value.status === "expired") {
115 toast.error("Connection expired, reconnect to restore access");
116 } else if (exit.value.status === "degraded") {
117 toast.warning(exit.value.detail ?? "Connection check returned an error");
118 } else {
119 toast.message("No health check is configured for this integration");
120 }

Callers

nothing calls this directly

Calls 3

useConnectionHealthFunction · 0.90
ownerLabelFunction · 0.90
handleCheckFunction · 0.85

Tested by

no test coverage detected