npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ut-portal

v9.6.79

Published

Microservice portal

Downloads

362

Readme

Microservice portal

Create portals in a modular way

Project links

Usage

Include ut-portal in your browser build INSTEAD of ut-front-react:

// usually this is in browser/index.js or portal/index.js
module.exports = (...params) => [
    require('ut-portal')(...params),
    // other modules
]

API

  • handle.tab.show({tab, params}) - Shows a new tab
  • portal.menu.item(definition) or portal.menu.item({component, id , title}) - Define a menu item, which when clicked opens a page.
    • definition - Component definition function
    • component - React component function
    • id - Passed as the id property to the component function
    • title - Title of the menu

Portal menu

To provide configuration for the portal, include it in a portal configuration module after ut-portal:

module.exports = (...params) => [
    // other modules,
    require('ut-portal')(...params),
    require('ut-portal-hello')(...params)
]

Then in ut-portal-hello, create a browser layer that returns handlers.

// browser.js
module.exports = () => function utPortalHello() {
    return {
        browser: () => [
            require('./portal.params.get')
        ]
    };
};

Implement a portal.params.get handler function named portal. The handler can reference components from other modules by using one of the destructuring syntaxes:

  • import:{component$subjectObjectPredicate}
  • import:{'component/x.y.z': componentXyz}

Then these components can be attached to the portal menu items:

// portal.params.get.js
const classes = require('./admin.css');

module.exports = function portal({
    import: {
        component$microserviceFooNew,
        component$microserviceFooBrowse,
        component$microserviceFooOpen,
        portalMenuItem
    }
}) {
    return {
        async 'portal.params.get'() {
            return {
                // return the theme parameters
                theme: {
                    ut: {
                        classes
                    }
                },
                // return the portal name
                portalName: 'Hello Portal',
                // return the portal menu
                menu: [{
                    title: 'Hello Menu',
                    items: [
                        await portalMenuItem(component$microserviceFooNew),
                        await portalMenuItem(component$microserviceFooBrowse),
                        await portalMenuItem({
                            component: component$microserviceFooOpen,
                            id: 1,
                            title: 'Open Foo 1'
                        })
                    ]
                }]
            };
        }
    };
};

Portal pages

Portal pages open as tabs in the UI. Portal pages are usually defined in dedicated files with the standard structure for defining handlers. The handler function should return an object, as shown below:

// @ts-check
import React from 'react';

/** @type { import("../../handlers").handlerFactory } */
export default ({
    import: {
    }
}) => ({
    'subject.object.predicate': () => ({
        title: 'Page title',
        permission: 'some.permission.id',
        component:() => function ComponentName {
            return (
                <div>Page content</div>
            );
        }

    })
});