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: Simplify logic for Panel.enabled property #1676

Merged

Conversation

adamantike
Copy link
Contributor

With this change, having a panel status set in the cookies exits earlier, as it isn't needed to retrieve the Django settings and panel name to calculate the default value.

With this change, having a panel status set in the cookies exits earlier,
as it isn't needed to retrieve the Django settings and panel name to
calculate the default value.
def enabled(self):
def enabled(self) -> bool:
# The user's cookies should override the default value
cookie_value = self.toolbar.request.COOKIES.get("djdt" + self.panel_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

If a user has enabled a panel (creating a cookie value of "on"), then changes their settings file to disable it, wouldn't this override the customized settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand correctly, that's the same behavior we have today, as the default value is only used when a cookie value is not found in the request.

This shouldn't change how a panel status is decided, just to return faster when the cookie is set.

Copy link
Contributor

Choose a reason for hiding this comment

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

You're correct. DebugToolbar.get_panel_classes is what I was worried about. I wanted to make sure that a developer was still able to stop using a panel even if the cookies are set.

@tim-schilling tim-schilling merged commit f138780 into jazzband:main Sep 25, 2022
@tim-schilling
Copy link
Contributor

Thank you for the PR!

@adamantike adamantike deleted the fix/simplify-panel-enabled-property branch October 17, 2022 20:32
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.

None yet

2 participants