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
chore: clean up icon code (#1384)
gbirmana2761f683c38
diff --git a/js/app/packages/app/component/EntityModal/MoveToProjectView.tsx b/js/app/packages/app/component/EntityModal/MoveToProjectView.tsxindex c3bd067d20..a6b6254dbd 100644--- a/js/app/packages/app/component/EntityModal/MoveToProjectView.tsx+++ b/js/app/packages/app/component/EntityModal/MoveToProjectView.tsx@@ -2,7 +2,7 @@ import { BozzyBracket } from '@core/component/BozzyBracket';import {CustomEntityIcon,EntityIcon,- getIconConfig,+ getEntityIconConfig,} from '@core/component/EntityIcon';import { ExplorerSpacer } from '@core/component/FileList/ExplorerSpacer';import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';@@ -366,27 +366,7 @@ export const MoveToProjectView = (props: {props.onFinish();};- const getIcon = createMemo(() => {- switch (props.entity.type) {- case 'channel':- switch (props.entity.channelType) {- case 'direct_message':- return getIconConfig('directMessage');- case 'organization':- return getIconConfig('company');- default:- return getIconConfig('channel');- }- case 'document':- return getIconConfig(props.entity.fileType || 'default');- case 'chat':- return getIconConfig('chat');- case 'project':- return getIconConfig('project');- case 'email':- return getIconConfig(props.entity.isRead ? 'emailRead' : 'email');- }- });+ const getIcon = createMemo(() => getEntityIconConfig(props.entity));return (<div class="" ref={rootScopeId} tabindex={-1}>diff --git a/js/app/packages/app/component/ItemDragAndDrop.tsx b/js/app/packages/app/component/ItemDragAndDrop.tsxindex 043c0c6ffe..8217531360 100644--- a/js/app/packages/app/component/ItemDragAndDrop.tsx+++ b/js/app/packages/app/component/ItemDragAndDrop.tsx@@ -1,5 +1,4 @@import { TruncatedText } from '@core/component/FileList/TruncatedText';-import { fileTypeToBlockName } from '@core/constant/allBlocks';import {DragDropProvider,DragDropSensors,@@ -7,7 +6,8 @@ import {mostIntersecting,useDragDropContext,} from '@thisbeyond/solid-dnd';-import { EntityIcon } from 'core/component/EntityIcon';+import { EntityIcon, getEntityIconType } from 'core/component/EntityIcon';+import type { EntityDragData } from '@macro-entity';import {createContext,createMemo,@@ -38,36 +38,16 @@ export function ItemDragOverlay() {return state?.active.draggable;});- const getEntityIconType = () => {- const data = activeDraggable()?.data;+ const iconType = createMemo(() => {+ const data = activeDraggable()?.data as EntityDragData | undefined;if (!data) return 'default';-- if (data.type === 'document') {- return fileTypeToBlockName(data.subType?.type ?? data.fileType, true);- }-- if (data.type === 'channel') {- switch (data.channelType) {- case 'direct_message':- return 'directMessage';- case 'organization':- return 'company';- default:- return 'channel';- }- }-- if (data.type === 'email') {- return data.isRead ? 'emailRead' : 'email';- }-- return data.type ?? 'default';- };+ return getEntityIconType(data);+ });return (<div class="w-auto max-w-[300px] flex flex-col gap-2 bg-active p-2 rounded-md z-drag shadow-sm pointer-events-none"><div class="flex flex-row items-center gap-2">- <EntityIcon size="sm" targetType={getEntityIconType()} />+ <EntityIcon size="sm" targetType={iconType()} /><TruncatedText size="sm">{activeDraggable()?.data.name}</TruncatedText></div>{/* TODO: when multiselect exists */}diff --git a/js/app/packages/app/component/Launcher.tsx b/js/app/packages/app/component/Launcher.tsxindex 177b9c6d84..327d7733bb 100644--- a/js/app/packages/app/component/Launcher.tsx+++ b/js/app/packages/app/component/Launcher.tsx@@ -296,7 +296,7 @@ const LauncherMenuItem = (props: LauncherMenuItemProps) => {const textFg = () =>USE_ENTITY_COLORS- ? getIconConfig(props.creatableBlock.blockName ?? 'pdf').foreground+ ? getIconConfig(props.creatableBlock.blockName).foreground: 'text-accent';const Icon = props.creatableBlock.icon;@@ -342,8 +342,7 @@ const LauncherMenuItem = (props: LauncherMenuItemProps) => {<divclass="absolute size-full inset-0 transition-transform origin-top opacity-20 ease duration-200 mix-blend-color"classList={{- [getIconConfig(props.creatableBlock.blockName ?? 'pdf').background]:- true,+ [getIconConfig(props.creatableBlock.blockName).background]: true,'scale-y-0': !props.focused,'scale-y-100': props.focused,}}diff --git a/js/app/packages/app/component/Soup/utils/filterConfigs.ts b/js/app/packages/app/component/Soup/utils/filterConfigs.tsindex d73fc33f0d..c2dfb89ab9 100644--- a/js/app/packages/app/component/Soup/utils/filterConfigs.ts+++ b/js/app/packages/app/component/Soup/utils/filterConfigs.ts@@ -67,7 +67,7 @@ export const ENTITY_TYPE_FILTERS: EntityTypeFilterConfig[] = [kind: 'channelCategory',channelCategory: 'groups',label: 'Teams',- iconType: 'directMessage',+ iconType: 'direct_message',enabled: true,shortcut: 'm',},diff --git a/js/app/packages/app/component/SoupContext.tsx b/js/app/packages/app/component/SoupContext.tsxindex 9e72dacbab..a3d8ae8148 100644--- a/js/app/packages/app/component/SoupContext.tsx+++ b/js/app/packages/app/component/SoupContext.tsx@@ -28,6 +28,7 @@ import {import { entityHasUnreadNotifications } from '@notifications';import type { PreviewViewStandardLabel } from '@service-email/generated/schemas';import type { PropertiesEntityType } from '@service-properties/client';+import { ChannelTypeEnum } from '@service-comms/client';import { useSetPropertyStatusCompleteMutation } from '@queries/properties/entity';import { storageServiceClient } from '@service-storage/client';import { createLazyMemo } from '@solid-primitives/memo';@@ -698,7 +699,8 @@ export function createNavigationEntityListShortcut({{canExecute: (entity) => {if (entity.type === 'channel') {- if (entity.channelType === 'direct_message') return false;+ if (entity.channelType === ChannelTypeEnum.DirectMessage)+ return false;const currentUserId = userId();if (!currentUserId) return false;diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsxindex c531fc225d..33c04eab7c 100644--- a/js/app/packages/app/component/UnifiedListView.tsx+++ b/js/app/packages/app/component/UnifiedListView.tsx@@ -9,6 +9,7 @@ import {} from '@app/component/soupFilters';import { URL_PARAMS as CHANNEL_PARAMS } from '@block-channel/constants';import { codeFileExtensions } from '@block-code/util/languageSupport';+import { ChannelTypeEnum } from '@service-comms/client';import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';import { DeprecatedButton } from '@core/component/FormControls/DeprecatedButton';import DropdownMenu from '@core/component/FormControls/DropdownMenu';@@ -776,7 +777,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {if (channelCategoryFilter_.length > 0) {filterFns.push((entity) => {if (entity.type !== 'channel') return true;- const isDm = entity.channelType === 'direct_message';+ const isDm = entity.channelType === ChannelTypeEnum.DirectMessage;const includePeople = channelCategoryFilter_.includes('people');const includeGroups = channelCategoryFilter_.includes('groups');// Defensive: if both are selected, behave like "no refinement".diff --git a/js/app/packages/app/component/command/KonsoleItem.tsx b/js/app/packages/app/component/command/KonsoleItem.tsxindex 9cdfd242d3..9a1ce2d813 100644--- a/js/app/packages/app/component/command/KonsoleItem.tsx+++ b/js/app/packages/app/component/command/KonsoleItem.tsx@@ -7,7 +7,7 @@ import { Hotkey } from '@core/component/Hotkey';import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';import { Message } from '@core/component/Message';import { UserIcon } from '@core/component/UserIcon';-import { fileTypeToBlockName } from '@core/constant/allBlocks';+import { fileTypeToBlockName, itemToBlockName } from '@core/constant/allBlocks';import {ENABLE_GMAIL_BASED_CONTACTS,ENABLE_TASKS_TABS,@@ -24,6 +24,7 @@ import type { BlockOrchestrator } from '@core/orchestrator';import { type ChannelWithParticipants, idToDisplayName } from '@core/user';import Terminal from '@phosphor-icons/core/regular/terminal.svg?component-solid';import type { Channel } from '@service-comms/generated/models/channel';+import { ChannelTypeEnum } from '@service-comms/client';import type { Attachment } from '@service-email/generated/schemas';import { useUserId } from '@core/context/user';import type { BasicDocumentSubTypeProperty } from '@service-storage/generated/schemas';@@ -82,7 +83,7 @@ export function hydrateChannel(const chan = lookup[item.data.id];if (!chan) return item;item.data.channel_type = chan.channel_type;- if (item.data.channel_type === 'direct_message') {+ if (item.data.channel_type === ChannelTypeEnum.DirectMessage) {item.data.participants = (chan as ChannelWithParticipants).participants;}}@@ -430,15 +431,13 @@ function getCommandItemBlockName(icon?: boolean): BlockName | BlockAlias | undefined {if (item.type === 'item') {- if (item.data.itemType === 'document') {- if (item.data.subType && item.data.subType.type === 'task') {- return 'task';- }- if (item.data.fileType) {- return fileTypeToBlockName(item.data.fileType, icon);- }- }- return fileTypeToBlockName(item.data.itemType, icon) ?? 'unknown';+ return itemToBlockName(+ {+ ...item.data,+ type: item.data.itemType,+ },+ icon+ );} else if (item.type === 'channel') {return 'channel';} else if (item.type === 'email') {@@ -482,12 +481,13 @@ export function filterItemByCategory(item: CommandItemCard) {case 'Channels':return (item.type === 'channel' &&- (item.data.channel_type === 'organization' ||- item.data.channel_type === 'private')+ (item.data.channel_type === ChannelTypeEnum.Organization ||+ item.data.channel_type === ChannelTypeEnum.Private));case 'DMs':return (- item.type === 'channel' && item.data.channel_type === 'direct_message'+ item.type === 'channel' &&+ item.data.channel_type === ChannelTypeEnum.DirectMessage);case 'Documents':return (@@ -582,7 +582,7 @@ export function CommandItemCard(props: CommandItemProps) {if (props.item.type === 'channel' &&- props.item.data.channel_type === 'direct_message'+ props.item.data.channel_type === ChannelTypeEnum.DirectMessage) {const participants = props.item.data.participants;if (participants && participants.length > 0) {@@ -599,9 +599,12 @@ export function CommandItemCard(props: CommandItemProps) {/>);}- targetType = 'directMessage';+ targetType = 'direct_message';}}+ if (props.item.type === 'channel' && props.item.data.channel_type) {+ targetType = props.item.data.channel_type;+ }return <EntityIcon targetType={targetType} size="sm" />;}}</Match>diff --git a/js/app/packages/app/component/command/useCommandItems.ts b/js/app/packages/app/component/command/useCommandItems.tsindex 9cc013d683..0232950684 100644--- a/js/app/packages/app/component/command/useCommandItems.ts+++ b/js/app/packages/app/component/command/useCommandItems.ts@@ -5,6 +5,7 @@ import { mapFromListsByKey } from '@core/util/compareUtils';import { useHistoryQuery } from '@queries/history/history';import type { Channel } from '@service-comms/generated/models/channel';import type { ChannelType } from '@service-comms/generated/models/channelType';+import { ChannelTypeEnum } from '@service-comms/client';import { createMemo } from 'solid-js';import type { CommandItemCard } from './KonsoleItem';@@ -93,7 +94,7 @@ export function useCommandItems() {name: channel.name!,channel_type: channel.channel_type,participants:- channel.channel_type === 'direct_message'+ channel.channel_type === ChannelTypeEnum.DirectMessage? (channel as any).participants: undefined,},diff --git a/js/app/packages/app/component/dock/QuickAccess.tsx b/js/app/packages/app/component/dock/QuickAccess.tsxindex 93db749cdb..8a1e4f134c 100644--- a/js/app/packages/app/component/dock/QuickAccess.tsx+++ b/js/app/packages/app/component/dock/QuickAccess.tsx@@ -16,6 +16,7 @@ import {type UnifiedNotification,} from '@notifications';import type { ApiChannelWithLatest as ChannelWithLatest } from '@service-comms/generated/models';+import { ChannelTypeEnum } from '@service-comms/client';import { useUserId } from '@core/context/user';import { NotificationEventType } from '@service-notification/generated/schemas';import { createMemo, createSignal, For, Show } from 'solid-js';@@ -132,7 +133,7 @@ function QuickAccessItem(props: QuickAccessItemProps) {};const getRecipientId = () => {- if (props.channel.channel_type === 'direct_message') {+ if (props.channel.channel_type === ChannelTypeEnum.DirectMessage) {let userIdValue = userId();let recipient = props.channel.participants.find((p) => p.user_id !== userIdValue@@ -211,7 +212,8 @@ export function QuickAccess() {if (!isHighPriorityNotification(notification)) return false;// For DM channels, include all message notifications- if (channel.channel_type === 'direct_message') return true;+ if (channel.channel_type === ChannelTypeEnum.DirectMessage)+ return true;// For other channels, only include mentions and repliesreturn (diff --git a/js/app/packages/block-canvas/component/nodes/EntityMention.tsx b/js/app/packages/block-canvas/component/nodes/EntityMention.tsxindex 4da47281a7..f03c3d9a20 100644--- a/js/app/packages/block-canvas/component/nodes/EntityMention.tsx+++ b/js/app/packages/block-canvas/component/nodes/EntityMention.tsx@@ -5,7 +5,7 @@ import { type BlockName, useBlockId } from '@core/block';import { CircleSpinner } from '@core/component/CircleSpinner';import { HoverCard } from '@core/component/HoverCard';import { PopupPreview } from '@core/component/DocumentPreview';-import { EntityIcon } from '@core/component/EntityIcon';+import { EntityIcon, getPreviewItemIconType } from '@core/component/EntityIcon';import { itemToBlockName } from '@core/constant/allBlocks';import { isTouchDevice } from '@core/mobile/isTouchDevice';import { type PreviewItemNoAccess, useItemPreview } from '@queries/preview';@@ -124,46 +124,8 @@ export function File(props: { node: EntityMentionNode; mode: RenderMode }) {}});- // Get icon type using the same logic as EntityWithEverythingconst iconType = createMemo(() => {- const currentItem = item();- if (- !currentItem ||- currentItem.loading ||- currentItem.access !== 'access'- ) {- return 'default';- }-- switch (currentItem.type) {- case 'channel':- switch (currentItem.channelType) {- case 'direct_message':- return 'directMessage';- case 'organization':- return 'company';- default:- return 'channel';- }- case 'document':- // TODO: consolidate is task logic, see isTaskEntity- if (- currentItem.fileType === 'md' &&- currentItem.subType?.type === 'task'- ) {- return 'task';- }- if (currentItem.fileType) return currentItem.fileType;- return 'default';- case 'chat':- return 'chat';- case 'project':- return 'project';- case 'email':- return 'email';- default:- return 'default';- }+ return getPreviewItemIconType(item());});const fileName = createMemo(() => {diff --git a/js/app/packages/block-channel/component/Top.tsx b/js/app/packages/block-channel/component/Top.tsxindex 17d8ff428f..e2936550de 100644--- a/js/app/packages/block-channel/component/Top.tsx+++ b/js/app/packages/block-channel/component/Top.tsx@@ -17,6 +17,7 @@ import HashIcon from '@icon/regular/hash.svg';import LinkIcon from '@icon/regular/link.svg';import type { ChannelParticipant } from '@service-comms/generated/models/channelParticipant';import type { ChannelType } from '@service-comms/generated/models/channelType';+import { ChannelTypeEnum } from '@service-comms/client';import { useUserId } from '@core/context/user';import { createMemo, Show } from 'solid-js';import { AttachmentsModal } from './AttachmentsModal';@@ -37,7 +38,7 @@ function TopIcon(props: TopIconProps) {return (<Show- when={props.channelType === 'direct_message' && recipient()}+ when={props.channelType === ChannelTypeEnum.DirectMessage && recipient()}fallback={<HashIcon class="w-4 h-4" />}>{(recipient) => {@@ -98,7 +99,8 @@ export function Top(props: TopProps) {id={props.channelId}itemType="channel"lockRename={- props.channelType === 'direct_message' || !isAdminOrOwner()+ props.channelType === ChannelTypeEnum.DirectMessage ||+ !isAdminOrOwner()}/></div>@@ -109,7 +111,7 @@ export function Top(props: TopProps) {</SplitHeaderRight><SplitToolbarRight><div class="p-1 flex flex-row gap-1 items-center h-full">- <Show when={props.channelType === 'public'}>+ <Show when={props.channelType === ChannelTypeEnum.Public}><DeprecatedIconButtontheme="clear"size="sm"@@ -124,7 +126,7 @@ export function Top(props: TopProps) {buttonSize="sm"/><AttachmentsModal />- <Show when={props.channelType !== 'direct_message'}>+ <Show when={props.channelType !== ChannelTypeEnum.DirectMessage}><ParticipantManagerchannelId={props.channelId}channelType={props.channelType}diff --git a/js/app/packages/block-project/component/ProjectCreateMenu.tsx b/js/app/packages/block-project/component/ProjectCreateMenu.tsxindex 54cf9ce2f9..9dcaf6d98f 100644--- a/js/app/packages/block-project/component/ProjectCreateMenu.tsx+++ b/js/app/packages/block-project/component/ProjectCreateMenu.tsx@@ -25,7 +25,7 @@ type MenuItemProps = {};function MenuItem(props: MenuItemProps) {- const selectedColor = getIconConfig(props.blockName ?? 'pdf').foreground;+ const selectedColor = getIconConfig(props.blockName).foreground;return (<DropdownMenu.Itemdiff --git a/js/app/packages/core/component/AI/component/input/Attachment.tsx b/js/app/packages/core/component/AI/component/input/Attachment.tsxindex c118bba5ad..f0a458af9d 100644--- a/js/app/packages/core/component/AI/component/input/Attachment.tsx+++ b/js/app/packages/core/component/AI/component/input/Attachment.tsx@@ -4,7 +4,7 @@ import {isDssImage,isImageAttachment,} from '@core/component/AI/util/attachment';-import { EntityIcon, channelTypeIcon } from '@core/component/EntityIcon';+import { EntityIcon } from '@core/component/EntityIcon';import { ImagePreview } from '@core/component/ImagePreview';import { toast } from '@core/component/Toast/Toast';import { fileTypeToBlockName } from '@core/constant/allBlocks';@@ -16,7 +16,6 @@ import Envelope from '@phosphor-icons/core/regular/envelope.svg';import Close from '@phosphor-icons/core/regular/x.svg?component-solid';import type { Accessor } from 'solid-js';import { createMemo, createSignal, For, Match, Show, Switch } from 'solid-js';-import { Dynamic } from 'solid-js/web';type AttachmentListProps = {removeAttachment: (id: string) => void;@@ -162,11 +161,7 @@ function ChatAttachment(props: {>{(a) => (<div class="flex gap-1 items-center">- <Dynamic- component={channelTypeIcon(a().channel_type)}- width={14}- height={14}- />+ <EntityIcon targetType={a().channel_type || 'channel'} /><div> {name()}</div></div>)}diff --git a/js/app/packages/core/component/EntityIcon.tsx b/js/app/packages/core/component/EntityIcon.tsxindex 4d7266130a..2ae24c2856 100644--- a/js/app/packages/core/component/EntityIcon.tsx+++ b/js/app/packages/core/component/EntityIcon.tsx@@ -3,7 +3,9 @@ import {blockAcceptedFileExtensionSet,fileTypeToBlockName,isBlockAlias,+ itemToBlockName,} from '@core/constant/allBlocks';+import { match } from 'ts-pattern';import { USE_WIDE_ICONS } from '@core/constant/featureFlags';import Building from '@icon/duotone/building-duotone.svg';import Chat from '@icon/duotone/chat-duotone.svg';@@ -46,6 +48,13 @@ import ThreeUsersIcon from '@icon/duotone/users-three-duotone.svg';import { FileTypeMap } from '@service-storage/fileTypeMap';import type { ChannelType } from '@service-cognition/generated/schemas/channelType';import type { FileType } from '@service-storage/generated/schemas/fileType';+import type {+ EntityData,+ ChannelEntity,+ DocumentEntity,+ EmailEntity,+} from '@macro-entity';+import type { PreviewItem } from '@queries/preview';import type { Component, JSX } from 'solid-js';import { Dynamic } from 'solid-js/web';@@ -59,11 +68,9 @@ type IconConfig = {export type EntityWithValidIcon =| BlockName| BlockAlias+ | ChannelType| 'default'| 'sharedProject'- | 'company'- | 'user'- | 'directMessage'| 'emailRead'| 'archive'| 'html';@@ -93,11 +100,29 @@ export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {background: 'bg-default-bg',prettyName: 'Channel',},- company: {+ public: {+ icon: GlobeIcon,+ foreground: 'text-default',+ background: 'bg-default-bg',+ prettyName: 'Public Channel',+ },+ organization: {icon: Building,foreground: 'text-default',background: 'bg-default-bg',- prettyName: 'Company',+ prettyName: 'Organization Channel',+ },+ private: {+ icon: ThreeUsersIcon,+ foreground: 'text-default',+ background: 'bg-default-bg',+ prettyName: 'Private Channel',+ },+ direct_message: {+ icon: Users,+ foreground: 'text-default',+ background: 'bg-default-bg',+ prettyName: 'Direct Message',},email: {icon: Email,@@ -189,23 +214,11 @@ export const ENTITY_ICON_CONFIGS: Record<EntityWithValidIcon, IconConfig> = {background: 'bg-default-bg',prettyName: 'File',},- directMessage: {- icon: Users,- foreground: 'text-default',- background: 'bg-default-bg',- prettyName: 'Direct Message',- },- user: {- icon: User,- foreground: 'text-default',- background: 'bg-default-bg',- prettyName: 'Direct Message',- },emailRead: {icon: EmailRead,foreground: 'text-default',background: 'bg-default-bg',- prettyName: 'Direct Message',+ prettyName: 'Read Email',},task: {icon: Check,@@ -244,7 +257,10 @@ export const WIDE_ICONS: Record<EntityWithValidIcon, Component> = {canvas: WideDiagram,html: WideFileCode,channel: WideChannel,- company: Building,+ public: GlobeIcon,+ organization: Building,+ private: ThreeUsersIcon,+ direct_message: WideChat,email: WideEmail,code: WideFileCode,csv: WideCsv,@@ -260,8 +276,6 @@ export const WIDE_ICONS: Record<EntityWithValidIcon, Component> = {video: WideVideo,contact: WideUser,default: WideUnknown,- directMessage: WideChat,- user: WideUser,emailRead: WideEmail,task: WideTask,};@@ -361,7 +375,7 @@ export function CustomEntityIcon() {const config = () =>ENTITY_ICON_CONFIGS[validateEntity(props.targetType || 'default')];- const sizeClass = () => ICON_SIZE_CLASSES[props.size ?? 'sm'];+ const sizeClass = () => ICON_SIZE_CLASSES[props.size ?? 'xs'];const isMonochrome = () => props.theme === 'monochrome';return (<div@@ -390,17 +404,32 @@ export function getIconConfig(return config;}-export function channelTypeIcon(channelType: ChannelType | undefined) {- switch (channelType) {- case 'direct_message':- return User;- case 'private':- return ThreeUsersIcon;- case 'organization':- return Building;- case 'public':- return GlobeIcon;- default:- return Channel;+type EntityIconData = Pick<EntityData, 'type'> & {+ channelType?: ChannelEntity['channelType'];+ fileType?: DocumentEntity['fileType'] | null;+ subType?: DocumentEntity['subType'];+ isRead?: EmailEntity['isRead'];+};++export function getEntityIconType(entity: EntityIconData): EntityWithValidIcon {+ const typeString = match(entity)+ .with({ type: 'channel' }, (e) => e.channelType || 'channel')+ .with({ type: 'document' }, (e) => itemToBlockName(e, true) ?? 'default')+ .with({ type: 'email', isRead: true }, () => 'emailRead')+ .with({ type: 'email' }, () => 'email')+ .otherwise((e) => e.type);++ return validateEntity(typeString);+}++export function getEntityIconConfig(entity: EntityData) {+ return getIconConfig(getEntityIconType(entity));+}++export function getPreviewItemIconType(item: PreviewItem): EntityWithValidIcon {+ if (item.loading || item.access !== 'access') {+ return 'default';}++ return getEntityIconType(item);}diff --git a/js/app/packages/core/component/ItemPreview.tsx b/js/app/packages/core/component/ItemPreview.tsxindex 60d301eca3..d14d3e5473 100644--- a/js/app/packages/core/component/ItemPreview.tsx+++ b/js/app/packages/core/component/ItemPreview.tsx@@ -27,7 +27,7 @@ import { PopupPreview } from './DocumentPreview';import { HoverCard } from './HoverCard';import { useSplitLayout } from '../../app/component/split-layout/layout';import { DeprecatedTextButton } from './DeprecatedTextButton';-import { EntityIcon } from './EntityIcon';+import { EntityIcon, getPreviewItemIconType } from './EntityIcon';export function useItemPreviewData(entity: Accessor<ItemEntity>) {const [item] = useItemPreview(entity);@@ -82,26 +82,7 @@ export function useItemPreviewData(entity: Accessor<ItemEntity>) {};const targetType = () => {- const currentItem = item();- if (currentItem.loading || currentItem.access !== 'access') {- return undefined;- }-- switch (currentItem.type) {- case 'document':- return currentItem.subType?.type ?? currentItem.fileType;- case 'channel':- switch (currentItem.channelType) {- case 'direct_message':- return 'directMessage';- case 'organization':- return 'company';- default:- return 'channel';- }- default:- return currentItem.type;- }+ return getPreviewItemIconType(item());};const ItemEntityIcon = (diff --git a/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx b/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsxindex 91f2ad9721..09336ef0bf 100644--- a/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx@@ -4,12 +4,12 @@ import {useMaybeBlockName,} from '@core/block';import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';-import { EntityIcon } from '@core/component/EntityIcon';import {DropdownMenuContent,MenuItem,MenuSeparator,} from '@core/component/Menu';+import { useItemPreviewData } from '@core/component/ItemPreview';import { ScopedPortal } from '@core/component/ScopedPortal';import { toast } from '@core/component/Toast/Toast';import { resolveBlockAlias, verifyBlockName } from '@core/constant/allBlocks';@@ -18,7 +18,6 @@ import { canNestBlock, createBlockInstance } from '@core/orchestrator';import {isAccessiblePreviewItem,type AccessiblePreviewItem,- useItemPreview,} from '@queries/preview';import { matches } from '@core/util/match';import TrashSimple from '@icon/duotone/trash-simple-duotone.svg';@@ -96,7 +95,7 @@ function DocumentCardInner(props: DocumentCardDecoratorProps) {const previewType = () =>blockNameToItemType(verifyBlockName(props.blockName));- const [item] = useItemPreview(() => ({+ const { item, ItemEntityIcon } = useItemPreviewData(() => ({id: props.documentId,type: previewType(),}));@@ -336,30 +335,7 @@ function DocumentCardInner(props: DocumentCardDecoratorProps) {<div class="p-2"><div class="flex center gap-2 items-center h-4"><div class="flex-shrink-0">- <Show- when={props.item.type === 'channel'}- fallback={- <EntityIcon- targetType={- props.item.type === 'document'- ? (props.item.subType?.type ?? props.item.fileType)- : props.item.type- }- size="sm"- />- }- >- <EntityIcon- size="sm"- targetType={- props.item.channelType === 'direct_message'- ? 'directMessage'- : props.item.channelType === 'organization'- ? 'company'- : 'channel'- }- />- </Show>+ <ItemEntityIcon size="sm" /></div><div class="text-sm font-semibold truncate grow-1"><BlockLink id={props.item.id} blockOrFileName={props.blockName}>diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsxindex f444cd7768..5b0a2d841b 100644--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx@@ -376,13 +376,7 @@ export function MentionsMenuItem(props: {return (<EntityIconsize="xs"- targetType={- props.item.data.channel_type === 'direct_message'- ? 'directMessage'- : props.item.data.channel_type === 'organization'- ? 'company'- : 'channel'- }+ targetType={props.item.data.channel_type || 'channel'}/>);diff --git a/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx b/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsxindex f63f0dec2c..16d5dd57b2 100644--- a/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx+++ b/js/app/packages/core/component/Properties/component/modal/shared/PropertyEntitySelector.tsx@@ -1,8 +1,8 @@import { useMaybeBlockId } from '@core/block';import { useChannelsContext } from '@core/context/channels';-import { EntityIcon } from '@core/component/EntityIcon';+import { EntityIcon, getEntityIconType } from '@core/component/EntityIcon';import { UserIcon } from '@core/component/UserIcon';-import { fileTypeToBlockName } from '@core/constant/allBlocks';+import { EntityDataTypeIcon } from '../../../utils/PropertyDataTypeIcon';import type { IUser } from '@core/user';import {idToEmail,@@ -12,13 +12,6 @@ import {useDisplayName,} from '@core/user';import { createFreshSearch } from '@core/util/freshSort';-import CompanyIcon from '@icon/duotone/building-duotone.svg';-import ChannelBuildingIcon from '@icon/duotone/building-office-duotone.svg';-import ThreadIcon from '@icon/duotone/envelope-duotone.svg';-import GlobeIcon from '@icon/duotone/globe-duotone.svg';-import ChannelIcon from '@icon/duotone/hash-duotone.svg';-import User from '@icon/duotone/user-duotone.svg';-import ThreeUsersIcon from '@icon/duotone/users-three-duotone.svg';import SearchIcon from '@icon/regular/magnifying-glass.svg';import {createEmailsInfiniteQuery,@@ -67,8 +60,6 @@ type EntityInputProps = {onClose?: () => void;};-const ICON_CLASSES = 'size-4 text-ink-muted';-function getEntityTypePluralLabel(entityType: EntityType | null | undefined): string {@@ -107,37 +98,27 @@ function getEntityIcon(entity: CombinedEntity) {/>);case 'channel':- switch (entity.data.channel_type) {- case 'direct_message':- return <User class={ICON_CLASSES} />;- case 'private':- return <ThreeUsersIcon class={ICON_CLASSES} />;- case 'organization':- return <ChannelBuildingIcon class={ICON_CLASSES} />;- case 'public':- return <GlobeIcon class={ICON_CLASSES} />;- default:- return <ChannelIcon class={ICON_CLASSES} />;- }- case 'item': {- const blockName =- entity.data.type === 'document'- ? entity.data.subType !== null &&- entity.data.subType !== undefined &&- entity.data.subType.type === 'task'- ? 'task'- : fileTypeToBlockName(entity.data.fileType, true)- : entity.data.type === 'chat'- ? 'chat'- : entity.data.type === 'project'- ? 'project'- : 'unknown';- return <EntityIcon targetType={blockName} size="xs" />;- }+ return (+ <EntityIcon+ targetType={entity.data.channel_type || 'channel'}+ size="xs"+ class="text-ink-muted"+ />+ );+ case 'item':+ return (+ <EntityIcon+ targetType={getEntityIconType(entity.data)}+ size="xs"+ class="text-ink-muted"+ />+ );case 'company':- return <CompanyIcon class={ICON_CLASSES} />;+ return (+ <EntityDataTypeIcon property={{ specificEntityType: 'COMPANY' }} />+ );case 'thread':- return <ThreadIcon class={ICON_CLASSES} />;+ return <EntityIcon targetType="email" size="xs" class="text-ink-muted" />;}}diff --git a/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx b/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsxindex fef7f18d3c..a588acd8cc 100644--- a/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx+++ b/js/app/packages/core/component/Properties/hooks/usePropertyEntityDisplay.tsx@@ -126,7 +126,9 @@ export function usePropertyEntityDisplay(}).with('PROJECT', () => <CoreEntityIcon targetType="project" size="xs" />).with('CHAT', () => <CoreEntityIcon targetType="chat" size="xs" />)- .with('COMPANY', () => <CoreEntityIcon targetType="company" size="xs" />)+ .with('COMPANY', () => (+ <CoreEntityIcon targetType="organization" size="xs" />+ )).with('THREAD', () => <CoreEntityIcon targetType="email" size="xs" />).otherwise(() => {if (options && 'fallbackIcon' in options) {diff --git a/js/app/packages/core/component/RecipientSelector.tsx b/js/app/packages/core/component/RecipientSelector.tsxindex 5c8a3c4c35..ab772949f8 100644--- a/js/app/packages/core/component/RecipientSelector.tsx+++ b/js/app/packages/core/component/RecipientSelector.tsx@@ -1,4 +1,4 @@-import { CustomEntityIcon, channelTypeIcon } from '@core/component/EntityIcon';+import { EntityIcon } from '@core/component/EntityIcon';import { toast } from '@core/component/Toast/Toast';import { UserIcon } from '@core/component/UserIcon';import {@@ -170,9 +170,8 @@ function RecipientComboboxItem(props: RecipientComboboxItemProps): JSX.Element {return (<Combobox.ItemLabel class="flex flex-row w-full gap-1.5 text-ink-muted select-none text-sm"><div class="flex flex-col items-center justify-center p-1">- <CustomEntityIcon- icon={channelTypeIcon(item().data.channel_type)}- size="xs"+ <EntityIcon+ targetType={item().data.channel_type || 'channel'}/></div><p class={'truncate my-auto'}>{item().data.name}</p>diff --git a/js/app/packages/core/constant/allBlocks.ts b/js/app/packages/core/constant/allBlocks.tsindex 50adce130a..eebfddb3be 100644--- a/js/app/packages/core/constant/allBlocks.ts+++ b/js/app/packages/core/constant/allBlocks.ts@@ -221,7 +221,8 @@ type ItemLike = {* @return The block name or undefined if there is no appropriate block.*/export function itemToBlockName(- item: ItemLike+ item: ItemLike,+ icon?: boolean): BlockName | BlockAlias | undefined {const subTypeName =item.subType && 'type' in item.subType@@ -231,9 +232,9 @@ export function itemToBlockName(return subTypeName;}if (item.fileType) {- return fileTypeToBlockName(item.fileType);+ return fileTypeToBlockName(item.fileType, icon);}- return fileTypeToBlockName(item.type);+ return fileTypeToBlockName(item.type, icon);}/**diff --git a/js/app/packages/core/context/channels.ts b/js/app/packages/core/context/channels.tsindex 07d57507bc..35bc10eef5 100644--- a/js/app/packages/core/context/channels.ts+++ b/js/app/packages/core/context/channels.ts@@ -3,6 +3,7 @@ import type {ApiActivity as ChannelsActivity,ApiChannelWithLatest,} from '@service-comms/generated/models';+import { ChannelTypeEnum } from '@service-comms/client';import { useListChannelsQuery } from '@queries/channel/channels';import { useChannelsActivityQuery } from '@queries/channel/activity';import { queryReadyGate } from '@queries/gate';@@ -88,7 +89,7 @@ export function useDmActivityByUserId(): Accessor<Map<string, number>> {const map = new Map<string, LastInteractionTimestamp>();for (const channel of allChannels) {- if (channel.channel_type !== 'direct_message') continue;+ if (channel.channel_type !== ChannelTypeEnum.DirectMessage) continue;const otherParticipant = channel.participants.find((p) => p.user_id !== currentUserdiff --git a/js/app/packages/macro-entity/src/components/Entity.tsx b/js/app/packages/macro-entity/src/components/Entity.tsxindex d1d308e3d6..bdba4f808c 100644--- a/js/app/packages/macro-entity/src/components/Entity.tsx+++ b/js/app/packages/macro-entity/src/components/Entity.tsx@@ -1,4 +1,4 @@-import { getIconConfig } from 'core/component/EntityIcon';+import { getEntityIconConfig } from 'core/component/EntityIcon';import { StaticMarkdown } from 'core/component/LexicalMarkdown/component/core/StaticMarkdown';import { unifiedListMarkdownTheme } from 'core/component/LexicalMarkdown/theme';import type { Component, JSX, ParentProps, Ref } from 'solid-js';@@ -21,24 +21,7 @@ interface EntityProps<T extends EntityData> extends ParentProps {export function Entity<T extends EntityData = EntityData>(props: EntityProps<T>) {- const iconConfig = createMemo(() => {- switch (props.entity.type) {- case 'channel':- if (props.entity.channelType === 'direct_message')- return getIconConfig('directMessage');-- if (props.entity.channelType === 'organization')- return getIconConfig('company');-- return getIconConfig('channel');- case 'document':- return getIconConfig(props.entity.fileType || 'default');- case 'email':- return getIconConfig(props.entity.isRead ? 'emailRead' : 'email');- default:- return getIconConfig(props.entity.type);- }- });+ const iconConfig = createMemo(() => getEntityIconConfig(props.entity));const content = children(() => {if (props.children) return props.children;diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsxindex 457a7e78cd..1ec3a82f53 100644--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx@@ -23,9 +23,10 @@ import {} from '@notifications';import { formatDocumentName } from '@service-storage/util/filename';import { syncServiceClient } from '@service-sync/client';+import { ChannelTypeEnum } from '@service-comms/client';import { mergeRefs } from '@solid-primitives/refs';import { createDraggable } from '@thisbeyond/solid-dnd';-import { getIconConfig } from 'core/component/EntityIcon';+import { getEntityIconConfig } from 'core/component/EntityIcon';import { StaticMarkdown } from 'core/component/LexicalMarkdown/component/core/StaticMarkdown';import { unifiedListMarkdownTheme } from 'core/component/LexicalMarkdown/theme';import { UserIcon } from 'core/component/UserIcon';@@ -762,29 +763,7 @@ export function EntityWithEverything(const { keydownDataDuringTask } = trackKeydownDuringTask();const userEmail = useEmail();- const getIcon = createMemo(() => {- switch (props.entity.type) {- case 'channel':- switch (props.entity.channelType) {- case 'direct_message':- return getIconConfig('directMessage');- case 'organization':- return getIconConfig('company');- default:- return getIconConfig('channel');- }- case 'document':- if (isTaskEntity(props.entity)) return getIconConfig('task');- if (props.entity.fileType) return getIconConfig(props.entity.fileType);- return getIconConfig('default');- case 'chat':- return getIconConfig('chat');- case 'project':- return getIconConfig('project');- case 'email':- return getIconConfig(props.entity.isRead ? 'emailRead' : 'email');- }- });+ const getIcon = createMemo(() => getEntityIconConfig(props.entity));/*** TODO (seamus + teo) : These notifications are being attached to the wrong@@ -1077,7 +1056,7 @@ export function EntityWithEverything(<Showwhen={props.entity.type === 'channel' &&- props.entity.channelType === 'direct_message'+ props.entity.channelType === ChannelTypeEnum.DirectMessage}fallback={<Dynamic@@ -1381,7 +1360,7 @@ export function EntityWithEverything(<Showwhen={props.entity.type === 'channel' &&- props.entity.channelType === 'direct_message'+ props.entity.channelType === ChannelTypeEnum.DirectMessage}fallback={<Dynamic@@ -1539,7 +1518,7 @@ function DirectMessageIcon(props: { entity: EntityData }) {.at(0): undefined;- const Fallback = () => <EntityIcon targetType="directMessage" />;+ const Fallback = () => <EntityIcon targetType="direct_message" />;return (<div class="bg-panel size-5 rounded-full p-[2px]">diff --git a/js/app/packages/macro-entity/src/components/InlineEntity.tsx b/js/app/packages/macro-entity/src/components/InlineEntity.tsxindex a116731a8d..398a85342d 100644--- a/js/app/packages/macro-entity/src/components/InlineEntity.tsx+++ b/js/app/packages/macro-entity/src/components/InlineEntity.tsx@@ -1,27 +1,11 @@import { createMemo } from 'solid-js';import type { EntityData } from '../types/entity';-import { getIconConfig } from '@core/component/EntityIcon';+import { getEntityIconConfig } from '@core/component/EntityIcon';import { cn } from '@ui/utils/classname';import { Dynamic } from 'solid-js/web';-import { match } from 'ts-pattern';export function InlineEntity(props: { entity: EntityData }) {- const iconConfig = createMemo<ReturnType<typeof getIconConfig>>(() => {- return match(props.entity)- .with({ type: 'channel', channelType: 'direct_message' }, () =>- getIconConfig('directMessage')- )- .with({ type: 'channel', channelType: 'organization' }, () =>- getIconConfig('company')- )- .with({ type: 'channel' }, () => getIconConfig('channel'))- .with({ type: 'document' }, (entity) =>- getIconConfig(entity.subType?.type ?? entity.fileType ?? 'default')- )- .with({ type: 'email', isRead: true }, () => getIconConfig('emailRead'))- .with({ type: 'email' }, () => getIconConfig('email'))- .otherwise((entity) => getIconConfig(entity.type));- });+ const iconConfig = createMemo(() => getEntityIconConfig(props.entity));return (<div class="flex items-center gap-2 min-w-0">diff --git a/js/app/packages/macro-entity/src/queries/dss.ts b/js/app/packages/macro-entity/src/queries/dss.tsindex a5361a9493..6ae145e5f4 100644--- a/js/app/packages/macro-entity/src/queries/dss.ts+++ b/js/app/packages/macro-entity/src/queries/dss.ts@@ -62,7 +62,7 @@ const resolveDocumentEntityName = (entity.subType === null || entity.subType === undefined? null: {- type: entity.subType.type as 'task',+ type: entity.subType.type,is_completed: entity.subType.is_completed,},});diff --git a/js/app/packages/macro-entity/src/queries/rename.ts b/js/app/packages/macro-entity/src/queries/rename.tsindex 562a1575b7..a0825fbdea 100644--- a/js/app/packages/macro-entity/src/queries/rename.ts+++ b/js/app/packages/macro-entity/src/queries/rename.ts@@ -6,6 +6,7 @@ import {} from '@queries/channel/channel';import { type MutationCallbacks, withCallbacks } from '@queries/utils';import type { ItemType } from '@service-storage/client';+import { ChannelTypeEnum } from '@service-comms/client';import type { EntityData } from '../types/entity';import { queryClient } from './client';import { queryKeys } from './key';@@ -79,7 +80,7 @@ const validateEntityRename = (entity: EntityData): void => {switch (entity.type) {case 'channel':// NOTE: channel type is undefined if provided from the split modal due to casting in createEntityData- if (entity.channelType === 'direct_message') {+ if (entity.channelType === ChannelTypeEnum.DirectMessage) {throw new Error('Direct messages do not support renaming');}break;diff --git a/js/app/packages/service-clients/service-comms/client.ts b/js/app/packages/service-clients/service-comms/client.tsindex b675c34606..d8867aceb1 100644--- a/js/app/packages/service-clients/service-comms/client.ts+++ b/js/app/packages/service-clients/service-comms/client.ts@@ -38,6 +38,7 @@ import type { PostMessageRequest } from './generated/models/postMessageRequest';import type { PostReactionRequest } from './generated/models/postReactionRequest';import type { PostTypingRequest } from './generated/models/postTypingRequest';import type { RemoveParticipantsRequest } from './generated/models/removeParticipantsRequest';+import { ChannelType } from './generated/models/channelType';const commsHost: string = SERVER_HOSTS['document-storage-service'];@@ -68,6 +69,13 @@ type WithMessageId = { message_id: string };type WithMentionId = { mention_id: string };type WithEntity = { entity_type: string; entity_id: string };+export const ChannelTypeEnum = {+ Public: ChannelType.public,+ Organization: ChannelType.organization,+ Private: ChannelType.private,+ DirectMessage: ChannelType.direct_message,+} as const satisfies Record<string, ChannelType>;+export const commsServiceClient = {async getChannel(args: WithChannelId) {const { channel_id } = args;