Skip to content

Commit

Permalink
Merge 6099fdf into de87cb8
Browse files Browse the repository at this point in the history
  • Loading branch information
soupette committed Aug 20, 2021
2 parents de87cb8 + 6099fdf commit 9e887a2
Show file tree
Hide file tree
Showing 215 changed files with 4,395 additions and 279 deletions.
1 change: 1 addition & 0 deletions packages/core/helper-plugin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ stats.json
package-lock.json
yarn-error.log


# Cruft
.DS_Store
npm-debug.log
Expand Down
11 changes: 11 additions & 0 deletions packages/core/helper-plugin/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
stories: [
'../*.stories.mdx',
'../lib/src/**/*.stories.mdx',
'../lib/src/**/*.stories.@(js|jsx|ts|tsx)',
],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
core: {
builder: 'webpack5',
},
};
9 changes: 9 additions & 0 deletions packages/core/helper-plugin/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
};
7 changes: 7 additions & 0 deletions packages/core/helper-plugin/Introduction.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Meta } from '@storybook/addon-docs';

<Meta title="Introduction" />

# Welcome to the Helper plugin documentation

Here you will find the documentation related to the complex components that are used in the Strapi admin panel.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Meta } from '@storybook/addon-docs';

<Meta title="components/CheckPagePermissions" />

# CheckPagePermissions

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 { CheckPagePermissions } from '@strapi/helper-plugin';
const permissions = [{ action: 'plugins::my-plugin.access', subject: null }];
const HomePage = () => {
return (
<CheckPagePermissions permissions={permissions}>
<main>
<h1>This is the homepage</h1>
</main>
</CheckPagePermissions>
);
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React, { useEffect, useRef, useState } from 'react';
import { Redirect } from 'react-router-dom';
import PropTypes from 'prop-types';
import useNotification from '../../hooks/useNotification';

import hasPermissions from '../../utils/hasPermissions';
import LoadingIndicatorPage from '../LoadingIndicatorPage';
import useRBACProvider from '../../hooks/useRBACProvider';
import hasPermissions from '../../utils/hasPermissions';
import LoadingIndicatorPage from '../../old/components/LoadingIndicatorPage';

const CheckPagePermissions = ({ permissions, children }) => {
const abortController = new AbortController();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Meta } from '@storybook/addon-docs';

<Meta title="components/CheckPermissions" />

# CheckPermissions

This component is used in order to apply RBAC to a component. If the user does not have the permissions to view a component it will be hidden.

## Usage

```
import { CheckPermissions } from '@strapi/helper-plugin';
const permissions = [{ action: 'plugins::my-plugin.read', subject: null }];
const HomePage = () => {
return (
<main>
<h1>This is the homepage</h1>
<CheckPermissions permissions={permissions}>
You can all see this if you have the right to.
</CheckPermissions>
</main>
);
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Meta } from '@storybook/addon-docs';

<Meta title="components/InjectionZone" />

# InjectionZone

This component is used in order to define an injection zone that other plugins can use to add components in a dedicated area.

## Usage

```
// Use the injection zone in a view
import { InjectionZone } from '@strapi/helper-plugin';
const HomePage = () => {
return (
<main>
<h1>This is the homepage</h1>
</main>
<InjectionZone area="my-plugin.homePage.right" />
);
};
// Define this injection zone
// path: 'my-plugin/admin/src/index.js
export default {
register() {
app.registerPlugin({
// ...
injectionZones: {
homepage: {
right: []
}
}
});
},
}
// Inject from a plugin
// path: 'my-other-plugin/admin/src/index.js'
export default {
register() {
// ...
},
bootstrap(app) {
app.getPlugin('my-plugin').injectComponent('homePage', 'right', {
name: 'my-other-plugin-component',
Component: () => 'This component is injected',
});
}
};
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import testData from '../../../testUtils/testData';
import testData from '../../../old/testUtils/testData';
import contentManagementUtilRemoveFieldsFromData from '../contentManagementUtilRemoveFieldsFromData';

describe('STRAPI_HELPER_PLUGIN | utils', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import testData from '../../../testUtils/testData';
import testData from '../../../old/testUtils/testData';
import formatComponentData from '../formatComponentData';

const { contentType, components, modifiedData } = testData;
Expand Down
Loading

0 comments on commit 9e887a2

Please sign in to comment.