Display the roles of the logged-in user in the Web Debug Toolbar#42800
Display the roles of the logged-in user in the Web Debug Toolbar#42800fabpot merged 1 commit intosymfony:5.4from
Conversation
|
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
|
|
||
| <div class="sf-toolbar-info-piece"> | ||
| <b>Roles</b> | ||
| <span>{{ collector.roles|join(', ') }}</span> |
There was a problem hiding this comment.
Should we limit the output here? I'm afraid we break the toolbar for apps with many roles. 🙈
There was a problem hiding this comment.
was checking 😬 i have 200+ roles :}
There was a problem hiding this comment.
yes. It's a symptom of permissions-as-roles. In that sense ive no idea what a reasonable no. of roles is, nor about an average role name length. I do agree the current toolbar has limited UI to display many data.
There was a problem hiding this comment.
Yeah, good point - limiting would be a good idea. Do you have any preference about this. I would see the following options:
- showing the first m roles, and something like "and n more"
- having something like a modal that could be opened if there are more than m roles
There was a problem hiding this comment.
this should not only contain the number of assigned roles
hence i suggested to use a title attribute and avoid this discussion :)
There was a problem hiding this comment.
I like @ro0NL's suggestion of using the title attribute:
I think 1 role is a good threshold value 😄 . In this example screenshot, the user only has 4 roles and it already wouldn't fit the normal modal.
Also, I always recommend people to limit the number of roles a user has as close to 1 as possible. Maybe complex applications need 3+ roles, but generally you should be able to manage 1 or 2 roles if you split roles from permissions.
There was a problem hiding this comment.
i agree the dashed underline is likely enough to trigger a user hover, and go from there.
i'd opt out from a random number to display roles for
we could spare out "Logged in as" in favor of the "user icon" as in the toolbar itself, if it's not redundant already :}
we could spare out "Authenticated: yes" in favor of the negative edge case (eg. "Not authenticated" as a single badge)
"Action" looks redundant :) could be some "logout icon" too
last but not least, IIUC the title attribute is limited to 512 chars. Perhaps we should invent some CSS only tooltip util.
There was a problem hiding this comment.
Please keep this discussion focussed and discuss cleaning up other things in another issue/pr :)
I'm 100% in favor of keeping this as simple as possible. Let's not increase difficulty with CSS/js tooltips. The longest role I've seen is Symfony's own ROLE_PREVIOUS_ADMIN, which is 19 characters long (meaning a user can have 24 roles before the title attribute overflows).
There was a problem hiding this comment.
I never implied "JS". We have a hard limit on title attributes.
edit: the 512 limit is IE only it seems. Max-width is default on title attributes ... let's do that 👍
ec98d71 to
1460732
Compare
|
@ro0NL Can you test this PR with your 200+ roles app? 🙃 |
|
Thank you @NicoHaase. |
… Toolbar -- bugfix for two roles (NicoHaase) This PR was merged into the 5.4 branch. Discussion ---------- Display the roles of the logged-in user in the Web Debug Toolbar -- bugfix for two roles | Q | A | ------------- | --- | Branch? | 5.4 for features | Bug fix? | yes | New feature? | yes | Deprecations? | no | Tickets | Additional fix for #42763 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> The first commit from #42800 did not work properly if there are exactly two roles assigned to the logged in user (as then, the first would be shown, but not the "and n more" span). This PR fixes this issue Commits ------- 895df9f Display the roles of the logged-in user in the Web Debug Toolbar -- bugfix


This PR adds the roles of the logged-in user to the WDT