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
434b1281
Commit
434b1281
authored
May 25, 2021
by
Jonas Wälter
Committed by
Douglas Barbosa Alexandre
May 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ProjectsFinder: add parameter 'topic' in place of 'tag' [RUN ALL RSPEC]
parent
15448f95
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
17 deletions
+31
-17
app/finders/projects_finder.rb
app/finders/projects_finder.rb
+7
-4
app/views/projects/_home_panel.html.haml
app/views/projects/_home_panel.html.haml
+3
-3
lib/api/helpers.rb
lib/api/helpers.rb
+1
-1
spec/features/projects_spec.rb
spec/features/projects_spec.rb
+7
-7
spec/finders/projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
+13
-2
No files found.
app/finders/projects_finder.rb
View file @
434b1281
...
...
@@ -14,7 +14,8 @@
# starred: boolean
# sort: string
# visibility_level: int
# tags: string[]
# tag: string[] - deprecated, use 'topic' instead
# topic: string[]
# personal: boolean
# search: string
# search_namespaces: boolean
...
...
@@ -37,6 +38,8 @@ class ProjectsFinder < UnionFinder
@params
=
params
@current_user
=
current_user
@project_ids_relation
=
project_ids_relation
@params
[
:topic
]
||=
@params
.
delete
(
:tag
)
if
@params
[
:tag
].
present?
end
def
execute
...
...
@@ -76,7 +79,7 @@ class ProjectsFinder < UnionFinder
collection
=
by_starred
(
collection
)
collection
=
by_trending
(
collection
)
collection
=
by_visibility_level
(
collection
)
collection
=
by_t
ag
s
(
collection
)
collection
=
by_t
opic
s
(
collection
)
collection
=
by_search
(
collection
)
collection
=
by_archived
(
collection
)
collection
=
by_custom_attributes
(
collection
)
...
...
@@ -176,8 +179,8 @@ class ProjectsFinder < UnionFinder
end
# rubocop: enable CodeReuse/ActiveRecord
def
by_t
ag
s
(
items
)
params
[
:t
ag
].
present?
?
items
.
tagged_with
(
params
[
:tag
])
:
items
def
by_t
opic
s
(
items
)
params
[
:t
opic
].
present?
?
items
.
tagged_with
(
params
[
:topic
])
:
items
end
def
by_search
(
items
)
...
...
app/views/projects/_home_panel.html.haml
View file @
434b1281
...
...
@@ -25,14 +25,14 @@
%span
.access-request-links.gl-ml-3
=
render
'shared/members/access_request_links'
,
source:
@project
-
if
@project
.
t
ag
_list
.
present?
=
cache_if
(
cache_enabled
,
[
@project
,
:t
ag
_list
],
expires_in:
1
.
day
)
do
-
if
@project
.
t
opic
_list
.
present?
=
cache_if
(
cache_enabled
,
[
@project
,
:t
opic
_list
],
expires_in:
1
.
day
)
do
%span
.home-panel-topic-list.mt-2.w-100.d-inline-flex.gl-font-base.gl-font-weight-normal.gl-align-items-center
=
sprite_icon
(
'tag'
,
css_class:
'icon gl-relative gl-mr-2'
)
-
@project
.
topics_to_show
.
each
do
|
topic
|
-
project_topics_classes
=
"badge badge-pill badge-secondary gl-mr-2"
-
explore_project_topic_path
=
explore_projects_path
(
t
ag
:
topic
)
-
explore_project_topic_path
=
explore_projects_path
(
t
opic
:
topic
)
-
if
topic
.
length
>
max_project_topic_length
%a
{
class:
"#{ project_topics_classes } str-truncated-30 has-tooltip"
,
data:
{
container:
"body"
},
title:
topic
,
href:
explore_project_topic_path
,
itemprop:
'keywords'
}
=
topic
.
titleize
...
...
lib/api/helpers.rb
View file @
434b1281
...
...
@@ -599,6 +599,7 @@ module API
:custom_attributes
,
:last_activity_after
,
:last_activity_before
,
:topic
,
:repository_storage
)
.
symbolize_keys
.
compact
...
...
@@ -611,7 +612,6 @@ module API
finder_params
[
:user
]
=
params
.
delete
(
:user
)
if
params
[
:user
]
finder_params
[
:id_after
]
=
sanitize_id_param
(
params
[
:id_after
])
if
params
[
:id_after
]
finder_params
[
:id_before
]
=
sanitize_id_param
(
params
[
:id_before
])
if
params
[
:id_before
]
finder_params
[
:tag
]
=
params
[
:topic
]
if
params
[
:topic
].
present?
finder_params
end
...
...
spec/features/projects_spec.rb
View file @
434b1281
...
...
@@ -128,23 +128,23 @@ RSpec.describe 'Project' do
end
it
'shows project topics'
do
project
.
update_attribute
(
:t
ag
_list
,
'topic1'
)
project
.
update_attribute
(
:t
opic
_list
,
'topic1'
)
visit
path
expect
(
page
).
to
have_css
(
'.home-panel-topic-list'
)
expect
(
page
).
to
have_link
(
'Topic1'
,
href:
explore_projects_path
(
t
ag
:
'topic1'
))
expect
(
page
).
to
have_link
(
'Topic1'
,
href:
explore_projects_path
(
t
opic
:
'topic1'
))
end
it
'shows up to 3 project t
ag
s'
do
project
.
update_attribute
(
:t
ag
_list
,
'topic1, topic2, topic3, topic4'
)
it
'shows up to 3 project t
opic
s'
do
project
.
update_attribute
(
:t
opic
_list
,
'topic1, topic2, topic3, topic4'
)
visit
path
expect
(
page
).
to
have_css
(
'.home-panel-topic-list'
)
expect
(
page
).
to
have_link
(
'Topic1'
,
href:
explore_projects_path
(
t
ag
:
'topic1'
))
expect
(
page
).
to
have_link
(
'Topic2'
,
href:
explore_projects_path
(
t
ag
:
'topic2'
))
expect
(
page
).
to
have_link
(
'Topic3'
,
href:
explore_projects_path
(
t
ag
:
'topic3'
))
expect
(
page
).
to
have_link
(
'Topic1'
,
href:
explore_projects_path
(
t
opic
:
'topic1'
))
expect
(
page
).
to
have_link
(
'Topic2'
,
href:
explore_projects_path
(
t
opic
:
'topic2'
))
expect
(
page
).
to
have_link
(
'Topic3'
,
href:
explore_projects_path
(
t
opic
:
'topic3'
))
expect
(
page
).
to
have_content
(
'+ 1 more'
)
end
end
...
...
spec/finders/projects_finder_spec.rb
View file @
434b1281
...
...
@@ -137,9 +137,9 @@ RSpec.describe ProjectsFinder do
end
end
describe
'filter by tags'
do
describe
'filter by tags
(deprecated)
'
do
before
do
public_project
.
t
ag
_list
=
'foo'
public_project
.
t
opic
_list
=
'foo'
public_project
.
save!
end
...
...
@@ -148,6 +148,17 @@ RSpec.describe ProjectsFinder do
it
{
is_expected
.
to
eq
([
public_project
])
}
end
describe
'filter by topics'
do
before
do
public_project
.
topic_list
=
'foo'
public_project
.
save!
end
let
(
:params
)
{
{
topic:
'foo'
}
}
it
{
is_expected
.
to
eq
([
public_project
])
}
end
describe
'filter by personal'
do
let!
(
:personal_project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
let
(
:params
)
{
{
personal:
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