Commit bf93f2fae5c24e48e0fd4811d68c98fc03133dbf

Authored by Cyril Mougel
2 parents 091eadae e3bc88ae
Exists in master and in 1 other branch production

Merge pull request #613 from mildavw/seriously

"Seriously?" Seriously? Replace these resolve/delete confirmations with ...
app/helpers/problems_helper.rb
1 module ProblemsHelper 1 module ProblemsHelper
2 - def problem_confirm  
3 - Errbit::Config.confirm_resolve_err === false ? nil : 'Seriously?' 2 + def problem_confirm(action)
  3 + t('problems.confirm.%s' % action) unless Errbit::Config.confirm_err_actions.eql? false
4 end 4 end
5 5
6 def truncated_problem_message(problem) 6 def truncated_problem_message(problem)
app/views/apps/edit.html.haml
1 - content_for :title, 'Edit App' 1 - content_for :title, 'Edit App'
2 - content_for :action_bar do 2 - content_for :action_bar do
3 = link_to_copy_attributes_from_other_app 3 = link_to_copy_attributes_from_other_app
4 - = link_to 'destroy application', app_path(app), :method => :delete, :data => { :confirm => 'Seriously?' }, :class => 'button' 4 + = link_to 'delete application', app_path(app), :method => :delete,
  5 + :data => { :confirm => t('apps.confirm_delete') }, :class => 'button'
5 = link_to('cancel', app_path(app), :class => 'button') 6 = link_to('cancel', app_path(app), :class => 'button')
6 7
7 = form_for app do |f| 8 = form_for app do |f|
app/views/problems/_table.html.haml
@@ -40,7 +40,9 @@ @@ -40,7 +40,9 @@
40 %td.issue_link 40 %td.issue_link
41 - if problem.app.issue_tracker_configured? && problem.issue_link.present? && problem.issue_link != 'pending' 41 - if problem.app.issue_tracker_configured? && problem.issue_link.present? && problem.issue_link != 'pending'
42 = link_to image_tag("#{problem.issue_type}_goto.png"), problem.issue_link, :target => "_blank" 42 = link_to image_tag("#{problem.issue_type}_goto.png"), problem.issue_link, :target => "_blank"
43 - %td.resolve= link_to image_tag("thumbs-up.png"), resolve_app_problem_path(problem.app, problem), :title => "Resolve", :method => :put, :data => { :confirm => problem_confirm }, :class => 'resolve' if problem.unresolved? 43 + %td.resolve= link_to image_tag("thumbs-up.png"), resolve_app_problem_path(problem.app, problem),
  44 + :title => "Resolve", :method => :put, :data => { :confirm => problem_confirm('resolve_one') },
  45 + :class => 'resolve' if problem.unresolved?
44 - if problems.none? 46 - if problems.none?
45 %tr 47 %tr
46 %td{:colspan => (any_issue_links ? 8 : 7)} 48 %td{:colspan => (any_issue_links ? 8 : 7)}
@@ -49,4 +51,6 @@ @@ -49,4 +51,6 @@
49 .tab-bar 51 .tab-bar
50 %ul 52 %ul
51 - %w(merge unmerge resolve unresolve delete).each do |action| 53 - %w(merge unmerge resolve unresolve delete).each do |action|
52 - %li= submit_tag action.capitalize, :id => "#{action}_problems", :class => 'button', :data => { :action => polymorphic_path([action == 'delete' ? 'destroy' : action, 'several_problems']), :confirm => problem_confirm } 54 + %li= submit_tag action.capitalize, :id => "#{action}_problems", :class => 'button',
  55 + :data => { :action => polymorphic_path([action == 'delete' ? 'destroy' : action, 'several_problems']),
  56 + :confirm => problem_confirm(action) }
app/views/problems/show.html.haml
@@ -13,9 +13,11 @@ @@ -13,9 +13,11 @@
13 = problem.last_notice_at.to_s(:precise) 13 = problem.last_notice_at.to_s(:precise)
14 - content_for :action_bar do 14 - content_for :action_bar do
15 - if problem.unresolved? 15 - if problem.unresolved?
16 - %span= link_to 'resolve', [:resolve, app, problem], :method => :put, :data => { :confirm => problem_confirm }, :class => 'resolve' 16 + %span= link_to 'resolve', [:resolve, app, problem], :method => :put,
  17 + :data => { :confirm => problem_confirm('resolve_one') }, :class => 'resolve'
17 - if current_user.authentication_token 18 - if current_user.authentication_token
18 - %span= link_to 'iCal', polymorphic_path([app, problem], :format => "ics", :auth_token => current_user.authentication_token), :class => "calendar_link" 19 + %span= link_to 'iCal', polymorphic_path([app, problem], :format => "ics",
  20 + :auth_token => current_user.authentication_token), :class => "calendar_link"
19 %span>= link_to 'up', (request.env['HTTP_REFERER'] ? :back : app_problems_path(app)), :class => 'up' 21 %span>= link_to 'up', (request.env['HTTP_REFERER'] ? :back : app_problems_path(app)), :class => 'up'
20 %br 22 %br
21 = render "issue_tracker_links" 23 = render "issue_tracker_links"
@@ -37,7 +39,8 @@ @@ -37,7 +39,8 @@
37 - else 39 - else
38 %span.comment-info 40 %span.comment-info
39 = time_ago_in_words(comment.created_at, true) << " ago by [Unknown User]" 41 = time_ago_in_words(comment.created_at, true) << " ago by [Unknown User]"
40 - %span.delete= link_to '&#10008;'.html_safe, [app, problem, comment], :method => :delete, :data => { :confirm => "Are you sure you don't need this comment?" }, :class => "destroy-comment" 42 + %span.delete= link_to '&#10008;'.html_safe, [app, problem, comment], :method => :delete,
  43 + :data => { :confirm => t("comments.confirm_delete") }, :class => "destroy-comment"
41 %tr 44 %tr
42 %td= simple_format comment.body 45 %td= simple_format comment.body
43 - if problem.comments_allowed? 46 - if problem.comments_allowed?
app/views/users/show.html.haml
@@ -9,7 +9,8 @@ @@ -9,7 +9,8 @@
9 = render 'shared/link_github_account' 9 = render 'shared/link_github_account'
10 %span= link_to('Add a New User', new_user_path, :class => 'add') 10 %span= link_to('Add a New User', new_user_path, :class => 'add')
11 = link_to 'edit', edit_user_path(user), :class => 'button' 11 = link_to 'edit', edit_user_path(user), :class => 'button'
12 - = link_to 'destroy', user_path(user), :method => :delete, :data => { :confirm => 'Seriously?' }, :class => 'button' 12 + = link_to 'destroy', user_path(user), :method => :delete,
  13 + :data => { :confirm => t('users.confirm_delete') }, :class => 'delete button'
13 14
14 %table.single_user 15 %table.single_user
15 %tr 16 %tr
config/config.example.yml
@@ -36,8 +36,8 @@ per_app_notify_at_notices: false @@ -36,8 +36,8 @@ per_app_notify_at_notices: false
36 # [0] for all notices, provided notification service is configured 36 # [0] for all notices, provided notification service is configured
37 notify_at_notices: [0] 37 notify_at_notices: [0]
38 38
39 -# Configure whether or not the user should be prompted before resolving an error.  
40 -confirm_resolve_err: true 39 +# Configure whether or not the user should be prompted before resolving/deleting/merging/etc an error.
  40 +confirm_err_actions: true
41 41
42 # Add an optional 'username' field to Users. 42 # Add an optional 'username' field to Users.
43 # Helpful when you need to plug in a custom authentication strategy, such as LDAP. 43 # Helpful when you need to plug in a custom authentication strategy, such as LDAP.
config/initializers/_load_config.rb
@@ -12,7 +12,7 @@ unless defined?(Errbit::Config) @@ -12,7 +12,7 @@ unless defined?(Errbit::Config)
12 Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM'] 12 Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM']
13 # Not really easy to use like an env because need an array and ENV return a string :( 13 # Not really easy to use like an env because need an array and ENV return a string :(
14 # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES'] 14 # Errbit::Config.email_at_notices = ENV['ERRBIT_EMAIL_AT_NOTICES']
15 - Errbit::Config.confirm_resolve_err = ENV['ERRBIT_CONFIRM_RESOLVE_ERR'].to_i == 0 15 + Errbit::Config.confirm_err_actions = ENV['ERRBIT_CONFIRM_ERR_ACTIONS'].to_i == 0
16 Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1 16 Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1
17 Errbit::Config.allow_comments_with_issue_tracker = ENV['ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER'].to_i == 0 17 Errbit::Config.allow_comments_with_issue_tracker = ENV['ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER'].to_i == 0
18 Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL'] 18 Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL']
config/locales/en.yml
@@ -69,7 +69,21 @@ en: @@ -69,7 +69,21 @@ en:
69 new: 69 new:
70 sign_in: "Sign in" 70 sign_in: "Sign in"
71 71
  72 + problems:
  73 + confirm:
  74 + delete: "Permanently delete selected issues?"
  75 + resolve: "Resolve selected issues? They can be unresolved later."
  76 + resolve_one: "Resolve this issue? It can be unresolved later."
  77 + merge: "Merge select issues? They can be unmerged later."
  78 + unmerge: "Unmerge selected issues? They can be re-merged later."
  79 + unresolve: "Unresolve selected issues? They can be resolved again later."
  80 +
  81 + comments:
  82 + confirm_delete: "Premanently delete this comment?"
  83 + users:
  84 + confirm_delete: "Permanently delete this user?"
