-
Notifications
You must be signed in to change notification settings - Fork 34
[BUG FIX] Language menu is showing despite only one language configured #491
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
base: master
Are you sure you want to change the base?
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideIntroduce an early exit in the language menu logic to skip rendering when a page only has one language and update tests to configure languages explicitly and validate this behavior. Flow diagram for language menu rendering logicflowchart TD
A["User requests page"] --> B["Get configured languages for site"]
B --> C["Get languages for current page"]
C --> D{"Are there at least 2 site languages?"}
D -- No --> E["Do not show language menu"]
D -- Yes --> F{"Are there at least 2 page languages?"}
F -- No --> E
F -- Yes --> G["Show language menu"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b0a6fd0 to
ded5458
Compare
ded5458 to
b889142
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #491 +/- ##
==========================================
+ Coverage 90.55% 93.67% +3.12%
==========================================
Files 72 76 +4
Lines 2732 2689 -43
Branches 322 0 -322
==========================================
+ Hits 2474 2519 +45
+ Misses 182 170 -12
+ Partials 76 0 -76 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats on your first PR! Left a couple comments from my point of view, perhaps @fsbraun has more.
|
@va-lang I have now installed the patch to check the UI. A new thought came to my mind and I would love to get your opinion on that:
What do you think of this alternative: Instead of hiding the menu, we also add the "add" and "remove" submenus in preview mode (inside The menu would be there and look something like this: Now there are things, the user can do, e.g. add a French version of the page. Let me know what you think! |
|
@fsbraun That’s a great point, I agree that showing an empty menu when there’s only one language doesn’t add much value, and extending it to include “Add” and “Remove” options in preview mode could make the behavior more consistent and user-friendly. Would update the PR |
|
@va-lang Thanks, well done! I am not sure of the overall logic, though. Here's what I would expect:
Finally, if the user cannot change the page, and only one language is available, shall we hide the language menu as anticipated in the beginning? |
|
|
||
| language_menu = request.toolbar.get_menu(LANGUAGE_MENU_IDENTIFIER) | ||
| self.assertIsNone(language_menu) | ||
| self.assertIsNone(language_menu, "Language menu should not be created if the page has only one language.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads up: we forgot to remove the modifications done to this test case. Just copypaste the code from the master branch to make sure it stays the same: https://github.com/django-cms/djangocms-versioning/blob/master/tests/test_toolbars.py#L499
Description
django CMS versioning "takes over" the language menu for pages.
However, unlike the behavior of the django CMS core, the language menu was being displayed even when only one language was configured.
Fixes DjangoCMS-#469
Related resources
cms_toolbars.py#L438-L46
Checklist
masterSlack to find a “pr review buddy” who is going to review my pull request.
Bug Fixes:
Fixes an issue where the language menu was displayed even when only one language was configured.