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

Additional options to control Alert Banner visibility #3764

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

jacob-xhio
Copy link
Contributor

@jacob-xhio jacob-xhio commented Aug 22, 2024

…version

Hoist P/R Checklist

Pull request authors: Review and check off the below. Items that do not apply can also be
checked off to indicate they have been considered. If unclear if a step is relevant, please leave
unchecked and note in comments.

  • Caught up with develop branch as of last change.
  • Added CHANGELOG entry, or determined not required.
  • Reviewed for breaking changes, added breaking-change label + CHANGELOG if so.
  • Updated doc comments / prop-types, or determined not required.
  • Reviewed and tested on Mobile, or determined not required.
  • Created Toolbox branch / PR, or determined not required.

If your change is still a WIP, please use the "Create draft pull request" option in the split
button below to indicate it is not ready yet for a final review.

Pull request reviewers: when merging this P/R, please consider using a squash commit to
collapse multiple intermediate commits into a single commit representing the overall feature
change. This helps keep the commit log clean and easy to scan across releases. PRs containing a
single commit should be rebased when possible.

@jacob-xhio jacob-xhio linked an issue Aug 22, 2024 that may be closed by this pull request
Copy link
Member

@amcclain amcclain left a comment

Choose a reason for hiding this comment

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

So I had not thought of combining these into a single property. Appreciate the implementation here, trying to weigh pros/cons.

Pros

  • Simpler, maybe, in that there's one new (replacement) top-level property on the spec.
  • and still one form control in the UI.

Cons

  • minor breaking change for any apps that had a preset saved with clientApps - I am not overly worried about it, there might be one or two, but if we added two new props for the new limits, the existing ones would still work
  • would it be more clear to have dedicated controls for each limit? Thinking of how limits across dimensions are AND'd together, OR'd within.
  • Limiting the current app version helpful in a way - although if you wanted to have a banner ready to show to an upcoming release you couldn't do it. If we had a dedicated text input you could put in current or next, etc.
  • Don't want to save appVersion in presets - easier to selectively include if in dedicated field

I dunno - obviously making a case here for separate fields to some extent, but happy to discuss, do appreciate aspects of this approach

try {
const roles = await XH.fetchJson({
url: 'roleAdmin/list'
});
Copy link
Member

Choose a reason for hiding this comment

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

This service might not always be enabled - some apps don't use Hoist's built-in role management. In that case, this would throw. Looks like we should have this call roleAdmin/config first to determine if enabled. If so, go on to load the roles. If not, might end up updating the UI, depending on how much we say about roles that's visible to users.

{lastDismissed, onClose} = this;

if (
!active ||
!message ||
(expires && expires < Date.now()) ||
(lastDismissed && lastDismissed > publishDate) ||
!this.isTargetedApp(clientApps)
isEmpty(limitTo) ||
Copy link
Member

Choose a reason for hiding this comment

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

This looks wrong - believe instead you want all the helper methods below to return true if no limits spec'd

/**
* Returns `true` if there are no limitations on application or if the
* current application is included in the defined limits.
* Returns `false` otherwise.
Copy link
Member

Choose a reason for hiding this comment

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

Nit - we can leave off the "returns false otherwise" - implied. TBH these first two private methods don't really need comments - they are pretty clear on their own. Could amend the first to isTargetedClientApp for a bit of extra clarity. A comment on the role method to indicate that user needs to have at least one of the roles might be helpful.

label: `Role: ${role}`,
value: `role-${role}`
}))
);
Copy link
Member

Choose a reason for hiding this comment

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

Would alpha-sort these if we go this route

}))
noOptionsMessageFn: () =>
'Enter one or more app codes, app versions, or roles.',
options: limitToOptions
}),
info: fragment(
span('Specify what apps should the banner be shown to.'),
Copy link
Member

Choose a reason for hiding this comment

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

This help text is now mismatched

@amcclain amcclain changed the title feat(AlertBanner): allow banner visibility filtering by role and app … Additional options to control Alert Banner visibility Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Additional options for controlling alert banner visibility
2 participants