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
Add support for links to a details page in the notification drawer #4492
Conversation
6c21f3d
to
b8d0b74
Compare
b8d0b74
to
2e481b9
Compare
2e481b9
to
c835ec5
Compare
@@ -129,6 +129,8 @@ function eventNotifications($timeout, API) { | |||
type: levelToType(type), | |||
message: message, | |||
data: notificationData, | |||
actionTitle: __('View details'), |
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.
@mzazrivec is this okay?
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.
Yes, I think so.
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.
Thanks 🍀 🍀
@@ -129,6 +129,8 @@ function eventNotifications($timeout, API) { | |||
type: levelToType(type), | |||
message: message, | |||
data: notificationData, | |||
actionTitle: __('View details'), | |||
actionCallback: this.viewDetails, |
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 do not want all notifications to have the View Details
link.
For e.g. in v2v, only the unsuccessful Request notifications need to have the View Details link, whereas the successful Request notifications should be plain messages without links
Is there a way to regulate that?
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.
Do we need new parameters in notification_types.yml for supplying more information about the link to the frontend ?
Information such as -
- Whether we need a link
:link: true
or:link: false
- Link text (other areas of the UI may need the text to be something other than "View Details")
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.
Theoretically possible, but there are some questions:
- Do you have control over what kind of notification types are getting emitted from automate?
- Are we okay with schema changes?
- Why do we need a custom link text? I am pretty sure it's not a good idea to specify it in the backend ...
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.
Or after thinking in the tram, it might be doable through decorators. What if we would have a notification_link
method into the subject's decorator and move the logic from the techdebt controller to there.
Something like this:
class ServiceTemplateTransformationPlanRequestDecorator < MiqDecorator
def notification_link
req = ServiceTemplateTransformationPlanRequest.select(:source_id).find(params[:id])
if aparna_says_link_is_needed(req)
{ :controller => 'migration', :action => 'index', :anchor => "plan/#{req.source_id}" }
else
nil
end
end
end
Generating the text binding:
def text_bindings
[:initiator, :subject, :cause].each_with_object(text_bindings_dynamic) do |key, result|
value = public_send(key)
result[key] = {
:link => value.decorate.notification_link,
:text => value.try(:name) || value.try(:description)
}.compact if value
end
end
And finally the controller:
class RestfulRedirectController < ApplicationController
def index
redirect_to(params[:link])
end
end
@AparnaKarve @martinpovolny @himdel what do you think?
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.
After thinking this through, maybe it's not the best idea to expose a redirect_to
so publicly. So it would be much safe to test in the text_bindings
if the notification has a notnil
result from the decorator and call the decorator again in the redirect controller...
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.
def aparna_says_link_is_needed?(request_id)
request = ServiceTemplateTransformationPlanRequest.find(request_id)
request.request_state == "finished" && request.status != "Ok"
end
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.
@AparnaKarve thanks 👍, yes it would work in your case, but on many other screens it won't and there's a request from @Ladas and @martinpovolny to support clickable links for some provider-related tasks that are accessible only through explorer screens. I would not like to maintain two different implementations until its really necessary.
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 think that this is getting too complex. The idea with decorators sounds like working around a need to add an attribute.
It's getting too complex.
The notification should be created with all the information needed.
if request_state == "finished" && status != "Ok"
then set some attribute telling the details are to be displayed. The information if the link should be displayed needs to be part of the notification.
We should not take the notification and do further lookups to decide whether to display details link.
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.
@skateman Are we now implementing what I first suggested above? #4492 (comment)
ManageIQ/manageiq-schema#263 looks good to me!
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.
@AparnaKarve as Martin stated I was trying to avoid changing the schema, but it will be better to do so.
%ul.dropdown-menu.dropdown-menu-right{'aria-labelledby' => 'dropdownKebabRight-{{ notification.id }}'} | ||
%li{:role => 'menuitem'} | ||
%a.secondary-action{:title => _('View details'), 'ng-click' => 'customScope.viewSubjectDetails(notification)'} | ||
= _('View deatils') |
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.
typo
@skateman So I verified that the |
@skateman without that ng-if drawerExpanded, doesn't this reintroduce the looong rendering with thousands of notifications problem? |
@himdel nice catch, going to fix it |
c835ec5
to
cb00a4a
Compare
@AparnaKarve could you please provide me the PR (enough if WIP) where you are emitting notifications? I'd need it to proceed... |
@skateman There is no PR yet... manageiq - backend_notifications_for_v2v_requests |
cb00a4a
to
d592c21
Compare
I added a backend and a schema PR to set if we want links for the given notification or not. @miq-bot add_label pending core |
I like this approach much better that the idea with the decorators. Thx, @skateman 👍 The "View deatils" typo from the screenshot seems fixed in the code. |
@miq-bot rm_label pending core |
@miq-bot assign @martinpovolny |
d592c21
to
f9eeeb4
Compare
Checked commits skateman/manageiq-ui-classic@abc67d4~...f9eeeb4 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
The angular-patternfly has a new notification-body template example for the notification drawer that displays a kebab on the right side of a notification with all the available actions inside.
For now we supported just two actions: marking a notification as read (by clicking on it) and removing the notification (by clicking on the
x
). However, the plan is to support at least one extra action to redirect the user to a page where the user can see more details.After the changes it will have the three actions inside the kebab, where the new View Details should redirect to the subject's screen:
For the toasts, it will have an extra
View details
link that does the same:Unfortunately, it is not possible to hide the link if the subject has an actual page to redirect to, so if the user clicks on the
View Details
for a such record, it will redirect to the dashboard with an error message:Hopefully this could be resolved in the future by omitting the link if it is not available, probably by using decorators or something similar.
@miq-bot add_reviewer @karelhala
@miq-bot add_reviewer @Hyperkid123
@miq-bot add_reviewer @martinpovolny
@miq-bot add_reviewer @AparnaKarve
@miq-bot add_label enhancement
Related issue: ManageIQ/manageiq-v2v#578
Schema PR: ManageIQ/manageiq-schema#263
Backend PR: ManageIQ/manageiq#17913