Remove not used code for global activities [SCI-4851] (#5773)

* Fix broken task/activity [SCI-4851]

* Remove unused code for global activities [SCI-4851]
This commit is contained in:
Soufiane 2023-07-17 15:36:22 +02:00 committed by GitHub
parent 3775727857
commit 5736c444f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 13 additions and 122 deletions

View file

@ -1,16 +0,0 @@
'use strict';
(function() {
function initActivitiesButton() {
$('.btn-more-activities')
.on('ajax:success', function(e, data) {
$(data.html).insertAfter($('#list-activities li').last());
if (data.more_url) {
$(this).attr('href', data.more_url);
} else {
$(this).remove();
}
});
}
initActivitiesButton();
}());

View file

@ -1,36 +0,0 @@
class ActivitiesController < ApplicationController
include ActivityHelper
def index
@vars = local_vars
render json: {
more_url: local_vars.fetch(:more_activities_url),
html: render_to_string(
partial: 'list', locals: @vars, formats: :html
)
}
end
private
def local_vars
page = (params[:page] || 1).to_i
activities = current_user.last_activities
.page(page)
.per(Constants::ACTIVITY_AND_NOTIF_SEARCH_LIMIT)
unless activities.blank? || activities.last_page?
more_url = url_for(
activities_url(
format: :json,
page: page + 1,
last_activity: activities.last.id
)
)
end
{
activities: activities,
more_activities_url: more_url,
page: page
}
end
end

View file

@ -131,11 +131,19 @@ class MyModulesController < ApplicationController
@next_page = activities.next_page
@starting_timestamp = activities.first&.created_at.to_i
render json: {
activities_html: render_to_string(partial: 'global_activities/activity_list'),
next_page: @next_page,
starting_timestamp: @starting_timestamp
}
respond_to do |format|
format.json do
render json: {
activities_html: render_to_string(
partial: 'global_activities/activity_list',
formats: :html
),
next_page: @next_page,
starting_timestamp: @starting_timestamp
}
end
format.html
end
end
# Different controller for showing activities inside tab

View file

@ -1,32 +0,0 @@
<li class="activity-item">
<span class="activity-item-date">
<%= l activity.created_at, format: :full %>
</span>
<span class="activity-item-text">
<%= activity_truncate(activity.message) %>
<% if activity.my_module %>
[<%=t 'Project' %>:
<% if activity.my_module.experiment.project.name.length >
Constants::NAME_TRUNCATION_LENGTH %>
<div class="modal-tooltip">
<%= truncate(activity.my_module.experiment.project.name,
lenght: Constants::NAME_TRUNCATION_LENGTH).strip %>
<span class="modal-tooltiptext"><%= activity.my_module.experiment.project.name %></span>
</div>
<% else %>
<%= activity.my_module.experiment.project.name %>
<% end %>, <%=t 'Module' %>:
<% if activity.my_module.name.length >
Constants::NAME_TRUNCATION_LENGTH %>
<div class="modal-tooltip"><%= truncate(
activity.my_module.name,
lenght: Constants::NAME_TRUNCATION_LENGTH) %>
<span class="modal-tooltiptext"><%= activity.my_module.name %></span>
</div>
<% else %>
<%= activity.my_module.name %>
<% end %>
]
<% end %>
</span>
</li>

View file

@ -1,3 +0,0 @@
<% activities.each_with_index do |activity, index| %>
<%= render 'activity', activity: activity %>
<% end %>

View file

@ -1,27 +0,0 @@
<% provide :head_title, t('nav.label.activities') %>
<div class="content-pane">
<div class="container" id="global-activity-page">
<div>
<ul id="list-activities" class="no-style content-activities">
<% if @vars[:activities].blank? %>
<li><em><%= t'activities.index.no_activities' %></em></li>
<% else %>
<% @vars[:activities].each do |activity| %>
<%= render 'activity', activity: activity %>
<% end %>
<% end %>
</ul>
<% if @vars[:more_activities_url].present? && @vars[:page] == 1 %>
<div class="text-center">
<a class="btn btn-secondary btn-more-activities"
href="<%= @vars[:more_activities_url] %>"
data-remote="true">
<%= t'activities.index.more_activities' %></a>
</div>
<% end %>
</div>
</div>
</div>
<%= javascript_include_tag 'activities/index.js' %>

View file

@ -87,7 +87,6 @@ Rails.application.config.assets.precompile += %w(repositories/share_modal.js)
Rails.application.config.assets.precompile += %w(repositories/edit.js)
Rails.application.config.assets.precompile += %w(repositories/stock.js)
Rails.application.config.assets.precompile += %w(repositories/repository_datatable.js)
Rails.application.config.assets.precompile += %w(activities/index.js)
Rails.application.config.assets.precompile += %w(global_activities/index.js)
Rails.application.config.assets.precompile += %w(repositories/show.js)
Rails.application.config.assets.precompile += %w(sidebar_toggle.js)

View file

@ -28,8 +28,6 @@ Rails.application.routes.draw do
end
end
resources :activities, only: [:index]
get '/jobs/:id/status', to: 'active_jobs#status'
get 'forbidden', to: 'application#forbidden', as: 'forbidden'