Skip to end of banner
Go to start of banner

Registry

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

As per the vocabulary, the Registry is designed as a storage place for apps outside of ui-dashboard to register resources. These will then become available to dashboard for the purposes of dynamic interactions between different frontend apps.

Here "Resource" is used to mean an object managed by a particular frontend app. For example ui-agreements manages "agreement", "agreementLine", "platform" resources, amongst others.

One particular example of this can be seen in the ability for SimpleSearch widget form to use an existing "lookup component" for a particular resource. In the figure below, an Agreement widget may allow the user to filter by "Linked license". This is a resource managed by ui-licenses, so here ui-licenses is registering a resource called a "license", alongside information for how to render a lookup component for that resource.

The dashboard then consumes that resource entry and renders its lookup component dynamically.

An agreement widget filter making use of a license lookup component

Implementation Code

The registering of resources with the registry is done through stripes eventHandler system.

static eventHandler(event, _s, data) {
  if (event === 'ui-dashboard-registry-load') {
    // Data should contain Registry singleton:
    setUpRegistry(data);
    return null;
  }
  return null;
}

Here the index.js file in ui-licenses consumes the event 'ui-dashboard-registry-load', and then triggers a function which sets up the license resource within the registry:

const setUpRegistry = (registry) => {
  // License Resource
  const licenseReg = registry.registerResource('license');
  licenseReg.addViewAll('/licenses');
  licenseReg.addViewTemplate(license => `/licenses/${license.id}`);

  // Lookup plugin
  licenseReg.addLookupComponent(LicenseLookup);
};

In this example LicenseLookup is the component which is rendered in the agreement widget configuration form above.


Since the registry is a singleton, all registered entries will be available to ui-dashboard when it needs to consume them, and Registry as an object contains several methods to allow modules to interact with it.


Information on how stripes eventing works can be found here: https://github.com/folio-org/stripes/blob/master/doc/dev-guide.md#handlers-and-events

Not mentioned in that document are the necessary additions to the package.json of an implementing module:

"actsAs": [
  "app",
  "handler",
  "settings"
],
"handlerName": "eventHandler",


Registry API

  • No labels