Problem/Motivation

In the URI "/admin/people", I found a Action dropdown for user list. There are the following options-

1. Add the Administrator role to the selected users

4. Remove the Administrator role from the selected users

people action dropdown

Proposed resolution

I think we can replace the "users" to "user(s)" for above options as others options (see attachment).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

imrancluster created an issue. See original summary.

imrancluster’s picture

Here is a patch. I have tested in my local environment. This patch will be applied after new installation.

imrancluster’s picture

Status: Active » Needs review
saurabh rawat’s picture

I have already tested this but it's not working even after clearing cache.

imrancluster’s picture

@saurabh rawat, If you apply the patch correctly then you have to reinstall your drupal site using updated code base. After that you will be able to see the changes.

saurabh rawat’s picture

You mean update.php or clearing cache will not work, I have to create new database and reinstall site.

imrancluster’s picture

Yes, after applying the patch, you have to create new database and reinstall site.

saurabh rawat’s picture

after reinstalling it is working but I don't think that it is right way as if someone is having drupal 8 site and S(he) wants to upgrade the version then they are not going to reinstall the site and change the database.

imrancluster’s picture

@saurabh rawat , I agree with you. Lets wait for senior advice. I am still learning Drupal 8 :)

cornelyus’s picture

Hi all,

A cache clear won't be enough on this case, because the label for administrator is actually saved in Database, "config" table with name "system.action.user_add_role_action.administrator".

Maybe a hook_update_N along with the label path, this could be done.

cornelyus’s picture

Tried to upgrade the label on hook_update_N, seemed to work in my tests.

tar_inet’s picture

#11It doesn´t work for me, you forgot to add the previous patch to yours. So , when a new role is added the option is still wrong.

Before applying #11

After applying #11

I merged both patched into one

renatog’s picture

Status: Needs review » Needs work
FileSize
90.29 KB
90.29 KB

Hi people

I applied the patch and the result is:

Zoom:

Good Work and Good Week.

Regards.

renatog’s picture

FileSize
29.51 KB
renatog’s picture

cornelyus’s picture

You're right @tar_inet .. i forgot to merge the 2. The patch I provided was for the exception situation reported before that it wouldn't change label for "old" roles.

tar_inet’s picture

#13 @renatog did you run the update.php? It looks like you haven´t.

tar_inet’s picture

Status: Needs work » Needs review
renatog’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
128.06 KB
32.88 KB

Hi people.

You are right @tar_inet

After run update.php works good for me. Follow screenshot with result.

Thank you very much for yours contributions guys.

Good Work.

Regards

cilefen’s picture

Status: Reviewed & tested by the community » Needs work

+1 for adding consistency to core! This issue needs a new title that explains the task succinctly because it becomes the commit message.

  1. +++ b/core/modules/user/user.install
    @@ -98,3 +98,30 @@ function user_update_8100() {
    + * Add user(s) to dropdown options for User list role add and remove.
    

    This comment will be a bit unclear when updates are executed. Is the update hook adding user(s) or "user(s)" to the dropdown option? I know the answer but I can imagine confusion. I think the dropdown can be referred to as "user actions". Why is "User" capitalized? Take a look at other hook_update_n comments for inspiration.

  2. +++ b/core/modules/user/user.install
    @@ -98,3 +98,30 @@ function user_update_8100() {
    +  // Config name prefix for plugin user_add_role_action.
    +  $config_prefix_add = 'system.action.user_add_role_action.';
    

    This comment isn't really necessary and neither is the variable. The same applies to the following comment and variable.

  3. +++ b/core/modules/user/user.install
    @@ -98,3 +98,30 @@ function user_update_8100() {
    +      $config_add->set('label', t('Add the @label role to the selected user(s)', array('@label' => $role_name)))->save(TRUE);
    

    We use the new array syntax now ;-)

  4. +++ b/core/modules/user/user.install
    @@ -98,3 +98,30 @@ function user_update_8100() {
    +      $config_remove->set('label', t('Remove the @label role to the selected user(s)', array('@label' => $role_name)))->save(TRUE);
    

    It should be "Remove the @label role from..."

_Archy_’s picture

Issue tags: +DCTransylvania
tar_inet’s picture

Title: Can we modify dropdown options for User list? » Change "users" to "user(s)" in user actions for consistency.
Status: Needs work » Needs review
FileSize
4.21 KB
1.85 KB

Thanks @cilefen, I hope this changes are better now

cornelyus’s picture

looks good to me!

kporras07’s picture

Status: Needs review » Reviewed & tested by the community

It works :D Marking as RTBC

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/interdiff-281072-22.txt
    @@ -0,0 +1,38 @@
    + ¶
    ...
    + ¶
    ...
    + ¶
    

    Trailing whitespace.

  2. +++ b/interdiff-281072-22.txt
    @@ -0,0 +1,38 @@
    +- * Add user(s) to dropdown options for User list role add and remove.
    ++ * Change "users" to "user(s)" in user actions for consistency.
    

    This should be a single line (but still less than 80 characters).

jansete’s picture

Status: Needs work » Needs review
FileSize
2.17 KB

Added the patch.

tar_inet’s picture

I messed it up, sorry. #26 @jansete patch looks good.

th_tushar’s picture

Added required proper comments.

tar_inet’s picture

It looks good to me.

jansete’s picture

This should be a single line (but still less than 80 characters).
#26 it's okay

renatog’s picture

Status: Needs review » Reviewed & tested by the community

Hi people.

#28 it's ok.

Good Work and Good Week.

Regards.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/user/user.install
@@ -98,3 +98,24 @@ function user_update_8100() {
+    $config_add = $config_factory->getEditable('system.action.user_add_role_action.' . $role_machine_name);
+    if (!empty($config_add->get('label'))) {
+      $config_add->set('label', t('Add the @label role to the selected user(s)', ['@label' => $role_name]))->save(TRUE);
+    }
+
+    $config_remove = $config_factory->getEditable('system.action.user_remove_role_action.' . $role_machine_name);
+    if (!empty($config_remove->get('label'))) {
+      $config_remove->set('label', t('Remove the @label role from the selected user(s)', ['@label' => $role_name]))->save(TRUE);
+    }

Hm, there is no guarantee that the configuration was created in the language that the update is running with, so this may break the strings in the configuration (make them appear in a different language then they should).

Also it is possible to customize this label isn't it? Why would we overwrite customized labels with our own?

cornelyus’s picture

I was under the impression that a configuration label should always be first and foremost in English, and translatable.

I am not sure about if "it is possible to customize this label"

Gábor Hojtsy’s picture

Issue summary: View changes
FileSize
60.64 KB

You can absolutely edit the action:

Forcibly updating the existing configured label to something else is IMHO not a good idea. If it was the same as the originally generated one, then *maybe*, but even then it might be best not to mess with the existing site IMHO.

cornelyus’s picture

thanks for pitching in :) @gabor .. I see it now.

My 2 cents.. maybe then just patch with the first original patch that only changed the string, and didn't do an hook_update to the label.. this would bring consistency for the newly installed core D8 for that particular label, right?

Gábor Hojtsy’s picture

Yeah I think so yes. There is also the problem of which language are these config entities getting created in but that is for another bug report :)

lomasr’s picture

I agree with Gábor, thanks for noticing. Applied the original patch in #2, it worked cleanly. Please see the screens. I am resubmitting the patch in #2 so that original patch comes on top.

lomasr’s picture

Status: Needs work » Needs review
faline’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
48.07 KB

I've tested and #37 is ok!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +String change in 8.4.0

Committed 4971d77 and pushed to 8.4.x. Thanks!

Funnily enough the actions aren't editable via the UI because #2605042: Cannot edit actions created by user_user_role_insert().

It's nice that these labels are not consistent with the other labels.

I'm crediting @saurabh rawat for testing the patch on existing sites and noting the lack of an upgrade path - even though there should not be an upgrade path it is always good to think about existing sites. I'm crediting @cilefen for the thorough review. I didn't credit @tstoeckler because their review was just very minor coding standards nits.

@kporras07 thank you for reviewing this issue! Just saying it works is not enough evidence for review credit. What we do need people to review is whether the issue has a correct scope, whether it passes the core gates, whether the solution completely fixes the problem without introducing other problems, and whether it's the best solution we can come up with. See the patch review guide for more information. When you do post a review, be sure to describe what you reviewed and how. This helps other reviewers understand why you considered the issue RTBC (and is considered for issue credit).

  • alexpott committed 4971d77 on 8.4.x
    Issue #2861072 by tar_inet, lomasr, imrancluster, cornelyus, jansete,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.