Merge pull request #1607 from okriuchykhin/ok_SCI_3229

Fix links for archived objects in global activities [SCI-3229][SCI-3241]
This commit is contained in:
Alex Kriuchykhin 2019-03-28 17:32:24 +01:00 committed by GitHub
commit 9137740266
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 114 additions and 85 deletions

View file

@ -171,13 +171,11 @@ class ProjectsController < ApplicationController
@project.last_modified_by = current_user @project.last_modified_by = current_user
if !return_error && @project.update(project_params) if !return_error && @project.update(project_params)
# Add activities if needed # Add activities if needed
if message_visibility.present?
log_activity(:change_project_visibility, log_activity(:change_project_visibility, visibility: message_visibility) if message_visibility.present?
visibility: message_visibility) log_activity(:rename_project) if message_renamed.present?
end log_activity(:archive_project) if project_params[:archived] == 'true'
if message_renamed.present? log_activity(:restore_project) if project_params[:archived] == 'false'
log_activity(:rename_project)
end
flash_success = t('projects.update.success_flash', name: @project.name) flash_success = t('projects.update.success_flash', name: @project.name)
if project_params[:archived] == 'true' if project_params[:archived] == 'true'
@ -192,12 +190,10 @@ class ProjectsController < ApplicationController
# The project should be restored # The project should be restored
unless @project.archived unless @project.archived
@project.restore(current_user) @project.restore(current_user)
log_activity(:restore_project)
end end
elsif @project.archived elsif @project.archived
# The project should be archived # The project should be archived
@project.archive(current_user) @project.archive(current_user)
log_activity(:archive_project)
end end
redirect_to projects_path redirect_to projects_path
flash[:success] = flash_success flash[:success] = flash_success

View file

@ -29,38 +29,45 @@ module GlobalActivitiesHelper
return value unless obj return value unless obj
current_value = obj.public_send(getter || 'name') current_value = obj.public_send(getter || 'name')
team = activity.team
path = ''
link = case obj case obj
when User when User
popover_for_user_name(obj, activity.team, false, true) return popover_for_user_name(obj, team, false, true)
when Tag when Tag
# Not link for now # Not link for now
current_value return current_value
when Team when Team
route_to_other_team(projects_path(team: obj), path = projects_path
obj, when Repository
current_value) path = repository_path(obj)
when Project when RepositoryRow
link_to current_value, project_path(obj) path = repository_path(obj.repository)
when Experiment when RepositoryColumn
link_to current_value, canvas_experiment_path(obj) path = repository_path(obj.repository)
when MyModule when Project
link_to current_value, protocols_my_module_path(obj) path = obj.archived? ? projects_path : project_path(obj)
when Protocol when Experiment
if obj.in_repository? return current_value unless obj.navigable?
route_to_other_team protocols_path, obj.team, current_value path = obj.archived? ? experiment_archive_project_path(obj.project) : canvas_experiment_path(obj)
else when MyModule
link_to current_value, protocols_my_module_path(obj.my_module) return current_value unless obj.navigable?
end path = obj.archived? ? module_archive_experiment_path(obj.experiment) : protocols_my_module_path(obj)
when Repository when Protocol
link_to current_value, repository_path(obj) if obj.in_repository?
when RepositoryRow path = protocols_path
link_to current_value, repository_path(obj.repository) elsif obj.my_module.navigable?
when RepositoryColumn path = protocols_my_module_path(obj.my_module)
link_to current_value, repository_path(obj.repository) else
when Result return current_value
link_to current_value, results_my_module_path(obj.my_module) end
end when Result
link return current_value unless obj.navigable?
path = obj.archived? ? archive_my_module_path(obj.my_module) : results_my_module_path(obj.my_module)
else
return current_value
end
route_to_other_team(path, obj, current_value)
end end
end end

View file

@ -87,7 +87,6 @@ class Activity < ApplicationRecord
when Team when Team
breadcrumbs[:team] = subject.name breadcrumbs[:team] = subject.name
end end
save!
end end
def activity_version def activity_version

View file

@ -108,6 +108,10 @@ class Experiment < ApplicationRecord
where(project: Project.viewable_by_user(user, teams)) where(project: Project.viewable_by_user(user, teams))
end end
def navigable?
!project.archived?
end
def active_modules def active_modules
my_modules.where(archived: false) my_modules.where(archived: false)
end end

View file

@ -141,9 +141,13 @@ class MyModule < ApplicationRecord
where(experiment: Experiment.viewable_by_user(user, teams)) where(experiment: Experiment.viewable_by_user(user, teams))
end end
def navigable?
!experiment.archived? && experiment.navigable?
end
# Removes assigned samples from module and connections with other # Removes assigned samples from module and connections with other
# modules. # modules.
def archive (current_user) def archive(current_user)
self.x = 0 self.x = 0
self.y = 0 self.y = 0
# Remove association with module group. # Remove association with module group.

View file

@ -70,6 +70,10 @@ class Result < ApplicationRecord
where(my_module: MyModule.viewable_by_user(user, teams)) where(my_module: MyModule.viewable_by_user(user, teams))
end end
def navigable?
!my_module.archived? && my_module.navigable?
end
def space_taken def space_taken
is_asset ? result_asset.space_taken : 0 is_asset ? result_asset.space_taken : 0
end end

View file

@ -25,8 +25,8 @@ module Activities
def call def call
enrich_message_items enrich_message_items
@activity.save!
@activity.generate_breadcrumbs @activity.generate_breadcrumbs
@activity.save!
self self
end end

View file

@ -15,7 +15,7 @@
<% unless activity.old_activity? %> <% unless activity.old_activity? %>
<% if activity.subject_type.present? %> <% if activity.subject_type.present? %>
<%= render partial: "global_activities/references/#{activity.subject_type.underscore}.html.erb", <%= render partial: "global_activities/references/#{activity.subject_type.underscore}.html.erb",
locals: { subject: activity.subject, breadcrumbs: activity.breadcrumbs } %> locals: { team: activity.team, subject: activity.subject, breadcrumbs: activity.breadcrumbs } %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

View file

@ -1,14 +1,17 @@
<%= render partial: "global_activities/references/project.html.erb", <%= render partial: "global_activities/references/project.html.erb",
locals: { subject: subject&.project, breadcrumbs: breadcrumbs } %> locals: { team: team, subject: subject&.project, breadcrumbs: breadcrumbs } %>
<div class="ga-breadcrumb"> <div class="ga-breadcrumb">
<%= image_tag 'icon_small/experiment.svg' %> <%= image_tag 'icon_small/experiment.svg' %>
<% if subject %> <% if subject&.navigable? %>
<%= link_to experiment_path(subject), title: subject.name do %> <% path = subject.archived? ? experiment_archive_project_path(subject.project) : canvas_experiment_path(subject) %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <%= route_to_other_team(path,
<% end %> team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %> <% else %>
<span title="<%= breadcrumbs[:experiment] %>"> <% name = subject&.name || breadcrumbs[:experiment] %>
<%= breadcrumbs[:experiment]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <span title="<%= name %>">
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
</span> </span>
<% end %> <% end %>
</div> </div>

View file

@ -1,14 +1,17 @@
<%= render partial: "global_activities/references/experiment.html.erb", <%= render partial: "global_activities/references/experiment.html.erb",
locals: { subject: subject&.experiment, breadcrumbs: breadcrumbs } %> locals: { team: team, subject: subject&.experiment, breadcrumbs: breadcrumbs } %>
<div class="ga-breadcrumb"> <div class="ga-breadcrumb">
<%= image_tag 'icon_small/task.svg' %> <%= image_tag 'icon_small/task.svg' %>
<% if subject %> <% if subject&.navigable? %>
<%= link_to my_module_path(subject), title: subject.name do %> <% path = subject.archived? ? module_archive_experiment_path(subject.experiment) : protocols_my_module_path(subject) %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <%= route_to_other_team(path,
<% end %> team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %> <% else %>
<span title="<%= breadcrumbs[:my_module] %>"> <% name = subject&.name || breadcrumbs[:my_module] %>
<%= breadcrumbs[:my_module]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <span title="<%= name %>">
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
</span> </span>
<% end %> <% end %>
</div> </div>

View file

@ -1,11 +1,13 @@
<%= render partial: "global_activities/references/team.html.erb", <%= render partial: "global_activities/references/team.html.erb",
locals: { subject: subject&.team, breadcrumbs: breadcrumbs } %> locals: { team: team, subject: subject&.team, breadcrumbs: breadcrumbs } %>
<div class="ga-breadcrumb"> <div class="ga-breadcrumb">
<%= image_tag 'icon_small/project.svg' %> <%= image_tag 'icon_small/project.svg' %>
<% if subject %> <% if subject %>
<%= link_to project_path(subject), title: subject.name do %> <% path = subject.archived? ? projects_path(team: team) : project_path(subject) %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <%= route_to_other_team(path,
<% end %> team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %> <% else %>
<span title="<%= breadcrumbs[:project] %>"> <span title="<%= breadcrumbs[:project] %>">
<%= breadcrumbs[:project]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <%= breadcrumbs[:project]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>

View file

@ -1,21 +1,23 @@
<% if subject.in_repository? %> <% if subject.in_repository? %>
<%= render partial: "global_activities/references/team.html.erb", <%= render partial: "global_activities/references/team.html.erb",
locals: { subject: subject&.team, breadcrumbs: breadcrumbs } %> locals: { team: team, subject: subject&.team, breadcrumbs: breadcrumbs } %>
<% else %> <% else %>
<%= render partial: "global_activities/references/my_module.html.erb", <%= render partial: "global_activities/references/my_module.html.erb",
locals: { subject: subject&.my_module, breadcrumbs: breadcrumbs } %> locals: { team: team, subject: subject&.my_module, breadcrumbs: breadcrumbs } %>
<% end %> <% end %>
<div class="ga-breadcrumb"> <div class="ga-breadcrumb">
<span class="fas fa-edit"></span> <span class="fas fa-edit"></span>
<% if subject %> <% if subject %>
<% if subject.in_repository? %> <% if subject.in_repository? || subject.my_module.navigable? %>
<%= route_to_other_team protocols_path(team: subject.team), <% path = subject.in_repository? ? protocols_path(team: subject.team) : protocols_my_module_path(subject.my_module) %>
subject.team, <%= route_to_other_team path,
team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH), subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name %> title: subject.name %>
<% else %> <% else %>
<%= link_to subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH), <span title="<%= subject.name %>">
protocols_my_module_path(subject.my_module), title: subject.name %> <%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
</span>
<% end %> <% end %>
<% else %> <% else %>
<span title="<%= breadcrumbs[:protocol] %>"> <span title="<%= breadcrumbs[:protocol] %>">

View file

@ -1,11 +1,12 @@
<%= render partial: "global_activities/references/team.html.erb", <%= render partial: "global_activities/references/team.html.erb",
locals: { subject: subject&.team, breadcrumbs: breadcrumbs } %> locals: { team: team, subject: subject&.team, breadcrumbs: breadcrumbs } %>
<div class="ga-breadcrumb"> <div class="ga-breadcrumb">
<span class="fas fa-clipboard-check"></span> <span class="fas fa-clipboard-check"></span>
<% if subject %> <% if subject %>
<%= link_to reports_path(subject), title: subject.name do %> <%= route_to_other_team(reports_path(subject),
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> team,
<% end %> subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %> <% else %>
<span title="<%= breadcrumbs[:report] %>"> <span title="<%= breadcrumbs[:report] %>">
<%= breadcrumbs[:report]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <%= breadcrumbs[:report]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>

View file

@ -1,11 +1,12 @@
<%= render partial: "global_activities/references/team.html.erb", <%= render partial: "global_activities/references/team.html.erb",
locals: { subject: subject&.team, breadcrumbs: breadcrumbs } %> locals: { team: team, subject: subject&.team, breadcrumbs: breadcrumbs } %>
<div class="ga-breadcrumb"> <div class="ga-breadcrumb">
<span class="fas fa-list-alt"></span> <span class="fas fa-list-alt"></span>
<% if subject %> <% if subject %>
<%= link_to repositories_path(subject), title: subject.name do %> <%= route_to_other_team(repositories_path(subject),
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> team,
<% end %> subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %> <% else %>
<span title="<%= breadcrumbs[:repository] %>"> <span title="<%= breadcrumbs[:repository] %>">
<%= breadcrumbs[:repository]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <%= breadcrumbs[:repository]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>

View file

@ -1,15 +1,18 @@
<%= render partial: "global_activities/references/my_module.html.erb", <%= render partial: "global_activities/references/my_module.html.erb",
locals: { subject: subject&.my_module, breadcrumbs: breadcrumbs } %> locals: { team: team, subject: subject&.my_module, breadcrumbs: breadcrumbs } %>
<div class="ga-breadcrumb"> <div class="ga-breadcrumb">
<span class="<%=result_icon_class(subject)%>"></span> <span class="<%=result_icon_class(subject)%>"></span>
<% if subject %> <% if subject&.navigable? %>
<%= link_to results_my_module_path(subject.my_module), title: subject.name do %> <% path = subject.archived? ? archive_my_module_path(subject.my_module) : results_my_module_path(subject.my_module) %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <%= route_to_other_team(path,
<% end %> team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %> <% else %>
<span title="<%= breadcrumbs[:result] %>"> <% name = subject&.name || breadcrumbs[:result] %>
<%= breadcrumbs[:result]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %> <span title="<%= name %>">
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
</span> </span>
<% end %> <% end %>
</div> </div>