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

Roles en permissions commands #322

Merged
merged 46 commits into from
Jul 2, 2024

Conversation

nico8948
Copy link
Contributor

@nico8948 nico8948 commented Aug 29, 2023

Fixes #321
Added role.bee.inc for:
ROLES
permissions List all permissons of the modules.
pls, permissions-list

role-add-perm Grant specified permission(s) to a role.
rap

role-create Add a role.
rcrt

role-delete Delete a role.
rdel

role-remove-perm Remove specified permission(s) from a role.
rrp

roles List all roles with the permissions.
rls, roles-list

Copy link
Collaborator

@yorkshire-pudding yorkshire-pudding left a comment

Choose a reason for hiding this comment

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

Hi @nico8948

Firstly, please accept my apologies for leaving this so long. On the whole this looks look but a warning for the roles command, a few minor improvements, and some presentation issues that we need to to address:

permissions

The list of all permissions is a bit unwieldy as a table. Firstly, could we limit it to modules with permissions, and ignore the ones without? Secondly, I think how you have done it when the module option is used is much better. Perhaps, there could be a simple heading for the module followed by this list. Perhaps:

NODE
Permissions: 'bypass node access','administer content types','administer nodes', etc

roles

As above

Tests will probably need amending when these changes are made.

commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
tests/backdrop/RolesCommandsTest.php Outdated Show resolved Hide resolved
tests/backdrop/RolesCommandsTest.php Outdated Show resolved Hide resolved
tests/backdrop/RolesCommandsTest.php Outdated Show resolved Hide resolved
tests/phpunit.xml Outdated Show resolved Hide resolved
Copy link
Collaborator

@yorkshire-pudding yorkshire-pudding left a comment

Choose a reason for hiding this comment

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

Hi @nico8948

I've proposed a move away from both message based output and tabular output for permissions and the same will be true for roles .

I've proposed a number of changes that handle different scenarios and will provide the information in an easier to read format.

I've also requested that variables are named in full to be more meaningful rather than shortened words and shortened concatenated phrases. Hopefully this will be clear what's needed in other functions.

Thanks for your patience.

commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
tests/backdrop/RolesCommandsTest.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@yorkshire-pudding yorkshire-pudding left a comment

Choose a reason for hiding this comment

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

Hi @nico8948 - please can you apply same principles to roles_bee_callback() that I suggested (and you accepted) for permissions_bee_callback(). Namely:

  • output as text rather than table or bee_message
  • exception checking - check if role exists, error if not; if no permissions for role, then error and exit
  • comments throughout so it is easier to follow
  • Will need a corresponding change to test_roles_command_works()

Thank you. I think we're almost there.

Copy link
Collaborator

@yorkshire-pudding yorkshire-pudding left a comment

Choose a reason for hiding this comment

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

@nico8948 - a number of changes and clarifications needed.

commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
commands/role.bee.inc Outdated Show resolved Hide resolved
Copy link
Collaborator

@yorkshire-pudding yorkshire-pudding left a comment

Choose a reason for hiding this comment

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

All looks good except the test. Here is change. I will commit to get this over the line.

tests/backdrop/RolesCommandsTest.php Outdated Show resolved Hide resolved
Copy link
Collaborator

@yorkshire-pudding yorkshire-pudding left a comment

Choose a reason for hiding this comment

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

A few that were missed in your last review of feedback. Please address.

Comment on lines 127 to 131
}
bee_message(bt("The !role role has the following permissions granted: !permissions", array(
'!role' => $options['role'],
'!permissions' => $permissions,
)));

This comment was marked as resolved.

}
else {
$output = array();
foreach ($roles as $role => $value) {

This comment was marked as resolved.

@nico8948
Copy link
Contributor Author

nico8948 commented Jul 2, 2024

I really don't know what the issue was? sorry

@yorkshire-pudding
Copy link
Collaborator

I really don't know what the issue was? sorry

@nico8948 - if you look on this page, you can see those comments in context, with the original feedback:
https://github.com/backdrop-contrib/bee/pull/322/files#r1652581724
https://github.com/backdrop-contrib/bee/pull/322/files#r1652619561

@nico8948
Copy link
Contributor Author

nico8948 commented Jul 2, 2024

ok?

Copy link
Collaborator

@yorkshire-pudding yorkshire-pudding left a comment

Choose a reason for hiding this comment

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

Last one please. We don't need 2 lots of checking if permissions are empty.

commands/role.bee.inc Outdated Show resolved Hide resolved
Co-authored-by: Martin Price <[email protected]>
@yorkshire-pudding yorkshire-pudding merged commit 34475e5 into backdrop-contrib:1.x-1.x Jul 2, 2024
2 checks passed
@nico8948
Copy link
Contributor Author

nico8948 commented Jul 2, 2024

I'll drink a beer to that...

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.

Add node, menu, roles and permissions commands
2 participants