-
-
Notifications
You must be signed in to change notification settings - Fork 557
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
User customizable datetime #1986
User customizable datetime #1986
Conversation
Thank you for this PR. This is a really good start. I have a few comments and questions regarding code organization but other than that it looks pretty good to me. |
Just to confirm are there any comments I need to respond to? I didn't see any while scrolling through the diffs. |
app/Core/Controller.php
Outdated
* This also doesn't effect JS date-time any, only PHP calls for date-time, as | ||
* they use incompatible formats. | ||
*/ | ||
if (isset($_SESSION['userdata']) && isset($_SESSION['userdata']['id'])) { |
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 is this needed in the base controller? If anything I would probably move it to the Auth Service where we initialize the session of the user. (Domain/Auth/Services/Auth.php method setUserSession)
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.
Because it gets overridden when the config file is loaded, at least it did during my testing. This allowed the config to still be read and then we update it based on the user settings.
I didn't move this closer to the config parser because that doesn't have access to the user session (for the user ID) nor is the session started yet, so even if I set the DI for SettingsRepo/Service I wouldn't be able to get the proper setting.
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.
Yeah, the issue I have with this here is that the Base controller should not have anything to do with session or user management. it's for controller management and so in a few months I will have forgotten that there is anything related to session in there. For the problem you mentioned please move it to the header controller which has some session calls already: https://github.com/Leantime/leantime/blob/master/app/Domain/Pageparts/Controllers/Header.php
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.
Ah ok yeah makes sense. Alright I'll move it over today.
{ | ||
return [ | ||
'dates' => [ | ||
'default' => 'm/d/Y', |
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.
The default should be pulled from the language file still. So int this case $this->__("language.dateformat")
that way the dateformat is still based on the user language.
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.
Agreed. I was curious how I could do that as that was what I originally wanted. I'll make that change.
'RFC850' => 'l, d-M-y' | ||
], | ||
'times' => [ | ||
'default' => 'h:i A', |
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.
See above. Take default from language file
composer.json
Outdated
@@ -56,6 +51,14 @@ | |||
"vedmant/laravel-feed-reader": "^1.6", | |||
"ext-fileinfo": "*" | |||
}, | |||
"optional": { |
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 were those moved to optional? We can't move them to optional since we don't know if users are using S3, ldap, oauth until runtime at which point the packages will be needed.
Please revert this change
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.
My thinking in this was to not block an install for users who don't use S3 or LDAP (primarily done for ext-ldap
but then it seemed relevant to others as well). Nothing is stopping the user from installing them still.
But if you prefer I revert this then I can do.
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.
Well the problem is that this is not in our build pipeline. So now we would have to make a lot of other changes to ensure our releases, default dev environments and tests still work. Most of our users do not install Leantime from source but using the release package or docker. This change goes a little beyond the scope of this PR. If you could revert this that would be great. We can have a separate discussion around that topic.
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.
Gotcha I'll revert it, sorry about that.
Sorry I keep forgetting that I have to actually submit the review before the comments are visible... |
Hi Eric, I had merged the PR but unfortunately had to revert it. Couple issue I found:
|
I'll look into this but I didn't experience this issue. Did it happen just with the
I'm a little confused here. So dates in the input box/JavaScript use a different format than what the PHP format supports. I can try to keep them in sync but I wasn't sure what file(s) needed to be touched, and am hoping much like the general date-time stuff being in To make things a bit more easier to manage in the future I'd write a "translater" of PHP date-time format to JS, which shouldn't be too difficult. I would just need to be able to pass the formats from backend to frontend. |
Closes #1945
Adds:
I tested this with basic auth login, not against LDAP or other options like OIDC. However, if
setUserSession
is called during the authentication process, the proper fsession index will be set.This only changes PHP, JS is untouched. I poked around to see if I could make changes for the JS side as well, but didn't feel comfortable enough yet around the code base to do so.
Some diffs are whitespace changes due to VSCode's formatting of things.