The Table Schema Provider fetching list of 8base table schemas and provide it via React Context.
Extends React.Component
Provider for 8base user permissions
childrenFunction Children of the provider. Could be either react node or function with loading state.
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>
);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>
);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>
);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>
);