diff options
author | Phil Hughes <me@iamphill.com> | 2017-07-07 21:42:41 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-07-07 21:42:41 +0100 |
commit | 59195b98d3dfef31915c901e86f91cec74d5fbfa (patch) | |
tree | b0eba5f79fdb835c838d75d1d0ff29a261b11387 /app/helpers | |
parent | 436047f6575ffc64f065928d1feb4144ca8f7158 (diff) | |
parent | 69e17c225e53feaa7449e468e89aca3f084ab9f9 (diff) | |
download | gitlab-ce-59195b98d3dfef31915c901e86f91cec74d5fbfa.tar.gz |
Merge branch 'master' into new-nav-fix-contextual-breadcrumbs
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/issuables_helper.rb | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index b5366519ed9..d0c518f81f7 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -245,6 +245,53 @@ module IssuablesHelper @counts[cache_key][state] end + def close_issuable_url(issuable) + issuable_url(issuable, close_reopen_params(issuable, :close)) + end + + def reopen_issuable_url(issuable) + issuable_url(issuable, close_reopen_params(issuable, :reopen)) + end + + def close_reopen_issuable_url(issuable, should_inverse = false) + issuable.closed? ^ should_inverse ? reopen_issuable_url(issuable) : close_issuable_url(issuable) + end + + def issuable_url(issuable, *options) + case issuable + when Issue + issue_url(issuable, *options) + when MergeRequest + merge_request_url(issuable, *options) + end + end + + def issuable_button_visibility(issuable, closed) + case issuable + when Issue + issue_button_visibility(issuable, closed) + when MergeRequest + merge_request_button_visibility(issuable, closed) + end + end + + def issuable_close_reopen_button_method(issuable) + case issuable + when Issue + '' + when MergeRequest + 'put' + 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? @@ -270,8 +317,6 @@ module IssuablesHelper issue_template_names when MergeRequest merge_request_template_names - else - raise 'Unknown issuable type!' end end @@ -301,4 +346,12 @@ module IssuablesHelper container: (is_collapsed ? 'body' : nil) } end + + def close_reopen_params(issuable, action) + { + issuable.model_name.to_s.underscore => { state_event: action } + }.tap do |params| + params[:format] = :json if issuable.is_a?(Issue) + end + end end |