Problem/Motivation
Sometimes you know a machine name for a permission but can't find it on the permissions page (mismatch, translation, etc).
It'd be nice to be able to easily search by machine name, but those strings are only available if you view source and really know what you're searching for. Not good for folks trying to develop custom or contrib modules and debug what they're doing, etc. See #53 for more.
Sadly, this is one of the most busy forms/pages in Drupal, so we don't always want to see that unless we need to.
Proposed resolution
Optionally display machine names.
A) Via an inconspicuous JS link to toggle (along the lines of "show row weights" vs. table drag) next to the existing toggle to show/hide the descriptions. #62-#64. See mockup in #71.
B) Via an advanced setting somewhere (e.g. Add a "Development" field group at /config/people/accounts with a checkbox to opt-in) #57
C) Always display. Working patch in #47.
Remaining tasks
Decide on an approach- Update tests and code
- Review
- RTBC
- Commit
User interface changes
(Conditionally?) display machine names on the permissions page.
Exact mechanism TBD.
API changes
None.
Data model changes
None.
Release notes snippet
TBD.
Original report by @RoySegall
Hello everyone.
There was an idea that came up in the office - display the machine name of the user permission near to the check boxes.
This is good when we write a test or developing a module.
Comment | File | Size | Author |
---|---|---|---|
#92 | 1734534-89.patch | 3.82 KB | Prashant.c |
#76 | toggle-perm.gif | 151.44 KB | eiriksm |
#76 | 1734534-76.patch | 4.13 KB | eiriksm |
#68 | field-list-overview.png | 223.54 KB | webchick |
#53 | Screenshot 2019-08-01 at 07.41.31.png | 24.95 KB | eiriksm |
Issue fork drupal-1734534
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
Comment #1
RoySegall CreditAttribution: RoySegall commentedComment #2
kalabroGood idea, but I think it will be better to introduce this feature in more appropriate module. Take a look at Fast Permissions Administration for example.
And yes, it can be easily done with Javascript, without preg_match.
Comment #3
salvisWe already have mouse-over hints to display that information. This is enough IMO, and I don't like adding more always-visible stuff to the badly overloaded permissions page:
BTW, there's trailing white space:
Comment #4
kalabro@salvis, I didn't know that we already have something like this. Could you please explain how to turn it on? I don't see any stuff from your screenshot on latest devel 7.x-1.x.
Thanks!
Comment #5
RoySegall CreditAttribution: RoySegall commentedBut you can't copy and the past the machine name to your IDE
Comment #6
salvisIt's the Display machine names of permissions and modules setting.
True, but that's not enough of a reason to further mess up the permissions list.
Comment #7
RoySegall CreditAttribution: RoySegall commentedI can add a check box in the devel setting if the user would like to see the permission
Comment #8
kalabroOh! Sorry, I didn't notice that option. Is this option really helpful or maybe we can make it better? When I need permission machine name I usually go to permissions page, inspect checkbox and copy it's value.
Let's see how Drupal core do:
Isn't it nice and tidy?
We can rename option and do the same:
Permissions (tested with and withoout fpa, admin_menu):
Modules (tested with and withoout admin_menu, module_filter):
Initial patch attached without PHP comments modification. If it is not a mess, we can finish it after @salvis review.
Comment #9
kalabroComment #10
RoySegall CreditAttribution: RoySegall commentedDidn't Understand anything for your post. Can you explain a little bit more?
Comment #11
kalabro@RoySegall, sorry for my English.
Shortly, I suggested a patch based on your idea and Drupal core styles. Now Devel's option "Display machine names of permissions and modules" allows to print machine names instead of adding title attribute.
Comment #12
RoySegall CreditAttribution: RoySegall commentedAre you in Munich? Would like to talk with you face to face about that. If not close the issue.
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedThanks for attaching that screenshot from the content types page. I see no reason why content should get this treatment but not permissions. So, I think this is a valid feature request and that Drupal core should implement it. Moving issue from devel to drupal core.
if core rejects this for some reason, we can move this back to devel.
Comment #14
salvisIt's not just the permissions machine names, but also the module machine names. I like seeing those on both the modules and the permissions pages (the screenshots missed the latter), because they can differ quite a bit from the user-facing module names.
Comment #15
kalabroThe same patch as #8, but for Drupal 8.x core.
Comment #16
kalabroThe patch #15 still applies correctly.
Any thoughts about that?
Comment #17
jibran#15: drupal-core-show-permission-machine-name-1734534-15.patch queued for re-testing.
Comment #18
jibran#1892872: Add title attribute to modules administration page closed as duplicate.
Comment #20
kalabroThe same patch again.
New screenshots:
Comment #21
RoySegall CreditAttribution: RoySegall commented@kalabro looks great but i don't understand the second image and how it relate to the issue.
Comment #22
kalabro@RoySegall,
#14:
Comment #23
Fabianx CreditAttribution: Fabianx commentedSounds like a task to me.
Comment #24
webchickI agree w/ task category, tagging as Usability.
I can see the value of doing this on the modules page, esp. since it's hidden by default and only available if you explicitly ask for more details. It's also something useful for site builders to know at various points (e.g. upgrades, troubleshooting searches...). The permissions page OTOH clutters thing up quite a bit, unfortunately. :( Especially since in many cases the human-readable vs. machine-readable will be exactly the same, just lowercase. And I can't really think of a site builder use case for exposing machine names for permissions; this seems much more like a developer-facing feature, so maybe a patch to Devel module instead?
Comment #25
webchickOh, lol ... it started there. ;) Funny.
Comment #26
RoySegall CreditAttribution: RoySegall commented@webchick This is was originally for devel but moshe decided to change it. Any way, there some machine names that don't look the same as the human name, i saw a lot of permission that look like these: user can edit commerce_kickstart_orders that in fact the human readable name is: User can edit Commerce Kikcstart orders(There is no permission like these, but you got the point).
Comment #27
webchickYes, of course, but what's the use case for showing this developer-focused information on a predominantly site builder-oriented screen (the permissions page gets visited every time a module is enabled, every time a new role is created, etc.)?
Comment #28
RoySegall CreditAttribution: RoySegall commentedEvery time we(and i mean we, i mean every drupal developer that need to use the permission name) we look on the name of the check box. These thing can be useful for developers so i don't see why it need to be part of the core. On the other hand, if some will see these small line that display the machine he will say - "Cool :)" (and smile, i promise that).
Any way, who ever access the permission page is the a manager and it won't harm if he could see that.
Comment #29
jibran+1 for all the changes done in #20. And can we accommodate comment from #1848064-50: Allow to filter modules by arbitrary search strings on the Modules page?
Comment #30
pcambraHere's a plain reroll of #20
I feel that the machine name besides every permission is quite intrusive if you're actually not interested in that information, it might be confusing, and clicking on hide description doesn't hide this.
For the record, currently Devel shows the machine name on top of the permission in a tooltip.
I like what the modules page does with a fieldset on the description... what about adding a "See description link" that expands the description, machine name and warning for the permission page?
Comment #32
pcambra#30: drupal-core-show-permission-machine-name-1734534-30.patch queued for re-testing.
Comment #33
hefox CreditAttribution: hefox commentedVisually looks good, and tested it on d7 w/ patch -p2 < drupal-core-show-permission-machine-name-1734534-30.patch and works. It defiantly adds more visual clutter though, but defiantly useful for developers.
Comment #34
RoySegall CreditAttribution: RoySegall commentedAre we still running with this ? :S
Comment #35
jibran30: drupal-core-show-permission-machine-name-1734534-30.patch queued for re-testing.
Comment #37
RoySegall CreditAttribution: RoySegall commented@jibran This patch needs a re roll first before retesting him and i also not sure if this path will be committed any time at all.
Comment #38
joachim CreditAttribution: joachim commentedThis probably belongs in devel module rather than core.
Comment #39
RoySegall CreditAttribution: RoySegall commented@joachim It's started as an add on for devel but it's moved to core.
Comment #44
jibranComment #47
eiriksmRenaming this since we already show machine names on the module page now.
Updated patch. This would be a great UX improvement. For translated pages, it's just really really bad UX that you can not search up the string you know should be there (since it is translated).
Comment #49
joep.hendrix CreditAttribution: joep.hendrix at CompuBase Internet Solutions commented#47 installs nicely and works perfectly.
Thank you!
Comment #50
firfin CreditAttribution: firfin commentedFeels like a great improvement to DX to me. Had no idea where to find the permission names I needed to use.
Comment #51
larowlan@webchick's question regarding whether this is warranted in core for the permissions page is not yet answered
I'll ping the product managers
Comment #52
webchickYeah, sorry, I still agree with 6 years ago me (funny that :P) that a) this clutters up the page tremendously and b) there hasn't yet been a defined use case for why a site builder (this is a site builder page) needs to have these machine names in their face all of the time. If you want additional opinions, you could also bring it to a UX team meeting on a Tuesday, but they'll probably have similar feedback.
A compromise could be a tooltip approach that is screenshotted in #3. Then the developer use case we're trying to solve of "I need to quickly know the machine name of this particular permission because it might be different from what's printed here" could be solved, without making the most visually heavy page in Drupal even heavier.
Comment #53
eiriksmI agree that those use cases are just small convenience things, and might not warrent what may seem like cluttering. But there is one other use case that I tried to shortly describe earlier, but I will be very elaborate here :)
Imagine Robin, a developer. They just got a ticket saying administrators can not access a certain path. Now Robin is a seasoned Drupal developer, and suspects this might be a permission problem. They quickly find the permission in question:
Now, with this patch applied, all they have to do is copy that text, CTRL-F on the permissions page, and immediately see the role was missing the permission. Bug solved in under 2 minutes :)
Now let's look at the debug session without the patch applied:
Robin goes to the permissions page, but the page is in Norwegian. So even if they suspect the string might be something like "Administer taxonomy" they have no idea what is going to be displayed here:
As I said, they are a pretty seasoned Drupal developer. They suspect this permission might come from the taxonomy module. So they open the file taxonomy.permissions.yml:
Now I actually wanted to make another point by using this permission. And that is the fact that knowing the "machine name" of a permission does not equal knowing what will be listed in the permissions page. So even if the site was in English I would probably have to open this file to find out what the actual permission was. So it is not just an issue with multilingual sites. But I digress from our story of the developer with the ticket. Robin now knows the English string for the permission. They go to "Translate interface", search up the string, and finds out the Norwegian translation is "Administrer vokabular og termer". They can now check the permission page. And surely enough, the role was missing the permission.
Bug solved for Robin, but not so easy. The steps needed was:
Robin ponder the complexities, and either use that new found frustration to create cat memes of the Drupal permission system, or create a patch :)
I also want to point out: This is when you are a seasoned Drupal developer. I can only speculate how one would struggle if they did not have the knowledge required to end up with the correct string. I am assuming people would just add permissions until it worked. Which is not something we want to encourage.
Hope that can justify adding more things to a very, very long page, and that it would solve things more than clutter, hopefully.
Comment #54
webchickI mean, as a seasoned developer myself, I would just view source on the permissions page and cmd+F for "administer taxonomy" and tada.
Comment #55
webchickBut as said, I don't have a problem with this being added to Devel module as a feature, as I can see its use for the developer audience. If you want it in core though, we need to always prioritize the least technical users' needs, and in this case it's the site builder vs. the developer.
Would a tooltip help Robin in this case? He (or she ;)) could probably narrow it down to something in the "Taxonomy" group and then it's another 3-5 seconds to hover over a few of the possible options there.
Comment #56
moshe weitzman CreditAttribution: moshe weitzman as a volunteer commentedDevel rarely mucks with the HTML/forms of Drupal pages. It just adds pages/blocks/menus. I'm not inclined to start doing that as HTML/forms are not APIs and can change at any time.
Comment #57
dwwHow about an advanced setting you can turn on somewhere in core to opt in to seeing the machine names?
(e.g. Add a "Development" field group at /config/people/accounts with a checkbox for seeing this?)
Comment #58
webchickIf you want to add an ideas queue issue for putting a Devel module "lite" in core, be my guest. :) But we're not adding all of that here for this particular screen/feature, IMO.
Comment #59
dww@webchick re: #58: I'm not proposing an entire "devel lite in core", I'm proposing a single checkbox on an existing settings page to enable this functionality to aid developers. But that's clearly "won't fix" already, so I won't spend the effort.
I'm leaning toward "won't fix" for this issue, since it seems neither core nor devel will accept this feature. I don't want anyone else to waste any more time on it if it's doomed. @webchick: would you be willing to do that if that's your assessment as a product manager?
Comment #60
webchickI still seem to not be getting an answer to the "compromise" question, which is whether we can do a tool tip on hover instead. I feel like that would solve everyone's problem. The permissions page is no less cluttered for site builders, but developers have an easy way to determine the machine name of a permission without resorting to digging around in source code.
Comment #61
webchickThat approach may have accessibility concerns, however, so tagging.
Comment #62
dww@webchick re: #60 and the "compromise" solution, I don't think that really helps. If I'm "Robin" from #53, and I know the machine name I care about is "administer taxonomy", I definitely do not want to hover over 300+ different rows searching for a tool tip that shows the text I'm looking for. I want to search for it, but I can't search if it's hidden in a tooltip.
If I'm Robin, I'd much rather enable a checkbox on the appropriate config form (*cough*) ;) that reveals all the "clutter" on the permissions page so that I can do a simple cmd+f, paste "administer taxonomy" and immediately go to the row I need to mess with.
Another idea: what if it's a JS toggle thingy along the lines of "show row weights" vs. table drag? By default the machine names are hidden via CSS, but if you click the "show machine names" link at the top of the page, voila! Happy Robin! Happy webchick? ;)
Cheers,
-Derek
Comment #63
dwwComment #64
dwwThe toggle link could be next to the existing "Hide descriptions" link...
Comment #65
joachim CreditAttribution: joachim as a volunteer commented> I still seem to not be getting an answer to the "compromise" question, which is whether we can do a tool tip on hover instead.
Another reason the tool tip is no good is that you can't copy-paste the tool tip text.
Comment #66
dwwre: #65: Agreed.
Even though this is technically NW to make "optional" a viable patch, I'd still like product manager review before anyone actually spends more time working on this. Let's agree on a plan before any more coding. Back to NR.
Thanks,
-Derek
Comment #67
larowlanComment #68
webchickCool, I appreciate the brainstorming.
Yep, good points for why a tool tip doesn't work for Robin. This JS toggle option still adds more stuff (YET ANOTHER CHECKBOX LOL :)) to the permissions page which we'd really rather not do, though. :\
Not necessarily ruling that suggestion out, but just to counter-brainstorm a bit. ;) You know how we have a "Field list" page in the admin/reports section, which provides an overview of field usages? Would a similar "permission overview" page with the machine names exposed on it work for that? That would clearly be targeted at the developer/more technical site architect vs. the "day to day maintenance of site" audience.
We could also take this brainstorming to the weekly Drupal UX team call, which happens Tuesdays at 12:30pm Pacific time in #ux on Slack.
Comment #69
dwwCounter-counter-brainstorming... ;)
#64 proposes: Adding 3 more words ("Show machine names"), right next to 2 existing words ("Hide descriptions") that provide very similar functionality, and then make this form a lot easier to use for developers.
To avoid the 3 new words (IMHO, an extremely small price to pay), #68 proposes an entirely separate report, new route (requiring entirely new tests, tons of sign-off, etc). The result of the separate report is a "translation" page that converts a string you know you're looking for into the string(s) that will be visible on the form you actually have to navigate to set the right permissions. Robin now has to have 2 windows open, and switch back and forth, copy machine name, paste into the search box (browser or native) on the translate report, copy the resulting display name, toggle back to the form they have to use, search + paste display name, lather, rinse, repeat. Meanwhile, non-developer site admins have to wonder WTF this "report" is telling them. We get to bikeshed all the usability WTF of a "report" that doesn't report anything, but is simply a translation tool for developers.
If we're going to do all that (ugh), let's add devel-lite to core. ;)
Or let's not. Let's just add "Show machine names" to the permission page. :) Most people won't even notice (I nearly missed "Hide descriptions"), the ones who care will be grateful that it's a simple toggle to easily and elegantly solve a known DX-wtf that's pissed them off for (at least) 7 years...
Cheers,
-Derek
Comment #70
webchickHaha, fair. Yeah, it's possible a toggle link in the same style as "hide descriptions" could work. I'll raise it on the UX call tomorrow if there is time.
Comment #71
webchickOk, reports back from the UX meeting! https://youtu.be/EwnuMzqE9mw?t=1979 is approximately when this discussion starts. (Sorry, it's slow to get going because I can't run a meeting and prep a presentation at the same time ;))
Sounds like there was agreement that the extra toggle should work! Suggestion was though rather than putting it to the side, put it down below the title so as to make it more scannable, so like:
Hide descriptions | Show machine names [should be off by default]
---
Administer blocks
administer blocks
...
Administer comment types and settings
administer comments
Warning: Give to trusted roles only; this permission has security implications.
...and so on.
Comment #73
webchickAlso crediting @AaronMcHale and @dww for their work on the compromise! (Others I'm sure need credit as well; just handling the UX credit for now.)
Comment #74
dwwRe: #71: Fantastic! That looks exactly like what I was trying to propose in #64, what I had added to the summary as option A. Sorry if that wasn't clear, already.
Yay, so I'm crossing off "Decide on an approach" from the remaining tasks. Progress! I think we've rescued this issue from the jaws of "won't fix". Huzzah. :)
@webchick: I'm assuming you're not planning to do any of the rest of those steps, and I don't think it requires any further product manager review (at least not at this time), so I'm unassigning you for now. If anyone plans to work on the patch and convert #47 into the proposed toggle, please assign yourself so no one duplicates effort.
Thanks, all!
-Derek
Comment #75
eiriksmFantastic!
I think I can speak for Robin (very glad my gender neutral name got recognition through a he (or she) comment btw) and say that they are very happy with this. Whipping up an initial patch.
Comment #76
eiriksmInitial patch. My javascript is probably not modern enough to do things correctly, but this certainly works :p
Animation of the result also attached. Was it something like this you had in mind?
Comment #77
dwwGreat, thanks! Almost there.
Thanks!
-Derek
Comment #78
joachim CreditAttribution: joachim as a volunteer commentedMight be a good idea to store the user's choice for this in the same magical way that 'show row weights' is stored, so it persists between page loads.
Comment #79
tstoecklerGreat to see progress on this, very exciting!
Some more notes on the patch itself:
Since this link only works if the client has JavaScript, it should have the "js-show" class.
Because the permissions page can get very (!!!) large, we should try to avoid any JavaScript that reacts to each permission on page load as that will lead to suboptimal performance and browser repaint with a few thousand permissions. Instead I think the machine names should just be hidden by default via CSS, i.e. the "hidden" class.
Comment #80
eiriksmAwesome suggestions and feedback. Unassigning for now, if someone wants to keep this going in the next days :)
Comment #91
Prashant.cI had created this duplicate issue https://www.drupal.org/project/drupal/issues/3413413, completely missed this one.
Tried to patches submitted above but were failing therefore created a new patch and a MR for the same by using mostly the changes from https://www.drupal.org/project/drupal/issues/1734534#comment-13222756
Assigning for review.
Thank you.
Comment #92
Prashant.cForgot to attach the patch file in the previous comment, attaching now.
Comment #93
smustgrave CreditAttribution: smustgrave at Mobomo commentedPreviously tagged for tests which are still needed.
Please take a look at the tags before moving to Needs Review thanks!
MR has a failure too, no need to attach a patch with MRs a patch file can be generated from the MR. Now we have patches and MRs which slows reviews.