How to use the mson/lib/compiler/registrar.client function in mson

To help you get started, we’ve selected a few mson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github redgeoff / mson-react / src / app.js View on Github external
componentDidMount() {
    // Allows us to listen to back and forward button clicks
    this.unlisten = this.props.history.listen(this.onLocation);

    if (registrar.client) {
      // Wait for the session to load before loading the initial component so that we can do things
      // like route based on a user's role
      registrar.client.user.awaitSession();
    }

    // Load the correct component based on the initial path
    this.onLocation(this.props.location);

    // TODO: is this too inefficient in that it cascades a lot of unecessary events? Instead, could:
    // 1. move more logic to app layer so that only cascade when need new window 2. use something
    // like a global scroll listener that the component can use when it is active
    window.addEventListener('scroll', e => {
      if (this.state.menuItem) {
        this.state.menuItem.content.emit('scroll', e);
      }
    });
github redgeoff / mson-react / src / render.js View on Github external
export default async app => {
  // Was the client registered?
  if (registrar.client) {
    // Make sure we load the session before doing any rendering so that components can do their
    // initial rendering based on the user's authentication status
    await registrar.client.user.awaitSession();
  }

  ReactDOM.render(
    ,
    document.getElementById('root')
  );
  registerServiceWorker();
};
github redgeoff / mson-react / src / render.js View on Github external
export default async app => {
  // Was the client registered?
  if (registrar.client) {
    // Make sure we load the session before doing any rendering so that components can do their
    // initial rendering based on the user's authentication status
    await registrar.client.user.awaitSession();
  }

  ReactDOM.render(
    ,
    document.getElementById('root')
  );
  registerServiceWorker();
};
github redgeoff / mson-react / src / menu.js View on Github external
items.forEach((item, index) => {
      // Has access to item?
      if (
        (!item.roles ||
          (registrar.client && registrar.client.user.hasRole(item.roles))) &&
        item.hidden !== true
      ) {
        submenus.push(
          
        );
      }
    });
    return submenus;
github redgeoff / mson-react / src / app.js View on Github external
requireAccess(roles) {
    const canAccess =
      !roles || (registrar.client && registrar.client.user.hasRole(roles));
    if (!canAccess) {
      this.emitLoggedOut();
    }
    return canAccess;
  }
github redgeoff / mson-react / src / submenu.js View on Github external
item.items.forEach((item, index) => {
      const isSelected = path === item.path;
      let classNames = [classes.secondary];
      if (isSelected) {
        classNames.push(classes.selected);
      }

      if (
        (!item.roles ||
          (registrar.client && registrar.client.user.hasRole(item.roles))) &&
        item.hidden !== true
      ) {
        listItems.push(
           this.handleClick(item)}
          >
            
                  {item.label}
                
              }