summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-10-15 13:10:42 +0000
committerSteve Azzopardi <steveazz@outlook.com>2018-10-16 13:43:53 +0200
commitc52bc477dcfc46fe85b39c9b76fb269c200176cd (patch)
tree9f77b89d2cfb74137443f2e8323996ed30f2420e
parenta05d39a2c3c2a928cbed13416c9ffbfe3b545dcc (diff)
downloadgitlab-ce-c52bc477dcfc46fe85b39c9b76fb269c200176cd.tar.gz
Merge branch '52564-personal-projects-pagination-in-profile-overview-tab-is-broken' into 'master'
Resolve "Personal projects pagination in Profile Overview tab is broken" Closes #52564 See merge request gitlab-org/gitlab-ce!22321
-rw-r--r--app/assets/javascripts/pages/users/user_overview_block.js15
-rw-r--r--app/assets/javascripts/pages/users/user_tabs.js29
-rw-r--r--app/controllers/users_controller.rb4
-rw-r--r--app/views/shared/projects/_list.html.haml3
-rw-r--r--changelogs/unreleased/52564-personal-projects-pagination-in-profile-overview-tab-is-broken.yml5
-rw-r--r--spec/features/users/overview_spec.rb31
6 files changed, 72 insertions, 15 deletions
diff --git a/app/assets/javascripts/pages/users/user_overview_block.js b/app/assets/javascripts/pages/users/user_overview_block.js
index 0009419cd0c..2ed177be558 100644
--- a/app/assets/javascripts/pages/users/user_overview_block.js
+++ b/app/assets/javascripts/pages/users/user_overview_block.js
@@ -1,10 +1,15 @@
import axios from '~/lib/utils/axios_utils';
+const DEFAULT_LIMIT = 20;
+
export default class UserOverviewBlock {
constructor(options = {}) {
this.container = options.container;
this.url = options.url;
- this.limit = options.limit || 20;
+ this.requestParams = {
+ limit: DEFAULT_LIMIT,
+ ...options.requestParams,
+ };
this.loadData();
}
@@ -15,9 +20,7 @@ export default class UserOverviewBlock {
axios
.get(this.url, {
- params: {
- limit: this.limit,
- },
+ params: this.requestParams,
})
.then(({ data }) => this.render(data))
.catch(() => loadingEl.classList.add('hide'));
@@ -34,7 +37,9 @@ export default class UserOverviewBlock {
if (count && count > 0) {
document.querySelector(`${this.container} .js-view-all`).classList.remove('hide');
} else {
- document.querySelector(`${this.container} .nothing-here-block`).classList.add('text-left', 'p-0');
+ document
+ .querySelector(`${this.container} .nothing-here-block`)
+ .classList.add('text-left', 'p-0');
}
loadingEl.classList.add('hide');
diff --git a/app/assets/javascripts/pages/users/user_tabs.js b/app/assets/javascripts/pages/users/user_tabs.js
index 23b0348a99f..1de9945baad 100644
--- a/app/assets/javascripts/pages/users/user_tabs.js
+++ b/app/assets/javascripts/pages/users/user_tabs.js
@@ -182,18 +182,22 @@ export default class UserTabs {
this.loadActivityCalendar('overview');
- UserTabs.renderMostRecentBlocks('#js-overview .activities-block', 5);
- UserTabs.renderMostRecentBlocks('#js-overview .projects-block', 10);
+ UserTabs.renderMostRecentBlocks('#js-overview .activities-block', {
+ requestParams: { limit: 5 },
+ });
+ UserTabs.renderMostRecentBlocks('#js-overview .projects-block', {
+ requestParams: { limit: 10, skip_pagination: true },
+ });
this.loaded.overview = true;
}
- static renderMostRecentBlocks(container, limit) {
+ static renderMostRecentBlocks(container, options) {
// eslint-disable-next-line no-new
new UserOverviewBlock({
container,
url: $(`${container} .overview-content-list`).data('href'),
- limit,
+ ...options,
});
}
@@ -216,7 +220,12 @@ export default class UserTabs {
let calendarHint = '';
if (action === 'activity') {
- calendarHint = sprintf(__('Summary of issues, merge requests, push events, and comments (Timezone: %{utcFormatted})'), { utcFormatted });
+ calendarHint = sprintf(
+ __(
+ 'Summary of issues, merge requests, push events, and comments (Timezone: %{utcFormatted})',
+ ),
+ { utcFormatted },
+ );
} else if (action === 'overview') {
calendarHint = __('Issues, merge requests, pushes and comments.');
}
@@ -224,7 +233,15 @@ export default class UserTabs {
$calendarWrap.find('.calendar-hint').text(calendarHint);
// eslint-disable-next-line no-new
- new ActivityCalendar('.tab-pane.active .js-contrib-calendar', '.tab-pane.active .user-calendar-activities', data, calendarActivitiesPath, utcOffset, 0, monthsAgo);
+ new ActivityCalendar(
+ '.tab-pane.active .js-contrib-calendar',
+ '.tab-pane.active .user-calendar-activities',
+ data,
+ calendarActivitiesPath,
+ utcOffset,
+ 0,
+ monthsAgo,
+ );
})
.catch(() => flash(__('There was an error loading users activity calendar.')));
}
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index d16240af404..5b70c69d7f4 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -56,10 +56,12 @@ class UsersController < ApplicationController
def projects
load_projects
+ skip_pagination = Gitlab::Utils.to_boolean(params[:skip_pagination])
+
respond_to do |format|
format.html { render 'show' }
format.json do
- pager_json("shared/projects/_list", @projects.count, projects: @projects)
+ pager_json("shared/projects/_list", @projects.count, projects: @projects, skip_pagination: skip_pagination)
end
end
end
diff --git a/app/views/shared/projects/_list.html.haml b/app/views/shared/projects/_list.html.haml
index e1da05d8f08..06eb3d03e31 100644
--- a/app/views/shared/projects/_list.html.haml
+++ b/app/views/shared/projects/_list.html.haml
@@ -8,6 +8,7 @@
- user = local_assigns[:user]
- show_last_commit_as_description = false unless local_assigns[:show_last_commit_as_description] == true
- remote = false unless local_assigns[:remote] == true
+- skip_pagination = false unless local_assigns[:skip_pagination] == true
.js-projects-list-holder
- if any_projects?(projects)
@@ -25,6 +26,6 @@
= icon('lock fw', base: 'circle', class: 'fa-lg private-fork-icon')
%strong= pluralize(@private_forks_count, 'private fork')
%span &nbsp;you have no access to.
- = paginate_collection(projects, remote: remote)
+ = paginate_collection(projects, remote: remote) unless skip_pagination
- else
.nothing-here-block No projects found
diff --git a/changelogs/unreleased/52564-personal-projects-pagination-in-profile-overview-tab-is-broken.yml b/changelogs/unreleased/52564-personal-projects-pagination-in-profile-overview-tab-is-broken.yml
new file mode 100644
index 00000000000..bddc1e16fab
--- /dev/null
+++ b/changelogs/unreleased/52564-personal-projects-pagination-in-profile-overview-tab-is-broken.yml
@@ -0,0 +1,5 @@
+---
+title: Hide pagination for personal projects on profile overview tab
+merge_request: 22321
+author:
+type: other
diff --git a/spec/features/users/overview_spec.rb b/spec/features/users/overview_spec.rb
index 11f357cbaa5..b0ff53f9ccb 100644
--- a/spec/features/users/overview_spec.rb
+++ b/spec/features/users/overview_spec.rb
@@ -104,8 +104,9 @@ describe 'Overview tab on a user profile', :js do
end
describe 'user has a personal project' do
- let(:private_project) { create(:project, :private, namespace: user.namespace, creator: user) { |p| p.add_maintainer(user) } }
- let!(:private_event) { create(:event, project: private_project, author: user) }
+ before do
+ create(:project, :private, namespace: user.namespace, creator: user) { |p| p.add_maintainer(user) }
+ end
include_context 'visit overview tab'
@@ -119,5 +120,31 @@ describe 'Overview tab on a user profile', :js do
expect(find('#js-overview .projects-block')).to have_selector('.js-view-all', visible: true)
end
end
+
+ describe 'user has more than ten personal projects' do
+ before do
+ create_list(:project, 11, :private, namespace: user.namespace, creator: user) do |project|
+ project.add_maintainer(user)
+ end
+ end
+
+ include_context 'visit overview tab'
+
+ it 'it shows max. ten entries in the list of projects' do
+ page.within('.projects-block') do
+ expect(page).to have_selector('.project-row', count: 10)
+ end
+ end
+
+ it 'shows a link to the project list' do
+ expect(find('#js-overview .projects-block')).to have_selector('.js-view-all', visible: true)
+ end
+
+ it 'does not show pagination' do
+ page.within('.projects-block') do
+ expect(page).not_to have_selector('.gl-pagination')
+ end
+ end
+ end
end
end