diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/concerns/toggle_award_emoji.rb | 10 | ||||
-rw-r--r-- | app/controllers/projects/notes_controller.rb | 44 | ||||
-rw-r--r-- | app/views/award_emoji/_awards_block.html.haml | 4 | ||||
-rw-r--r-- | app/views/projects/diffs/_line.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/notes/_note.html.haml | 16 | ||||
-rw-r--r-- | app/views/projects/notes/_notes_with_form.html.haml | 27 |
7 files changed, 68 insertions, 43 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 62f63701799..713d552976c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -366,6 +366,14 @@ class ApplicationController < ActionController::Base request.base_url end + def require_feature!(feature) + if Gitlab::Feature.feature_enabled?(feature) + yield + else + head(:service_unavailable) + end + end + private def set_default_sort diff --git a/app/controllers/concerns/toggle_award_emoji.rb b/app/controllers/concerns/toggle_award_emoji.rb index 036777c80c1..13c3de4ddbb 100644 --- a/app/controllers/concerns/toggle_award_emoji.rb +++ b/app/controllers/concerns/toggle_award_emoji.rb @@ -6,12 +6,14 @@ module ToggleAwardEmoji end def toggle_award_emoji - name = params.require(:name) + require_feature!(:toggling_award_emoji) do + name = params.require(:name) - awardable.toggle_award_emoji(name, current_user) - TodoService.new.new_award_emoji(to_todoable(awardable), current_user) + awardable.toggle_award_emoji(name, current_user) + TodoService.new.new_award_emoji(to_todoable(awardable), current_user) - render json: { ok: true } + render json: { ok: true } + end end private diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 836f79ff080..db046aaa7a4 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -22,39 +22,47 @@ class Projects::NotesController < Projects::ApplicationController end def create - @note = Notes::CreateService.new(project, current_user, note_params).execute + require_feature!(:creating_notes) do + @note = Notes::CreateService.new(project, current_user, note_params).execute - respond_to do |format| - format.json { render json: note_json(@note) } - format.html { redirect_back_or_default } + respond_to do |format| + format.json { render json: note_json(@note) } + format.html { redirect_back_or_default } + end end end def update - @note = Notes::UpdateService.new(project, current_user, note_params).execute(note) + require_feature!(:updating_notes) do + @note = Notes::UpdateService.new(project, current_user, note_params).execute(note) - respond_to do |format| - format.json { render json: note_json(@note) } - format.html { redirect_back_or_default } + respond_to do |format| + format.json { render json: note_json(@note) } + format.html { redirect_back_or_default } + end end end def destroy - if note.editable? - Notes::DeleteService.new(project, current_user).execute(note) - end - - respond_to do |format| - format.js { head :ok } + require_feature!(:removing_notes) do + if note.editable? + Notes::DeleteService.new(project, current_user).execute(note) + end + + respond_to do |format| + format.js { head :ok } + end end end def delete_attachment - note.remove_attachment! - note.update_attribute(:attachment, nil) + require_feature!(:removing_note_attachments) do + note.remove_attachment! + note.update_attribute(:attachment, nil) - respond_to do |format| - format.js { head :ok } + respond_to do |format| + format.js { head :ok } + end end end diff --git a/app/views/award_emoji/_awards_block.html.haml b/app/views/award_emoji/_awards_block.html.haml index 02efcecc889..44263e97231 100644 --- a/app/views/award_emoji/_awards_block.html.haml +++ b/app/views/award_emoji/_awards_block.html.haml @@ -1,12 +1,12 @@ - grouped_emojis = awardable.grouped_awards(with_thumbs: inline) .awards.js-awards-block{ class: ("hidden" if !inline && grouped_emojis.empty?), data: { award_url: url_for([:toggle_award_emoji, @project.namespace.becomes(Namespace), @project, awardable]) } } - awards_sort(grouped_emojis).each do |emoji, awards| - %button.btn.award-control.js-emoji-btn.has-tooltip{ type: "button", class: (award_active_class(awards, current_user)), data: { placement: "bottom", title: award_user_list(awards, current_user) } } + %button.btn.award-control.js-emoji-btn.has-tooltip{ disabled: !Gitlab::Feature.toggling_award_emoji_enabled?, type: "button", class: (award_active_class(awards, current_user)), data: { placement: "bottom", title: award_user_list(awards, current_user) } } = emoji_icon(emoji, sprite: false) %span.award-control-text.js-counter = awards.count - - if current_user + - if current_user && Gitlab::Feature.toggling_award_emoji_enabled? .award-menu-holder.js-award-holder %button.btn.award-control.js-add-award{ type: "button" } = icon('smile-o', class: "award-control-icon award-control-icon-normal") diff --git a/app/views/projects/diffs/_line.html.haml b/app/views/projects/diffs/_line.html.haml index f1577e8a47b..9e46625378a 100644 --- a/app/views/projects/diffs/_line.html.haml +++ b/app/views/projects/diffs/_line.html.haml @@ -15,7 +15,7 @@ = link_text - else = link_to "", "##{line_code}", id: line_code, data: { linenumber: link_text } - - if !@diff_notes_disabled && can?(current_user, :create_note, @project) + - if !@diff_notes_disabled && can?(current_user, :create_note, @project) && Gitlab::Feature.creating_notes_enabled? = link_to_new_diff_note(line_code) %td.new_line.diff-line-num{ class: type, data: { linenumber: line.new_pos } } - link_text = type == "old" ? " ".html_safe : line.new_pos diff --git a/app/views/projects/notes/_note.html.haml b/app/views/projects/notes/_note.html.haml index bcdbff08011..a2b614486ad 100644 --- a/app/views/projects/notes/_note.html.haml +++ b/app/views/projects/notes/_note.html.haml @@ -21,20 +21,22 @@ - if access %span.note-role.hidden-xs= access - if current_user - = link_to '#', title: 'Award Emoji', class: 'note-action-button note-emoji-button js-add-award js-note-emoji', data: { position: 'right' } do - = icon('spinner spin') - = icon('smile-o') - - if note_editable + - if Gitlab::Feature.toggling_award_emoji_enabled? + = link_to '#', title: 'Award Emoji', class: 'note-action-button note-emoji-button js-add-award js-note-emoji', data: { position: 'right' } do + = icon('spinner spin') + = icon('smile-o') + - if note_editable && Gitlab::Feature.updating_notes_enabled? = link_to '#', title: 'Edit comment', class: 'note-action-button js-note-edit' do = icon('pencil') - = link_to namespace_project_note_path(note.project.namespace, note.project, note), title: 'Remove comment', method: :delete, data: { confirm: 'Are you sure you want to remove this comment?' }, remote: true, class: 'note-action-button hidden-xs js-note-delete danger' do - = icon('trash-o') + - if Gitlab::Feature.removing_notes_enabled? + = link_to namespace_project_note_path(note.project.namespace, note.project, note), title: 'Remove comment', method: :delete, data: { confirm: 'Are you sure you want to remove this comment?' }, remote: true, class: 'note-action-button hidden-xs js-note-delete danger' do + = icon('trash-o') .note-body{class: note_editable ? 'js-task-list-container' : ''} .note-text = preserve do = markdown(note.note, pipeline: :note, cache_key: [note, "note"], author: note.author) = edited_time_ago_with_tooltip(note, placement: 'bottom', html_class: 'note_edited_ago', include_author: true) - - if note_editable + - if note_editable && Gitlab::Feature.updating_notes_enabled? = render 'projects/notes/edit_form', note: note .note-awards = render 'award_emoji/awards_block', awardable: note, inline: false diff --git a/app/views/projects/notes/_notes_with_form.html.haml b/app/views/projects/notes/_notes_with_form.html.haml index 1c39ce897a3..b8c99389b4a 100644 --- a/app/views/projects/notes/_notes_with_form.html.haml +++ b/app/views/projects/notes/_notes_with_form.html.haml @@ -2,20 +2,25 @@ = render "projects/notes/notes" %ul.notes.notes-form.timeline %li.timeline-entry - - if can? current_user, :create_note, @project - .timeline-icon.hidden-xs.hidden-sm - %a.author_link{ href: user_path(current_user) } - = image_tag avatar_icon(current_user), alt: current_user.to_reference, class: 'avatar s40' - .timeline-content.timeline-content-form - = render "projects/notes/form", view: diff_view + - if Gitlab::Feature.creating_notes_enabled? + - if can? current_user, :create_note, @project + .timeline-icon.hidden-xs.hidden-sm + %a.author_link{ href: user_path(current_user) } + = image_tag avatar_icon(current_user), alt: current_user.to_reference, class: 'avatar s40' + .timeline-content.timeline-content-form + = render "projects/notes/form", view: diff_view + - else + .disabled-comment.text-center + .disabled-comment-text.inline + Please + = link_to "register",new_user_session_path + or + = link_to "login",new_user_session_path + to post a comment - else .disabled-comment.text-center .disabled-comment-text.inline - Please - = link_to "register",new_user_session_path - or - = link_to "login",new_user_session_path - to post a comment + Creating comments is currently disabled. :javascript var notes = new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{diff_view}") |