From efc9408fbf2a0524ca249842a429792dc7019810 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 15 May 2017 14:51:40 +0100 Subject: Added description template selector [ci skip] --- app/helpers/issuables_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 9290e4ec133..8358fd43e72 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -199,6 +199,12 @@ module IssuablesHelper issuable_filter_params.any? { |k| params.key?(k) } end + def issuable_initial_data(issuable) + { + templates: issuable_templates(issuable) + }.to_json + end + private def sidebar_gutter_collapsed? -- cgit v1.2.1 From 3301ca10552e7d95d7fb5108a180caa38ddfb9c5 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Tue, 16 May 2017 16:18:52 +0100 Subject: Fixed up the template dropdown to correctly work [ci skip] --- app/helpers/issuables_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 8358fd43e72..7922527014a 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -201,7 +201,9 @@ module IssuablesHelper def issuable_initial_data(issuable) { - templates: issuable_templates(issuable) + templates: issuable_templates(issuable), + project_path: ref_project.path, + namespace_path: ref_project.namespace.full_path }.to_json end -- cgit v1.2.1 From 71777a4a184945d6b58170af55d9fd9fef821ac9 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 16 May 2017 19:41:15 +0800 Subject: Rename BuildsController to JobsController Rename other URL generators admin_builds_path -> admin_jobs_path Fix tests and more renaming Fix more tests Also change build_id to job_id in the controller --- app/helpers/blob_helper.rb | 2 +- app/helpers/builds_helper.rb | 8 ++++---- app/helpers/gitlab_routing_helper.rb | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 7eb3512378c..6a72b0059ea 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -120,7 +120,7 @@ module BlobHelper def blob_raw_url if @build && @entry - raw_namespace_project_build_artifacts_path(@project.namespace, @project, @build, path: @entry.path) + raw_namespace_project_job_artifacts_path(@project.namespace, @project, @build, path: @entry.path) elsif @snippet if @snippet.project_id raw_namespace_project_snippet_path(@project.namespace, @project, @snippet) diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb index 2eb2c6c7389..f0a0d245dc0 100644 --- a/app/helpers/builds_helper.rb +++ b/app/helpers/builds_helper.rb @@ -2,7 +2,7 @@ module BuildsHelper def build_summary(build, skip: false) if build.has_trace? if skip - link_to "View job trace", pipeline_build_url(build.pipeline, build) + link_to "View job trace", pipeline_job_url(build.pipeline, build) else build.trace.html(last_lines: 10).html_safe end @@ -20,8 +20,8 @@ module BuildsHelper def javascript_build_options { - page_url: namespace_project_build_url(@project.namespace, @project, @build), - build_url: namespace_project_build_url(@project.namespace, @project, @build, :json), + page_url: namespace_project_job_url(@project.namespace, @project, @build), + build_url: namespace_project_job_url(@project.namespace, @project, @build, :json), build_status: @build.status, build_stage: @build.stage, log_state: '' @@ -31,7 +31,7 @@ module BuildsHelper def build_failed_issue_options { title: "Build Failed ##{@build.id}", - description: namespace_project_build_url(@project.namespace, @project, @build) + description: namespace_project_job_url(@project.namespace, @project, @build) } end end diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index fc308b3960e..40864bed0ff 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -50,8 +50,8 @@ module GitlabRoutingHelper namespace_project_cycle_analytics_path(project.namespace, project, *args) end - def project_builds_path(project, *args) - namespace_project_builds_path(project.namespace, project, *args) + def project_jobs_path(project, *args) + namespace_project_jobs_path(project.namespace, project, *args) end def project_ref_path(project, ref_name, *args) @@ -110,8 +110,8 @@ module GitlabRoutingHelper namespace_project_pipeline_url(pipeline.project.namespace, pipeline.project, pipeline.id, *args) end - def pipeline_build_url(pipeline, build, *args) - namespace_project_build_url(pipeline.project.namespace, pipeline.project, build.id, *args) + def pipeline_job_url(pipeline, build, *args) + namespace_project_job_url(pipeline.project.namespace, pipeline.project, build.id, *args) end def commits_url(entity, *args) @@ -215,13 +215,13 @@ module GitlabRoutingHelper case action when 'download' - download_namespace_project_build_artifacts_path(*args) + download_namespace_project_job_artifacts_path(*args) when 'browse' - browse_namespace_project_build_artifacts_path(*args) + browse_namespace_project_job_artifacts_path(*args) when 'file' - file_namespace_project_build_artifacts_path(*args) + file_namespace_project_job_artifacts_path(*args) when 'raw' - raw_namespace_project_build_artifacts_path(*args) + raw_namespace_project_job_artifacts_path(*args) end end -- cgit v1.2.1 From b2c2751836703a6dcf3ae92e05bf8b59ba4aa9a3 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 24 May 2017 12:25:53 +0100 Subject: Changed all data to come through the JSON script element [ci skip] --- app/helpers/issuables_helper.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 7922527014a..fb73c92279d 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -201,9 +201,22 @@ module IssuablesHelper def issuable_initial_data(issuable) { + endpoint: namespace_project_issue_path(@project.namespace, @project, issuable), + canUpdate: can?(current_user, :update_issue, issuable), + canDestroy: can?(current_user, :destroy_issue, issuable), + canMove: issuable.can_move?(current_user), + issuableRef: issuable.to_reference, + isConfidential: issuable.confidential, + markdownPreviewUrl: preview_markdown_path(@project), + markdownDocs: help_page_path('user/markdown'), + projectsAutocompleteUrl: autocomplete_projects_path(project_id: @project.id), templates: issuable_templates(issuable), - project_path: ref_project.path, - namespace_path: ref_project.namespace.full_path + projectPath: ref_project.path, + projectNamespace: ref_project.namespace.full_path, + initialTitleHtml: markdown_field(issuable, :title), + initialTitleText: issuable.title, + initialDescriptionHtml: markdown_field(issuable, :description), + initialDescriptionText: issuable.description }.to_json end -- cgit v1.2.1 From fd3750c68590119d0cfb48c8b5245f6c09cc9f02 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 24 May 2017 12:56:05 +0100 Subject: fixed bug with can? check when user is not logged in --- app/helpers/issuables_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index fb73c92279d..62b1bfa997e 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -204,7 +204,7 @@ module IssuablesHelper endpoint: namespace_project_issue_path(@project.namespace, @project, issuable), canUpdate: can?(current_user, :update_issue, issuable), canDestroy: can?(current_user, :destroy_issue, issuable), - canMove: issuable.can_move?(current_user), + canMove: current_user ? issuable.can_move?(current_user) : false, issuableRef: issuable.to_reference, isConfidential: issuable.confidential, markdownPreviewUrl: preview_markdown_path(@project), -- cgit v1.2.1 From 0defc4f7ccae38e69f0ad185bc912eb4f5448661 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Thu, 25 May 2017 18:46:51 +0100 Subject: fixed issuable templates dropdown not showing --- app/helpers/issuables_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 62b1bfa997e..c380a10c82d 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -210,7 +210,7 @@ module IssuablesHelper markdownPreviewUrl: preview_markdown_path(@project), markdownDocs: help_page_path('user/markdown'), projectsAutocompleteUrl: autocomplete_projects_path(project_id: @project.id), - templates: issuable_templates(issuable), + issuableTemplates: issuable_templates(issuable), projectPath: ref_project.path, projectNamespace: ref_project.namespace.full_path, initialTitleHtml: markdown_field(issuable, :title), -- cgit v1.2.1 From aed0387f97ec62b184da90bdca0ce40f9dc58b45 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 26 May 2017 18:27:30 -0500 Subject: Consistent diff and blob size limit names --- app/helpers/blob_helper.rb | 14 +++++--------- app/helpers/diff_helper.rb | 8 ++++---- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 622e14e21ff..63a4d215113 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -240,14 +240,10 @@ module BlobHelper def blob_render_error_reason(viewer) case viewer.render_error + when :collapsed + "it is larger than #{number_to_human_size(viewer.collapse_limit)}" when :too_large - max_size = - if viewer.can_override_max_size? - viewer.overridable_max_size - else - viewer.max_size - end - "it is larger than #{number_to_human_size(max_size)}" + "it is larger than #{number_to_human_size(viewer.size_limit)}" when :server_side_but_stored_externally case viewer.blob.external_storage when :lfs @@ -264,8 +260,8 @@ module BlobHelper error = viewer.render_error options = [] - if error == :too_large && viewer.can_override_max_size? - options << link_to('load it anyway', url_for(params.merge(viewer: viewer.type, override_max_size: true, format: nil))) + if error == :collapsed + options << link_to('load it anyway', url_for(params.merge(viewer: viewer.type, expanded: true, format: nil))) end # If the error is `:server_side_but_stored_externally`, the simple viewer will show the same error, diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 4c4fbdd4d39..0726dc6eafd 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -8,8 +8,8 @@ module DiffHelper [marked_old_line, marked_new_line] end - def expand_all_diffs? - params[:expand_all_diffs].present? + def diffs_expanded? + params[:expanded].present? end def diff_view @@ -22,10 +22,10 @@ module DiffHelper end def diff_options - options = { ignore_whitespace_change: hide_whitespace?, no_collapse: expand_all_diffs? } + options = { ignore_whitespace_change: hide_whitespace?, expanded: diffs_expanded? } if action_name == 'diff_for_path' - options[:no_collapse] = true + options[:expanded] = true options[:paths] = params.values_at(:old_path, :new_path) end -- cgit v1.2.1 From a7349560b2d13ea7894a462738b3a7687fdbae72 Mon Sep 17 00:00:00 2001 From: blackst0ne Date: Tue, 30 May 2017 15:35:49 +1100 Subject: 'New issue'/'New merge request' dropdowns should show only projects with issues/merge requests feature enabled --- app/helpers/selects_helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/selects_helper.rb b/app/helpers/selects_helper.rb index a7d1fe4aa47..1a4f1431bdc 100644 --- a/app/helpers/selects_helper.rb +++ b/app/helpers/selects_helper.rb @@ -45,6 +45,14 @@ module SelectsHelper end end + with_feature_enabled_data_attribute = + case opts.delete(:with_feature_enabled) + when 'issues' then 'data-with-issues-enabled' + when 'merge_requests' then 'data-with-merge-requests-enabled' + end + + opts[with_feature_enabled_data_attribute] = true + hidden_field_tag(id, opts[:selected], opts) end -- cgit v1.2.1 From a2c859427c4b8a8a9542cdc1299c35aade3e4555 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Wed, 24 May 2017 17:32:59 +0100 Subject: Fixed the show_user_callout method --- app/helpers/application_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e5e64650708..36d9090b3ae 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -276,7 +276,7 @@ module ApplicationHelper end def show_user_callout? - cookies[:user_callout_dismissed] == 'true' + cookies[:user_callout_dismissed].nil? end def linkedin_url(user) -- cgit v1.2.1 From fd376b3ed4de310f8e599cbbeb5c18e5a31c188c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 30 May 2017 14:11:58 +0200 Subject: Revert "Merge branch '1937-https-clone-url-username' into 'master' " MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c425f366bfa84efab92b5d5e1d0721f16a2890bc, reversing changes made to 82f6c0f5ac4ed29390ed90592d2c431f3494d93f. Signed-off-by: Rémy Coutable --- app/helpers/button_helper.rb | 2 +- app/helpers/projects_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb index 206d0753f08..0081bbd92b3 100644 --- a/app/helpers/button_helper.rb +++ b/app/helpers/button_helper.rb @@ -56,7 +56,7 @@ module ButtonHelper content_tag (append_link ? :a : :span), protocol, class: klass, - href: (project.http_url_to_repo(current_user) if append_link), + href: (project.http_url_to_repo if append_link), data: { html: true, placement: placement, diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 654aa1a6533..7b0584c42a2 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -276,7 +276,7 @@ module ProjectsHelper when 'ssh' project.ssh_url_to_repo else - project.http_url_to_repo(current_user) + project.http_url_to_repo end end -- cgit v1.2.1 From 07c984d81cd7985d4ab7597cbb21b5f623b438e9 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Thu, 18 May 2017 13:24:34 +0100 Subject: Port fix-realtime-edited-text-for-issues 9-2-stable fix to master. --- app/helpers/application_helper.rb | 2 +- app/helpers/editable_helper.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 app/helpers/editable_helper.rb (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e5e64650708..e87d8dc21cc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -181,7 +181,7 @@ module ApplicationHelper end def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false) - return if object.last_edited_at == object.created_at || object.last_edited_at.blank? + return unless object.is_edited? content_tag :small, class: 'edited-text' do output = content_tag(:span, 'Edited ') diff --git a/app/helpers/editable_helper.rb b/app/helpers/editable_helper.rb new file mode 100644 index 00000000000..e3ad62e8c18 --- /dev/null +++ b/app/helpers/editable_helper.rb @@ -0,0 +1,13 @@ +module EditableHelper + def updated_at_by(editable) + return nil unless editable.is_edited? + + { + updated_at: editable.updated_at, + updated_by: { + name: editable.last_edited_by.name, + path: user_path(editable.last_edited_by) + } + } + end +end -- cgit v1.2.1 From d537a9a45b23bac1aaff028302aae515d6afe949 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Mon, 22 May 2017 11:38:11 +0100 Subject: Move issuable_app_data to helper --- app/helpers/issuables_helper.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 9290e4ec133..39982eb2e2c 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -1,5 +1,6 @@ module IssuablesHelper include GitlabRoutingHelper + include EditableHelper def sidebar_gutter_toggle_icon sidebar_gutter_collapsed? ? icon('angle-double-left', { 'aria-hidden': 'true' }) : icon('angle-double-right', { 'aria-hidden': 'true' }) @@ -273,4 +274,11 @@ module IssuablesHelper container: (is_collapsed ? 'body' : nil) } end + + def issuable_app_data(project, issue) + data = { "endpoint" => realtime_changes_namespace_project_issue_path(project.namespace, project, issue), "can-update" => can?(current_user, :update_issue, issue).to_s, "issuable-ref" => issue.to_reference } + updated_at_by = updated_at_by(issue) + + data.merge(updated_at_by) if updated_at_by.present? + end end -- cgit v1.2.1 From aa1d87bd81df0c4020f2cee7788d1f8ea1635838 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Mon, 22 May 2017 16:29:49 +0100 Subject: Fix helper methods returning wrong data types for vue --- app/helpers/editable_helper.rb | 2 +- app/helpers/issuables_helper.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/editable_helper.rb b/app/helpers/editable_helper.rb index e3ad62e8c18..166963f993d 100644 --- a/app/helpers/editable_helper.rb +++ b/app/helpers/editable_helper.rb @@ -1,6 +1,6 @@ module EditableHelper def updated_at_by(editable) - return nil unless editable.is_edited? + return {} unless editable.is_edited? { updated_at: editable.updated_at, diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 39982eb2e2c..f995c86c059 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -276,9 +276,13 @@ module IssuablesHelper end def issuable_app_data(project, issue) - data = { "endpoint" => realtime_changes_namespace_project_issue_path(project.namespace, project, issue), "can-update" => can?(current_user, :update_issue, issue).to_s, "issuable-ref" => issue.to_reference } + data = { + endpoint: realtime_changes_namespace_project_issue_path(project.namespace, project, issue), + 'can-update' => can?(current_user, :update_issue, issue).to_s, + 'issuable-ref' => issue.to_reference || '' + } updated_at_by = updated_at_by(issue) - data.merge(updated_at_by) if updated_at_by.present? + data.merge(updated_at_by) end end -- cgit v1.2.1 From 33d66a47f6da19831889d8717ec9f11b8b5c6b6c Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 24 May 2017 11:53:28 +0100 Subject: Correct editable_helper spec and format issuable_app_data updated_at to iso8061 --- app/helpers/editable_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/editable_helper.rb b/app/helpers/editable_helper.rb index 166963f993d..ddb2fd22a35 100644 --- a/app/helpers/editable_helper.rb +++ b/app/helpers/editable_helper.rb @@ -3,7 +3,7 @@ module EditableHelper return {} unless editable.is_edited? { - updated_at: editable.updated_at, + updated_at: editable.updated_at.to_time.iso8601, updated_by: { name: editable.last_edited_by.name, path: user_path(editable.last_edited_by) -- cgit v1.2.1 From 632d0c0a4c6ed8dd099f67a6914868811490e6a4 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 31 May 2017 11:10:33 +0100 Subject: Remove EditableHelper and move method to IssuablesHelper --- app/helpers/editable_helper.rb | 13 ------------- app/helpers/issuables_helper.rb | 13 ++++++++++++- 2 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 app/helpers/editable_helper.rb (limited to 'app/helpers') diff --git a/app/helpers/editable_helper.rb b/app/helpers/editable_helper.rb deleted file mode 100644 index ddb2fd22a35..00000000000 --- a/app/helpers/editable_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -module EditableHelper - def updated_at_by(editable) - return {} unless editable.is_edited? - - { - updated_at: editable.updated_at.to_time.iso8601, - updated_by: { - name: editable.last_edited_by.name, - path: user_path(editable.last_edited_by) - } - } - end -end diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index f995c86c059..afe19f017d7 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -1,6 +1,5 @@ module IssuablesHelper include GitlabRoutingHelper - include EditableHelper def sidebar_gutter_toggle_icon sidebar_gutter_collapsed? ? icon('angle-double-left', { 'aria-hidden': 'true' }) : icon('angle-double-right', { 'aria-hidden': 'true' }) @@ -285,4 +284,16 @@ module IssuablesHelper data.merge(updated_at_by) end + + def updated_at_by(issuable) + return {} unless issuable.is_edited? + + { + updated_at: issuable.updated_at.to_time.iso8601, + updated_by: { + name: issuable.last_edited_by.name, + path: user_path(issuable.last_edited_by) + } + } + end end -- cgit v1.2.1 From b888ed59abd3a6cc6a1c14278c38fda472f5b90c Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 31 May 2017 14:03:32 +0100 Subject: Fixed issuables_helper_spec and added a test for issuable_app_data --- app/helpers/issuables_helper.rb | 46 ++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index afe19f017d7..a4197d34db3 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -199,6 +199,29 @@ module IssuablesHelper issuable_filter_params.any? { |k| params.key?(k) } end + def issuable_app_data(project, issue) + data = { + endpoint: realtime_changes_namespace_project_issue_path(project.namespace, project, issue), + 'can-update' => can?(current_user, :update_issue, issue).to_s, + 'issuable-ref' => issue.to_reference || '' + } + updated_at_by = updated_at_by(issue) + + data.merge(updated_at_by) + end + + def updated_at_by(issuable) + return {} unless issuable.is_edited? + + { + updated_at: issuable.updated_at.to_time.iso8601, + updated_by: { + name: issuable.last_edited_by.name, + path: user_path(issuable.last_edited_by) + } + } + end + private def sidebar_gutter_collapsed? @@ -273,27 +296,4 @@ module IssuablesHelper container: (is_collapsed ? 'body' : nil) } end - - def issuable_app_data(project, issue) - data = { - endpoint: realtime_changes_namespace_project_issue_path(project.namespace, project, issue), - 'can-update' => can?(current_user, :update_issue, issue).to_s, - 'issuable-ref' => issue.to_reference || '' - } - updated_at_by = updated_at_by(issue) - - data.merge(updated_at_by) - end - - def updated_at_by(issuable) - return {} unless issuable.is_edited? - - { - updated_at: issuable.updated_at.to_time.iso8601, - updated_by: { - name: issuable.last_edited_by.name, - path: user_path(issuable.last_edited_by) - } - } - end end -- cgit v1.2.1 From 563c1ca01cf94e125a5d01669e6e8455da257246 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 30 May 2017 23:38:06 +0300 Subject: Fix: A diff comment on a change at last line of a file shows as two comments in discussion --- app/helpers/diff_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb index 4c4fbdd4d39..5f3897b4f40 100644 --- a/app/helpers/diff_helper.rb +++ b/app/helpers/diff_helper.rb @@ -66,12 +66,12 @@ module DiffHelper discussions_left = discussions_right = nil - if left && (left.unchanged? || left.removed?) + if left && (left.unchanged? || left.discussable?) line_code = diff_file.line_code(left) discussions_left = @grouped_diff_discussions[line_code] end - if right && right.added? + if right&.discussable? line_code = diff_file.line_code(right) discussions_right = @grouped_diff_discussions[line_code] end -- cgit v1.2.1 From 34fcade1fd104deecaba69dc050cf2dcabb9e866 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 1 Jun 2017 09:05:21 -0500 Subject: Fix replying to a commit discussion displayed in the context of an MR --- app/helpers/notes_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 375110b77e2..3d4802290b5 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -50,7 +50,7 @@ module NotesHelper def link_to_reply_discussion(discussion, line_type = nil) return unless current_user - data = { discussion_id: discussion.id, line_type: line_type } + data = { discussion_id: discussion.reply_id, line_type: line_type } button_tag 'Reply...', class: 'btn btn-text-field js-discussion-reply-button', data: data, title: 'Add a reply' -- cgit v1.2.1 From 26dde5f55f1dac2e6bea4f7e1dfa51c72dc756cb Mon Sep 17 00:00:00 2001 From: "Taurie Davis, Simon Knox and Adam Niedzielski" Date: Wed, 24 May 2017 12:25:44 +0200 Subject: Add Conversational Development Index page to admin panel --- app/helpers/application_helper.rb | 4 ++-- app/helpers/conversational_development_index_helper.rb | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 app/helpers/conversational_development_index_helper.rb (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 36d9090b3ae..f422c48329c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -275,8 +275,8 @@ module ApplicationHelper 'active' if condition end - def show_user_callout? - cookies[:user_callout_dismissed].nil? + def show_callout?(name) + cookies[name] != 'true' end def linkedin_url(user) diff --git a/app/helpers/conversational_development_index_helper.rb b/app/helpers/conversational_development_index_helper.rb new file mode 100644 index 00000000000..1ff54415811 --- /dev/null +++ b/app/helpers/conversational_development_index_helper.rb @@ -0,0 +1,16 @@ +module ConversationalDevelopmentIndexHelper + def score_level(score) + if score < 33.33 + 'low' + elsif score < 66.66 + 'average' + else + 'high' + end + end + + def format_score(score) + precision = score < 1 ? 2 : 1 + number_with_precision(score, precision: precision) + end +end -- cgit v1.2.1 From f2b34fb208020706a5b5a73b2e50473bfda2c745 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Fri, 2 Jun 2017 07:42:18 +0000 Subject: Show current user immediately in issuable filters --- app/helpers/avatars_helper.rb | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index b7e0ff8ecd0..bbe7f3c8fb4 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -8,18 +8,28 @@ module AvatarsHelper })) end - def user_avatar(options = {}) + def user_avatar_without_link(options = {}) avatar_size = options[:size] || 16 user_name = options[:user].try(:name) || options[:user_name] css_class = options[:css_class] || '' - - avatar = image_tag( - avatar_icon(options[:user] || options[:user_email], avatar_size), + avatar_url = options[:url] || avatar_icon(options[:user] || options[:user_email], avatar_size) + data_attributes = { container: 'body' } + + if options[:lazy] + data_attributes[:src] = avatar_url + end + + image_tag( + options[:lazy] ? '' : avatar_url, class: "avatar has-tooltip s#{avatar_size} #{css_class}", alt: "#{user_name}'s avatar", title: user_name, - data: { container: 'body' } + data: data_attributes ) + end + + def user_avatar(options = {}) + avatar = user_avatar_without_link(options) if options[:user] link_to(avatar, user_path(options[:user])) -- cgit v1.2.1 From e591401b0b3f08baf4cd28d0fcb8e184a515fc74 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 2 Jun 2017 10:27:53 +0100 Subject: Removed unneeded newline in issuables_helper_spec and removed unneeded updated_at_by variable in issuable_app_data --- app/helpers/issuables_helper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index a4197d34db3..e9389178e68 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -205,9 +205,8 @@ module IssuablesHelper 'can-update' => can?(current_user, :update_issue, issue).to_s, 'issuable-ref' => issue.to_reference || '' } - updated_at_by = updated_at_by(issue) - data.merge(updated_at_by) + data.merge(updated_at_by(issue)) end def updated_at_by(issuable) -- cgit v1.2.1 From b2d577a7a293ac6c82a8bc64f5b134558460df5b Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Fri, 2 Jun 2017 17:30:58 +0100 Subject: Fix up merge issues --- app/helpers/issuables_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/helpers') diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 0269a4cc4e2..5e8f0849969 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -219,7 +219,9 @@ module IssuablesHelper initialDescriptionText: issuable.description } - data.merge(updated_at_by(issue)) + data.merge!(updated_at_by(issuable)) + + data.to_json end def updated_at_by(issuable) -- cgit v1.2.1 From 4cfa5ce4a95379a9ebe08f57b170af4b5ee9a9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 2 Jun 2017 19:11:26 +0200 Subject: Enable the Style/PreferredHashMethods cop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- app/helpers/dropdowns_helper.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/dropdowns_helper.rb b/app/helpers/dropdowns_helper.rb index 8ed99642c7a..ac8c518ac84 100644 --- a/app/helpers/dropdowns_helper.rb +++ b/app/helpers/dropdowns_helper.rb @@ -1,27 +1,27 @@ module DropdownsHelper def dropdown_tag(toggle_text, options: {}, &block) - content_tag :div, class: "dropdown #{options[:wrapper_class] if options.has_key?(:wrapper_class)}" do + content_tag :div, class: "dropdown #{options[:wrapper_class] if options.key?(:wrapper_class)}" do data_attr = { toggle: "dropdown" } - if options.has_key?(:data) + if options.key?(:data) data_attr = options[:data].merge(data_attr) end dropdown_output = dropdown_toggle(toggle_text, data_attr, options) - dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.has_key?(:dropdown_class)}") do + dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") do output = "" - if options.has_key?(:title) + if options.key?(:title) output << dropdown_title(options[:title]) end - if options.has_key?(:filter) + if options.key?(:filter) output << dropdown_filter(options[:placeholder]) end - output << content_tag(:div, class: "dropdown-content #{options[:content_class] if options.has_key?(:content_class)}") do - capture(&block) if block && !options.has_key?(:footer_content) + output << content_tag(:div, class: "dropdown-content #{options[:content_class] if options.key?(:content_class)}") do + capture(&block) if block && !options.key?(:footer_content) end if block && options[:footer_content] @@ -41,7 +41,7 @@ module DropdownsHelper def dropdown_toggle(toggle_text, data_attr, options = {}) default_label = data_attr[:default_label] - content_tag(:button, class: "dropdown-menu-toggle #{options[:toggle_class] if options.has_key?(:toggle_class)}", id: (options[:id] if options.has_key?(:id)), type: "button", data: data_attr) do + content_tag(:button, class: "dropdown-menu-toggle #{options[:toggle_class] if options.key?(:toggle_class)}", id: (options[:id] if options.key?(:id)), type: "button", data: data_attr) do output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{'is-default' if toggle_text == default_label}") output << icon('chevron-down') output.html_safe -- cgit v1.2.1 From 2eec0b73e8201761e9c350621651d2949dea52af Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 5 Jun 2017 09:26:20 +0300 Subject: Fix submodule link to then project under subgroup Before this change only last namespace in full path was extracted. It's fine unless you have a link to submodule under subgroups. In that case self_url? method returns false and link is processed as external. I could not find a proper regex to cover all cases and correctly extract full path to repository and instead used current instance host name to get correct path to namespace and project. Signed-off-by: Dmitriy Zaporozhets --- app/helpers/submodule_helper.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app/helpers') diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index c0763a8a9c4..8e0a1e2ecdf 100644 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -13,6 +13,17 @@ module SubmoduleHelper if url =~ /([^\/:]+)\/([^\/]+(?:\.git)?)\Z/ namespace, project = $1, $2 + gitlab_hosts = [Gitlab.config.gitlab.url, + Gitlab.config.gitlab_shell.ssh_path_prefix] + + gitlab_hosts.each do |host| + if url.start_with?(host) + namespace, _, project = url.sub(host, '').rpartition('/') + break + end + end + + namespace.sub!(/\A\//, '') project.rstrip! project.sub!(/\.git\z/, '') -- cgit v1.2.1 From e245d7eebe747378f4158b30634ab0da4df59117 Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Tue, 6 Jun 2017 08:28:39 +0000 Subject: Resolve "When changing project visibility setting, change other dropdowns automatically" --- app/helpers/projects_helper.rb | 10 +++++++--- app/helpers/visibility_level_helper.rb | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 7b0584c42a2..f74e61c9481 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -138,11 +138,15 @@ module ProjectsHelper if @project.private? level = @project.project_feature.send(field) - options.delete('Everyone with access') - highest_available_option = options.values.max if level == ProjectFeature::ENABLED + disabled_option = ProjectFeature::ENABLED + highest_available_option = ProjectFeature::PRIVATE if level == disabled_option end - options = options_for_select(options, selected: highest_available_option || @project.project_feature.public_send(field)) + options = options_for_select( + options, + selected: highest_available_option || @project.project_feature.public_send(field), + disabled: disabled_option + ) content_tag( :select, diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb index b4aaf498068..50757b01538 100644 --- a/app/helpers/visibility_level_helper.rb +++ b/app/helpers/visibility_level_helper.rb @@ -31,9 +31,9 @@ module VisibilityLevelHelper when Gitlab::VisibilityLevel::PRIVATE "Project access must be granted explicitly to each user." when Gitlab::VisibilityLevel::INTERNAL - "The project can be cloned by any logged in user." + "The project can be accessed by any logged in user." when Gitlab::VisibilityLevel::PUBLIC - "The project can be cloned without any authentication." + "The project can be accessed without any authentication." end end -- cgit v1.2.1