-
Notifications
You must be signed in to change notification settings - Fork 96
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
Change Basic settings field display; better admin UX #433
Conversation
joshcanhelp
commented
Apr 16, 2018
- Refactored Basic settings with new render functions, new descriptions
- Fixed PHP < 5.4 array style for advanced render functions
- Persist tab showing on settings page
- Universal show/hide JS for switch fields
- Constant for JWKS cache transient name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments
// Show/hide field for specific switches | ||
$('[data-expand!=""]').each( function() { | ||
var $thisSwitch = $( this ); | ||
var $showFieldRow = $( '#' + $thisSwitch.attr( 'data-expand' ) ).closest( 'tr' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Length is always there for a jQuery selector. Next line checks that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the "data-expand" and then "closest TR".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having data-expand
is what gets you into the each
here. No data-expand
, no each
assets/js/admin.js
Outdated
function localStorageAvailable() { | ||
try { | ||
var x = '__storage_test__'; | ||
window.localStorage.setItem(x, x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this try/catch the only way to check for availability? And, can the removeItem
fail after the first one succeeded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but it's the best way:
As for removeItem
, that would be a weird case, not implementing the webStorage interface. But localStorage persist forever and we don't want to store something we're never going to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this stored under some domain key or can it collide with existing "x" stored keys? In that case, you might want to use some key like "a0_local_storage_assertion"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's per-domain:
https://stackoverflow.com/q/4201239/728480
But you have a good point about that. WP sites could load a million other JS libraries.
lib/admin/WP_Auth0_Admin_Basic.php
Outdated
public function render_client_secret_b64_encoded( $args = array() ) { | ||
$this->render_switch( $args['label_for'], $args['opt_name'] ); | ||
$this->render_field_description( | ||
__( 'Enable this if your Client Secret is base64 enabled. ', 'wp-auth0' ) . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base64 encoded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did I say "enabled" here? 😆
Fixed!
$this->render_field_description( | ||
sprintf( '<a href="https://%s/.well-known/jwks.json" target="_blank">%s</a>', | ||
$domain, | ||
__( 'View your JWKS here', 'wp-auth0' ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this section show the JWKs contents or what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Links to it, yes.
23de224
to
c5b6c64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