Problem/Motivation

It would be useful to be able to document on the site why a certain role exists.

Proposed resolution

Add a property "description" to the config entity type "user_role".

Remaining tasks

User interface changes

  • On /admin/people/roles a column "Description" is added to the role table.

    Before

    Roles list before

    After

    Roles list after

  • On the role edit page (for example /admin/people/roles/manage/anonymous), a description field is added.

    Before

    Role edit form before

    After

    Role edit form after

API changes

\Drupal\user\RoleInterface gets two new methods:

  • getDescription()
  • setDescription()

Data model changes

  • The config entity type "user_role" gets a new property called "description".
  • Upon installation of the user module, the roles "anonymous" and "authenticated" get a default description.
  • Upon installation using the profile "demo_umami", the roles "administrator", "anonymous", "authenticated", "author" and "editor" get a default description.
  • Upon installation using the profile "standard", the roles "administrator", "anonymous" and "authenticated" get a default description.
  • On a post update, the roles "anonymous" and "authenticated" get a description.

Release notes snippet

Original report by webchick

Kind of a sister issue to #228061: Usability UMN: Allow roles to be weighted in terms of role usability, I'd love the way to add *descriptions* to roles as well. This would be able to act as documentation for site admins as to 'why' a role exists.

CommentFileSizeAuthor
#100 drupal-256287-role-description-d10.patch4.74 KBmegachriz
#86 256287-config-condition.patch16.89 KBelfakhar
#85 256287.patch142.99 KBelfakhar
#83 256287.patch143.38 KBelfakhar
#81 256287.patch17.06 KBelfakhar
#74 interdiff_71-74.txt3.11 KBalanmoreira
#74 256287-74.patch96.62 KBalanmoreira
#71 interdiff_69-71.txt83.52 KBalanmoreira
#71 256287-71.patch93.16 KBalanmoreira
#69 interdiff_63-69.txt571 bytesravi.shankar
#69 256287-69.patch15.9 KBravi.shankar
#63 edit-role-after.png59.52 KBmegachriz
#63 edit-role-before.png40.2 KBmegachriz
#63 roles-list-after.png140.88 KBmegachriz
#63 roles-list-before.png125.78 KBmegachriz
#63 drupal-role-descriptions-256287-63.patch15.9 KBmegachriz
#53 interdiff_48-53.txt2.44 KBraman.b
#53 256287-53.patch79.62 KBraman.b
#48 interdiff_46-48.txt63.57 KBraman.b
#48 256287-48.patch76.89 KBraman.b
#46 interdiff_45-46.txt544 bytesridhimaabrol24
#46 256287-46.patch13.28 KBridhimaabrol24
#45 interdiff.txt885 bytespaulocs
#45 256287-45.patch13.08 KBpaulocs
#43 interdiff_38-43.txt3.42 KBridhimaabrol24
#43 256287-43.patch13.08 KBridhimaabrol24
#38 interdiff_37-38.txt5.02 KBridhimaabrol24
#38 256287-38.patch13.58 KBridhimaabrol24
#37 interdiff_35-37.txt1.79 KBridhimaabrol24
#37 256287-37.patch10.96 KBridhimaabrol24
#35 interdiff_32-35.txt1.13 KBridhimaabrol24
#35 256287-35.patch9.17 KBridhimaabrol24
#32 interdiff_27-32.txt488 bytesridhimaabrol24
#32 256287-32.patch8.04 KBridhimaabrol24
#27 256287-27.patch7.99 KBderekcresswell
#27 interdiff-256287-24-27.txt5.55 KBderekcresswell
#24 256287-role-description-24.patch5.6 KBgrahl
#18 roledescriptionnotpresent.png109.78 KBmeenakshig
#1 user-role-descriptions-256287-1.patch6.87 KBwebchick

Issue fork drupal-256287

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

webchick’s picture

Status: Active » Needs work
StatusFileSize
new6.87 KB

