diff --git a/docs/3.x.x/en/plugin-development/ui-components.md b/docs/3.x.x/en/plugin-development/ui-components.md index 0396a12233..85a904a897 100644 --- a/docs/3.x.x/en/plugin-development/ui-components.md +++ b/docs/3.x.x/en/plugin-development/ui-components.md @@ -328,6 +328,171 @@ export default FooPage; *** +## OverlayBlocker + +The OverlayBlocker is a React component that is very useful to block user interactions when the strapi server is restarting in order to avoid front-end errors. + +### Usage + +| Property | Type | Required | Description | +| -------- | ---- | -------- | ----------- | +| children | node | no | Anything that is wrapped inside the OverlayBlocker | +| isOpen | bool | no | If set to `true` it will display the component | + +### Example + +In this example we'll have a button that when clicked it will display the OverlayBlocker for 5 seconds thus 'freezes' the admin so the user can't navigate (it simulates a very long server restart). + +**Path -** `./plugins/my-plugin/admin/src/containers/FooPage/constants.js`. +```js +export const ON_BUTTON_CLICK = 'MyPlugin/FooPage/ON_BUTTON_CLICK'; +export const RESET_SHOW_OVERLAY_PROP = 'MyPlugin/FooPage/RESET_SHOW_OVERLAY_PROP'; +``` + +**Path -** `./plugins/my-plugin/admin/src/containers/FooPage/actions.js`. +```js +import { ON_BUTTON_CLICK, RESET_SHOW_OVERLAY_PROP } from './constants'; + +export function onButtonClick() { + return { + type: ON_BUTTON_CLICK, + }; +} + +export function resetShowOverlayProp() { + return { + type: RESET_SHOW_OVERLAY_PROP, + }; +} +``` + +**Path -** `./plugins/my-plugin/admin/src/containers/FooPage/index.js`. +```js +import React from 'react'; +import PropTypes from 'prop-types'; +import { connect } from 'react-redux'; +import { bindActionCreators, compose } from 'redux'; + +// Design +import Button from 'components/Button'; +import OverlayBlocker from 'components/OverlayBlocker'; + +// Utils +import injectSaga from 'utils/injectSaga'; +import injectReducer from 'utils/injectReducer'; + +// Actions +import { onButtonClick } from './actions'; + +// Reducer +import reducer from './reducer'; + +// Saga +import saga from './saga'; + +// Selectors (see the documentation to see how to use selectors) +import makeSelectFooPage from './selectors'; + + +export class FooPage extends React.Component { + render() { + return ( +