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

@cpelements/pfe-navigation-account

v1.0.36

Published

Navigation account element for PatternFly Elements

Downloads

117

Readme

PatternFly Element | Navigation account element

This is a companion component with pfe-navigation, it creates an account dropdown with appropriate content based on a user's roles and permissions.

Usage

This component should be a direct child of pfe-navigation, and should have the attribute slot="account"

<pfe-navigation-account slot="account"></pfe-navigation-account>

If it should be in logged out state:

  • login-link should be set to a valid login URL

If it should be in a logged in state:

  • logout-link should be set to a valid logout URL
  • The component should be provided the information from the JWT via one of these methods:
    • Using the userData setter: Provide the JSON object from the JWT to the setter. Make a reference to the DOM object and set .userData, e.g.:
      document.querySelector('pfe-navigation-account').userData = howeverYouGetTheJWT('make it so');
    • @todo via chapeaux and keycloack.js

Tip: Don't add the login-link attribute until the auth state of the user is known, this will prevent a login link from flashing while the user's status is being figured out.

UserData Object

The userData method expects an object that at minimum should have:

{
      realm_access: {
        roles: []
      },
      REDHAT_LOGIN: "[email protected]",
      lastName: "Ruvalcaba",
      account_number: "123456",
      preferred_username: "[email protected]",
      firstName: "Wes",
      email: "[email protected]",
      username: "[email protected]",
      fullName: "Wes Ruvalcaba"
}

realm_access.roles is checked for two roles:

  • admin:org:all
  • portal_manage_subscriptions

If the user has these roles they should be present in the array, if not they can be left out.

@todo: update to ask users to file an issue in the repository For any questions or help, contact the CPFED group.

Attributes

  • login-link: Link to login user, required for anonymous users non-keycloack implementations will be put directly into an <a> tag.
  • logout-link: Link to logout user, required for logged in users non-keycloack implementations will be put directly into an <a> tag.
  • avatar-url: Provided by the component, used by pfe-navigation
  • full-name: Provided by the component, used by pfe-navigation

Events

  • pfe-shadow-dom-event: Fires when an element is clicked inside of a dropdown in the shadow root. This is for analytics to properly categorize and report the event. event.detail has:
    • target Element clicked
    • parent the pfe-navigation element

Dependencies

Is meant to be used inside of pfe-navigation as optional functionality.

Dev

`npm start`

Test

`npm run test`

Build

`npm run build`

Demo

From the PFElements root directory, run:

`npm run demo`

Code style

Navigation-account (and all PFElements) use Prettier to auto-format JS and JSON. The style rules get applied when you commit a change. If you choose to, you can integrate your editor with Prettier to have the style rules applied on every save.