Here's a first stab. I had to change user_roles() to return $role rather than just the name, and haven't begun to track down all the places this broke things.

Also todo:
- The update hook adds descriptions to anonymous/authenticated, but this needs to be done in system.install too.
- We now need the ability to edit the autheticated/anonymous roles so that their descriptions can be changed.
- Probably some tests for user_roles().

lilou’s picture

Title: Allow role descriptons » Allow role descriptions

Patch still applied against CVS HEAD.

David_Rothstein’s picture

Subscribing. This seems like a really good idea.

rickvug’s picture

Issue tags: +Usability

Applying usability tag.

keith.smith’s picture

"autheticated" is a typo.

I like this patch. Descriptions for roles would be handy. I'd note that we have a couple of varying ways of showing examples in core; this one uses the 'Example: "authenticated user"' rather than the 'Example: authenticated user' approach. In another patch, one of these days, we should really conform these example strings to a single standard.

kika’s picture

Issue tags: +Needs screenshots

Needs screenshot

michaelfavia’s picture

@webchick: if theres no complaint im going to roll this new functionality into the UI redesign of the roles page #393406: "Edit" links on roles admin page are confusing to users: "Edit permissions" should be the primary link.I dont link multiissue patches but they are very interrelated. Im going to mimic the content types page for the design and operation which leaves the ease of extension for contrib modules on the "edit link" and still lets us mitigate the permissions link on this page while adding your new functionality. ill have a patch for review on the other issue today or tomorrow morning.

michaelfavia’s picture

Status: Needs work » Closed (duplicate)

@webchick: rolled your changes into the most recent patch on the issue above. also enabled editing of the "protected roles". your review and thoughts would be appreciated. the migration really simplified form validation and submission logic as well as creating a common UI that users already know from the content types page. im marking this issue as a duplicate but please revert if this isnt the best way to move forward.

David_Rothstein’s picture

Version: 7.x-dev » 8.3.x-dev
Issue summary: View changes
Status: Closed (duplicate) » Needs work

Let's reopen this since the other issue wound up considering those changes to be out of scope.

There is some code in the other issue too though (in addition to the patch above). I assume it's pretty far out of date at this point though :)

David_Rothstein’s picture

The linked issue is one way to do it (although probably not for Drupal 8).

David_Rothstein’s picture

