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

Group roles and permissions UI #243

Open
wants to merge 110 commits into
base: 8.x-1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 96 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
6e19874
Start implementing the roles overview.
pfrenssen May 13, 2016
1251538
Add provisionary routes for the roles and permissions edit forms so w…
pfrenssen May 14, 2016
0896bee
Add a method to determine whether a role is mutable.
pfrenssen May 14, 2016
da38761
Show the links for editing roles and permissions in the table.
pfrenssen May 14, 2016
a798f5b
Turn the roles overview from a form into a controller.
pfrenssen May 14, 2016
142fe56
Provide a local action to add a role.
pfrenssen May 14, 2016
a1777f6
Return a 404 on the group role overview when the entity is not a group.
pfrenssen May 14, 2016
397ecf4
Add a skeleton for the roles form.
pfrenssen Jun 1, 2016
46bd056
Change the method from isMutable() to isLocked() so it matches what i…
pfrenssen Jun 1, 2016
23a465e
Update documentation.
pfrenssen Jun 1, 2016
5c6411f
Revert "Add a skeleton for the roles form."
pfrenssen Jun 1, 2016
8cae14b
isMutable() has been inverted and is now called isLocked().
pfrenssen Jun 2, 2016
1bd2e71
Add links to the OG Role entity declaration.
pfrenssen Jun 2, 2016
dc92913
Implement the role add/edit form.
pfrenssen Jun 2, 2016
2cc8a37
Use the correct naming scheme for entity forms.
pfrenssen Jun 2, 2016
8d57411
Fix redirect link to role overview after editing a role.
pfrenssen Jun 2, 2016
e389af6
Role add controller and small form modification.
ArchieVasyatkinMonsoon Feb 1, 2017
9a725af
Adding reoute for creation group-specific role links, restoring overv…
ArchieVasyatkinMonsoon Feb 1, 2017
7aae695
Add amitaibu/196
zerolab Feb 21, 2017
746932f
Remove duplicated method.
pfrenssen Jul 4, 2018
d52259e
Fix clashing routes
zerolab Feb 21, 2017
d50c800
Fix new group roles considered required, rather than standard
zerolab Feb 21, 2017
297669e
Add OG role deletion form
zerolab Feb 21, 2017
f43ad36
Add permissions overview and role permission forms
zerolab Mar 7, 2017
8e94836
Fix PHP warnings
zerolab Mar 7, 2017
bcdfb40
Fix role edit fails because of wrong 'exists' check
zerolab Mar 10, 2017
4241159
Use _entity_access for og_role routes
zerolab Mar 10, 2017
0dbad65
Fix go role validation issue
zerolab Mar 10, 2017
04b0dc9
Linting
zerolab Mar 10, 2017
416eacd
Restrict deletion for default OG roles
zerolab Mar 10, 2017
c195c80
Tweak roles list operations
zerolab Mar 10, 2017
4a5f2a3
Change group role overview page to DraggableListBuilder
zerolab Mar 13, 2017
49eaed5
Fix coding standards issues
zerolab Apr 12, 2017
6c1235a
Use OgRole name
zerolab Apr 28, 2017
f74626d
Fix machine name validation
zerolab Apr 28, 2017
1c0320e
Fix typos
zerolab Apr 28, 2017
0bf45ec
Fix roles overview page title
zerolab Apr 28, 2017
e5b4ec3
Update single permission form to use role name in path
zerolab Apr 29, 2017
fd9581d
Add permission page parameters validation
zerolab Apr 29, 2017
96c4226
Return 404 instead of access denied
zerolab Apr 29, 2017
6361f2f
Standardise parameter names
zerolab Apr 29, 2017
7a3c87d
Stick to entity yaml routes for roles
zerolab Apr 29, 2017
2697c8c
Fix redirects and role add machine name form
zerolab Apr 29, 2017
e7408e7
Code style
zerolab Apr 29, 2017
09d41eb
Improve permissions page when no group content permissions available
zerolab Apr 29, 2017
d3e628b
Fix role edit form returning 404 post-tweaks
zerolab Apr 29, 2017
90833eb
Use better OgRole fetching method
zerolab May 2, 2017
ff1aaf2
Fix roles overview menu link
zerolab May 12, 2017
add6c3a
Fix route on roles permissions overview page
zerolab May 12, 2017
70611e5
Fix docblock
zerolab Nov 27, 2017
1c91e5e
Allow permission grouping by provider
zerolab Nov 28, 2017
1b1c8cb
Reflect the roles weight on the permissions page
zerolab Nov 28, 2017
3132b2b
Lint
zerolab Nov 28, 2017
15e9536
Add message on save
zerolab Apr 25, 2018
79cbd4e
Instead of crashing when a entity definition doesn't exist, log an er…
pfrenssen Jul 10, 2018
8c21354
This table doesn't only represent roles, but also permissions.
pfrenssen Jul 10, 2018
8de6aa8
Update documentation.
pfrenssen Jul 12, 2018
3f3516b
Add type hints to closure arguments.
pfrenssen Jul 12, 2018
2c40084
Move og_role routes to og module.
MPParsley Dec 21, 2018
a0379da
Move og entity routes to top of file.
MPParsley Dec 21, 2018
7d17371
Revert last commit.
MPParsley Dec 21, 2018
e55d9ee
Update og_ui/src/Form/OgPermissionsForm.php
MPParsley Apr 24, 2019
04c8040
Update og_ui/src/Form/OgPermissionsForm.php
MPParsley Apr 24, 2019
38b3558
Update og_ui/src/Form/OgPermissionsForm.php
MPParsley Apr 24, 2019
4eb68c2
Update og_ui/src/Form/OgPermissionsForm.php
MPParsley Apr 24, 2019
4cdcfb5
Update og_ui/src/Form/OgPermissionsForm.php
MPParsley Apr 24, 2019
22b9e0e
Update og_ui/src/Form/OgPermissionsForm.php
MPParsley Apr 24, 2019
3575972
Update og_ui/src/Form/OgPermissionsForm.php
MPParsley Apr 24, 2019
be6d20c
Apply suggestions from code review
MPParsley Apr 24, 2019
11b12ea
Apply suggestions from code review
MPParsley Apr 24, 2019
b9f4821
Apply suggestions from code review
MPParsley Apr 24, 2019
7398389
Update og.routing.yml
MPParsley May 12, 2019
7c39e91
Merge pull request #5 from Gizra/feature/cleanup_cs_errors
MPParsley May 28, 2019
37e43c5
Merge remote-tracking branch 'origin/8.x-1.x' into 196-redux
pfrenssen Jun 11, 2019
75bb191
Merge remote-tracking branch 'origin/8.x-1.x' into 196-redux
pfrenssen Jun 12, 2019
8aa3e10
Merge remote-tracking branch 'origin/8.x-1.x' into 196-redux
pfrenssen Jun 12, 2019
39507d1
Merge remote-tracking branch 'origin/consolidate-permissions' into 19…
pfrenssen Jun 13, 2019
5c7c46b
Merge remote-tracking branch 'origin/8.x-1.x' into 196-redux
pfrenssen Jun 13, 2019
62b44d0
Merge remote-tracking branch 'origin/8.x-1.x' into 196-redux
pfrenssen Jun 13, 2019
f5ed38d
Test access to the roles and permissions UI.
pfrenssen Jun 14, 2019
cd085c7
Merge pull request #6 from Gizra/8.x-1.x
MPParsley Sep 10, 2019
d4dd2b2
Merge pull request #9 from Gizra/8.x-1.x
MPParsley Feb 7, 2020
ef03f0d
Merge branch '8.x-1.x' into 196-redux
MPParsley Jul 4, 2020
d423ec0
Remove calls to t()
MPParsley Jul 4, 2020
1d79922
Merge branch '8.x-1.x' into 196-redux
MPParsley Jul 20, 2020
2e9e465
Renamed permission
MPParsley Jul 20, 2020
202908e
Fix lines that exceed 80 characters
MPParsley Jul 20, 2020
908896c
Merge branch '8.x-1.x' into 196-redux
MPParsley Aug 5, 2020
fc8b00a
Merge branch '8.x-1.x' into 196-redux
MPParsley Aug 10, 2020
046f8b2
Add strict types
MPParsley Aug 10, 2020
da1b097
Merge branch '8.x-1.x' into 196-redux
MPParsley Aug 16, 2020
4db405a
Merge branch '8.x-1.x' into 196-redux
MPParsley Jan 19, 2021
1169b53
Apply suggestions from code review
MPParsley Jan 19, 2021
13f0e4f
Merge branch '8.x-1.x' into 196-redux
MPParsley Apr 20, 2021
b4e9381
Merge branch '8.x-1.x' into 196-redux
MPParsley Apr 22, 2021
5599a5b
Use RouteProviderInterface
MPParsley Apr 28, 2021
ee2d98a
Use EntityTypeInterface
MPParsley Apr 28, 2021
e8b65f3
Change deprecated link() to toLink()
MPParsley Apr 30, 2021
1518ff5
Remove deprecated drupal_set_message
MPParsley Apr 30, 2021
cde56f6
Apply suggestions from code review
MPParsley Apr 30, 2021
361378d
Update og_ui/src/Form/OgPermissionsForm.php
MPParsley Apr 30, 2021
b4f00c9
Update og_ui/src/Form/OgRoleForm.php
MPParsley Apr 30, 2021
fa38aaf
Merge branch '8.x-1.x' into 196-redux
MPParsley Sep 15, 2021
b8cd389
Remove extra blank line
MPParsley Sep 28, 2021
c763ff3
Merge branch '8.x-1.x' into 196-redux
MPParsley Sep 30, 2021
7d7046a
Merge branch '8.x-1.x' into 196-redux
MPParsley Feb 11, 2022
0be7778
Merge branch '8.x-1.x' into 196-redux
MPParsley Aug 25, 2022
15c1b7a
Add required options module for Kernel test
MPParsley Aug 25, 2022
ead050c
Merge branch '8.x-1.x' into 196-redux
MPParsley Aug 26, 2022
b9fa416
Fix phpcs issues
MPParsley Aug 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions og.routing.yml
@@ -1,5 +1,38 @@
# Routes for Organic groups.

