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

Refactors dashboard state to a component #1373

Conversation

AllenBW
Copy link
Member

@AllenBW AllenBW commented Jan 25, 2018

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1540733

In support of the longer term fix brought on by #1372

So there's a few bzs this fixes (for real this time):

look, its working 🍰

rbac

Goal of this is to be identical to original, cept no more 403 kick ya outta the app state change errors

TODO 👍 : (In this)

  • add the basic component, put all the existing logic in the right places
  • build out the dashboard.component.service
  • refactor dashboard.component.spec
  • ensure dashboard.component is working as intended

@AllenBW AllenBW requested a review from himdel as a code owner January 25, 2018 22:43
@miq-bot miq-bot added the wip label Jan 25, 2018
@AllenBW AllenBW force-pushed the enhancement/master/#1533222-componentize-dashboard branch from 46fc4b7 to 7c0e33a Compare January 26, 2018 14:06
@miq-bot
Copy link
Member

miq-bot commented Jan 26, 2018

This pull request is not mergeable. Please rebase and repush.

@AllenBW AllenBW force-pushed the enhancement/master/#1533222-componentize-dashboard branch from 7c0e33a to f6f7953 Compare January 26, 2018 15:37
@AllenBW AllenBW force-pushed the enhancement/master/#1533222-componentize-dashboard branch 3 times, most recently from 89e71b9 to b68fddf Compare January 26, 2018 22:11
@AllenBW AllenBW removed the wip label Jan 28, 2018
@AllenBW AllenBW changed the title [WIP] Refactors dashboard state to a component Refactors dashboard state to a component Jan 28, 2018
@AllenBW AllenBW requested a review from chalettu January 28, 2018 12:59
@AllenBW
Copy link
Member Author

AllenBW commented Jan 28, 2018

Thinking its probably a good idea to get @serenamarie125 to check this out also... specifically the loading of the state before the widgets are present, maybe each column should have a loading spinner?

Or maybe not?

@AllenBW AllenBW added this to the Sprint 78 Ending Jan 29, 2018 milestone Jan 29, 2018
Copy link
Contributor

@chalettu chalettu left a comment

Choose a reason for hiding this comment

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

Never mind original comment

@serenamarie125
Copy link

serenamarie125 commented Jan 30, 2018

@AllenBW thanks for bringing this up ! From a PatternFly perspective, the cards should be displayed with their loading state, then once the data is available ... 🐰 🎩

The base card describes this state here: http://www.patternfly.org/pattern-library/cards/base-card/#design

@serenamarie125
Copy link

FYI - After chatting with @AllenBW as well as some of the visual designers, we will look into an alternate solution from a PF perspective - possibly a way to tie cards together, so that if data isn't available, you can only show a single spinner. This won't be trivial and a design should be done up front, implemented in PF and then be brought back to product. So for now, let's stick with the PF solution. Sound good ?

@AllenBW
Copy link
Member Author

AllenBW commented Jan 30, 2018

@serenamarie125 so present state, these aren't actually pf cards... you ok with the top two "header" cards being swapped for the design of the pfInfoStatusCard? http://www.patternfly.org/angular-patternfly/#/api/patternfly.card.component:pfInfoStatusCard

ok swapping is a bad idea, gonna add a real quick loading state, we'll revisit this in the near future 😁

@AllenBW
Copy link
Member Author

AllenBW commented Jan 30, 2018

@serenamarie125 updated the first comment to have a new gif, showing loading state! also... if the user doesn't have permissions to view the card, its removed when loading fails

@AllenBW AllenBW force-pushed the enhancement/master/#1533222-componentize-dashboard branch from 4684a2a to 6d3312e Compare January 30, 2018 18:57
Copy link

@serenamarie125 serenamarie125 left a comment

Choose a reason for hiding this comment

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

This is a thing of beauty! LGTM @AllenBW

@serenamarie125
Copy link

@miq-bot add_label ux/approved

@AllenBW AllenBW force-pushed the enhancement/master/#1533222-componentize-dashboard branch from 8c6a1a9 to f450f6e Compare February 2, 2018 13:51
@AllenBW AllenBW force-pushed the enhancement/master/#1533222-componentize-dashboard branch from f450f6e to e72fe1b Compare February 2, 2018 13:52
Removes nasty polling, still isn't a solid fix, but better
Copy link
Contributor

@chalettu chalettu left a comment

Choose a reason for hiding this comment

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

Small little change for readability but this looks like a great change for how dashboards work. Great job!

@@ -123,4 +130,10 @@ export function NavigationFactory (RBAC, Polling, POLLING_INTERVAL, $ngRedux, Co
})
})
}

function setPermissions () {
menuItems[1].permissions = RBAC.has(RBAC.FEATURES.SERVICES.VIEW)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we create constants for these array positions. I know its simple but it will make the code a little easier to read.

Copy link
Member Author

Choose a reason for hiding this comment

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

The assignment is self informing, I don't so much agree with creating variables that server no other purpose than to increase verbosity .

@dclarizio
Copy link

@himdel your attention required on this blocker PR . . . thx, Dan

@himdel
Copy link
Contributor

himdel commented Feb 5, 2018

So... before reviewing this any further... do we need to gaprindashvili/yes this?

I mean, it's great to see code rewritten to components.
It's just not so great as a blockers-only bugfix...

@@ -4,7 +4,7 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Project-Id-Version: \n"

#: ./client/app/states/dashboard/dashboard.html:88
#: ./client/app/components/dashboard/dashboard.html:88
Copy link
Contributor

Choose a reason for hiding this comment

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

recreating pot files should not be a part of the PR

Copy link
Member Author

Choose a reason for hiding this comment

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

@himdel will remove, but why not? especially when file refactoring takes place?

@AllenBW
Copy link
Member Author

AllenBW commented Feb 5, 2018

@himdel agreed its a large change to be a bugfix, but removing the "application gateway" (the three asset resolves that challenged a user enters entering dashboard state) state resolves is the best way to fix the bz..

When any of those fails, the app router throws us into a $stateChangeError loop. Unfortunately throwing a event.preventDefault() will not address this infinite loop. These calls have to be allowed to fail, means we need to get em outta the resolve, means dashboard now has to be a component.

@himdel
Copy link
Contributor

himdel commented Feb 5, 2018

@AllenBW So.. if we just backported a change that prevents the resolve from erroring..?

Something like

 function resolveServicesWithDefinedServiceIds (CollectionsApi, RBAC) {
   if (RBAC.has('service_view') && RBAC.has(RBAC.FEATURES.SERVICES.VIEW)) {
     const options = {
       expand: 'resources',
       filter: ['service_id=nil'],
       attributes: ['chargeback_report']
     }
 
     return CollectionsApi.query('services', options)
+      .catch(function() {
+         return null;
+      });
   }
 
   return true
 }

?

@miq-bot
Copy link
Member

miq-bot commented Feb 5, 2018

Checked commits AllenBW/manageiq-ui-service@e8962bb~...6e55968 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
0 files checked, 0 offenses detected
Everything looks fine. 🏆

Copy link
Contributor

@himdel himdel left a comment

Choose a reason for hiding this comment

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

Verified user switching now works correctly, regardless of the initial login role.

LGTM, thanks @AllenBW :)

@himdel himdel merged commit 924fee0 into ManageIQ:master Feb 5, 2018
@himdel
Copy link
Contributor

himdel commented Feb 5, 2018

@AllenBW One thing I do notice..

  1. log in with EvmGroup-desktop
  2. theres no count shown for My Services in the menu (as that role can't access services)

but..

  1. log in with any other role
  2. switch to EvmGroup-desktop
  3. the count is there (but clicking the menu item still gives me "There was an error loading the services. Use of the read action is forbidden")

Not sure if this is just about removing the count (but that doesn't sound blocker-worthy), or if the menu item should not be there (but that would be a separate bug entirely).

@AllenBW AllenBW deleted the enhancement/master/#1533222-componentize-dashboard branch February 5, 2018 17:59
@simaishi
Copy link
Contributor

simaishi commented Feb 5, 2018

So.. if we just backported a change that prevents the resolve from erroring..?

@AllenBW @himdel since I don't see a reply to that question... can either one of you confirm that we will be backporting the entire PR to Gaprindashvili branch?

@AllenBW
Copy link
Member Author

AllenBW commented Feb 5, 2018

@simaishi yes, whole pr, apologies for delayed response 😭

@simaishi
Copy link
Contributor

simaishi commented Feb 5, 2018

@AllenBW @himdel @dclarizio

This is built on top of #1375, which is not in Gaprindashvili yet (not blocker), and can't be backported as is. I think we have 2 options here... Either 1) we create a separate PR for Gaprindashvili without #1375 (not sure how much work that is...), or 2) we take #1375 now and backport this PR as well.

Two PRs touch many files/lines and I'm not sure how 'safe' it is to get either/both PRs to gaprindashvili branch now. Looking for a guidance from someone familiar with both changes...

cc @chrispy1

@AllenBW
Copy link
Member Author

AllenBW commented Feb 5, 2018

To answer the how much work question (@simaishi ), wouldn't say more than a few hours of effort to copy this into a Gaprindashvili specific branch, the only overlap is a single file, and even that is not more than 5 or so lines

@himdel
Copy link
Contributor

himdel commented Feb 6, 2018

@AllenBW Can you take care of creating a gaprindashvili version of this?

AllenBW added a commit to AllenBW/manageiq-ui-service that referenced this pull request Feb 6, 2018
@simaishi
Copy link
Contributor

simaishi commented Feb 6, 2018

Backported to Gaprindashvili via #1378

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants