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: agentless nodes banner #14971

Merged
merged 11 commits into from
Oct 19, 2022
Merged

ui: agentless nodes banner #14971

merged 11 commits into from
Oct 19, 2022

Conversation

WenInCode
Copy link
Contributor

@WenInCode WenInCode commented Oct 13, 2022

Description

Displays a notice banner on the nodes index page if there are agentless nodes that are being filtered. I've adopted the existing <Notice> component styling, instead of exactly what was prescribed in the designs. Should we want to update the <Notice> banner design, I would be happy to do so in a follow-up.

I discussed how we should be storing the dismissal in consul in the tech-frontend channel. There is not a good way for consul to persist this data at the moment, and because we have anonymous users, the key can't be user based. For now I am just storing this key in local storage. Right now, if you were to dismiss the notice it would not show up again on any datacenter. Should we want to have it show up per datacenter, we could add that to the key. This is now being saved per dc.

Updated Demo:
https://www.loom.com/share/311578f76ac2406f8be4c38d0fab3a8e

Screenshots

Screen Shot 2022-10-12 at 6 17 09 PM

Links

PR Checklist

  • updated test coverage
  • external facing docs updated
  • not a security concern

@jnwright
Copy link
Contributor

I think we want to show this per cluster since it would be different Kubernetes deployments, and it might be a good reminder. There's nowhere in the UI right now that explicitly calls out whether a cluster is a Kubernetes deployment or not, so users may (?) forget and wonder why there are no client agents if the banner has been removed. @jkirschner-hashicorp do you agree, or do you think showing it once is fine?

@WenInCode
Copy link
Contributor Author

@jnwright I've udpated it to save the key based on the datacenter, so the banner will show up per dc.

If you want to try this out you can on this build: https://consul-ui-staging-ds2vj97yj-hashicorp.vercel.app/ui/dc1/nodes

I'll work on getting the mock-data working (without breaking existing tests) after lunch in a new branch.

@jnwright
Copy link
Contributor

is there a way to do it per partition? clusters are represented by partitions in ENT, not datacenters. I'm trying to consider the case of a user having more than one kubernetes deployment. So one or more partitions are kubernetes, and one is a non-agentless deployment. if they dismiss it once for the whole datacenter, they could switch to the other runtime's cluster and see client nodes. they would then switch to the other kubernetes partition and not remember that it's kubernetes. if there's no banner, they could think it's an error that there are no client nodes.

@WenInCode
Copy link
Contributor Author

@jnwright I did not know that's how it worked for ENT. I've updated it to have a postfix that is a combination of both dc and partition. so if one of them is present it will be that one, but if both are present it will be both.

you can try it out here: https://consul-ui-staging-2c89cdyf6-hashicorp.vercel.app/ui/dc1/nodes

Copy link
Contributor

@jnwright jnwright left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

Copy link
Contributor

@LevelbossMike LevelbossMike left a comment

Choose a reason for hiding this comment

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

Requesting changes as I added a comment that we might want to discuss in this PR. Please let me know what you think about adding a reactive LocalStorage-wrapper for this feature.

this.storageKey = `consul-nodes-agentless-notice-dismissed-${this.args.postfix}`;
}

if (window.localStorage.getItem(this.storageKey) === DISMISSED_VALUE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Three things that came to my mind when looking at this:

  1. Accessing local-storage directly and not wrapping it will make the test-suite really persist values when we dismiss a notice
  2. We are checking against a string, although we are setting a boolean when dismissing
  3. We aren't really deriving state, but checking local storage and then setting state based on that, which kind of goes against the reactive state ideas of Octane.

What I could imagine doing is creating a wrapper service for local-storage that works with storage classes that encapsulate the buckets of storage we want to interact with. This sounds complicated and may be overkill for a use-case like this, but I suppose we have other places in the application that could benefit from an approach like this.

I prototyped a mechanism that is heavily inspired by ember-local-storage, but works with tracked properties in a repository of mine:

https://github.com/LevelbossMike/local-storage-service

I also demonstrate how this mechanism could be used in testing so that we don't pollute local-storage when executing the test-suite.

Having said that, I'm unsure, if it would be worth the effort to add a mechanism like this for this particular feature. How do you feel about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@LevelbossMike I originally was trying to use ember-tracked-local-storage to get the reactive nature of it, instead of reading that localstorage state and setting local state based on it. I ran into issues with setting up dynamic keys with the tracked property. However, that doesn't look like it would be an issue in your package.

Ember question for you. I don't see where the notices get tracked in your example. Do changes to services state trigger changes in the same way that arguments or tracked properties do?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just leaving this here for history. As discussed briefly in a call: In the example repository, I'm setting up the notices-storage so that it uses a tracked array internally. That's the reason we can create reactive getters based on the state-property of the notices-storage.

Reference: https://github.com/tracked-tools/tracked-built-ins

Use local-storage service, prototyped here https://github.com/LevelbossMike/local-storage-service, to manage local storage usage in an octane way. Does not write to local storage in tests by default and is easy to stub out.
@WenInCode
Copy link
Contributor Author

@LevelbossMike letting you know it's ready for another review from you tomorrow

Copy link
Contributor

@LevelbossMike LevelbossMike left a comment

Choose a reason for hiding this comment

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

👏 - nice!

@WenInCode WenInCode merged commit 2a9cc3f into main Oct 19, 2022
@WenInCode WenInCode deleted the ui/feature/agentless-nodes-banner branch October 19, 2022 15:06
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.

3 participants