Skip to content

hooks/useSaveLoadButtons#

useSaveLoadButtons()#

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

Returns a component with Save/Load buttons and all necessary dialogs

Type Parameters#

Type Parameter Default type
TProtocol any

Parameters#

Parameter Type
config UseSaveLoadButtonsConfig<TProtocol>

Returns#

() => Element

Example#

const SaveLoadButtons = useSaveLoadButtons({
  entityTypeSuffix: 'pages',
  methods: { save: 'save_page', load: 'load_page', list: 'list_pages' }
})

return <SaveLoadButtons />

UseSaveLoadButtonsConfig#

Extends#

  • Omit<SaveLoadConfig<TProtocol>, "pluginId" | "sendMessage" | "currentEntityName">

Type Parameters#

Type Parameter Default type
TProtocol any

Properties#

dialogTitles?#

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

Optional custom dialog titles

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

entityTypeSuffix?#

optional entityTypeSuffix?: string;

Custom entity type suffix (default: 'entities')

Inherited from#

SaveLoadConfig.entityTypeSuffix

labels?#

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

Optional custom button labels

load?#
optional load?: string;
save?#
optional save?: 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#
Omit.methods

previewComponent?#

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

Optional custom preview component

Inherited from#
Omit.previewComponent