diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-07-11 19:24:46 -0500 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-07-11 19:24:46 -0500 |
commit | c011890d3af66ddcbac3783e0df69430bfe204a0 (patch) | |
tree | d1430841802669cbe4330cd5f5bbd84af898222f | |
parent | 0452e0a57e24fdd65f559cc1a8629892714adc7a (diff) | |
download | gitlab-ce-rs-remove-clipboard-button-with-class.tar.gz |
Remove duplication-heavy clipboard_button_with_class helperrs-remove-clipboard-button-with-class
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/19682
-rw-r--r-- | app/helpers/button_helper.rb | 31 | ||||
-rw-r--r-- | app/views/profiles/personal_access_tokens/index.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/commit/_commit_box.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/commits/_commit.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/container_registry/_tag.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/merge_requests/show/_how_to_merge.html.haml | 6 | ||||
-rw-r--r-- | app/views/projects/pipelines/_info.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/snippets/show.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/_clone_panel.html.haml | 2 | ||||
-rw-r--r-- | app/views/shared/issuable/_sidebar.html.haml | 4 | ||||
-rw-r--r-- | app/views/snippets/show.html.haml | 2 |
11 files changed, 22 insertions, 35 deletions
diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb index 0f097f86816..2ff5a440b69 100644 --- a/app/helpers/button_helper.rb +++ b/app/helpers/button_helper.rb @@ -1,38 +1,25 @@ module ButtonHelper # Output a "Copy to Clipboard" button # - # data - Data attributes passed to `content_tag` + # data - Data attributes passed to `content_tag` (default: {}) + # css_class - CSS class override (default: "btn-clipboard") # # Examples: # # # Define the clipboard's text - # clipboard_button(clipboard_text: "Foo") + # clipboard_button(data: { clipboard_text: "Foo" }) # # => "<button class='...' data-clipboard-text='Foo'>...</button>" # # # Define the target element - # clipboard_button(clipboard_target: "div#foo") + # clipboard_button(data: { clipboard_target: "div#foo" }) # # => "<button class='...' data-clipboard-target='div#foo'>...</button>" # - # See http://clipboardjs.com/#usage - def clipboard_button(data = {}) - content_tag :button, - icon('clipboard'), - class: "btn btn-clipboard", - data: data, - type: :button - end - - # Output a "Copy to Clipboard" button with a custom CSS class - # - # data - Data attributes passed to `content_tag` - # css_class - Class passed to the `content_tag` + # # Override the CSS class + # clipboard_button(css_class: 'btn-transparent') + # # => "<button class='btn btn-transparent'>...</button>" # - # Examples: - # - # # Define the target element - # clipboard_button_with_class({clipboard_target: "div#foo"}, css_class: "btn-clipboard") - # # => "<button class='btn btn-clipboard' data-clipboard-target='div#foo'>...</button>" - def clipboard_button_with_class(data = {}, css_class: 'btn-clipboard') + # See http://clipboardjs.com/#usage + def clipboard_button(data: {}, css_class: 'btn-clipboard') content_tag :button, icon('clipboard'), class: "btn #{css_class}", diff --git a/app/views/profiles/personal_access_tokens/index.html.haml b/app/views/profiles/personal_access_tokens/index.html.haml index 71ac367830d..5e4b962ec04 100644 --- a/app/views/profiles/personal_access_tokens/index.html.haml +++ b/app/views/profiles/personal_access_tokens/index.html.haml @@ -15,7 +15,7 @@ Your New Personal Access Token .form-group = text_field_tag 'created-personal-access-token', flash[:personal_access_token], readonly: true, class: "form-control", 'aria-describedby' => "created-personal-access-token-help-block" - = clipboard_button(clipboard_text: flash[:personal_access_token]) + = clipboard_button(data: { clipboard_text: flash[:personal_access_token] }) %span#created-personal-access-token-help-block.help-block.text-danger Make sure you save it - you won't be able to access it again. %hr diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index 3ad866bb2f1..6c62ed5849a 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -42,7 +42,7 @@ %span.hidden-xs.hidden-sm Commit = link_to @commit.id, namespace_project_commit_path(@project.namespace, @project, @commit), class: "monospace hidden-xs hidden-sm" = link_to @commit.short_id, namespace_project_commit_path(@project.namespace, @project, @commit), class: "monospace visible-xs-inline visible-sm-inline" - = clipboard_button(clipboard_text: @commit.id) + = clipboard_button(data: { clipboard_text: @commit.id }) %span.cgray= pluralize(@commit.parents.count, "parent") - @commit.parents.each do |parent| = link_to parent.short_id, namespace_project_commit_path(@project.namespace, @project, parent), class: "monospace" diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index 929496f81d8..a37e3ef3ed9 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -25,7 +25,7 @@ .commit-actions.hidden-xs - if commit.status = render_commit_status(commit, cssclass: 'btn btn-transparent') - = clipboard_button_with_class({ clipboard_text: commit.id }, css_class: 'btn-transparent') + = clipboard_button(data: { clipboard_text: commit.id }, css_class: 'btn-transparent') = link_to commit.short_id, namespace_project_commit_path(project.namespace, project, commit), class: "commit-short-id btn btn-transparent" = link_to_browse_code(project, commit) diff --git a/app/views/projects/container_registry/_tag.html.haml b/app/views/projects/container_registry/_tag.html.haml index 10822b6184c..5436a08fb7f 100644 --- a/app/views/projects/container_registry/_tag.html.haml +++ b/app/views/projects/container_registry/_tag.html.haml @@ -1,7 +1,7 @@ %tr.tag %td = escape_once(tag.name) - = clipboard_button(clipboard_text: "docker pull #{tag.path}") + = clipboard_button(data: { clipboard_text: "docker pull #{tag.path}" }) %td - if tag.revision %span.has-tooltip{ title: "#{tag.revision}" } diff --git a/app/views/projects/merge_requests/show/_how_to_merge.html.haml b/app/views/projects/merge_requests/show/_how_to_merge.html.haml index b3bea900d42..32a6b1ab0c2 100644 --- a/app/views/projects/merge_requests/show/_how_to_merge.html.haml +++ b/app/views/projects/merge_requests/show/_how_to_merge.html.haml @@ -8,7 +8,7 @@ %p %strong Step 1. Fetch and check out the branch for this merge request - = clipboard_button_with_class({clipboard_target: "pre#merge-info-1"}, css_class: "btn-clipboard") + = clipboard_button(data: { clipboard_target: "pre#merge-info-1" }) %pre.dark#merge-info-1 - if @merge_request.for_fork? :preserve @@ -25,7 +25,7 @@ %p %strong Step 3. Merge the branch and fix any conflicts that come up - = clipboard_button_with_class({clipboard_target: "pre#merge-info-3"}, css_class: "btn-clipboard") + = clipboard_button(data: { clipboard_target: "pre#merge-info-3" }) %pre.dark#merge-info-3 - if @merge_request.for_fork? :preserve @@ -38,7 +38,7 @@ %p %strong Step 4. Push the result of the merge to GitLab - = clipboard_button_with_class({clipboard_target: "pre#merge-info-4"}, css_class: "btn-clipboard") + = clipboard_button(data: { clipboard_target: "pre#merge-info-4" }) %pre.dark#merge-info-4 :preserve git push origin #{h @merge_request.target_branch} diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index 8289aefcde7..56d715229ce 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -26,7 +26,7 @@ .commit-info-row %span.light Commit = link_to @pipeline.sha, namespace_project_commit_path(@project.namespace, @project, @pipeline.sha), class: "monospace" - = clipboard_button(clipboard_text: @pipeline.sha) + = clipboard_button(data: { clipboard_text: @pipeline.sha }) - if @commit .commit-box.content-block diff --git a/app/views/projects/snippets/show.html.haml b/app/views/projects/snippets/show.html.haml index bae4d8f349f..e9b2087ba69 100644 --- a/app/views/projects/snippets/show.html.haml +++ b/app/views/projects/snippets/show.html.haml @@ -8,7 +8,7 @@ = blob_icon 0, @snippet.file_name = @snippet.file_name .file-actions.hidden-xs - = clipboard_button(clipboard_target: ".blob-content[data-blob-id='#{@snippet.id}']") + = clipboard_button(data: { clipboard_target: ".blob-content[data-blob-id='#{@snippet.id}']" }) = link_to 'Raw', raw_namespace_project_snippet_path(@project.namespace, @project, @snippet), class: "btn btn-sm", target: "_blank" = render 'shared/snippets/blob' diff --git a/app/views/shared/_clone_panel.html.haml b/app/views/shared/_clone_panel.html.haml index 3b82d8e686f..c2d770132ea 100644 --- a/app/views/shared/_clone_panel.html.haml +++ b/app/views/shared/_clone_panel.html.haml @@ -19,7 +19,7 @@ = text_field_tag :project_clone, default_url_to_repo(project), class: "js-select-on-focus form-control", readonly: true .input-group-btn - = clipboard_button(clipboard_target: '#project_clone') + = clipboard_button(data: { clipboard_target: '#project_clone' }) :javascript $('ul.clone-options-dropdown a').on('click',function(e){ diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index adfab1af53e..108dd1f446a 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -157,13 +157,13 @@ - project_ref = cross_project_reference(@project, issuable) .block.project-reference .sidebar-collapsed-icon - = clipboard_button(clipboard_text: project_ref) + = clipboard_button(data: { clipboard_text: project_ref }) .cross-project-reference.hide-collapsed %span Reference: %cite{title: project_ref} = project_ref - = clipboard_button(clipboard_text: project_ref) + = clipboard_button(data: { clipboard_text: project_ref }) :javascript new MilestoneSelect('{"namespace":"#{@project.namespace.path}","path":"#{@project.path}"}'); diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml index ed3992650d4..8d405f08f94 100644 --- a/app/views/snippets/show.html.haml +++ b/app/views/snippets/show.html.haml @@ -8,6 +8,6 @@ = blob_icon 0, @snippet.file_name = @snippet.file_name .file-actions.hidden-xs - = clipboard_button(clipboard_target: ".blob-content[data-blob-id='#{@snippet.id}']") + = clipboard_button(data: { clipboard_target: ".blob-content[data-blob-id='#{@snippet.id}']" }) = link_to 'Raw', raw_snippet_path(@snippet), class: "btn btn-sm", target: "_blank" = render 'shared/snippets/blob' |