JSPM

  • Created
  • Published
  • Downloads 81
  • Score
    100M100P100Q82036F
  • License MIT

permissions licenses and plans, user validations handling for whole app

Package Exports

  • @zohodesk/permissions

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@zohodesk/permissions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Components


READ_ONLY, SHOW, HIDE

const restrictionRules = {
  <group-name>: {
    <features>: {
      <feature-action-1>: [SHOW, READ_ONLY],  //In array 1th position meant can we show ?, 2st position meant to can we readOnly ?
      <feature-action-2>: [SHOW, READ_ONLY],
      <feature-action-3>: [HIDE]
      }
    }
  }
};

const readyOnlyMessages = {
  <group-name>: {
    <features>: {
      <feature-action-1>: message ,
      <feature-action-2>: message ,
      <feature-action-3>: message
    }
  }
};

const restrictionRules = {
  tickets: {
    isSpam: {
      secondaryContact: [SHOW, READ_ONLY],
      timeline: [HIDE],
      mergeTicket: [SHOW, READ_ONLY],
       edit : [SHOW]
      }
    },
    bluePrintApplied: {
      status: [SHOW, READ_ONLY],
      move: [HIDE],
      edit : [HIDE]
    }
  },
  contacts: {
    anonymous_users : {
      edit: [HIDE],
      follow: [HIDE],
      add_tickets: [SHOW, READ_ONLY],
      add_products: [SHOW]
      }
    }
  }
  
};

const lockMessages = {
  contacts: {
    anonymous_users: {
      edit: 'support.contacts.edit.field.locked',
      add_tickets: 'support.add_tickets.field.locked',
      add_products: 'support.add_products.field.locked'
    }
};

Restriction handling using util methods

Write an file.
const getRestriction = getRestrictionLayer(restrictionRules,lockMessages);
export default getRestriction;

How to use the it.

import getRestriction from 'written-file';
getRestriction(features=[...], group-name , feature-action-1);

getRestriction(['isSpam','bluePrintApplied'],'tickets','edit')
getRestriction('isSpam','tickets','edit')

Restriction handling using components

Write an file.
const RestrictionValidator = restrictionValidator(restrictionRules,lockMessages);
export default RestrictionValidator;

How to use the it.

import RestrictionValidator from 'written-file';

<RestrictionValidator
        module={group-name}
        features={features [] or feature string} 
        action={feature or action}
      >
        <span>
          <Icon name='ZD-addNew' iconClass={iconClass} /> Add product
        </span>
  </RestrictionValidator>