Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(email): add sidepanel to email block, tweak sidepanel components (#3683)
Seamus0fb59fa2ca0b
diff --git a/js/app/packages/app/component/side-panel/SidePanel.tsx b/js/app/packages/app/component/side-panel/SidePanel.tsxindex 98b83479e2..0f4c08397f 100644--- a/js/app/packages/app/component/side-panel/SidePanel.tsx+++ b/js/app/packages/app/component/side-panel/SidePanel.tsx@@ -358,7 +358,7 @@ function Row(props: ParentProps<{ label: JSX.Element }>) {* EditTrigger, an anchor, a button) without nesting elements.*/const pillClass = cn(- 'inline-flex items-center gap-1.5 min-w-0 max-w-full',+ 'inline-flex items-center gap-1.5 min-w-0 max-w-[30ch]','px-2 py-1 leading-tight text-left rounded-full');@@ -370,8 +370,17 @@ function Pill(props: ParentProps<{ class?: string }>) {}/** Empty-state indicator used inside value pills. */-function EmptyPill() {- return <CircleDashedEmpty class="size-3 shrink-0 opacity-50" />;+function EmptyPill(props: { label?: JSX.Element } = {}) {+ return (+ <span class="inline-flex min-w-0 items-center gap-1.5 opacity-50">+ <Show when={!props.label}>+ <CircleDashedEmpty class="size-3 shrink-0" />+ </Show>+ <Show when={props.label}>+ <span class="truncate">{props.label}</span>+ </Show>+ </span>+ );}/**diff --git a/js/app/packages/app/component/side-panel/properties/EntityPropertiesSection.tsx b/js/app/packages/app/component/side-panel/properties/EntityPropertiesSection.tsxindex 20e6288780..f19f9e2a2c 100644--- a/js/app/packages/app/component/side-panel/properties/EntityPropertiesSection.tsx+++ b/js/app/packages/app/component/side-panel/properties/EntityPropertiesSection.tsx@@ -20,6 +20,7 @@ import {createMemo,createSignal,For,+ type JSX,Match,Show,Switch,@@ -31,6 +32,10 @@ export interface EntityPropertiesSectionProps {entityType: EntityType;canEdit: boolean;documentName?: string;+ includeMetadata?: boolean;+ propertyFilter?: (property: Property) => boolean;+ getEmptyLabel?: (property: Property) => JSX.Element | undefined;+ showAddProperty?: boolean;defaultPinnedPropertyIds?: () => readonly string[];pinnedPropertyIds?: () => string[];pinnedPropertyDefinitionOrder?: readonly string[];@@ -42,18 +47,26 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {const { properties, isLoading, error, refetch } = useEntityProperties(props.entityId,props.entityType,- false+ props.includeMetadata ?? false);const filteredPinnedProperties = createMemo(() => {const defaultPinnedIds = props.defaultPinnedPropertyIds?.() ?? [];const pinnedIds = props.pinnedPropertyIds?.() ?? [];- const pinned = properties().filter(- (property) =>- !property.isMetadata &&- (defaultPinnedIds.includes(property.propertyDefinitionId) ||- pinnedIds.includes(property.propertyId))- );+ const usesPinnedFilter =+ props.defaultPinnedPropertyIds !== undefined ||+ props.pinnedPropertyIds !== undefined;+ const pinned = properties().filter((property) => {+ if (props.propertyFilter && !props.propertyFilter(property)) {+ return false;+ }+ if (property.isMetadata) return props.includeMetadata === true;+ if (!usesPinnedFilter) return true;+ return (+ defaultPinnedIds.includes(property.propertyDefinitionId) ||+ pinnedIds.includes(property.propertyId)+ );+ });return sortPinnedProperties(pinned, props.pinnedPropertyDefinitionOrder);});@@ -151,11 +164,12 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {</Show><Show when={gridPinnedProperties().length > 0}>- <SidePanel.Grid class="py-2">+ <SidePanel.Grid class="auto-rows-[minmax(1.75rem,auto)]"><For each={gridPinnedProperties()}>{(property) => (<SidePanelPropertyRowentityId={props.entityId}+ getEmptyLabel={props.getEmptyLabel}property={property}/>)}@@ -176,8 +190,10 @@ export function EntityPropertiesSection(props: EntityPropertiesSectionProps) {</div></Show>- <Show when={props.canEdit}>- <AddPinnedPropertyButton />+ <Show when={props.canEdit && props.showAddProperty !== false}>+ <div class="mt-2">+ <AddPinnedPropertyButton />+ </div></Show><Modals /></PropertiesProvider>@@ -225,7 +241,11 @@ function isNonUserMultiEntityProperty(property: Property): boolean {);}-function SidePanelPropertyRow(props: { entityId: string; property: Property }) {+function SidePanelPropertyRow(props: {+ entityId: string;+ getEmptyLabel?: (property: Property) => JSX.Element | undefined;+ property: Property;+}) {const ctx = usePropertiesContext();const t = () => props.property.valueType;const isMulti = () => !!props.property.isMultiSelect;@@ -235,23 +255,40 @@ function SidePanelPropertyRow(props: { entityId: string; property: Property }) {(t() === 'SELECT_STRING' || t() === 'SELECT_NUMBER' || t() === 'ENTITY');const isInputType = () =>t() === 'STRING' || t() === 'NUMBER' || t() === 'LINK' || t() === 'BOOLEAN';+ const isMultilineRow = () => t() === 'STRING' && hasValue(props.property);return (<><span- class="text-ink-muted truncate self-center"+ class={cn('text-ink-muted truncate', {+ 'self-start pt-[0.3125rem]': isMultilineRow(),+ 'self-center': !isMultilineRow(),+ })}title={props.property.displayName}>{props.property.displayName}</span>- <div class="min-w-0 self-center">+ <div+ class={cn('min-w-0 max-w-full overflow-hidden', {+ 'self-start py-0.5': isMultilineRow(),+ 'self-center': !isMultilineRow(),+ })}+ ><PropertyNS.Root+ class="min-w-0 max-w-full overflow-hidden"property={props.property}canEdit={ctx.canEdit}onSave={ctx.saveHandler.saveProperty}onRefresh={ctx.onRefresh}>- <Switch fallback={<SinglePill property={props.property} />}>+ <Switch+ fallback={+ <SinglePill+ getEmptyLabel={props.getEmptyLabel}+ property={props.property}+ />+ }+ ><Match when={isInputType()}><InputValue /></Match>@@ -271,7 +308,10 @@ function SidePanelPropertyRow(props: { entityId: string; property: Property }) {);}-function SinglePill(props: { property: Property }) {+function SinglePill(props: {+ getEmptyLabel?: (property: Property) => JSX.Element | undefined;+ property: Property;+}) {const ctx = usePropertiesContext();const isReadOnly = () => !ctx.canEdit || props.property.isMetadata;const empty = () => !hasValue(props.property);@@ -293,11 +333,18 @@ function SinglePill(props: { property: Property }) {return (<PropertyNS.Tooltip property={props.property}><PropertyNS.EditTrigger- class={cn(SidePanel.pillClass, 'w-fit', {+ class={cn(SidePanel.pillClass, 'w-fit overflow-hidden', {'hover:bg-hover': !isReadOnly(),})}>- <Show when={!empty()} fallback={<SidePanel.EmptyPill />}>+ <Show+ when={!empty()}+ fallback={+ <SidePanel.EmptyPill+ label={props.getEmptyLabel?.(props.property)}+ />+ }+ ><Showwhen={isNonUserEntity() && entity()}fallback={@@ -306,17 +353,19 @@ function SinglePill(props: { property: Property }) {property={props.property}class="size-3 shrink-0"/>- <PropertyNS.Text property={props.property} />+ <PropertyNS.Text property={props.property} class="min-w-0" /></>}><span class="shrink-0 flex items-center">{entityDisplay.icon()}</span>- <span class="truncate">{entityDisplay.name()}</span>+ <span class="min-w-0 truncate">{entityDisplay.name()}</span></Show></Show>- <PropertyNS.Caret />+ <Show when={!isReadOnly()}>+ <PropertyNS.Caret />+ </Show></PropertyNS.EditTrigger></PropertyNS.Tooltip>);@@ -336,7 +385,9 @@ function UserStackPill(props: { property: Property }) {><Show when={!empty()} fallback={<SidePanel.EmptyPill />}><PropertyNS.UserStack property={props.property} maxUsers={3} />- <PropertyNS.Text property={props.property} />+ <span class="min-w-0 truncate">+ <PropertyNS.Text property={props.property} />+ </span></Show><PropertyNS.Caret /></PropertyNS.EditTrigger>@@ -579,11 +630,11 @@ function NonUserEntityChip(props: {return (<divref={containerRef}- class="inline-flex shrink-0 border h-7 items-stretch border-edge-muted rounded-md text-ink overflow-clip"+ class="inline-flex min-w-0 max-w-full border h-7 items-stretch border-edge-muted rounded-md text-ink overflow-clip"><buttontype="button"- class="flex min-w-0 max-w-[20ch] items-center gap-1.5 px-2 text-left"+ class="flex min-w-0 max-w-full items-center gap-1.5 px-2 text-left"onClick={openEditor}disabled={!props.canEdit}>@@ -611,7 +662,7 @@ function NonUserEntityChip(props: {function InputValue() {return (- <div class="min-w-0 w-full">+ <div class="min-w-0 max-w-full overflow-hidden"><PropertyNS.Display /></div>);diff --git a/js/app/packages/app/component/split-layout/components/SplitToolbar.tsx b/js/app/packages/app/component/split-layout/components/SplitToolbar.tsxindex 412d6f02aa..4b2afd9da7 100644--- a/js/app/packages/app/component/split-layout/components/SplitToolbar.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitToolbar.tsx@@ -17,7 +17,7 @@ export function SplitToolbar(props: { ref: Setter<HTMLDivElement | null> }) {// into.return (<div- class="flex items-start justify-between w-full"+ class="flex items-center justify-between w-full"data-split-toolbarref={props.ref}>diff --git a/js/app/packages/block-email/component/Email.tsx b/js/app/packages/block-email/component/Email.tsxindex d3c129ce0e..7e4cc20875 100644--- a/js/app/packages/block-email/component/Email.tsx+++ b/js/app/packages/block-email/component/Email.tsx@@ -1,3 +1,4 @@+import { SidePanel } from '@app/component/side-panel';import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import { EmailCompose } from '@block-email/component/compose/Compose';import {@@ -37,6 +38,7 @@ import { EmailFormContextProvider } from './EmailFormContext';import { EmailParticipants } from './EmailParticipants';import { MessageList } from './MessageList';import { ModalsProvider } from './ModalsProvider';+import { EmailSidePanelSections } from './sidepanel/EmailSidePanelSections';import { TopBar } from './TopBar';const TARGET_MESSAGE_HIGHLIGHT_MS = 800;@@ -51,7 +53,13 @@ type EmailViewProps = {export function EmailView(props: EmailViewProps) {return (<EmailProvider threadID={props.threadId()}>- <EmailContent {...props} />+ <SidePanel.Layout>+ <EmailContent {...props} />+ <EmailSidePanelSections+ threadId={props.threadId()}+ title={props.title}+ />+ </SidePanel.Layout></EmailProvider>);}diff --git a/js/app/packages/block-email/component/TopBar.tsx b/js/app/packages/block-email/component/TopBar.tsxindex 69d7f8d95f..a33d0698cf 100644--- a/js/app/packages/block-email/component/TopBar.tsx+++ b/js/app/packages/block-email/component/TopBar.tsx@@ -10,12 +10,15 @@ import {} from '@app/component/next-soup/utils';import type { BlockTool } from '@app/component/ResponsiveBlockToolbar';import { ResponsiveBlockToolbar } from '@app/component/ResponsiveBlockToolbar';+import { SidePanel, useSidePanel } from '@app/component/side-panel';import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';import {SplitHeaderBadge,StaticSplitLabel,} from '@app/component/split-layout/components/SplitLabel';+import { SplitToolbarLeft } from '@app/component/split-layout/components/SplitToolbar';import { useSplitLayout } from '@app/component/split-layout/layout';+import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import { toast } from '@core/component/Toast/Toast';import {getShareDrawerRecipientInput,@@ -23,6 +26,7 @@ import {useShareDialogContext,} from '@core/component/TopBar/ShareButton';import { ENABLE_EMAIL_SHARING } from '@core/constant/featureFlags';+import { registerHotkey } from '@core/hotkey/hotkeys';import { TOKENS } from '@core/hotkey/tokens';import { getActiveCommandByToken, runCommand } from '@core/hotkey/utils';import { isMobile } from '@core/mobile/isMobile';@@ -31,11 +35,12 @@ import { AnimatedTaskIcon } from '@icon/wide-task';import { buildMentionMarkdownString } from '@lexical-core';import CheckIcon from '@phosphor/check.svg';import ProhibitIcon from '@phosphor/prohibit.svg';+import SidePanelIcon from '@phosphor/square-half.svg';import TrashIcon from '@phosphor/trash.svg';import ArrowCounterClockwise from '@phosphor-icons/core/regular/arrow-counter-clockwise.svg?component-solid';import { useEmailLinksQuery } from '@queries/email/link';-import { Button } from '@ui';-import { createSignal } from 'solid-js';+import { Button, cn } from '@ui';+import { createSignal, onCleanup, Show } from 'solid-js';import { useEmailContext } from './EmailContext';export function TopBar(props: {@@ -44,10 +49,28 @@ export function TopBar(props: {isDraft?: boolean;}) {const { popoverSplit } = useSplitLayout();+ const splitPanel = useSplitPanel();const shareCtx = useShareDialogContext();const emailCtx = useEmailContext();const soup = useMaybeSoup();const linksQuery = useEmailLinksQuery();+ const sidePanel = useSidePanel();++ if (splitPanel?.splitHotkeyScope) {+ const reg = registerHotkey({+ hotkey: ']',+ scopeId: splitPanel.splitHotkeyScope,+ hotkeyToken: TOKENS.block.toggleSidePanel,+ description: 'Toggle Side Panel',+ keyDownHandler: () => {+ if (!sidePanel) return false;+ if (!sidePanel.hasSections()) return false;+ sidePanel.toggle();+ return true;+ },+ });+ onCleanup(() => reg.dispose());+ }const isInvite = () => {const row = soup?.items.get(props.id);@@ -198,6 +221,37 @@ export function TopBar(props: {buttonComponent: () => <ShareTrigger />,focusTarget: getShareDrawerRecipientInput,},+ {+ label: () =>+ sidePanel?.isOpen() ? 'Hide Side Panel' : 'Show Side Panel',+ icon: SidePanelIcon,+ action: () => sidePanel?.toggle(),+ isActive: () => sidePanel?.isOpen() ?? false,+ condition: () => !(sidePanel?.isNarrow() ?? isMobile()),+ buttonComponent: () => (+ <Show when={sidePanel}>+ {(panel) => (+ <Button+ depth={2}+ variant="base"+ size="icon-sm"+ class={cn('bg-surface order-20', {+ 'bg-active': sidePanel?.isOpen(),+ })}+ tooltip={+ sidePanel?.isOpen() ? 'Hide Side Panel' : 'Show Side Panel'+ }+ hotkey={TOKENS.block.toggleSidePanel}+ onClick={() => {+ panel().toggle();+ }}+ >+ <SidePanelIcon />+ </Button>+ )}+ </Show>+ ),+ },];return (@@ -228,6 +282,9 @@ export function TopBar(props: {itemType="email"name={props.title}/>+ <SplitToolbarLeft>+ <SidePanel.NarrowTabs />+ </SplitToolbarLeft></>);}diff --git a/js/app/packages/block-email/component/sidepanel/EmailSidePanelSections.tsx b/js/app/packages/block-email/component/sidepanel/EmailSidePanelSections.tsxnew file mode 100644index 0000000000..00d18d93bf--- /dev/null+++ b/js/app/packages/block-email/component/sidepanel/EmailSidePanelSections.tsx@@ -0,0 +1,67 @@+import { SidePanel } from '@app/component/side-panel';+import { EntityPropertiesSection } from '@app/component/side-panel/properties';+import type { Property } from '@property/types';+import { Suspense } from 'solid-js';+import { useEmailContext } from '../EmailContext';++interface EmailSidePanelSectionsProps {+ threadId: string;+ title: string;+}++export function EmailSidePanelSections(props: EmailSidePanelSectionsProps) {+ const emailCtx = useEmailContext();+ const canEdit = () => emailCtx.permissions().isOwner;++ return (+ <>+ <SidePanel.Section id="details" title="Details" defaultOpen order={10}>+ <Suspense fallback={<SidePanel.Loading />}>+ <EntityPropertiesSection+ entityId={props.threadId}+ entityType="THREAD"+ canEdit={canEdit()}+ documentName={props.title}+ includeMetadata+ propertyFilter={(property) => property.isMetadata === true}+ getEmptyLabel={getEmailMetadataEmptyLabel}+ showAddProperty={false}+ />+ </Suspense>+ </SidePanel.Section>+ <SidePanel.Section+ id="properties"+ title="Properties"+ defaultOpen+ order={20}+ >+ <Suspense fallback={<SidePanel.Loading />}>+ <EntityPropertiesSection+ entityId={props.threadId}+ entityType="THREAD"+ canEdit={canEdit()}+ documentName={props.title}+ propertyFilter={(property) => property.isMetadata !== true}+ />+ </Suspense>+ </SidePanel.Section>+ </>+ );+}++function getEmailMetadataEmptyLabel(property: Property) {+ if (!property.isMetadata) return undefined;++ switch (property.displayName) {+ case 'Last Sent':+ return 'No sent messages';+ case 'Last Received':+ return 'No received messages';+ case 'Thread Started':+ return 'No messages';+ case 'Subject':+ return 'No subject';+ default:+ return undefined;+ }+}