Broadleaf Microservices

Action Registrar

Table of Contents

The ActionRegistrar is a repository of the action components used to support actions within the metadata-driven components. This document gives an overview of how it can be used to create actions within the admin application.

Usage

The ActionRegistrar is used to store React components for metadata-driven actions. The registrar is used within various metadata-driven components to provide an extensible mechanism of adding custom action behaviors.

Action components may be retrieved for an entire view, or individually for a certain placement and type, for example:

import { services } from '@broadleaf/admin-components';
const { ActionRegistrar } = services;

// get action information for a view
const actions = ActionRegistrar.getActionComponents('View', 'ENTITY');

// each entry includes the component, and the action placement/type
const { component, placement, type } = actions[0];

// get the action component directly
const component = ActionRegistrar.getActionComponent('View', 'ENTITY', 'PRIMARY', 'CREATE');

Registering Actions

An action component can be registered with the ActionRegistrar in order to support a new metadata-driven action, or override an existing one:

import { services } from '@broadleaf/admin-components';
const { ActionRegistrar } = services;

// register a single action
ActionRegistrar.registerActionComponent('View', 'ENTITY', {
  component: MyActionComponent,
  placement: 'PRIMARY',
  type: 'MY_ACTION'
});

// register a set of actions
ActionRegistrar.registerActionComponents('View', 'ENTITY', [
  {
    component: MyActionComponent,
    placement: 'PRIMARY',
    type: 'MY_ACTION'
  },
  {
    component: MyOtherActionComponent,
    placement: 'PRIMARY',
    type: 'MY_OTHER_ACTION'
  }
]);