8000 hide revoke button for lebanon users by smallst · Pull Request #7958 · codecombat/codecombat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

hide revoke button for lebanon users #7958

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 1 commit into from
Apr 11, 2025
Merged

Conversation

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

simply hide the revoke button to forbid lebanon teachers revoke their license.
fix ENG-1730

image

Summary by CodeRabbit

  • New Features
    • Updated license management options: The "check and revoke license" functionality now appears only for users outside of Lebanon.
    • Enhanced teacher dashboard: License revocation controls are now tailored based on your geographical location, providing a more refined user interface experience.

Copy link
Contributor
coderabbitai bot commented Apr 2, 2025

Walkthrough

The pull request updates the user interface for license revocation by adding conditional checks based on the user's country. In both the modal and the teacher dashboard component, the "check and revoke license" UI elements are now rendered only if the user's country is not Lebanon. Additionally, the teacher dashboard component introduces a computed property to retrieve user data from the global window object, which refines the conditional rendering logic.

Changes

File(s) Change Summary
app/templates/.../manage-licenses-modal.pug
ozaria/site/components/.../ViewAndManage.vue
Added conditional logic to render the license revocation UI only when the user's country is not "Lebanon". In the ViewAndManage component, introduced a new computed property me to access global user data.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant M as Modal Renderer
    participant C as Country Checker

    U->>M: Open licenses modal
    M->>C: Check user country
    alt Country != Lebanon
        C-->>M: Return country info
        M->>M: Render "check and revoke license" tab
    else Country is Lebanon
        C-->>M: Return country info
        M->>M: Skip rendering the tab
    end
Loading
sequenceDiagram
    participant U as User
    participant V as ViewAndManage Component
    participant W as Window Object

    U->>V: Open teacher dashboard
    V->>W: Retrieve global 'me'
    alt showLicenses is true and me.country != 'lebanon'
        W-->>V: Return user data
        V->>V: Render revoke license button
    else Condition not met
        V->>V: Do not render revoke button
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
disable license revoke in Lebanon (ENG-1730)

Possibly related PRs

Suggested reviewers

  • adamkecskes
  • mrfinch

Poem

Hello, I'm a hopping rabbit, so spry,
Watching new changes as they fly by,
A conditional twist to keep it neat,
Lebanon checks keep the revokes discrete,
In code fields I hop with glee – oh my!
🐇🎉
Code and carrots, side by side!


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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

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: 0

🧹 Nitpick comments (1)
ozaria/site/components/teacher-dashboard/BaseSingleClass/ViewAndManage.vue (1)

169-169: Condition implemented to hide revoke license button for Lebanon users

The implementation correctly adds a conditional check to only show the revoke licenses button for users whose country is not 'lebanon'. This matches the condition in the modal template and fulfills the PR objective.

Consider extracting this country check into a separate computed property to improve readability and maintainability:

- v-if="showLicenses && me.get('country') !== 'lebanon'"
+ v-if="showLicenses && isRevokeLicenseAllowed"

And add this computed property:

isRevokeLicenseAllowed() {
  return this.me.get('country') !== 'lebanon'
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1e85875 and cd45560.

📒 Files selected for processing (2)
  • app/templates/courses/manage-licenses-modal.pug (1 hunks)
  • ozaria/site/components/teacher-dashboard/BaseSingleClass/ViewAndManage.vue (2 hunks)
🔇 Additional comments (2)
app/templates/courses/manage-licenses-modal.pug (1)

163-166:

✅ Verification successful

Condition implemented to hide revoke license tab for Lebanon users

The implementation correctly adds a conditional check that only renders the "check and revoke license" tab for users whose country is not 'lebanon'. This aligns with the PR objective to hide the revoke button for Lebanon users.


🏁 Script executed:

#!/bin/bash
# Verify that me.get('country') is used consistently throughout the codebase for country-based restrictions
rg -i "me\.get\('country'\)" --type=js --type=vue --type=pug

Length of output: 96


Below is an updated verification step along with the revised review comment. I've generated a new shell script that uses explicit glob patterns (instead of the unrecognized "vue" file type) to search for the usage of me.get('country') across .vue, .js, and .pug files:

Once this command is executed, please manually verify that no additional instances conflict with the intended behavior of conditionally hiding the revoke license tab for Lebanon users. Based on the current confirmation in the file app/templates/courses/manage-licenses-modal.pug (lines 163-166), the conditional is correctly implemented.


Country-Based License Tab Visibility – Manual Verification Requested

  • The if me.get('country') !== 'lebanon' condition in app/templates/courses/manage-licenses-modal.pug (lines 163‑166) properly restricts the revoke license tab from users in Lebanon.
  • A re-run of the search (using the updated script above) should confirm that me.get('country') is not used in conflicting ways elsewhere in the codebase.

Please run the new script and review the findings to ensure consistency across the codebase.


🏁 Script executed:

#!/bin/bash
# Re-run the search for me.get('country') in .vue, .js, and .pug files explicitly
rg -i "me\.get\('country'\)" --glob="*.vue" --glob="*.js" --glob="*.pug"

Length of output: 5877


Revoke License Tab Visibility Confirmed

The conditional check in app/templates/courses/manage-licenses-modal.pug (lines 163‑166) that uses if me.get('country') !== 'lebanon' is correctly implemented to hide the revoke license tab for Lebanon users. A re-run of the search across .vue, .js, and .pug files confirmed that this pattern is used consistently—with no conflicting or alternative implementations detected.

  • Verify that no additional conditions override or conflict with this check in other parts of the code.
  • Confirmed instance in app/templates/courses/manage-licenses-modal.pug aligns with the PR objective.
ozaria/site/components/teacher-dashboard/BaseSingleClass/ViewAndManage.vue (1)

66-68: New computed property for accessing user data

Adding the me computed property is a good approach to access the global window.me object in a Vue-friendly way. This makes the component's dependencies more explicit and enables proper reactivity within the component.

@smallst smallst merged commit 2ff767d into master Apr 11, 2025
3 checks passed
@smallst smallst deleted the yuqiang/hide-revoke-for-lebanon branch April 11, 2025 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0