Skip to content

feat: Organize global admin settings form into tabs for better UX #591

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

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

SxxAq
Copy link

@SxxAq SxxAq commented Mar 22, 2025

Description

This PR implements the redesign of Global Admin Settings to align with the event settings UI pattern. The new design incorporates a tabbed interface that improves organization and user experience for administrators.

Changes Made

  • Restructured the Global Admin Settings interface to use a tabbed layout

  • Organized settings into five distinct categories:

      - Basics
      - Localization
      - Email
      - Payment Gateways
      - Maps
    

Screenshots

250323_00h41m38s_screenshot
250323_00h42m29s_screenshot
250323_00h42m21s_screenshot
250323_00h42m14s_screenshot
250323_00h42m03s_screenshot

Related Issue

🎯 Closes #479

Summary by Sourcery

Organize the global admin settings form into tabs for better user experience. This change restructures the global admin settings interface to use a tabbed layout, organizing settings into five distinct categories: Basics, Localization, Email, Payment Gateways, and Maps.

Enhancements:

  • Restructure the Global Admin Settings interface to use a tabbed layout to improve organization and user experience.
  • Organize settings into five distinct categories: Basics, Localization, Email, Payment Gateways, and Maps.

Copy link
Contributor

sourcery-ai bot commented Mar 22, 2025

Reviewer's Guide by Sourcery

This pull request restructures the Global Admin Settings interface by introducing a tabbed layout. The settings are now organized into five categories: Basics, Localization, Email, Payment Gateways, and Maps. This change aims to improve the user experience by providing a more organized and intuitive interface.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Refactored the global settings form into a tabbed interface for improved organization and user experience.
  • Introduced tabs for Basics, Localization, Email, Payment Gateways, and Maps.
  • Moved relevant settings fields into their respective tabs.
  • Updated the template to render the tabbed interface.
  • Modified the view to handle the active tab and filter fields accordingly.
src/pretix/control/forms/global_settings.py
src/pretix/control/views/global_settings.py
src/pretix/control/templates/pretixcontrol/global_settings.html

Assessment against linked issues

Issue Objective Addressed Explanation

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @SxxAq - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Flagging hardcoded password field in global settings form. (link)
  • Flagging hardcoded stripe webhook secret key field in global settings form. (link)
  • Flagging hardcoded send grid api key field in global settings form. (link)
  • Flagging hardcoded stripe connect secret key field in global settings form. (link)

Overall Comments:

  • Consider using a template tag or filter to generate the tab URLs to avoid hardcoding them in the template.
  • The javascript code to show/hide email vendor specific fields should be moved to a separate file.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🔴 Security: 4 blocking issues
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 2 issues found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

} else if (thrownError !== "abort" && thrownError !== "") {
console.log(thrownError);
alert(gettext("Unknown error."));
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring repeated configuration blocks for datetimepickers, colorpickers, and select2 by extracting shared settings into helper methods to reduce complexity and improve code maintainability.

Refactoring the repeated configuration blocks can reduce complexity without changing behavior. For example, extract shared settings for datetimepickers and colorpickers into helper methods. One approach would be:

function getDateTimePickerDefaults(extra) {
  const defaults = {
    format: $("body").attr("data-datetimeformat"),
    locale: $("body").attr("data-datetimelocale"),
    useCurrent: false,
    showClear: true, // update based on element requirement later if needed
    icons: {
      time: "fa fa-clock-o",
      date: "fa fa-calendar",
      up: "fa fa-chevron-up",
      down: "fa fa-chevron-down",
      previous: "fa fa-chevron-left",
      next: "fa fa-chevron-right",
      today: "fa fa-screenshot",
      clear: "fa fa-trash",
      close: "fa fa-remove",
    }
  };
  return $.extend({}, defaults, extra);
}

// Usage in form_handlers:
el.find(".datetimepicker").each(function () {
  $(this).datetimepicker(
    getDateTimePickerDefaults({showClear: !$(this).prop("required")})
  );
  if (!$(this).val()) {
    $(this).data("DateTimePicker").viewDate(moment().startOf("day"));
  }
});

Similarly, create helper methods for settings used in colorpicker and select2, etc. This keeps functionality intact while reducing nesting and repetition.

# other custom paths can be added here
],
"oauth2_provider.subdomain",
)

urlpatterns = [
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (complexity): Consider refactoring the URL routes into dedicated modules to improve maintainability and reduce complexity by grouping related routes into separate files and including them in the main urls.py file.

Refactoring the URL routes into dedicated modules would reduce vertical space and nesting, making maintenance easier. Consider grouping related routes (e.g. admin, event, oauth) into separate files and then including them in the main urls.py.

For example:

# pretix/control/urls/admin_urls.py
from django.urls import re_path as url
from pretix.control.views import admin, pages, global_settings, user, users, typeahead

urlpatterns = [
    url(r"^$", admin.AdminDashboard.as_view(), name="admin.dashboard"),
    url(r"^organizers/$", admin.OrganizerList.as_view(), name="admin.organizers"),
    # ... other admin routes
]

Then update your main file:

# pretix/control/urls.py
from django.urls import include, re_path as url

urlpatterns = [
    url(r"^admin/", include("pretix.control.urls.admin_urls")),
    # ... include other route groups similarly
]

This retains all functionality while easing navigation and reducing complexity in a single file.

"smtp_host",
"smtp_port",
"smtp_username",
"smtp_password",
Copy link
Contributor

Choose a reason for hiding this comment

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

🚨 issue (security): Flagging hardcoded password field in global settings form.

"payment_stripe_connect_publishable_key",
"payment_stripe_connect_test_secret_key",
"payment_stripe_connect_test_publishable_key",
"stripe_webhook_secret_key",
Copy link
Contributor

Choose a reason for hiding this comment

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

🚨 issue (security): Flagging hardcoded stripe webhook secret key field in global settings form.

"email": [
"mail_from",
"email_vendor",
"send_grid_api_key",
Copy link
Contributor

Choose a reason for hiding this comment

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

🚨 issue (security): Flagging hardcoded send grid api key field in global settings form.

"smtp_use_ssl",
],
"payment_gateways": [
"payment_stripe_connect_secret_key",
Copy link
Contributor

Choose a reason for hiding this comment

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

🚨 issue (security): Flagging hardcoded stripe connect secret key field in global settings form.

Copy link
Member

@norbusan norbusan left a comment

Choose a reason for hiding this comment

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

As mentioned in the two comments, please separate code changes from reformatting changes.
There are MANY places where code was reformatted.

if (
global_settings.get("smtp_port") is None
or global_settings.get("smtp_port") == ""
):
Copy link
Member

Choose a reason for hiding this comment

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

You seem to have a different line length setting, which introduces a lot of unrelated changes.
Please change this and make sure that no code changes are mixed with reformatting issues.

),
(
"banner_message",
I18nFormField(
Copy link
Member

Choose a reason for hiding this comment

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

Same in all the changes here, unrelated reformatting changes

@SxxAq
Copy link
Author

SxxAq commented Apr 4, 2025

@norbusan I have resolved the formatting-related issues. Please review the changes.

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.

Enhance design of Global Admin Settings
2 participants