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
5f231d51
Commit
5f231d51
authored
Mar 31, 2021
by
Samantha Ming
Committed by
Savas Vedova
Mar 31, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use search param in refs call to filter revisions
Issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/324612
parent
e85e1011
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
23 deletions
+85
-23
app/assets/javascripts/projects/compare/components/revision_dropdown.vue
...scripts/projects/compare/components/revision_dropdown.vue
+37
-22
changelogs/unreleased/324612-tag-not-visible-compare-page.yml
...gelogs/unreleased/324612-tag-not-visible-compare-page.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/projects/compare/components/revision_dropdown_spec.js
...end/projects/compare/components/revision_dropdown_spec.js
+40
-1
No files found.
app/assets/javascripts/projects/compare/components/revision_dropdown.vue
View file @
5f231d51
<
script
>
<
script
>
import
{
GlDropdown
,
GlDropdownItem
,
GlSearchBoxByType
,
GlDropdownSectionHeader
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlDropdownItem
,
GlSearchBoxByType
,
GlDropdownSectionHeader
}
from
'
@gitlab/ui
'
;
import
{
debounce
}
from
'
lodash
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
s__
}
from
'
~/locale
'
;
const
emptyDropdownText
=
s__
(
'
CompareRevisions|Select branch/tag
'
);
const
EMPTY_DROPDOWN_TEXT
=
s__
(
'
CompareRevisions|Select branch/tag
'
);
const
SEARCH_DEBOUNCE_MS
=
300
;
export
default
{
export
default
{
components
:
{
components
:
{
...
@@ -38,19 +40,11 @@ export default {
...
@@ -38,19 +40,11 @@ export default {
};
};
},
},
computed
:
{
computed
:
{
filteredBranches
()
{
hasBranches
()
{
return
this
.
branches
.
filter
((
branch
)
=>
return
Boolean
(
this
.
branches
?.
length
);
branch
.
toLowerCase
().
includes
(
this
.
searchTerm
.
toLowerCase
()),
);
},
},
hasFilteredBranches
()
{
hasTags
()
{
return
this
.
filteredBranches
.
length
;
return
Boolean
(
this
.
tags
?.
length
);
},
filteredTags
()
{
return
this
.
tags
.
filter
((
tag
)
=>
tag
.
toLowerCase
().
includes
(
this
.
searchTerm
.
toLowerCase
()));
},
hasFilteredTags
()
{
return
this
.
filteredTags
.
length
;
},
},
},
},
watch
:
{
watch
:
{
...
@@ -59,13 +53,34 @@ export default {
...
@@ -59,13 +53,34 @@ export default {
this
.
fetchBranchesAndTags
(
true
);
this
.
fetchBranchesAndTags
(
true
);
}
}
},
},
searchTerm
:
debounce
(
function
debounceSearch
()
{
this
.
searchBranchesAndTags
();
},
SEARCH_DEBOUNCE_MS
),
},
},
mounted
()
{
mounted
()
{
this
.
fetchBranchesAndTags
();
this
.
fetchBranchesAndTags
();
},
},
methods
:
{
methods
:
{
searchBranchesAndTags
()
{
return
axios
.
get
(
this
.
refsProjectPath
,
{
params
:
{
search
:
this
.
searchTerm
,
},
})
.
then
(({
data
})
=>
{
this
.
branches
=
data
.
Branches
||
[];
this
.
tags
=
data
.
Tags
||
[];
})
.
catch
(()
=>
{
createFlash
({
message
:
s__
(
'
CompareRevisions|There was an error while searching the branch/tag list. Please try again.
'
,
),
});
});
},
fetchBranchesAndTags
(
reset
=
false
)
{
fetchBranchesAndTags
(
reset
=
false
)
{
const
endpoint
=
this
.
refsProjectPath
;
this
.
loading
=
true
;
this
.
loading
=
true
;
if
(
reset
)
{
if
(
reset
)
{
...
@@ -73,7 +88,7 @@ export default {
...
@@ -73,7 +88,7 @@ export default {
}
}
return
axios
return
axios
.
get
(
endpoint
)
.
get
(
this
.
refsProjectPath
)
.
then
(({
data
})
=>
{
.
then
(({
data
})
=>
{
this
.
branches
=
data
.
Branches
||
[];
this
.
branches
=
data
.
Branches
||
[];
this
.
tags
=
data
.
Tags
||
[];
this
.
tags
=
data
.
Tags
||
[];
...
@@ -90,7 +105,7 @@ export default {
...
@@ -90,7 +105,7 @@ export default {
});
});
},
},
getDefaultBranch
()
{
getDefaultBranch
()
{
return
this
.
paramsBranch
||
emptyDropdownText
;
return
this
.
paramsBranch
||
EMPTY_DROPDOWN_TEXT
;
},
},
onClick
(
revision
)
{
onClick
(
revision
)
{
this
.
selectedRevision
=
revision
;
this
.
selectedRevision
=
revision
;
...
@@ -119,24 +134,24 @@ export default {
...
@@ -119,24 +134,24 @@ export default {
@
keyup.enter=
"onSearchEnter"
@
keyup.enter=
"onSearchEnter"
/>
/>
</
template
>
</
template
>
<gl-dropdown-section-header
v-if=
"has
Filtered
Branches"
>
<gl-dropdown-section-header
v-if=
"hasBranches"
>
{{ s__('CompareRevisions|Branches') }}
{{ s__('CompareRevisions|Branches') }}
</gl-dropdown-section-header>
</gl-dropdown-section-header>
<gl-dropdown-item
<gl-dropdown-item
v-for=
"
(branch, index) in filteredB
ranches"
v-for=
"
branch in b
ranches"
:key=
"
`branch${index}`
"
:key=
"
branch
"
is-check-item
is-check-item
:is-checked=
"selectedRevision === branch"
:is-checked=
"selectedRevision === branch"
@
click=
"onClick(branch)"
@
click=
"onClick(branch)"
>
>
{{ branch }}
{{ branch }}
</gl-dropdown-item>
</gl-dropdown-item>
<gl-dropdown-section-header
v-if=
"has
Filtered
Tags"
>
<gl-dropdown-section-header
v-if=
"hasTags"
>
{{ s__('CompareRevisions|Tags') }}
{{ s__('CompareRevisions|Tags') }}
</gl-dropdown-section-header>
</gl-dropdown-section-header>
<gl-dropdown-item
<gl-dropdown-item
v-for=
"
(tag, index) in filteredT
ags"
v-for=
"
tag in t
ags"
:key=
"
`tag${index}`
"
:key=
"
tag
"
is-check-item
is-check-item
:is-checked=
"selectedRevision === tag"
:is-checked=
"selectedRevision === tag"
@
click=
"onClick(tag)"
@
click=
"onClick(tag)"
...
...
changelogs/unreleased/324612-tag-not-visible-compare-page.yml
0 → 100644
View file @
5f231d51
---
title
:
Use search param in refs call to filter revisions
merge_request
:
57442
author
:
type
:
fixed
locale/gitlab.pot
View file @
5f231d51
...
@@ -7829,6 +7829,9 @@ msgstr ""
...
@@ -7829,6 +7829,9 @@ msgstr ""
msgid "CompareRevisions|There was an error while loading the branch/tag list. Please try again."
msgid "CompareRevisions|There was an error while loading the branch/tag list. Please try again."
msgstr ""
msgstr ""
msgid "CompareRevisions|There was an error while searching the branch/tag list. Please try again."
msgstr ""
msgid "CompareRevisions|There was an error while updating the branch/tag list. Please try again."
msgid "CompareRevisions|There was an error while updating the branch/tag list. Please try again."
msgstr ""
msgstr ""
...
...
spec/frontend/projects/compare/components/revision_dropdown_spec.js
View file @
5f231d51
import
{
GlDropdown
}
from
'
@gitlab/ui
'
;
import
{
GlDropdown
,
GlSearchBoxByType
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
AxiosMockAdapter
from
'
axios-mock-adapter
'
;
import
AxiosMockAdapter
from
'
axios-mock-adapter
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
...
@@ -23,6 +23,10 @@ describe('RevisionDropdown component', () => {
...
@@ -23,6 +23,10 @@ describe('RevisionDropdown component', () => {
...
defaultProps
,
...
defaultProps
,
...
props
,
...
props
,
},
},
stubs
:
{
GlDropdown
,
GlSearchBoxByType
,
},
});
});
};
};
...
@@ -36,6 +40,7 @@ describe('RevisionDropdown component', () => {
...
@@ -36,6 +40,7 @@ describe('RevisionDropdown component', () => {
});
});
const
findGlDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
const
findGlDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
const
findSearchBox
=
()
=>
wrapper
.
find
(
GlSearchBoxByType
);
it
(
'
sets hidden input
'
,
()
=>
{
it
(
'
sets hidden input
'
,
()
=>
{
createComponent
();
createComponent
();
...
@@ -85,6 +90,40 @@ describe('RevisionDropdown component', () => {
...
@@ -85,6 +90,40 @@ describe('RevisionDropdown component', () => {
expect
(
axios
.
get
).
toHaveBeenLastCalledWith
(
newRefsProjectPath
);
expect
(
axios
.
get
).
toHaveBeenLastCalledWith
(
newRefsProjectPath
);
});
});
describe
(
'
search
'
,
()
=>
{
it
(
'
shows flash message on error
'
,
async
()
=>
{
axiosMock
.
onGet
(
'
some/invalid/path
'
).
replyOnce
(
404
);
createComponent
();
await
wrapper
.
vm
.
searchBranchesAndTags
();
expect
(
createFlash
).
toHaveBeenCalled
();
});
it
(
'
makes request with search param
'
,
async
()
=>
{
jest
.
spyOn
(
axios
,
'
get
'
).
mockResolvedValue
({
data
:
{
Branches
:
[],
Tags
:
[],
},
});
const
mockSearchTerm
=
'
foobar
'
;
createComponent
();
findSearchBox
().
vm
.
$emit
(
'
input
'
,
mockSearchTerm
);
await
axios
.
waitForAll
();
expect
(
axios
.
get
).
toHaveBeenCalledWith
(
defaultProps
.
refsProjectPath
,
expect
.
objectContaining
({
params
:
{
search
:
mockSearchTerm
,
},
}),
);
});
});
describe
(
'
GlDropdown component
'
,
()
=>
{
describe
(
'
GlDropdown component
'
,
()
=>
{
it
(
'
renders props
'
,
()
=>
{
it
(
'
renders props
'
,
()
=>
{
createComponent
();
createComponent
();
...
...
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