Skip to content
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

Merged
merged 2 commits into from
Aug 4, 2020

Conversation

HichamELBSI
Copy link
Contributor

Signed-off-by: HichamELBSI elabbassih@gmail.com

Description of what you did:

  • Move the current Users & Permissions plugin folder in an OLD/ folder
  • Create a container for each settings page (Role, Provider, Email Template and Advanced Settings)
  • Init the new Settings section

Signed-off-by: HichamELBSI <elabbassih@gmail.com>
@derrickmehaffy
Copy link
Member

This is moving all the Users & Permissions options into the new settings menu yeah? If possible can you attach a quick screenshot of the layout in the new menu?

name: 'roles',
to: `${strapi.settingsBaseURL}/${pluginId}/roles`,
Component: () => (
<CheckPagePermissions permissions={pluginPermissions.settings}>
Copy link
Contributor

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;

Copy link
Contributor

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,
Copy link
Contributor

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}>
Copy link
Contributor

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,
Copy link
Contributor

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}>
Copy link
Contributor

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}>
Copy link
Contributor

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,
Copy link
Contributor

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';
Copy link
Contributor

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 />
Copy link
Contributor

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';
Copy link
Contributor

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

@soupette soupette changed the base branch from master to features/users-permissions August 4, 2020 09:11
@soupette
Copy link
Contributor

soupette commented Aug 4, 2020

This is moving all the Users & Permissions options into the new settings menu yeah? If possible can you attach a quick screenshot of the layout in the new menu?

Screenshot 2020-08-04 at 11 44 53

Signed-off-by: HichamELBSI <elabbassih@gmail.com>
@codecov
Copy link

codecov bot commented Aug 4, 2020

Codecov Report

❗ No coverage uploaded for pull request base (features/users-permissions@81a4509). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@                      Coverage Diff                      @@
##             features/users-permissions    #7302   +/-   ##
=============================================================
  Coverage                              ?   27.48%           
=============================================================
  Files                                 ?     1097           
  Lines                                 ?    14729           
  Branches                              ?     2353           
=============================================================
  Hits                                  ?     4048           
  Misses                                ?     8951           
  Partials                              ?     1730           
Flag Coverage Δ
#front 19.41% <0.00%> (?)
#unit 53.14% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81a4509...cb0f33c. Read the comment docs.

Copy link
Contributor

@soupette soupette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@soupette soupette merged commit f4aad12 into features/users-permissions Aug 4, 2020
@soupette soupette deleted the settings/users-permissions branch August 4, 2020 11:58
@alexandrebodin alexandrebodin changed the title [WIP] Init Users & Permissions settings section Init Users & Permissions settings section Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants