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
630cd0d3
Commit
630cd0d3
authored
Jan 11, 2022
by
Jacques
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix blob controls bug
Fixed incorrect controls bug in repo refactor
parent
7d3e3a44
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
14 deletions
+31
-14
app/assets/javascripts/repository/components/blob_controls.vue
...ssets/javascripts/repository/components/blob_controls.vue
+10
-4
spec/frontend/repository/components/blob_controls_spec.js
spec/frontend/repository/components/blob_controls_spec.js
+21
-10
No files found.
app/assets/javascripts/repository/components/blob_controls.vue
View file @
630cd0d3
...
@@ -63,19 +63,25 @@ export default {
...
@@ -63,19 +63,25 @@ export default {
},
},
computed
:
{
computed
:
{
filePath
()
{
filePath
()
{
const
{
path
}
=
this
.
$route
.
params
;
return
this
.
$route
.
params
.
path
;
updateElementsVisibility
(
'
.tree-controls
'
,
!
path
);
},
return
path
;
showBlobControls
()
{
return
this
.
filePath
&&
this
.
$route
.
name
===
'
blobPathDecoded
'
;
},
},
blobInfo
()
{
blobInfo
()
{
return
this
.
project
?.
repository
?.
blobs
?.
nodes
[
0
]
||
{};
return
this
.
project
?.
repository
?.
blobs
?.
nodes
[
0
]
||
{};
},
},
},
},
watch
:
{
showBlobControls
(
shouldShow
)
{
updateElementsVisibility
(
'
.tree-controls
'
,
!
shouldShow
);
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<div
v-if=
"
filePath
"
>
<div
v-if=
"
showBlobControls
"
>
<gl-button
data-testid=
"find"
:href=
"blobInfo.findFilePath"
:class=
"$options.buttonClassList"
>
<gl-button
data-testid=
"find"
:href=
"blobInfo.findFilePath"
:class=
"$options.buttonClassList"
>
{{
$options
.
i18n
.
findFile
}}
{{
$options
.
i18n
.
findFile
}}
</gl-button>
</gl-button>
...
...
spec/frontend/repository/components/blob_controls_spec.js
View file @
630cd0d3
...
@@ -7,8 +7,11 @@ import BlobControls from '~/repository/components/blob_controls.vue';
...
@@ -7,8 +7,11 @@ import BlobControls from '~/repository/components/blob_controls.vue';
import
blobControlsQuery
from
'
~/repository/queries/blob_controls.query.graphql
'
;
import
blobControlsQuery
from
'
~/repository/queries/blob_controls.query.graphql
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
{
shallowMountExtended
}
from
'
helpers/vue_test_utils_helper
'
;
import
createRouter
from
'
~/repository/router
'
;
import
createRouter
from
'
~/repository/router
'
;
import
{
updateElementsVisibility
}
from
'
~/repository/utils/dom
'
;
import
{
blobControlsDataMock
,
refMock
}
from
'
../mock_data
'
;
import
{
blobControlsDataMock
,
refMock
}
from
'
../mock_data
'
;
jest
.
mock
(
'
~/repository/utils/dom
'
);
let
router
;
let
router
;
let
wrapper
;
let
wrapper
;
let
mockResolver
;
let
mockResolver
;
...
@@ -64,8 +67,14 @@ describe('Blob controls component', () => {
...
@@ -64,8 +67,14 @@ describe('Blob controls component', () => {
expect
(
findPermalinkButton
().
attributes
(
'
href
'
)).
toBe
(
'
permalink/file.js
'
);
expect
(
findPermalinkButton
().
attributes
(
'
href
'
)).
toBe
(
'
permalink/file.js
'
);
});
});
it
(
'
does not render any buttons if no filePath is provided
'
,
async
()
=>
{
it
.
each
`
router
.
replace
({
name
:
'
blobPath
'
,
params
:
{
path
:
null
}
});
name | path
${
'
blobPathDecoded
'
}
|
${
null
}
${
'
treePathDecoded
'
}
|
${
'
myFile.js
'
}
`
(
'
does not render any buttons if router name is $name and router path is $path
'
,
async
({
name
,
path
})
=>
{
router
.
replace
({
name
,
params
:
{
path
}
});
await
nextTick
();
await
nextTick
();
...
@@ -73,5 +82,7 @@ describe('Blob controls component', () => {
...
@@ -73,5 +82,7 @@ describe('Blob controls component', () => {
expect
(
findBlameButton
().
exists
()).
toBe
(
false
);
expect
(
findBlameButton
().
exists
()).
toBe
(
false
);
expect
(
findHistoryButton
().
exists
()).
toBe
(
false
);
expect
(
findHistoryButton
().
exists
()).
toBe
(
false
);
expect
(
findPermalinkButton
().
exists
()).
toBe
(
false
);
expect
(
findPermalinkButton
().
exists
()).
toBe
(
false
);
});
expect
(
updateElementsVisibility
).
toHaveBeenCalledWith
(
'
.tree-controls
'
,
true
);
},
);
});
});
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