-
Notifications
You must be signed in to change notification settings - Fork 231
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
Custom notifications in notification drawer #2001
Custom notifications in notification drawer #2001
Conversation
1c9e134
to
697843e
Compare
// internal notifications have different types than API events | ||
var notificationEventTypeMap = { | ||
success: 'Normal', | ||
error: 'Warning' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should handle all four types in the drawer: info, success, error, and warning. Then we just map event "normal" -> "info"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eliminating both maps via PR to common
|
||
var iconClassByEventSeverity = { | ||
Normal: 'pficon pficon-info', | ||
Warning: 'pficon pficon-warning-triangle-o' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check what toast notifications are doing for these icon mappings. Ideally we have one map somewhere so we're always consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like they use alertIcon
:
<span class="{{notification.type | alertIcon}}" aria-hidden="true"></span>
I'll update & use that
notificationListener = null; | ||
var makeProjectGroup = function(projectName, notifications) { | ||
return { | ||
heading: $filter('displayName')(projects[projectName]) || projectName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ||
is not necessary since displayName
default to name if there's no display name.
var project = projects[projectName]
return {
heading: $filter('displayName')(project),
project: project,
notifications: notifications
};
}; | ||
} | ||
return result; | ||
}, {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benjaminapetersen I know you prefer this indentation style, but the rest of the code uses
return _.reduce(events, function(result, event) {
// ...
});
Let's try to keep consistent styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update this.
Ref #1121 for when we have time.
var proj = $routeParams.project; | ||
return _.orderBy( | ||
_.assign({}, firstMap[proj], secondMap[proj]), | ||
['event.lastTimestamp', 'event.firstTimestamp'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be assigning timestamps to events in notification service to get proper ordering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can follow-up a PR to origin-web-common
to do some work on NotificationsService. This line should just be a fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, OK as a follow on
drawer.drawerHidden = true; | ||
var deregisterEventsWatch = function() { | ||
if(eventsWatcher) { | ||
DataService.unwatch(eventsWatcher); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventsWatcher = null;
// clientGeneratedNotifications.push(notification); | ||
// }; | ||
var notificationWatchCallback = function(event, notification) { | ||
var uid = notification.id || _.uniqueId('notification-'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we should add in an ID for those that don't have one in NotificationsService.
unread: true, | ||
uid: uid, | ||
// emulating an API event to simplify the template | ||
event: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not add a dummy event. I'd rather copy necessary properties like uid
and timestamp
from the event to top-level properties, and use those in the view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok ill update
uid: uid, | ||
// emulating an API event to simplify the template | ||
event: { | ||
lastTimestamp: notification.lastTimestamp || moment.parseZone(new Date()).utc().format(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to add the timestamp in NotificationsService
if(!projectName) { | ||
return; | ||
} | ||
notificationListener = $rootScope.$on('NotificationsService.onNotificationAdded', cb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to add this once instead of registering and removing on project changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. no need to update this one like the events watch.
Updated. Will need a release of |
Hi @benjaminapetersen, The 'Clear All' doesn't appear to be working correctly. I start out with 3 notifications: I think click on an 'X' to remove one: Then click on 'Clear All' and all three re-appear instead of removing them all as I was expecting: |
Thanks @dtaylor113! I made a few updates last night & have another push coming this morn that addresses these items. I updated |
4d1a986
to
8316f01
Compare
Updated & squashed the last 5 commits down. |
btw, Id's are still janky w/o the update to |
8316f01
to
32aa7ff
Compare
Rebased, also put a fallback |
var markRead = function(event) { | ||
_.set(cachedEvents, [event.metadata.uid, READ], true); | ||
var markRead = function(id) { | ||
_.set(cachedEvents, [id, READ], true); | ||
BrowserStore.saveJSON('session','events', cachedEvents); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're saving read and clear status by ID in session storage, we should really change NotificationService to generated a UID instead of using _.uniqueId
. With _.uniqueId
the IDs will be reused if you refresh the page, and notification might be incorrectly hidden from the drawer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true. I could pull the generateSecret
function from ApplicationGenerator
:
scope._generateSecret = function(){
//http://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4()+s4()+s4()+s4();
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler could just be _.uniqueId('notification_') + Date.now()
.
@openshift/team-ux-review Need some feedback! We have our notifications integrated into the drawer with the curated api events. This creates some quirks that we think need to be addressed before we can merge this feature.
These two events should be the same level (actually the "Deployment Created" event might be more weighty than "Deployment Started"), but the icons seem to indicate that "Deployment Created" is of lesser value.
With the API event we link the name of the object, with the internal notification we add a
However, since internal events have 4 states (explained above) we probably don't want 4 icons with counts in the header.
It might be ideal to make these smaller similar to how gmail gives a centered And save the large toasts for bad things:
Thoughts? Observations gathered from earlier discussion with @ncameronbritt @spadgett |
32aa7ff
to
327b0f7
Compare
327b0f7
to
86ebd5c
Compare
The toast notifications are helpful when a user takes an action in the sense that they provide feedback to the user. But obviously toasts aren't the only way we could provide the user feedback that the system registered their input. The little message like gmail provides is another option. Having the button itself do something is yet another. May be worth thinking about this from a PF perspective too for actions that don't obviously change a user's context. |
Right! @ncameronbritt you suggested something like this for a button effect: I dunno why github made the gif huge 😕 |
Right on @benjaminapetersen! I like that that communicates that something is happening right in the place where the user took an action. |
Looks cool, but not consistent with what we do in PatternFly. I'd suggest we wait on that behavior and do some |
@serenamarie125 We've had some feedback from @smarterclayton and @sspeiche that some of the confirmation toasts are annoying. ("I know I just clicked that button. Why are you telling me?") See also #1911. I remember you and @jeff-phillips-18 had similar concerns. The problem is that on some pages, depending on what tab is selected, nothing on the page changes in response to an action. So it can look like the button didn't do anything. One example is clicking "Start Build" on the build config page with the "Configuration" tab selected. Nothing changes, and it seems like the action didn't work. The user might try clicking the button several times and accidentally creating several builds. What we'd really like is a way to let users know an action succeeded that is a little less in-your-face than a toast. A more subtle, "Yep, that worked" message. The Gmail screenshot from @benjaminapetersen is good example. The button changing is also interesting, although I'd like something that works in contexts where there isn't a button. Do you think this make sense to explore as a pattern in Patternfly? |
@spadgett I agree that the toasts can be annoying. IMO, we should be identifying a strategy for default usage of toasts & availability in the notification drawer. Ultimately the user should be able to configure what they would like to see where as well. That being said, I do agree that we need a solution so that users are aware that they have performed an action. @spadgett is this something we can do for 3.8? If so, i think that will give us the ability to perform some research and come up with a solution which should be used for similar use cases across products. (thus my answer is yes i think we should explore a PatternFly solution 😄 ) |
@jeff-phillips-18 shouldn't the toast be UNDER the top banner? Maybe this is a bug in PatternFly, although I thought we had fixed it? |
Hi, common was bumped to 0.0.57 |
@dtaylor113 yup think this PR will wait on all the version bumps in #2103. |
7cb97e9
to
7b7a4b5
Compare
Reviewed & rebased. [test] Quite a few moving parts here, once I finish the test overhaul I want to circle back around & provide some coverage to these components. |
[merge] |
[merge] |
wake up... [merge] |
Another flake
|
flakes, and travis keeps hanging... [merge] |
Needs rebase |
- previously only a curated list of API Events made it into the drawer - this change catches all "internal events" currently experienced as toasts & brings them into the drawer - future improvement may be to suppress the "toast" for certain internal events so as not to excessively message the user
7b7a4b5
to
966b580
Compare
rebased again. |
Evaluated for origin web console test up to 966b580 |
Evaluated for origin web console merge up to 966b580 |
Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin_web_console/232/) (Base Commit: c63e2f5) (PR Branch Commit: 966b580) |
Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_web_console/236/) (Base Commit: 2041c75) (PR Branch Commit: 966b580) |
Integrates our internal notifications into the notification drawer.
Enhancement to #1326
@spadgett