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
427d935b
Commit
427d935b
authored
Feb 18, 2021
by
Mark Lapierre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '118597-improve-autofill-suggestions-for-usernames' into 'master'"
This reverts merge request !54072
parent
b1b1aa45
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
147 deletions
+50
-147
app/assets/javascripts/gfm_auto_complete.js
app/assets/javascripts/gfm_auto_complete.js
+0
-34
changelogs/unreleased/118597-improve-autofill-suggestions-for-usernames.yml
...sed/118597-improve-autofill-suggestions-for-usernames.yml
+0
-5
spec/features/issues/gfm_autocomplete_spec.rb
spec/features/issues/gfm_autocomplete_spec.rb
+6
-24
spec/frontend/gfm_auto_complete_spec.js
spec/frontend/gfm_auto_complete_spec.js
+44
-84
No files found.
app/assets/javascripts/gfm_auto_complete.js
View file @
427d935b
...
@@ -266,7 +266,6 @@ class GfmAutoComplete {
...
@@ -266,7 +266,6 @@ class GfmAutoComplete {
},
},
// eslint-disable-next-line no-template-curly-in-string
// eslint-disable-next-line no-template-curly-in-string
insertTpl
:
'
${atwho-at}${username}
'
,
insertTpl
:
'
${atwho-at}${username}
'
,
limit
:
10
,
searchKey
:
'
search
'
,
searchKey
:
'
search
'
,
alwaysHighlightFirst
:
true
,
alwaysHighlightFirst
:
true
,
skipSpecialCharacterTest
:
true
,
skipSpecialCharacterTest
:
true
,
...
@@ -312,31 +311,6 @@ class GfmAutoComplete {
...
@@ -312,31 +311,6 @@ class GfmAutoComplete {
return
data
;
return
data
;
},
},
sorter
(
query
,
items
)
{
if
(
!
query
)
{
return
items
;
}
const
lowercaseQuery
=
query
.
toLowerCase
();
const
members
=
items
.
slice
();
const
{
nameOrUsernameStartsWith
,
nameOrUsernameIncludes
}
=
GfmAutoComplete
.
Members
;
return
members
.
sort
((
a
,
b
)
=>
{
if
(
nameOrUsernameStartsWith
(
a
,
lowercaseQuery
))
{
return
-
1
;
}
if
(
nameOrUsernameStartsWith
(
b
,
lowercaseQuery
))
{
return
1
;
}
if
(
nameOrUsernameIncludes
(
a
,
lowercaseQuery
))
{
return
-
1
;
}
if
(
nameOrUsernameIncludes
(
b
,
lowercaseQuery
))
{
return
1
;
}
return
0
;
});
},
},
},
});
});
}
}
...
@@ -798,14 +772,6 @@ GfmAutoComplete.Members = {
...
@@ -798,14 +772,6 @@ GfmAutoComplete.Members = {
title
,
title
,
)}${
availabilityStatus
}
</small>
${
icon
}
</li>`
;
)}${
availabilityStatus
}
</small>
${
icon
}
</li>`
;
},
},
nameOrUsernameStartsWith
(
member
,
query
)
{
// `member.search` is a name:username string like `MargeSimpson msimpson`
return
member
.
search
.
split
(
'
'
).
some
((
name
)
=>
name
.
toLowerCase
().
startsWith
(
query
));
},
nameOrUsernameIncludes
(
member
,
query
)
{
// `member.search` is a name:username string like `MargeSimpson msimpson`
return
member
.
search
.
toLowerCase
().
includes
(
query
);
},
};
};
GfmAutoComplete
.
Labels
=
{
GfmAutoComplete
.
Labels
=
{
templateFunction
(
color
,
title
)
{
templateFunction
(
color
,
title
)
{
...
...
changelogs/unreleased/118597-improve-autofill-suggestions-for-usernames.yml
deleted
100644 → 0
View file @
b1b1aa45
---
title
:
Improve at.js members autocomplete matching
merge_request
:
54072
author
:
type
:
changed
spec/features/issues/gfm_autocomplete_spec.rb
View file @
427d935b
...
@@ -6,7 +6,6 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -6,7 +6,6 @@ RSpec.describe 'GFM autocomplete', :js do
let_it_be
(
:user_xss_title
)
{
'eve <img src=x onerror=alert(2)<img src=x onerror=alert(1)>'
}
let_it_be
(
:user_xss_title
)
{
'eve <img src=x onerror=alert(2)<img src=x onerror=alert(1)>'
}
let_it_be
(
:user_xss
)
{
create
(
:user
,
name:
user_xss_title
,
username:
'xss.user'
)
}
let_it_be
(
:user_xss
)
{
create
(
:user
,
name:
user_xss_title
,
username:
'xss.user'
)
}
let_it_be
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let_it_be
(
:user
)
{
create
(
:user
,
name:
'💃speciąl someone💃'
,
username:
'someone.special'
)
}
let_it_be
(
:user2
)
{
create
(
:user
,
name:
'Marge Simpson'
,
username:
'msimpson'
)
}
let_it_be
(
:group
)
{
create
(
:group
,
name:
'Ancestor'
)
}
let_it_be
(
:group
)
{
create
(
:group
,
name:
'Ancestor'
)
}
let_it_be
(
:child_group
)
{
create
(
:group
,
parent:
group
,
name:
'My group'
)
}
let_it_be
(
:child_group
)
{
create
(
:group
,
parent:
group
,
name:
'My group'
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
child_group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
child_group
)
}
...
@@ -17,7 +16,6 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -17,7 +16,6 @@ RSpec.describe 'GFM autocomplete', :js do
before_all
do
before_all
do
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user
)
project
.
add_maintainer
(
user_xss
)
project
.
add_maintainer
(
user_xss
)
project
.
add_maintainer
(
user2
)
end
end
describe
'when tribute_autocomplete feature flag is off'
do
describe
'when tribute_autocomplete feature flag is off'
do
...
@@ -88,7 +86,11 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -88,7 +86,11 @@ RSpec.describe 'GFM autocomplete', :js do
wait_for_requests
wait_for_requests
expect
(
find_highlighted_autocomplete_item
).
to
have_content
(
user_xss
.
username
)
expect
(
page
).
to
have_selector
(
'.atwho-container'
)
page
.
within
'.atwho-container #at-view-users'
do
expect
(
find
(
'li'
).
text
).
to
have_content
(
user_xss
.
username
)
end
end
end
it
'opens autocomplete menu for Milestone when field starts with text with item escaping HTML characters'
do
it
'opens autocomplete menu for Milestone when field starts with text with item escaping HTML characters'
do
...
@@ -188,23 +190,7 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -188,23 +190,7 @@ RSpec.describe 'GFM autocomplete', :js do
wait_for_requests
wait_for_requests
expect
(
find_highlighted_autocomplete_item
).
to
have_content
(
user
.
name
)
expect
(
find
(
'.atwho-view li'
,
visible:
true
)).
to
have_content
(
user
.
name
)
end
it
'shows names that start with the query as the top result'
do
type
(
find
(
'#note-body'
),
'@mar'
)
wait_for_requests
expect
(
find_highlighted_autocomplete_item
).
to
have_content
(
user2
.
name
)
end
it
'shows usernames that start with the query as the top result'
do
type
(
find
(
'#note-body'
),
'@msi'
)
wait_for_requests
expect
(
find_highlighted_autocomplete_item
).
to
have_content
(
user2
.
name
)
end
end
it
'selects the first item for non-assignee dropdowns if a query is entered'
do
it
'selects the first item for non-assignee dropdowns if a query is entered'
do
...
@@ -1018,8 +1004,4 @@ RSpec.describe 'GFM autocomplete', :js do
...
@@ -1018,8 +1004,4 @@ RSpec.describe 'GFM autocomplete', :js do
wait_for_requests
wait_for_requests
end
end
def
find_highlighted_autocomplete_item
find
(
'.atwho-view li.cur'
,
visible:
true
)
end
end
end
spec/frontend/gfm_auto_complete_spec.js
View file @
427d935b
...
@@ -576,14 +576,7 @@ describe('GfmAutoComplete', () => {
...
@@ -576,14 +576,7 @@ describe('GfmAutoComplete', () => {
});
});
});
});
describe
(
'
GfmAutoComplete.Members
'
,
()
=>
{
describe
(
'
Members.templateFunction
'
,
()
=>
{
const
member
=
{
name
:
'
Marge Simpson
'
,
username
:
'
msimpson
'
,
search
:
'
MargeSimpson msimpson
'
,
};
describe
(
'
templateFunction
'
,
()
=>
{
it
(
'
should return html with avatarTag and username
'
,
()
=>
{
it
(
'
should return html with avatarTag and username
'
,
()
=>
{
expect
(
expect
(
GfmAutoComplete
.
Members
.
templateFunction
({
GfmAutoComplete
.
Members
.
templateFunction
({
...
@@ -635,39 +628,6 @@ describe('GfmAutoComplete', () => {
...
@@ -635,39 +628,6 @@ describe('GfmAutoComplete', () => {
});
});
});
});
describe
(
'
nameOrUsernameStartsWith
'
,
()
=>
{
it
.
each
`
query | result
${
'
mar
'
}
|
${
true
}
${
'
msi
'
}
|
${
true
}
${
'
margesimpson
'
}
|
${
true
}
${
'
msimpson
'
}
|
${
true
}
${
'
arge
'
}
|
${
false
}
${
'
rgesimp
'
}
|
${
false
}
${
'
maria
'
}
|
${
false
}
${
'
homer
'
}
|
${
false
}
`
(
'
returns $result for $query
'
,
({
query
,
result
})
=>
{
expect
(
GfmAutoComplete
.
Members
.
nameOrUsernameStartsWith
(
member
,
query
)).
toBe
(
result
);
});
});
describe
(
'
nameOrUsernameIncludes
'
,
()
=>
{
it
.
each
`
query | result
${
'
mar
'
}
|
${
true
}
${
'
msi
'
}
|
${
true
}
${
'
margesimpson
'
}
|
${
true
}
${
'
msimpson
'
}
|
${
true
}
${
'
arge
'
}
|
${
true
}
${
'
rgesimp
'
}
|
${
true
}
${
'
maria
'
}
|
${
false
}
${
'
homer
'
}
|
${
false
}
`
(
'
returns $result for $query
'
,
({
query
,
result
})
=>
{
expect
(
GfmAutoComplete
.
Members
.
nameOrUsernameIncludes
(
member
,
query
)).
toBe
(
result
);
});
});
});
describe
(
'
labels
'
,
()
=>
{
describe
(
'
labels
'
,
()
=>
{
const
dataSources
=
{
const
dataSources
=
{
labels
:
`
${
TEST_HOST
}
/autocomplete_sources/labels`
,
labels
:
`
${
TEST_HOST
}
/autocomplete_sources/labels`
,
...
...
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