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
47195d3c
Commit
47195d3c
authored
Aug 16, 2021
by
Andrew Smith (EspadaV8)
Committed by
Doug Stull
Aug 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Insert full epic reference in auto-complete selections
parent
21607dbf
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
6 deletions
+77
-6
ee/app/assets/javascripts/vue_shared/components/gfm_autocomplete/utils.js
...vascripts/vue_shared/components/gfm_autocomplete/utils.js
+1
-0
ee/app/controllers/ee/projects/autocomplete_sources_controller.rb
...ontrollers/ee/projects/autocomplete_sources_controller.rb
+10
-1
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+2
-0
ee/app/services/ee/projects/autocomplete_service.rb
ee/app/services/ee/projects/autocomplete_service.rb
+3
-1
ee/spec/controllers/ee/projects/autocomplete_sources_controller_spec.rb
...llers/ee/projects/autocomplete_sources_controller_spec.rb
+8
-4
ee/spec/frontend/vue_shared/components/gfm_autocomplete/utils_spec.js
...tend/vue_shared/components/gfm_autocomplete/utils_spec.js
+14
-0
ee/spec/services/ee/projects/autocomplete_service_spec.rb
ee/spec/services/ee/projects/autocomplete_service_spec.rb
+39
-0
No files found.
ee/app/assets/javascripts/vue_shared/components/gfm_autocomplete/utils.js
View file @
47195d3c
...
...
@@ -21,6 +21,7 @@ export const tributeConfig = {
menuItemLimit
,
menuItemTemplate
:
({
original
})
=>
`<small>
${
original
.
iid
}
</small>
${
escape
(
original
.
title
)}
`
,
selectTemplate
:
({
original
})
=>
original
.
reference
||
`&
${
original
.
iid
}
`
,
},
},
};
ee/app/controllers/ee/projects/autocomplete_sources_controller.rb
View file @
47195d3c
...
...
@@ -13,7 +13,10 @@ module EE
def
epics
return
render_404
unless
project
.
group
.
licensed_feature_available?
(
:epics
)
render
json:
autocomplete_service
.
epics
render
json:
issuable_serializer
.
represent
(
autocomplete_service
.
epics
,
parent_group:
project
.
group
&
.
id
)
end
def
vulnerabilities
...
...
@@ -21,6 +24,12 @@ module EE
render
json:
autocomplete_service
.
vulnerabilities
end
private
def
issuable_serializer
GroupIssuableAutocompleteSerializer
.
new
end
end
end
end
ee/app/models/ee/epic.rb
View file @
47195d3c
...
...
@@ -156,6 +156,8 @@ module EE
public_only
.
or
(
where
(
confidential:
true
,
group_id:
groups
))
end
scope
:with_group_route
,
->
{
preload
([
group: :route
])
}
MAX_HIERARCHY_DEPTH
=
7
def
etag_caching_enabled?
...
...
ee/app/services/ee/projects/autocomplete_service.rb
View file @
47195d3c
...
...
@@ -5,7 +5,9 @@ module EE
def
epics
EpicsFinder
.
new
(
current_user
,
group_id:
project
.
group
&
.
id
,
state:
'opened'
)
.
execute
.
select
([
:iid
,
:title
])
.
execute
.
with_group_route
.
select
(
:iid
,
:title
,
:group_id
)
end
def
vulnerabilities
...
...
ee/spec/controllers/ee/projects/autocomplete_sources_controller_spec.rb
View file @
47195d3c
...
...
@@ -29,15 +29,19 @@ RSpec.describe Projects::AutocompleteSourcesController do
end
describe
'#epics'
do
it
'returns the correct response'
do
it
'returns the correct response'
,
:aggregate_failures
do
epic_json_response
=
{
'iid'
=>
epic
.
iid
,
'title'
=>
epic
.
title
,
'reference'
=>
epic
.
to_reference
(
epic
)
}
get
:epics
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
).
to
be_an
(
Array
)
expect
(
json_response
.
count
).
to
eq
(
1
)
expect
(
json_response
.
first
).
to
include
(
'iid'
=>
epic
.
iid
,
'title'
=>
epic
.
title
)
expect
(
json_response
.
first
).
to
include
(
epic_json_response
)
end
end
end
...
...
ee/spec/frontend/vue_shared/components/gfm_autocomplete/utils_spec.js
View file @
47195d3c
...
...
@@ -12,6 +12,12 @@ describe('ee gfm_autocomplete/utils', () => {
title
:
"
Epic title <script>alert('hi')</script>
"
,
};
const
subgroupEpic
=
{
iid
:
987654
,
reference
:
'
gitlab&987654
'
,
title
:
"
Subgroup context epic title <script>alert('hi')</script>
"
,
};
it
(
'
uses & as the trigger
'
,
()
=>
{
expect
(
epicsConfig
.
trigger
).
toBe
(
'
&
'
);
});
...
...
@@ -31,5 +37,13 @@ describe('ee gfm_autocomplete/utils', () => {
it
(
'
shows the iid and title in the menu item
'
,
()
=>
{
expect
(
epicsConfig
.
menuItemTemplate
({
original
:
epic
})).
toMatchSnapshot
();
});
it
(
'
inserts the iid on autocomplete selection within a top level group context
'
,
()
=>
{
expect
(
epicsConfig
.
selectTemplate
({
original
:
epic
})).
toBe
(
`&
${
epic
.
iid
}
`
);
});
it
(
'
inserts the reference on autocomplete selection within a group context
'
,
()
=>
{
expect
(
epicsConfig
.
selectTemplate
({
original
:
subgroupEpic
})).
toBe
(
subgroupEpic
.
reference
);
});
});
});
ee/spec/services/ee/projects/autocomplete_service_spec.rb
0 → 100644
View file @
47195d3c
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Projects
::
AutocompleteService
do
let_it_be
(
:group
,
refind:
true
)
{
create
(
:group
,
:nested
,
:private
,
avatar:
fixture_file_upload
(
'spec/fixtures/dk.png'
))
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:epic
)
{
create
(
:epic
,
group:
group
,
author:
user
)
}
subject
{
described_class
.
new
(
project
,
user
)
}
before
do
group
.
add_developer
(
user
)
end
describe
'#epics'
do
let
(
:expected_attributes
)
{
[
:iid
,
:title
,
:group_id
,
:group
]
}
before
do
stub_licensed_features
(
epics:
true
)
end
it
'returns nothing if not allowed'
do
guest
=
create
(
:user
)
epics
=
described_class
.
new
(
project
,
guest
).
epics
expect
(
epics
).
to
be_empty
end
it
'returns epics from group'
do
result
=
subject
.
epics
.
map
{
|
epic
|
epic
.
slice
(
expected_attributes
)
}
expect
(
result
).
to
contain_exactly
(
epic
.
slice
(
expected_attributes
))
end
end
end
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