Skip to content

DEV: Add various APIs and outlets to the themes config area #33385

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

Merged
merged 5 commits into from
Jul 1, 2025

Conversation

OsamaSayegh
Copy link
Member

No description provided.

@tgxworld
Copy link
Contributor

tgxworld commented Jul 1, 2025

@OsamaSayegh The test failures are legit. Can you have a look please?

@OsamaSayegh OsamaSayegh force-pushed the apis-limiting-themes-page branch from e8f2690 to 60d0d6d Compare July 1, 2025 07:06
@OsamaSayegh
Copy link
Member Author

This failure is quite interesting. So this PR adds a new plugin API to add custom cards to the themes grid. To make that work, we define a method in plugin-api.gjs that calls a function imported from a file in the admin bundle. This works fine for admins/staff, but for non-staff users who don't get the admin bundle, the site blows up when the plugin-api.gjs tries to import the file from the admin bundle.

Not sure what the best way is to fix this, but for now I've moved the relevant files out of the admin bundle into the discourse bundle.

* @param {AdminConfigAreaCard} adminConfigAreaCardComponent - The
* `AdminConfigAreaCard` class from core to be optionally used as a container
* for the card content.
* @returns {Component} - A Glimmer component class for the card to be added
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we return a Component here but a function. I think we can just leave the return value blank here since nothing we return to the function caller is of use.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm not following. What I'm trying to document here is what the callback function should return to us, not the return value of the addCardToAdminThemesGrid method itself. We need the callback function to return a component that contains the card content.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh ok I thought the callback function is usually documented above the function’s params. Let me check tomorrow.

Comment on lines 45 to 55
api.renderInOutlet(
"admin-config-area-components-empty-list-bottom",
class extends Component {
<template>
<div class="my-custom-empty-list">
Additional message shown at the bottom of the empty list.
</div>
</template>
}
);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
api.renderInOutlet(
"admin-config-area-components-empty-list-bottom",
class extends Component {
<template>
<div class="my-custom-empty-list">
Additional message shown at the bottom of the empty list.
</div>
</template>
}
);
});
api.renderInOutlet(
"admin-config-area-components-empty-list-bottom",
<template>
<div class="my-custom-empty-list">
Additional message shown at the bottom of the empty list.
</div>
</template>
);
});

Can you confirm but I don't think we need to return a component here and can just return the template.

Copy link
Member Author

@OsamaSayegh OsamaSayegh Jul 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, we don't need a full blown component here, a template will work just fine.

Comment on lines 3431 to 3440
* return class extends Component {
* <template>
* <adminConfigAreaCardComponent class="my-custom-card">
* <:content>
* <!-- your custom card content goes here -->
* </:content>
* </adminConfigAreaCardComponent>
* </template>
* }
* });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can simplify this example to return a <template> based onhttps://github.com/discourse/discourse/blob/eef0b47b4393ab2f6af1d910a3dcf1f14427b797/app/assets/javascripts/discourse/app/lib/plugin-api.gjs#L1312?

@OsamaSayegh OsamaSayegh merged commit 0ccf792 into main Jul 1, 2025
16 checks passed
@OsamaSayegh OsamaSayegh deleted the apis-limiting-themes-page branch July 1, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants