Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[feature] Added generic message notification type (shown in dialg box) #275
[feature] Added generic message notification type (shown in dialg box) #275
Changes from 17 commits
c207c9d
1025bfb
2605a09
bf3ba25
a15a284
3a0377d
2be7037
581cc90
a7c792d
9e7c1fc
2608c11
2a922a6
0686c2d
8106f3e
cc528df
aca39bc
1e6b840
00ec345
e69600f
bbff510
8dfcfce
df10915
6e5db98
6de368f
b0725b1
9ed5982
4a9956b
4593ef3
9f11de6
b09cd6f
8229268
08ab21b
69bfb39
0020c21
859734e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@pandafy do you think we could avoid binding on
document
here too? ThatstopPropagation()
below scares me. We could incur in the same problem we had for the keyup event in other modules if we need to use the same JS event. The problem will be that to find this will probably take hours because by that time we'll have forgotten.We can open a new issue for this.
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.
Can we make these checks re-usable? We also use these for click 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.
This change makes the checks reusable, but it might add unnecessary complexity and confusion for now ig. If you need to then I will do it.
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 will fire on every keyup event that will happen in OpenWISP. Are you sure this change is intended?
Can't we narrow down the firing a bit to make sure it's not fired unless needed?
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 allows the notification dialog or widget to close whenever the ESC is pressed. I would like to know if there is any other way to reduce it.
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.
While this is a useful, yet basic feature. I don't know how I feel about triggering an event handler for every key press. This JS is loaded on all the pages of OpenWISP. so this event handler will get executed when filling out any field in OpenWISP.
If we plan to to keep this, we shall adopt the concept of early return. In this case, return from the function if the key is not
Esc
.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 avoid doing such practices because it would break functionalities added by other modules.
This is the reason for openwisp/openwisp-controller#868 bug.
I apologise that this exist!!!
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 we find a way to avoid to bind to the document like that, it should be possible to specify to which element to bind, or filter the elements instead of using
*
, probably also removinge.stopPropagation();
may be a good idea, depending if we bind this event to an HTML container shared with the rest of the UI or with some other HTML container which is specific to the notifications module.@Dhanus3133 please let me know if the suggestion above is clear.
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.
Updated, let me know if that requires some 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.
It works, thanks!
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.
It is not clear to me what are we doing here.
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.
Actually, in the call, we discussed on the generic message type we don't want to allow users to click on the
target_url
directly something like this on theOrg 2
So, with this regex, we eliminate this ability. The users view the description and then proceed to the
target_url
via the dialog. (Will add comments there)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 went ahead and fixed the reason for failing test. This would allow us to close this PR quickly.
In previous commits, we changed the logic of the
notify
handler to give preference to thelevel
kwarg passed to the notify signal.@Dhanus3133 we need to add a test case in test_models.py which verifies that the preference of level is given to the
level
kwargs over thelevel
defined in notification type.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 believe the file is
test_notifications.py
. Updated with the changes there.