Skip to content

hooks/useEntityButtons#

useEntityButtons()#

function useEntityButtons<TProtocol>(config): () => Element;

Complete entity management buttons

Type Parameters#

Type Parameter Default type
TProtocol any

Parameters#

Parameter Type
config UseEntityButtonsConfig<TProtocol>

Returns#

() => Element

Example#

const EntityButtons = useEntityButtons<CustomPageAPI>({
  entityTypeSuffix: 'pages',
  methods: {
    save: 'save_page',
    load: 'load_page',
    list: 'list_pages',
    preview: 'preview_page'
  },
  defaultState: {
    name: 'Untitled',
    layout: '<text label="Welcome!" />',
    code: '# Start here'
  }
})

return (
  <StandardPageAppBar form={<EntityButtons />} />
)

UseEntityButtonsConfig#

useSaveLoad Hook

Provides developer-friendly save/load functionality for plugins. Automatically handles: - Entity browser registration - Save/Load dialogs - Backend communication

Extends#

Type Parameters#

Type Parameter Default type
TProtocol any

Properties#

currentEntityName?#

optional currentEntityName?: string;

Current entity name (for highlighting in entity browser)

Inherited from#

SaveLoadConfig.currentEntityName

defaultState?#

optional defaultState?: Record<string, any>;

Default state for "New" button

dialogTitles?#

optional dialogTitles?: {
  load?: string;
  saveAs?: string;
};

Custom dialog titles

load?#
optional load?: string;
saveAs?#
optional saveAs?: string;

entityTypeSuffix?#

optional entityTypeSuffix?: string;

Custom entity type suffix (default: 'entities')

Inherited from#

SaveLoadConfig.entityTypeSuffix

labels?#

optional labels?: {
  load?: string;
  new?: string;
  save?: string;
  saveAs?: string;
};

Custom button labels

load?#
optional load?: string;
new?#
optional new?: string;
save?#
optional save?: string;
saveAs?#
optional saveAs?: string;

methods?#

optional methods?: {
  list?: keyof TProtocol;
  load?: keyof TProtocol;
  preview?: keyof TProtocol;
  save?: keyof TProtocol;
};

Backend method names - type-safe against protocol interface

list?#
optional list?: keyof TProtocol;
load?#
optional load?: keyof TProtocol;
preview?#
optional preview?: keyof TProtocol;
save?#
optional save?: keyof TProtocol;
Inherited from#

SaveLoadConfig.methods

newMethod?#

optional newMethod?: keyof TProtocol;

Method to call for "New" (optional - can handle client-side)

previewComponent?#

optional previewComponent?: ComponentType<{
  entityName: string;
  previewData: any;
}>;

Optional custom preview component

Inherited from#

SaveLoadConfig.previewComponent