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(tasks): task compose v1 (#692)

Seamus2ece11841cf1
diff --git a/js/app/packages/app/component/Launcher.tsx b/js/app/packages/app/component/Launcher.tsx
index 5739ceee35..fe082d2b56 100644
--- a/js/app/packages/app/component/Launcher.tsx
+++ b/js/app/packages/app/component/Launcher.tsx
@@ -15,7 +15,6 @@ import {
createChat,
createCodeFileFromText,
createMarkdownFile,
- createTask,
} from '@core/util/create';
import { createControlledOpenSignal } from '@core/util/createControlledOpenSignal';
import { isErr, ok } from '@core/util/maybeResult';
@@ -70,9 +69,14 @@ const createBlock = async (spec: {
const createComponent = async (spec: {
componentId: string;
shouldInsert?: boolean;
+ asPopover?: boolean;
}) => {
setCreateMenuOpen(false, false);
- const { replaceSplit, insertSplit } = useSplitLayout();
+ const { replaceSplit, insertSplit, popoverSplit } = useSplitLayout();
+ if (spec.asPopover) {
+ popoverSplit({ type: 'component', id: spec.componentId });
+ return;
+ }
if (spec.shouldInsert) {
insertSplit({ type: 'component', id: spec.componentId });
} else {
@@ -121,16 +125,9 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
altHotkeyToken: TOKENS.create.taskNewSplit,
hotkey: 't' as const,
keyDownHandler: () => {
- createBlock({
- blockName: 'task',
- loading: true,
- createFn: () =>
- createTask({
- title: '',
- content: '',
- projectId: undefined,
- }),
- shouldInsert: pressedKeys().has('opt'),
+ createComponent({
+ componentId: 'task-compose',
+ asPopover: true,
});
return true;
},
diff --git a/js/app/packages/app/component/SoupContext.tsx b/js/app/packages/app/component/SoupContext.tsx
index 7fae55c9c1..8dde548c8b 100644
--- a/js/app/packages/app/component/SoupContext.tsx
+++ b/js/app/packages/app/component/SoupContext.tsx
@@ -97,6 +97,28 @@ export type UnifiedListContext = {
_setNavigateThroughList: (fn: NavigateListFn) => void;
};
+export function createStubSoupContext(): UnifiedListContext {
+ return {
+ viewsDataStore: createStore({})[0],
+ setViewDataStore: () => {},
+ selectedView: () => '',
+ setSelectedView: () => {},
+ virtualizerHandleSignal: createSignal(),
+ entityListRefSignal: createSignal(),
+ entitiesSignal: createSignal(),
+ emailViewSignal: createSignal<PreviewViewStandardLabel>('all'),
+ showHelpDrawer: () => new Set(),
+ setShowHelpDrawer: () => {},
+ actionRegistry: createEntityActionRegistry(),
+ navigateThroughList: async () => ({
+ success: false,
+ type: '',
+ entity: undefined,
+ }),
+ _setNavigateThroughList: () => {},
+ };
+}
+
const DEFAULT_VIEW_ID: DefaultView = 'signal';
const DEFAULT_VIEW_IDS_SET = new Set(VIEWCONFIG_DEFAULTS_IDS);
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index 043c0ae229..cc50a34d33 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -22,6 +22,7 @@ import {
createNavigationEntityListShortcut,
createSoupContext,
} from '../SoupContext';
+import { PopoverSplitRenderer } from './components/PopoverSplitRenderer';
import { SplitContainer } from './components/SplitContainer';
import { SplitLayoutContext, SplitPanelContext } from './context';
import { useSplitLayout } from './layout';
@@ -320,6 +321,14 @@ export function SplitLayoutContainer(props: SplitLayoutContainerProps) {
)}
</For>
</Resize.Zone>
+ <PopoverSplitRenderer
+ popovers={splitManager.popovers}
+ onClosePopover={(id) => {
+ const activePopovers = splitManager.getActivePopovers();
+ const popover = activePopovers.find((p) => p.id === id);
+ popover?.close();
+ }}
+ />
</SplitLayoutContext.Provider>
);
}
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index d512bdc58b..182954d42a 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -1,4 +1,5 @@
import { ChannelCompose } from '@block-channel/component/Compose';
+import { ComposeTask } from '@block-md/component/ComposeTask';
import { LoadingBlock } from '@core/component/LoadingBlock';
import { DEV_MODE_ENV, LOCAL_ONLY } from '@core/constant/featureFlags';
import type { ViewId } from '@core/types/view';
@@ -56,6 +57,7 @@ registerComponent('unified-list', () => <Soup />, { viewId: 'signal' });
registerComponent('loading', () => <LoadingBlock />);
registerComponent('channel-compose', () => <ChannelCompose />);
registerComponent('email-compose', () => <EmailCompose />);
+registerComponent('task-compose', () => <ComposeTask />);
if (LOCAL_ONLY) {
registerComponent(
diff --git a/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx b/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx
new file mode 100644
index 0000000000..1e7d32a433
--- /dev/null
+++ b/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx
@@ -0,0 +1,152 @@
+import { ClippedPanel } from '@core/component/ClippedPanel';
+import { DialogWrapper } from '@core/component/DialogWrapper';
+import clickOutside from '@core/directive/clickOutside';
+import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
+import { Dialog } from '@kobalte/core/dialog';
+import { createMemo, createSignal, For, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import { createStubSoupContext } from '../../SoupContext';
+import { SplitPanelContext, type SplitPanelContextType } from '../context';
+import type {
+ PopoverSplitOptions,
+ SplitContent,
+ SplitHandle,
+ SplitId,
+ SplitMount,
+} from '../layoutManager';
+
+false && clickOutside;
+
+export type PopoverSplitData = {
+ id: string;
+ content: SplitContent;
+ mount: SplitMount;
+ isOpen: boolean;
+ options: PopoverSplitOptions;
+};
+
+export function PopoverSplitRenderer(props: {
+ popovers: () => Map<string, PopoverSplitData>;
+ onClosePopover?: (id: string) => void;
+}) {
+ const activePopovers = createMemo(() =>
+ Array.from(props.popovers().values()).filter((popover) => popover.isOpen)
+ );
+ return (
+ <For each={activePopovers()}>
+ {(popover) => (
+ <PopoverSplitModal
+ popover={popover}
+ onClose={() => props.onClosePopover?.(popover.id)}
+ />
+ )}
+ </For>
+ );
+}
+
+function PopoverSplitModal(props: {
+ popover: PopoverSplitData;
+ onClose: () => void;
+}) {
+ const [panelRef, setPanelRef] = createSignal<HTMLElement | null>(null);
+ const [contentOffsetTop, setContentOffsetTop] = createSignal(0);
+ const [previewState, setPreviewState] = createSignal(false);
+
+ const stubHandle: SplitHandle = {
+ id: props.popover.id as SplitId,
+ close: props.onClose,
+ content: () => props.popover.content,
+ canGoBack: () => false,
+ canGoForward: () => false,
+ goBack: () => {},
+ goForward: () => {},
+ reset: () => {},
+ activate: () => {},
+ isActive: () => true,
+ isFirst: () => true,
+ isLast: () => true,
+ displayName: () => props.popover.content.id,
+ setDisplayName: () => {},
+ toggleSpotlight: () => {},
+ isSpotLight: () => false,
+ isPopover: () => true,
+ replace: () => {},
+ removeFromHistory: () => {},
+ registerContentChangeListener: () => {},
+ unregisterContentChangeListener: () => {},
+ getUrlSegments: () => [],
+ getUrl: () => '',
+ meta: () =>
+ props.popover.mount.kind === 'component'
+ ? (props.popover.mount as any).meta
+ : undefined,
+ updateMeta:
+ props.popover.mount.kind === 'component'
+ ? (props.popover.mount as any).updateMeta
+ : undefined,
+ };
+
+ const stubPanelContext: SplitPanelContextType = {
+ handle: stubHandle,
+ splitHotkeyScope: `popover-${props.popover.id}`,
+ isPanelActive: () => true,
+ unifiedListContext: createStubSoupContext(),
+ panelRef,
+ panelSize: { width: null, height: null },
+ contentOffsetTop,
+ setContentOffsetTop,
+ previewState: [previewState, setPreviewState] as [
+ typeof previewState,
+ typeof setPreviewState,
+ ],
+ layoutRefs: {},
+ };
+
+ const [bindHotKeyDom, scopeId] = useHotkeyDOMScope(
+ `popover-split-${props.popover.id}`
+ );
+
+ registerHotkey({
+ hotkey: 'escape',
+ scopeId,
+ description: 'Close Popover',
+ keyDownHandler() {
+ props.onClose();
+ return true;
+ },
+ });
+
+ return (
+ <Dialog
+ open={props.popover.isOpen}
+ onOpenChange={(open) => {
+ if (!open) {
+ props.onClose();
+ }
+ }}
+ modal={true}
+ >
+ <Dialog.Overlay class="fixed inset-0 z-modal-overlay bg-transparent" />
+ <div class={`fixed inset-0 z-modal flex pointer-events-none isolate`}>
+ <Dialog.Content
+ use:clickOutside={() => props.onClose()}
+ ref={(r) => {
+ bindHotKeyDom(r);
+ }}
+ >
+ <DialogWrapper>
+ <Dialog.Content>
+ <ClippedPanel active tl ref={setPanelRef}>
+ <SplitPanelContext.Provider value={stubPanelContext}>
+ <Show when={props.popover.mount}>
+ <Dynamic component={props.popover.mount.element} />
+ </Show>
+ </SplitPanelContext.Provider>
+ </ClippedPanel>
+ </Dialog.Content>
+ </DialogWrapper>
+ </Dialog.Content>
+ </div>
+ </Dialog>
+ );
+}
diff --git a/js/app/packages/app/component/split-layout/components/SplitDrawer.tsx b/js/app/packages/app/component/split-layout/components/SplitDrawer.tsx
index f965722f1c..c8ce7656da 100644
--- a/js/app/packages/app/component/split-layout/components/SplitDrawer.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitDrawer.tsx
@@ -90,9 +90,9 @@ export function SplitDrawer(
const constrainedSize = getConstrainedSize();
if (isHorizontal()) {
- return { width: constrainedSize, top: `${contentOffsetTop()}px` };
+ return { width: constrainedSize, top: `${contentOffsetTop() + 1}px` };
} else {
- return { height: constrainedSize, top: `${contentOffsetTop()}px` };
+ return { height: constrainedSize, top: `${contentOffsetTop() + 1}px` };
}
};
@@ -116,11 +116,11 @@ export function SplitDrawer(
<Show when={drawerControl.isOpen()}>
<ScopedPortal scope="split">
<div
- class="inset-px bg-modal-overlay absolute transition-opacity ease-in-out pattern-edge"
+ class="inset-px bg-modal-overlay absolute"
style={{ top: `${contentOffsetTop()}px` }}
onClick={drawerControl.close}
/>
- <div class={getPositionClasses()} style={getSizeStyle()}>
+ <div class={getPositionClasses()} style={{ ...getSizeStyle() }}>
<div class={getGradientMaskClasses()} />
<BrightJoins dots={[true, true, true, true]} />
<div class="flex items-center justify-start gap-2 shrink-0">
diff --git a/js/app/packages/app/component/split-layout/layout.ts b/js/app/packages/app/component/split-layout/layout.ts
index 2400d1a3b7..e742ec2eaf 100644
--- a/js/app/packages/app/component/split-layout/layout.ts
+++ b/js/app/packages/app/component/split-layout/layout.ts
@@ -58,6 +58,15 @@ export function useSplitLayout() {
return splitManager.createNewSplit(content, true);
}
+ function popoverSplit(content: SplitContent) {
+ const splitManager = globalSplitManager();
+ if (!splitManager) {
+ console.error('no split manager found');
+ return;
+ }
+ return splitManager.createPopoverSplit({ content: content });
+ }
+
function resetSplit() {
if (!splitPanelContext) {
console.error('No split panel context found');
@@ -76,10 +85,11 @@ export function useSplitLayout() {
}
return {
- replaceOrInsertSplit: replaceOrInsertSplit,
- replaceSplit: replaceSplit,
- insertSplit: insertSplit,
- resetSplit: resetSplit,
- getSplitCount: getSplitCount,
+ getSplitCount,
+ replaceOrInsertSplit,
+ replaceSplit,
+ insertSplit,
+ resetSplit,
+ popoverSplit,
};
}
diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.ts
index d89e05c2fc..9979a27bb2 100644
--- a/js/app/packages/app/component/split-layout/layoutManager.ts
+++ b/js/app/packages/app/component/split-layout/layoutManager.ts
@@ -82,6 +82,18 @@ type ComponentMount = {
export type SplitMount = BlockMount | ComponentMount;
+export type PopoverSplitOptions = {
+ content: SplitContent;
+ onClose?: () => void;
+};
+
+export type PopoverSplitHandle = {
+ close: () => void;
+ isOpen: () => boolean;
+ content: () => SplitContent;
+ id: string;
+};
+
export type SplitState = {
id: SplitId;
history: History<SplitContent>;
@@ -212,6 +224,27 @@ export type SplitManager = {
/** Set the layout resize context from the component tree. */
setResizeContext: (cts: ResizeZoneCtx) => void;
+
+ /** Create a temporary popover split that renders content in a modal dialog */
+ createPopoverSplit: (options: PopoverSplitOptions) => PopoverSplitHandle;
+
+ /** Get all active popover splits */
+ getActivePopovers: () => PopoverSplitHandle[];
+
+ /** Close all popover splits */
+ closeAllPopovers: () => void;
+
+ /** Get reactive accessor to popovers map */
+ popovers: () => Map<
+ string,
+ {
+ id: string;
+ content: SplitContent;
+ mount: SplitMount;
+ isOpen: boolean;
+ options: PopoverSplitOptions;
+ }
+ >;
} & UrlCapabilities;
export type SplitHandle<TMeta extends ComponentMeta = ComponentMeta> = {
@@ -228,6 +261,7 @@ export type SplitHandle<TMeta extends ComponentMeta = ComponentMeta> = {
canGoForward: () => boolean;
content: () => SplitContent;
isSpotLight: () => boolean;
+ isPopover: () => boolean;
displayName: () => string;
canGoBack: () => boolean;
isActive: () => boolean;
@@ -320,12 +354,23 @@ export function createSplitLayout(
lastActiveSplitId: SplitId | undefined;
spotlightId: SplitId | undefined;
events: SplitEventWithType[];
+ popovers: Map<
+ string,
+ {
+ id: string;
+ content: SplitContent;
+ mount: SplitMount;
+ isOpen: boolean;
+ options: PopoverSplitOptions;
+ }
+ >;
}>({
splits: [],
activeSplitId: undefined,
lastActiveSplitId: undefined,
spotlightId: undefined,
events: [],
+ popovers: new Map(),
});
const [resizeContext, setResizeContext] = createSignal<ResizeZoneCtx>();
@@ -593,6 +638,7 @@ export function createSplitLayout(
isLast: () => state.splits.at(-1)?.id === id,
isActive: () => currentSplit.id === state.activeSplitId,
isSpotLight: () => state.spotlightId === currentSplit.id,
+ isPopover: () => state.popovers.has(currentSplit.id),
toggleSpotlight: (force?: boolean) => {
toggleSpotlightSplit(currentSplit.id, force);
},
@@ -757,6 +803,104 @@ export function createSplitLayout(
return splitNamesById[state.activeSplitId] || undefined;
};
+ // Popover split functions
+ function createPopoverSplit(
+ options: PopoverSplitOptions
+ ): PopoverSplitHandle {
+ const id = `popover-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
+ const mount = createPinnedMount(orchestrator, options.content);
+
+ const popoverData = {
+ id,
+ content: options.content,
+ mount,
+ isOpen: true,
+ options,
+ };
+
+ setState('popovers', (prev) => {
+ const newMap = new Map(prev);
+ newMap.set(id, popoverData);
+ return newMap;
+ });
+
+ const handle: PopoverSplitHandle = {
+ id,
+ close: () => {
+ setState('popovers', (prev) => {
+ const newMap = new Map(prev);
+ const popover = newMap.get(id);
+ if (popover) {
+ newMap.set(id, { ...popover, isOpen: false });
+ // Schedule cleanup after a brief delay to allow for animations
+ setTimeout(() => {
+ setState('popovers', (prev) => {
+ const cleanupMap = new Map(prev);
+ cleanupMap.delete(id);
+ return cleanupMap;
+ });
+ }, 300);
+ }
+ return newMap;
+ });
+ options.onClose?.();
+ },
+ isOpen: () => {
+ const popover = state.popovers.get(id);
+ return popover?.isOpen ?? false;
+ },
+ content: () => options.content,
+ };
+
+ return handle;
+ }
+
+ function getActivePopovers(): PopoverSplitHandle[] {
+ return Array.from(state.popovers.values())
+ .filter((popover) => popover.isOpen)
+ .map((popover) => ({
+ id: popover.id,
+ close: () => {
+ setState('popovers', (prev) => {
+ const newMap = new Map(prev);
+ const p = newMap.get(popover.id);
+ if (p) {
+ newMap.set(popover.id, { ...p, isOpen: false });
+ setTimeout(() => {
+ setState('popovers', (prev) => {
+ const cleanupMap = new Map(prev);
+ cleanupMap.delete(popover.id);
+ return cleanupMap;
+ });
+ }, 300);
+ }
+ return newMap;
+ });
+ popover.options.onClose?.();
+ },
+ isOpen: () => {
+ const p = state.popovers.get(popover.id);
+ return p?.isOpen ?? false;
+ },
+ content: () => popover.content,
+ }));
+ }
+
+ function closeAllPopovers(): void {
+ setState('popovers', (prev) => {
+ const newMap = new Map();
+ for (const [id, popover] of prev) {
+ newMap.set(id, { ...popover, isOpen: false });
+ popover.options.onClose?.();
+ }
+ // Schedule cleanup
+ setTimeout(() => {
+ setState('popovers', () => new Map());
+ }, 300);
+ return newMap;
+ });
+ }
+
return {
splits: () => state.splits,
activeSplitId: () => state.activeSplitId,
@@ -779,5 +923,9 @@ export function createSplitLayout(
resizeContext,
setResizeContext,
getOrchestrator: () => orchestrator,
+ createPopoverSplit,
+ getActivePopovers,
+ closeAllPopovers,
+ popovers: () => state.popovers,
};
}
diff --git a/js/app/packages/block-md/component/ComposeTask.tsx b/js/app/packages/block-md/component/ComposeTask.tsx
new file mode 100644
index 0000000000..1ff599a15b
--- /dev/null
+++ b/js/app/packages/block-md/component/ComposeTask.tsx
@@ -0,0 +1,418 @@
+import { useSplitPanel } from '@app/component/split-layout/layoutUtils';
+import { EntityIcon } from '@core/component/EntityIcon';
+import { IconButton } from '@core/component/IconButton';
+import { BlockLink } from '@core/component/LexicalMarkdown/component/core/BlockLink';
+import { MarkdownTextarea } from '@core/component/LexicalMarkdown/component/core/MarkdownTextarea';
+import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
+import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
+import { initializeEditorEmpty } from '@core/component/LexicalMarkdown/utils';
+import {
+ propertyApiValuesToNormalized,
+ propertyValueToApi,
+} from '@core/component/Properties/api/converters';
+import { Modals } from '@core/component/Properties/component/modal';
+import { PropertyRow } from '@core/component/Properties/component/panel';
+import { SYSTEM_PROPERTY_IDS } from '@core/component/Properties/constants';
+import {
+ PropertiesProvider,
+ type PropertySaveHandler,
+ usePropertiesContext,
+} from '@core/component/Properties/context/PropertiesContext';
+import type {
+ Property,
+ PropertyApiValues,
+ PropertyOption,
+} from '@core/component/Properties/types';
+import { TextButton } from '@core/component/TextButton';
+import { toast } from '@core/component/Toast/Toast';
+import { itemToSafeName } from '@core/constant/allBlocks';
+import { createMarkdownFile } from '@core/util/create';
+import { filterMap } from '@core/util/list';
+import { isErr } from '@core/util/maybeResult';
+import XIcon from '@icon/regular/x.svg';
+import { propertiesServiceClient } from '@service-properties/client';
+import type { PropertyDefinition } from '@service-properties/generated/schemas/propertyDefinition';
+import { useQuery } from '@tanstack/solid-query';
+import type { LexicalEditor } from 'lexical';
+import { createSignal, For, Show, Suspense } from 'solid-js';
+import { createStore, reconcile, type Store, unwrap } from 'solid-js/store';
+import { tabbable } from 'tabbable';
+
+// Show these props in the composer.
+const COMPOSER_PROPERTIES = [
+ SYSTEM_PROPERTY_IDS.ASSIGNEES,
+ SYSTEM_PROPERTY_IDS.STATUS,
+ SYSTEM_PROPERTY_IDS.DUE_DATE,
+ SYSTEM_PROPERTY_IDS.PRIORITY,
+];
+
+/**
+ * Make a task and append props.
+ * @param taskTitle Title string
+ * @param taskContent content markdown string
+ * @param properties Stored prop value map
+ * @param definitions The definitions map for extra meta data
+ * @returns
+ */
+async function createTaskWithProperties(
+ taskTitle: string,
+ taskContent: string,
+ properties: Array<[string, PropertyApiValues]>,
+ definitions: Map<string, PropertyDefinition>
+) {
+ const res = await createMarkdownFile({
+ title: taskTitle,
+ content: taskContent,
+ isTask: true,
+ });
+
+ if (!res) {
+ toast.failure('Failed to create Task');
+ return null;
+ }
+
+ const propRequests = properties.map(([id, value]) => {
+ const isMultiSelect = definitions.get(id)?.is_multi_select ?? false;
+ return propertiesServiceClient.setEntityProperty({
+ entity_id: res,
+ entity_type: 'TASK',
+ property_id: id,
+ body: {
+ value: propertyValueToApi(value, isMultiSelect),
+ },
+ });
+ });
+
+ await Promise.allSettled(propRequests);
+
+ toast.embed(
+ () => <TaskToastPreview id={res} title={taskTitle} body={taskContent} />,
+ {
+ duration: 2_000,
+ }
+ );
+
+ return res;
+}
+
+/**
+ * Helper to get display value of local property
+ * @param definition The prop definition
+ * @param savedValues The map of saved vals by propDef id
+ * @param options The map of the options for the prop from the server
+ * @returns
+ */
+function extractPropertyValue(
+ definition: PropertyDefinition,
+ savedValues: Store<Record<string, PropertyApiValues>>,
+ options: Map<string, PropertyOption[]>
+) {
+ const { type, value } = propertyApiValuesToNormalized(
+ savedValues[definition.id]
+ );
+ if (type === 'EMPTY') return null;
+ if (
+ definition.data_type === 'SELECT_NUMBER' ||
+ definition.data_type === 'SELECT_STRING'
+ ) {
+ const opts = options.get(definition.id);
+ if (!opts) return null;
+ if (Array.isArray(value)) {
+ return filterMap(value as string[], (id) => {
+ const opt = opts.find((opt) => opt.id === id);
+ return opt ? opt.value.value : undefined;
+ });
+ }
+ } else {
+ return value;
+ }
+}
+
+/**
+ * Toast preview component for successful task creation.
+ * @param props
+ * @returns
+ */
+function TaskToastPreview(props: { title: string; body: string; id: string }) {
+ return (
+ <BlockLink blockOrFileName="task" id={props.id}>
+ <div class="text-ink size-full">
+ <div class="flex row items-center gap-2 mb-4">
+ <EntityIcon targetType="task" />
+ <span class="text-base font-medium">
+ {props.title ||
+ itemToSafeName({ type: 'document', subType: 'task' })}
+ </span>
+ </div>
+ <div class="text-ink-muted text-sm h-fit max-h-18 w-full truncate">
+ <StaticMarkdown
+ markdown={props.body}
+ theme={unifiedListMarkdownTheme}
+ singleLine
+ />
+ </div>
+ </div>
+ </BlockLink>
+ );
+}
+
+export interface ComposeTaskProps {
+ onCreateTask?: (title: string, content: string) => void;
+ onClose?: () => void;
+ initialTitle?: string;
+ initialContent?: string;
+ placeholder?: string;
+}
+
+export function ComposeTask(props: ComposeTaskProps) {
+ const splitPanel = useSplitPanel();
+ const [title, setTitle] = createSignal(props.initialTitle ?? '');
+ const [content, setContent] = createSignal(props.initialContent ?? '');
+ const [bodyEditor, setBodyEditor] = createSignal<LexicalEditor>();
+ const [containerRef, setContainerRef] = createSignal<HTMLDivElement>();
+
+ const [propertyValues, setPropertyValues] = createStore<
+ Record<string, PropertyApiValues>
+ >({});
+
+ const systemPropertiesQuery = useQuery(() => ({
+ queryKey: ['compose-task', 'system-properties'],
+ queryFn: async () => {
+ const result = await propertiesServiceClient.listProperties({
+ scope: 'system',
+ include_options: true,
+ });
+ if (isErr(result)) {
+ throw new Error('Failed to fetch system properties');
+ }
+ const [, data] = result;
+ return data;
+ },
+ staleTime: 1000 * 60 * 10, // TODO (seamus) Ask daniel what might make us wanna refetch this
+ retry: 1,
+ refetchOnWindowFocus: false,
+ refetchOnMount: false,
+ refetchOnReconnect: false,
+ placeholderData: (prev) => prev,
+ }));
+
+ const definitions = () => {
+ if (!systemPropertiesQuery.isSuccess) return new Map();
+ const data = systemPropertiesQuery.data;
+ return new Map(
+ data.map((p) => {
+ const definition = 'definition' in p ? p.definition : p;
+ return [definition.id, definition];
+ })
+ );
+ };
+
+ const options = () => {
+ if (!systemPropertiesQuery.isSuccess) return new Map();
+ const data = systemPropertiesQuery.data;
+ return new Map(
+ data.map((p) => {
+ const definition = 'definition' in p ? p.definition : p;
+ const options = 'property_options' in p ? p.property_options : [];
+ return [definition.id, options];
+ })
+ );
+ };
+
+ const properties = () => {
+ return filterMap(COMPOSER_PROPERTIES, (id) => {
+ const definition = definitions().get(id);
+ if (!definition) return;
+ return {
+ propertyId: `compose-${definition.display_name}`,
+ propertyDefinitionId: definition.id,
+ displayName: definition.display_name,
+ isMultiSelect: definition.is_multi_select,
+ owner: definition.owner,
+ specificEntityType: definition.specific_entity_type ?? null,
+ updatedAt: '',
+ createdAt: '',
+ valueType: definition.data_type,
+ value: extractPropertyValue(definition, propertyValues, options()),
+ } as Property;
+ });
+ };
+
+ const saveHandler: PropertySaveHandler = {
+ saveProperty: async (property: Property, value: PropertyApiValues) => {
+ setPropertyValues(property.propertyDefinitionId, value);
+ return { ok: true, value: undefined };
+ },
+ saveDate: async (property: Property, date: Date) => {
+ setPropertyValues(property.propertyDefinitionId, {
+ valueType: 'DATE',
+ value: date.toISOString(),
+ });
+ return { ok: true, value: undefined };
+ },
+ };
+
+ const handleCreateTask = async () => {
+ const taskTitle = title().trim();
+ const taskContent = content().trim();
+ const properties = structuredClone(Object.entries(unwrap(propertyValues)));
+
+ createTaskWithProperties(taskTitle, taskContent, properties, definitions());
+
+ setTitle('');
+ setPropertyValues(reconcile({}));
+
+ const ed = bodyEditor();
+ ed && initializeEditorEmpty(ed);
+
+ if (splitPanel?.handle.isPopover()) {
+ splitPanel.handle.close();
+ }
+
+ props.onCreateTask?.(taskTitle, taskContent);
+ props.onClose?.();
+ };
+
+ const editorFocusChange = (e: KeyboardEvent, dir: 1 | -1) => {
+ const root = bodyEditor()?.getRootElement();
+ const container = containerRef();
+ if (!(root && container)) return;
+ const tabbables = tabbable(container);
+ const ndx = tabbables.indexOf(root);
+ const next = (ndx + dir + tabbables.length) % tabbables.length;
+ const elem = tabbables.at(next);
+ if (elem) {
+ elem.focus();
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ };
+
+ return (
+ <div
+ class="flex flex-col relative bracket-never"
+ tabIndex={-1}
+ ref={setContainerRef}
+ >
+ <div class="flex items-center gap-1 p-2">
+ <Show when={splitPanel?.handle.isPopover()}>
+ <IconButton
+ icon={XIcon}
+ onClick={splitPanel?.handle.close}
+ size="sm"
+ tabIndex={-1}
+ theme="current"
+ />
+ </Show>
+ <div class="flex items-center gap-2">
+ <span class="text-sm font-medium text-ink-disabled/50">
+ Create Task
+ </span>
+ </div>
+ </div>
+ <div class="w-full border-b border-edge-muted/50" />
+ <div class="p-2">
+ <div class="flex-shrink-0 flex p-2 gap-2 items-center">
+ <EntityIcon targetType="task" size="sm" />
+ <input
+ type="text"
+ placeholder="Task Title"
+ value={title()}
+ onInput={(e) => setTitle(e.currentTarget.value)}
+ class="w-full py-2 text-xl font-medium placeholder-ink-placeholder/50"
+ on:keydown={(e) => {
+ if (e.key === 'Escape') {
+ const container = containerRef();
+ if (container) {
+ container.focus();
+ e.stopPropagation();
+ e.preventDefault();
+ }
+ }
+ if (e.key === 'Enter' || e.key === 'ArrowDown') {
+ const editor = bodyEditor();
+ if (editor) {
+ e.stopPropagation();
+ e.preventDefault();
+ editor.focus(undefined, { defaultSelection: 'rootEnd' });
+ }
+ }
+ }}
+ />
+ </div>
+
+ <div class="min-h-0 text-base m-2">
+ <MarkdownTextarea
+ editable={() => true}
+ onChange={(value) => setContent(value)}
+ initialValue={props.initialContent}
+ placeholder={props.placeholder ?? 'Add description...'}
+ captureEditor={setBodyEditor}
+ onEscape={() => {
+ containerRef()?.focus();
+ return true;
+ }}
+ onFocusLeaveStart={(e) => editorFocusChange(e, -1)}
+ onFocusLeaveEnd={(e) => editorFocusChange(e, +1)}
+ />
+ </div>
+
+ <Suspense>
+ <PropertiesProvider
+ entityType="TASK"
+ canEdit={true}
+ properties={properties}
+ onRefresh={() => {}}
+ onPropertyAdded={() => {}}
+ onPropertyDeleted={() => {}}
+ saveHandler={saveHandler}
+ >
+ <div class="w-full grid grid-cols-2 gap-1 flex-wrap text-xs font-mono text-ink-muted mt-8">
+ <For each={properties()}>
+ {(prop) => {
+ const { openPropertyEditor, openDatePicker } =
+ usePropertiesContext();
+ const handleValueClick = (
+ property: Property,
+ anchor?: HTMLElement
+ ) => {
+ if (property.valueType === 'DATE') {
+ openDatePicker(property, anchor);
+ } else if (
+ property.valueType === 'SELECT_STRING' ||
+ property.valueType === 'SELECT_NUMBER' ||
+ property.valueType === 'ENTITY'
+ ) {
+ openPropertyEditor(property, anchor);
+ }
+ };
+ return (
+ <div class="grid grid-cols-[8rem_auto] rounded-xs items-center p-1">
+ <PropertyRow
+ property={prop}
+ onValueClick={handleValueClick}
+ withDelete={false}
+ withPin={false}
+ />
+ </div>
+ );
+ }}
+ </For>
+ </div>
+ <Modals />
+ </PropertiesProvider>
+ </Suspense>
+ </div>
+
+ <div class="w-full border-b border-edge-muted/50" />
+ <div class="flex-shrink-0 flex justify-end p-2">
+ <TextButton
+ icon={() => <EntityIcon targetType="task" theme="monochrome" />}
+ onClick={handleCreateTask}
+ text="Create Task"
+ theme="accent"
+ />
+ </div>
+ </div>
+ );
+}
diff --git a/js/app/packages/block-md/component/FrontMatterProperties.tsx b/js/app/packages/block-md/component/FrontMatterProperties.tsx
index 86c6529730..d9e964b7fd 100644
--- a/js/app/packages/block-md/component/FrontMatterProperties.tsx
+++ b/js/app/packages/block-md/component/FrontMatterProperties.tsx
@@ -5,11 +5,19 @@ import {
dispatchInternalLayoutShift,
REMOVE_PINNED_PROPERTY_COMMAND,
} from '@core/component/LexicalMarkdown/plugins';
+import { saveEntityProperty } from '@core/component/Properties/api';
import { Modals } from '@core/component/Properties/component/modal';
import { PanelContainer } from '@core/component/Properties/component/panel';
import { getDefaultPinnedProperties } from '@core/component/Properties/constants';
-import { PropertiesProvider } from '@core/component/Properties/context/PropertiesContext';
+import {
+ PropertiesProvider,
+ type PropertySaveHandler,
+} from '@core/component/Properties/context/PropertiesContext';
import { useEntityProperties } from '@core/component/Properties/hooks';
+import type {
+ Property,
+ PropertyApiValues,
+} from '@core/component/Properties/types';
import CaretDown from '@icon/bold/caret-down-bold.svg';
import CaretRight from '@icon/bold/caret-right-bold.svg';
import EyeSlash from '@icon/bold/eye-slash-bold.svg';
@@ -143,6 +151,19 @@ export function FrontMatterProperties(props: FrontMatterPropertiesProps) {
const height = () => containerSize.height;
createEffect(on(height, layoutShift));
+ // Network-based save handler for FrontMatter properties
+ const saveHandler: PropertySaveHandler = {
+ saveProperty: async (property: Property, value: PropertyApiValues) => {
+ return await saveEntityProperty(blockId, entityType, property, value);
+ },
+ saveDate: async (property: Property, date: Date) => {
+ return await saveEntityProperty(blockId, entityType, property, {
+ valueType: 'DATE',
+ value: date.toISOString(),
+ });
+ },
+ };
+
return (
<Show when={!error()} fallback={props.fallback}>
<div class="mt-6 mb-6" ref={setContainerRef}>
@@ -157,6 +178,7 @@ export function FrontMatterProperties(props: FrontMatterPropertiesProps) {
onPropertyPinned={handlePropertyPinned}
onPropertyUnpinned={handlePropertyUnpinned}
pinnedPropertyIds={pinnedPropertyIds}
+ saveHandler={saveHandler}
>
{/* Collapsible header with horizontal line */}
<div class="flex items-center gap-2 pt-2">
diff --git a/js/app/packages/core/block.ts b/js/app/packages/core/block.ts
index f65949c1a3..6f16c3997f 100644
--- a/js/app/packages/core/block.ts
+++ b/js/app/packages/core/block.ts
@@ -537,6 +537,17 @@ export const useMaybeBlockName = (): BlockName | undefined => {
return context.name;
};
+export const useMaybeBlockAliasedName = ():
+ | BlockName
+ | BlockAlias
+ | undefined => {
+ const context = useContext(BlockContext);
+ if (!context) {
+ return;
+ }
+ return context.aliasContext?.alias ?? context.name;
+};
+
function styledConsoleError(message: string, code: string) {
if (import.meta.env.DEV) {
const styles = `
diff --git a/js/app/packages/core/component/ClippedPanel.tsx b/js/app/packages/core/component/ClippedPanel.tsx
index 281f447d59..0f80f36f8b 100644
--- a/js/app/packages/core/component/ClippedPanel.tsx
+++ b/js/app/packages/core/component/ClippedPanel.tsx
@@ -1,5 +1,5 @@
import { cornerClip } from '@core/util/clipPath';
-import type { JSXElement } from 'solid-js';
+import type { JSXElement, Ref } from 'solid-js';
import { beveledCorners } from '../../block-theme/signals/themeSignals';
interface PanelProps {
@@ -9,6 +9,7 @@ interface PanelProps {
tl?: boolean;
bl?: boolean;
br?: boolean;
+ ref?: Ref<HTMLDivElement>;
}
export function ClippedPanel(props: PanelProps) {
@@ -55,6 +56,7 @@ export function ClippedPanel(props: PanelProps) {
: '0',
}}
class="h-full w-full box-border overflow-hidden bg-panel"
+ ref={props.ref}
>
{props.children}
</div>
diff --git a/js/app/packages/core/component/DatePicker/index.tsx b/js/app/packages/core/component/DatePicker/index.tsx
index 8c5581eef6..ac5cd900f9 100644
--- a/js/app/packages/core/component/DatePicker/index.tsx
+++ b/js/app/packages/core/component/DatePicker/index.tsx
@@ -69,10 +69,6 @@ export function DatePicker(props: DatePickerProps) {
props.onChange(newDate);
};
- const _handleQuickSelect = (date: Date) => {
- props.onChange(date);
- };
-
const isToday = (day: number) => {
const today = new Date();
return (
diff --git a/js/app/packages/core/component/DialogWrapper.tsx b/js/app/packages/core/component/DialogWrapper.tsx
index 172972b23a..712e1b9339 100644
--- a/js/app/packages/core/component/DialogWrapper.tsx
+++ b/js/app/packages/core/component/DialogWrapper.tsx
@@ -1,16 +1,21 @@
-import type { JSXElement } from 'solid-js';
+import type { JSXElement, Ref } from 'solid-js';
export interface DialogWrapperProps {
children: JSXElement;
class?: string;
width?: string;
+ overlayRef?: Ref<HTMLDivElement>;
+ contentRef?: Ref<HTMLDivElement>;
}
export function DialogWrapper(props: DialogWrapperProps) {
const width = props.width ?? '800px';
return (
- <div class="z-modal fixed inset-0 bg-modal-overlay pattern-edge-muted pattern-diagonal-4">
+ <div
+ class="z-modal fixed inset-0 bg-modal-overlay pattern-edge-muted pattern-diagonal-4"
+ ref={props.overlayRef}
+ >
<div
style={{
'max-width': 'calc(100vw - (var(--gutter-size) * 2))',
@@ -20,6 +25,7 @@ export function DialogWrapper(props: DialogWrapperProps) {
width: width,
}}
class={props.class}
+ ref={props.contentRef}
>
{props.children}
</div>
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/core/MarkdownTextarea.tsx b/js/app/packages/core/component/LexicalMarkdown/component/core/MarkdownTextarea.tsx
index 1b592e9381..30ec2eace6 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/core/MarkdownTextarea.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/core/MarkdownTextarea.tsx
@@ -277,7 +277,7 @@ export function MarkdownTextarea(props: MarkdownTextareaProps) {
<DecoratorRenderer editor={editor} />
<NodeAccessoryRenderer editor={editor} store={accessoryStore} />
<Show when={showPlaceholder()}>
- <div class="pointer-events-none text-ink-extra-muted absolute top-0">
+ <div class="pointer-events-none text-ink-placeholder/50 absolute top-0">
<p class="my-1.5 pointer-events-none">
{props.placeholder ?? '...'}
</p>
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 2f7b9afc07..8ac0f03742 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/MentionsMenu.tsx
@@ -227,6 +227,7 @@ async function handleUserMention(
dependencies;
let mentionId: string | undefined;
+ console.log({ blockName, blockId });
if (blockName !== 'channel') {
if (blockId) {
const record: UserMentionRecord = {
diff --git a/js/app/packages/core/component/Properties/PropertiesView.tsx b/js/app/packages/core/component/Properties/PropertiesView.tsx
index 5494784c6d..da2c9d2ee1 100644
--- a/js/app/packages/core/component/Properties/PropertiesView.tsx
+++ b/js/app/packages/core/component/Properties/PropertiesView.tsx
@@ -1,15 +1,21 @@
import { useBlockId } from '@core/block';
import LoadingSpinner from '@icon/regular/spinner.svg';
import { type Accessor, createMemo, Show } from 'solid-js';
+import { saveEntityProperty } from './api';
import { Modals } from './component/modal/Modals';
import { AddPropertyButton } from './component/panel/AddPropertyButton';
import { PanelContainer } from './component/panel/PanelContainer';
import {
PropertiesProvider,
+ type PropertySaveHandler,
usePropertiesContext,
} from './context/PropertiesContext';
import { useEntityProperties } from './hooks';
-import type { PropertiesPanelProps, Property } from './types';
+import type {
+ PropertiesPanelProps,
+ Property,
+ PropertyApiValues,
+} from './types';
const CONTAINER_CLASSES =
'h-full overflow-hidden relative font-mono flex flex-col';
@@ -42,6 +48,23 @@ export function PropertiesView(props: PropertiesPanelProps) {
handleRefresh();
};
+ const saveHandler: PropertySaveHandler = {
+ saveProperty: async (property: Property, value: PropertyApiValues) => {
+ return await saveEntityProperty(
+ blockId,
+ props.entityType,
+ property,
+ value
+ );
+ },
+ saveDate: async (property: Property, date: Date) => {
+ return await saveEntityProperty(blockId, props.entityType, property, {
+ valueType: 'DATE',
+ value: date.toISOString(),
+ });
+ },
+ };
+
return (
<PropertiesProvider
entityType={props.entityType}
@@ -54,6 +77,7 @@ export function PropertiesView(props: PropertiesPanelProps) {
onPropertyPinned={props.onPropertyPinned}
onPropertyUnpinned={props.onPropertyUnpinned}
pinnedPropertyIds={props.pinnedPropertyIds}
+ saveHandler={saveHandler}
>
<PropertiesViewContent
properties={properties}
diff --git a/js/app/packages/core/component/Properties/api/converters.ts b/js/app/packages/core/component/Properties/api/converters.ts
index 81dcaeef8e..41112a7cd2 100644
--- a/js/app/packages/core/component/Properties/api/converters.ts
+++ b/js/app/packages/core/component/Properties/api/converters.ts
@@ -2,6 +2,7 @@ import type { PropertyValue } from '@service-properties/generated/schemas/proper
import { NUMBER_DECIMAL_PLACES } from '../constants';
import type {
EntityPropertyWithDefinition,
+ EntityReference,
Property,
PropertyApiValues,
SetPropertyValue,
@@ -9,6 +10,20 @@ import type {
} from '../types';
import { isEntityReferenceArray, isStringArray } from '../utils/typeGuards';
+/**
+ * Normalized flat value type for PropertyApiValues conversion
+ * Contains the actual value with proper TypeScript typing based on the PropertyApiValues type
+ */
+export type NormalizedPropertyValue =
+ | { type: 'STRING'; value: string }
+ | { type: 'NUMBER'; value: number }
+ | { type: 'BOOLEAN'; value: boolean }
+ | { type: 'DATE'; value: Date }
+ | { type: 'SELECT_OPTION'; value: string[] }
+ | { type: 'ENTITY_REFERENCE'; value: EntityReference[] }
+ | { type: 'LINK'; value: string[] }
+ | { type: 'EMPTY'; value: null };
+
/**
* Type guard to check if PropertyValue has a specific type
*/
@@ -260,3 +275,90 @@ export function propertyValueToApi(
}
}
}
+
+/**
+ * Convert PropertyApiValues from domain format to a normalized flat value structure
+ *
+ * Transforms the PropertyApiValues discriminated union into a simplified format with:
+ * - Consistent type field naming
+ * - Properly typed value field
+ * - Normalized handling of all value types including empty/null values
+ */
+export function propertyApiValuesToNormalized(
+ apiValues: PropertyApiValues | null | undefined
+): NormalizedPropertyValue {
+ // Handle null/undefined values
+ if (!apiValues) {
+ return { type: 'EMPTY', value: null };
+ }
+
+ // Handle each PropertyApiValues type
+ switch (apiValues.valueType) {
+ case 'STRING': {
+ if (apiValues.value !== null && typeof apiValues.value === 'string') {
+ return { type: 'STRING', value: apiValues.value };
+ }
+ return { type: 'EMPTY', value: null };
+ }
+
+ case 'NUMBER': {
+ if (
+ apiValues.value !== null &&
+ typeof apiValues.value === 'number' &&
+ !isNaN(apiValues.value)
+ ) {
+ return {
+ type: 'NUMBER',
+ value: parseFloat(apiValues.value.toFixed(NUMBER_DECIMAL_PLACES)),
+ };
+ }
+ return { type: 'EMPTY', value: null };
+ }
+
+ case 'BOOLEAN': {
+ if (apiValues.value !== null && typeof apiValues.value === 'boolean') {
+ return { type: 'BOOLEAN', value: apiValues.value };
+ }
+ return { type: 'EMPTY', value: null };
+ }
+
+ case 'DATE': {
+ if (apiValues.value !== null && typeof apiValues.value === 'string') {
+ const date = new Date(apiValues.value);
+ if (!isNaN(date.getTime())) {
+ return { type: 'DATE', value: date };
+ }
+ }
+ return { type: 'EMPTY', value: null };
+ }
+
+ case 'SELECT_STRING':
+ case 'SELECT_NUMBER': {
+ if (apiValues.values && isStringArray(apiValues.values)) {
+ return { type: 'SELECT_OPTION', value: apiValues.values };
+ }
+ return { type: 'EMPTY', value: null };
+ }
+
+ case 'ENTITY': {
+ if (apiValues.refs && isEntityReferenceArray(apiValues.refs)) {
+ return { type: 'ENTITY_REFERENCE', value: apiValues.refs };
+ }
+ return { type: 'EMPTY', value: null };
+ }
+
+ case 'LINK': {
+ if (apiValues.values && isStringArray(apiValues.values)) {
+ return { type: 'LINK', value: apiValues.values };
+ }
+ return { type: 'EMPTY', value: null };
+ }
+
+ default: {
+ const exhaustiveCheck: never = apiValues;
+ throw new Error(
+ `Unsupported value type: ${(exhaustiveCheck as { valueType: string }).valueType}`
+ );
+ }
+ }
+}
diff --git a/js/app/packages/core/component/Properties/component/modal/EditPropertyValueModal.tsx b/js/app/packages/core/component/Properties/component/modal/EditPropertyValueModal.tsx
index ab456e89c9..18318681ba 100644
--- a/js/app/packages/core/component/Properties/component/modal/EditPropertyValueModal.tsx
+++ b/js/app/packages/core/component/Properties/component/modal/EditPropertyValueModal.tsx
@@ -1,5 +1,5 @@
-import { useBlockId } from '@core/block';
import { IconButton } from '@core/component/IconButton';
+import { ScopedPortal } from '@core/component/ScopedPortal';
import {
constrainModalToViewport,
MODAL_VIEWPORT_CLASSES,
@@ -13,9 +13,8 @@ import {
onMount,
Show,
} from 'solid-js';
-import { Portal } from 'solid-js/web';
-import { saveEntityProperty } from '../../api';
import { MODAL_DIMENSIONS } from '../../constants';
+import { usePropertiesContext } from '../../context/PropertiesContext';
import { usePropertyEditor } from '../../hooks/usePropertyEditor';
import type { PropertyApiValues, PropertyEditorProps } from '../../types';
import { getValueTypeDisplay } from '../../utils';
@@ -28,12 +27,12 @@ import { PropertyOptionSelector } from './shared/PropertyOptionSelector';
// Common CSS classes
const MODAL_BASE =
- 'absolute bg-dialog border-3 border-edge shadow-xl z-modal max-h-96 overflow-hidden flex flex-col w-full max-w-md';
+ 'absolute bg-dialog border-3 border-edge shadow-xl max-h-96 overflow-hidden flex flex-col w-full max-w-md';
const HEADER_CLASSES = 'flex items-center justify-between pt-3 pb-2 px-4';
const CONTENT_CLASSES = 'flex-1 max-h-64 pt-2 px-4 pb-4';
export function EditPropertyValueModal(props: PropertyEditorProps) {
- const blockId = useBlockId();
+ const { saveHandler } = usePropertiesContext();
const [selectedEntityRefs, setSelectedEntityRefs] = createSignal<
EntityReference[]
@@ -85,19 +84,15 @@ export function EditPropertyValueModal(props: PropertyEditorProps) {
`Invalid property type for modal editor: ${props.property.valueType}`
)
);
+ props.onClose();
return;
}
- // saveEntityProperty already handles error logging and user feedback
- const result = await saveEntityProperty(
- blockId,
- props.entityType,
- props.property,
- apiValues
- );
-
- if (result.ok) {
+ try {
+ await saveHandler.saveProperty(props.property, apiValues);
props.onSaved();
+ } catch (error) {
+ console.error('Failed to save property:', error);
}
props.onClose();
@@ -163,11 +158,8 @@ export function EditPropertyValueModal(props: PropertyEditorProps) {
});
return (
- <Portal>
- <div
- class="fixed inset-0 bg-overlay z-modal-overlay"
- onClick={handleClose}
- >
+ <ScopedPortal scope="local">
+ <div class="fixed inset-0 z-modal" onClick={handleClose}>
<div
ref={modalRef}
class={`${MODAL_BASE} ${MODAL_VIEWPORT_CLASSES}`}
@@ -258,6 +250,6 @@ export function EditPropertyValueModal(props: PropertyEditorProps) {
</div>
</div>
</div>
- </Portal>
+ </ScopedPortal>
);
}
diff --git a/js/app/packages/core/component/Properties/component/modal/Modals.tsx b/js/app/packages/core/component/Properties/component/modal/Modals.tsx
index ba9a801f80..1e8cab7295 100644
--- a/js/app/packages/core/component/Properties/component/modal/Modals.tsx
+++ b/js/app/packages/core/component/Properties/component/modal/Modals.tsx
@@ -1,23 +1,21 @@
-import { useBlockId } from '@core/block';
import { DatePicker } from '@core/component/DatePicker';
+import { ScopedPortal } from '@core/component/ScopedPortal';
import { type Component, createMemo } from 'solid-js';
-import { Portal, Show } from 'solid-js/web';
-import { saveEntityProperty } from '../../api';
+import { Show } from 'solid-js/web';
import { usePropertiesContext } from '../../context/PropertiesContext';
import type { Property } from '../../types';
-import { ERROR_MESSAGES, handlePropertyError } from '../../utils/errorHandling';
import { useModalPosition } from '../../utils/position';
import { CreatePropertyModal } from './CreatePropertyModal';
import { EditPropertyValueModal } from './EditPropertyValueModal';
import { SelectPropertyModal } from './SelectPropertyModal';
export const Modals: Component = () => {
- const blockId = useBlockId();
const {
entityType,
onPropertyAdded,
properties,
onRefresh,
+ saveHandler,
propertySelectorModal,
propertyEditorModal,
datePickerModal,
@@ -38,22 +36,12 @@ export const Modals: Component = () => {
};
const handleDateSaved = async (newDate: Date, property: Property) => {
- const result = await saveEntityProperty(blockId, entityType, property, {
- valueType: 'DATE',
- value: newDate.toISOString(),
- });
-
- if (
- !handlePropertyError(
- result,
- ERROR_MESSAGES.PROPERTY_SAVE,
- 'Modals.handleDateSaved'
- )
- ) {
- return;
+ try {
+ await saveHandler.saveDate(property, newDate);
+ onRefresh();
+ } catch (error) {
+ console.error('Failed to save date property:', error);
}
-
- onRefresh();
closeDatePicker();
};
@@ -96,14 +84,14 @@ export const Modals: Component = () => {
const anchor = state().anchor;
return anchor ? (
- <Portal>
+ <ScopedPortal scope="local">
<DatePicker
value={dateValue}
onChange={(newDate) => handleDateSaved(newDate, property)}
onClose={closeDatePicker}
anchorRef={anchor}
/>
- </Portal>
+ </ScopedPortal>
) : null;
}}
</Show>
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.tsx
index e43bf6a946..66ce198eae 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,4 +1,4 @@
-import { useBlockId } from '@core/block';
+import { useMaybeBlockId } from '@core/block';
import { useChannelsContext } from '@core/component/ChannelsProvider';
import { EntityIcon } from '@core/component/EntityIcon';
import { UserIcon } from '@core/component/UserIcon';
@@ -209,7 +209,7 @@ export function PropertyEntitySelector(props: EntityInputProps) {
let searchInputRef!: HTMLInputElement;
// Get current entity context for self-filtering
- const blockId = useBlockId();
+ const blockId = useMaybeBlockId();
const { entityType: currentEntityType } = usePropertiesContext();
const history = useHistory();
@@ -349,8 +349,10 @@ export function PropertyEntitySelector(props: EntityInputProps) {
const MAX_SEARCH_RESULTS = 20;
// Filter out the current entity when selecting same entity type (e.g., parent task on a task)
- const excludeFilter = (e: CombinedEntity) =>
- !(getEntityType(e) === currentEntityType && e.id === blockId);
+ const excludeFilter = blockId
+ ? (e: CombinedEntity) =>
+ !(getEntityType(e) === currentEntityType && e.id === blockId)
+ : () => true;
// Get visible entities based on search
const localResults = term
diff --git a/js/app/packages/core/component/Properties/component/panel/PropertyGrid.tsx b/js/app/packages/core/component/Properties/component/panel/PropertyGrid.tsx
index 5e0d3cc2ef..308c6275e0 100644
--- a/js/app/packages/core/component/Properties/component/panel/PropertyGrid.tsx
+++ b/js/app/packages/core/component/Properties/component/panel/PropertyGrid.tsx
@@ -86,6 +86,8 @@ export const PropertyGrid: Component<PropertiesListProps> = (props) => {
<PropertyRow
property={property}
onValueClick={handleValueClick}
+ withDelete
+ withPin
/>
)}
</For>
@@ -103,6 +105,8 @@ export const PropertyGrid: Component<PropertiesListProps> = (props) => {
<PropertyRow
property={property}
onValueClick={handleValueClick}
+ withDelete
+ withPin
/>
)}
</For>
@@ -120,6 +124,8 @@ export const PropertyGrid: Component<PropertiesListProps> = (props) => {
<PropertyRow
property={property}
onValueClick={handleValueClick}
+ withDelete
+ withPin
/>
)}
</For>
diff --git a/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx b/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx
index 2efdea62d7..fcb8e30e0d 100644
--- a/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx
+++ b/js/app/packages/core/component/Properties/component/panel/PropertyLabel.tsx
@@ -1,4 +1,4 @@
-import { useBlockAliasedName } from '@core/block';
+import { useMaybeBlockAliasedName } from '@core/block';
import { IconButton } from '@core/component/IconButton';
import DeleteIcon from '@icon/bold/x-bold.svg';
import PinIcon from '@icon/regular/push-pin.svg';
@@ -17,6 +17,8 @@ import { PropertyDataTypeIcon } from '../../utils';
type PropertyLabelProps = {
property: Property;
+ withPin?: boolean;
+ withDelete?: boolean;
};
export const PropertyLabel: Component<PropertyLabelProps> = (props) => {
@@ -28,13 +30,17 @@ export const PropertyLabel: Component<PropertyLabelProps> = (props) => {
onPropertyUnpinned,
pinnedPropertyIds,
} = usePropertiesContext();
- const blockName = useBlockAliasedName();
- const isBuiltin = getBuiltinPropertyIds(blockName).includes(
- props.property.propertyDefinitionId
- );
- const isDefaultPinned = getDefaultPinnedProperties(blockName).includes(
- props.property.propertyDefinitionId
- );
+ const blockName = useMaybeBlockAliasedName();
+ const isBuiltin =
+ blockName &&
+ getBuiltinPropertyIds(blockName).includes(
+ props.property.propertyDefinitionId
+ );
+ const isDefaultPinned =
+ blockName &&
+ getDefaultPinnedProperties(blockName).includes(
+ props.property.propertyDefinitionId
+ );
const isPinned = createMemo(
() => pinnedPropertyIds?.()?.includes(props.property.propertyId) ?? false
@@ -94,7 +100,12 @@ export const PropertyLabel: Component<PropertyLabelProps> = (props) => {
fallback={<div class="w-3 h-3 flex-shrink-0" />}
>
<Show
- when={onPropertyPinned && onPropertyUnpinned && !isDefaultPinned}
+ when={
+ onPropertyPinned &&
+ onPropertyUnpinned &&
+ !isDefaultPinned &&
+ props.withPin
+ }
>
<div
class={`flex-shrink-0 transition-opacity ${
@@ -113,7 +124,7 @@ export const PropertyLabel: Component<PropertyLabelProps> = (props) => {
</div>
</Show>
- <Show when={!isBuiltin}>
+ <Show when={!isBuiltin && props.withDelete}>
<div
class={`flex-shrink-0 transition-opacity ${
isHovered() ? 'opacity-100' : 'opacity-0'
diff --git a/js/app/packages/core/component/Properties/component/panel/PropertyRow.tsx b/js/app/packages/core/component/Properties/component/panel/PropertyRow.tsx
index f61b4cd1ee..b297c18447 100644
--- a/js/app/packages/core/component/Properties/component/panel/PropertyRow.tsx
+++ b/js/app/packages/core/component/Properties/component/panel/PropertyRow.tsx
@@ -6,13 +6,19 @@ import { PropertyLabel } from './PropertyLabel';
interface PropertyRowProps {
property: Property;
onValueClick: (property: Property, anchor?: HTMLElement) => void;
+ withDelete?: boolean;
+ withPin?: boolean;
}
export const PropertyRow: Component<PropertyRowProps> = (props) => {
return (
<>
<div class="flex items-start min-w-0">
- <PropertyLabel property={props.property} />
+ <PropertyLabel
+ property={props.property}
+ withDelete={props.withDelete}
+ withPin={props.withPin}
+ />
</div>
<div class="flex items-start min-w-0">
<PropertyValue property={props.property} onEdit={props.onValueClick} />
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/BooleanValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/BooleanValue.tsx
index aa9680cbba..b1bee5d45c 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/BooleanValue.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/BooleanValue.tsx
@@ -19,7 +19,6 @@ type BooleanValueProps = {
export const BooleanValue: Component<BooleanValueProps> = (props) => {
const { value, isSaving, toggle } = useBooleanEditor(
props.property as Property & { valueType: 'BOOLEAN' },
- props.entityType,
props.onRefresh
);
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/EntityValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/EntityValue.tsx
index 2e7cba03d7..e58be40a0c 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/EntityValue.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/EntityValue.tsx
@@ -1,9 +1,8 @@
-import { useBlockId } from '@core/block';
import type { EntityReference } from '@service-properties/generated/schemas/entityReference';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
import type { Component } from 'solid-js';
import { createSignal, For, Show } from 'solid-js';
-import { saveEntityProperty } from '../../api';
+import { usePropertiesContext } from '../../context/PropertiesContext';
import type { Property } from '../../types';
import { getEntityValues } from '../../utils';
import { ERROR_MESSAGES, handlePropertyError } from '../../utils/errorHandling';
@@ -23,7 +22,7 @@ type EntityValueProps = {
* Shows entity badges and opens modal on click
*/
export const EntityValue: Component<EntityValueProps> = (props) => {
- const blockId = useBlockId();
+ const { saveHandler } = usePropertiesContext();
const [isSaving, setIsSaving] = createSignal(false);
const handleEditClick = (e: MouseEvent) => {
@@ -45,15 +44,10 @@ export const EntityValue: Component<EntityValueProps> = (props) => {
entity.entity_type !== entityToRemove.entity_type
);
- const result = await saveEntityProperty(
- blockId,
- props.entityType,
- props.property,
- {
- valueType: 'ENTITY',
- refs: newValues.length > 0 ? newValues : null,
- }
- );
+ const result = await saveHandler.saveProperty(props.property, {
+ valueType: 'ENTITY',
+ refs: newValues.length > 0 ? newValues : null,
+ });
if (
handlePropertyError(
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/LinkValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/LinkValue.tsx
index 5d921e8ef5..bf9477b902 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/LinkValue.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/LinkValue.tsx
@@ -1,4 +1,3 @@
-import { useBlockId } from '@core/block';
import { IconButton } from '@core/component/IconButton';
import { useUnfurl } from '@core/signal/unfurl';
import DeleteIcon from '@icon/bold/x-bold.svg';
@@ -8,7 +7,7 @@ import { proxyResource } from '@service-unfurl/client';
import type { Component } from 'solid-js';
import { createSignal, For, Show } from 'solid-js';
import { createStore } from 'solid-js/store';
-import { saveEntityProperty } from '../../api';
+import { usePropertiesContext } from '../../context/PropertiesContext';
import type { Property } from '../../types';
import {
extractDomain,
@@ -27,7 +26,7 @@ type LinkValueProps = {
};
export const LinkValue: Component<LinkValueProps> = (props) => {
- const blockId = useBlockId();
+ const { saveHandler } = usePropertiesContext();
const [isAdding, setIsAdding] = createSignal(false);
const [inputValue, setInputValue] = createSignal('');
const [error, setError] = createSignal<string | null>(null);
@@ -80,15 +79,10 @@ export const LinkValue: Component<LinkValueProps> = (props) => {
newValues = [normalized];
}
- const result = await saveEntityProperty(
- blockId,
- props.entityType,
- props.property,
- {
- valueType: 'LINK',
- values: newValues,
- }
- );
+ const result = await saveHandler.saveProperty(props.property, {
+ valueType: 'LINK',
+ values: newValues,
+ });
if (result.ok) {
cancelAdding();
@@ -111,15 +105,10 @@ export const LinkValue: Component<LinkValueProps> = (props) => {
try {
const newValues = linkValues.filter((link: string) => link !== url);
- const result = await saveEntityProperty(
- blockId,
- props.entityType,
- props.property,
- {
- valueType: 'LINK',
- values: newValues.length > 0 ? newValues : null,
- }
- );
+ const result = await saveHandler.saveProperty(props.property, {
+ valueType: 'LINK',
+ values: newValues.length > 0 ? newValues : null,
+ });
if (result.ok) {
props.onRefresh?.();
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/NumberValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/NumberValue.tsx
index 6d8835f5ec..da7f49e9c8 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/NumberValue.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/NumberValue.tsx
@@ -18,11 +18,7 @@ type NumberValueProps = {
* Numbers are formatted to 4 decimal places
*/
export const NumberValue: Component<NumberValueProps> = (props) => {
- const editor = useInlineEditor(
- props.property,
- props.entityType,
- props.onRefresh
- );
+ const editor = useInlineEditor(props.property, props.onRefresh);
const supportsInline = () =>
props.canEdit &&
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/SelectValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/SelectValue.tsx
index 5bb8d80ae5..abb0d4c1cb 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/SelectValue.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/SelectValue.tsx
@@ -1,10 +1,9 @@
-import { useBlockId } from '@core/block';
import { IconButton } from '@core/component/IconButton';
import DeleteIcon from '@icon/bold/x-bold.svg';
import type { EntityType } from '@service-properties/generated/schemas/entityType';
import type { Component } from 'solid-js';
import { createSignal, For, Show } from 'solid-js';
-import { saveEntityProperty } from '../../api';
+import { usePropertiesContext } from '../../context/PropertiesContext';
import { PROPERTY_STYLES } from '../../styles/styles';
import type { Property } from '../../types';
import { formatPropertyValue, getSelectValues } from '../../utils';
@@ -24,7 +23,7 @@ type SelectValueProps = {
* Opens options modal on click
*/
export const SelectValue: Component<SelectValueProps> = (props) => {
- const blockId = useBlockId();
+ const { saveHandler } = usePropertiesContext();
const [hoveredValue, setHoveredValue] = createSignal<string | null>(null);
const [isSaving, setIsSaving] = createSignal(false);
@@ -48,15 +47,10 @@ export const SelectValue: Component<SelectValueProps> = (props) => {
return;
}
- const result = await saveEntityProperty(
- blockId,
- props.entityType,
- props.property,
- {
- valueType,
- values: newValues.length > 0 ? newValues : null,
- }
- );
+ const result = await saveHandler.saveProperty(props.property, {
+ valueType,
+ values: newValues.length > 0 ? newValues : null,
+ });
if (
handlePropertyError(
diff --git a/js/app/packages/core/component/Properties/component/propertyValue/TextValue.tsx b/js/app/packages/core/component/Properties/component/propertyValue/TextValue.tsx
index 597012d11a..92f54e41bd 100644
--- a/js/app/packages/core/component/Properties/component/propertyValue/TextValue.tsx
+++ b/js/app/packages/core/component/Properties/component/propertyValue/TextValue.tsx
@@ -17,11 +17,7 @@ type TextValueProps = {
* Display component for string properties with inline editing
*/
export const TextValue: Component<TextValueProps> = (props) => {
- const editor = useInlineEditor(
- props.property,
- props.entityType,
- props.onRefresh
- );
+ const editor = useInlineEditor(props.property, props.onRefresh);
const supportsInline = () =>
props.canEdit &&
diff --git a/js/app/packages/core/component/Properties/context/PropertiesContext.tsx b/js/app/packages/core/component/Properties/context/PropertiesContext.tsx
index 6bec73471d..ed7ebe319b 100644
--- a/js/app/packages/core/component/Properties/context/PropertiesContext.tsx
+++ b/js/app/packages/core/component/Properties/context/PropertiesContext.tsx
@@ -7,7 +7,7 @@ import {
type ParentProps,
useContext,
} from 'solid-js';
-import type { Property } from '../types';
+import type { Property, PropertyApiValues, Result } from '../types';
// Specific modal state types with proper typing
export interface PropertySelectorModalState {
@@ -28,6 +28,14 @@ export interface CreatePropertyModalState {
isOpen: boolean;
}
+export interface PropertySaveHandler {
+ saveProperty: (
+ property: Property,
+ value: PropertyApiValues
+ ) => Promise<Result<void>>;
+ saveDate: (property: Property, date: Date) => Promise<Result<void>>;
+}
+
export interface PropertiesContextValue {
entityType: EntityType;
canEdit: boolean;
@@ -39,6 +47,7 @@ export interface PropertiesContextValue {
onPropertyPinned?: (propertyId: string) => void;
onPropertyUnpinned?: (propertyId: string) => void;
pinnedPropertyIds?: () => string[];
+ saveHandler: PropertySaveHandler;
// Specific modal state accessors
propertySelectorModal: Accessor<PropertySelectorModalState | null>;
@@ -77,6 +86,7 @@ export interface PropertiesProviderProps extends ParentProps {
onPropertyPinned?: (propertyId: string) => void;
onPropertyUnpinned?: (propertyId: string) => void;
pinnedPropertyIds?: () => string[];
+ saveHandler: PropertySaveHandler;
}
const PropertiesContext = createContext<PropertiesContextValue>();
@@ -181,6 +191,7 @@ export function PropertiesProvider(props: PropertiesProviderProps) {
onPropertyPinned: props.onPropertyPinned,
onPropertyUnpinned: props.onPropertyUnpinned,
pinnedPropertyIds: props.pinnedPropertyIds,
+ saveHandler: props.saveHandler,
// Specific modal state
propertySelectorModal,
propertyEditorModal,
diff --git a/js/app/packages/core/component/Properties/hooks/useBooleanEditor.ts b/js/app/packages/core/component/Properties/hooks/useBooleanEditor.ts
index a8183301cf..269bd351af 100644
--- a/js/app/packages/core/component/Properties/hooks/useBooleanEditor.ts
+++ b/js/app/packages/core/component/Properties/hooks/useBooleanEditor.ts
@@ -1,7 +1,5 @@
-import { useBlockId } from '@core/block';
-import type { EntityType } from '@service-properties/generated/schemas/entityType';
import { type Accessor, createMemo, createSignal } from 'solid-js';
-import { saveEntityProperty } from '../api';
+import { usePropertiesContext } from '../context/PropertiesContext';
import type { Property } from '../types';
import { ERROR_MESSAGES, handlePropertyError } from '../utils/errorHandling';
@@ -14,14 +12,13 @@ import { ERROR_MESSAGES, handlePropertyError } from '../utils/errorHandling';
*/
export function useBooleanEditor(
property: Property & { valueType: 'BOOLEAN' },
- entityType: EntityType,
onSaved?: () => void
): {
value: Accessor<boolean | null>;
isSaving: Accessor<boolean>;
toggle: () => Promise<void>;
} {
- const blockId = useBlockId();
+ const { saveHandler } = usePropertiesContext();
const [isSaving, setIsSaving] = createSignal(false);
const currentValue = createMemo(() => {
@@ -40,7 +37,7 @@ export function useBooleanEditor(
// Otherwise toggle between true and false
const newValue = actualValue === null ? true : !actualValue;
- const result = await saveEntityProperty(blockId, entityType, property, {
+ const result = await saveHandler.saveProperty(property, {
valueType: 'BOOLEAN',
value: newValue,
});
diff --git a/js/app/packages/core/component/Properties/hooks/useInlineEditor.ts b/js/app/packages/core/component/Properties/hooks/useInlineEditor.ts
index f1acc32117..82b558e551 100644
--- a/js/app/packages/core/component/Properties/hooks/useInlineEditor.ts
+++ b/js/app/packages/core/component/Properties/hooks/useInlineEditor.ts
@@ -1,8 +1,6 @@
-import { useBlockId } from '@core/block';
-import type { EntityType } from '@service-properties/generated/schemas/entityType';
import { type Accessor, createSignal, type Setter } from 'solid-js';
-import { saveEntityProperty } from '../api';
import { NUMBER_DECIMAL_PLACES } from '../constants';
+import { usePropertiesContext } from '../context/PropertiesContext';
import type { Property, PropertyApiValues } from '../types';
import { formatPropertyValue } from '../utils';
import { ERROR_MESSAGES, handlePropertyError } from '../utils/errorHandling';
@@ -16,7 +14,6 @@ import { ERROR_MESSAGES, handlePropertyError } from '../utils/errorHandling';
*/
export function useInlineEditor(
property: Property,
- entityType: EntityType,
onSaved?: () => void
): {
isEditing: Accessor<boolean>;
@@ -27,8 +24,7 @@ export function useInlineEditor(
cancelEdit: () => void;
save: () => Promise<void>;
} {
- const blockId = useBlockId();
-
+ const { saveHandler } = usePropertiesContext();
const [isEditing, setIsEditing] = createSignal(false);
const [inputValue, setInputValue] = createSignal('');
const [isSaving, setIsSaving] = createSignal(false);
@@ -86,12 +82,7 @@ export function useInlineEditor(
throw new Error(`Unsupported property type: ${property.valueType}`);
}
- const result = await saveEntityProperty(
- blockId,
- entityType,
- property,
- apiValues
- );
+ const result = await saveHandler.saveProperty(property, apiValues);
if (
handlePropertyError(
diff --git a/js/app/packages/core/component/Toast/Toast.tsx b/js/app/packages/core/component/Toast/Toast.tsx
index 445f89c9c3..325fe3dfda 100644
--- a/js/app/packages/core/component/Toast/Toast.tsx
+++ b/js/app/packages/core/component/Toast/Toast.tsx
@@ -290,6 +290,36 @@ function createToast(
);
}
+function embed(
+ component: Component,
+ options?: {
+ persistent?: boolean;
+ duration?: number;
+ region?: string;
+ }
+) {
+ return toaster.show(
+ (props) => (
+ <Toast
+ toastId={props.toastId}
+ class="flex flex-col items-center justify-between gap-2 border rounded-md p-3 pointer-events-auto border-edge-muted bg-panel relative
+ ui-opened:animate-slide-in ui-closed:animate-hide transition-transform ui-swipe-move:translate-x-[var(--kb-toast-swipe-move-x)]
+ ui-swipe-cancel:translate-x-0 ui-swipe-cancel:ease-out ui-swipe-cancel:duration-200 ui-swipe-end:animate-swipe-out"
+ duration={options?.duration}
+ persistent={options?.persistent}
+ >
+ <div class="size-full">
+ <Dynamic component={component} />
+ </div>
+ <Toast.CloseButton class="ml-auto absolute top-2 right-2 z-1">
+ <XIcon class="h-5 ml-4 text-gray-500" />
+ </Toast.CloseButton>
+ </Toast>
+ ),
+ { region: options?.region || 'toast-region' }
+ );
+}
+
export function createUploadToast(message: string) {
return toaster.show(
(props) => (
@@ -320,4 +350,5 @@ export const toast = {
failure,
alert,
promise,
+ embed,
};