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

ui: Create and use collapsible notices component #10270

Closed
wants to merge 3 commits into from

Conversation

kaxcode
Copy link
Contributor

@kaxcode kaxcode commented May 20, 2021

collapsible_banner

  • Creates CollapsibleNotices component
  • Restructure the acceptance tests folder for topology
  • Adds testing for TProxy notices in Topology tab
  • Use of CollapsibleNotices in Toplogy route when there are more than 2 Notices.

@kaxcode kaxcode added the theme/ui Anything related to the UI label May 20, 2021
@kaxcode kaxcode requested a review from johncowen May 20, 2021 14:53
@@ -22,43 +22,93 @@ as |route|>
</BlockSlot>
</EmptyState>
{{else}}


{{#if (or (and topology.DefaultAllow topology.FilteredByACLs topology.undefinedIntention) (and topology.WildcardIntention topology.FilteredByACLs topology.undefinedIntention)) }}
Copy link
Contributor Author

@kaxcode kaxcode May 20, 2021

Choose a reason for hiding this comment

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

🙈 The conditional works but I had to duplicate the code in the {{else}}. LMK if you can think of a better way to format this. @johncowen

Copy link
Contributor

Choose a reason for hiding this comment

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

Theres an option here to maybe make a computedProperty on the topology model

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok so I've had a proper look at this after our chat, I guess I can think of a couple of options:

  1. I remember speaking to @freddygv about the all of these boolean type properties can quickly get out of hand, and I wondered if using some sort of state: "" with a predefined list of states might have been a better approach here? From the condition you've written here it looks like there are two states, I'm not sure if thats correct or not as I don't have enough context into the feature to know. This one is obviously necessitates a backend change, and it might not even be possible/might be a bit late in the game to be tweaking this, but it is an internal endpoint so maybe not?
  2. If the booleans are this 'nuanced', it looks to me like this is just an or checking all four fields, which is more straightforwards that what you have here, and that also lines up with how you've written the conditionals below.
{{or 
  topology.DefaultAllow
  topology.FilteredByACLs
  topology.undefinedIntention
  topology.WildcardIntention
}}

Actually didn't we remove all the references to undefined?

Me personally I like number 2 more than the computed property option, as this is a view concern not a model one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The 2nd option does not take into account that I have to have >2 notices to show that button. That's what I'm trying to capture in the conditionals I wrote. Grouping them all together in the or does not guarantee that use case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahhh, of course yeah I forgot about that 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Wonder if you could do something with compact or array_some 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe this?

      {{#let (without false (array true true false false)) as |visibleNotices|}}
        {{if gt visibleNotices.length 2}}
          {{!-- make collapsable --}}
        {{/if}}
      {{/let}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've already moved the logic to a computed func in the model. Does that work?
I also just pushed renaming undefinedIntention to be notDefinedIntention.

@vercel vercel bot temporarily deployed to Preview – consul May 20, 2021 14:59 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging May 20, 2021 14:59 Inactive
@kaxcode kaxcode force-pushed the ui/feature/collapsable-banners branch from c03276d to f3c75d6 Compare May 21, 2021 14:46
@vercel vercel bot temporarily deployed to Preview – consul May 21, 2021 14:47 Inactive
Copy link
Contributor

@johncowen johncowen left a comment

Choose a reason for hiding this comment

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

Sorry I had this sitting here this morning and I hadn't submitted the review, just realized you pushed the computed version! Sorry!

Anyway, read through and see what you think.

ui/packages/consul-ui/tests/pages/dc/services/show.js Outdated Show resolved Hide resolved
@@ -22,43 +22,93 @@ as |route|>
</BlockSlot>
</EmptyState>
{{else}}


{{#if (or (and topology.DefaultAllow topology.FilteredByACLs topology.undefinedIntention) (and topology.WildcardIntention topology.FilteredByACLs topology.undefinedIntention)) }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok so I've had a proper look at this after our chat, I guess I can think of a couple of options:

  1. I remember speaking to @freddygv about the all of these boolean type properties can quickly get out of hand, and I wondered if using some sort of state: "" with a predefined list of states might have been a better approach here? From the condition you've written here it looks like there are two states, I'm not sure if thats correct or not as I don't have enough context into the feature to know. This one is obviously necessitates a backend change, and it might not even be possible/might be a bit late in the game to be tweaking this, but it is an internal endpoint so maybe not?
  2. If the booleans are this 'nuanced', it looks to me like this is just an or checking all four fields, which is more straightforwards that what you have here, and that also lines up with how you've written the conditionals below.
{{or 
  topology.DefaultAllow
  topology.FilteredByACLs
  topology.undefinedIntention
  topology.WildcardIntention
}}

Actually didn't we remove all the references to undefined?

Me personally I like number 2 more than the computed property option, as this is a view concern not a model one.

Copy link
Contributor

@johncowen johncowen left a comment

Choose a reason for hiding this comment

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

LGTM! Especially, thanks for adding the docs for the new component!

There are a couple of things here we could potentially circle back and tweak, but fine to do that in a PR in the future at some point.

@kaxcode kaxcode force-pushed the ui/feature/collapsable-banners branch from f9fc233 to 52af9e7 Compare May 25, 2021 15:42
@vercel vercel bot temporarily deployed to Preview – consul May 25, 2021 15:42 Inactive
@kaxcode kaxcode closed this May 25, 2021
dhiaayachi pushed a commit that referenced this pull request May 25, 2021
* Create and use collapsible notices

* Refactor collapsible-notices

* Split up the topology acceptance tests

* Add acceptance tests for tproxy notices

* Add component file

* Adds additional TProxy notices tests

* Adds conditional to only show collapsable if more than 2 notices are present

* Adds changelog

* Refactorting the conditonal for collapsing the notices

* Renaming undefinedIntention to be notDefinedIntention

* Refactor tests
dhiaayachi pushed a commit that referenced this pull request May 25, 2021
* Create and use collapsible notices

* Refactor collapsible-notices

* Split up the topology acceptance tests

* Add acceptance tests for tproxy notices

* Add component file

* Adds additional TProxy notices tests

* Adds conditional to only show collapsable if more than 2 notices are present

* Adds changelog

* Refactorting the conditonal for collapsing the notices

* Renaming undefinedIntention to be notDefinedIntention

* Refactor tests
mikemorris pushed a commit that referenced this pull request May 27, 2021
* Create and use collapsible notices

* Refactor collapsible-notices

* Split up the topology acceptance tests

* Add acceptance tests for tproxy notices

* Add component file

* Adds additional TProxy notices tests

* Adds conditional to only show collapsable if more than 2 notices are present

* Adds changelog

* Refactorting the conditonal for collapsing the notices

* Renaming undefinedIntention to be notDefinedIntention

* Refactor tests
@kaxcode kaxcode deleted the ui/feature/collapsable-banners branch August 13, 2021 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants