From 10353d3d6d39ea17611b6e6c84e64c6a58cb6440 Mon Sep 17 00:00:00 2001 From: soupette Date: Wed, 25 Aug 2021 10:17:33 +0200 Subject: [PATCH] Add useNotification documentation Signed-off-by: soupette --- .../useNotification.stories.mdx | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 packages/core/helper-plugin/lib/src/hooks/useNotification/useNotification.stories.mdx diff --git a/packages/core/helper-plugin/lib/src/hooks/useNotification/useNotification.stories.mdx b/packages/core/helper-plugin/lib/src/hooks/useNotification/useNotification.stories.mdx new file mode 100644 index 0000000000..6507ef2bff --- /dev/null +++ b/packages/core/helper-plugin/lib/src/hooks/useNotification/useNotification.stories.mdx @@ -0,0 +1,48 @@ + + +import { Meta } from '@storybook/addon-docs'; + + + +# useNotification + +This component is used in order to apply RBAC to a view. If the user does not have the permissions to access the view he will be redirect to the homepage: + +## Usage + +``` +import { useNotification } from '@strapi/helper-plugin'; +import { Button, Main } from '@strapi/parts'; + +const HomePage = () => { + const toggleNotification = useNotification(); + + const handleClick = () => { + toggleNotification({ + // required + type: 'info|success|warning', + // required + message: { id: 'notification.version.update.message', defaultMessage: 'A new version is available' }, + // optional + link: { + url: 'https://github.com/strapi/strapi/releases/tag/v4', + label: { + id: 'notification.version.update.link', + defaultMessage: 'See more' + }, + }, + // optional: default = false + blockTransition: true, + // optional + onClose: () => localStorage.setItem('STRAPI_UPDATE_NOTIF', true), + }); + } + + return ( +
+

This is the homepage

+ +
+ ); +}; +```