@8base/permissions-provider

The Table Schema Provider fetching list of 8base table schemas and provide it via React Context.

This package was moved to @8base-react/permissions-provider package. Use it instead.
Last updated 6 months ago by zouxuoz .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @8base/permissions-provider 
SYNC missed versions from official npm registry.

8base Table Schema Provider

The Table Schema Provider fetching list of 8base table schemas and provide it via React Context.

API

Table of Contents

PermissionsProvider

Extends React.Component

Provider for 8base user permissions

Properties

  • children Function Children of the provider. Could be either react node or function with loading state.

Usage

Programatic usage

import React from 'react';
import { PermissionsProvider, PermissionContext, isAllowed } from '@8base/permission-provider';

class MyComponent extends React.Component {
  static contextType = PermissionContext;

  render() {
    const allowed = isAllowed({
      resource: 'schema',
      type: 'custom',
      permission: 'edit'
    }, this.context);

    return <Button disabled={!allowed}>Edit Schema!</Button>
  }
}

const Application = () => (
  <PermissionsProvider>
    {
      ({ loading }) => loading ? 'Loading...' : (
        <MyComponent />
      )
    }
  </PermissionsProvider>
);

Conditional rendering by schema permission

import React from 'react';
import { PermissionsProvider, IfAllowed } from '@8base/permission-provider';

const MyComponent = () => (
  <IfAllowed permissions={[['custom', 'schema', 'edit']]}>
    <Button>Edit Schema!</Button>
  </IfAllowed>
);

const Application = () => (
  <PermissionsProvider>
    {
      ({ loading }) => loading ? 'Loading...' : (
        <MyComponent />
      )
    }
  </PermissionsProvider>
);

Conditional rendering by data permission

import React from 'react';
import { IfAllowed } from '@8base/permission-provider';

const MyComponent = () => (
  <IfAllowed permissions={[['data', 'Clients', 'create']]}>
    <Button>Create Client!</Button>
  </IfAllowed>
);

const Application = () => (
  <PermissionsProvider>
    {
      ({ loading }) => loading ? 'Loading...' : (
        <MyComponent />
      )
    }
  </PermissionsProvider>
);

Usage with render props

import React from 'react';
import { IfAllowed } from '@8base/permission-provider';

const MyComponent = () => (
  <IfAllowed permissions={[['custom', 'schema', 'edit']]}>
    {
      (allowed) => <Button disabled={!allowed}>Edit Schema!</Button>
    }
  </IfAllowed>
);

const Application = () => (
  <PermissionsProvider>
    {
      ({ loading }) => loading ? 'Loading...' : (
        <MyComponent />
      )
    }
  </PermissionsProvider>
);

Current Tags

  • 0.37.2                                ...           latest (6 months ago)

