Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rinkitadhana
Copy link
Contributor

@rinkitadhana rinkitadhana commented Jul 20, 2025

fixes #4443

Add Domain

image

Edit Domain

image

Summary by CodeRabbit

  • New Features

    • Enhanced domain logo upload with live preview, client-side image validation (file type and size), and a dedicated remove button.
    • Improved error messaging for invalid image uploads.
  • Style

    • Refined form layout, colors, spacing, and typography for clearer and more consistent appearance.
    • Updated button, dropdown, and checkbox styles to match the new theme.
  • Bug Fixes

    • Improved reliability of image preview and removal actions.
  • Accessibility

    • Improved labels and descriptions for better clarity and usability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 20, 2025

Walkthrough

The "add domain" and "edit domain" HTML templates were updated to enhance the visual design and user experience, particularly for the domain logo upload section. The updates introduce interactive image preview, client-side validation for uploads, improved error handling, and consistent styling throughout the forms. JavaScript functions were added for image preview and removal.

Changes

Files Change Summary
website/templates/organization/dashboard/add_domain.html Refactored form UI and styling, redesigned logo upload with preview, validation, and removal logic.
website/templates/organization/dashboard/edit_domain.html Updated UI, redesigned logo upload/preview/validation, improved manager/notification section styles.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant Template (JS)

    User->>Browser: Selects image file for logo upload
    Browser->>Template (JS): Triggers previewUploadedImage()
    Template (JS)->>Template (JS): Validate file type and size
    alt Validation fails
        Template (JS)->>Browser: Display error message
        Template (JS)->>Browser: Do not update preview
    else Validation succeeds
        Template (JS)->>Browser: Display image preview
        Template (JS)->>Browser: Show remove button, hide default icon
    end

    User->>Browser: Clicks remove logo button
    Browser->>Template (JS): Triggers removeUploadedImage()
    Template (JS)->>Browser: Clear input, hide preview, show default icon, clear errors
Loading
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 auto-generate unit tests to generate unit tests for 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.

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

🔭 Outside diff range comments (2)
website/templates/organization/dashboard/edit_domain.html (2)

322-354: previewUploadedImage / removeUploadedImage duplicated across templates – move to a shared JS module

The two functions are copy-pasted here and in add_domain.html. Any future bug-fix (e.g., MIME list, size limit, a11y tweaks) will have to be done twice and risks divergence.

Export them once (e.g., static/js/file-preview.js) and load that script from both templates. This keeps the templates clean and reduces maintenance overhead.


356-391: displayWebshotPreview lacks the validation present for logo uploads

Logo uploads enforce MIME type and 5 MB size limits; webshot uploads do not. An oversized or unsupported file can trigger memory spikes when drawn on a canvas. Apply the same validation logic (or reuse the shared helper suggested above).

♻️ Duplicate comments (2)
website/templates/organization/dashboard/add_domain.html (2)

346-484: Same comments as in edit_domain.html

The previewUploadedImage, removeUploadedImage, and displayWebshotPreview blocks duplicate logic, console debugging, and missing validation issues already flagged in the Edit Domain template. Consolidate them into a shared script and apply the validation fix for webshots.


275-276: Name attribute should be user[] for multiple selections

See detailed explanation in the previous file.

🧹 Nitpick comments (3)
website/templates/organization/dashboard/edit_domain.html (3)

393-411: Remove verbose console.log debugging before shipping

Five separate console.log calls leak implementation details into the browser console and add noise in production. Either gate them behind a DEBUG flag or drop them:

- console.log('Preview function called with:', { previewId, defaultIconId, removeButtonId });
...
- console.log('Elements found:', { preview: preview !== null, defaultIcon: defaultIcon !== null, removeButton: removeButton !== null, errorDiv: errorDiv !== null });
+ // debug statements removed – keep production console clean

240-258: Typo & copy error in explanatory text

registerd user” and “someones reports” contain typos that undermine professionalism.

- Email should be domain mail and should be registerd user on BLT.
+ Email must use the domain and belong to a registered BLT user.
...
- Get notified when someones reports a bug on this domain.
+ Get notified when someone reports a bug on this domain.

74-78: Hard-coded brand colour—prefer Tailwind config or CSS variable

#e74c3c is repeated dozens of times. Define it once in the Tailwind
theme (theme.extend.colors) or expose a CSS var so future rebranding
doesn’t require hunting through templates.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 37f4c66 and e7bae54.

📒 Files selected for processing (2)
  • website/templates/organization/dashboard/add_domain.html (9 hunks)
  • website/templates/organization/dashboard/edit_domain.html (7 hunks)
🔇 Additional comments (1)
website/templates/organization/dashboard/edit_domain.html (1)

245-257: Duplicate <select> name without [] may overwrite values

Each dynamically added manager dropdown is rendered as
<select name="user">. Browsers send all values for duplicate
names, but Django’s default request.POST['user'] will return only the
last one, unless you explicitly call getlist(). To avoid silent data
loss, append [] to the name or use distinct names:

- <select name="user"
+ <select name="user[]"

@DonnieBLT DonnieBLT added this pull request to the merge queue Jul 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Jul 21, 2025
@DonnieBLT DonnieBLT added this pull request to the merge queue Jul 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Jul 21, 2025
@DonnieBLT DonnieBLT added this pull request to the merge queue Jul 23, 2025
Merged via the queue into OWASP-BLT:main with commit 999fffd Jul 23, 2025
13 checks passed
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.

[Frontend] Improve UI/UX of "add domain" and "edit domain" page

2 participants