Module: IssuableActions
Constant Summary
Gitlab::Cache::Helpers::DEFAULT_EXPIRY
Instance Method Summary
collapse
#spam_action_response_fields
#mark_as_spam
#cache, #render_cached
Instance Method Details
#bulk_update ⇒ Object
135
136
137
138
139
140
141
142
143
144
|
# File 'app/controllers/concerns/issuable_actions.rb', line 135
def bulk_update
result = Issuable::BulkUpdateService.new(parent, current_user, bulk_update_params).execute(resource_name)
if result.success?
quantity = result.payload[:count]
render json: { notice: "#{quantity} #{resource_name.pluralize(quantity)} updated" }
elsif result.error?
render json: { errors: result.message }, status: result.http_status
end
end
|
#check_destroy_confirmation! ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
# File 'app/controllers/concerns/issuable_actions.rb', line 110
def check_destroy_confirmation!
return true if params[:destroy_confirm]
error_message = "Destroy confirmation not provided for #{issuable.human_class_name}"
exception = RuntimeError.new(error_message)
Gitlab::ErrorTracking.track_exception(
exception,
project_path: issuable.project.full_path,
issuable_type: issuable.class.name,
issuable_id: issuable.id
)
index_path = polymorphic_path([parent, issuable.class])
respond_to do |format|
format.html do
flash[:notice] = error_message
redirect_to index_path
end
format.json do
render json: { errors: error_message }, status: :unprocessable_entity
end
end
end
|
#destroy ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'app/controllers/concerns/issuable_actions.rb', line 93
def destroy
Issuable::DestroyService.new(container: issuable.project, current_user: current_user).execute(issuable)
name = issuable.human_class_name
flash[:notice] = "The #{name} was successfully deleted."
index_path = polymorphic_path([parent, issuable.class])
respond_to do |format|
format.html { redirect_to index_path, status: :see_other }
format.json do
render json: {
web_url: index_path
}
end
end
end
|
#discussions {|discussion_notes| ... } ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'app/controllers/concerns/issuable_actions.rb', line 146
def discussions
finder = Issuable::DiscussionsListService.new(current_user, issuable, finder_params_for_issuable)
discussion_notes = finder.execute
yield discussion_notes if block_given?
if finder.paginator.present? && finder.paginator.has_next_page?
response.['X-Next-Page-Cursor'] = finder.paginator.cursor_for_next_page
end
case issuable
when MergeRequest, Issue
if stale?(etag: [discussion_cache_context, discussion_notes])
render json: discussion_serializer.represent(discussion_notes, context: self)
end
else
render json: discussion_serializer.represent(discussion_notes, context: self)
end
end
|
#realtime_changes ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'app/controllers/concerns/issuable_actions.rb', line 72
def realtime_changes
Gitlab::PollingInterval.(response, interval: 3_000)
response = {
title: view_context.markdown_field(issuable, :title),
title_text: issuable.title,
description: view_context.markdown_field(issuable, :description),
description_text: issuable.description,
task_completion_status: issuable.task_completion_status,
lock_version: issuable.lock_version
}
if issuable.edited?
response[:updated_at] = issuable.last_edited_at.to_time.iso8601
response[:updated_by_name] = issuable.last_edited_by.name
response[:updated_by_path] = user_path(issuable.last_edited_by)
end
render json: response
end
|
#show ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/concerns/issuable_actions.rb', line 18
def show
respond_to do |format|
format.html do
@issuable_sidebar = serializer.represent(issuable, serializer: 'sidebar') render 'show'
end
format.json do
render json: serializer.represent(issuable, serializer: params[:serializer])
end
end
end
|
#update ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'app/controllers/concerns/issuable_actions.rb', line 31
def update
updated_issuable = update_service.execute(issuable)
@issuable = updated_issuable
if updated_issuable.is_a?(Spammable)
respond_to do |format|
format.html do
if updated_issuable.valid?
redirect_to spammable_path
else
with_captcha_check_html_format(spammable: spammable) { render :edit }
end
end
format.json do
with_captcha_check_json_format(spammable: spammable) { render_entity_json }
end
end
else
respond_to do |format|
format.html do
render :edit
end
format.json do
render_entity_json
end
end
end
rescue ActiveRecord::StaleObjectError
render_conflict_response
end
|