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
202e37bb
Commit
202e37bb
authored
Jul 30, 2018
by
Filipa Lacerda
Committed by
Phil Hughes
Jul 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Copy diff file path as GFM" is broken
parent
036c6db8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
21 deletions
+59
-21
app/assets/javascripts/diffs/components/diff_file_header.vue
app/assets/javascripts/diffs/components/diff_file_header.vue
+4
-0
app/assets/javascripts/vue_shared/components/clipboard_button.vue
...ts/javascripts/vue_shared/components/clipboard_button.vue
+14
-1
changelogs/unreleased/48823-copy-gfm.yml
changelogs/unreleased/48823-copy-gfm.yml
+5
-0
spec/javascripts/diffs/components/diff_file_header_spec.js
spec/javascripts/diffs/components/diff_file_header_spec.js
+1
-1
spec/javascripts/vue_shared/components/clipboard_button_spec.js
...avascripts/vue_shared/components/clipboard_button_spec.js
+35
-19
No files found.
app/assets/javascripts/diffs/components/diff_file_header.vue
View file @
202e37bb
...
@@ -108,6 +108,9 @@ export default {
...
@@ -108,6 +108,9 @@ export default {
false
,
false
,
);
);
},
},
gfmCopyText
()
{
return
`\`
${
this
.
diffFile
.
filePath
}
\``
;
},
},
},
methods
:
{
methods
:
{
...
mapActions
(
'
diffs
'
,
[
'
toggleFileDiscussions
'
]),
...
mapActions
(
'
diffs
'
,
[
'
toggleFileDiscussions
'
]),
...
@@ -191,6 +194,7 @@ export default {
...
@@ -191,6 +194,7 @@ export default {
<clipboard-button
<clipboard-button
:title=
"__('Copy file path to clipboard')"
:title=
"__('Copy file path to clipboard')"
:text=
"diffFile.filePath"
:text=
"diffFile.filePath"
:gfm=
"gfmCopyText"
css-class=
"btn-default btn-transparent btn-clipboard"
css-class=
"btn-default btn-transparent btn-clipboard"
/>
/>
...
...
app/assets/javascripts/vue_shared/components/clipboard_button.vue
View file @
202e37bb
...
@@ -31,6 +31,11 @@ export default {
...
@@ -31,6 +31,11 @@ export default {
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
gfm
:
{
type
:
String
,
required
:
false
,
default
:
null
,
},
title
:
{
title
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
...
@@ -51,6 +56,14 @@ export default {
...
@@ -51,6 +56,14 @@ export default {
default
:
'
btn-default
'
,
default
:
'
btn-default
'
,
},
},
},
},
computed
:
{
clipboardText
()
{
if
(
this
.
gfm
!==
null
)
{
return
JSON
.
stringify
({
text
:
this
.
text
,
gfm
:
this
.
gfm
});
}
return
this
.
text
;
},
},
};
};
</
script
>
</
script
>
...
@@ -59,7 +72,7 @@ export default {
...
@@ -59,7 +72,7 @@ export default {
v-tooltip
v-tooltip
:class=
"cssClass"
:class=
"cssClass"
:title=
"title"
:title=
"title"
:data-clipboard-text=
"
t
ext"
:data-clipboard-text=
"
clipboardT
ext"
:data-container=
"tooltipContainer"
:data-container=
"tooltipContainer"
:data-placement=
"tooltipPlacement"
:data-placement=
"tooltipPlacement"
type=
"button"
type=
"button"
...
...
changelogs/unreleased/48823-copy-gfm.yml
0 → 100644
View file @
202e37bb
---
title
:
Resolve Copy diff file path as GFM is broken
merge_request
:
20725
author
:
type
:
fixed
spec/javascripts/diffs/components/diff_file_header_spec.js
View file @
202e37bb
...
@@ -303,7 +303,7 @@ describe('diff_file_header', () => {
...
@@ -303,7 +303,7 @@ describe('diff_file_header', () => {
const
button
=
vm
.
$el
.
querySelector
(
'
.btn-clipboard
'
);
const
button
=
vm
.
$el
.
querySelector
(
'
.btn-clipboard
'
);
expect
(
button
).
not
.
toBe
(
null
);
expect
(
button
).
not
.
toBe
(
null
);
expect
(
button
.
dataset
.
clipboardText
).
toBe
(
props
.
diffFile
.
filePath
);
expect
(
button
.
dataset
.
clipboardText
).
toBe
(
'
{"text":"files/ruby/popen.rb","gfm":"`files/ruby/popen.rb`"}
'
);
});
});
describe
(
'
file mode
'
,
()
=>
{
describe
(
'
file mode
'
,
()
=>
{
...
...
spec/javascripts/vue_shared/components/clipboard_button_spec.js
View file @
202e37bb
...
@@ -6,6 +6,11 @@ describe('clipboard button', () => {
...
@@ -6,6 +6,11 @@ describe('clipboard button', () => {
const
Component
=
Vue
.
extend
(
clipboardButton
);
const
Component
=
Vue
.
extend
(
clipboardButton
);
let
vm
;
let
vm
;
afterEach
(()
=>
{
vm
.
$destroy
();
});
describe
(
'
without gfm
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
vm
=
mountComponent
(
Component
,
{
vm
=
mountComponent
(
Component
,
{
text
:
'
copy me
'
,
text
:
'
copy me
'
,
...
@@ -14,10 +19,6 @@ describe('clipboard button', () => {
...
@@ -14,10 +19,6 @@ describe('clipboard button', () => {
});
});
});
});
afterEach
(()
=>
{
vm
.
$destroy
();
});
it
(
'
renders a button for clipboard
'
,
()
=>
{
it
(
'
renders a button for clipboard
'
,
()
=>
{
expect
(
vm
.
$el
.
tagName
).
toEqual
(
'
BUTTON
'
);
expect
(
vm
.
$el
.
tagName
).
toEqual
(
'
BUTTON
'
);
expect
(
vm
.
$el
.
getAttribute
(
'
data-clipboard-text
'
)).
toEqual
(
'
copy me
'
);
expect
(
vm
.
$el
.
getAttribute
(
'
data-clipboard-text
'
)).
toEqual
(
'
copy me
'
);
...
@@ -33,4 +34,19 @@ describe('clipboard button', () => {
...
@@ -33,4 +34,19 @@ describe('clipboard button', () => {
it
(
'
should render provided classname
'
,
()
=>
{
it
(
'
should render provided classname
'
,
()
=>
{
expect
(
vm
.
$el
.
classList
).
toContain
(
'
btn-danger
'
);
expect
(
vm
.
$el
.
classList
).
toContain
(
'
btn-danger
'
);
});
});
});
describe
(
'
with gfm
'
,
()
=>
{
it
(
'
sets data-clipboard-text with gfm
'
,
()
=>
{
vm
=
mountComponent
(
Component
,
{
text
:
'
copy me
'
,
gfm
:
'
`path/to/file`
'
,
title
:
'
Copy this value into Clipboard!
'
,
cssClass
:
'
btn-danger
'
,
});
expect
(
vm
.
$el
.
getAttribute
(
'
data-clipboard-text
'
)).
toEqual
(
'
{"text":"copy me","gfm":"`path/to/file`"}
'
,
);
});
});
});
});
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