The duplicate issue (#1835668: Add description field to roles) pointed out that there's a contrib module which does this: https://www.drupal.org/project/role_help

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

anybody’s picture

But does it really make sense to require a contrib module for something essential like that?
Every field has a description field for a very good reason > inline documentation. So if roles don't become fieldable entity in the future, there should be clearly a help text, I think!

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

meenakshig’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: user-role-descriptions-256287-1.patch, failed testing. View results

meenakshig’s picture

meenakshig’s picture

StatusFileSize
new109.78 KB

description field not present for roles

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

grahl’s picture

Status: Needs work » Needs review
StatusFileSize
new5.6 KB

Reviving this issue since the referenced module role_help has not been ported and roles aren't fieldable.

Here is a patch to bring role descriptions into the interface. Patch is against 8.9.2, will update if necessary.

Status: Needs review » Needs work

The last submitted patch, 24: 256287-role-description-24.patch, failed testing. View results

derekcresswell’s picture

Issue tags: +Needs tests
  1. +++ b/core/modules/user/config/install/user.role.anonymous.yml
    @@ -3,6 +3,7 @@ status: true
    +description: ''
    
    +++ b/core/modules/user/config/install/user.role.authenticated.yml
    @@ -3,6 +3,7 @@ status: true
    +description: ''
    

    We could probably provide these with descriptions, for completeness.

  2. +++ b/core/modules/user/src/RoleForm.php
    @@ -12,6 +12,13 @@
    +  /**
    +   * Role.
    +   *
    +   * @var \Drupal\user\RoleInterface
    +   */
    +  protected $entity;
    

    Poor naming choice / comment description.

    Edit: Not needed at all. This is declared in the parent class.

  3. +++ b/core/modules/user/src/RoleListBuilder.php
    @@ -64,6 +64,7 @@ public function getFormId() {
    +    $header['description'] = t('Description');
    

    Utilise $this->t within classes.

Tests need to be added for this issue.

derekcresswell’s picture

Title: Allow role descriptions » Give roles a description value
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.55 KB
new7.99 KB

Addressed all issues I outlined in #26.

Added tests for the description functions as well as the RoleListBuilder.

w01f’s picture

Just wondering if this new description field would be useable or somehow extendable to attaching specific images (media) to roles?

For example, if I wanted a different icon to represent different roles and to show the correct icon next to user names in a view (my specific use case).

longwave’s picture

@W01F I think you are looking for #775734: Role as fieldable entity, this will only allow adding a single text field to roles.

longwave’s picture

Status: Needs review » Needs work

Patch needs work as the tests failed entirely, also I don't think we can add methods to RoleInterface except in a major version jump as this is a backward compatibility break for anything that is currently implementing it.

derekcresswell’s picture

I'm unsure why the tests failed like that, I'll give it another look.

This only adds new features and most cases where someone has overridden the roles entity they would be using this as a base already. But you are correct, this could be pushed to 10.0 in that case.

ridhimaabrol24’s picture

Status: Needs work » Needs review
StatusFileSize
new8.04 KB
new488 bytes

Test groups arent generated due to missing @group annotation in the new test added. Fixing that.

derekcresswell’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/user/src/RoleListBuilder.php
@@ -72,6 +73,9 @@ public function buildHeader() {
+    $row['description'] = [
+      '#markup' => $entity->getDescription(),
+    ];

This is the only thing I don't like. I am not sure why it does not work without the markup.

Thank you for catching the group tag. : )

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 32: 256287-32.patch, failed testing. View results

ridhimaabrol24’s picture

StatusFileSize
new9.17 KB
new1.13 KB

Fixing test cases!

derekcresswell’s picture

core/tests/fixtures/config_install/multilingual.tar.gz needs to be updated. This is the cause for some of the test fails.

Still looking into how to fix the other errors caused by the configuration difference.

ridhimaabrol24’s picture

StatusFileSize
new10.96 KB
new1.79 KB

Trying to fix more tests!

ridhimaabrol24’s picture

StatusFileSize
new13.58 KB
new5.02 KB

Fixing the rest of the test cases!

ridhimaabrol24’s picture

Status: Needs work » Needs review

Moving to "Needs Review" as all the tests are now passing.

longwave’s picture

Status: Needs review » Needs work

Thanks for working on this!

  1. +++ b/core/modules/jsonapi/tests/src/Functional/RoleTest.php
    @@ -88,6 +88,7 @@ protected function getExpectedDocument() {
    +          'description' => null,
    

    NULL should be uppercase.

  2. +++ b/core/modules/user/src/RoleForm.php
    @@ -16,7 +16,10 @@ class RoleForm extends EntityForm {
    +
    

    Extra blank line at start of method.

  3. +++ b/core/modules/user/src/RoleForm.php
    @@ -49,10 +58,13 @@ public function form(array $form, FormStateInterface $form_state) {
    +
    

    Same

  4. +++ b/core/modules/user/src/RoleForm.php
    @@ -49,10 +58,13 @@ public function form(array $form, FormStateInterface $form_state) {
         // Prevent leading and trailing spaces in role names.
         $entity->set('label', trim($entity->label()));
    +    $entity->setDescription(trim($entity->getDescription()));
    

    Do we trim this for other descriptions? Do we need to update the comment to match?

  5. +++ b/core/modules/user/src/RoleInterface.php
    @@ -97,4 +97,22 @@ public function getWeight();
    +  /**
    +   * Returns the description.
    +   *
    +   * @return string
    +   *   The description.
    +   */
    +  public function getDescription();
    +
    +  /**
    +   * Sets the description to the given value.
    +   *
    +   * @param string $description
    +   *   The desired description.
    +   *
    +   * @return $this
    +   */
    +  public function setDescription($description);
    

    I had BC concerns but I think looking at the policy we are OK: https://www.drupal.org/core/d8-bc-policy#interfaces

    "Interfaces that are not tagged with either @api or @internal can be safely used as type hints. No methods will be changed or removed from these interface in a breaking way.

    However, we reserve the ability to add methods to these interfaces in minor releases to support new features."

  6. +++ b/core/modules/user/src/RoleListBuilder.php
    @@ -72,6 +73,9 @@ public function buildHeader() {
         $row['label'] = $entity->label();
    +    $row['description'] = [
    +      '#markup' => $entity->getDescription(),
    +    ];
    

    Why #markup for the description but not for the label?

  7. +++ b/core/modules/user/tests/src/Functional/Rest/RoleResourceTestBase.php
    @@ -52,6 +52,7 @@ protected function getExpectedNormalizedEntity() {
    +      'description' => null,
    

    NULL should be capitalised.

  8. +++ b/core/profiles/demo_umami/config/install/user.role.author.yml
    @@ -40,3 +40,4 @@ permissions:
    +description: null
    
    +++ b/core/profiles/demo_umami/config/install/user.role.editor.yml
    @@ -44,3 +44,4 @@ permissions:
    +description: null
    

    We should set some good descriptions for the Umami roles.

  9. +++ b/core/tests/Drupal/FunctionalTests/Installer/InstallerExistingConfigTestBase.php
    @@ -107,7 +107,11 @@ public function testConfigSync() {
    +        'user.role.anonymous',
    +        'user.role.authenticated',
    

    Is this only to make the tests pass? This feels like working around a problem that should be solved elsewhere.

longwave’s picture

+++ b/core/modules/user/src/RoleInterface.php
@@ -97,4 +97,22 @@ public function getWeight();
+  public function getDescription();
...
+  public function setDescription($description);

A further thought: should we drop NULLs, use empty string as the default, and add typehints on the methods?

#3154762: [policy, no patch] All new Drupal 10 code should use appropriate type hints wherever possible is not yet policy but is starting to be followed in other new features I think.

derekcresswell’s picture

I like the idea of using an empty string by default as opposed to NULL.

Good find on the interface documentation.

As for #40.6, I was not sure why the markup was needed but without it the rows would not render properly. Now I'm thinking it may have been the NULLs. If not, no idea.

#40.9, it's definitely skirting the issue. We'll need to find out how to have it come up as not changed.

ridhimaabrol24’s picture

StatusFileSize
new13.08 KB
new3.42 KB

Implemented suggestions from #40 except the 9th point. Still looking into the last point.

longwave’s picture

Do we also need to consider an upgrade path here? The descriptions should be set for anonymous and authenticated user roles on existing sites, I think.

paulocs’s picture

StatusFileSize
new13.08 KB
new885 bytes

Fixing code standard and set description = '' instead of NULL RoleResourceTestBase.php

It still needs work.

ridhimaabrol24’s picture

StatusFileSize
new13.28 KB
new544 bytes

Fixing few test cases!

ridhimaabrol24’s picture

In the failed test, the minimal profile gets installed and it picks the config from core/modules/user/config but it doesn't get the "description" field in it. Hence the test cases fail. I have checked this issue, the config in the user module is correct but in the tests, the new config doesn't get updated. Can someone suggest a step forward.
Thank you

raman.b’s picture

StatusFileSize
new76.89 KB
new63.57 KB

I think we need to update the configuration tarballs to fix the remaining tests

tests/fixtures/config_install/multilingual.tar.gz
tests/fixtures/config_install/testing_config_install.tar.gz

raman.b’s picture

Status: Needs work » Needs review

Triggering the tests

longwave’s picture

This is looking good, but I still think we need an upgrade path to add the description to anonymous and authenticated user roles, and tests for this.

paulocs’s picture

Status: Needs review » Needs work

Set to need work because of comment #50.

derekcresswell’s picture

raman.b’s picture

Status: Needs work » Needs review
Issue tags: -Needs upgrade path, -Needs upgrade path tests
StatusFileSize
new79.62 KB
new2.44 KB

Adding post update to add description to anonymous and authenticated user roles and a test for it

paulocs’s picture

Status: Needs review » Reviewed & tested by the community

Now patch looks good.
Set to RTBC.

longwave’s picture

Nice work, this looks really good now. RTBC+1

anybody’s picture

Great work, thank you all! This is a very helpful little improvement missing since Drupal 6 :)
RTBC+1

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

quietone’s picture

Issue summary: View changes
catch’s picture

quietone’s picture

Status: Reviewed & tested by the community » Needs work

Setting to NW for #59

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

megachriz’s picture

Issue summary: View changes
Issue tags: -Needs screenshots, -Needs issue summary update
StatusFileSize
new15.9 KB
new125.78 KB
new140.88 KB
new40.2 KB
new59.52 KB

I've tried to reroll the patch in #53 for the latest 9.3.x (and 9.4.x). This went mostly okay, except for the changes to tests/fixtures/config_install/multilingual.tar.gz and tests/fixtures/config_install/testing_config_install.tar.gz, from which I'm not sure yet how to update these. So I'm leaving this issue to "Needs work" because of that.

@raman.b
Can you re-add the changes needed for the tarballs?

I've also updated the issue summary and added screenshots.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

damiaosj’s picture

Assigned: Unassigned » damiaosj

I'll try to work on this.

damiaosj’s picture

Assigned: damiaosj » Unassigned

Sorry, I tried to work on this one but it's beyond my actual knowlege...

Changing the status to unassigned for someone with more experience take a look.

damiaosj’s picture

Assigned: Unassigned » damiaosj

Hi! I'll try to help on this one more time...

damiaosj’s picture

Assigned: damiaosj » Unassigned

Hi guys! Sorry... I really tried to help but didn't make it... So, I'm leaving for someone with more knowledge to work on...

ravi.shankar’s picture

StatusFileSize
new15.9 KB
new571 bytes

Fixing failed tests of patch #63.

alanmoreira’s picture

Assigned: Unassigned » alanmoreira

I'll work on this

alanmoreira’s picture

StatusFileSize
new93.16 KB
new83.52 KB

I was able to fix the problems on the "Installer" tests. Could not make any progress on the "Config" tests, though.

Leaving unassigned and as "Needs work".

alanmoreira’s picture

Assigned: alanmoreira » Unassigned
alanmoreira’s picture

Assigned: Unassigned » alanmoreira

I'll fix the #71 patch and the interdiff because i removed some tests that i should not have removed.

alanmoreira’s picture

Assigned: alanmoreira » Unassigned
StatusFileSize
new96.62 KB
new3.11 KB

Patch adjusted. Leaving unassigned.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anybody’s picture

2 years later I just saw this helpful one got stuck again as of #63.

So perhaps this should first be reviewed at a usability team meeting as of Needs usability review so we can do the right things here afterwards and finally fix this?

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

yoroy’s picture

Issue tags: -Needs usability review

It's a pity these nice little usabillitytweaks get stalled. I would say this is fine to continue with. Content types, vocabularies, media types, menus all have their own description field, it's perfectly reasonable and useful to add similar for roles.

Edit: screenshots look fine, with one remark: the description text for the description text field in the edit-role screenshot essentially duplicates the label, without adding any more helpful context. It could probably be left.

chris matthews’s picture

elfakhar’s picture

StatusFileSize
new17.06 KB

Adding a condition on configs to not add a description on a role when it does not exist

elfakhar’s picture

elfakhar’s picture

StatusFileSize
new143.38 KB
elfakhar’s picture

elfakhar’s picture

StatusFileSize
new142.99 KB
elfakhar’s picture

StatusFileSize
new16.89 KB
elfakhar’s picture

rkoller’s picture

Usability review

We've discussed this issue several times over the course of the last few months.

The first time we've discussed this issue at #3364446: Drupal Usability Meeting 2023-06-09. The link to the recording of the meeting is https://youtu.be/V_jT7Y9wWL8 . For the record the attendees at the meeting were @aaronmchale, @benjifisher, @emma-horrell, @rkoller, @simohell, and @worldlinemine.

We've revisited this issue at #3365687: Drupal Usability Meeting 2023-06-16. The link to the recording of the meeting is https://youtu.be/iriHrANnMKk . For the record the attendees at the meeting were @benjifisher, @blackbamboo, @rkoller, @shaal, and @worldlinemine.

The third and last time we've discussed this issue was in today's meeting at #3404028: Drupal Usability Meeting 2023-12-01. That issue will have a link to a recording of the meeting. For the record, the attendees at the usability meeting were @AaronMcHale, @anushrikumari, @benjifisher, @ckrina, @rkoller, @simohell, and @worldlinemine.

If you want more feedback from the usability team, a good way to reach out is in the #ux channel in Slack.

At first it has to be pointed out that there was a clear consensus right from the first meeting on that adding a description field to a role is a helpful and desirable addition.

The problem with the currently suggested descriptions is for one some sort of redundancy in the beginning of the sentences with "The role given..." or "The basic role give..." while the end of the sentences mostly mirrors the role name and doesn't add any extra value/information except for Anonymous users to a certain degree where it is stated that it is a role given to logged in users.

Therefore we've tried to come up with suggestions for the Anonymous user, Authenticated user, Content editor, and Administrator role during the three meetings as well as asynchronous discussions. It was sort of a rabbit hole if you are trying to get to a consensus for clear, concise, none redundant descriptions in plain language minding edge cases and scenarios. Three meetings plus asynchronous discussion in a Google Doc in between are testament to that. In today's call we came to the conclusion that this issue might "never" or at least not get in the near future. The missing consensus on the micro copy is just blocking a helpful and useful feature.

The group would suggest the following approach to proceed:

1. Make this issue only about providing/adding a description field to a role without adding a default description for any of the roles in the standard profile ( Anonymous user, Authenticated user, Content editor, and Administrator) and the additional roles for demo_umami (Author, Editor).

2. Move the work on the default role descriptions to a to be created follow-up issue.

3. In regards of micro copy the only thing left to change in this issue is the description for the description field on the role edit form. At the moment the description The description for this role. doesn't provide any value/information. It would be good to be inline with the proposed changes in #3365222: Make Description Field Labels Consistent:

For the field label use:
Description

For the field description use:
Displays on [the place where the description will be shown]

For a content type the description for the description is for example Displays on the Content types page. so analogous for the Roles page it would be Displays on the Roles page. there. That way the user knows where that information will be displayed and used.

rkoller’s picture

one addition to #88.2 after some post meeting followup conversation on slack yesterday. Ideally there should be three followup issues:

  1. Default role descriptions for the Standard profile
  2. Default role descriptions for the demo_umami profile ( compared to standard it is missing the content editor role but has Author and Editor instead)
  3. Discuss the implications if the user is changing the Administrator role on the role settings page (admin/people/role-settings). How should that change be handled in regards of the descriptions of the former Administrator role and the new Administrator role? Because if you change the Administrator role from the Standard or the demo_umami profile that Administrator role gets set back to the initial list of permissions which is actually none: https://git.drupalcode.org/project/drupal/-/blob/9.5.x/core/profiles/sta... . Therefore its description would have to be updated and reflect those changes otherwise it would be misleading and confusing to the user. That brings up also the question if you update the description for the former Administrator role to something reflecting that this role isn't an administration role anymore still having the name Administrator could also be potentially puzzling. There is also an existing issue that deals with the potential consequences of changing the Administrator role and the possibility of locking yourself out: #3293874: Prevent accidental lockouts on the Role settings page and clarify the corresponding description for its select box.
    Plus how to handle the description of the new Administrator role permission. Was that new role previously one of the Standard roles or a role newly created by the user? Is the old description for a role becoming the new Administrator role be stored in case the Administrator role is changed again? All details that would have to be discussed and minded in the followup.
anybody’s picture

Thanks @rkoller! Let's finish this. I think we should turn this into a MR for the last steps. I'll see what I can do in the next days. This will be a tiny, but very helpful addition!

jansete’s picture

I think that the most useful of having a role description is show this description in the roles checkboxes as description in the user form and be available for others contrib modules like role delegation.

\Drupal\user\AccountForm::form

$form['account']['roles']

anybody’s picture

@jansete yes! Any plans to proceed here as written in #89 + #90?

megachriz’s picture

Issue summary: View changes

It looks like that the list of remaining tasks is outdated. I tried to update it based on the information from #88.

I also looked in the code and I see the following:

  1. If we are going to remove default descriptions for now, we no longer need the test 'AddUserRoleDescriptionTest'.
  2. In RoleListBuilderTest::testListBuilder() I see the following:
    $this->assertSession()->pageTextContains($role->label());
    $this->assertSession()->pageTextContains($role->getDescription());
    

    I think that should be replaced with what is actually expected to be displayed on the screen:

    $this->assertSession()->pageTextContains('My Role');
    $this->assertSession()->pageTextContains('Lorem ipsum');
    

@anybody, @rkoller
Can you verify if the list of remaining tasks is complete? Did I forget something?

rkoller’s picture

I'll open a followup issue for #88.2 now. will update the issue summary here accordingly and link the issue as soon as the issue is created.

rkoller’s picture

Issue summary: View changes

I've created the follow up for #88.2, and updated the issue summary accordingly linking to #3470972: Create default role descriptions for the standard profile .

UPDATE: argh while now cross checking the question from @megachriz i've realized i'Ve forgot about my comment in #89. Need to update the issue and create a second one for umami as well. after that is done i will take another look if the rest of the remaining tasks is complete. apologies.

rkoller’s picture

Issue summary: View changes
rkoller’s picture

Issue summary: View changes

Based on #89 i've also created #3470976: Create additional default role descriptions unique to the demo_umami profile and updated the issue summary accordingly.

In regards of #93, i've made some additional slight adjustments to the issue summary. for the linked comments i've added a reference to the points made within the comment and i've added the point about #89.3 to the list of remaining tasks, that was missing so far. That way everything is covered that was raised in the ux meetings. @anybody might need to take another look if the rest of the remaining tasks looks also fine and complete.

jansete’s picture

This issue looks very nice, although we have to unify efforts if anybody need a temporary function avoiding conflicts with the final solution of this issue, I've implemented a little module: https://www.drupal.org/project/role_description

megachriz’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new4.74 KB

Since the latest patch no longer applied on Drupal 10.4.0, I've "rerolled" the patch into a MR. And with the following changes:

Also attached a patch for Drupal 10.4.0, with the changes to tests removed. The MR is based on Drupal 11.1.x.

Hopefully, it passes tests.

smustgrave’s picture

Status: Needs review » Needs work

Thanks

So MR should point to 11.x vs 11.1.x

Also with the change we will need an upgrade hook (plus tests) that sets the description to '' for all roles

megachriz’s picture

@smustgrave
Setting default descriptions was postponed to a follow-up, to reduce the complexity of this issue and and to increase the likelyhood of getting this done (less chance for merge conflicts). Does it then still make sense to set them to empty strings here? The code ensures that getDescription() returns an empty string when the property is not set. Or should each property of a config entity always be set?
Also, the update tests made things more complicated when rerolling patches.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.