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
447b4c8c
Commit
447b4c8c
authored
Apr 30, 2021
by
Nathan Friend
Committed by
Natalia Tepluhina
Apr 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix tag matching behavior on New Release page
parent
876a10fd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
26 deletions
+68
-26
app/assets/javascripts/releases/components/tag_field_new.vue
app/assets/javascripts/releases/components/tag_field_new.vue
+16
-1
changelogs/unreleased/nfriend-fix-substring-tag-on-release-page.yml
.../unreleased/nfriend-fix-substring-tag-on-release-page.yml
+5
-0
spec/frontend/releases/components/tag_field_new_spec.js
spec/frontend/releases/components/tag_field_new_spec.js
+47
-25
No files found.
app/assets/javascripts/releases/components/tag_field_new.vue
View file @
447b4c8c
...
...
@@ -74,6 +74,21 @@ export default {
// we need to show the "create from" input.
this
.
showCreateFrom
=
true
;
},
shouldShowCreateTagOption
(
isLoading
,
matches
,
query
)
{
// Show the "create tag" option if:
return
(
// we're not currently loading any results, and
!
isLoading
&&
// the search query isn't just whitespace, and
query
.
trim
()
&&
// the `matches` object is non-null, and
matches
&&
// the tag name doesn't already exist
!
matches
.
tags
.
list
.
some
(
(
tagInfo
)
=>
tagInfo
.
name
.
toUpperCase
()
===
query
.
toUpperCase
().
trim
(),
)
);
},
},
translations
:
{
tagName
:
{
...
...
@@ -111,7 +126,7 @@ export default {
>
<template
#footer
="
{ isLoading, matches, query }">
<gl-dropdown-item
v-if=
"
!isLoading && matches && matches.tags.totalCount === 0
"
v-if=
"
shouldShowCreateTagOption(isLoading, matches, query)
"
is-check-item
:is-checked=
"tagName === query"
@
click=
"createTagClicked(query)"
...
...
changelogs/unreleased/nfriend-fix-substring-tag-on-release-page.yml
0 → 100644
View file @
447b4c8c
---
title
:
Fix tag matching behavior on New Release page
merge_request
:
60035
author
:
type
:
fixed
spec/frontend/releases/components/tag_field_new_spec.js
View file @
447b4c8c
...
...
@@ -10,29 +10,35 @@ const TEST_PROJECT_ID = '1234';
const
TEST_CREATE_FROM
=
'
test-create-from
'
;
const
NONEXISTENT_TAG_NAME
=
'
nonexistent-tag
'
;
// A mock version of the RefSelector component that simulates
// a scenario where the users has searched for "nonexistent-tag"
// and the component has found no tags that match.
const
RefSelectorStub
=
Vue
.
component
(
'
RefSelectorStub
'
,
{
data
()
{
return
{
footerSlotProps
:
{
isLoading
:
false
,
matches
:
{
tags
:
{
totalCount
:
0
},
},
query
:
NONEXISTENT_TAG_NAME
,
},
};
},
template
:
'
<div><slot name="footer" v-bind="footerSlotProps"></slot></div>
'
,
});
describe
(
'
releases/components/tag_field_new
'
,
()
=>
{
let
store
;
let
wrapper
;
let
RefSelectorStub
;
const
createComponent
=
(
mountFn
=
shallowMount
,
{
searchQuery
}
=
{
searchQuery
:
NONEXISTENT_TAG_NAME
},
)
=>
{
// A mock version of the RefSelector component that just renders the
// #footer slot, so that the content inside this slot can be tested.
RefSelectorStub
=
Vue
.
component
(
'
RefSelectorStub
'
,
{
data
()
{
return
{
footerSlotProps
:
{
isLoading
:
false
,
matches
:
{
tags
:
{
totalCount
:
1
,
list
:
[{
name
:
TEST_TAG_NAME
}],
},
},
query
:
searchQuery
,
},
};
},
template
:
'
<div><slot name="footer" v-bind="footerSlotProps"></slot></div>
'
,
});
const
createComponent
=
(
mountFn
=
shallowMount
)
=>
{
wrapper
=
mountFn
(
TagFieldNew
,
{
store
,
stubs
:
{
...
...
@@ -84,8 +90,6 @@ describe('releases/components/tag_field_new', () => {
describe
(
'
when the user selects a new tag name
'
,
()
=>
{
beforeEach
(
async
()
=>
{
findCreateNewTagOption
().
vm
.
$emit
(
'
click
'
);
await
wrapper
.
vm
.
$nextTick
();
});
it
(
"
updates the store's release.tagName property
"
,
()
=>
{
...
...
@@ -102,8 +106,6 @@ describe('releases/components/tag_field_new', () => {
beforeEach
(
async
()
=>
{
findTagNameDropdown
().
vm
.
$emit
(
'
input
'
,
updatedTagName
);
await
wrapper
.
vm
.
$nextTick
();
});
it
(
"
updates the store's release.tagName property
"
,
()
=>
{
...
...
@@ -116,6 +118,28 @@ describe('releases/components/tag_field_new', () => {
});
});
describe
(
'
"Create tag" option
'
,
()
=>
{
describe
(
'
when the search query exactly matches one of the search results
'
,
()
=>
{
beforeEach
(
async
()
=>
{
createComponent
(
mount
,
{
searchQuery
:
TEST_TAG_NAME
});
});
it
(
'
does not show the "Create tag" option
'
,
()
=>
{
expect
(
findCreateNewTagOption
().
exists
()).
toBe
(
false
);
});
});
describe
(
'
when the search query does not exactly match one of the search results
'
,
()
=>
{
beforeEach
(
async
()
=>
{
createComponent
(
mount
,
{
searchQuery
:
NONEXISTENT_TAG_NAME
});
});
it
(
'
shows the "Create tag" option
'
,
()
=>
{
expect
(
findCreateNewTagOption
().
exists
()).
toBe
(
true
);
});
});
});
describe
(
'
validation
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
(
mount
);
...
...
@@ -176,8 +200,6 @@ describe('releases/components/tag_field_new', () => {
const
updatedCreateFrom
=
'
update-create-from
'
;
findCreateFromDropdown
().
vm
.
$emit
(
'
input
'
,
updatedCreateFrom
);
await
wrapper
.
vm
.
$nextTick
();
expect
(
store
.
state
.
editNew
.
createFrom
).
toBe
(
updatedCreateFrom
);
});
});
...
...
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