From 086a6a2764448ec33f1f1d634843fd9ded75abf4 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Fri, 11 Oct 2024 12:32:51 -0400 Subject: [PATCH] Make dashboard sidebar render async and adjust dashboard pagination (#21324) * Make dashboard sidebar render async and adjust dashboard pagination * Adjust dashboard system spec to test sidebar * Adjust dashboard system spec to test sidebar * Adjust dashboard * Remove count header needs * Remove test for analytics org rendering * Adjust tests --- app/controllers/dashboards_controller.rb | 11 ++- app/views/dashboards/_actions.html.erb | 34 +++---- app/views/dashboards/_actions_mobile.html.erb | 14 +-- .../dashboards/_header_and_action.html.erb | 91 +++++++++++++++++++ app/views/dashboards/followers.html.erb | 8 +- .../following_organizations.html.erb | 8 +- .../dashboards/following_podcasts.html.erb | 9 +- app/views/dashboards/following_tags.html.erb | 8 +- app/views/dashboards/following_users.html.erb | 9 +- app/views/dashboards/hidden_tags.html.erb | 8 +- app/views/dashboards/show.html.erb | 12 +-- app/views/dashboards/sidebar.html.erb | 5 + config/routes.rb | 1 + spec/requests/dashboard_spec.rb | 14 +-- .../dashboards/user_visits_dashboard_spec.rb | 16 ++-- 15 files changed, 154 insertions(+), 94 deletions(-) create mode 100644 app/views/dashboards/_header_and_action.html.erb create mode 100644 app/views/dashboards/sidebar.html.erb diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index 347054fe5223..b23414e6ba13 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -15,8 +15,11 @@ class DashboardsController < ApplicationController before_action :set_no_cache_header before_action :authenticate_user! + layout false, only: :sidebar + LIMIT_PER_PAGE_DEFAULT = 80 LIMIT_PER_PAGE_MAX = 1000 + ARTICLES_PER_PAGE = 25 def show fetch_and_authorize_user @@ -46,10 +49,16 @@ def show @page_views_count = @articles.sum(&:page_views_count) @articles = @articles.includes(:collection).sorting(params[:sort]).decorate - @articles = Kaminari.paginate_array(@articles).page(params[:page]).per(50) + @articles = Kaminari.paginate_array(@articles).page(params[:page]).per(ARTICLES_PER_PAGE) @collections_count = target.collections.non_empty.count end + def sidebar + @user = current_user + @organizations = @user.admin_organizations + @action = params[:state] + end + def following_tags fetch_and_authorize_user @followed_tags = follows_for_tag(user: @user, order_by: :points) diff --git a/app/views/dashboards/_actions.html.erb b/app/views/dashboards/_actions.html.erb index 3d7cff51b62c..ef25cf10dfe2 100644 --- a/app/views/dashboards/_actions.html.erb +++ b/app/views/dashboards/_actions.html.erb @@ -1,28 +1,28 @@ -