# OgRole entity routes.

entity.og_role.collection:
path: 'admin/config/group/roles/{entity_type_id}/{bundle_id}'
defaults:
_entity_list: 'og_role'
_title_callback: '\Drupal\og_ui\Controller\OgUiController::rolesOverviewPageTitleCallback'
requirements:
_permission: 'administer organic groups'

entity.og_role.add_form:
path: 'admin/config/group/roles/{entity_type_id}/{bundle_id}/add'
defaults:
_entity_form: og_role.default
_title: 'Add role'
requirements:
_permission: 'administer organic groups'

entity.og_role.edit_form:
path: 'admin/config/group/role/{og_role}/edit'
defaults:
_entity_form: og_role.default
_title_callback: '\Drupal\og_ui\Form\OgRoleForm::editRoleTitleCallback'
requirements:
_entity_access: 'og_role.update'

entity.og_role.delete_form:
path: 'admin/config/group/role/{og_role}/delete'
defaults:
_entity_form: og_role.delete
requirements:
_entity_access: 'og_role.delete'

og.subscribe:
path: 'group/{entity_type_id}/{group}/subscribe/{membership_type}'
defaults:
Expand Down
5 changes: 5 additions & 0 deletions og_ui/og_ui.links.action.yml
@@ -0,0 +1,5 @@
entity.og_role.add_form:
route_name: entity.og_role.add_form
title: 'Add role'
appears_on:
- entity.og_role.collection
16 changes: 16 additions & 0 deletions og_ui/og_ui.links.menu.yml
Expand Up @@ -11,3 +11,19 @@ og_ui.settings:
parent: og_ui.admin_index
description: 'Administer OG settings.'
route_name: og_ui.settings