72 apps: 85 apps:
  86 + confirm_delete: "Permanently delete this app?"
73 index: 87 index:
74 notify: Notification Service 88 notify: Notification Service
75 tracker: Tracker 89 tracker: Tracker
spec/views/apps/edit.html.haml_spec.rb
@@ -14,8 +14,7 @@ describe &quot;apps/edit.html.haml&quot; do @@ -14,8 +14,7 @@ describe &quot;apps/edit.html.haml&quot; do
14 14
15 it "should confirm the 'destroy' link" do 15 it "should confirm the 'destroy' link" do
16 render 16 render
17 -  
18 - action_bar.should have_selector('a.button[data-confirm="Seriously?"]') 17 + action_bar.should have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_delete'))
19 end 18 end
20 19
21 end 20 end
spec/views/problems/show.html.haml_spec.rb
@@ -28,21 +28,18 @@ describe &quot;problems/show.html.haml&quot; do @@ -28,21 +28,18 @@ describe &quot;problems/show.html.haml&quot; do
28 28
29 it "should confirm the 'resolve' link by default" do 29 it "should confirm the 'resolve' link by default" do
30 render 30 render
31 -  
32 - action_bar.should have_selector('a.resolve[data-confirm="Seriously?"]') 31 + action_bar.should have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one'))
33 end 32 end
34 33
35 it "should confirm the 'resolve' link if configuration is unset" do 34 it "should confirm the 'resolve' link if configuration is unset" do
36 - Errbit::Config.stub(:confirm_resolve_err).and_return(nil) 35 + Errbit::Config.stub(:confirm_err_actions).and_return(nil)
37 render 36 render
38 -  
39 - action_bar.should have_selector('a.resolve[data-confirm="Seriously?"]') 37 + action_bar.should have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one'))
40 end 38 end
41 39
42 it "should not confirm the 'resolve' link if configured not to" do 40 it "should not confirm the 'resolve' link if configured not to" do
43 - Errbit::Config.stub(:confirm_resolve_err).and_return(false) 41 + Errbit::Config.stub(:confirm_err_actions).and_return(false)
44 render 42 render
45 -  
46 action_bar.should have_selector('a.resolve[data-confirm="null"]') 43 action_bar.should have_selector('a.resolve[data-confirm="null"]')
47 end 44 end
48 45
@@ -50,7 +47,6 @@ describe &quot;problems/show.html.haml&quot; do @@ -50,7 +47,6 @@ describe &quot;problems/show.html.haml&quot; do
50 url = 'http://localhost:3000/problems' 47 url = 'http://localhost:3000/problems'
51 controller.request.env['HTTP_REFERER'] = url 48 controller.request.env['HTTP_REFERER'] = url
52 render 49 render
53 -  
54 action_bar.should have_selector("span a.up[href='#{url}']", :text => 'up') 50 action_bar.should have_selector("span a.up[href='#{url}']", :text => 'up')
55 end 51 end
56 52
spec/views/users/show.html.haml_spec.rb
@@ -53,6 +53,12 @@ describe &#39;users/show.html.haml&#39; do @@ -53,6 +53,12 @@ describe &#39;users/show.html.haml&#39; do
53 render 53 render
54 view.content_for(:action_bar).should include('Unlink GitHub account') 54 view.content_for(:action_bar).should include('Unlink GitHub account')
55 end 55 end
  56 +
  57 + it "should confirm the 'resolve' link by default" do
  58 + render
  59 + view.content_for(:action_bar).should have_selector('a.delete[data-confirm="%s"]' % I18n.t('.users.confirm_delete'))
  60 + end
  61 +
56 end 62 end
57 end 63 end
58 end 64 end