diff options
author | Mayra Cabrera <mcabrera@gitlab.com> | 2019-06-05 16:28:43 +0000 |
---|---|---|
committer | Mayra Cabrera <mcabrera@gitlab.com> | 2019-06-05 16:28:43 +0000 |
commit | ec2f253a1ed8c0fe18cc677501d54cab36997c19 (patch) | |
tree | 6c1ebf7e4cdaadcaab38cedfbe4dc77c2ab82824 | |
parent | 327c7d5a07fa08276a52b6a2bfdf79eee812a2cd (diff) | |
parent | 0b0f39c5737265eb796040d13f6411f0c6b17708 (diff) | |
download | gitlab-ce-ec2f253a1ed8c0fe18cc677501d54cab36997c19.tar.gz |
Merge branch 'snowplow-attrs-helper' into 'master'
Add snowplow haml attr helper
See merge request gitlab-org/gitlab-ce!28724
-rw-r--r-- | app/helpers/tracking_helper.rb | 7 | ||||
-rw-r--r-- | app/views/projects/_import_project_pane.html.haml | 21 | ||||
-rw-r--r-- | spec/helpers/tracking_helper_spec.rb | 11 |
3 files changed, 28 insertions, 11 deletions
diff --git a/app/helpers/tracking_helper.rb b/app/helpers/tracking_helper.rb new file mode 100644 index 00000000000..51ea79d1ddd --- /dev/null +++ b/app/helpers/tracking_helper.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module TrackingHelper + def tracking_attrs(label, event, property) + {} # CE has no tracking features + end +end diff --git a/app/views/projects/_import_project_pane.html.haml b/app/views/projects/_import_project_pane.html.haml index b5678b56ca6..28d4f8eb201 100644 --- a/app/views/projects/_import_project_pane.html.haml +++ b/app/views/projects/_import_project_pane.html.haml @@ -8,59 +8,58 @@ .import-buttons - if gitlab_project_import_enabled? .import_gitlab_project.has-tooltip{ data: { container: 'body' } } - = link_to new_import_gitlab_project_path, class: 'btn btn_import_gitlab_project project-submit', data: { track_label: "#{track_label}", track_event: "click_button", track_property: "gitlab_export" } do + = link_to new_import_gitlab_project_path, class: 'btn btn_import_gitlab_project project-submit', **tracking_attrs(track_label, 'click_button', 'gitlab_export') do = icon('gitlab', text: 'GitLab export') - if github_import_enabled? %div - = link_to new_import_github_path, class: 'btn js-import-github', data: { track_label: "#{track_label}", track_event: "click_button", track_property: "github" } do + = link_to new_import_github_path, class: 'btn js-import-github', **tracking_attrs(track_label, 'click_button', 'github') do = icon('github', text: 'GitHub') - if bitbucket_import_enabled? %div = link_to status_import_bitbucket_path, class: "btn import_bitbucket #{'how_to_import_link' unless bitbucket_import_configured?}", - data: { track_label: "#{track_label}", track_event: "click_button", track_property: "bitbucket_cloud" } do + **tracking_attrs(track_label, 'click_button', 'bitbucket_cloud') do = icon('bitbucket', text: 'Bitbucket Cloud') - unless bitbucket_import_configured? = render 'bitbucket_import_modal' - if bitbucket_server_import_enabled? %div - = link_to status_import_bitbucket_server_path, class: "btn import_bitbucket", - data: { track_label: "#{track_label}", track_event: "click_button", track_property: "bitbucket_server" } do + = link_to status_import_bitbucket_server_path, class: "btn import_bitbucket", **tracking_attrs(track_label, 'click_button', 'bitbucket_server') do = icon('bitbucket-square', text: 'Bitbucket Server') %div - if gitlab_import_enabled? %div = link_to status_import_gitlab_path, class: "btn import_gitlab #{'how_to_import_link' unless gitlab_import_configured?}", - data: { track_label: "#{track_label}", track_event: "click_button", track_property: "gitlab_com" } do + **tracking_attrs(track_label, 'click_button', 'gitlab_com') do = icon('gitlab', text: 'GitLab.com') - unless gitlab_import_configured? = render 'gitlab_import_modal' - if google_code_import_enabled? %div - = link_to new_import_google_code_path, class: 'btn import_google_code', data: { track_label: "#{track_label}", track_event: "click_button", track_property: "google_code" } do + = link_to new_import_google_code_path, class: 'btn import_google_code', **tracking_attrs(track_label, 'click_button', 'google_code') do = icon('google', text: 'Google Code') - if fogbugz_import_enabled? %div - = link_to new_import_fogbugz_path, class: 'btn import_fogbugz', data: { track_label: "#{track_label}", track_event: "click_button", track_property: "fogbugz" } do + = link_to new_import_fogbugz_path, class: 'btn import_fogbugz', **tracking_attrs(track_label, 'click_button', 'fogbugz') do = icon('bug', text: 'Fogbugz') - if gitea_import_enabled? %div - = link_to new_import_gitea_path, class: 'btn import_gitea', data: { track_label: "#{track_label}", track_event: "click_button", track_property: "gitea" } do + = link_to new_import_gitea_path, class: 'btn import_gitea', **tracking_attrs(track_label, 'click_button', 'gitea') do = custom_icon('gitea_logo') Gitea - if git_import_enabled? %div - %button.btn.js-toggle-button.js-import-git-toggle-button{ type: "button", data: { toggle_open_class: 'active', data: { toggle_open_class: 'active', track_label: "#{track_label}" , track_event: "click_button", track_property: "repo_url" } } } + %button.btn.js-toggle-button.js-import-git-toggle-button{ type: "button", data: { toggle_open_class: 'active' }, **tracking_attrs(track_label, 'click_button', 'repo_url') } = icon('git', text: 'Repo by URL') - if manifest_import_enabled? %div - = link_to new_import_manifest_path, class: 'btn import_manifest', data: { track_label: "#{track_label}", track_event: "click_button", track_property: "manifest_file" } do + = link_to new_import_manifest_path, class: 'btn import_manifest', **tracking_attrs(track_label, 'click_button', 'manifest_file') do = icon('file-text-o', text: 'Manifest file') - if phabricator_import_enabled? diff --git a/spec/helpers/tracking_helper_spec.rb b/spec/helpers/tracking_helper_spec.rb new file mode 100644 index 00000000000..71505e8ea69 --- /dev/null +++ b/spec/helpers/tracking_helper_spec.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe TrackingHelper do + describe '#tracking_attrs' do + it 'returns an empty hash' do + expect(helper.tracking_attrs('a', 'b', 'c')).to eq({}) + end + end +end |