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
1553266: When d-bus methods are unavailable, show appropriate message (ENT-576) #1836
Conversation
nikosmoum
commented
Jun 12, 2018
- Added a "safe call" mechanism that makes the initial dbus calls (entitlementService, configService, productsService) only if the service is available, tries to restart the rhsm service if possible, and otherwise failing gracefully.
- Added new UI curtain that provides a meaningful message and advice to the end user.
- Re-added utility method statusUpdateFailed that was accidentally deleted.
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.
Overall it is very good PR 👍 . I have some small requests (code style).
cockpit/src/subscriptions-client.js
Outdated
/* Utility function to check if an object has a specific property */ | ||
function hasProperty(object, property) { | ||
return Object.prototype.hasOwnProperty.call(object, property); | ||
} |
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 it really necessary to have special function for this testing? This function is used only on one place in the code.
cockpit/src/subscriptions-client.js
Outdated
}); | ||
} | ||
|
||
function callProductsService() { |
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 do you create special function for this? Is this reason any unit testing in the future? IMHO you needn't to create special function, because you can do it in this way:
safeDBusCall(productsService, 'ListInstalledProducts', () => {
productsService.ListInstalledProducts('', {}, userLang) // FIXME: use proxy settings
// ...
});
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.
Done. It is because of the Java developer in me, that isn't used to how anonymous high-order functions look 😄
cockpit/src/subscriptions-client.js
Outdated
getSubscriptionDetails(); | ||
needRender(); | ||
}); | ||
safeDBusCall(entitlementService, 'GetStatus', 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 would use arrow function here too () => {};
. It will not be necessary to do explicit binding of this
. You will be able to use this
instead of that
in following code.
cockpit/src/subscriptions-client.js
Outdated
client.readConfig = () => { | ||
return configService.wait(() => configService.GetAll(userLang).then(config => { | ||
return configService.wait(() => { | ||
safeDBusCall(configService, 'GetAll', callConfigService); |
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.
Consider using arrow function here too.
cockpit/src/subscriptions-client.js
Outdated
* @param delegateMethod the method that we delegate the actual call to dbus | ||
*/ | ||
function safeDBusCall(serviceProxy, methodName, delegateMethod) { | ||
if (!hasProperty(serviceProxy, methodName)) { |
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 simplify the code to use something like this:
if (!Object.prototype.hasOwnProperty.call(serviceProxy, methodName)) {
* Added a "safe call" mechanism that makes the initial dbus calls (entitlementService, configService, productsService) only if the service is available, tries to restart the rhsm service if possible, and otherwise failing gracefully. * Added new UI curtain that provides a meaningful message and advice to the end user. * Re-added utility method statusUpdateFailed that was accidentally deleted.
71b2470
to
cdf0357
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.
ACK