og_ui.roles_permissions_overview:
title: 'OG roles'
parent: og_ui.admin_index
description: 'Administer OG roles.'
route_name: og_ui.roles_permissions_overview
route_parameters:
type: 'roles'

og_ui.permissions_overview:
title: 'OG permissions'
parent: og_ui.admin_index
description: 'Administer OG permissions.'
route_name: og_ui.roles_permissions_overview
route_parameters:
type: 'permissions'
16 changes: 8 additions & 8 deletions og_ui/og_ui.routing.yml
Expand Up @@ -25,18 +25,18 @@ og_ui.roles_permissions_overview:
_permission: 'administer organic groups'
type: '^(roles|permissions)$'

og_ui.roles_form:
path: 'admin/config/group/roles/{entity_type}/{bundle}'
og_ui.permissions_overview:
path: 'admin/config/group/permissions/{entity_type_id}/{bundle_id}'
defaults:
_form: '\Drupal\og_ui\Form\OgRolesForm'
_title: '@todo - create title callback'
_form: '\Drupal\og_ui\Form\OgPermissionsForm'
_title_callback: '\Drupal\og_ui\Form\OgPermissionsForm::titleCallback'
requirements:
_permission: 'administer organic groups'

og_ui.permissions_form:
path: 'admin/config/group/permissions/{entity_type}/{bundle}'
og_ui.permissions_edit_form:
path: 'admin/config/group/permissions/{entity_type_id}/{bundle_id}/{role_name}'
defaults:
_form: '\Drupal\og_ui\Form\OgPermissionsForm'
_title: '@todo - create title callback'
_form: '\Drupal\og_ui\Form\OgRolePermissionsForm'
_title_callback: '\Drupal\og_ui\Form\OgRolePermissionsForm::rolePermissionTitleCallback'
requirements:
_permission: 'administer organic groups'
48 changes: 42 additions & 6 deletions og_ui/src/Controller/OgUiController.php
Expand Up @@ -4,6 +4,7 @@