115 Versions

  • 0.37.2 [deprecated]           ...           6 months ago
  • 0.37.1 [deprecated]           ...           7 months ago
  • 0.37.0 [deprecated]           ...           7 months ago
  • 0.36.6 [deprecated]           ...           7 months ago
  • 0.36.5 [deprecated]           ...           7 months ago
  • 0.36.4 [deprecated]           ...           7 months ago
  • 0.36.3 [deprecated]           ...           7 months ago
  • 0.36.2 [deprecated]           ...           7 months ago
  • 0.36.1 [deprecated]           ...           7 months ago
  • 0.36.0 [deprecated]           ...           7 months ago
  • 0.35.1 [deprecated]           ...           8 months ago
  • 0.35.0 [deprecated]           ...           8 months ago
  • 0.34.0 [deprecated]           ...           8 months ago
  • 0.33.1 [deprecated]           ...           8 months ago
  • 0.33.0 [deprecated]           ...           8 months ago
  • 0.32.3 [deprecated]           ...           8 months ago
  • 0.32.2 [deprecated]           ...           9 months ago
  • 0.32.1 [deprecated]           ...           9 months ago
  • 0.32.0 [deprecated]           ...           9 months ago
  • 0.31.2 [deprecated]           ...           9 months ago
  • 0.31.1 [deprecated]           ...           9 months ago
  • 0.31.0 [deprecated]           ...           9 months ago
  • 0.30.0 [deprecated]           ...           9 months ago
  • 0.29.2 [deprecated]           ...           9 months ago
  • 0.29.1 [deprecated]           ...           9 months ago
  • 0.29.0 [deprecated]           ...           9 months ago
  • 0.28.5 [deprecated]           ...           9 months ago
  • 0.28.4 [deprecated]           ...           9 months ago
  • 0.28.3 [deprecated]           ...           10 months ago
  • 0.28.2 [deprecated]           ...           10 months ago
  • 0.28.1 [deprecated]           ...           10 months ago
  • 0.28.0 [deprecated]           ...           10 months ago
  • 0.27.1 [deprecated]           ...           10 months ago
  • 0.27.0 [deprecated]           ...           10 months ago
  • 0.26.0 [deprecated]           ...           10 months ago
  • 0.25.1 [deprecated]           ...           10 months ago
  • 0.25.0 [deprecated]           ...           10 months ago
  • 0.24.0 [deprecated]           ...           10 months ago
  • 0.23.1 [deprecated]           ...           10 months ago
  • 0.23.0 [deprecated]           ...           10 months ago
  • 0.22.0 [deprecated]           ...           10 months ago
  • 0.21.4 [deprecated]           ...           10 months ago
  • 0.21.3 [deprecated]           ...           10 months ago
  • 0.21.2 [deprecated]           ...           a year ago
  • 0.21.1 [deprecated]           ...           a year ago
  • 0.21.0 [deprecated]           ...           a year ago
  • 0.20.4 [deprecated]           ...           a year ago
  • 0.20.3 [deprecated]           ...           a year ago
  • 0.20.2 [deprecated]           ...           a year ago
  • 0.20.1 [deprecated]           ...           a year ago
  • 0.20.0 [deprecated]           ...           a year ago
  • 0.19.6 [deprecated]           ...           a year ago
  • 0.19.5 [deprecated]           ...           a year ago
  • 0.19.4 [deprecated]           ...           a year ago
  • 0.19.3 [deprecated]           ...           a year ago
  • 0.19.2 [deprecated]           ...           a year ago
  • 0.19.1 [deprecated]           ...           a year ago
  • 0.19.0 [deprecated]           ...           a year ago
  • 0.18.7 [deprecated]           ...           a year ago
  • 0.18.6 [deprecated]           ...           a year ago
  • 0.18.5 [deprecated]           ...           a year ago
  • 0.18.4 [deprecated]           ...           a year ago
  • 0.18.3 [deprecated]           ...           a year ago
  • 0.18.2 [deprecated]           ...           a year ago
  • 0.18.1 [deprecated]           ...           a year ago
  • 0.18.0 [deprecated]           ...           a year ago
  • 0.17.2 [deprecated]           ...           a year ago
  • 0.17.1 [deprecated]           ...           a year ago
  • 0.17.0 [deprecated]           ...           a year ago
  • 0.16.10 [deprecated]           ...           a year ago
  • 0.16.9 [deprecated]           ...           a year ago
  • 0.16.8 [deprecated]           ...           a year ago
  • 0.16.7 [deprecated]           ...           a year ago
  • 0.16.6 [deprecated]           ...           a year ago
  • 0.16.5 [deprecated]           ...           a year ago
  • 0.16.4 [deprecated]           ...           a year ago
  • 0.16.3 [deprecated]           ...           a year ago
  • 0.16.2 [deprecated]           ...           a year ago
  • 0.16.1 [deprecated]           ...           a year ago
  • 0.16.0 [deprecated]           ...           a year ago
  • 0.15.4 [deprecated]           ...           a year ago
  • 0.15.3 [deprecated]           ...           a year ago
  • 0.15.2 [deprecated]           ...           a year ago
  • 0.15.1 [deprecated]           ...           a year ago
  • 0.15.0 [deprecated]           ...           a year ago
  • 0.14.4 [deprecated]           ...           a year ago
  • 0.14.3 [deprecated]           ...           a year ago
  • 0.14.2 [deprecated]           ...           a year ago
  • 0.14.1 [deprecated]           ...           a year ago
  • 0.14.0 [deprecated]           ...           a year ago
  • 0.13.0 [deprecated]           ...           a year ago
  • 0.12.0 [deprecated]           ...           a year ago
  • 0.11.3 [deprecated]           ...           a year ago
  • 0.11.2 [deprecated]           ...           a year ago
  • 0.11.1 [deprecated]           ...           a year ago
  • 0.11.0 [deprecated]           ...           a year ago
  • 0.10.5 [deprecated]           ...           a year ago
  • 0.10.4 [deprecated]           ...           a year ago
  • 0.10.3 [deprecated]           ...           a year ago
  • 0.10.2 [deprecated]           ...           a year ago
  • 0.10.1 [deprecated]           ...           a year ago
  • 0.10.0 [deprecated]           ...           a year ago
  • 0.9.2 [deprecated]           ...           a year ago
  • 0.9.1 [deprecated]           ...           a year ago
  • 0.9.0 [deprecated]           ...           a year ago
  • 0.8.5 [deprecated]           ...           a year ago
  • 0.8.4 [deprecated]           ...           a year ago
  • 0.8.3 [deprecated]           ...           a year ago
  • 0.8.2 [deprecated]           ...           a year ago
  • 0.8.1 [deprecated]           ...           a year ago
  • 0.8.0 [deprecated]           ...           a year ago
  • 0.7.3 [deprecated]           ...           a year ago
  • 0.7.2 [deprecated]           ...           a year ago
  • 0.7.1 [deprecated]           ...           a year ago
  • 0.7.0 [deprecated]           ...           a year ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 115
Last Month 460
Dependencies (4)
Dev Dependencies (14)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |