Project card permission with not assigned team admin [SCI-8727]

This commit is contained in:
Giga Chubinidze 2023-07-07 07:06:43 +04:00
parent 71e5c81f8b
commit e1ab7bda4b
2 changed files with 107 additions and 91 deletions

View file

@ -13,6 +13,7 @@ module Toolbars
@project_folders = current_user.current_team.project_folders.where(id: project_folder_ids)
@items = @projects + @project_folders
@not_assigned = @projects.any? { |project| !project.assigned_users.include?(current_user) }
@single = @items.length == 1
@ -29,6 +30,7 @@ module Toolbars
def actions
return [] if @item_type == :none
return [access_action] if @not_assigned
[
restore_action,

View file

@ -3,98 +3,112 @@
<% project_form = f %>
<%= f.hidden_field :archived, value: !project.archived %>
<% end %>
<% assigned = project.assigned_users.include?(current_user) %>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="projectActionsDropdown">
<!-- Restore project -->
<% if project.archived? && can_restore_project?(project) %>
<li class="form-dropdown-item">
<%= link_to(project_path(project, format: :json) + '?project[archived]=false',
method: :put,
remote: true,
class: 'project-archive-restore-form') do %>
<i class="sn-icon sn-icon-restore"></i>
<span><%= t('projects.index.restore_option') %></span>
<% end %>
</li>
<% end %>
<% if assigned %>
<!-- Edit project -->
<% if project.active? && can_manage_project?(project) %>
<li>
<a href="<%= edit_project_path(project, format: :json) %>"
class="edit-project-btn"
data-action="edit"
data-remote="true">
<i class="sn-icon sn-icon-edit"></i>
<span><%= t('projects.index.edit_option') %></span>
</a>
</li>
<% end %>
<!-- Project members access -->
<li class="form-dropdown-item">
<%= link_to can_manage_project_users?(project) ? edit_access_permissions_project_path(project) : access_permissions_project_path(project),
data: { action: 'remote-modal'} do %>
<i class="sn-icon sn-icon-project-member-access"></i>
<%= I18n.t('projects.index.project_members_access') %>
<% end %>
</li>
<!-- Move project -->
<% if can_manage_team?(project.team) %>
<li class="form-dropdown-item">
<a href="#" data-project-id="<%= project.id %>" data-url="/project_folders/move_to_modal" class="move-projects-btn">
<i class="sn-icon sn-icon-move"></i>
<%= I18n.t('projects.index.move_button') %>
</a>
</li>
<% end %>
<!-- Export project -->
<% if can_export_project?(project) %>
<li class="form-dropdown-item">
<a href="#" data-project-id="<%= project.id %>" data-url="<%= export_projects_modal_team_path(project.team) %>" class="export-projects-btn">
<i class="sn-icon sn-icon-export"></i>
<%= I18n.t('projects.export_projects.export_button') %>
</a>
</li>
<% end %>
<!-- Archive project -->
<% if project.active? && can_archive_project?(project) %>
<li class="form-dropdown-item">
<%= link_to(project_path(project, format: :json) + '?project[archived]=true',
method: :put,
remote: true,
class: 'project-archive-restore-form',
data: { confirm: t('projects.index.archive_confirm') }) do %>
<i class="sn-icon sn-icon-archive"></i>
<span><%= t('projects.index.archive_option') %></span>
<% end %>
</li>
<% end %>
<!-- Show comments -->
<li>
<a href="#"
class="open-comments-sidebar"
data-turbolinks="false"
data-object-type="Project"
data-object-id="<%= project.id %>">
<i class="sn-icon sn-icon-comments"></i>
<span id="comment-count-<%= project.id %>">
<% unseen_comment_count = project.comments.unseen_by(current_user).count %>
<% if unseen_comment_count.positive? %>
<%= t('projects.index.comments_option_with_unread', comments_count: unseen_comment_count) %>
<% else %>
<%= t('projects.index.comments_option') %>
<!-- Restore project -->
<% if project.archived? && can_restore_project?(project) %>
<li class="form-dropdown-item">
<%= link_to(project_path(project, format: :json) + '?project[archived]=false',
method: :put,
remote: true,
class: 'project-archive-restore-form') do %>
<i class="sn-icon sn-icon-restore"></i>
<span><%= t('projects.index.restore_option') %></span>
<% end %>
</span>
</a>
</li>
<!-- Open activities -->
<li>
<a href="/global_activities?<%= Activity.url_search_query({ subjects: { Project: [project] } }) %>">
<i class="sn-icon sn-icon-activities"></i>
<span><%= t('projects.index.activities_option') %></span>
</a>
</li>
</li>
<% end %>
<!-- Edit project -->
<% if project.active? && can_manage_project?(project) %>
<li>
<a href="<%= edit_project_path(project, format: :json) %>"
class="edit-project-btn"
data-action="edit"
data-remote="true">
<i class="sn-icon sn-icon-edit"></i>
<span><%= t('projects.index.edit_option') %></span>
</a>
</li>
<% end %>
<!-- Project members access -->
<li class="form-dropdown-item">
<%= link_to can_manage_project_users?(project) ? edit_access_permissions_project_path(project) : access_permissions_project_path(project),
data: { action: 'remote-modal'} do %>
<i class="sn-icon sn-icon-project-member-access"></i>
<%= I18n.t('projects.index.project_members_access') %>
<% end %>
</li>
<!-- Move project -->
<% if can_manage_team?(project.team) %>
<li class="form-dropdown-item">
<a href="#" data-project-id="<%= project.id %>" data-url="/project_folders/move_to_modal" class="move-projects-btn">
<i class="sn-icon sn-icon-move"></i>
<%= I18n.t('projects.index.move_button') %>
</a>
</li>
<% end %>
<!-- Export project -->
<% if can_export_project?(project) %>
<li class="form-dropdown-item">
<a href="#" data-project-id="<%= project.id %>" data-url="<%= export_projects_modal_team_path(project.team) %>" class="export-projects-btn">
<i class="sn-icon sn-icon-export"></i>
<%= I18n.t('projects.export_projects.export_button') %>
</a>
</li>
<% end %>
<!-- Archive project -->
<% if project.active? && can_archive_project?(project) %>
<li class="form-dropdown-item">
<%= link_to(project_path(project, format: :json) + '?project[archived]=true',
method: :put,
remote: true,
class: 'project-archive-restore-form',
data: { confirm: t('projects.index.archive_confirm') }) do %>
<i class="sn-icon sn-icon-archive"></i>
<span><%= t('projects.index.archive_option') %></span>
<% end %>
</li>
<% end %>
<!-- Show comments -->
<li>
<a href="#"
class="open-comments-sidebar"
data-turbolinks="false"
data-object-type="Project"
data-object-id="<%= project.id %>">
<i class="sn-icon sn-icon-comments"></i>
<span id="comment-count-<%= project.id %>">
<% unseen_comment_count = project.comments.unseen_by(current_user).count %>
<% if unseen_comment_count.positive? %>
<%= t('projects.index.comments_option_with_unread', comments_count: unseen_comment_count) %>
<% else %>
<%= t('projects.index.comments_option') %>
<% end %>
</span>
</a>
</li>
<!-- Open activities -->
<li>
<a href="/global_activities?<%= Activity.url_search_query({ subjects: { Project: [project] } }) %>">
<i class="sn-icon sn-icon-activities"></i>
<span><%= t('projects.index.activities_option') %></span>
</a>
</li>
<% else %>
<!-- Project members access -->
<li class="form-dropdown-item">
<%= link_to can_manage_project_users?(project) ? edit_access_permissions_project_path(project) : access_permissions_project_path(project),
data: { action: 'remote-modal'} do %>
<i class="sn-icon sn-icon-project-member-access"></i>
<%= I18n.t('projects.index.project_members_access') %>
<% end %>
</li>
<% end %>
</ul>