Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chg(ui): add args for local email part display when no display name (#4094)

Seamusb82e2043f95b
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index cefbf3477b..8959cf95b7 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -166,7 +166,9 @@ const AssigneeGroupContent = (props: {
assigneeId: MacroId;
fallbackLabel: string;
}) => {
- const [assigneeName] = useDisplayName(props.assigneeId);
+ const [assigneeName] = useDisplayName(props.assigneeId, {
+ emailFallback: 'local-part',
+ });
return (
<>
<UserIcon
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx b/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
index 0231bf55db..8a7f13528a 100644
--- a/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/views/tasks/list-property-value.tsx
@@ -39,7 +39,7 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
>
<Property.Tooltip property={props.property}>
<Layer depth={2}>
- <Property.EditTrigger class="list-property-cell min-w-0 rounded-full hover:bg-surface/50 inline-flex items-center gap-1 px-2 py-1.5 leading-tight text-left hover:ring ring-edge ring-inset @max-[840px]/u-list:hover:ring-0 @max-[840px]/u-list:px-1">
+ <Property.EditTrigger class="list-property-cell w-full max-w-full min-w-0 overflow-hidden rounded-full hover:bg-surface/50 inline-flex items-center gap-1 px-2 py-1.5 leading-tight text-left hover:ring ring-edge ring-inset @max-[840px]/u-list:hover:ring-0 @max-[840px]/u-list:px-1">
<Show
when={!isEmpty()}
fallback={
@@ -84,7 +84,7 @@ export const ListPropertyValue: Component<ListPropertyValueProps> = (props) => {
</Switch>
<Property.Text
property={props.property}
- class="flex-1 @max-[840px]/u-list:hidden"
+ class="min-w-0 max-w-full flex-1 @max-[840px]/u-list:hidden"
/>
</Show>
<Property.Caret class="@max-[840px]/u-list:hidden" />
diff --git a/js/app/packages/core/user/displayName.ts b/js/app/packages/core/user/displayName.ts
index 678f4ff227..c99b443974 100644
--- a/js/app/packages/core/user/displayName.ts
+++ b/js/app/packages/core/user/displayName.ts
@@ -58,11 +58,23 @@ function queueItemsForFetch(items: string[]) {
setDisplayNameFetchQueue((prev) => [...prev, ...items]);
}
-function defaultNameTransform(item: UserNameItem): string {
+type DisplayNameOptions = {
+ emailFallback?: 'full' | 'local-part';
+};
+
+function formatEmailFallback(email: string, options?: DisplayNameOptions) {
+ if (options?.emailFallback !== 'local-part') return email;
+ return email.split('@')[0] || email;
+}
+
+function defaultNameTransform(
+ item: UserNameItem,
+ options?: DisplayNameOptions
+): string {
// TODO: UserNameItem needs to be ported to use MacroId
const email = macroIdToEmail(item.id as MacroId);
- if (item.loading) return email;
+ if (item.loading) return formatEmailFallback(email, options);
if (item.lastName || item.firstName) {
let name: string[] = [];
@@ -77,13 +89,13 @@ function defaultNameTransform(item: UserNameItem): string {
name.push(item.lastName);
}
- if (name.length === 0) return email;
+ if (name.length === 0) return formatEmailFallback(email, options);
let nameStringified = name.join(' ');
return nameStringified;
}
- return email;
+ return formatEmailFallback(email, options);
}
async function fetchDisplayNames(ids: string[]): Promise<UserNameItem[]> {
@@ -179,7 +191,8 @@ type DisplayNameParts = {
};
export function useDisplayNameParts(
- id: MacroId | undefined | null
+ id: MacroId | undefined | null,
+ options?: DisplayNameOptions
): DisplayNameParts {
if (!id) {
return {
@@ -206,13 +219,14 @@ export function useDisplayNameParts(
return name && name !== 'N/A' ? name : '';
};
- const fullName = () => defaultNameTransform(getItem());
+ const fullName = () => defaultNameTransform(getItem(), options);
return { firstName, lastName, fullName, refetch };
}
export function useDisplayName(
- id: MacroId | undefined | null
+ id: MacroId | undefined | null,
+ options?: DisplayNameOptions
): UserNamePreviewFetcher {
if (!id) {
return [
@@ -226,7 +240,7 @@ export function useDisplayName(
const { getItem, refetch, mutate } = useUserNameItem(id);
- const accessor = () => defaultNameTransform(getItem());
+ const accessor = () => defaultNameTransform(getItem(), options);
return [accessor, { refetch, mutate }];
}
diff --git a/js/app/packages/core/user/util.ts b/js/app/packages/core/user/util.ts
index 1c1b7e401f..7e96507d14 100644
--- a/js/app/packages/core/user/util.ts
+++ b/js/app/packages/core/user/util.ts
@@ -21,7 +21,9 @@ export function emailToId(email: string): string {
export function idToDisplayName(id: string): string {
const macroId = tryMacroId(id);
- const [displayName] = useDisplayName(macroId);
+ const [displayName] = useDisplayName(macroId, {
+ emailFallback: 'local-part',
+ });
return displayName();
}
diff --git a/js/app/packages/property/src/component/propertyValue/PropertyTooltip.tsx b/js/app/packages/property/src/component/propertyValue/PropertyTooltip.tsx
index 33abff5f53..e798589aa3 100644
--- a/js/app/packages/property/src/component/propertyValue/PropertyTooltip.tsx
+++ b/js/app/packages/property/src/component/propertyValue/PropertyTooltip.tsx
@@ -105,7 +105,7 @@ const TooltipWrapper = (props: {
};
const ValueContainer = (props: { children: JSX.Element }) => (
- <div class="inline-flex items-center gap-1.5 px-2 py-1 text-xs leading-none text-ink-muted h-fit w-fit rounded-sm">
+ <div class="inline-flex min-w-0 items-center gap-1.5 px-2 py-0.5 text-xs leading-5 text-ink-muted w-fit rounded-sm">
{props.children}
</div>
);
@@ -247,7 +247,7 @@ const EntityValuePill = (props: { entity: EntityReference }) => {
return (
<ValueContainer>
<Show when={icon()}>{icon()}</Show>
- <span class="truncate max-w-37.5">{name()}</span>
+ <span class="min-w-0 truncate max-w-37.5">{name()}</span>
</ValueContainer>
);
};
@@ -264,7 +264,7 @@ const UserEntityItem = (props: { entity: EntityReference }) => {
<div class="size-4 rounded-full overflow-hidden shrink-0">
<UserIcon id={props.entity.entity_id} isDeleted={false} size="fill" />
</div>
- <span class="truncate max-w-37.5">{name()}</span>
+ <span class="min-w-0 truncate max-w-37.5">{name()}</span>
</ValueContainer>
);
};
diff --git a/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx b/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
index 7bc19bd878..f2dbcaf505 100644
--- a/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
+++ b/js/app/packages/property/src/editors/selectors/PropertyEntitySelector.tsx
@@ -79,7 +79,7 @@ function getEntityTypePluralLabel(
function getEntityName(entity: CombinedEntity): string {
if (entity.kind === 'user') {
const { name, email } = entity.data;
- if (name === email) return email;
+ if (name === email) return email.split('@')[0] || email;
return `${name} | ${email}`;
}
const data = entity.data;
@@ -522,7 +522,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
<Entity.Icon entity={entity.data as EntityData} />
</Show>
</div>
- <span class="truncate min-w-0">
+ <span class="truncate min-w-0 max-w-full">
<Show
when={entity.kind === 'entity'}
fallback={getEntityName(entity)}
diff --git a/js/app/packages/property/src/editors/selectors/entityUtils.ts b/js/app/packages/property/src/editors/selectors/entityUtils.ts
index 962e810b17..b2b4f58c54 100644
--- a/js/app/packages/property/src/editors/selectors/entityUtils.ts
+++ b/js/app/packages/property/src/editors/selectors/entityUtils.ts
@@ -109,7 +109,7 @@ export function threadMapper(email: EmailEntity): CombinedEntity {
export function getEntityName(entity: CombinedEntity): string {
if (entity.kind === 'user') {
const { name, email } = entity.data;
- if (name === email) return email;
+ if (name === email) return email.split('@')[0] || email;
return name;
}
diff --git a/js/app/packages/property/src/extractors/PropertyText.tsx b/js/app/packages/property/src/extractors/PropertyText.tsx
index a85b074307..33d79ec685 100644
--- a/js/app/packages/property/src/extractors/PropertyText.tsx
+++ b/js/app/packages/property/src/extractors/PropertyText.tsx
@@ -94,7 +94,9 @@ function UserPropertyText(props: {
fallback?: JSX.Element;
class?: string;
}) {
- const parts = useDisplayNameParts(tryMacroId(props.id));
+ const parts = useDisplayNameParts(tryMacroId(props.id), {
+ emailFallback: 'local-part',
+ });
const text = () => parts.firstName() || parts.fullName();
return (