uPortal-web-components

Portlet Registry to Array

NPM Version Maven Central Build Status

A utility that flattens the portlet registry tree into an array

Installation

# install with npm
npm install @uportal/portlet-registry-to-array

# install with yarn
yarn add @uportal/portlet-registry-to-array

install with maven

<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>uportal__portlet-registry-to-array</artifactId>
    <version>{version number goes here}</version>
</dependency>

install with gradle

compile 'org.webjars.npm:uportal__portlet-registry-to-array:{version number goes here}'

Usage

import { portletRegistryToArray } from '@uportal/portlet-registry-to-array';

// In production this would come over the network
const exampleRegistry = {
  registry: {
    categories: [
      {
        name: 'All categories',
        description: 'All channel categories',
        id: 'local.1',
        portlets: [
          {
            fname: 'courses',
            keywords: [],
            averageRating: 0,
            name: 'Courses',
            description: 'Course links and announcements.',
            ratingsCount: 0,
            typeId: 8,
            id: 52,
            state: 'PUBLISHED',
            title: 'Courses',
            parameters: {
              mobileIconUrl: {
                name: 'mobileIconUrl',
                description: '',
                value: '/uPortal/media/skins/icons/mobile/courses_alt.png',
              },
              iconUrl: {
                name: 'iconUrl',
                description: '',
                value:
                  '/ResourceServingWebapp/rs/tango/0.8.90/32x32/apps/accessories-text-editor.png',
              },
              configurable: {
                name: 'configurable',
                description: '',
                value: 'true',
              },
            },
          },
        ],
        subcategories: [],
      },
    ],
  },
};

const portletList = portletRegistryToArray(exampleRegistry);
console.log(portletList);