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(list): use new entity components in new list view (#1422)

Seamusb0a84c9e8f3c
diff --git a/js/app/packages/app/component/PropertyDisplayControl.tsx b/js/app/packages/app/component/PropertyDisplayControl.tsx
index 8d09baebe5..22c8c63a00 100644
--- a/js/app/packages/app/component/PropertyDisplayControl.tsx
+++ b/js/app/packages/app/component/PropertyDisplayControl.tsx
@@ -111,7 +111,6 @@ const SuggestedPill: Component<SuggestedPillProps> = (props) => {
text-xs text-ink
bg-transparent hover:bg-hover
border border-edge
- cursor-pointer
transition-colors"
>
<PropertyDataTypeIcon property={props.property} />
diff --git a/js/app/packages/app/component/next-soup/actions/make-copy-action.ts b/js/app/packages/app/component/next-soup/actions/make-copy-action.ts
index bc74675c94..08b9025719 100644
--- a/js/app/packages/app/component/next-soup/actions/make-copy-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-copy-action.ts
@@ -1,5 +1,5 @@
import { toast } from '@core/component/Toast/Toast';
-import type { EntityData } from '@macro-entity';
+import type { EntityData } from '@entity';
import type { SoupState } from '../create-soup-state';
import { createBulkCopyDssEntityMutation } from '../../../../macro-entity/src/queries/dss';
diff --git a/js/app/packages/app/component/next-soup/actions/make-delete-action.ts b/js/app/packages/app/component/next-soup/actions/make-delete-action.ts
index f4aa4b209c..02b297a105 100644
--- a/js/app/packages/app/component/next-soup/actions/make-delete-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-delete-action.ts
@@ -1,5 +1,5 @@
import { toast } from '@core/component/Toast/Toast';
-import type { EntityData } from '@macro-entity';
+import type { EntityData } from '@entity';
import { openBulkEditModal } from '@app/component/bulk-edit-entity/BulkEditEntityModal';
import { globalSplitManager } from '@app/signal/splitLayout';
import { globalRemoveFromSplitHistory } from '@app/component/split-layout/layoutUtils';
diff --git a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
index b6a66e8039..a64a9903f0 100644
--- a/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-mark-done-action.ts
@@ -3,7 +3,7 @@ import {
type EntityData,
isTaskEntity,
type TaskEntityWithProperties,
-} from '@macro-entity';
+} from '@entity';
import {
markNotificationsForEntityAsDone,
type NotificationSource,
diff --git a/js/app/packages/app/component/next-soup/actions/make-move-to-project-action.ts b/js/app/packages/app/component/next-soup/actions/make-move-to-project-action.ts
index 96354bd3cc..39fdefa8a5 100644
--- a/js/app/packages/app/component/next-soup/actions/make-move-to-project-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-move-to-project-action.ts
@@ -1,5 +1,5 @@
import { toast } from '@core/component/Toast/Toast';
-import type { EntityData } from '@macro-entity';
+import type { EntityData } from '@entity';
import { openBulkEditModal } from '@app/component/bulk-edit-entity/BulkEditEntityModal';
import type { SoupState } from '../create-soup-state';
import { restoreSoupFocus } from '../utils';
diff --git a/js/app/packages/app/component/next-soup/actions/make-rename-action.ts b/js/app/packages/app/component/next-soup/actions/make-rename-action.ts
index 53cc6103d0..bf304fee26 100644
--- a/js/app/packages/app/component/next-soup/actions/make-rename-action.ts
+++ b/js/app/packages/app/component/next-soup/actions/make-rename-action.ts
@@ -1,5 +1,5 @@
import { toast } from '@core/component/Toast/Toast';
-import type { EntityData } from '@macro-entity';
+import type { EntityData } from '@entity';
import { openBulkEditModal } from '@app/component/bulk-edit-entity/BulkEditEntityModal';
import type { SoupState } from '../create-soup-state';
import { restoreSoupFocus } from '../utils';
diff --git a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
index 00d1e30968..7364068978 100644
--- a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
@@ -1,7 +1,7 @@
import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { HotkeyTags } from '@core/hotkey/constants';
import { TOKENS } from '@core/hotkey/tokens';
-import type { EntityData } from '@macro-entity';
+import type { EntityData } from '@entity';
import type { SoupState } from '../create-soup-state';
import {
makeCopyAction,
diff --git a/js/app/packages/app/component/next-soup/create-soup-state.test.ts b/js/app/packages/app/component/next-soup/create-soup-state.test.ts
index b18aa9c052..a68acc5c77 100644
--- a/js/app/packages/app/component/next-soup/create-soup-state.test.ts
+++ b/js/app/packages/app/component/next-soup/create-soup-state.test.ts
@@ -37,7 +37,7 @@ vi.mock('@core/component/EntityIcon', () => ({
}));
import { createSoupState } from './create-soup-state';
-import type { EntityData } from '@macro-entity';
+import type { EntityData } from '../../../entity/src';
const createTestEntity = (id: string, name?: string): EntityData => ({
id,
diff --git a/js/app/packages/app/component/next-soup/create-soup-state.ts b/js/app/packages/app/component/next-soup/create-soup-state.ts
index f5aa9d62da..41e20f0ded 100644
--- a/js/app/packages/app/component/next-soup/create-soup-state.ts
+++ b/js/app/packages/app/component/next-soup/create-soup-state.ts
@@ -11,7 +11,7 @@ import {
import { createSelectionState } from '@app/component/next-soup/selection-state';
import { SORT_CONFIGS } from '@app/component/next-soup/soup-view/sort-options';
import { isModality } from '@core/mobile/inputModality';
-import type { EntityData, WithSearch } from '@macro-entity';
+import type { EntityData, WithSearch } from '@entity';
import { createMemo, createSignal } from 'solid-js';
type SoupEntity = EntityData | WithSearch<EntityData>;
diff --git a/js/app/packages/app/component/next-soup/filters/filters.ts b/js/app/packages/app/component/next-soup/filters/filters.ts
index 737ba634ae..e758529c65 100644
--- a/js/app/packages/app/component/next-soup/filters/filters.ts
+++ b/js/app/packages/app/component/next-soup/filters/filters.ts
@@ -1,8 +1,4 @@
-import {
- isTaskEntity,
- type EntityData,
- type WithNotification,
-} from '@macro-entity';
+import { isTaskEntity, type EntityData, type WithNotification } from '@entity';
import {
signalFilter,
noiseFilter,
diff --git a/js/app/packages/app/component/next-soup/filters/signal-filters.ts b/js/app/packages/app/component/next-soup/filters/signal-filters.ts
index 2320130b23..5168ab2bad 100644
--- a/js/app/packages/app/component/next-soup/filters/signal-filters.ts
+++ b/js/app/packages/app/component/next-soup/filters/signal-filters.ts
@@ -2,7 +2,7 @@ import {
isTaskEntity,
type TaskEntityWithProperties,
type EntityData,
-} from '@macro-entity';
+} from '@entity';
import { useUserId } from '@core/context/user';
import { createMemo } from 'solid-js';
import {
diff --git a/js/app/packages/app/component/next-soup/soup-view/sort-options.ts b/js/app/packages/app/component/next-soup/soup-view/sort-options.ts
index 4b3070ff59..16739e8e47 100644
--- a/js/app/packages/app/component/next-soup/soup-view/sort-options.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/sort-options.ts
@@ -5,7 +5,7 @@ import {
type WithSearch,
type EntityData,
type WithNotification,
-} from '@macro-entity';
+} from '@entity';
export type SystemSortOption =
| 'updated_at'
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
index c289732abc..95b1cbcde2 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-entity-actions-menu.tsx
@@ -2,7 +2,7 @@ import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { globalSplitManager } from '@app/signal/splitLayout';
import { MenuItem } from '@core/component/Menu';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
-import type { EntityData } from '@macro-entity';
+import type { EntityData } from '@entity';
import {
makeCopyAction,
makeDeleteAction,
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-entity-context-menu.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-entity-context-menu.tsx
index 6a7af3c618..b0af71c38d 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-entity-context-menu.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-entity-context-menu.tsx
@@ -1,7 +1,7 @@
import { ContextMenuContent, MenuSeparator } from '@core/component/Menu';
import { isMobile } from '@core/mobile/isMobile';
import { ContextMenu } from '@kobalte/core/context-menu';
-import { Entity, type EntityData } from '@macro-entity';
+import { InlineEntity, type EntityData } from '@entity';
import { type FlowComponent, Show } from 'solid-js';
import { useSoupView } from './soup-view-context';
import { SoupEntityActionsMenu } from './soup-entity-actions-menu';
@@ -27,10 +27,7 @@ export const SoupEntityContextMenu: FlowComponent<
{(selectedEntity) => (
<ContextMenuContent mobileFullScreen>
<Show when={isMobile()}>
- <Entity
- entity={selectedEntity()}
- timestamp={props.entityTimestamp}
- />
+ <InlineEntity entity={selectedEntity()} />
<MenuSeparator />
</Show>
<SoupEntityActionsMenu
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-entity-selection-toolbar.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-entity-selection-toolbar.tsx
index e5af9051bc..f62edacf12 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-entity-selection-toolbar.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-entity-selection-toolbar.tsx
@@ -10,7 +10,7 @@ import {
toggleKonsoleVisibility,
} from '@app/component/command/state';
import { EntitySelectionToolbarModal } from '@app/component/EntitySelectionToolbarModal';
-import type { EntityData } from '@macro-entity';
+import type { EntityData } from '@entity';
interface SoupEntitySelectionToolbarProps {
selected: EntityData[];
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
index ef22a48f63..95c044aa95 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
@@ -13,7 +13,7 @@ import { useEmailLinksStatus } from '@core/email-link';
import { arrayEquals } from '@core/util/compareUtils';
import { debouncedDependent } from '@core/util/debounce';
import { fuzzyMatch } from '@core/util/fuzzy';
-import type { EntityData, WithNotification, WithSearch } from '@macro-entity';
+import type { EntityData, WithNotification, WithSearch } from '@entity';
import { useNotificationsForEntity } from '@notifications';
import {
type SoupItemsQueryFilters,
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 36f1d0f2bd..a31ddf5bfa 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
@@ -1,5 +1,4 @@
import CheckIcon from '@icon/bold/check-bold.svg';
-import { URL_PARAMS as CHANNEL_PARAMS } from '@block-channel/constants';
import {
useGlobalBlockOrchestrator,
useGlobalNotificationSource,
@@ -12,7 +11,6 @@ import {
import { useSoup } from '@app/component/next-soup/soup-context';
import { SoupEntityContextMenu } from '@app/component/next-soup/soup-view/soup-entity-context-menu';
import {
- type SoupEntity,
type SoupRow,
SoupViewContextProvider,
useSoupView,
@@ -35,25 +33,15 @@ import { SplitPanelContext } from '@app/component/split-layout/context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import { LoadingBlock } from '@core/component/LoadingBlock';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
-import { useTaskProperties } from '@core/component/Properties/hooks';
import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';
import {
type EntityData,
- isTaskEntity,
- type Notification,
- queryKeys,
- unreadFilterFn,
- useQueryClient,
-} from '@macro-entity';
-import {
- createEffectOnEntityTypeNotification,
- getMetadata,
- isChannelMention,
- isChannelMessageReply,
- isChannelMessageSend,
- tryToTypedNotification,
- type UnifiedNotification,
-} from '@notifications';
+ ListEntity,
+ type SearchLocation,
+ type ProjectEntity,
+} from '@entity';
+import { queryKeys, useQueryClient } from '@macro-entity';
+import { createEffectOnEntityTypeNotification } from '@notifications';
import { debounce } from '@solid-primitives/scheduled';
import { cn } from '@ui/utils/classname';
import {
@@ -72,11 +60,6 @@ import { type VirtualizerHandle, VList } from 'virtua/solid';
import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';
import { SoupToolbar } from './soup-toolbar';
import { useUserId } from '@core/context/user';
-import {
- type EntityClickHandler,
- type EntityPointerDownHandler,
- EntityWithEverything,
-} from '../../../../macro-entity/src/components/EntityWithEverything';
import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { SoupViewFileDropzone } from '@app/component/next-soup/soup-view/soup-view-file-dropzone';
import { useHotkeyDOMScope } from '@core/hotkey/hotkeys';
@@ -88,6 +71,7 @@ import { SoupChatInput } from '@app/component/SoupChatInput';
import { ENABLE_UNIFIED_LIST_AI_INPUT } from '@core/constant/featureFlags';
import { isMobile } from '@core/mobile/isMobile';
import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';
+import { usePropertyEditorHotkeys } from '@app/component/property-edit-modal/hooks/usePropertyEditorHotkeys';
const DEFAULT_ENTITY_HEIGHT = 40;
@@ -253,6 +237,12 @@ export const SoupViewList = (props: SoupViewListProps) => {
soup,
});
+ // Property editor
+ usePropertyEditorHotkeys({
+ scopeId: scopeId(),
+ soup,
+ });
+
// Register soup view hotkeys (jump navigation, enter, escape, cmd+k, etc.)
useSoupViewHotkeys({
splitId: panel.handle.id,
@@ -300,9 +290,15 @@ export const SoupViewList = (props: SoupViewListProps) => {
const orchestrator = useGlobalBlockOrchestrator();
- const taskPropertiesStore = useTaskProperties(soup.data);
+ type EntityClickArgs = {
+ type: 'entity' | 'project';
+ entity: EntityData;
+ projectEntity?: ProjectEntity;
+ event: MouseEvent | PointerEvent;
+ location?: SearchLocation;
+ };
- const onEntityClick: EntityClickHandler<EntityData> = async (args) => {
+ const onEntityClick = async (args: EntityClickArgs) => {
const { type, event, location } = args;
const entity = (
@@ -326,86 +322,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
});
};
- const onEntityDoubleClick: EntityClickHandler<EntityData> = async (args) => {
- const { entity, event, location } = args;
-
- if (!soup.previewEntity()) {
- return;
- }
-
- await openEntityInSplitFromUnifiedList(entity, {
- openInNewSplit: event.shiftKey,
- location,
- splitHandle: panel.handle,
- });
- };
-
- const onEntityPointerDown: EntityPointerDownHandler<EntityData> = async (
- args
- ) => {
- const { type, location, event } = args;
-
- const entity = (
- type === 'entity' ? args.entity : args.projectEntity
- ) as EntityData;
-
- // middle mouse button pressed
- if (event.button === 1 && event.pointerType === 'mouse') {
- // TODO: current page should remain focused after opening new tab
- openEntityInNewTab({ entity, location });
- }
- };
-
- const onClickEntityAction = (entity: EntityData) => {
- if (markDoneAction.canExecute(entity)) {
- markDoneAction.executeWithSoup([entity], soup);
- }
- };
-
- const blockOrchestrator = useGlobalBlockOrchestrator();
- const gotoChannelNotification = async (notification: UnifiedNotification) => {
- let message_id: string | undefined;
- let thread_id: string | undefined;
-
- if (isChannelMention(notification)) {
- const metadata = getMetadata(notification);
- message_id = metadata.messageId;
- } else if (isChannelMessageReply(notification)) {
- const metadata = getMetadata(notification);
- message_id = metadata.messageId;
- thread_id = metadata.threadId;
- } else if (isChannelMessageSend(notification)) {
- const metadata = getMetadata(notification);
- message_id = metadata.messageId;
- } else {
- return;
- }
-
- const blockHandle = await blockOrchestrator.getBlockHandle(
- notification.entity_id,
- 'channel'
- );
- if (!blockHandle) return;
-
- notificationSource.markAsRead(notification);
-
- return blockHandle?.goToLocationFromParams({
- [CHANNEL_PARAMS.message]: message_id,
- [CHANNEL_PARAMS.thread]: thread_id,
- });
- };
-
- const onClickNotification = ({
- entity,
- }: {
- entity: SoupEntity & { notification: Notification };
- }) => {
- const notification = tryToTypedNotification(entity.notification);
- if (!notification || entity.type !== 'channel') return;
-
- gotoChannelNotification(notification);
- };
-
let lastClickedEntityId = -1;
const getSelectionAnchorIndex = (params: {
@@ -494,10 +410,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
onCleanup(() => debouncedFetchMore.clear());
- const [entityContextMenuOpen, setEntityContextMenuOpen] = createSignal<
- string | undefined
- >(undefined);
-
const [localEntityListRef, setLocalEntityListRef] = createSignal<
HTMLDivElement | undefined
>();
@@ -637,21 +549,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
}
};
- const properties = () => {
- if (isTaskEntity(row.original)) {
- return taskPropertiesStore()[row.original.id] ?? [];
- }
- return undefined;
- };
-
- const shouldDisplayDoneButton = () => {
- if (row.original.type === 'email') {
- return !row.original.done;
- }
-
- return (row.original.notifications?.().length ?? 0) > 0;
- };
-
return (
<EntityRow
entityId={row.original.id}
@@ -663,11 +560,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
<SoupEntityContextMenu
entity={row.original}
entityTimestamp={timestamp()}
- onOpenChange={(open) => {
- setEntityContextMenuOpen(
- open ? row.original.id : undefined
- );
- }}
>
<div
class="flex flex-col w-full min-w-0"
@@ -689,33 +581,14 @@ export const SoupViewList = (props: SoupViewListProps) => {
</div>
}
>
- <EntityWithEverything
- splitId={panel.handle.id}
+ <ListEntity
entity={row.original}
timestamp={timestamp()}
- properties={properties()}
- searchActive={!!searchText()}
- selected={{
- active:
- row.isFocused() ||
- entityContextMenuOpen() === row.original.id,
- // TODO: Update this to take into account when this is used within a nested
- // view like the preview panel
- muted:
- row.isFocused() && !panel.isPanelActive(),
- }}
highlighted={
panel.isPanelActive() && row.isFocused()
}
onMouseOver={() => {
- if (
- soup.previewEntity() ||
- isKeypressActive()
- )
- return;
- soup.focus.set(row.original.id);
- }}
- onFocusIn={() => {
+ if (isKeypressActive()) return;
if (soup.previewEntity()) return;
soup.focus.set(row.original.id);
}}
@@ -723,12 +596,8 @@ export const SoupViewList = (props: SoupViewListProps) => {
soup.filters.isActive('signal') &&
!soup.filters.isActive('noise')
}
- unreadIndicatorActive={unreadFilterFn(
- row.original
- )}
- showDoneButton={shouldDisplayDoneButton()}
checked={row.isSelected()}
- onChecked={(next, shiftKey) =>
+ onChecked={(next: boolean, shiftKey: boolean) =>
handleMultiSelectChecked({
entity: row.original,
entityIndex: i(),
@@ -736,11 +605,34 @@ export const SoupViewList = (props: SoupViewListProps) => {
shiftKey: shiftKey ?? false,
})
}
- onClick={onEntityClick}
- onDblClick={onEntityDoubleClick}
- onPointerDown={onEntityPointerDown}
- onClickRowAction={onClickEntityAction}
- onClickNotification={onClickNotification}
+ onClick={(event: MouseEvent) => {
+ onEntityClick({
+ type: 'entity',
+ entity: row.original,
+ event,
+ location: undefined,
+ });
+ }}
+ onProjectClick={(projectEntity, event) => {
+ onEntityClick({
+ type: 'project',
+ projectEntity,
+ entity: row.original,
+ event,
+ location: undefined,
+ });
+ }}
+ onContentHitClick={(
+ e: PointerEvent | MouseEvent,
+ location?: SearchLocation
+ ) => {
+ onEntityClick({
+ type: 'entity',
+ entity: row.original,
+ event: e,
+ location,
+ });
+ }}
/>
</Show>
</div>
diff --git a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
index ace676a111..e518988434 100644
--- a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
@@ -19,7 +19,7 @@ import {
getScopeElement,
runCommand,
} from '@core/hotkey/utils';
-import { isSearchEntity } from '@macro-entity';
+import { isSearchEntity } from '@entity';
import type { Accessor } from 'solid-js';
import type { VirtualizerHandle } from 'virtua/solid';
import type { SoupState } from '../create-soup-state';
diff --git a/js/app/packages/app/component/next-soup/utils.ts b/js/app/packages/app/component/next-soup/utils.ts
index 065dad272e..e1f6c0b73a 100644
--- a/js/app/packages/app/component/next-soup/utils.ts
+++ b/js/app/packages/app/component/next-soup/utils.ts
@@ -10,11 +10,11 @@ import { waitForFrames } from '@core/util/sleep';
import {
type EntityData,
isSearchEntity,
- queryKeys,
type SearchLocation,
type TaskEntityWithProperties,
type WithSearch,
-} from '@macro-entity';
+} from '@entity';
+import { queryKeys } from '@macro-entity';
import { queryClient } from '@queries/client';
import { emailClient } from '@service-email/client';
import {
diff --git a/js/app/packages/app/component/property-edit-modal/hooks/usePropertyEditorHotkeys.ts b/js/app/packages/app/component/property-edit-modal/hooks/usePropertyEditorHotkeys.ts
index fa5727f7a7..6b920749f7 100644
--- a/js/app/packages/app/component/property-edit-modal/hooks/usePropertyEditorHotkeys.ts
+++ b/js/app/packages/app/component/property-edit-modal/hooks/usePropertyEditorHotkeys.ts
@@ -1,5 +1,4 @@
import { registerHotkey } from 'core/hotkey/hotkeys';
-import { onCleanup, onMount, type Accessor } from 'solid-js';
import { openPropertyEditor } from '../state/propertyEditor';
import type {
Property,
@@ -10,11 +9,11 @@ import { TOKENS } from '@core/hotkey/tokens';
import { HotkeyTags } from '@core/hotkey/constants';
import { useAllProperties } from './useAllProperties';
import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';
+import type { SoupState } from '@app/component/next-soup/create-soup-state';
interface PropertyEditorHotkeyOptions {
scopeId: string;
- getSelectedEntities: () => EntityData[];
- enabled?: Accessor<boolean>;
+ soup: SoupState;
}
/**
@@ -22,10 +21,10 @@ interface PropertyEditorHotkeyOptions {
* - `cmd-shift-o`: Opens property selector
* - `cmd-shift-s`: Direct edit status property
* - `cmd-shift-p`: Direct edit priority property
- * - `cmd-shift-a`: Direct edit assigness property
+ * - `cmd-shift-a`: Direct edit assignees property
*/
export function usePropertyEditorHotkeys(options: PropertyEditorHotkeyOptions) {
- const { scopeId, getSelectedEntities, enabled = () => true } = options;
+ const { scopeId, soup } = options;
const allProperties = useAllProperties();
const propertyById = (propertyId: string) => {
@@ -37,16 +36,19 @@ export function usePropertyEditorHotkeys(options: PropertyEditorHotkeyOptions) {
const priority = () => propertyById(SYSTEM_PROPERTY_IDS.PRIORITY);
const assignees = () => propertyById(SYSTEM_PROPERTY_IDS.ASSIGNEES);
+ const getEntitiesForAction = (): EntityData[] => {
+ const selected = soup.selection.selected();
+ if (selected.length > 0) return selected;
+ const focused = soup.focus.item();
+ return focused ? [focused] : [];
+ };
+
// Helper to open property editor if entities are selected
const openIfSelected = (
mode: 'selector' | 'direct' = 'selector',
property?: Property | PropertyDefinitionDomain
) => {
- if (!enabled()) {
- console.log('[PropertyEditor] Hotkey disabled');
- return;
- }
- const entities = getSelectedEntities();
+ const entities = getEntitiesForAction();
if (entities && entities.length > 0) {
openPropertyEditor(entities, mode, property);
} else {
@@ -54,75 +56,86 @@ export function usePropertyEditorHotkeys(options: PropertyEditorHotkeyOptions) {
}
};
- onMount(() => {
- const disposers: Array<{ dispose: () => void }> = [];
- disposers.push(
- registerHotkey({
- hotkey: ['shift+cmd+o'],
- hotkeyToken: TOKENS.entity.action.properties,
- tags: [HotkeyTags.SelectionModification],
- displayPriority: 10,
- description: 'Open property editor',
- keyDownHandler: () => {
- const entities = getSelectedEntities();
- if (!entities.every(isTaskEntity)) return true;
- openIfSelected('selector');
- return true;
- },
- scopeId,
- }),
- registerHotkey({
- hotkey: ['shift+cmd+p'],
- hotkeyToken: TOKENS.entity.action.priority,
- tags: [HotkeyTags.SelectionModification],
- displayPriority: 10,
- description: 'Set priority',
- keyDownHandler: () => {
- const property = priority();
- const entities = getSelectedEntities();
- if (!entities.every(isTaskEntity) || !property) return true;
- openIfSelected('direct', property);
- return true;
- },
- condition: () => Boolean(priority()),
- scopeId,
- }),
- registerHotkey({
- hotkey: ['shift+cmd+a'],
- hotkeyToken: TOKENS.entity.action.assignee,
- tags: [HotkeyTags.SelectionModification],
- displayPriority: 10,
- description: 'Set assignee',
- keyDownHandler: () => {
- const property = assignees();
- const entities = getSelectedEntities();
- if (!entities.every(isTaskEntity) || !property) return true;
- openIfSelected('direct', property);
- return true;
- },
- condition: () => Boolean(assignees()),
- scopeId,
- }),
- registerHotkey({
- hotkey: ['shift+cmd+s'],
- hotkeyToken: TOKENS.entity.action.status,
- tags: [HotkeyTags.SelectionModification],
- displayPriority: 10,
- description: 'Set status',
- keyDownHandler: () => {
- const property = status();
- const entities = getSelectedEntities();
- if (!entities.every(isTaskEntity) || !property) return true;
- openIfSelected('direct', property);
- return true;
- },
- condition: () => Boolean(status()),
- scopeId,
- })
- );
- onCleanup(() => {
- disposers.forEach((disposer) => disposer.dispose());
- });
+ // Open property selector - shift+cmd+o
+ registerHotkey({
+ hotkey: ['shift+cmd+o'],
+ hotkeyToken: TOKENS.entity.action.properties,
+ tags: [HotkeyTags.SelectionModification],
+ displayPriority: 10,
+ description: 'Open property editor',
+ keyDownHandler: () => {
+ openIfSelected('selector');
+ return true;
+ },
+ condition: () => {
+ const entities = getEntitiesForAction();
+ return entities.length > 0 && entities.every(isTaskEntity);
+ },
+ scopeId,
+ });
+
+ // Set priority - shift+cmd+p
+ registerHotkey({
+ hotkey: ['shift+cmd+p'],
+ hotkeyToken: TOKENS.entity.action.priority,
+ tags: [HotkeyTags.SelectionModification],
+ displayPriority: 10,
+ description: 'Set priority',
+ keyDownHandler: () => {
+ openIfSelected('direct', priority());
+ return true;
+ },
+ condition: () => {
+ const entities = getEntitiesForAction();
+ return (
+ entities.length > 0 &&
+ entities.every(isTaskEntity) &&
+ Boolean(priority())
+ );
+ },
+ scopeId,
+ });
+
+ // Set assignee - shift+cmd+a
+ registerHotkey({
+ hotkey: ['shift+cmd+a'],
+ hotkeyToken: TOKENS.entity.action.assignee,
+ tags: [HotkeyTags.SelectionModification],
+ displayPriority: 10,
+ description: 'Set assignee',
+ keyDownHandler: () => {
+ openIfSelected('direct', assignees());
+ return true;
+ },
+ condition: () => {
+ const entities = getEntitiesForAction();
+ return (
+ entities.length > 0 &&
+ entities.every(isTaskEntity) &&
+ Boolean(assignees())
+ );
+ },
+ scopeId,
+ });
+
+ // Set status - shift+cmd+s
+ registerHotkey({
+ hotkey: ['shift+cmd+s'],
+ hotkeyToken: TOKENS.entity.action.status,
+ tags: [HotkeyTags.SelectionModification],
+ displayPriority: 10,
+ description: 'Set status',
+ keyDownHandler: () => {
+ openIfSelected('direct', status());
+ return true;
+ },
+ condition: () => {
+ const entities = getEntitiesForAction();
+ return (
+ entities.length > 0 && entities.every(isTaskEntity) && Boolean(status())
+ );
+ },
+ scopeId,
});
return {
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index 9a4173a636..ac3d91b463 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -140,7 +140,7 @@ if (LOCAL_ONLY) {
registerComponent(
'entity-debug',
- lazy(() => import('@entity/src/debug/DebugEntityView'))
+ lazy(() => import('@entity/debug/DebugEntityView'))
);
}
diff --git a/js/app/packages/block-email/component/date-selector.tsx b/js/app/packages/block-email/component/date-selector.tsx
index 979f1a0e30..66d09ca9c4 100644
--- a/js/app/packages/block-email/component/date-selector.tsx
+++ b/js/app/packages/block-email/component/date-selector.tsx
@@ -420,7 +420,7 @@ const DateSelectorItem: Component<
<Combobox.Item
item={props.item}
class={cn(
- 'flex flex-row w-full justify-between items-center gap-2 py-1.5 pr-2 pl-6 relative cursor-pointer data-[highlighted]:bg-hover',
+ 'flex flex-row w-full justify-between items-center gap-2 py-1.5 pr-2 pl-6 relative data-[highlighted]:bg-hover',
props.item.rawValue.type === 'select-custom' &&
'border-t border-edge-muted pl-2'
)}
diff --git a/js/app/packages/block-md/component/FrontMatterProperties.tsx b/js/app/packages/block-md/component/FrontMatterProperties.tsx
index 1218e79123..faf8425fe9 100644
--- a/js/app/packages/block-md/component/FrontMatterProperties.tsx
+++ b/js/app/packages/block-md/component/FrontMatterProperties.tsx
@@ -188,7 +188,7 @@ export function FrontMatterProperties(props: FrontMatterPropertiesProps) {
<div class="flex items-center gap-2 pt-2">
<div class="w-6 border-t border-edge-muted" />
<button
- class="flex items-center gap-1 px-2 cursor-pointer hover:opacity-70 transition-opacity"
+ class="flex items-center gap-1 px-2 hover:opacity-70 transition-opacity"
onClick={toggleExpanded}
>
{isExpanded() ? (
@@ -225,7 +225,7 @@ export function FrontMatterProperties(props: FrontMatterPropertiesProps) {
<div class="pt-4 pb-2">
<button
- class="flex items-center gap-1 cursor-pointer opacity-75 hover:opacity-50 transition-opacity"
+ class="flex items-center gap-1 opacity-75 hover:opacity-50 transition-opacity"
onClick={toggleExpanded}
>
<EyeSlash class="w-3 h-3 mr-2" />
diff --git a/js/app/packages/core/component/ForwardToChannel.tsx b/js/app/packages/core/component/ForwardToChannel.tsx
index 8cce5e0665..030244fc97 100644
--- a/js/app/packages/core/component/ForwardToChannel.tsx
+++ b/js/app/packages/core/component/ForwardToChannel.tsx
@@ -294,7 +294,7 @@ export function ForwardToChannel(props: ForwardToChannelProps) {
<div class="flex w-full items-center p-3 gap-3 flex-wrap">
<Show when={canSendAsGroup()}>
<label
- class={`flex items-start gap-2 ${!canSendAsGroup() ? 'cursor-not-allowed' : 'cursor-pointer'}`}
+ class={`flex items-start gap-2 ${!canSendAsGroup() ? 'cursor-not-allowed' : 'cursor-default'}`}
>
<div class="relative mt-0.5">
<input
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx
index 5b0a2d841b..a94f79bffe 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx
@@ -1068,7 +1068,7 @@ function MentionsMenuInner(props: {
</span>
<button
type="button"
- class="text-xs font-medium text-ink-muted hover:text-ink hover:underline cursor-pointer"
+ class="text-xs font-medium text-ink-muted hover:text-ink hover:underline"
onMouseDown={(e) => {
e.preventDefault();
e.stopPropagation();
diff --git a/js/app/packages/core/component/Link.tsx b/js/app/packages/core/component/Link.tsx
index 9af47057b3..a2a32da3bc 100644
--- a/js/app/packages/core/component/Link.tsx
+++ b/js/app/packages/core/component/Link.tsx
@@ -24,7 +24,7 @@ export function UnfurlLink(props: UnfurlLinkProps) {
return (
<div
- class="hover:bg-hover p-1 px-1.5 overflow-clip text-xs transition-colors hover:transition-none cursor-pointer"
+ class="hover:bg-hover p-1 px-1.5 overflow-clip text-xs transition-colors hover:transition-none"
onClick={() => window.open(props.unfurled.url)}
>
<div class="flex flex-row items-center gap-1.5 w-full h-full">
diff --git a/js/app/packages/core/component/Properties/component/modal/shared/PropertyDateSelector.tsx b/js/app/packages/core/component/Properties/component/modal/shared/PropertyDateSelector.tsx
index 591e256e30..b901f76649 100644
--- a/js/app/packages/core/component/Properties/component/modal/shared/PropertyDateSelector.tsx
+++ b/js/app/packages/core/component/Properties/component/modal/shared/PropertyDateSelector.tsx
@@ -206,7 +206,7 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
{(option, index) => (
<div
data-date-index={index()}
- class={`flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 cursor-pointer ${
+ class={`flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 ${
index() === selectedIndex() ? 'bg-hover' : ''
}`}
onClick={() => handleSelectDate(option.date)}
@@ -233,7 +233,7 @@ export const PropertyDateSelector = (props: DateSelectorProps) => {
<div class="border-t border-edge-muted mt-1 pt-1">
<div
data-date-index={dateOptions().length}
- class={`flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 cursor-pointer ${
+ class={`flex flex-row w-full justify-between items-center gap-2 py-1.5 px-2 ${
selectedIndex() === dateOptions().length ? 'bg-hover' : ''
}`}
onClick={() => setMode('calendar')}
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/CondensedPropertyValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/CondensedPropertyValue.tsx
index e9a3990c51..3f4a9a96e1 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/CondensedPropertyValue.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/CondensedPropertyValue.tsx
@@ -54,10 +54,9 @@ export const CondensedPropertyValue: Component<CondensedPropertyValueProps> = (
>
<div
class={cn(
- 'inline-flex items-center text-xs leading-none text-ink-muted shrink-0 py-1.5 h-6.5 transition-colors border border-edge-muted/50 px-1.5',
+ 'inline-flex items-center text-xs leading-none text-ink-muted shrink-0 py-1.5 h-6.5 transition-colors px-1.5',
{
- 'cursor-pointer hover:border-edge-muted hover:bg-hover/50':
- props.canEdit,
+ 'hover:border-edge-muted hover:bg-hover/50': props.canEdit,
'opacity-50': !validValue(),
}
)}
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/DateValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/DateValue.tsx
index c764271c9c..1a42042ec6 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/DateValue.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/DateValue.tsx
@@ -60,8 +60,7 @@ export const DateValue: Component<PropertyValueProps> = (props) => {
class={cn(
'inline-flex items-center leading-none shrink-0 py-1.5 h-6.5 transition-colors border border-edge-muted px-1.5',
{
- 'cursor-pointer hover:border-edge-muted hover:bg-hover/50':
- props.canEdit,
+ 'hover:border-edge-muted hover:bg-hover/50': props.canEdit,
}
)}
>
diff --git a/js/app/packages/core/component/RecipientSelector.tsx b/js/app/packages/core/component/RecipientSelector.tsx
index ab772949f8..2a481f70d2 100644
--- a/js/app/packages/core/component/RecipientSelector.tsx
+++ b/js/app/packages/core/component/RecipientSelector.tsx
@@ -480,7 +480,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
{truncateString(displayText ?? '', 20)}
</p>
<XIcon
- class="w-5 h-5 cursor-pointer hover:bg-hover hover-transition-bg p-1 "
+ class="w-5 h-5 hover:bg-hover hover-transition-bg p-1 "
onClick={() => state.remove(option)}
/>
</div>
@@ -502,7 +502,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
)}
</p>
<XIcon
- class="w-5 h-5 cursor-pointer hover:bg-hover hover-transition-bg p-1 "
+ class="w-5 h-5 hover:bg-hover hover-transition-bg p-1 "
onClick={() => state.remove(option)}
/>
</div>
@@ -523,7 +523,7 @@ export function RecipientSelector<K extends CombinedRecipientKind>(
{truncateString(email, 20)}
</p>
<XIcon
- class="w-5 h-5 cursor-pointer hover:bg-hover hover-transition-bg p-1 "
+ class="w-5 h-5 hover:bg-hover hover-transition-bg p-1 "
onClick={() => state.remove(option)}
/>
</div>
diff --git a/js/app/packages/entity/src/composed/ListEntity.tsx b/js/app/packages/entity/src/composed/ListEntity.tsx
index 39bd511a5f..f82b18d9a0 100644
--- a/js/app/packages/entity/src/composed/ListEntity.tsx
+++ b/js/app/packages/entity/src/composed/ListEntity.tsx
@@ -5,6 +5,7 @@ import {
isProjectContainedEntity,
type ProjectEntity,
type EntityData,
+ isTaskEntity,
} from '../types/entity';
import { Match, Show, Switch, type Ref } from 'solid-js';
import {
@@ -38,6 +39,7 @@ interface ListEntityProps {
ref?: Ref<HTMLDivElement>;
checked?: boolean;
highlighted?: boolean;
+ hovered?: boolean;
onChecked?: (checked: boolean, shiftKey: boolean) => void;
onMouseOver?: () => void;
onMouseLeave?: () => void;
@@ -46,7 +48,10 @@ interface ListEntityProps {
entity: ProjectEntity,
e: PointerEvent | MouseEvent
) => void;
- onContentHitClick?: (location?: SearchLocation) => void;
+ onContentHitClick?: (
+ e: PointerEvent | MouseEvent,
+ location?: SearchLocation
+ ) => void;
}
interface LayoutProps {
@@ -113,6 +118,9 @@ function NarrowLayout(props: LayoutProps) {
{(entity) => <Entity.Title entity={entity()} />}
</Match>
</Switch>
+ <Show when={isTaskEntity(props.entity) && props.entity}>
+ {(entity) => <Entity.Properties entity={entity()} />}
+ </Show>
</Entity.Slot>
<Entity.Slot
@@ -291,6 +299,9 @@ function WideLayout(props: LayoutProps) {
<Show when={props.isShared}>
<SharedBadge ownerId={props.entity.ownerId} />
</Show>
+ <Show when={isTaskEntity(props.entity) && props.entity}>
+ {(entity) => <Entity.Properties entity={entity()} />}
+ </Show>
</Entity.Slot>
<Entity.Slot
@@ -347,6 +358,9 @@ export function ListEntity(props: ListEntityProps) {
ref={mergeRefs(props.ref, draggable)}
class={cn('@container/entity w-full min-h-10 relative group/narrow', {
'bg-accent/5': props.checked,
+ 'hover:bg-hover/30':
+ !props.checked && !props.highlighted && !props.hovered,
+ 'bg-hover/20': props.hovered && !props.highlighted && !props.checked,
'bg-accent/5 outline-1 outline-accent/20 outline-offset-[-1px]':
props.highlighted,
})}
diff --git a/js/app/packages/entity/src/entity.ts b/js/app/packages/entity/src/entity.ts
index 743c05b97a..6b6b98fa8f 100644
--- a/js/app/packages/entity/src/entity.ts
+++ b/js/app/packages/entity/src/entity.ts
@@ -23,6 +23,9 @@ import {
NotificationCount,
} from './extractors-notification';
+// Property components
+import { EntityKeyProperties } from './extractors-property';
+
/**
* Entity composable component namespace.
*/
@@ -47,4 +50,5 @@ export const Entity = {
Description: NotificationDescription,
Count: NotificationCount,
},
+ Properties: EntityKeyProperties,
};
diff --git a/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx b/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx
new file mode 100644
index 0000000000..f907f13fbe
--- /dev/null
+++ b/js/app/packages/entity/src/extractors-property/entity-key-properties.tsx
@@ -0,0 +1,141 @@
+import { PropertyValue } from '@core/component/Properties/component/propertyValue/PropertyValue';
+import {
+ PropertiesProvider,
+ type PropertySaveHandler,
+} from '@core/component/Properties/context/PropertiesContext';
+import { Modals } from '@core/component/Properties/component/modal';
+import type {
+ Property,
+ PropertyApiValues,
+} from '@core/component/Properties/types';
+import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';
+import { EntityType } from '@service-properties/generated/schemas/entityType';
+import { For, Show, createMemo } from 'solid-js';
+import { useSaveEntityPropertyMutation } from '@queries/properties/entity';
+import { match } from 'ts-pattern';
+import {
+ type EntityData,
+ type EntityWithProperties,
+ isTaskEntity,
+} from '../types/entity';
+import { soupPropertyToProperty } from './property-helpers';
+
+/**
+ * Key property definition IDs in display order: Status, Priority, Assignees
+ */
+const KEY_PROPERTY_ORDER = [
+ SYSTEM_PROPERTY_IDS.STATUS,
+ SYSTEM_PROPERTY_IDS.PRIORITY,
+ SYSTEM_PROPERTY_IDS.ASSIGNEES,
+] as const;
+
+function getEntityType(entity: EntityData): EntityType {
+ return match(entity)
+ .when(isTaskEntity, () => EntityType.TASK)
+ .with({ type: 'channel' }, () => EntityType.CHANNEL)
+ .with({ type: 'chat' }, () => EntityType.CHAT)
+ .with({ type: 'project' }, () => EntityType.PROJECT)
+ .with({ type: 'email' }, () => EntityType.THREAD)
+ .with({ type: 'document' }, () => EntityType.DOCUMENT)
+ .exhaustive();
+}
+
+export interface EntityKeyPropertiesProps {
+ /** Entity with properties attached */
+ entity: EntityWithProperties<EntityData>;
+ /** Callback when properties are refreshed */
+ onRefresh?: () => void;
+}
+
+/**
+ * Displays key properties (Status, Priority, Assignees) for an entity.
+ *
+ * This is an opinionated, high-level component that:
+ * - Takes only an entity as input
+ * - Automatically extracts properties from the entity
+ * - Filters to only show Status, Priority, and Assignees
+ * - Renders them in a consistent order
+ * - Handles save mutations internally
+ *
+ * @example
+ * ```tsx
+ * <EntityKeyProperties entity={taskEntity} />
+ * ```
+ */
+export function EntityKeyProperties(props: EntityKeyPropertiesProps) {
+ const entityType = createMemo(() => getEntityType(props.entity));
+
+ const keyProperties = createMemo((): Property[] => {
+ const soupProperties = props.entity.properties ?? [];
+
+ const converted = soupProperties
+ .map(soupPropertyToProperty)
+ .filter((prop) =>
+ KEY_PROPERTY_ORDER.includes(
+ prop.propertyDefinitionId as (typeof KEY_PROPERTY_ORDER)[number]
+ )
+ );
+
+ return converted.sort((a, b) => {
+ const aIndex = KEY_PROPERTY_ORDER.indexOf(
+ a.propertyDefinitionId as (typeof KEY_PROPERTY_ORDER)[number]
+ );
+ const bIndex = KEY_PROPERTY_ORDER.indexOf(
+ b.propertyDefinitionId as (typeof KEY_PROPERTY_ORDER)[number]
+ );
+ return aIndex - bIndex;
+ });
+ });
+
+ const saveMutation = useSaveEntityPropertyMutation();
+
+ const saveHandler: PropertySaveHandler = {
+ saveProperty: (property: Property, value: PropertyApiValues) =>
+ saveMutation.mutateAsync({
+ entityId: props.entity.id,
+ entityType: entityType(),
+ property,
+ apiValues: value,
+ }),
+ saveDate: (property: Property, date: Date) =>
+ saveMutation.mutateAsync({
+ entityId: props.entity.id,
+ entityType: entityType(),
+ property,
+ apiValues: {
+ valueType: 'DATE',
+ value: date.toISOString(),
+ },
+ }),
+ };
+
+ return (
+ <Show when={keyProperties().length > 0}>
+ <PropertiesProvider
+ entityType={entityType()}
+ canEdit={true}
+ properties={keyProperties}
+ onRefresh={props.onRefresh ?? (() => {})}
+ onPropertyAdded={() => {}}
+ onPropertyDeleted={() => {}}
+ saveHandler={saveHandler}
+ >
+ <div
+ class="grid items-center gap-1 justify-start overflow-hidden w-24"
+ style={{
+ 'grid-template-columns': 'min-content min-content 1fr',
+ }}
+ >
+ <For each={keyProperties()}>
+ {(property) => (
+ <div class="relative">
+ <PropertyValue property={property} condensed />
+ </div>
+ )}
+ </For>
+ </div>
+ <Modals />
+ </PropertiesProvider>
+ </Show>
+ );
+}
diff --git a/js/app/packages/entity/src/extractors-property/index.ts b/js/app/packages/entity/src/extractors-property/index.ts
new file mode 100644
index 0000000000..e33512d3e2
--- /dev/null
+++ b/js/app/packages/entity/src/extractors-property/index.ts
@@ -0,0 +1,13 @@
+export {
+ EntityKeyProperties,
+ type EntityKeyPropertiesProps,
+} from './entity-key-properties';
+
+export {
+ soupPropertyToProperty,
+ soupPropertiesToProperties,
+ sortProperties,
+ filterKeyProperties,
+ getSortedKeyProperties,
+ PROPERTY_SORT_ORDER,
+} from './property-helpers';
diff --git a/js/app/packages/entity/src/extractors-property/property-helpers.ts b/js/app/packages/entity/src/extractors-property/property-helpers.ts
new file mode 100644
index 0000000000..1be47a32ed
--- /dev/null
+++ b/js/app/packages/entity/src/extractors-property/property-helpers.ts
@@ -0,0 +1,342 @@
+import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';
+import type {
+ Property,
+ PropertyOption,
+ ValueType,
+} from '@core/component/Properties/types';
+import {
+ SYSTEM_PROPERTY_IDS,
+ PROPERTY_OPTION_IDS,
+ NUMBER_DECIMAL_PLACES,
+} from '@core/component/Properties/constants';
+import { nanoid } from 'nanoid';
+
+/**
+ * Sort order for key properties (status, priority, assignees)
+ */
+export const PROPERTY_SORT_ORDER = [
+ SYSTEM_PROPERTY_IDS.STATUS,
+ SYSTEM_PROPERTY_IDS.PRIORITY,
+ SYSTEM_PROPERTY_IDS.ASSIGNEES,
+] as const;
+
+/**
+ * Static options for system properties (Status and Priority).
+ * These match the backend seed data and allow tooltips to display
+ * human-readable values without fetching options from the API.
+ */
+const SYSTEM_PROPERTY_OPTIONS: Record<string, PropertyOption[]> = {
+ [SYSTEM_PROPERTY_IDS.STATUS]: [
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.NOT_STARTED,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'Not Started' },
+ display_order: 0,
+ created_at: '',
+ updated_at: '',
+ },
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'In Progress' },
+ display_order: 1,
+ created_at: '',
+ updated_at: '',
+ },
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.IN_REVIEW,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'In Review' },
+ display_order: 2,
+ created_at: '',
+ updated_at: '',
+ },
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.COMPLETED,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'Completed' },
+ display_order: 3,
+ created_at: '',
+ updated_at: '',
+ },
+ {
+ id: PROPERTY_OPTION_IDS.STATUS.CANCELED,
+ property_definition_id: SYSTEM_PROPERTY_IDS.STATUS,
+ value: { type: 'string', value: 'Canceled' },
+ display_order: 4,
+ created_at: '',
+ updated_at: '',
+ },
+ ],
+ [SYSTEM_PROPERTY_IDS.PRIORITY]: [
+ {
+ id: PROPERTY_OPTION_IDS.PRIORITY.LOW,
+ property_definition_id: SYSTEM_PROPERTY_IDS.PRIORITY,
+ value: { type: 'string', value: 'Low' },
+ display_order: 0,
+ created_at: '',
+ updated_at: '',
+ },
+ {
+ id: PROPERTY_OPTION_IDS.PRIORITY.MEDIUM,
+ property_definition_id: SYSTEM_PROPERTY_IDS.PRIORITY,
+ value: { type: 'string', value: 'Medium' },
+ display_order: 1,
+ created_at: '',
+ updated_at: '',
+ },
+ {
+ id: PROPERTY_OPTION_IDS.PRIORITY.HIGH,
+ property_definition_id: SYSTEM_PROPERTY_IDS.PRIORITY,
+ value: { type: 'string', value: 'High' },
+ display_order: 2,
+ created_at: '',
+ updated_at: '',
+ },
+ {
+ id: PROPERTY_OPTION_IDS.PRIORITY.URGENT,
+ property_definition_id: SYSTEM_PROPERTY_IDS.PRIORITY,
+ value: { type: 'string', value: 'Urgent' },
+ display_order: 3,
+ created_at: '',
+ updated_at: '',
+ },
+ ],
+};
+
+/**
+ * Get static options for a system property definition ID.
+ * Returns undefined if not a known system property with static options.
+ */
+function getSystemPropertyOptions(
+ propertyDefinitionId: string
+): PropertyOption[] | undefined {
+ return SYSTEM_PROPERTY_OPTIONS[propertyDefinitionId];
+}
+
+/**
+ * Type guard to check if PropertyValue has a specific type
+ */
+function hasPropertyValueType(
+ value: unknown,
+ type: string
+): value is { type: string; value: unknown } {
+ return (
+ value !== null &&
+ value !== undefined &&
+ typeof value === 'object' &&
+ 'type' in value &&
+ (value as { type: string }).type === type &&
+ 'value' in value
+ );
+}
+
+/**
+ * Type guard for string arrays
+ */
+function isStringArray(value: unknown): value is string[] {
+ return Array.isArray(value) && value.every((v) => typeof v === 'string');
+}
+
+/**
+ * Type guard for entity reference arrays
+ */
+function isEntityReferenceArray(
+ value: unknown
+): value is Array<{ entity_type: string; entity_id: string }> {
+ return (
+ Array.isArray(value) &&
+ value.every(
+ (v) =>
+ typeof v === 'object' &&
+ v !== null &&
+ 'entity_type' in v &&
+ 'entity_id' in v
+ )
+ );
+}
+
+/**
+ * Convert SoupProperty from DSS format to domain Property type
+ *
+ * SoupProperty is a simplified representation from the document storage service,
+ * while Property is the full domain model used by UI components.
+ */
+export function soupPropertyToProperty(soupProperty: SoupProperty): Property {
+ const definition = soupProperty.definition;
+ const propertyValue = soupProperty.value;
+
+ // Get static options for system properties (Status, Priority)
+ // This allows tooltips to display human-readable values
+ const options = getSystemPropertyOptions(definition.id);
+
+ const baseProperty = {
+ propertyId: nanoid(8), // SoupProperty doesn't have a property ID, generate one
+ propertyDefinitionId: definition.id,
+ displayName: definition.display_name,
+ isMultiSelect: definition.is_multi_select,
+ isMetadata: definition.is_metadata,
+ isSystemProperty: definition.is_system,
+ options,
+ owner: definition.owner,
+ specificEntityType: definition.specific_entity_type,
+ createdAt: definition.created_at,
+ updatedAt: definition.updated_at,
+ };
+
+ const valueType = definition.data_type as ValueType;
+
+ // Handle each value type with proper type checking
+ switch (valueType) {
+ case 'STRING': {
+ if (hasPropertyValueType(propertyValue, 'String')) {
+ const stringVal = propertyValue.value;
+ if (typeof stringVal === 'string' && stringVal) {
+ return { ...baseProperty, valueType: 'STRING', value: stringVal };
+ }
+ }
+ return { ...baseProperty, valueType: 'STRING', value: null };
+ }
+
+ case 'NUMBER': {
+ if (hasPropertyValueType(propertyValue, 'Number')) {
+ const numVal = propertyValue.value;
+ if (
+ typeof numVal === 'number' &&
+ numVal !== undefined &&
+ numVal !== null
+ ) {
+ return {
+ ...baseProperty,
+ valueType: 'NUMBER',
+ value: parseFloat(numVal.toFixed(NUMBER_DECIMAL_PLACES)),
+ };
+ }
+ }
+ return { ...baseProperty, valueType: 'NUMBER', value: null };
+ }
+
+ case 'BOOLEAN': {
+ if (hasPropertyValueType(propertyValue, 'Boolean')) {
+ const boolVal = propertyValue.value;
+ if (typeof boolVal === 'boolean') {
+ return { ...baseProperty, valueType: 'BOOLEAN', value: boolVal };
+ }
+ }
+ return { ...baseProperty, valueType: 'BOOLEAN', value: null };
+ }
+
+ case 'DATE': {
+ if (hasPropertyValueType(propertyValue, 'Date')) {
+ const dateVal = propertyValue.value;
+ if (
+ dateVal &&
+ (typeof dateVal === 'string' || typeof dateVal === 'number')
+ ) {
+ return {
+ ...baseProperty,
+ valueType: 'DATE',
+ value: new Date(dateVal),
+ };
+ }
+ }
+ return { ...baseProperty, valueType: 'DATE', value: null };
+ }
+
+ case 'SELECT_STRING':
+ case 'SELECT_NUMBER': {
+ if (hasPropertyValueType(propertyValue, 'SelectOption')) {
+ const selectVal = propertyValue.value;
+ if (isStringArray(selectVal)) {
+ return {
+ ...baseProperty,
+ valueType,
+ value: selectVal,
+ };
+ }
+ }
+ return { ...baseProperty, valueType, value: null };
+ }
+
+ case 'ENTITY': {
+ if (hasPropertyValueType(propertyValue, 'EntityReference')) {
+ const entityVal = propertyValue.value;
+ if (isEntityReferenceArray(entityVal)) {
+ return { ...baseProperty, valueType: 'ENTITY', value: entityVal };
+ }
+ }
+ return { ...baseProperty, valueType: 'ENTITY', value: null };
+ }
+
+ case 'LINK': {
+ if (hasPropertyValueType(propertyValue, 'Link')) {
+ const linkVal = propertyValue.value;
+ if (isStringArray(linkVal)) {
+ return {
+ ...baseProperty,
+ valueType: 'LINK',
+ value: linkVal,
+ };
+ }
+ }
+ return { ...baseProperty, valueType: 'LINK', value: null };
+ }
+
+ default: {
+ // Fallback for unknown types - treat as string with null value
+ return { ...baseProperty, valueType: 'STRING', value: null };
+ }
+ }
+}
+
+/**
+ * Convert array of SoupProperty to Property array
+ */
+export function soupPropertiesToProperties(
+ soupProperties: SoupProperty[]
+): Property[] {
+ return soupProperties.map(soupPropertyToProperty);
+}
+
+/**
+ * Sort properties by the defined sort order (status, priority, assignees first)
+ */
+export function sortProperties(properties: Property[]): Property[] {
+ return [...properties].sort((a, b) => {
+ const aIndex = PROPERTY_SORT_ORDER.indexOf(
+ a.propertyDefinitionId as (typeof PROPERTY_SORT_ORDER)[number]
+ );
+ const bIndex = PROPERTY_SORT_ORDER.indexOf(
+ b.propertyDefinitionId as (typeof PROPERTY_SORT_ORDER)[number]
+ );
+
+ if (aIndex !== -1 && bIndex !== -1) {
+ return aIndex - bIndex;
+ }
+ if (aIndex !== -1) {
+ return -1;
+ }
+ if (bIndex !== -1) {
+ return 1;
+ }
+ return 0;
+ });
+}
+
+/**
+ * Filter properties to only include key properties (status, priority, assignees)
+ */
+export function filterKeyProperties(properties: Property[]): Property[] {
+ return properties.filter((prop) =>
+ PROPERTY_SORT_ORDER.includes(
+ prop.propertyDefinitionId as (typeof PROPERTY_SORT_ORDER)[number]
+ )
+ );
+}
+
+/**
+ * Get sorted key properties from a property array
+ */
+export function getSortedKeyProperties(properties: Property[]): Property[] {
+ return sortProperties(filterKeyProperties(properties));
+}
diff --git a/js/app/packages/entity/src/extractors-search/content-hits.tsx b/js/app/packages/entity/src/extractors-search/content-hits.tsx
index 19dd686db0..931a2f086c 100644
--- a/js/app/packages/entity/src/extractors-search/content-hits.tsx
+++ b/js/app/packages/entity/src/extractors-search/content-hits.tsx
@@ -7,7 +7,7 @@ import { SearchContentHitRow } from './search-content-hit-row';
interface ExtractorContentHitsProps {
entity: EntityData;
- onClick?: (location?: SearchLocation) => void;
+ onClick?: (e: PointerEvent | MouseEvent, location?: SearchLocation) => void;
visibleCount?: number;
}
diff --git a/js/app/packages/entity/src/extractors-search/search-content-hit-row.tsx b/js/app/packages/entity/src/extractors-search/search-content-hit-row.tsx
index 7dcad53b42..b627d0c7c1 100644
--- a/js/app/packages/entity/src/extractors-search/search-content-hit-row.tsx
+++ b/js/app/packages/entity/src/extractors-search/search-content-hit-row.tsx
@@ -8,24 +8,17 @@ import { UserIcon } from '@core/component/UserIcon';
import { SearchLocation as SearchLoc } from './search-location';
import { getSenderId } from './search-helpers';
-// Re-export helper for backward compatibility and testing
-export { getSenderId };
-
interface SearchContentHitRowProps {
hit: ContentHitData;
- onClick?: (location?: SearchLocation) => void;
+ onClick?: (e: PointerEvent | MouseEvent, location?: SearchLocation) => void;
index?: number;
count?: number;
}
export function SearchContentHitRow(props: SearchContentHitRowProps) {
const senderId = () => getSenderId(props.hit);
- const handleClick = () => {
- if (props.hit.location) {
- props.onClick?.(props.hit.location);
- } else {
- props.onClick?.();
- }
+ const handleClick = (e: PointerEvent | MouseEvent) => {
+ props.onClick?.(e, props.hit.location);
};
return (
@@ -35,13 +28,6 @@ export function SearchContentHitRow(props: SearchContentHitRowProps) {
)}
onClick={handleClick}
role="button"
- tabIndex={0}
- onKeyDown={(e) => {
- if (e.key === 'Enter' || e.key === ' ') {
- e.preventDefault();
- handleClick();
- }
- }}
>
<div class="flex flex-col gap-3">
<Show when={props.hit.type === 'channel' || props.hit.type === 'email'}>
diff --git a/js/app/packages/entity/src/extractors/entity-icon.tsx b/js/app/packages/entity/src/extractors/entity-icon.tsx
index e932fe6cad..e88fc1b0e2 100644
--- a/js/app/packages/entity/src/extractors/entity-icon.tsx
+++ b/js/app/packages/entity/src/extractors/entity-icon.tsx
@@ -36,12 +36,7 @@ function DirectMessageIcon(props: { entity: ChannelEntity }) {
export function EntityIcon(props: EntityIconProps) {
const iconType = () => {
return match(props.entity)
- .when(isChannelEntity, ({ channelType }) =>
- match(channelType)
- .with('direct_message', () => 'directMessage' as const)
- .with('organization', () => 'company' as const)
- .otherwise(() => 'channel')
- )
+ .when(isChannelEntity, ({ channelType }) => channelType)
.when(isTaskEntity, () => 'task')
.with({ type: 'document' }, ({ fileType }) => {
return fileType ?? 'default';
@@ -58,7 +53,7 @@ export function EntityIcon(props: EntityIconProps) {
else return 'default' as const;
};
- const isDirectMessage = () => iconType() === 'directMessage';
+ const isDirectMessage = () => iconType() === 'direct_message';
return (
<Show
diff --git a/js/app/packages/entity/src/index.ts b/js/app/packages/entity/src/index.ts
index 1be3824966..7000e34357 100644
--- a/js/app/packages/entity/src/index.ts
+++ b/js/app/packages/entity/src/index.ts
@@ -23,4 +23,6 @@ export {
filterValidNotifications,
} from './utils/notification';
+export { unreadFilterFn } from './utils/filter';
+
export { default as DebugEntityView } from './debug/DebugEntityView';
diff --git a/js/app/packages/queries/properties/entity.ts b/js/app/packages/queries/properties/entity.ts
index ef4d1da3a7..229b3dc959 100644
--- a/js/app/packages/queries/properties/entity.ts
+++ b/js/app/packages/queries/properties/entity.ts
@@ -96,8 +96,105 @@ export type SaveEntityPropertyParams = {
apiValues: PropertyApiValues;
};
+type SaveEntityPropertyContext = {
+ previousDss: [QueryKey, InfiniteData<SoupPage, unknown> | undefined][];
+};
+
+/**
+ * Converts PropertyApiValues to the SoupProperty value format for optimistic updates.
+ */
+function apiValuesToSoupPropertyValue(
+ apiValues: PropertyApiValues
+): { type: string; value: unknown } | null {
+ switch (apiValues.valueType) {
+ case 'STRING':
+ return apiValues.value != null
+ ? { type: 'String', value: apiValues.value }
+ : null;
+ case 'NUMBER':
+ return apiValues.value != null
+ ? { type: 'Number', value: apiValues.value }
+ : null;
+ case 'BOOLEAN':
+ return apiValues.value != null
+ ? { type: 'Boolean', value: apiValues.value }
+ : null;
+ case 'DATE':
+ return apiValues.value != null
+ ? { type: 'Date', value: apiValues.value }
+ : null;
+ case 'SELECT_STRING':
+ case 'SELECT_NUMBER':
+ return apiValues.values != null && apiValues.values.length > 0
+ ? { type: 'SelectOption', value: apiValues.values }
+ : null;
+ case 'ENTITY':
+ return apiValues.refs != null && apiValues.refs.length > 0
+ ? { type: 'EntityReference', value: apiValues.refs }
+ : null;
+ case 'LINK':
+ return apiValues.values != null && apiValues.values.length > 0
+ ? { type: 'Link', value: apiValues.values }
+ : null;
+ default:
+ return null;
+ }
+}
+
+/**
+ * Updates a specific property in DSS data for optimistic updates.
+ */
+function updateDssProperty(
+ data: InfiniteData<SoupPage, unknown> | undefined,
+ entityId: string,
+ propertyDefinitionId: string,
+ newValue: { type: string; value: unknown } | null
+): InfiniteData<SoupPage, unknown> | undefined {
+ if (!data) return data;
+
+ return {
+ ...data,
+ pages: data.pages.map((page) => ({
+ ...page,
+ items: page.items.map((item) => {
+ if ('data' in item && item.data && 'id' in item.data) {
+ const itemData = item.data as {
+ id: string;
+ properties?: SoupProperty[];
+ };
+ if (itemData.id === entityId && itemData.properties) {
+ const updatedProperties = itemData.properties.map((prop) => {
+ if (prop.definition.id === propertyDefinitionId) {
+ return {
+ ...prop,
+ value: newValue,
+ };
+ }
+ return prop;
+ });
+ return {
+ ...item,
+ data: {
+ ...item.data,
+ properties: updatedProperties,
+ },
+ } as typeof item;
+ }
+ }
+ return item;
+ }),
+ })),
+ pageParams: data.pageParams,
+ };
+}
+
export function useSaveEntityPropertyMutation(
- callbacks?: MutationCallbacks<void, Error, SaveEntityPropertyParams>
+ callbacks?: MutationCallbacks<
+ void,
+ Error,
+ SaveEntityPropertyParams,
+ SaveEntityPropertyContext
+ >
) {
return useMutation(() => ({
mutationFn: async (vars: SaveEntityPropertyParams) => {
@@ -118,30 +215,65 @@ export function useSaveEntityPropertyMutation(
})
);
},
- ...withCallbacks<void, Error, SaveEntityPropertyParams>(
- {
- onError(error) {
- console.error('Failed to save property', error);
- toast.failure('Failed to save property');
- },
- onSettled: (_data, _error, variables) => {
- invalidatePropertiesForEntity(
- variables.entityType,
- variables.entityId
- );
+ onMutate: async (
+ vars: SaveEntityPropertyParams
+ ): Promise<SaveEntityPropertyContext> => {
+ // Cancel any in-flight DSS queries that might overwrite our optimistic update
+ await queryClient.cancelQueries({ queryKey: soupKeys.items._def });
- // If the status property was changed, also invalidate DSS
- // so that tasks can reappear in Signal when marked un-done
- if (
- variables.property.propertyDefinitionId ===
- SYSTEM_PROPERTY_IDS.STATUS
- ) {
- queryClient.invalidateQueries({ queryKey: soupKeys.items._def });
- }
- },
- },
- callbacks
- ),
+ // Snapshot previous DSS data for rollback
+ const previousDss = queryClient.getQueriesData<
+ InfiniteData<SoupPage, unknown>
+ >({
+ queryKey: soupKeys.items._def,
+ });
+
+ // Convert API values to soup property value format
+ const soupValue = apiValuesToSoupPropertyValue(vars.apiValues);
+
+ // Optimistically update DSS queries
+ queryClient.setQueriesData<InfiniteData<SoupPage, unknown>>(
+ { queryKey: soupKeys.items._def },
+ (old) =>
+ updateDssProperty(
+ old,
+ vars.entityId,
+ vars.property.propertyDefinitionId,
+ soupValue
+ )
+ );
+
+ return { previousDss };
+ },
+ onError: (
+ error: Error,
+ _vars: SaveEntityPropertyParams,
+ context: SaveEntityPropertyContext | undefined
+ ) => {
+ console.error('Failed to save property', error);
+ toast.failure('Failed to save property');
+
+ // Rollback optimistic updates
+ if (context) {
+ for (const [key, data] of context.previousDss) {
+ queryClient.setQueryData(key, data);
+ }
+ }
+ },
+ onSettled: (_data, _error, variables) => {
+ invalidatePropertiesForEntity(variables.entityType, variables.entityId);
+
+ // Invalidate DSS to ensure consistency with server state
+ queryClient.invalidateQueries({ queryKey: soupKeys.items._def });
+ },
+ ...(callbacks
+ ? withCallbacks<
+ void,
+ Error,
+ SaveEntityPropertyParams,
+ SaveEntityPropertyContext
+ >({}, callbacks)
+ : {}),
}));
}
@@ -505,6 +637,9 @@ export function useBulkSaveEntityPropertiesMutation(
invalidatePropertiesForEntity(entityType, entityId);
});
});
+
+ // Invalidate soup/DSS queries to ensure UI updates reactively
+ queryClient.invalidateQueries({ queryKey: soupKeys.items._def });
},
},
callbacks
diff --git a/js/app/tsconfig.json b/js/app/tsconfig.json
index 29d40595ec..776043a580 100644
--- a/js/app/tsconfig.json
+++ b/js/app/tsconfig.json
@@ -199,8 +199,11 @@
"@block-theme/*": [
"./packages/block-theme/*"
],
+ "@entity": [
+ "./packages/entity/src/index.ts"
+ ],
"@entity/*": [
- "./packages/entity/*"
+ "./packages/entity/src/*"
],
},
"rootDir": ".",