Skip to main content

DynamicPanel API

The dynamicPanel module of the @codebolt/plugin-sdk.

import plugin from '@codebolt/plugin-sdk';

Quick Reference

MethodDescription
closeCloses a DynamicPanel and removes it from the UI.
listLists all currently active DynamicPanels.
offMessageRemoves the message handler for a specific panel.
onMessageRegisters a handler for messages coming from a specific panel's iframe.
openOpens a new DynamicPanel with the given HTML content.
sendPushes arbitrary data into the panel's iframe via postMessage.
updateReplaces the HTML content of an existing DynamicPanel.

Methods


close

plugin.dynamicPanel.close(panelId: string): Promise<DynamicPanelResponse>

Closes a DynamicPanel and removes it from the UI.

ParameterTypeRequiredDescription
panelIdstringYesThe panel to close

Returns: Promise<DynamicPanelResponse>

Full reference →


list

plugin.dynamicPanel.list(): Promise<DynamicPanelListResponse>

Lists all currently active DynamicPanels.

No parameters.

Returns: Promise<DynamicPanelListResponse>

Full reference →


offMessage

plugin.dynamicPanel.offMessage(panelId: string): void

Removes the message handler for a specific panel.

ParameterTypeRequiredDescription
panelIdstringYesThe panel to stop listening to

Returns: void

Full reference →


onMessage

plugin.dynamicPanel.onMessage(panelId: string, handler: Function): void

Registers a handler for messages coming from a specific panel's iframe. The iframe sends messages via window.parent.postMessage({ type: '...', data: {...} }, '*').

Only one handler per panelId is supported. Calling this again for the same panelId replaces the previous handler.

ParameterTypeRequiredDescription
panelIdstringYesThe panel to listen to
handlerFunctionYesCallback receiving the message data

Returns: void

Full reference →


open

plugin.dynamicPanel.open(panelId: string, title: string, html: string, opts?: DynamicPanelOpenOptions): Promise<DynamicPanelOpenResponse>

Opens a new DynamicPanel with the given HTML content.

When opts.waitForResponse is true the call blocks until the panel iframe sends a { type: 'submit', data: {...} } message via window.parent.postMessage(). The resolved value then contains the submitted data.

ParameterTypeRequiredDescription
panelIdstringYesUnique identifier for the panel
titlestringYesHuman-readable panel title shown in the tab
htmlstringYesFull HTML document rendered inside the panel iframe
optsDynamicPanelOpenOptionsNoOptional: waitForResponse, timeout

Returns: Promise<DynamicPanelOpenResponse>

Full reference →


send

plugin.dynamicPanel.send(panelId: string, data: any): Promise<DynamicPanelResponse>

Pushes arbitrary data into the panel's iframe via postMessage. The iframe receives this in its window.addEventListener('message', ...) handler.

ParameterTypeRequiredDescription
panelIdstringYesThe target panel
dataanyYesAny JSON-serializable payload

Returns: Promise<DynamicPanelResponse>

Full reference →


update

plugin.dynamicPanel.update(panelId: string, html: string): Promise<DynamicPanelResponse>

Replaces the HTML content of an existing DynamicPanel.

ParameterTypeRequiredDescription
panelIdstringYesThe panel to update
htmlstringYesNew HTML content

Returns: Promise<DynamicPanelResponse>

Full reference →