namespace Drupal\og_ui\Controller;

use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
Expand Down Expand Up @@ -74,30 +75,44 @@ public static function create(ContainerInterface $container) {
* The overview as a render array.
*/
public function rolesPermissionsOverviewPage($type) {
$route = $type === 'roles' ? 'entity.og_role.collection' : 'og_ui.permissions_overview';
$action = $type === 'roles' ? $this->t('Edit roles') : $this->t('Edit permissions');
$header = [$this->t('Group type'), $this->t('Operations')];
$rows = [];
$build = [];

foreach ($this->groupTypeManager->getGroupMap() as $entity_type => $bundles) {
$definition = $this->entityTypeManager->getDefinition($entity_type);
try {
$definition = $this->entityTypeManager->getDefinition($entity_type);
}
catch (PluginNotFoundException $e) {
// The entity type manager might throw this exception if the entity type
// is not defined. If this happens it means there is a discrepancy
// between the group types in config, and the modules that providing
// these entity types. This is not something we can rectify here but it
// does not block the rendering of the page. In the rare case that this
// occurs, let's log an error and exclude the entity type from the page.
$this->getLogger('og')->error('Error: the %entity_type entity type is not defined but is supposed to have group bundles.', ['%entity_type' => $entity_type]);
continue;
}

$bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity_type);
foreach ($bundles as $bundle) {
$rows[] = [
[
'data' => $definition->getLabel() . ' - ' . $bundle_info[$bundle]['label'],
],
[
'data' => Link::createFromRoute($action, 'og_ui.' . $type . '_form', [
'entity_type' => $entity_type,
'bundle' => $bundle,
'data' => Link::createFromRoute($action, $route, [
'entity_type_id' => $entity_type,
'bundle_id' => $bundle,
]),
],
];
}
}

$build['roles_table'] = [
$build['roles_permissions_table'] = [
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
Expand All @@ -108,7 +123,7 @@ public function rolesPermissionsOverviewPage($type) {
}

/**
* Title callback for rolesPermissionsOverviewPage.
* Title callback for rolesPermissionsOverviewPage().
*
* @param string $type
* The type of overview, either 'roles' or 'permissions'.
Expand All @@ -120,4 +135,25 @@ public function rolesPermissionsOverviewTitleCallback($type) {
return $this->t('OG @type overview', ['@type' => $type]);
}

/**
* Title callback for the roles overview page.
*
* @param string $entity_type_id
* The group entity type ID.
* @param string $bundle_id
* The group bundle ID.
*
* @return \Drupal\Core\StringTranslation\TranslatableMarkup
* The roles overview page title.
*
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
* Thrown when the entity type with the given ID is not defined.
*/
public function rolesOverviewPageTitleCallback($entity_type_id, $bundle_id) {
return $this->t('OG @type - @bundle roles', [
'@type' => $this->entityTypeManager->getDefinition($entity_type_id)->getLabel(),
'@bundle' => $this->entityTypeBundleInfo->getBundleInfo($entity_type_id)[$bundle_id]['label'],
]);
}

}