Could you break out the avatarImg method from the post widget? It seems to be a useful general way to include avatars in widgets.
It’s a little inconvenient to add new menus to the header widget because the widget contents are wrapped inside html in the render function. I ended up adding the quick message menu itself as another list item after the quick message icon.
edit I’m probably missing something, but there seems to be a similar issue for the Header Search Plugin. If I insert it after the home-logo widget, i.e. api.decorateWidget('home-logo:after' ... it ends up inside the title element, which leads to conflicts with the home-logo click event…
I’m wondering what the point of having widget events as separate from widget actions is? i.e. when would you use an event instead of an action?
Following your lead with the _notificationsChanged function, I put my observers for messages in the site-header component and then re-rendered all of the header widgets when the observer fires. This pattern doesn’t feel amazing. Thoughts on best practices in this kind of situation?
So the way I ended up handling this for now is by overriding the ‘click’ event in the home-logo and popping the routeTo function in a condition that checks if the target is the site logo
Sure I think that’s a good idea. I’m in the middle of other work right now but if you did a PR for that I’d accept it
What we could do is add a new decorator target in this case. Something like header:afterPanels. Then it could be added that way.
When you say events are you talking about browser events like click or the app-events? Both exist for different reasons.
It’s a serious downside of the widget approach - they are meant to only update when you interact with them. This is a pattern that came out of creating it for our post stream, where the vast majority of rendering only ever had to happen following a click of some sort. If your data is coming in via a different mechanism (say our message bus) I recommend you use the app-events to trigger a rerender. If your data comes in via interacting with the header you shouldn’t need to do anything. The observer thing was mostly there to simplify and reuse the previous code. If I coded it from scratch I would probably just use app-events for it.
Links to (when clicked): http://discourse.example.com/sample-page/
instead of: http://www.example.com/sample-page/
The HTML is correct, so I’m guessing the click handler does something funky.
EDIT: Thank you so much for adding this!
EDIT #2: I attempted to add permalinks to the Discourse instance to work around this and redirect to the correct external link. This however didn’t work it appears permalinks are not followed by the menu links, however permalinks are followed when the link appears in post content.