8000 anonymous user should be able to see cpp/java but cannot select it by smallst · Pull Request #7955 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

anonymous user should be able to see cpp/java but cannot select it #7955

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 re 8000 lated emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 30, 2025

Conversation

smallst
Copy link
Contributor
@smallst smallst commented Apr 1, 2025

fancy-select doesn't show the disabled item.
so get rid of this old package and use alternative chioces.js

fix ENG-1729
image

Summary by CodeRabbit

  • New Features

    • Improved language and code format dropdowns with enhanced styling and usability using Choices.js.
    • Added a custom styled language selection tab for a more polished interface.
  • Refactor

    • Replaced the previous dropdown implementation and styles with a modern solution for better user experience.
    • Updated templates and styles to support the new dropdown structure and appearance.
  • Chores

    • Removed legacy dropdown scripts and styles that are no longer in use.
    • Updated dependencies to include Choices.js.

Copy link
Contributor
coderabbitai bot commented Apr 1, 2025

Walkthrough

This set of changes replaces the custom "fancySelect" dropdown implementation with the Choices.js library for language and code format selection in the play UI. It removes the legacy jQuery-based plugin and its associated CSS, updates the JavaScript logic to instantiate and manage Choices.js instances, and adjusts SASS and Pug templates to match the new structure and styling. The package.json is updated to include Choices.js as a dependency, and custom SASS is added for the new dropdown style.

Changes

Files/Paths Change Summary
app/views/play/common/ChangeLanguageTab.js Replaces fancySelect plugin usage with Choices.js for dropdowns, manages Choices.js instances, updates event handlers, and adjusts DOM selectors.
app/styles/play/common/change_language_tab.sass Adds new SASS styles for the custom language selection tab, targeting Choices.js structure and appearance.
app/styles/play/modal/play-heroes-modal.sass Removes import of fancy_select.css, renames selectors from .fancy-select to .my-fancy-select, updates nested selectors, and tweaks styling for the new dropdown.
app/templates/play/common/change-language-tab.pug Wraps the select in a .my-fancy-select container and updates option tags for compatibility with Choices.js.
vendor/scripts/fancy_select.js Removes the legacy jQuery/Zepto fancySelect plugin implementation entirely.
vendor/styles/fancy_select.css Removes the legacy CSS for the fancySelect dropdown.
app/vendor.js Removes the import of fancy_select.js from the vendor bundle.
package.json Adds Choices.js as a new dependency.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ChangeLanguageTab
    participant Choices.js

    User->>ChangeLanguageTab: Interacts with language/code format dropdown
    ChangeLanguageTab->>Choices.js: Initializes or destroys Choices instance as needed
    Choices.js-->>ChangeLanguageTab: Renders enhanced dropdown UI
    User->>Choices.js: Selects a language/format
    Choices.js-->>ChangeLanguageTab: Triggers change event
    ChangeLanguageTab->>ChangeLanguageTab: Handles selection logic and updates state
    ChangeLanguageTab->>Choices.js: (If needed) Rebuilds dropdown
Loading

Assessment against linked issues

Objective Addressed Explanation
Show premium-only languages (cpp, java) before premium paywall for visibility (ENG-1729) The refactor changes dropdown UI but does not explicitly implement or clarify ordering or visibility logic for premium-only languages.

Possibly related PRs

Suggested reviewers

  • mrfinch

Poem

In the garden of code, a dropdown anew,
Choices.js blossoms where fancy once grew.
Old scripts retire, new styles take the stage,
With teal and bold, the options engage.
Select your tongue, let the code flow—
A rabbit’s delight, in UI’s fresh glow!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4134f6 and ed19048.

