Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { memo, useCallback, useMemo } from 'react';
import { useSafeLingui } from '../../../i18n';
import { useOptionalNodeTypeRegistry } from '../../core';
import { usePreviewNode } from '../../hooks';
import { type ListItem, Toolbox } from '../Toolbox';
Expand All @@ -21,7 +22,9 @@ export const AddNodePanel = memo(function AddNodePanel({
title,
loading,
renderEmptyState,
searchPlaceholder,
}: AddNodePanelProps) {
const { _ } = useSafeLingui();
const registry = useOptionalNodeTypeRegistry();
const { previewNodeConnectionInfo } = usePreviewNode();

Expand Down Expand Up @@ -87,6 +90,9 @@ export const AddNodePanel = memo(function AddNodePanel({
onClose={onClose}
onItemHover={onNodeHover}
renderEmptyState={renderEmptyState}
searchPlaceholder={
searchPlaceholder ?? _({ id: 'addNodePanel.searchNodes', message: 'Search nodes' })
}
/>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ export interface AddNodePanelProps {
* When provided, replaces the built-in icon + message empty state.
*/
renderEmptyState?: ToolboxEmptyStateRenderer<NodeItemData>;
/**
* Placeholder for the search input. Should describe what will be searched,
* such as "Search agents". Defaults to "Search nodes".
*/
searchPlaceholder?: string;
}
13 changes: 11 additions & 2 deletions packages/apollo-react/src/canvas/components/Toolbox/Toolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export interface ToolboxProps<T> {
onItemHover?: (item: ListItem<T>) => void;
onBack?: () => void;
onSearch?: ToolboxSearchHandler<T>;
/**
* Placeholder for the search input. Should describe what will be searched,
* such as "Search nodes". Defaults to a generic "Search".
*/
searchPlaceholder?: string;
/**
* Optional row of icon shortcuts rendered above the title. Apollo controls
* the visuals so the strip stays consistent across consumers; pass the
Expand Down Expand Up @@ -155,9 +160,10 @@ export function Toolbox<T>({
fullHeight = false,
quickActions,
renderEmptyState,
searchPlaceholder: searchPlaceholderProp,
}: ToolboxProps<T>) {
const { _ } = useSafeLingui();
const searchPlaceholder = _({ id: 'toolbox.search', message: 'Search' });
const searchPlaceholder = searchPlaceholderProp ?? _({ id: 'toolbox.search', message: 'Search' });
const [items, setItems] = useState<ListItem<T>[]>(initialItems);
const [search, setSearch] = useState('');
const [searchLoading, setSearchLoading] = useState(false);
Expand Down Expand Up @@ -203,7 +209,10 @@ export function Toolbox<T>({
const wrappedRenderEmptyState = useMemo(
() =>
renderEmptyState && !isSearching
? () => renderEmptyState({ currentCategory: currentParentItem ?? undefined })
? () =>
renderEmptyState({
currentCategory: currentParentItem ?? undefined,
})
: undefined,
[renderEmptyState, isSearching, currentParentItem]
);
Expand Down
1 change: 1 addition & 0 deletions packages/apollo-react/src/canvas/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"sticky-note.toolbar.color": "Color",
"sticky-note.toolbar.delete": "Delete",
"sticky-note.toolbar.edit": "Edit",
"addNodePanel.searchNodes": "Search nodes",
"toolbox.search": "Search",
"loop-node.add-node": "Add node to loop",
"loop-node.mode.parallel": "Parallel",
Expand Down
Loading