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
Add settings to allow multiple badges to be displayed #5378
Conversation
@DomLennonZA this is better suited as a plugin than being in core. |
@pichalite Wouldn't this then lead themes to have a dependency on a plugin? Right now, any user who does not want this functionality wont get it. I cant really see any harm in adding it to core. If thats the consensus though, I will move it out into a plugin. |
Not really. Based on the code in the PR, all user groups will be added to post data no matter what the ACP setting is. Also, if multiple badges setting is turned on in ACP... user level "Group Title" setting becomes useless. You may bot know this but NodeBB used to show all group badges but decided to remove it and move to only one badge because it's not easy to fit all the badges on the post. Takes up a lot of space on the post. |
@pichalite Your assumption here is incorrect. The |
I did not say Are you planning to send a PR with template changes to handle multiple badges in persona theme? |
If the theme wishes to use multiple badges, it should also handle the scenario where a user does not want multiple badges.
No, not unless @julianlam or @psychobunny want me to. This is purely for people who want to use this in their current or future templates and can be ignored if it is not needed. |
What about the group data always being included in the payload no matter what the ACP setting is for allowing multiple badges. Also as you said, this is for people who want multiple badges. So, a plugin makes lot more sense than adding this to core. |
Here are my thoughts:
With above, you then won't need to have a specific ACP setting to enable or disable multiple badges, the badges themselves will all be available for the theme to parse if it elects to do so. If you're worried about performance, drop in an LRU cache for group badge data, even... We do have to think of edge cases, however... what would a badge set look like with no badges? one badge? a hundred badges? (a million badges? -1 badges? 3.1415 badges? NaN badges? 😆 ) |
@julianlam Sorry, Im just trying to figure out what tasks should be done here? As far as I can see, performance shouldn't be an issue. Implementing a LRU cache seems a little overkill for this but can be done if deemed necessary. Secondly, if I understand correctly you are saying we should put all the user's groups into a single array and just push their selected group to the top of that array. While thats fine, this would break current templates. |
It doesn't have to break current templates. You add the field for the array, but you don't need to remove the field for the single entry. |
Yeah that is a good point @DomLennonZA, we'll have to introduce a new field for |
As others have mentioned |
Ok, I think my last commit handles most of the issues raised here. There is some work that needs to be done in the template for multiple badges to be shown(and for letting the user know that may actually be a thing). @barisusakli @julianlam any more changes you think should go in before I jump onto something else? |
@julianlam @barisusakli any additional comments? |
Can you remove the styling changes? What does selecting a group in the user profile page do? Does it move that group to the front of the Persona theme needs a change as well for this PR to make sense, without that this is not functional. Theme needs to check if |
@barisusakli Showing multiple groups is configurable in the ACP. When it is enabled, the user's For making the Persona changes. As I mentioned, this is optional and only for themes that want to display multiple badges. I am more than happy to do the work if you want this in the Persona theme, otherwise these changes wont affect the theme at all. What do you want? |
@DomLennonZA can you remove the styling changes in this PR and make a PR to persona to add the multiple badge template if it's enabled. You will have to expose |
@barisusakli Sorry, been caught up with other work. Will get onto this ASAP |
@barisusakli Styling changes are removed. Ill add the persona changes when this is in or would you prefer me to add them now? |
Yes please, we'd like to review both PR's at the same time, thanks :) |
@psychobunny @barisusakli Pull request submitted. I couldn't find a guide on the formatting practices but I hope this its OK. NodeBB/nodebb-theme-persona#351 |
Hi @psychobunny @barisusakli . Any update on this getting merged in? |
I had an idea about this, how about if Let's say I am a member of But I only want to display In the user edit page the template would change to
Let me know what you think? |
@barisusakli That sounds fine. Do we select all by default? |
@DomLennonZA I don't think they should all be selected by default, since |
Any updates on this @DomLennonZA ? |
This exposes a setting in
meta
to say whether all of a user's badges should be displayed. This also exposes all the user's groups in a property calledallGroups
incontrollers/topics.js
. Even though this setting exists, it still needs to be supported by the theme the user has. The default behavior of using the selected group still exists to ensure that no existing sites break.Re: #5338