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
38282685
Commit
38282685
authored
Jan 27, 2019
by
Camil Staps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add "Starred projects" tab to user overview
parent
936d4e80
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
3 deletions
+68
-3
app/assets/javascripts/pages/users/user_tabs.js
app/assets/javascripts/pages/users/user_tabs.js
+1
-1
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+24
-1
app/finders/starred_projects_finder.rb
app/finders/starred_projects_finder.rb
+33
-0
app/helpers/users_helper.rb
app/helpers/users_helper.rb
+1
-1
app/views/users/show.html.haml
app/views/users/show.html.haml
+8
-0
config/routes/user.rb
config/routes/user.rb
+1
-0
No files found.
app/assets/javascripts/pages/users/user_tabs.js
View file @
38282685
...
...
@@ -143,7 +143,7 @@ export default class UserTabs {
this
.
loadOverviewTab
();
}
const
loadableActions
=
[
'
groups
'
,
'
contributed
'
,
'
projects
'
,
'
snippets
'
];
const
loadableActions
=
[
'
groups
'
,
'
contributed
'
,
'
projects
'
,
'
s
tarred
'
,
'
s
nippets
'
];
if
(
loadableActions
.
indexOf
(
action
)
>
-
1
)
{
this
.
loadTab
(
action
,
endpoint
);
}
...
...
app/controllers/users_controller.rb
View file @
38282685
...
...
@@ -17,7 +17,7 @@ class UsersController < ApplicationController
prepend_before_action
(
only:
[
:show
])
{
authenticate_sessionless_user!
(
:rss
)
}
before_action
:user
,
except:
[
:exists
]
before_action
:authorize_read_user_profile!
,
only:
[
:calendar
,
:calendar_activities
,
:groups
,
:projects
,
:contributed_projects
,
:snippets
]
only:
[
:calendar
,
:calendar_activities
,
:groups
,
:projects
,
:contributed_projects
,
:s
tarred_projects
,
:s
nippets
]
def
show
respond_to
do
|
format
|
...
...
@@ -82,6 +82,19 @@ class UsersController < ApplicationController
end
end
def
starred
load_starred_projects
respond_to
do
|
format
|
format
.
html
{
render
'show'
}
format
.
json
do
render
json:
{
html:
view_to_html_string
(
"shared/projects/_list"
,
projects:
@starred_projects
)
}
end
end
end
def
snippets
load_snippets
...
...
@@ -120,6 +133,10 @@ class UsersController < ApplicationController
ContributedProjectsFinder
.
new
(
user
).
execute
(
current_user
)
end
def
starred_projects
StarredProjectsFinder
.
new
(
user
).
execute
(
current_user
)
end
def
contributions_calendar
@contributions_calendar
||=
Gitlab
::
ContributionsCalendar
.
new
(
user
,
current_user
)
end
...
...
@@ -145,6 +162,12 @@ class UsersController < ApplicationController
prepare_projects_for_rendering
(
@contributed_projects
)
end
def
load_starred_projects
@starred_projects
=
starred_projects
.
joined
(
user
)
prepare_projects_for_rendering
(
@starred_projects
)
end
def
load_groups
@groups
=
JoinedGroupsFinder
.
new
(
user
).
execute
(
current_user
)
...
...
app/finders/starred_projects_finder.rb
0 → 100644
View file @
38282685
# frozen_string_literal: true
class
StarredProjectsFinder
<
UnionFinder
def
initialize
(
user
)
@user
=
user
end
# Finds the projects "@user" starred, limited to either public projects or
# projects visible to the given user.
#
# current_user - When given the list of the projects is limited to those only
# visible by this user.
#
# Returns an ActiveRecord::Relation.
# rubocop: disable CodeReuse/ActiveRecord
def
execute
(
current_user
=
nil
)
segments
=
all_projects
(
current_user
)
find_union
(
segments
,
Project
).
includes
(
:namespace
).
order_id_desc
end
# rubocop: enable CodeReuse/ActiveRecord
private
def
all_projects
(
current_user
)
projects
=
[]
projects
<<
@user
.
starred_projects
.
visible_to_user
(
current_user
)
if
current_user
projects
<<
@user
.
starred_projects
.
public_to_user
(
current_user
)
projects
end
end
app/helpers/users_helper.rb
View file @
38282685
...
...
@@ -89,7 +89,7 @@ module UsersHelper
tabs
=
[]
if
can?
(
current_user
,
:read_user_profile
,
@user
)
tabs
+=
[
:overview
,
:activity
,
:groups
,
:contributed
,
:projects
,
:snippets
]
tabs
+=
[
:overview
,
:activity
,
:groups
,
:contributed
,
:projects
,
:s
tarred
,
:s
nippets
]
end
tabs
...
...
app/views/users/show.html.haml
View file @
38282685
...
...
@@ -111,6 +111,10 @@
%li
.js-projects-tab
=
link_to
user_projects_path
,
data:
{
target:
'div#projects'
,
action:
'projects'
,
toggle:
'tab'
,
endpoint:
user_projects_path
(
format: :json
)
}
do
=
s_
(
'UserProfile|Personal projects'
)
-
if
profile_tab?
(
:starred
)
%li
.js-starred-tab
=
link_to
user_starred_projects_path
,
data:
{
target:
'div#starred'
,
action:
'starred'
,
toggle:
'tab'
,
endpoint:
user_starred_projects_path
(
format: :json
)
}
do
=
s_
(
'UserProfile|Starred projects'
)
-
if
profile_tab?
(
:snippets
)
%li
.js-snippets-tab
=
link_to
user_snippets_path
,
data:
{
target:
'div#snippets'
,
action:
'snippets'
,
toggle:
'tab'
,
endpoint:
user_snippets_path
(
format: :json
)
}
do
...
...
@@ -142,6 +146,10 @@
#projects
.tab-pane
-# This tab is always loaded via AJAX
-
if
profile_tab?
(
:starred
)
#starred
.tab-pane
-# This tab is always loaded via AJAX
-
if
profile_tab?
(
:snippets
)
#snippets
.tab-pane
-# This tab is always loaded via AJAX
...
...
config/routes/user.rb
View file @
38282685
...
...
@@ -59,6 +59,7 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d
get
:groups
get
:projects
get
:contributed
,
as: :contributed_projects
get
:starred
,
as: :starred_projects
get
:snippets
get
:exists
get
:activity
...
...
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