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

New event that lets plugins trigger notifications in the admin area #11483

Merged
merged 3 commits into from Mar 18, 2017

Conversation

Projects
None yet
2 participants
@tsteur
Member

tsteur commented Mar 14, 2017

They have to be triggered before assigning the notifications to the view and there is no other way to determine when a plugin is supposed to trigger notifications in the admin. Ideally, in the future we would even move the notifications above to CoreAdminHome or somewhere else eventually.

First thought of using Controller.addAdminNotifications as we often use this wording but then we would need to rather do Piwik::postEvent('Controller.triggerAdminNotifications', &$notifications); as otherwise nothing can be added.

Plugins could actually also use this event to cancel notifications where in the past it was needed to hide them via CSS.

Happy about any other naming suggestions but want to keep it "specific" to notifications and not something to general like postEvent('Controller.renderAdminView, $view').

tsteur added some commits Mar 14, 2017

New event that lets plugins trigger notifications in the admin area
They have to be triggered before assigning the notifications to the view and there is no other way to determine when a plugin is supposed to trigger notifications in the admin. Ideally, in the future we would even move the notifications above to CoreAdminHome or somewhere else eventually.

First thought of using `Controller.addAdminNotifications` as we often use this wording but then we would need to rather do `Piwik::postEvent('Controller.triggerAdminNotifications', &$notifications);` as otherwise nothing can be added.

Plugins could actually also use this event to cancel notifications where in the past it was needed to hide them via CSS. 

Happy about any other naming suggestions but want to keep it "specific" to notifications and not something to general like `postEvent('Controller.renderAdminView, $view')`.

@tsteur tsteur added the Needs Review label Mar 14, 2017

@tsteur tsteur added this to the 3.0.3 milestone Mar 14, 2017

@sgiehl

This comment has been minimized.

Member

sgiehl commented Mar 17, 2017

Not sure if setBasicVariablesAdminView() is the right place to trigger that event.

Couldn't the method setBasicVariablesAdminView() maybe be called even on non admin pages?
When having a plugin with at least one page shown in admin the controller would inherit from ControllerAdmin, calling setBasicVariablesView which is more or less required to display any page will also trigger setBasicVariablesAdminView(). If that controller should additionally have one page showing up as "normal" page it might also call setBasicVariablesView. Correct?
But maybe that's only an negligible edge case...

Otherwise LGTM

@tsteur

This comment has been minimized.

Member

tsteur commented Mar 18, 2017

There is also the problem that some controllers do not extend the admin controller like ScheduledReports (even though it is shown in the admin) and the notification wouldn't appear there.

I trigger the event there because this is the place where we also show all the other notifications like invalid plugins, invalid license, php version is EOL, debug mode is enabled, etc and this is shortly before we assign the notifications to the admin view. So at least we make sure to be consistent and show them together or none. From what I saw eg in scheduled reports controller it then calls setGeneralVariablesView() and not the basic variables.

At some point we really need to refactor this and have only one controller and more clear indication whether it is an admin page, a reporting page or a regular standalone page like All Websites Dashboard but for now there is not really another place for it.

Later we could also add an event Controller.triggerReportingNotifications or similar if needed that is triggered in Controller class.

@tsteur tsteur merged commit 794e5d4 into 3.x-dev Mar 18, 2017

1 of 2 checks passed

continuous-integration/travis-ci/push The Travis CI build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@tsteur tsteur deleted the adminnotifications branch Mar 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment