Skip to content
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

DEV: Resolve a compatibility issue in core with CustomHtml component #54

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion javascripts/discourse/components/right-sidebar-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import Component from "@glimmer/component";
import { getOwner } from "@ember/application";
import { tracked } from "@glimmer/tracking";

const componentNameOverrides = {
// avoids name collision with core's custom-html component
"custom-html": "custom-html-rsb",
};

export default class RightSidebarBlocks extends Component {
@tracked blocks = [];

Expand All @@ -11,7 +16,12 @@ export default class RightSidebarBlocks extends Component {
const blocksArray = [];

JSON.parse(settings.blocks).forEach((block) => {
if (getOwner(this).hasRegistration(`component:${block.name}`)) {
block.internalName =
block.name in componentNameOverrides
? componentNameOverrides[block.name]
: block.name;

if (getOwner(this).hasRegistration(`component:${block.internalName}`)) {
block.classNames = `rs-component rs-${block.name}`;
block.parsedParams = {};
if (block.params) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{{#each blocks as |block|}}
<div class={{block.classNames}}>
{{component block.name params=block.parsedParams}}
{{component block.internalName params=block.parsedParams}}
</div>
<PluginOutlet
@name="below-right-sidebar-block"
Expand Down