-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Init Users & Permissions settings section #7302
Init Users & Permissions settings section #7302
Conversation
Signed-off-by: HichamELBSI <elabbassih@gmail.com>
This is moving all the |
name: 'roles', | ||
to: `${strapi.settingsBaseURL}/${pluginId}/roles`, | ||
Component: () => ( | ||
<CheckPagePermissions permissions={pluginPermissions.settings}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The settings key does not exist in the permissions.js
file. Maybe you could update this file as follows:
const pluginPermissions = {
// Roles
accessRoles: [
{ action: 'plugins::users-permissions.roles.create', subject: null },
{ action: 'plugins::users-permissions.roles.read', subject: null },
{ action: 'plugins::users-permissions.roles.update', subject: null },
],
createRole: [{ action: 'plugins::users-permissions.roles.create', subject: null }],
deleteRole: [{ action: 'plugins::users-permissions.roles.delete', subject: null }],
readRoles: [{ action: 'plugins::users-permissions.roles.read', subject: null }],
updateRole: [{ action: 'plugins::users-permissions.roles.update', subject: null }],
// AdvancedSettings
readAdvancedSettings: [
{ action: 'plugins::users-permissions.advanced-settings.read', subject: null },
{ action: 'plugins::users-permissions.advanced-settings.update', subject: null },
],
updateAdvancedSettings: [
{ action: 'plugins::users-permissions.advanced-settings.update', subject: null },
],
// Emails
readEmailTemplates: [
{ action: 'plugins::users-permissions.email-templates.read', subject: null },
{ action: 'plugins::users-permissions.email-templates.update', subject: null },
],
updateEmailTemplates: [
{ action: 'plugins::users-permissions.email-templates.update', subject: null },
],
// Providers
readProviders: [
{ action: 'plugins::users-permissions.providers.read', subject: null },
{ action: 'plugins::users-permissions.providers.update', subject: null },
],
updateProviders: [{ action: 'plugins::users-permissions.providers.update', subject: null }],
};
export default pluginPermissions;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you will need to a Router
for the roles pages so you can't wrap the component using the CheckPagePermissions
`
<RolesPage /> | ||
</CheckPagePermissions> | ||
), | ||
permissions: pluginPermissions.settings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
permissions: pluginPermissions.accessRoles
name: 'providers', | ||
to: `${strapi.settingsBaseURL}/${pluginId}/providers`, | ||
Component: () => ( | ||
<CheckPagePermissions permissions={pluginPermissions.settings}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<CheckPagePermissions permissions={pluginPermissions.readProviders}>
<ProvidersPage /> | ||
</CheckPagePermissions> | ||
), | ||
permissions: pluginPermissions.settings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pluginPermissions.readProviders
name: 'email-templates', | ||
to: `${strapi.settingsBaseURL}/${pluginId}/email-templates`, | ||
Component: () => ( | ||
<CheckPagePermissions permissions={pluginPermissions.settings}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<CheckPagePermissions permissions={pluginPermissions.readEmailTemplates}>
name: 'advanced-settings', | ||
to: `${strapi.settingsBaseURL}/${pluginId}/advanced-settings`, | ||
Component: () => ( | ||
<CheckPagePermissions permissions={pluginPermissions.settings}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<CheckPagePermissions permissions={pluginPermissions.readAdvancedSettings}>
<AdvancedSettingsPage /> | ||
</CheckPagePermissions> | ||
), | ||
permissions: pluginPermissions.settings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pluginPermissions.readAdvancedSettings
@@ -0,0 +1,7 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you will need a router a suggest the following modifications:
import React from 'react';
import { Switch, Route, Link } from 'react-router-dom';
import { useGlobalContext, CheckPagePermissions, NotFound } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
import pluginPermissions from '../../permissions';
const RolesEditPage = () => <div>Role edit</div>;
const ProtectedRolesEditPage = () => (
<CheckPagePermissions permissions={pluginPermissions.updateRole}>
<RolesEditPage />
</CheckPagePermissions>
);
const RolesCreatePage = () => (
<CheckPagePermissions permissions={pluginPermissions.createRole}>
<RolesEditPage />
</CheckPagePermissions>
);
const RolesListPage = () => {
return (
<CheckPagePermissions permissions={pluginPermissions.accessRoles}>
<div>Role list</div>
<div>
<Link to="/settings/users-permissions/roles/1">Edit Role</Link>
</div>
<div>
<Link to="/settings/users-permissions/roles/new">Create Role</Link>
</div>
</CheckPagePermissions>
);
};
const Role = () => {
const { settingsBaseURL } = useGlobalContext();
return (
<Switch>
<Route path={`${settingsBaseURL}/${pluginId}/roles/new`} component={RolesCreatePage} exact />
<Route
path={`${settingsBaseURL}/${pluginId}/roles/:id`}
component={ProtectedRolesEditPage}
exact
/>
<Route path={`${settingsBaseURL}/${pluginId}/roles`} component={RolesListPage} exact />
<Route path="" component={NotFound} />
</Switch>
);
};
export default Roles;
to: `${strapi.settingsBaseURL}/${pluginId}/roles`, | ||
Component: () => ( | ||
<CheckPagePermissions permissions={pluginPermissions.settings}> | ||
<RolesPage /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Roles />
import Initializer from './containers/Initializer'; | ||
import RolesPage from './containers/Roles'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import Role from './containers/Roles
Signed-off-by: HichamELBSI <elabbassih@gmail.com>
e1b8ca4
to
cb0f33c
Compare
Codecov Report
@@ Coverage Diff @@
## features/users-permissions #7302 +/- ##
=============================================================
Coverage ? 27.48%
=============================================================
Files ? 1097
Lines ? 14729
Branches ? 2353
=============================================================
Hits ? 4048
Misses ? 8951
Partials ? 1730
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: HichamELBSI elabbassih@gmail.com
Description of what you did: