-
Notifications
You must be signed in to change notification settings - Fork 174
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
Luigi core config refactorings #187
Luigi core config refactorings #187
Conversation
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 like the changes!
Just a few how to be modern suggestions from my side, feel free to implement them or not.
One obsolete console.log(), 2 useless (I think) variable declarations. Please explain or remove them :)
}; | ||
this.config; | ||
|
||
this.configReadyCallback = function() {}; |
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 think here's the same story as with this.config;
above. It doesn't change anything if you remove this line.
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.
This initial value is meant to enable calling this.configReadyCallback without the need of an if
block to prove if it is defined or not.
value = value.apply(this, parameters); | ||
if (isPromise(value)) { | ||
return value; | ||
getConfig() { |
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.
You can be more modern here and use a getter.
get Config() {
return this.config;
}
and then
this.getConfig()
-> this.Config
.
I'm not requesting this change but I'd like you to know it :)
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 consider that option, but I see unnecessary to create a breaking change for this tiny improvement.
…-refactorings # Conflicts: # core/src/navigation/LeftNav.html # core/src/navigation/TopNav.html # core/src/navigation/services/navigation.js # core/src/services/routing.js
); | ||
}; | ||
// Expose it window for user app to call Luigi.setConfig() | ||
window.Luigi = LuigiInstance; |
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.
Do we need to add everything to window.Luigi Wouldn't setConfig
be enough?
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.
For consistency I decided to expose the whole Luigi config instance, as this is what we are exporting through es module. But on the other side, I am in favour of exposing as less as possible to the window object, so I will apply the change you proposed. Thanks!
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.
Now I know why I did not do that. Luigi config is a class, so setConfig is interacting with other members of the class. Therefore IMHO the best solution is to expose the whole instance
core/src/utilities/async-helpers.js
Outdated
return value; | ||
} | ||
} | ||
return wrapAsPromise(value); |
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.
Do we need this function? Wouldn't that be easier to wrap it here? :) I't not used anywhere else
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.
Good catch, removed
nextValue = nextValue[propertyPath[propIndex++]]; | ||
class LuigiConfigManager { | ||
constructor() { | ||
this.configReadyTimeout = { |
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.
Do we need this object?
The valueMs
is not used anywhere. My suggestion would be to change this configReadyTimeout
from an object to a string with just the id
value.
The other option would be to use this valueMs
in the timeout below, but then I don't like the name of the object, because what is an id of a timeout then?
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.
Id of a timeout makes sense to me, it is the way you identify a timeout you set in case you want to do something with it, like removing it. I will use valueMs instead the magic number '2000' when setting the timeout and keep the object.
5779e96
docs/navigation-configuration.md
Outdated
@@ -286,7 +286,7 @@ When loading, the **viewUrl** uses the following dynamic URL parameters: | |||
- `sort = asc` | |||
|
|||
``` | |||
Luigi.setConfig({ | |||
window.Luigi.setConfig({ |
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 still should work with just Luigi.setConfig
right?
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.
yes, everywhere is used with Luigi.setConfig. I just added it here to the documentation for consistency
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.
So it's ok with this task, but I guess for the future we should set it to just Luigi.setConfig
, it just seems easier ;)
docs/navigation-configuration.md
Outdated
@@ -286,7 +286,7 @@ When loading, the **viewUrl** uses the following dynamic URL parameters: | |||
- `sort = asc` | |||
|
|||
``` | |||
Luigi.setConfig({ | |||
window.Luigi.setConfig({ |
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.
So it's ok with this task, but I guess for the future we should set it to just Luigi.setConfig
, it just seems easier ;)
1b59811
…-refactorings # Conflicts: # core/src/App.html # core/src/Authorization.html
…-refactorings # Conflicts: # core/src/navigation/TopNav.html
* Refactor Luigi config code in core to be a class * Encapsulate configNotReadyCallback in luigi core config class * move object generic methods to helpers files * Use proper key in cypress config for screenshots folder * Cosmetic changes based on pull request review * Small change in docu for consistency * Remove wrapAsPromise function and use it as inline code * use timeout value in ms instead of magic number in luigi config file * Small change in docu for consistency
Description
Changes proposed in this pull request:
Related issue(s)