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

1553266: When d-bus methods are unavailable, show appropriate message (ENT-576) #1836

Merged
merged 1 commit into from Jun 14, 2018

Conversation

nikosmoum
Copy link
Member

  • 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.

@jirihnidek jirihnidek self-assigned this Jun 13, 2018
Copy link
Contributor

@jirihnidek jirihnidek left a 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).

/* Utility function to check if an object has a specific property */
function hasProperty(object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
}
Copy link
Contributor

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.

});
}

function callProductsService() {
Copy link
Contributor

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
    // ...
});

Copy link
Member Author

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 😄

getSubscriptionDetails();
needRender();
});
safeDBusCall(entitlementService, 'GetStatus', function () {
Copy link
Contributor

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.

client.readConfig = () => {
return configService.wait(() => configService.GetAll(userLang).then(config => {
return configService.wait(() => {
safeDBusCall(configService, 'GetAll', callConfigService);
Copy link
Contributor

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.

* @param delegateMethod the method that we delegate the actual call to dbus
*/
function safeDBusCall(serviceProxy, methodName, delegateMethod) {
if (!hasProperty(serviceProxy, methodName)) {
Copy link
Contributor

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.
Copy link
Contributor

@jirihnidek jirihnidek left a comment

Choose a reason for hiding this comment

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

ACK

@jirihnidek jirihnidek merged commit 41fa159 into master Jun 14, 2018
@awood awood deleted the nikos/m/1553266 branch March 20, 2019 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants