Commit bf93f2fae5c24e48e0fd4811d68c98fc03133dbf
Exists in
master
and in
1 other branch
Merge pull request #613 from mildavw/seriously
"Seriously?" Seriously? Replace these resolve/delete confirmations with ...
Showing
11 changed files
with
46 additions
and
22 deletions
Show diff stats
app/helpers/problems_helper.rb
1 | 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 | 4 | end |
5 | 5 | |
6 | 6 | def truncated_problem_message(problem) | ... | ... |
app/views/apps/edit.html.haml
1 | 1 | - content_for :title, 'Edit App' |
2 | 2 | - content_for :action_bar do |
3 | 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 | 6 | = link_to('cancel', app_path(app), :class => 'button') |
6 | 7 | |
7 | 8 | = form_for app do |f| | ... | ... |
app/views/problems/_table.html.haml
... | ... | @@ -40,7 +40,9 @@ |
40 | 40 | %td.issue_link |
41 | 41 | - if problem.app.issue_tracker_configured? && problem.issue_link.present? && problem.issue_link != 'pending' |
42 | 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 | 46 | - if problems.none? |
45 | 47 | %tr |
46 | 48 | %td{:colspan => (any_issue_links ? 8 : 7)} |
... | ... | @@ -49,4 +51,6 @@ |
49 | 51 | .tab-bar |
50 | 52 | %ul |
51 | 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 | 13 | = problem.last_notice_at.to_s(:precise) |
14 | 14 | - content_for :action_bar do |
15 | 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 | 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 | 21 | %span>= link_to 'up', (request.env['HTTP_REFERER'] ? :back : app_problems_path(app)), :class => 'up' |
20 | 22 | %br |
21 | 23 | = render "issue_tracker_links" |
... | ... | @@ -37,7 +39,8 @@ |
37 | 39 | - else |
38 | 40 | %span.comment-info |
39 | 41 | = time_ago_in_words(comment.created_at, true) << " ago by [Unknown User]" |
40 | - %span.delete= link_to '✘'.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 '✘'.html_safe, [app, problem, comment], :method => :delete, | |
43 | + :data => { :confirm => t("comments.confirm_delete") }, :class => "destroy-comment" | |
41 | 44 | %tr |
42 | 45 | %td= simple_format comment.body |
43 | 46 | - if problem.comments_allowed? | ... | ... |
app/views/users/show.html.haml
... | ... | @@ -9,7 +9,8 @@ |
9 | 9 | = render 'shared/link_github_account' |
10 | 10 | %span= link_to('Add a New User', new_user_path, :class => 'add') |
11 | 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 | 15 | %table.single_user |
15 | 16 | %tr | ... | ... |
config/config.example.yml
... | ... | @@ -36,8 +36,8 @@ per_app_notify_at_notices: false |
36 | 36 | # [0] for all notices, provided notification service is configured |
37 | 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 | 42 | # Add an optional 'username' field to Users. |
43 | 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 | 12 | Errbit::Config.email_from = ENV['ERRBIT_EMAIL_FROM'] |
13 | 13 | # Not really easy to use like an env because need an array and ENV return a string :( |
14 | 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 | 16 | Errbit::Config.user_has_username = ENV['ERRBIT_USER_HAS_USERNAME'].to_i == 1 |
17 | 17 | Errbit::Config.allow_comments_with_issue_tracker = ENV['ERRBIT_ALLOW_COMMENTS_WITH_ISSUE_TRACKER'].to_i == 0 |
18 | 18 | Errbit::Config.enforce_ssl = ENV['ERRBIT_ENFORCE_SSL'] | ... | ... |
config/locales/en.yml
... | ... | @@ -69,7 +69,21 @@ en: |
69 | 69 | new: |
70 | 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 | 85 | apps: |
86 | + confirm_delete: "Permanently delete this app?" | |
73 | 87 | index: |
74 | 88 | notify: Notification Service |
75 | 89 | tracker: Tracker | ... | ... |
spec/views/apps/edit.html.haml_spec.rb
... | ... | @@ -14,8 +14,7 @@ describe "apps/edit.html.haml" do |
14 | 14 | |
15 | 15 | it "should confirm the 'destroy' link" do |
16 | 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 | 18 | end |
20 | 19 | |
21 | 20 | end | ... | ... |
spec/views/problems/show.html.haml_spec.rb
... | ... | @@ -28,21 +28,18 @@ describe "problems/show.html.haml" do |
28 | 28 | |
29 | 29 | it "should confirm the 'resolve' link by default" do |
30 | 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 | 32 | end |
34 | 33 | |
35 | 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 | 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 | 38 | end |
41 | 39 | |
42 | 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 | 42 | render |
45 | - | |
46 | 43 | action_bar.should have_selector('a.resolve[data-confirm="null"]') |
47 | 44 | end |
48 | 45 | |
... | ... | @@ -50,7 +47,6 @@ describe "problems/show.html.haml" do |
50 | 47 | url = 'http://localhost:3000/problems' |
51 | 48 | controller.request.env['HTTP_REFERER'] = url |
52 | 49 | render |
53 | - | |
54 | 50 | action_bar.should have_selector("span a.up[href='#{url}']", :text => 'up') |
55 | 51 | end |
56 | 52 | ... | ... |
spec/views/users/show.html.haml_spec.rb
... | ... | @@ -53,6 +53,12 @@ describe 'users/show.html.haml' do |
53 | 53 | render |
54 | 54 | view.content_for(:action_bar).should include('Unlink GitHub account') |
55 | 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 | 62 | end |
57 | 63 | end |
58 | 64 | end | ... | ... |