Tidy up close_reopen helpers and fix filtered-search-token padding
This commit is contained in:
parent
848d868b9b
commit
f0f94278d8
4 changed files with 41 additions and 23 deletions
|
@ -163,6 +163,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
.droplab-dropdown li.filtered-search-token {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.filtered-search-term {
|
||||
.name {
|
||||
background-color: inherit;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
- is_current_user = current_user == issuable.author
|
||||
- display_issuable_type = issuable.model_name.human.downcase
|
||||
- is_current_user = issuable_author_is_current_user(issuable)
|
||||
- display_issuable_type = issuable_display_type(issuable)
|
||||
- button_method = issuable_close_reopen_button_method(issuable)
|
||||
|
||||
- if can_update && is_current_user
|
||||
= link_to "Close #{display_issuable_type}", close_issuable_url(issuable), method: button_method,
|
||||
class: "btn btn-grouped btn-close #{issuable_button_visibility(issuable, true)}", title: "Close #{display_issuable_type}"
|
||||
class: "hidden-xs hidden-sm btn btn-grouped btn-close #{issuable_button_visibility(issuable, true)}", title: "Close #{display_issuable_type}"
|
||||
= link_to "Reopen #{display_issuable_type}", reopen_issuable_url(issuable), method: button_method,
|
||||
class: "btn btn-grouped btn-reopen #{issuable_button_visibility(issuable, false)}", title: "Reopen #{display_issuable_type}"
|
||||
class: "hidden-xs hidden-sm btn btn-grouped btn-reopen #{issuable_button_visibility(issuable, false)}", title: "Reopen #{display_issuable_type}"
|
||||
- elsif can_update && !is_current_user
|
||||
= render 'shared/issuable/close_reopen_report_toggle', issuable: issuable
|
||||
- else
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- display_issuable_type = issuable.model_name.human.downcase
|
||||
- display_issuable_type = issuable_display_type(issuable)
|
||||
- button_action = issuable.closed? ? 'reopen' : 'close'
|
||||
- display_button_action = button_action.capitalize
|
||||
- button_responsive_class = 'hidden-xs hidden-sm'
|
||||
|
|
Loading…
Reference in a new issue