Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 14:09:20 +0300
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 14:09:20 +0300
commit2f22890d4223c0b524ee1f27e222a24a8f0c9a87 (patch)
tree79609a077a37cc49d95463b649ff4098cea10b4d /app/helpers
parent907b754173ed4185574c38ded0a173360d073085 (diff)
parentfb7b0d6e710d462f5bef1df3195fa8b051668bfc (diff)
Merge branch 'update-droplab-to-webpack-version' into new-resolvable-discussion
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/blob_helper.rb6
-rw-r--r--app/helpers/button_helper.rb25
-rw-r--r--app/helpers/system_note_helper.rb26
3 files changed, 51 insertions, 6 deletions
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 91d6d1852cf..b0ac1623fbe 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -102,7 +102,7 @@ module BlobHelper
if Gitlab::MarkupHelper.previewable?(filename)
'Preview'
else
- 'Preview Changes'
+ 'Preview changes'
end
end
@@ -210,13 +210,13 @@ module BlobHelper
end
def copy_file_path_button(file_path)
- clipboard_button(clipboard_text: file_path, class: 'btn-clipboard btn-transparent prepend-left-5', title: 'Copy file path to clipboard')
+ clipboard_button(text: file_path, gfm: "`#{file_path}`", class: 'btn-clipboard btn-transparent prepend-left-5', title: 'Copy file path to clipboard')
end
def copy_blob_content_button(blob)
return if markup?(blob.name)
- clipboard_button(clipboard_target: ".blob-content[data-blob-id='#{blob.id}']", class: "btn btn-sm", title: "Copy content to clipboard")
+ clipboard_button(target: ".blob-content[data-blob-id='#{blob.id}']", class: "btn btn-sm", title: "Copy content to clipboard")
end
def open_raw_file_button(path)
diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb
index 0b30471f2ae..c85e96cf78d 100644
--- a/app/helpers/button_helper.rb
+++ b/app/helpers/button_helper.rb
@@ -1,23 +1,42 @@
module ButtonHelper
# Output a "Copy to Clipboard" button
#
- # data - Data attributes passed to `content_tag`
+ # data - Data attributes passed to `content_tag` (default: {}):
+ # :text - Text to copy (optional)
+ # :gfm - GitLab Flavored Markdown to copy, if different from `text` (optional)
+ # :target - Selector for target element to copy from (optional)
#
# Examples:
#
# # Define the clipboard's text
- # clipboard_button(clipboard_text: "Foo")
+ # clipboard_button(text: "Foo")
# # => "<button class='...' data-clipboard-text='Foo'>...</button>"
#
# # Define the target element
- # clipboard_button(clipboard_target: "div#foo")
+ # clipboard_button(target: "div#foo")
# # => "<button class='...' data-clipboard-target='div#foo'>...</button>"
#
# See http://clipboardjs.com/#usage
def clipboard_button(data = {})
css_class = data[:class] || 'btn-clipboard btn-transparent'
title = data[:title] || 'Copy to clipboard'
+
+ # This supports code in app/assets/javascripts/copy_to_clipboard.js that
+ # works around ClipboardJS limitations to allow the context-specific copy/pasting of plain text or GFM.
+ if text = data.delete(:text)
+ data[:clipboard_text] =
+ if gfm = data.delete(:gfm)
+ { text: text, gfm: gfm }
+ else
+ text
+ end
+ end
+
+ target = data.delete(:target)
+ data[:clipboard_target] = target if target
+
data = { toggle: 'tooltip', placement: 'bottom', container: 'body' }.merge(data)
+
content_tag :button,
icon('clipboard', 'aria-hidden': 'true'),
class: "btn #{css_class}",
diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb
new file mode 100644
index 00000000000..3074921caff
--- /dev/null
+++ b/app/helpers/system_note_helper.rb
@@ -0,0 +1,26 @@
+module SystemNoteHelper
+ ICON_NAMES_BY_ACTION = {
+ 'commit' => 'icon_commit',
+ 'merge' => 'icon_merge',
+ 'merged' => 'icon_merged',
+ 'opened' => 'icon_status_open',
+ 'closed' => 'icon_status_closed',
+ 'time_tracking' => 'icon_stopwatch',
+ 'assignee' => 'icon_user',
+ 'title' => 'icon_pencil',
+ 'task' => 'icon_check_square_o',
+ 'label' => 'icon_tags',
+ 'cross_reference' => 'icon_random',
+ 'branch' => 'icon_code_fork',
+ 'confidential' => 'icon_eye_slash',
+ 'visible' => 'icon_eye',
+ 'milestone' => 'icon_clock_o',
+ 'discussion' => 'icon_comment_o',
+ 'moved' => 'icon_arrow_circle_o_right'
+ }.freeze
+
+ def icon_for_system_note(note)
+ icon_name = ICON_NAMES_BY_ACTION[note.system_note_metadata&.action]
+ custom_icon(icon_name) if icon_name
+ end
+end