📒 Files selected for processing (1)
  • app/views/play/common/ChangeLanguageTab.js (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/views/play/common/ChangeLanguageTab.js
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ESLint CI
  • GitHub Check: Node.js CI (18.10.0)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@smallst smallst changed the title get rid of fancy-select and make our own version anonymous user should be able to see cpp/java but cannot select it Apr 30, 2025
@smallst smallst marked this pull request as ready for review April 30, 2025 04:21
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
app/views/play/common/ChangeLanguageTab.js (1)

189-264: Consider consistent naming convention for Choices instances

The codebase uses inconsistent naming conventions between languageChoices and codeformatChoices. Consider standardizing to either languageChoices/codeFormatChoices or languagechoices/codeformatchoices.

-      this.languageChoices = null
-      this.codeformatChoices = null
+      this.languageChoices = null
+      this.codeFormatChoices = null

Update all references accordingly throughout the file.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1ccc7db and 813072c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • app/styles/play/common/change_language_tab.sass (1 hunks)
  • app/styles/play/modal/play-heroes-modal.sass (3 hunks)
  • app/templates/play/common/change-language-tab.pug (1 hunks)
  • app/vendor.js (0 hunks)
  • app/views/play/common/ChangeLanguageTab.js (4 hunks)
  • package.json (1 hunks)
  • vendor/scripts/fancy_select.js (0 hunks)
  • vendor/styles/fancy_select.css (0 hunks)
💤 Files with no reviewable changes (3)
  • app/vendor.js
  • vendor/styles/fancy_select.css
  • vendor/scripts/fancy_select.js
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: ESLint CI
  • GitHub Check: Node.js CI (18.10.0)
🔇 Additional comments (13)
package.json (1)

111-111: LGTM: Added Choices.js dependency for the dropdown replacement

The addition of the choices.js dependency (v11.1.0) correctly supports the replacement of the previously used custom fancySelect plugin with a more modern dropdown solution.

app/styles/play/common/change_language_tab.sass (1)

1-28: Styles look good for the new Choices.js dropdown implementation

The new stylesheet properly imports base styles from the library and provides custom styling for the dropdown elements. The styling maintains consistent colors with the application's design system (#2B8686 for text, #abc for hover state).

app/templates/play/common/change-language-tab.pug (1)

2-5: LGTM: Updated template structure for Choices.js compatibility

The template structure has been appropriately modified to work with Choices.js, wrapping the select in a container with the new class name and updating option elements accordingly.

app/styles/play/modal/play-heroes-modal.sass (3)

530-541: LGTM: Updated selectors for RTL support

The selectors have been properly updated from .fancy-select to .my-fancy-select and li to .item to match the new Choices.js structure while maintaining RTL (right-to-left) language support.


542-567: LGTM: Updated main dropdown styling

The main dropdown styling has been properly updated to use .my-fancy-select instead of .fancy-select, and the addition of border-radius: 4px gives the trigger a more polished appearance.


579-595: LGTM: Updated language option styling

The language option styling has been properly updated to use .item instead of li selectors, with the addition of margin-bottom: -1px to improve vertical alignment of the options.

app/views/play/common/ChangeLanguageTab.js (7)

13-17: LGTM: Added required imports for Choices.js

The new import statements correctly add the Choices.js library and ensure the associated styles are included.


189-203: Good implementation of Choices.js for code formats

The implementation correctly initializes Choices.js for code formats with appropriate configuration. The mobile check is a good optimization to avoid unnecessarily initializing the library on mobile devices.


214-228: Good implementation of Choices.js for code languages

The implementation correctly initializes Choices.js for language selection with appropriate configuration, matching the pattern used for code formats.


229-236: Consistent implementation of language option blurbs

The code for appending localized blurbs to each dropdown option's text is maintained, preventing duplication when called multiple times.


242-244: Good addition of rebuilding the language dropdown

The addition of this.buildCodeLanguages() ensures the dropdown is properly reconstructed after changing the language.


256-257: Good addition of rebuilding the format dropdown

The addition of this.buildCodeFormats() ensures the dropdown is properly reconstructed after changing the code format.


204-211:

❓ Verification inconclusive

Verify DOM traversal works with Choices.js structure

The DOM traversal has been updated to accommodate Choices.js structure, but let's ensure it works correctly.


🏁 Script executed:

#!/bin/bash
# Search for any other instances where DOM traversal might need similar adjustments
rg -n "find\(.*\.options" --type js app/

Length of output: 1147


Confirm DOM traversal in ChangeLanguageTab.js matches Choices.js markup

I’ve searched the codebase and only two instances of the old .options .item traversal remain (both in ChangeLanguageTab.js). Please verify that these still target the correct elements in the new Choices.js dropdown and update the selectors if the HTML structure or class names have changed.

• app/views/play/common/ChangeLanguageTab.js
– Line 204: $select.parent().parent().find('.options .item')
– Line 229: identical traversal in the second handler

Test both in the browser and adjust (e.g. to .choices__list--dropdown .choices__item) if necessary.

Copy link
Contributor
@mrfinch mrfinch left a comment

Choose a reason for hiding this comment

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

fancy_select is not used anywhere else?

if (this.languageChoices) {
this.languageChoices.destroy()
}
this.languageChoices = new Choices($select[0], {
Copy link
Contributor

Choose a reason for hiding this comment

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

language and codeformat use the same object as second parameter, DRY code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. yes we only use fancy-select here lol

@smallst smallst merged commit 5b4d9f0 into master Apr 30, 2025
2 of 3 checks passed
@smallst smallst deleted the yuqiang/show-all-langs-for-free branch April 30, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
6179
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0