|
| 1 | +'use client' |
| 2 | + |
| 3 | +import { useState } from 'react' |
1 | 4 | import styles from '@/platform/app/(shell)/integrations/_components/connection-access/connection-access.module.css' |
2 | | -import { Disclosure } from '@/platform/design-system/components' |
| 5 | +import { |
| 6 | + SCOPE_GROUPS, |
| 7 | + scopeGroup, |
| 8 | +} from '@/platform/app/(shell)/integrations/_components/connection-access/scope-groups' |
| 9 | +import { Button, Disclosure } from '@/platform/design-system/components' |
3 | 10 | import type { OrganizationIntegration } from '@/platform/lib/integrations/model' |
4 | 11 |
|
5 | 12 | interface ConnectionAccessProps { |
6 | 13 | integration: OrganizationIntegration |
7 | 14 | } |
8 | 15 |
|
9 | 16 | export function ConnectionAccess({ integration }: ConnectionAccessProps) { |
| 17 | + const [showIds, setShowIds] = useState(false) |
10 | 18 | const scopes = integration.requestedScopes |
11 | 19 | if (!scopes?.length) return null |
12 | 20 | return ( |
13 | | - <Disclosure label='Requested permissions' variant='activity'> |
14 | | - <ul className={styles.scopes} aria-label='Requested provider permissions'> |
15 | | - {scopes.map(({ id, label }) => ( |
16 | | - <li key={id} className={styles.scope}> |
17 | | - <span data-type='T059'>{label}</span> |
18 | | - {label !== id && <span data-type='T050'>{id}</span>} |
19 | | - </li> |
20 | | - ))} |
21 | | - </ul> |
22 | | - </Disclosure> |
| 21 | + <section className={styles.section} aria-label='Requested permissions'> |
| 22 | + <header className={styles.header}> |
| 23 | + <h2 data-type='T093'>Requested permissions</h2> |
| 24 | + <Button |
| 25 | + size='compact' |
| 26 | + variant='quiet' |
| 27 | + render={<button type='button' aria-expanded={showIds} />} |
| 28 | + onClick={() => setShowIds(!showIds)} |
| 29 | + > |
| 30 | + {showIds ? 'Hide scope IDs' : 'Show scope IDs'} |
| 31 | + </Button> |
| 32 | + </header> |
| 33 | + {SCOPE_GROUPS.map((group) => { |
| 34 | + const entries = scopes.filter(({ id }) => scopeGroup(id) === group) |
| 35 | + if (!entries.length) return null |
| 36 | + return ( |
| 37 | + <Disclosure key={group} label={group} initiallyOpen> |
| 38 | + <ul className={styles.scopes} aria-label={group}> |
| 39 | + {entries.map(({ id, label }) => ( |
| 40 | + <li key={id} className={styles.scope}> |
| 41 | + <span data-type='T060'>{label}</span> |
| 42 | + {showIds && label !== id && <span data-type='T050'>{id}</span>} |
| 43 | + </li> |
| 44 | + ))} |
| 45 | + </ul> |
| 46 | + </Disclosure> |
| 47 | + ) |
| 48 | + })} |
| 49 | + </section> |
23 | 50 | ) |
24 | 51 | } |
0 commit comments