Line

ui/client/features/pages-editor/hooks/usePaletteWrap

Cockpit client (features), v0.9. Source: ui/client/features/pages-editor/hooks/usePaletteWrap.tsx.

Functions#

usePaletteWrap()#

usePaletteWrap(feature, file, contentHash, selectedNodeId, onWrapped, onExpressionCreated): object

Defined in: ui/client/features/pages-editor/hooks/usePaletteWrap.tsx:14

#533 (Slice 3 of #518's design) -- "Wrap with...": follows the current JSX selection (nodeId, the same selection every other Pages editor tab already uses), asks the server what it suggests (a flagged hit, fit-checked Expressions, a real dry-run preview once a name is available), and turns "Approve" into the real, non-dry-run extraction. Two calls only, mirroring #527/#532's own read/write split: GET wrap-suggest (never writes) and POST wrap (only reached from Approve).

Parameters#

feature

string

file

string

contentHash

string

selectedNodeId

string | null

onWrapped

(tree) => void

onExpressionCreated

() => void

Returns#

cancelPreview

cancelPreview: () => void

Cancel — drop the preview, keep the suggestion (hit/suggestions/name) so it can be edited again.

Returns

void

confirm

confirm: () => Promise<void>

"Approve" — the only call in this whole flow that writes anything.

Returns

Promise<void>

confirming

confirming: boolean

loading

loading: boolean

name

name: string

preview

preview: () => Promise<void>

"Wrap with..." — fetches the real dry-run preview for the current name (derived, or typed).

Returns

Promise<void>

setName

setName: Dispatch<SetStateAction<string>>

status

status: StatusMessage | null

suggestion

suggestion: WrapSuggestion | null