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
import { UserIcon } from '@core/component/UserIcon';
import { getDisplayName, idToEmail, tryMacroId } from '@core/user';
import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
import IconX from '@icon/system/regular/x.svg';
import type { ChannelParticipant } from '@queries/channel/types';
import { Badge, Button, Item } from '@ui';
import { Show } from 'solid-js';
export function ParticipantsListItem(props: {
participant: ChannelParticipant;
currentUserId?: string;
editable: boolean;
onClick: (event: MouseEvent) => void | Promise<void>;
onRemove: () => void;
}) {
const canRemove = () =>
props.editable &&
props.currentUserId !== props.participant.user_id &&
props.participant.role !== 'owner';
const displayName = () =>
getDisplayName(tryMacroId(props.participant.user_id), {
emailFallback: 'local-part',
}) || idToEmail(props.participant.user_id);
const navigationHandlers = useSplitNavigationHandler<HTMLAnchorElement>(
async (event) => {
event.preventDefault();
event.stopPropagation();
await props.onClick(event);
}
);
return (
<div class="relative">
<a
{...navigationHandlers}
role="link"
tabIndex={0}
aria-label={`Message ${displayName()}`}
class="block rounded-xl hover:bg-hover focus-visible:outline-2 focus-visible:outline-edge"
onKeyDown={(event) => {
if (event.key !== 'Enter') return;
event.preventDefault();
event.currentTarget.click();
}}
>
<Item class={props.editable ? 'pr-12' : undefined}>
<UserIcon
id={props.participant.user_id}
size="lg"
isDeleted={false}
suppressClick
showTooltip={false}
/>
<Item.Content>
<Item.Title class="truncate">{displayName()}</Item.Title>
<Item.Description class="truncate">
{idToEmail(props.participant.user_id)}
</Item.Description>
</Item.Content>
<Item.Actions>
<Badge variant="outline" size="sm">
{
{ owner: 'Owner', admin: 'Admin', member: 'Member' }[
props.participant.role
]
}
</Badge>
</Item.Actions>
</Item>
</a>
<Show when={props.editable}>
<div class="absolute right-4 top-1/2 -translate-y-1/2">
<Button
variant="danger"
aria-label={
canRemove() ? 'Remove participant' : 'Cannot remove participant'
}
tooltip={
canRemove() ? 'Remove participant' : 'Cannot remove participant'
}
size="icon-sm"
disabled={!canRemove()}
onClick={(event) => {
event.preventDefault();
event.stopPropagation();
if (!canRemove()) return;
props.onRemove();
}}
>
<IconX class="size-3.5 touch:size-6 shrink-0 pointer-events-none" />
</Button>
</div>
</Show>
</div>
);
}