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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -15,7 +15,7 @@
<% unless activity.old_activity? %>
<% if activity.subject_type.present? %>
<%= 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 %>
</div>

View file

@ -1,14 +1,17 @@
<%= 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">
<%= image_tag 'icon_small/experiment.svg' %>
<% if subject %>
<%= link_to experiment_path(subject), title: subject.name do %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% end %>
<% if subject&.navigable? %>
<% path = subject.archived? ? experiment_archive_project_path(subject.project) : canvas_experiment_path(subject) %>
<%= route_to_other_team(path,
team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %>
<span title="<%= breadcrumbs[:experiment] %>">
<%= breadcrumbs[:experiment]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% name = subject&.name || breadcrumbs[:experiment] %>
<span title="<%= name %>">
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
</span>
<% end %>
</div>

View file

@ -1,14 +1,17 @@
<%= 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">
<%= image_tag 'icon_small/task.svg' %>
<% if subject %>
<%= link_to my_module_path(subject), title: subject.name do %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% end %>
<% if subject&.navigable? %>
<% path = subject.archived? ? module_archive_experiment_path(subject.experiment) : protocols_my_module_path(subject) %>
<%= route_to_other_team(path,
team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %>
<span title="<%= breadcrumbs[:my_module] %>">
<%= breadcrumbs[:my_module]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% name = subject&.name || breadcrumbs[:my_module] %>
<span title="<%= name %>">
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
</span>
<% end %>
</div>

View file

@ -1,11 +1,13 @@
<%= 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">
<%= image_tag 'icon_small/project.svg' %>
<% if subject %>
<%= link_to project_path(subject), title: subject.name do %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% end %>
<% path = subject.archived? ? projects_path(team: team) : project_path(subject) %>
<%= route_to_other_team(path,
team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %>
<span title="<%= breadcrumbs[:project] %>">
<%= breadcrumbs[:project]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>

View file

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

View file

@ -1,11 +1,12 @@
<%= 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">
<span class="fas fa-clipboard-check"></span>
<% if subject %>
<%= link_to reports_path(subject), title: subject.name do %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% end %>
<%= route_to_other_team(reports_path(subject),
team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %>
<span title="<%= breadcrumbs[:report] %>">
<%= breadcrumbs[:report]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>

View file

@ -1,11 +1,12 @@
<%= 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">
<span class="fas fa-list-alt"></span>
<% if subject %>
<%= link_to repositories_path(subject), title: subject.name do %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% end %>
<%= route_to_other_team(repositories_path(subject),
team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %>
<span title="<%= breadcrumbs[:repository] %>">
<%= breadcrumbs[:repository]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>

View file

@ -1,15 +1,18 @@
<%= 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">
<span class="<%=result_icon_class(subject)%>"></span>
<% if subject %>
<%= link_to results_my_module_path(subject.my_module), title: subject.name do %>
<%= subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% end %>
<% if subject&.navigable? %>
<% path = subject.archived? ? archive_my_module_path(subject.my_module) : results_my_module_path(subject.my_module) %>
<%= route_to_other_team(path,
team,
subject.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
title: subject.name) %>
<% else %>
<span title="<%= breadcrumbs[:result] %>">
<%= breadcrumbs[:result]&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
<% name = subject&.name || breadcrumbs[:result] %>
<span title="<%= name %>">
<%= name&.truncate(Constants::NAME_TRUNCATION_LENGTH) %>
</span>
<% end %>
</div>