Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

...

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

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

...

A RegistryResource is a class containing information about a particular resource of the registry. It has fields that are technically publically available, but they should only be accessed through the requisite getters and setters.

Once https://github.com/tc39/proposal-private-methods#private-methods-and-fields or equivalent become available and supported, these fields should be made private. This class contains the following methods with which to interact with it:
 

Warning

getLink/setLink are implemented, but their shape is not yet finalised in generality. It is HIGHLY recommended that these are not utilised, and any early implementors confine their use to get/set for ViewResource and ViewResources.

...

This function will return an a Javascript Map with keys that are Strings referring to a kind of link, eg "viewResource", and values that are either Strings or functions.

...

This function sets a string OR function entry on the above Map.

getLink(linkName)

This function returns the string OR function entry set on the above Map.

Note

Currently it is presumed that a string link implies a direct URL which can be followed, and a function link is to be passed one parameter, namely the resource in question. See the agreements implementation for an example.


setViewResources(link)

A function for the special case of setLink which should reflect a basic URL path for a "view all" page for the resource. In the case of agreements it would be "/erm/agreements/"

...

setViewResource(

...

link)

Sets a function field "viewAllTemplate", which should take some parameters, such as filterList, or a backend search query, and returns a URL which reflects that search in the frontend.

addViewTemplate(template)

Sets a function field, "viewTemplate" which will take an object representing the resource in question and will return a URL to find that resource in the frontend. For example agreements would take an agreement, and use its ID field to return something of the form A function for the special case of setLink which should reflect a basic URL path for a "view" page for a resource. In the case of agreements it would be "/erm/agreements/03b7f730-66fe-4bfa-9838-062e903d36fa"

getViewAll()

Returns the viewAll field above.

getViewAllTemplate()

Returns the "viewAllTemplate" field above

getViewTemplate()

Returns the "viewTemplate" field above

...

{id}".

getViewResources()

A function which fetches 'viewResources' from above.

getViewResource()

A function which fetches 'viewResource' from above.

setLookupComponent(component)

Takes in a react component and assigns it to the field "lookupComponent".

...

Warning

The methods above for templating links and customRendering custom rendering are essentially just code injection, so it is vitally important that implementers consider that their code is just going to be run within ui-dashboard, and potentially elsewhere too. The risk here is minimal, with no user defined methods, but it's still worth noting and taking care when implementing a custom render function.

...