Skip to content
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

Fix incorrect redirection #2993

Merged
merged 1 commit into from
Mar 26, 2024
Merged

Fix incorrect redirection #2993

merged 1 commit into from
Mar 26, 2024

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Mar 23, 2024

What does this implement/fix?

We should not try to apply settings levels (incl. all the consequences such as ill-fated redirects) when we have already detected that there are no expert-settings elements on this page.


Related issue or feature (if applicable): #2992

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

@DL6ER DL6ER requested a review from a team March 23, 2024 18:49
@DL6ER DL6ER linked an issue Mar 23, 2024 that may be closed by this pull request
@rdwebdesign
Copy link
Member

rdwebdesign commented Mar 24, 2024

Now Gravity Update page works, but All Settings page is empty (even using the toggle button).

@DL6ER
Copy link
Member Author

DL6ER commented Mar 24, 2024

Now we recall why the code was there :-) Should be fixed.

@rdwebdesign
Copy link
Member

rdwebdesign commented Mar 24, 2024

Now:

  • Gravity Update page works (no matter what settings level is selected),
  • All Settings page is also works,
  • BUT... if you select Expert level, the expert pages on the menu are only visible if you are in a Settings page.
    If you are in a different page (Example: /index), the menu will show only the Basic pages.

We need to run applyExpertSettings() in all pages, but we need a different redirect rule.

We should redirect only:

  • if we are inside any Settings pages (something like if ( $(".settings-selector").length !== 0 ) ) AND
  • if we ended up with an empty page (no visible boxes) after switching to Basic level.

@rdwebdesign
Copy link
Member

The original issue is $(".box:visible").length will be zero in 2 cases:

  • the page contains only "invisible" boxes (this is how we are identifying empty boxes);
  • the page has no .box elements at all
    (this causes the issue in Gravity page and can also cause issues in other pages without this element).

Suggestion:

Revert all commits and change this code:

    // If we left with an empty page (no visible boxes) after switching from
    // Expert to Basic settings, redirect to admin/settings/system instead
-   if ($(".box:visible").length === 0) {
+   if ($(".settings-selector").length !== 0 && $(".box:visible").length === 0) {
      window.location.href = "/admin/settings/system";
    }

This will trigger the redirect only if:

  • class settings-selector is present (this class is present in every settings pages, but not in other pages)
    AND
  • there are no visible boxes (the page is empty)

@DL6ER DL6ER merged commit ab87e11 into development-v6 Mar 26, 2024
8 checks passed
@DL6ER DL6ER deleted the fix/redirect_settings branch March 26, 2024 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Gravity page is redirect depending on the settings level
2 participants