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
f0e3674c
Commit
f0e3674c
authored
Sep 17, 2020
by
Paul Slaughter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tooltip for diffs edit file dropdown
- Also renames the "Edit file" to "Edit in single-file editor"
parent
888559be
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
17 deletions
+46
-17
app/assets/javascripts/diffs/components/edit_button.vue
app/assets/javascripts/diffs/components/edit_button.vue
+13
-3
locale/gitlab.pot
locale/gitlab.pot
+4
-1
spec/features/merge_request/maintainer_edits_fork_spec.rb
spec/features/merge_request/maintainer_edits_fork_spec.rb
+1
-1
spec/features/projects/blobs/edit_spec.rb
spec/features/projects/blobs/edit_spec.rb
+1
-1
spec/frontend/diffs/components/edit_button_spec.js
spec/frontend/diffs/components/edit_button_spec.js
+27
-11
No files found.
app/assets/javascripts/diffs/components/edit_button.vue
View file @
f0e3674c
<
script
>
<
script
>
import
{
uniqueId
}
from
'
lodash
'
;
import
{
import
{
GlTooltipDirective
,
GlTooltipDirective
,
GlIcon
,
GlIcon
,
...
@@ -37,13 +38,16 @@ export default {
...
@@ -37,13 +38,16 @@ export default {
default
:
false
,
default
:
false
,
},
},
},
},
data
()
{
return
{
tooltipId
:
uniqueId
(
'
edit_button_tooltip_
'
)
};
},
computed
:
{
computed
:
{
tooltipTitle
()
{
tooltipTitle
()
{
if
(
this
.
isDisabled
)
{
if
(
this
.
isDisabled
)
{
return
__
(
"
Can't edit as source branch was deleted
"
);
return
__
(
"
Can't edit as source branch was deleted
"
);
}
}
return
''
;
return
__
(
'
Edit file in...
'
)
;
},
},
isDisabled
()
{
isDisabled
()
{
return
!
this
.
editPath
;
return
!
this
.
editPath
;
...
@@ -51,6 +55,10 @@ export default {
...
@@ -51,6 +55,10 @@ export default {
},
},
methods
:
{
methods
:
{
handleShow
(
evt
)
{
handleShow
(
evt
)
{
// We must hide the tooltip because it is redundant and doesn't close itself
// when dropdown opens because we are still "focused".
this
.
$root
.
$emit
(
'
bv::hide::tooltip
'
,
this
.
tooltipId
);
if
(
this
.
canCurrentUserFork
&&
!
this
.
canModifyBlob
)
{
if
(
this
.
canCurrentUserFork
&&
!
this
.
canModifyBlob
)
{
evt
.
preventDefault
();
evt
.
preventDefault
();
this
.
$emit
(
'
showForkMessage
'
);
this
.
$emit
(
'
showForkMessage
'
);
...
@@ -66,7 +74,7 @@ export default {
...
@@ -66,7 +74,7 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<div
v-gl-tooltip.top=
"
tooltipTitle
"
class=
"gl-display-flex"
>
<div
v-gl-tooltip.top=
"
{ title: tooltipTitle, id: tooltipId }
" class="gl-display-flex">
<gl-dropdown
<gl-dropdown
toggle-class=
"rounded-0"
toggle-class=
"rounded-0"
:disabled=
"isDisabled"
:disabled=
"isDisabled"
...
@@ -80,7 +88,9 @@ export default {
...
@@ -80,7 +88,9 @@ export default {
<span
class=
"gl-dropdown-toggle-text"
><gl-icon
name=
"pencil"
/></span>
<span
class=
"gl-dropdown-toggle-text"
><gl-icon
name=
"pencil"
/></span>
<gl-icon
class=
"gl-dropdown-caret"
name=
"chevron-down"
aria-hidden=
"true"
/>
<gl-icon
class=
"gl-dropdown-caret"
name=
"chevron-down"
aria-hidden=
"true"
/>
</
template
>
</
template
>
<gl-dropdown-item
v-if=
"editPath"
:href=
"editPath"
>
{{ __('Edit file') }}
</gl-dropdown-item>
<gl-dropdown-item
v-if=
"editPath"
:href=
"editPath"
>
{{
__('Edit in single-file editor')
}}
</gl-dropdown-item>
<gl-dropdown-item
v-if=
"ideEditPath"
:href=
"ideEditPath"
>
{{
<gl-dropdown-item
v-if=
"ideEditPath"
:href=
"ideEditPath"
>
{{
__('Edit in Web IDE')
__('Edit in Web IDE')
}}
</gl-dropdown-item>
}}
</gl-dropdown-item>
...
...
locale/gitlab.pot
View file @
f0e3674c
...
@@ -9243,7 +9243,7 @@ msgstr ""
...
@@ -9243,7 +9243,7 @@ msgstr ""
msgid "Edit environment"
msgid "Edit environment"
msgstr ""
msgstr ""
msgid "Edit file"
msgid "Edit file
in...
"
msgstr ""
msgstr ""
msgid "Edit files in the editor and commit changes here"
msgid "Edit files in the editor and commit changes here"
...
@@ -9258,6 +9258,9 @@ msgstr ""
...
@@ -9258,6 +9258,9 @@ msgstr ""
msgid "Edit in Web IDE"
msgid "Edit in Web IDE"
msgstr ""
msgstr ""
msgid "Edit in single-file editor"
msgstr ""
msgid "Edit issues"
msgid "Edit issues"
msgstr ""
msgstr ""
...
...
spec/features/merge_request/maintainer_edits_fork_spec.rb
View file @
f0e3674c
...
@@ -28,7 +28,7 @@ RSpec.describe 'a maintainer edits files on a source-branch of an MR from a fork
...
@@ -28,7 +28,7 @@ RSpec.describe 'a maintainer edits files on a source-branch of an MR from a fork
wait_for_requests
wait_for_requests
within
first
(
'.js-file-title'
)
do
within
first
(
'.js-file-title'
)
do
find
(
'[data-testid="edit_file"]'
).
click
find
(
'[data-testid="edit_file"]'
).
click
click_link
'Edit
file
'
click_link
'Edit
in single-file editor
'
end
end
wait_for_requests
wait_for_requests
end
end
...
...
spec/features/projects/blobs/edit_spec.rb
View file @
f0e3674c
...
@@ -30,7 +30,7 @@ RSpec.describe 'Editing file blob', :js do
...
@@ -30,7 +30,7 @@ RSpec.describe 'Editing file blob', :js do
def
mr_edit_and_commit
(
commit_changes:
true
)
def
mr_edit_and_commit
(
commit_changes:
true
)
wait_for_requests
wait_for_requests
find
(
'[data-testid="edit_file"]'
).
click
find
(
'[data-testid="edit_file"]'
).
click
click_link
'Edit
file
'
click_link
'Edit
in single-file editor
'
fill_and_commit
(
commit_changes
)
fill_and_commit
(
commit_changes
)
end
end
...
...
spec/frontend/diffs/components/edit_button_spec.js
View file @
f0e3674c
...
@@ -3,9 +3,12 @@ import { GlDeprecatedDropdown, GlDeprecatedDropdownItem, GlIcon } from '@gitlab/
...
@@ -3,9 +3,12 @@ import { GlDeprecatedDropdown, GlDeprecatedDropdownItem, GlIcon } from '@gitlab/
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
{
createMockDirective
,
getBinding
}
from
'
helpers/vue_mock_directive
'
;
import
EditButton
from
'
~/diffs/components/edit_button.vue
'
;
import
EditButton
from
'
~/diffs/components/edit_button.vue
'
;
jest
.
mock
(
'
lodash/uniqueId
'
,
()
=>
(
str
=
''
)
=>
`
${
str
}
fake`
);
const
TOOLTIP_ID
=
'
edit_button_tooltip_fake
'
;
const
EDIT_ITEM
=
{
const
EDIT_ITEM
=
{
href
:
'
test-path
'
,
href
:
'
test-path
'
,
text
:
'
Edit
file
'
,
text
:
'
Edit
in single-file editor
'
,
};
};
const
IDE_EDIT_ITEM
=
{
const
IDE_EDIT_ITEM
=
{
href
:
'
ide-test-path
'
,
href
:
'
ide-test-path
'
,
...
@@ -66,7 +69,7 @@ describe('EditButton', () => {
...
@@ -66,7 +69,7 @@ describe('EditButton', () => {
});
});
it
(
'
does not have tooltip
'
,
()
=>
{
it
(
'
does not have tooltip
'
,
()
=>
{
expect
(
getTooltip
()).
to
Be
(
''
);
expect
(
getTooltip
()).
to
Equal
({
id
:
TOOLTIP_ID
,
title
:
'
Edit file in...
'
}
);
});
});
it
(
'
shows pencil dropdown
'
,
()
=>
{
it
(
'
shows pencil dropdown
'
,
()
=>
{
...
@@ -74,16 +77,26 @@ describe('EditButton', () => {
...
@@ -74,16 +77,26 @@ describe('EditButton', () => {
expect
(
wrapper
.
find
(
'
.gl-dropdown-caret
'
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
'
.gl-dropdown-caret
'
).
exists
()).
toBe
(
true
);
});
});
it
.
each
`
describe
.
each
`
event | expectedEmit
event | expectedEmit | expectedRootEmit
${
'
show
'
}
|
${
'
open
'
}
${
'
show
'
}
|
${
'
open
'
}
|
${[[
'
bv::hide::tooltip
'
,
TOOLTIP_ID
]]}
${
'
hide
'
}
|
${
'
close
'
}
${
'
hide
'
}
|
${
'
close
'
}
|
${[]}
`
(
'
when dropdown emits $event, emits $expectedEmit
'
,
({
event
,
expectedEmit
})
=>
{
`
(
'
when dropdown emits $event
'
,
({
event
,
expectedEmit
,
expectedRootEmit
})
=>
{
expect
(
wrapper
.
emitted
(
expectedEmit
)).
toBeUndefined
();
let
rootEmitSpy
;
beforeEach
(()
=>
{
rootEmitSpy
=
jest
.
spyOn
(
wrapper
.
vm
.
$root
,
'
$emit
'
);
findDropdown
().
vm
.
$emit
(
event
);
findDropdown
().
vm
.
$emit
(
event
);
});
expect
(
wrapper
.
emitted
(
expectedEmit
)).
toEqual
([[]]);
it
(
`emits
${
expectedEmit
}
`
,
()
=>
{
expect
(
wrapper
.
emitted
(
expectedEmit
)).
toEqual
([[]]);
});
it
(
`emits root =
${
JSON
.
stringify
(
expectedRootEmit
)}
`
,
()
=>
{
expect
(
rootEmitSpy
.
mock
.
calls
).
toEqual
(
expectedRootEmit
);
});
});
});
});
});
...
@@ -118,7 +131,10 @@ describe('EditButton', () => {
...
@@ -118,7 +131,10 @@ describe('EditButton', () => {
});
});
it
(
'
should have tooltip
'
,
()
=>
{
it
(
'
should have tooltip
'
,
()
=>
{
expect
(
getTooltip
()).
toBe
(
"
Can't edit as source branch was deleted
"
);
expect
(
getTooltip
()).
toEqual
({
id
:
TOOLTIP_ID
,
title
:
"
Can't edit as source branch was deleted
"
,
});
});
});
});
});
});
});
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