Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ee5490c8
Commit
ee5490c8
authored
Mar 23, 2021
by
Virgile Mathieu
Committed by
Paul Slaughter
Mar 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add copy to clipboard button on project ID
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53224
parent
994a0bc4
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
3 deletions
+21
-3
app/helpers/button_helper.rb
app/helpers/button_helper.rb
+3
-1
app/views/projects/_home_panel.html.haml
app/views/projects/_home_panel.html.haml
+3
-2
changelogs/unreleased/255288-add-a-click-to-copy-link-against-the-project-ID.yml
...55288-add-a-click-to-copy-link-against-the-project-ID.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/helpers/button_helper_spec.rb
spec/helpers/button_helper_spec.rb
+7
-0
No files found.
app/helpers/button_helper.rb
View file @
ee5490c8
...
@@ -25,6 +25,7 @@ module ButtonHelper
...
@@ -25,6 +25,7 @@ module ButtonHelper
button_text
=
data
[
:button_text
]
||
''
button_text
=
data
[
:button_text
]
||
''
hide_tooltip
=
data
[
:hide_tooltip
]
||
false
hide_tooltip
=
data
[
:hide_tooltip
]
||
false
hide_button_icon
=
data
[
:hide_button_icon
]
||
false
hide_button_icon
=
data
[
:hide_button_icon
]
||
false
item_prop
=
data
[
:itemprop
]
||
nil
# This supports code in app/assets/javascripts/copy_to_clipboard.js that
# 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.
# works around ClipboardJS limitations to allow the context-specific copy/pasting of plain text or GFM.
...
@@ -49,7 +50,8 @@ module ButtonHelper
...
@@ -49,7 +50,8 @@ module ButtonHelper
data:
data
,
data:
data
,
type: :button
,
type: :button
,
title:
title
,
title:
title
,
aria:
{
label:
title
}
aria:
{
label:
title
},
itemprop:
item_prop
}
}
content_tag
:button
,
button_attributes
do
content_tag
:button
,
button_attributes
do
...
...
app/views/projects/_home_panel.html.haml
View file @
ee5490c8
...
@@ -17,8 +17,9 @@
...
@@ -17,8 +17,9 @@
=
render_if_exists
'compliance_management/compliance_framework/compliance_framework_badge'
,
project:
@project
=
render_if_exists
'compliance_management/compliance_framework/compliance_framework_badge'
,
project:
@project
.home-panel-metadata.d-flex.flex-wrap.text-secondary.gl-font-base.gl-font-weight-normal.gl-line-height-normal
.home-panel-metadata.d-flex.flex-wrap.text-secondary.gl-font-base.gl-font-weight-normal.gl-line-height-normal
-
if
can?
(
current_user
,
:read_project
,
@project
)
-
if
can?
(
current_user
,
:read_project
,
@project
)
%span
.text-secondary
{
itemprop:
'identifier'
,
data:
{
qa_selector:
'project_id_content'
}
}
-
button_class
=
"btn-clipboard btn-transparent btn-no-padding gl-font-base gl-font-weight-normal gl-line-height-normal home-panel-metadata"
=
s_
(
'ProjectPage|Project ID: %{project_id}'
)
%
{
project_id:
@project
.
id
}
-
button_text
=
s_
(
'ProjectPage|Project ID: %{project_id}'
)
%
{
project_id:
@project
.
id
}
=
clipboard_button
(
title:
s_
(
'ProjectPage|Copy project ID'
),
text:
@project
.
id
,
hide_button_icon:
true
,
button_text:
button_text
,
class:
button_class
,
qa_selector:
'project_id_content'
,
itemprop:
'identifier'
)
-
if
current_user
-
if
current_user
%span
.access-request-links.gl-ml-3
%span
.access-request-links.gl-ml-3
=
render
'shared/members/access_request_links'
,
source:
@project
=
render
'shared/members/access_request_links'
,
source:
@project
...
...
changelogs/unreleased/255288-add-a-click-to-copy-link-against-the-project-ID.yml
0 → 100644
View file @
ee5490c8
---
title
:
"
Add
click
to
copy
button
over
project
ID"
merge_request
:
53224
author
:
Virgile MATHIEU @vmathieu
type
:
added
locale/gitlab.pot
View file @
ee5490c8
...
@@ -23827,6 +23827,9 @@ msgstr ""
...
@@ -23827,6 +23827,9 @@ msgstr ""
msgid "ProjectOverview|You must sign in to star a project"
msgid "ProjectOverview|You must sign in to star a project"
msgstr ""
msgstr ""
msgid "ProjectPage|Copy project ID"
msgstr ""
msgid "ProjectPage|Project ID: %{project_id}"
msgid "ProjectPage|Project ID: %{project_id}"
msgstr ""
msgstr ""
...
...
spec/helpers/button_helper_spec.rb
View file @
ee5490c8
...
@@ -171,6 +171,7 @@ RSpec.describe ButtonHelper do
...
@@ -171,6 +171,7 @@ RSpec.describe ButtonHelper do
expect
(
element
.
attr
(
'data-placement'
)).
to
eq
(
'bottom'
)
expect
(
element
.
attr
(
'data-placement'
)).
to
eq
(
'bottom'
)
expect
(
element
.
attr
(
'data-container'
)).
to
eq
(
'body'
)
expect
(
element
.
attr
(
'data-container'
)).
to
eq
(
'body'
)
expect
(
element
.
attr
(
'data-clipboard-text'
)).
to
eq
(
nil
)
expect
(
element
.
attr
(
'data-clipboard-text'
)).
to
eq
(
nil
)
expect
(
element
.
attr
(
'itemprop'
)).
to
eq
(
nil
)
expect
(
element
.
inner_text
).
to
eq
(
""
)
expect
(
element
.
inner_text
).
to
eq
(
""
)
expect
(
element
.
to_html
).
to
include
sprite_icon
(
'copy-to-clipboard'
)
expect
(
element
.
to_html
).
to
include
sprite_icon
(
'copy-to-clipboard'
)
...
@@ -209,5 +210,11 @@ RSpec.describe ButtonHelper do
...
@@ -209,5 +210,11 @@ RSpec.describe ButtonHelper do
expect
(
element
(
hide_button_icon:
true
).
to_html
).
not_to
include
sprite_icon
(
'duplicate'
)
expect
(
element
(
hide_button_icon:
true
).
to_html
).
not_to
include
sprite_icon
(
'duplicate'
)
end
end
end
end
context
'with `itemprop` attribute provided'
do
it
'shows copy to clipboard button with `itemprop` attribute'
do
expect
(
element
(
itemprop:
"identifier"
).
attr
(
'itemprop'
)).
to
eq
(
"identifier"
)
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment