Overriding .gjs files - not possible?

Hello,

with a recent update one of our components broke. The component was previously extending the inline quote button which was quote-button.hbs. This file doesnt exist enymore - instead all the code was moved into a gjs file post-text-selection-toolbar.gjs and if I try to override it the “old way” the browser complains with the following message.

component-templates.js:62 [discourse/theme-48/discourse/templates/components/post-text-selection-toolbar] post-text-selection-toolbar was authored using gjs and its template cannot be overridden. Ignoring override.

Does that mean this piece of UI in Discourse can only be targeted by the defined PluginOutlets there?

  <PluginOutlet
                @name="quote-share-buttons-after"
                @connectorTagName="span"
              />

 <PluginOutlet @name="quote-button-after" @connectorTagName="div" />

What if I needed more control over the state of the buttons and the new ones added. I feel like this limits functionality.

Does anyone know how to handle that case?

3 Likes

Hello :wave:

I think this can be possible now with api.renderInOutlet ?

5 Likes

Hi @Sören_Geier - that’s correct, you’ll need to use plugin outlets to make changes in this part of the UI. Plugin outlets are a much more robust way to extend things, and will be more reliable across Discourse core updates.

If the existing Plugin Outlets don’t work for your use-case, then please let us know and we’ll be happy to look at introducing new ones.

In this case, you might be interested in the proposal in DEV: Add outlet and API for adding/controlling post selection buttons by keegangeorge · Pull Request #23782 · discourse/discourse · GitHub. This introduces a ‘wrapper plugin outlet’ which will allow themes/plugins to totally replace the core implementation if they need to.

This is an alternative way to render things into Plugin Outlets, yes. But it’s more of a code-style thing - it doesn’t actually introduce any new features when compared to /connectors/... files.

7 Likes