Skip to main content

IAdminForthPlugin

Properties​

activationOrder​

activationOrder: number

Before activating all plugins are sorted by this number and then activated in order. If you want to make sure that your plugin is activated after some other plugin, set this number to higher value. (default is 0)


adminforth​

adminforth: IAdminForth


className​

className: string


customFolderName​

customFolderName: string


customFolderPath​

customFolderPath: string


pluginDir​

pluginDir: string


pluginInstanceId​

pluginInstanceId: string


pluginOptions​

pluginOptions: any


pluginsScope​

pluginsScope: "resource" | "global"


resourceConfig​

resourceConfig: AdminForthResource

Methods​

componentPath()​

componentPath(componentFile): string

Parameters​

ParameterType
componentFilestring

Returns​

string


instanceUniqueRepresentation()​

instanceUniqueRepresentation(pluginOptions): string

If plugin should support multiple installations per one resource, this function that should return unique string for each instance of plugin. For example if plugin is installed for one column and this column defined as targetColumn in plugin options, then this method should return ${pluginOptions.targetColumn}.

If plugin should support only one installation per resource, option can return 'single'

Parameters​

ParameterTypeDescription
pluginOptionsanyoptions of plugin

Returns​

string


modifyGlobalConfig()?​

optional modifyGlobalConfig(adminforth): void

This method is used for plugins, applied in global scope (pluginsScope = 'global')

Parameters​

ParameterTypeDescription
adminforthIAdminForthInstance of IAdminForth

Returns​

void


modifyResourceConfig()?​

optional modifyResourceConfig(adminforth, resourceConfig, allPluginInstances?): void

AdminForth plugins concept is based on modification of full AdminForth configuration to add some custom functionality. For example plugin might simply add custom field to resource by reusing AdminForthResourceColumn.components object, then add some hook which will modify record before getting or saving it to database.

So this method is core of AdminForth plugins. It allows to modify full resource configuration.

Parameters​

ParameterTypeDescription
adminforthIAdminForthInstance of IAdminForth
resourceConfigAdminForthResourceResource configuration object which will be modified by plugin
allPluginInstances?object[]-

Returns​

void


setupEndpoints()​

setupEndpoints(server): void

Here you can register custom endpoints for your plugin.

Parameters​

ParameterTypeDescription
serverIHttpServer-

Returns​

void


shouldHaveSingleInstancePerWholeApp()?​

optional shouldHaveSingleInstancePerWholeApp(): boolean

If this method returns true, AdminForth will allow only one instance of plugin per whole app (only for case when we are creating copy of resource and activating plugins) If false, multiple instances of plugin can be installed on different resources.

Returns​

boolean


validateConfigAfterDiscover()?​

optional validateConfigAfterDiscover(adminforth, resourceConfig): void

Optional method which will be called after AdminForth discovers all resources and their columns. Can be used to validate types of columns, check if some columns are missing, etc.

Parameters​

ParameterType
adminforthIAdminForth
resourceConfigAdminForthResource

Returns​

void