-
Notifications
You must be signed in to change notification settings - Fork 437
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
[frontend] Fix default subscription switch #4384
Conversation
@adrianschroeter JFYI^ |
@@ -0,0 +1,2 @@ | |||
$('#subscriptions-form').replaceWith('<%= escape_javascript(render(partial: 'webui/subscriptions/subscriptions_form')) %>'); |
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 seems like quite a round-about way of doing implementing this feature, I mean, we have many steps to implement this feature:
- Click Reset link
- Send ajax requests to SubscriptionsController#index
- Return javascript to replace #subscriptions-form with the default subscriptions form html rendered in the javascript.
Why not just make the Reset link be a normal request to the controller? Also FYI reseting a user's subscriptions to the default can also be achieved by deleting all of the user's subscriptions. So it could be done with a destroy method on the controller i.e.
def destroy
subscriptions_form.reset_to_default
end
And then in event_subscription/form.rb:
def reset_to_default
subscriber.event_subscriptions.delete_all
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.
@evanrolfe With the current approach a user can see the change and then decide if he wants it or not. Your proposal would directly apply the changes.
And regarding the roundtrip... we have that one way or the other. And without ajax we even have a full page reload.
@subscriptions_form = subscriptions_form | ||
@subscriptions_form = subscriptions_form(default_form: params[:default_form]) | ||
|
||
Rails.logger.debug "### ping# ##" |
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.
Please remove this before merging!
PR#4336 added a switch that allows users to reset their notification subscription to default. This was hardcoded to clear all subscriptions. With this commit the default subscription settings are retrieved from the server via ajax and properly set in the ui. The user can then decide to save the new settings or cancel it by reloading the page.
10471e1
to
cbd05fc
Compare
Codecov Report
@@ Coverage Diff @@
## master #4384 +/- ##
==========================================
- Coverage 88.13% 88.13% -0.01%
==========================================
Files 352 352
Lines 18691 18696 +5
==========================================
+ Hits 16474 16478 +4
- Misses 2217 2218 +1
|
This got added in openSUSE#4186 and openSUSE#4384 and then removed while switching interfaces to bootstrap in openSUSE#8341. Fixes openSUSE#16198 which was caused by a spammer script going back and forth on routes with format=js because it could not acknowledge a status message anymore. Thanks spammer, keep up the good work!
This got added in openSUSE#4186 and openSUSE#4384 and then removed while switching interfaces to bootstrap in openSUSE#8341. Fixes openSUSE#16198 which was caused by a spammer script going back and forth on routes with format=js because it could not acknowledge a status message anymore. Thanks spammer, keep up the good work!
#4336 added a switch that allows users to reset their notification
subscription to default. This was hardcoded to clear all subscriptions.
With this commit the default subscription settings are retrieved from
the server via ajax and properly set in the ui.
The user can then decide to save the new settings or cancel it by
reloading the page.