Skip to content
Scott Halstvedt edited this page Jun 24, 2015 · 2 revisions

AskNature 2.0 - React Components

Layouts and navbar

Restrict

modules/restrict.jsx

The Restrict component allows its child content to be displayed only when a user has a given capability. It requires the following props:

user (User object): represents the profile to be used for capability evaluation (usually the currently authenticated user)

capability (string): the name of the capability to be evaluated; capabilities are attributes of the UserStatus database class

deniedComponent (React Component): a component to display if the user does not qualify with the proper capability

In addition, the component requires children.

Usage example:

<Restrict user={user} capability="EditStrategy" deniedComponent={component}>
        <h1>This only appears if you have the 'EditStrategy' capability</h1>
</Restrict>

RestrictOptions

modules/restrictoptions.jsx

The RestrictOptions component allows its child component to be parametrized based on the capabilities of a user.

Usage example:

<RestrictOptions user={user} options={{'EditPage': {'options': ['one', 'two', 'three']}, 'OtherPermission': {'options': ['one', 'two']}}}>
        <Select props=...>
</RestrictOptions>

Cards and detailview

Restrict

modules/restrict.jsx

The Restrict component allows its child content to be displayed only when a user has a given capability. It requires the following props:

user (User object): represents the profile to be used for capability evaluation (usually the currently authenticated user)

capability (string): the name of the capability to be evaluated; capabilities are attributes of the UserStatus database class

deniedComponent (React Component): a component to display if the user does not qualify with the proper capability

In addition, the component requires children.

Usage example:

<Restrict user={user} capability="EditStrategy" deniedComponent={component}>
        <h1>This only appears if you have the 'EditStrategy' capability</h1>
</Restrict>

RestrictOptions

modules/restrictoptions.jsx

The RestrictOptions component allows its child component to be parametrized based on the capabilities of a user.

Usage example:

<RestrictOptions user={user} options={{'EditPage': {'options': ['one', 'two', 'three']}, 'OtherPermission': {'options': ['one', 'two']}}}>
        <Select props=...>
</RestrictOptions>

RelationshipList

Restrict

modules/restrict.jsx

The Restrict component allows its child content to be displayed only when a user has a given capability. It requires the following props:

user (User object): represents the profile to be used for capability evaluation (usually the currently authenticated user)

capability (string): the name of the capability to be evaluated; capabilities are attributes of the UserStatus database class

deniedComponent (React Component): a component to display if the user does not qualify with the proper capability

In addition, the component requires children.

Usage example:

<Restrict user={user} capability="EditStrategy" deniedComponent={component}>
        <h1>This only appears if you have the 'EditStrategy' capability</h1>
</Restrict>

RestrictOptions

modules/restrictoptions.jsx

The RestrictOptions component allows its child component to be parametrized based on the capabilities of a user.

Usage example:

<RestrictOptions user={user} options={{'EditPage': {'options': ['one', 'two', 'three']}, 'OtherPermission': {'options': ['one', 'two']}}}>
        <Select props=...>
</RestrictOptions>

Infinite Scroll and Search

Restrict

modules/restrict.jsx

The Restrict component allows its child content to be displayed only when a user has a given capability. It requires the following props:

user (User object): represents the profile to be used for capability evaluation (usually the currently authenticated user)

capability (string): the name of the capability to be evaluated; capabilities are attributes of the UserStatus database class

deniedComponent (React Component): a component to display if the user does not qualify with the proper capability

In addition, the component requires children.

Usage example:

<Restrict user={user} capability="EditStrategy" deniedComponent={component}>
        <h1>This only appears if you have the 'EditStrategy' capability</h1>
</Restrict>

RestrictOptions

modules/restrictoptions.jsx

The RestrictOptions component allows its child component to be parametrized based on the capabilities of a user.

Usage example:

<RestrictOptions user={user} options={{'EditPage': {'options': ['one', 'two', 'three']}, 'OtherPermission': {'options': ['one', 'two']}}}>
        <Select props=...>
</RestrictOptions>