|
| 1 | +import { SplitDrawer } from '@app/component/split-layout/components/SplitDrawer'; |
| 2 | +import { useDrawerControl } from '@app/component/split-layout/components/SplitDrawerContext'; |
| 3 | +import { IconButton } from '@core/component/IconButton'; |
| 4 | +import { PropertiesView } from '@core/component/Properties/PropertiesView'; |
| 5 | +import TagIcon from '@icon/regular/tag.svg'; |
| 6 | +import { EntityType } from '@service-properties/generated/schemas/entityType'; |
| 7 | +import { Suspense } from 'solid-js'; |
| 8 | + |
| 9 | +const DRAWER_ID = 'properties'; |
| 10 | + |
| 11 | +export function EmailPropertiesModal(props: { |
| 12 | + buttonSize?: 'sm' | 'base'; |
| 13 | + subject?: string; |
| 14 | +}) { |
| 15 | + const drawerControl = useDrawerControl(DRAWER_ID); |
| 16 | + |
| 17 | + return ( |
| 18 | + <> |
| 19 | + <IconButton |
| 20 | + icon={TagIcon} |
| 21 | + theme={drawerControl.isOpen() ? 'accent' : 'clear'} |
| 22 | + size={props.buttonSize ?? 'base'} |
| 23 | + tooltip={{ label: 'Properties' }} |
| 24 | + onClick={drawerControl.toggle} |
| 25 | + /> |
| 26 | + <SplitDrawer id={DRAWER_ID} side="right" size={550} title="Properties"> |
| 27 | + <Suspense fallback={<LoadingFallback />}> |
| 28 | + {/* canEdit is always true for email: |
| 29 | + - Email threads have no sharing mechanism (unlike documents) |
| 30 | + - If user can view the thread, it's from their connected account |
| 31 | + - This component only renders after email loads (Show guards in Block.tsx) */} |
| 32 | + <EmailPropertiesContent canEdit={true} subject={props.subject} /> |
| 33 | + </Suspense> |
| 34 | + </SplitDrawer> |
| 35 | + </> |
| 36 | + ); |
| 37 | +} |
| 38 | + |
| 39 | +function EmailPropertiesContent(props: { canEdit: boolean; subject?: string }) { |
| 40 | + return ( |
| 41 | + <PropertiesView |
| 42 | + blockType={'email'} |
| 43 | + canEdit={props.canEdit} |
| 44 | + entityType={EntityType.THREAD} |
| 45 | + documentName={props.subject} |
| 46 | + /> |
| 47 | + ); |
| 48 | +} |
| 49 | + |
| 50 | +function LoadingFallback() { |
| 51 | + return ( |
| 52 | + <div class="flex justify-center items-center py-8"> |
| 53 | + <div class="animate-spin rounded-full h-6 w-6 border-b-2 border-ink-muted"></div> |
| 54 | + </div> |
| 55 | + ); |
| 56 | +} |
0 commit comments