Skip to content
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

Merged
merged 1 commit into from
Jan 24, 2018

Conversation

bgeuken
Copy link
Member

@bgeuken bgeuken commented Jan 22, 2018

#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.

@bgeuken bgeuken added the Frontend Things related to the OBS RoR app label Jan 22, 2018
@bgeuken
Copy link
Member Author

bgeuken commented Jan 22, 2018

@adrianschroeter JFYI^

@@ -0,0 +1,2 @@
$('#subscriptions-form').replaceWith('<%= escape_javascript(render(partial: 'webui/subscriptions/subscriptions_form')) %>');

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:

  1. Click Reset link
  2. Send ajax requests to SubscriptionsController#index
  3. 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

Copy link
Member Author

@bgeuken bgeuken Jan 22, 2018

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# ##"

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.
@codecov
Copy link

codecov bot commented Jan 22, 2018

Codecov Report

Merging #4384 into master will decrease coverage by <.01%.
The diff coverage is 90%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#api 80.19% <ø> (ø) ⬆️
#rspec 70.77% <90%> (ø) ⬆️

@bgeuken bgeuken merged commit c1337f0 into openSUSE:master Jan 24, 2018
@bgeuken bgeuken deleted the update_subscriptions branch January 24, 2018 11:03
hennevogel added a commit to hennevogel/open-build-service that referenced this pull request May 27, 2024
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!
hennevogel added a commit to hennevogel/open-build-service that referenced this pull request May 28, 2024
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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Things related to the OBS RoR app
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants