diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-07-06 15:35:07 +0100 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-07-07 14:57:28 +0100 |
commit | f0f94278d80f06f01808f6301a1a43d5ab06cef2 (patch) | |
tree | c39877b62f18e4c543ee1d14db7f51b8405d6d11 /app/helpers | |
parent | 848d868b9b695392176a541de1b097a6f95b6253 (diff) | |
download | gitlab-ce-f0f94278d80f06f01808f6301a1a43d5ab06cef2.tar.gz |
Tidy up close_reopen helpers and fix filtered-search-token padding
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/issuables_helper.rb | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 04133196700..4161a6a1896 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -254,36 +254,50 @@ module IssuablesHelper end def close_reopen_issuable_url(issuable, should_inverse = false) - is_closed = issuable.closed? - is_closed = !is_closed if should_inverse - - is_closed ? reopen_issuable_url(issuable) : close_issuable_url(issuable) + issuable.closed? ^ should_inverse ? reopen_issuable_url(issuable) : close_issuable_url(issuable) end def issuable_url(issuable, *options) case issuable - when Issue then issue_url(issuable, *options) - when MergeRequest then merge_request_url(issuable, *options) - else raise 'unknown issuable type' + when Issue + issue_url(issuable, *options) + when MergeRequest + merge_request_url(issuable, *options) + else + raise TypeError.new('unknown issuable type') end end def issuable_button_visibility(issuable, closed) case issuable - when Issue then issue_button_visibility(issuable, closed) - when MergeRequest then merge_request_button_visibility(issuable, closed) - else raise 'unknown issuable type' + when Issue + issue_button_visibility(issuable, closed) + when MergeRequest + merge_request_button_visibility(issuable, closed) + else + raise TypeError.new('unknown issuable type') end end def issuable_close_reopen_button_method(issuable) case issuable - when Issue then '' - when MergeRequest then 'put' - else raise 'unknown issuable type' + when Issue + '' + when MergeRequest + 'put' + else + raise TypeError.new('unknown issuable type') end end + def issuable_author_is_current_user(issuable) + issuable.author == current_user + end + + def issuable_display_type(issuable) + issuable.model_name.human.downcase + end + private def sidebar_gutter_collapsed? @@ -342,10 +356,10 @@ module IssuablesHelper end def close_reopen_params(issuable, action) - params = {} - params[issuable.model_name.to_s.underscore] = {} - params[issuable.model_name.to_s.underscore][:state_event] = action - params[:format] = :json if issuable.is_a?(Issue) - params + { + issuable.model_name.to_s.underscore => { state_event: action } + }.tap do |params| + params[:format] = :json if issuable.is_a?(Issue) + end end end |