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.

feat: display entity name with format document name (#1047)

gbirmanfcfc695faf96
diff --git a/js/app/packages/macro-entity/src/components/Entity.tsx b/js/app/packages/macro-entity/src/components/Entity.tsx
index 7cfd220ba9..d1d308e3d6 100644
--- a/js/app/packages/macro-entity/src/components/Entity.tsx
+++ b/js/app/packages/macro-entity/src/components/Entity.tsx
@@ -4,6 +4,7 @@ import { unifiedListMarkdownTheme } from 'core/component/LexicalMarkdown/theme';
import type { Component, JSX, ParentProps, Ref } from 'solid-js';
import { children, createMemo, Show, Suspense } from 'solid-js';
import { Dynamic } from 'solid-js/web';
+import { formatDocumentName } from '@service-storage/util/filename';
import { createProfilePictureQuery } from '../queries/auth';
import type { EntityData } from '../types/entity';
import type { EntityClickHandler } from './EntityWithEverything';
@@ -94,6 +95,15 @@ export function Entity<T extends EntityData = EntityData>(
});
});
+ const displayName = createMemo(() => {
+ if (props.entity.type === 'document') {
+ return formatDocumentName(props.entity.name, props.entity.fileType, {
+ fullyQualifiedBlockName: true,
+ });
+ }
+ return props.entity.name;
+ });
+
return (
<div
data-entity
@@ -113,7 +123,7 @@ export function Entity<T extends EntityData = EntityData>(
/>
</div>
<span class="@md:w-52 truncate font-medium text-sm">
- {props.entity.name}
+ {displayName()}
</span>
</div>
diff --git a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
index 80a26a3cad..cc864f13f5 100644
--- a/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
+++ b/js/app/packages/macro-entity/src/components/EntityWithEverything.tsx
@@ -8,6 +8,7 @@ import { matches } from '@core/util/match';
import CheckIcon from '@icon/regular/check.svg';
import { tryToTypedNotification } from '@notifications';
import { useEmail, useUserId } from '@core/context/user';
+import { formatDocumentName } from '@service-storage/util/filename';
import { syncServiceClient } from '@service-sync/client';
import { mergeRefs } from '@solid-primitives/refs';
import { createDraggable } from '@thisbeyond/solid-dnd';
@@ -549,6 +550,15 @@ export function EntityWithEverything(
const searchHighlightName = () =>
isSearchEntity(props.entity) && props.entity.search.nameHighlight;
+ const displayName = createMemo(() => {
+ if (props.entity.type === 'document') {
+ return formatDocumentName(props.entity.name, props.entity.fileType, {
+ fullyQualifiedBlockName: true,
+ });
+ }
+ return props.entity.name;
+ });
+
const contentHitData = () => {
if (!isSearchEntity(props.entity)) return [];
return props.entity.search.contentHitData ?? [];
@@ -701,7 +711,7 @@ export function EntityWithEverything(
</Show>
<Show
when={isSearch() && searchHighlightName()}
- fallback={props.entity.name}
+ fallback={displayName()}
>
{(name) => (
<StaticMarkdown
@@ -816,7 +826,7 @@ export function EntityWithEverything(
>
<Show
when={isSearch() && searchHighlightName()}
- fallback={props.entity.name}
+ fallback={displayName()}
>
{(name) => (
<StaticMarkdown