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

FIX: Take into account language fallbacks for admin sidebar plugin links #27061

Merged
merged 1 commit into from
May 19, 2024

Conversation

martin-brennan
Copy link
Contributor

@martin-brennan martin-brennan commented May 17, 2024

This commit fixes an issue where I18n.lookup was being used to
check if a link had a valid I18n key when the addAdminSidebarSectionLink
plugin API was used. However this was imperfect -- usually when we do
I18n.t, we fall back to the default locale (en), but if
I18n.lookup is used we do not do this, so we were removing the link
needlessly.

This issue was identified via the plugin API's use in https://github.com/discourse/docker_manager

c.f. https://meta.discourse.org/t/new-admin-sidebar-wheres-the-update-discourse-button/308213/15?u=martin

This commit fixes an issue where I18n.lookup was being used to
check if a link had a valid I18n key when the `addAdminSidebarSectionLink`
plugin API was used. However this was imperfect -- usually when we do
`I18n.t`, we fall back to the default locale (`en`), but if
`I18n.lookup` is used we do not do this, so we were removing the link
needlessly.

This issue was identified via the plugin API's use in https://github.com/discourse/docker_manager

c.f. https://meta.discourse.org/t/new-admin-sidebar-wheres-the-update-discourse-button/308213/15?u=martin
Copy link
Contributor

@pmusaraj pmusaraj left a comment

Choose a reason for hiding this comment

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

Approving this, but I wonder if the extra check is necessary... IMO we should leave that responsibility to the plugin.

@martin-brennan
Copy link
Contributor Author

@pmusaraj yeah not sure, I keep flipping back and forth on this. I do think that plugins should not be able to make the UI look bad, so this is why I kept the check in core.

@martin-brennan martin-brennan merged commit f2cdc3b into main May 19, 2024
16 checks passed
@martin-brennan martin-brennan deleted the dev/fix-admin-i18n-sidebar-err branch May 19, 2024 23:41
@discoursebot
Copy link

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/new-admin-sidebar-wheres-the-update-discourse-button/308213/20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants