fix error if user is not assigned to any teams

This commit is contained in:
mlorb 2018-05-25 17:14:22 +02:00
parent 815616aac1
commit f02363dfce
5 changed files with 105 additions and 130 deletions

View file

@ -41,9 +41,18 @@
locals: { flash: flash, notice: notice, alert: alert } %>
<% end %>
<%= render "shared/left_menu_bar" if user_signed_in? %>
<%= render "shared/left_menu_bar" if user_signed_in? && current_user.teams.length > 0 %>
<div id="content-wrapper">
<%= yield :content %>
<% if current_user.teams.length == 0 %>
<!-- If member of no teams -->
<div class="jumbotron">
<h2><%=t 'general.no_teams.title' %></h2>
<p data-hook="general-no-teams-text"><%=t 'general.no_teams.text' %></p>
</div>
<% else %>
<%= yield :content %>
<% end %>
</div>
<script>

View file

@ -1,116 +1,106 @@
<% provide(:head_title, t("projects.index.head_title")) %>
<%= render partial: "shared/sidebar" %>
<%= render partial: "shared/secondary_navigation" %>
<div class="content-pane" id="projects-index">
<% if can_create_projects?(current_team) %>
<!-- New project modal -->
<div class="modal" id="new-project-modal" tabindex="-1" role="dialog" aria-labelledby="new-project-modal-label">
<%= bootstrap_form_for @project, remote: true do |f| %>
<% if current_team %>
<%= render partial: "shared/sidebar" %>
<%= render partial: "shared/secondary_navigation" %>
<div class="content-pane" id="projects-index">
<% if can_create_projects?(current_team) %>
<!-- New project modal -->
<div class="modal" id="new-project-modal" tabindex="-1" role="dialog" aria-labelledby="new-project-modal-label">
<%= bootstrap_form_for @project, remote: true do |f| %>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="new-project-modal-label"><%= t("projects.index.modal_new_project.modal_title") %></h4>
</div>
<div class="modal-body">
<%= render partial: "new.html.erb", locals: { form: f, teams: @teams } %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
<%= f.submit t("projects.index.modal_new_project.create"), class: "btn btn-success" %>
</div>
</div>
</div>
<% end %>
</div>
<% end %>
<!-- Edit project modal -->
<div class="modal" id="edit-project-modal" tabindex="-1" role="dialog" aria-labelledby="edit-project-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="new-project-modal-label"><%= t("projects.index.modal_new_project.modal_title") %></h4>
<h4 class="modal-title" id="edit-project-modal-label"></h4>
</div>
<div class="modal-body">
<%= render partial: "new.html.erb", locals: { form: f, teams: @teams } %>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
<%= f.submit t("projects.index.modal_new_project.create"), class: "btn btn-success" %>
<button type="button" class="btn btn-success" data-action="submit"><%=t "projects.index.modal_edit_project.submit" %></button>
</div>
</div>
</div>
</div>
<!-- Manage users modal -->
<div class="modal" id="manage-users-modal" tabindex="-1" role="dialog" aria-labelledby="manage-users-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="manage-users-modal-label"><%= t("projects.index.modal_manage_users.modal_title") %> <span id="manage-users-modal-project"></span></h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<div id="projects-toolbar">
<form class="form-inline" action="<%= projects_path %>">
<div class="form-group">
<% if @teams.length > 0 && can_create_projects?(current_team) %>
<!-- new project button -->
<a class="btn btn-primary pull-right" id="new-project-btn">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
<span class="hidden-xs"><%=t "projects.index.new" %></span>
</a>
<% end %>
<!-- project sort -->
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="sortMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="hidden-xs"><%= t'projects.index.sort' %></span>
<span class="visible-xs-inline"><i class="glyphicon glyphicon-sort"></i></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="sortMenu">
<% ["new", "old", "atoz", "ztoa"].each do |sort| %>
<% if @current_sort != sort %>
<li><a href="?<%= {team: @current_team_id, sort: sort}.reject{|k,v| v.to_s == "0"}.to_query %>"><%= t('projects.index.sort_' + sort) %></a></li>
<% else %>
<li class="disabled"><a href="#"><%= t('projects.index.sort_' + sort) %></a></li>
<% end %>
<% end %>
</ul>
</div>
</div>
</form>
</div>
<% @projects_by_teams.each do |team, projects| %>
<%= render partial: "projects/index/team_projects",
locals: {team: team, projects: projects} %>
<% end %>
</div>
<% end %>
<!-- Edit project modal -->
<div class="modal" id="edit-project-modal" tabindex="-1" role="dialog" aria-labelledby="edit-project-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="edit-project-modal-label"></h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
<button type="button" class="btn btn-success" data-action="submit"><%=t "projects.index.modal_edit_project.submit" %></button>
</div>
</div>
</div>
</div>
<!-- Manage users modal -->
<div class="modal" id="manage-users-modal" tabindex="-1" role="dialog" aria-labelledby="manage-users-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="manage-users-modal-label"><%= t("projects.index.modal_manage_users.modal_title") %> <span id="manage-users-modal-project"></span></h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<div id="projects-toolbar">
<form class="form-inline" action="<%= projects_path %>">
<div class="form-group">
<% if @teams.length > 0 && can_create_projects?(current_team) %>
<!-- new project button -->
<a class="btn btn-primary pull-right" id="new-project-btn">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
<span class="hidden-xs"><%=t "projects.index.new" %></span>
</a>
<% end %>
<!-- project sort -->
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="sortMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="hidden-xs"><%= t'projects.index.sort' %></span>
<span class="visible-xs-inline"><i class="glyphicon glyphicon-sort"></i></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="sortMenu">
<% ["new", "old", "atoz", "ztoa"].each do |sort| %>
<% if @current_sort != sort %>
<li><a href="?<%= {team: @current_team_id, sort: sort}.reject{|k,v| v.to_s == "0"}.to_query %>"><%= t('projects.index.sort_' + sort) %></a></li>
<% else %>
<li class="disabled"><a href="#"><%= t('projects.index.sort_' + sort) %></a></li>
<% end %>
<% end %>
</ul>
</div>
</div>
</form>
</div>
<% if @teams.length == 0 %>
<!-- Show link to team management if member of
no teams -->
<div class="jumbotron">
<h2><%=t 'projects.index.no_teams.title' %></h2>
<p><%=t 'projects.index.no_teams.text' %></p>
<p data-hook="projects-manage-teams-button">
<%= link_to t('projects.index.no_teams.btn'), teams_path, class: 'btn btn-primary' %>
</p>
</div>
<% else %>
<% @projects_by_teams.each do |team, projects| %>
<%= render partial: "projects/index/team_projects",
locals: {team: team, projects: projects} %>
<% end %>
<% end %>
</div>
<%= javascript_include_tag "projects/index", "data-turbolinks-track" => true %>

View file

@ -1,7 +1,7 @@
<% provide(:head_title, t("protocols.index.head_title")) %>
<div class="content-pane" id="protocols-index">
<% if current_team %>
<% if current_team %>
<div class="content-pane" id="protocols-index">
<ul class="nav nav-tabs nav-settings">
<li role="presentation" class="<%= "active" if @type == :public %>">
<%= link_to t("protocols.index.navigation.public"), protocols_path(team: @current_team, type: :public) %>
@ -125,18 +125,8 @@
</div>
</div>
</div>
<% else %>
<!-- Show link to team management if member of
no teams -->
<div class="jumbotron">
<h2><%=t 'protocols.index.no_teams.title' %></h2>
<p><%=t 'protocols.index.no_teams.text' %></p>
<p data-hook="protocols-manage-teams-button">
<%= link_to t('protocols.index.no_teams.btn'), teams_path, class: 'btn btn-primary' %>
</p>
</div>
<% end %>
</div>
</div>
<% end %>
<div id="protocolsio-preview-modal-target"></div>
<%= render partial: "protocols/import_export/import_json_protocol_modal.html.erb" %>

View file

@ -25,12 +25,6 @@
<% end %>
</div>
</div>
<% else %>
<!-- If member of no teams -->
<div class="jumbotron">
<h2><%=t 'repositories.index.no_teams.title' %></h2>
<p><%=t 'repositories.index.no_teams.text' %></p>
</div>
<% end %>
<%= javascript_include_tag "repositories/index", "data-turbolinks-track" => true %>

View file

@ -266,10 +266,6 @@ en:
invite_users_link: "Invite users"
invite_users_details: "to team %{team}."
contact_admins: "To invite additional users to team %{team}, contact its administrator/s."
no_teams:
title: "Your dashboard is empty!"
text: "It seems you're not a member of any team. See team management to sort it out."
btn: "Manage Teams"
create:
success_flash: "Project <strong>%{name}</strong> successfully created."
name_taken: "This project name has to be unique inside a team (this includes the archive)."
@ -916,9 +912,6 @@ en:
delete_flash: "\"%{name}\" inventory was successfully deleted!"
rename_flash: "\"%{old_name}\" inventory was successfully renamed to \"%{new_name}\"!"
copy_flash: "\"%{new}\" inventory was successfully copied from \"%{old}\"!"
no_teams:
title: "Your dashboard is empty!"
text: "It seems you're not a member of any team. See team management to sort it out."
visibility: "Visibility"
advanced: "Advanced"
options_dropdown:
@ -1626,10 +1619,6 @@ en:
archive:
description: "Archived protocols can only be seen by you. Restoring protocols will return them to their previous location (team/my protocols)."
restore: "Restore"
no_teams:
title: "Your dashboard is empty!"
text: "It seems you're not a member of any team. See team management to sort it out."
btn: "Manage Teams"
make_private_unauthorized: "You do not have permission to move selected protocols to My protocols."
make_private_error: "Error occured while moving selected protocols to My protocols."
publish_unauthorized: "You do not have permission to move selected protocols to Team protocols."
@ -1928,6 +1917,9 @@ en:
no_name: "(no name)"
error: "An error has occurred, please try again later."
filter: "Filter:"
no_teams:
title: "Your dashboard is empty!"
text: "It seems you're not a member of any team."
api:
core: