Skip to content

[WIP] pubsub replacement of AlertsMessageService - #6187

Closed
benjaminapetersen wants to merge 1 commit into
openshift:masterfrom
benjaminapetersen:bpeterse/refactor-alerts
Closed

benjaminapetersen wants to merge 1 commit into
openshift:masterfrom
benjaminapetersen:bpeterse/refactor-alerts

Conversation

@benjaminapetersen

Copy link
Copy Markdown
Contributor
  • eliminates AlertsMessageService
  • allows the alert directive to listen for events, eliminating need for controller handling $scope.alerts
  • adds dismissable property to alerts, allowing user to dismiss w/icon (see patternfly reference)
  • adds duration property to alerts, allowing auto dismiss after timeout
  • pubsub.publish for immediate alert
  • pubsub.publishAsync for delay, such as route change, before creating alert

Quick example, if all properties used:

 pubsub.publish('alert', {
        type: "error",
        message: "Oh no, a bad thing.",
        details: "Reason: bad stuff happened.",
        dismissable: true,  // user can click 'x' to say 'go away!'
        duration: 10000     // or we will eliminate after 10 seconds automatically
});

@spadgett @jwforres for thoughts

@spadgett

spadgett commented Dec 3, 2015

Copy link
Copy Markdown
Member

I think rather than automatically dismiss alerts, we should wait for Patternfly toast notifications, which are coming soon.

@benjaminapetersen

Copy link
Copy Markdown
Contributor Author

Yeah, i think we could convert, or could have:

pubsub.publish('alert', { });
pubsub.publish('toast', { });
// or namespace, if we think pubsub usage will grow
pubsub.publish('alert.message', { });
pubsub.publish('alert.toast', { });

Would a message vs a toast serve a different purpose?
We also have <tasks>, which generates <class="tile tile-status"> markup, such as when you create a project...

@spadgett

spadgett commented Dec 3, 2015

Copy link
Copy Markdown
Member

Does this get rid of the $scope.alerts in every controller? 👍

@benjaminapetersen

Copy link
Copy Markdown
Contributor Author

Yup 😋

For that reason I'd be up for finishing this now, then fixing for toasts later.

@openshift-bot

Copy link
Copy Markdown
Contributor

Origin Action Required: Pull request cannot be automatically merged, please rebase your branch from latest HEAD and push again

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 4, 2015
@spadgett

Copy link
Copy Markdown
Member

We should look at notifications and the notification service in angular-patternfly to see how it fits with what you have.

https://github.com/patternfly/angular-patternfly

@benjaminapetersen

Copy link
Copy Markdown
Contributor Author

Definitely, lets try to use. I do like a single pubsub module, even if we do pubsub.publish('alerts') and just proxy it to the PF Notification Service. This would give us consistency in the future when we do other pubsub (def prefer avoiding $rootScope & $emit/$broadcast).

I'm a little wary of the PF Notification List sharing a $scope with a controller, rather than 1.) passing explicitly <list notifications="notifications"> or letting it listen to the service directly. Isolation would be a good thing. 😄

@benjaminapetersen

Copy link
Copy Markdown
Contributor Author

TODO (per conversation today):

  • Add support for a persistent alert. It should be possible to make an alert linger while navigating between pages. This can either be a param persist: true or can be a new pubsub channel pubsub.publish('alert.persist', { });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this work properly with multiple alerts or when an alert is dismissed, then another alert with the same type is displayed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe the ng-repeat should treat each alert separately, the ng-switch should cycle for individual alerts. So at this point you should get stacked alerts of the same type, not a queue (which is prob good, we don't have a priority system).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I'm asking more about Bootstrap data-dismiss="alert" because I don't know how it works. For instance, if I add another alert back with the same key, will it show up or stay dismissed from before?

@spadgett

Copy link
Copy Markdown
Member

@benjaminapetersen It looks like you can't use the pf-notification directive outside of pf-notification-list or the dismiss button doesn't work.

Interestingly, their notification disappears after a delay unless you specify persistent. Persistent notifications have a dismiss button.

@benjaminapetersen

Copy link
Copy Markdown
Contributor Author

Interesting, looks like cause all notifications are listed off of $rootScope and use $parent for function... I tend to prefer avoiding both. I do think it makes sense to disappear unless specify delay.

@spadgett

Copy link
Copy Markdown
Member

Wonder if they're using root scope so notifications persist as you navigate to different pages.

@benjaminapetersen

Copy link
Copy Markdown
Contributor Author

Probably, as an alt to storing in a service.

@benjaminapetersen

Copy link
Copy Markdown
Contributor Author

Looks like Toasts landed in Patternfly 2.9.0

@jwforres

Copy link
Copy Markdown
Member

Yep, we have an open issue related to icons in topology view preventing us
from updating to 2.9 yet
On Jan 21, 2016 1:43 PM, "Ben Petersen" [email protected] wrote:

Looks like Toasts landed in Patternfly 2.9.0
https://github.com/patternfly/patternfly/releases/tag/v2.9.0

—
Reply to this email directly or view it on GitHub
#6187 (comment).

@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 27, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 6, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 20, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 24, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 8, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 15, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 24, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 26, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 5, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 12, 2016
@openshift-bot openshift-bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 8, 2016
@danmcp

danmcp commented Jun 14, 2016

Copy link
Copy Markdown

Need to reopen to new ui repo if still valid.

@danmcp danmcp closed this Jun 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/web needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants