Merge pull request #3200 from urbanrotnik/ur-sci-5525

Add breadcrumbs on Experiments and Tasks pages [SCI-5525]
This commit is contained in:
Urban Rotnik 2021-03-08 14:13:44 +01:00 committed by GitHub
commit e1db291729
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 56 additions and 13 deletions

View file

@ -466,6 +466,13 @@ li.module-hover {
@include font-small;
padding: .75em 0;
}
&.breadcrumbs-in-secondary-navigation {
.projects-breadcrumbs {
margin-left: 3em;
padding-bottom: 0;
}
}
}
.projects-index {

View file

@ -320,6 +320,10 @@ a[data-toggle="tooltip"] {
.open > a:focus {
background-color: $color-white;
}
&.with-breadcrumbs {
padding-top: 0;
}
}
.nav-name {

View file

@ -44,10 +44,20 @@ class ProjectsController < ApplicationController
)
}
else
if current_folder
breadcrumbs_html = render_to_string(partial: 'projects/index/breadcrumbs.html.erb',
locals: { target_folder: current_folder })
projects_cards_url = project_folder_cards_url(current_folder)
title = current_folder.name
else
breadcrumbs_html = ''
projects_cards_url = cards_projects_url
end
render json: {
projects_cards_url: current_folder ? project_folder_cards_url(current_folder) : cards_projects_url,
breadcrumbs_html: current_folder ? render_to_string(partial: 'projects/index/breadcrumbs.html.erb') : '',
title: current_folder ? current_folder&.name : title,
projects_cards_url: projects_cards_url,
breadcrumbs_html: breadcrumbs_html,
title: title,
toolbar_html: render_to_string(partial: 'projects/index/toolbar.html.erb'),
cards_html: render_to_string(
partial: 'projects/index/team_projects.html.erb',

View file

@ -1,7 +1,9 @@
# frozen_string_literal: true
module ProjectsHelper
def projects_view_mode
def projects_view_mode(project: nil)
return (project.archived? ? 'archived' : 'active') if project
return 'archived' if current_folder&.archived?
params[:view_mode] == 'archived' ? 'archived' : 'active'

View file

@ -5,7 +5,7 @@
<%= content_for :sidebar do %>
<%= render partial: 'shared/sidebar/my_modules.html.erb', locals: { experiment: @experiment, my_modules: @active_modules } %>
<% end %>
<%= render partial: "shared/secondary_navigation" %>
<%= render partial: 'shared/secondary_navigation', locals: { render_breadcrumbs: true, project: @experiment.project } %>
<div class="content-pane" id="experiment-canvas">
<div class="row">

View file

@ -5,7 +5,7 @@
<%= content_for :sidebar do %>
<%= render partial: 'shared/sidebar/archived_my_modules.html.erb', locals: { experiment: @experiment, my_modules: @my_modules } %>
<% end %>
<%= render partial: 'shared/secondary_navigation' %>
<%= render partial: 'shared/secondary_navigation', locals: { render_breadcrumbs: true, project: @experiment.project } %>
<div class="content-pane" id="module-archive">
<% if @my_modules.present? %>

View file

@ -14,7 +14,7 @@
<%= render partial: 'shared/sidebar/my_module.html.erb' %>
<% end %>
<%= render partial: 'shared/drag_n_drop_overlay' %>
<%= render partial: "shared/secondary_navigation" %>
<%= render partial: 'shared/secondary_navigation', locals: { render_breadcrumbs: true, project: @experiment.project, experiment: @experiment } %>
<div class="content-pane my-modules-protocols-index" data-task-id="<%= @my_module.id %>">
<!-- Details -->

View file

@ -1,7 +1,10 @@
<% target_folder ||= current_folder %>
<% target_folder ||= nil %>
<% experiment ||= nil %>
<% project ||= nil %>
<div class="projects-breadcrumbs">
<%= link_to(t('projects.index.breadcrumbs_root'),
projects_path(view_mode: projects_view_mode),
projects_path(view_mode: projects_view_mode(project: project)),
class: 'project-folder-link',
data: { projects_cards_url: cards_projects_url,
sidebar_url: sidebar_team_path(current_team) }) %>
@ -16,4 +19,14 @@
) %>
<span>/</span>
<% end %>
<% if project %>
<%= link_to(project.name, project_path(project), class: 'project-folder-link') %>
<span>/</span>
<% end %>
<% if experiment %>
<%= link_to(experiment.name, canvas_experiment_path(experiment), class: 'project-folder-link') %>
<span>/</span>
<% end %>
</div>

View file

@ -1,6 +1,6 @@
<div class="content-header sticky-header">
<div id="breadcrumbsWrapper">
<%= render partial: 'projects/index/breadcrumbs' if current_folder %>
<%= render partial: 'projects/index/breadcrumbs', locals: { target_folder: current_folder } if current_folder %>
</div>
<div class="title-row">
<h1 data-view-mode="active" class="projects-title"><%= current_folder&.name || t('projects.index.head_title') %></h1>

View file

@ -1,6 +1,6 @@
<div class="content-header sticky-header">
<div id="breadcrumbsWrapper">
<%= render partial: 'projects/index/breadcrumbs', locals: { target_folder: @project.project_folder } %>
<%= render partial: 'projects/index/breadcrumbs', locals: { target_folder: @project.project_folder, project: @project } %>
</div>
<div class="title-row">
<h1 class="project-name">

View file

@ -1,7 +1,14 @@
<% render_breadcrumbs ||= nil %>
<% experiment ||= nil %>
<% project ||= nil %>
<% content_for :secondary_navigation do %>
<nav class="navbar navbar-default navbar-secondary">
<div class="container-fluid">
<% if render_breadcrumbs %>
<div id="breadcrumbsWrapper" class="breadcrumbs-in-secondary-navigation">
<%= render partial: 'projects/index/breadcrumbs', locals: {target_folder: project.project_folder, project: project, experiment: experiment} %>
</div>
<% end %>
<div class="navbar-header">
<!-- Small devices dropdown button -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#secondary-menu" aria-expanded="false">
@ -13,7 +20,7 @@
</div>
<!-- buttons -->
<div class="collapse navbar-collapse" id="secondary-menu">
<div class="collapse navbar-collapse <%= render_breadcrumbs ? 'with-breadcrumbs' : '' %>" id="secondary-menu">
<!-- True secondary navigation (buttons on the right side) -->
<ul class="nav navbar-nav navbar-right" style="vertical-align: bottom">