|
| 1 | +import { useAtomValue, Result } from "@effect-atom/atom-react"; |
| 2 | +import { useScope } from "@executor/react/api/scope-context"; |
1 | 3 | import { Badge } from "@executor/react/components/badge"; |
2 | 4 | import { Button } from "@executor/react/components/button"; |
3 | 5 |
|
| 6 | +import { googleDiscoverySourceAtom } from "./atoms"; |
| 7 | + |
4 | 8 | export default function EditGoogleDiscoverySource({ |
5 | 9 | sourceId, |
6 | 10 | onSave, |
7 | 11 | }: { |
8 | 12 | readonly sourceId: string; |
9 | 13 | readonly onSave: () => void; |
10 | 14 | }) { |
| 15 | + const scopeId = useScope(); |
| 16 | + const sourceResult = useAtomValue(googleDiscoverySourceAtom(scopeId, sourceId)); |
| 17 | + |
| 18 | + const source = Result.isSuccess(sourceResult) ? sourceResult.value : null; |
| 19 | + const config = source?.config; |
| 20 | + const authKind = config?.auth.kind ?? "none"; |
| 21 | + |
11 | 22 | return ( |
12 | 23 | <div className="space-y-6"> |
13 | 24 | <div> |
14 | 25 | <h1 className="text-xl font-semibold text-foreground"> |
15 | 26 | Edit Google Discovery Source |
16 | 27 | </h1> |
17 | 28 | <p className="mt-1 text-[13px] text-muted-foreground"> |
18 | | - This source is managed from its Discovery document and can be refreshed from the source header. |
| 29 | + View configuration for this Google API source. To change authentication, |
| 30 | + remove and re-add the source with updated OAuth credentials. |
19 | 31 | </p> |
20 | 32 | </div> |
21 | 33 |
|
22 | 34 | <div className="flex items-center gap-3 rounded-lg border border-border bg-card px-4 py-3"> |
23 | 35 | <div className="min-w-0 flex-1"> |
24 | 36 | <p className="truncate text-sm font-semibold text-card-foreground"> |
25 | | - {sourceId} |
| 37 | + {source?.name ?? sourceId} |
26 | 38 | </p> |
| 39 | + {config?.discoveryUrl && ( |
| 40 | + <p className="mt-0.5 text-xs text-muted-foreground font-mono truncate"> |
| 41 | + {config.discoveryUrl} |
| 42 | + </p> |
| 43 | + )} |
27 | 44 | </div> |
28 | 45 | <Badge variant="secondary" className="text-[10px]"> |
29 | 46 | Google Discovery |
30 | 47 | </Badge> |
31 | 48 | </div> |
32 | 49 |
|
| 50 | + {config && ( |
| 51 | + <div className="space-y-3"> |
| 52 | + <div className="grid grid-cols-2 gap-3 text-sm"> |
| 53 | + <div className="rounded-lg border border-border bg-card/50 p-3"> |
| 54 | + <p className="text-[10px] uppercase tracking-wider text-muted-foreground mb-1">Service</p> |
| 55 | + <p className="text-sm font-medium text-foreground"> |
| 56 | + {config.service} |
| 57 | + </p> |
| 58 | + </div> |
| 59 | + <div className="rounded-lg border border-border bg-card/50 p-3"> |
| 60 | + <p className="text-[10px] uppercase tracking-wider text-muted-foreground mb-1">Version</p> |
| 61 | + <p className="text-sm font-medium text-foreground"> |
| 62 | + {config.version} |
| 63 | + </p> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + |
| 67 | + <div className="rounded-lg border border-border bg-card/50 p-3"> |
| 68 | + <p className="text-[10px] uppercase tracking-wider text-muted-foreground mb-1">Authentication</p> |
| 69 | + <p className="text-sm font-medium text-foreground capitalize"> |
| 70 | + {authKind === "oauth2" ? "OAuth 2.0" : authKind} |
| 71 | + </p> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + )} |
| 75 | + |
33 | 76 | <div className="flex items-center justify-end border-t border-border pt-4"> |
34 | 77 | <Button onClick={onSave}>Done</Button> |
35 | 78 | </div> |
|
0 commit comments