Skip to content

Commit 2b4953a

Browse files
danielkweonaidanhb
authored andcommitted
add [properties-fe] - properties panel in emails (#612)
1 parent 5d8c7e4 commit 2b4953a

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-2
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
}

js/app/packages/block-email/component/TopBar.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import {
33
SplitHeaderBadge,
44
StaticSplitLabel,
55
} from '@app/component/split-layout/components/SplitLabel';
6-
import { SplitToolbarLeft } from '@app/component/split-layout/components/SplitToolbar';
6+
import {
7+
SplitToolbarLeft,
8+
SplitToolbarRight,
9+
} from '@app/component/split-layout/components/SplitToolbar';
10+
import { ENABLE_PROPERTIES_METADATA } from '@core/constant/featureFlags';
11+
import { Show } from 'solid-js';
12+
import { EmailPropertiesModal } from './EmailPropertiesModal';
713

814
export function TopBar(props: { title: string }) {
915
return (
@@ -16,6 +22,11 @@ export function TopBar(props: { title: string }) {
1622
<SplitHeaderBadge text="beta" tooltip="Email is in Beta" />
1723
</div>
1824
</SplitToolbarLeft>
25+
<SplitToolbarRight>
26+
<Show when={ENABLE_PROPERTIES_METADATA}>
27+
<EmailPropertiesModal buttonSize="sm" subject={props.title} />
28+
</Show>
29+
</SplitToolbarRight>
1930
</>
2031
);
2132
}

js/app/packages/core/component/Properties/component/panel/PropertyGrid.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const PropertyGrid: Component<PropertiesListProps> = (props) => {
2323
for (const prop of props.properties) {
2424
if (prop.isMetadata) {
2525
// Hide "Project" property if value is null
26-
if (prop.value != null) {
26+
if (prop.value != null || !['Project'].includes(prop.displayName)) {
2727
metadata.push(prop);
2828
}
2929
} else if (builtinPropertyIds.includes(prop.propertyDefinitionId)) {

0 commit comments

Comments
 (0)