From 992d3bffa354a5007a1a3a98348271811e8c5c38 Mon Sep 17 00:00:00 2001 From: aignatov-bio <47317017+aignatov-bio@users.noreply.github.com> Date: Thu, 28 Oct 2021 13:58:31 +0200 Subject: [PATCH] small permissions interface updates [SCI-6145] (#3620) Co-authored-by: Anton --- app/helpers/user_roles_helper.rb | 2 +- .../experiments/modals/_edit_modal.html.erb | 3 -- .../experiments/modals/_show_modal.html.erb | 3 -- .../my_modules/modals/_edit_modal.html.erb | 3 -- .../my_modules/modals/_show_modal.html.erb | 3 -- app/views/canvas/edit/_my_module.html.erb | 19 ++++++----- .../_experiment_actions_dropdown.html.erb | 32 +++++++++---------- 7 files changed, 28 insertions(+), 37 deletions(-) diff --git a/app/helpers/user_roles_helper.rb b/app/helpers/user_roles_helper.rb index 30cacea7a..d0abfd844 100644 --- a/app/helpers/user_roles_helper.rb +++ b/app/helpers/user_roles_helper.rb @@ -3,7 +3,7 @@ module UserRolesHelper def user_roles_collection Rails.cache.fetch([current_user, 'available_user_roles']) do - @user_roles_collection ||= UserRole.all.pluck(:name, :id) + @user_roles_collection ||= UserRole.order(id: :asc).pluck(:name, :id) end end end diff --git a/app/views/access_permissions/experiments/modals/_edit_modal.html.erb b/app/views/access_permissions/experiments/modals/_edit_modal.html.erb index 684082584..5a8f45e92 100644 --- a/app/views/access_permissions/experiments/modals/_edit_modal.html.erb +++ b/app/views/access_permissions/experiments/modals/_edit_modal.html.erb @@ -22,9 +22,6 @@ } %> <% end %> - diff --git a/app/views/access_permissions/experiments/modals/_show_modal.html.erb b/app/views/access_permissions/experiments/modals/_show_modal.html.erb index 52c2bd104..9c0d98391 100644 --- a/app/views/access_permissions/experiments/modals/_show_modal.html.erb +++ b/app/views/access_permissions/experiments/modals/_show_modal.html.erb @@ -13,9 +13,6 @@ <%= render partial: 'access_permissions/partials/user_assignment', locals: { user_assignment: user_assignment, user: user, resource: experiment } %> <% end %> - diff --git a/app/views/access_permissions/my_modules/modals/_edit_modal.html.erb b/app/views/access_permissions/my_modules/modals/_edit_modal.html.erb index a8b4c3272..e70756903 100644 --- a/app/views/access_permissions/my_modules/modals/_edit_modal.html.erb +++ b/app/views/access_permissions/my_modules/modals/_edit_modal.html.erb @@ -23,9 +23,6 @@ } %> <% end %> - diff --git a/app/views/access_permissions/my_modules/modals/_show_modal.html.erb b/app/views/access_permissions/my_modules/modals/_show_modal.html.erb index 67a480174..0ffa28fcc 100644 --- a/app/views/access_permissions/my_modules/modals/_show_modal.html.erb +++ b/app/views/access_permissions/my_modules/modals/_show_modal.html.erb @@ -13,9 +13,6 @@ <%= render partial: 'access_permissions/partials/user_assignment', locals: { user_assignment: user_assignment, user: user, resource: my_module } %> <% end %> - diff --git a/app/views/canvas/edit/_my_module.html.erb b/app/views/canvas/edit/_my_module.html.erb index dc8943428..65ba6a393 100644 --- a/app/views/canvas/edit/_my_module.html.erb +++ b/app/views/canvas/edit/_my_module.html.erb @@ -26,9 +26,6 @@
  • <%= t('experiments.canvas.edit.clone_module') %>
  • -
  • > - <%= t('experiments.canvas.edit.clone_module_group') %> -
  • <% end %> <% if can_manage_my_module?(my_module) %>
  • @@ -40,16 +37,22 @@ can_manage_my_module_users?(my_module) ? edit_access_permissions_project_experiment_my_module_path(my_module.experiment.project, my_module.experiment, my_module) : access_permissions_project_experiment_my_module_path(my_module.experiment.project, my_module.experiment, my_module), data: { action: 'remote-modal'} %>
  • - <% if module_group&.my_modules&.all? { |my_module| can_manage_my_module?(my_module) } %> -
  • - <%= t('experiments.canvas.edit.move_module_group') %> -
  • - <% end %> <% if can_archive_my_module?(my_module) %>
  • <%= t('experiments.canvas.edit.delete_module') %>
  • <% end %> + <% if can_manage_experiment?(my_module.experiment) %> +
  • > + <%= t('experiments.canvas.edit.clone_module_group') %> +
  • + <% end %> + <% if module_group&.my_modules&.all? { |my_module| can_manage_my_module?(my_module) } %> +
  • + <%= t('experiments.canvas.edit.move_module_group') %> +
  • + <% end %> + <% if module_group&.my_modules&.all? { |my_module| can_archive_my_module?(my_module) } %>
  • <%= t('experiments.canvas.edit.delete_module_group') %> diff --git a/app/views/projects/show/_experiment_actions_dropdown.html.erb b/app/views/projects/show/_experiment_actions_dropdown.html.erb index c5768f46a..cf1b02786 100644 --- a/app/views/projects/show/_experiment_actions_dropdown.html.erb +++ b/app/views/projects/show/_experiment_actions_dropdown.html.erb @@ -37,6 +37,22 @@ <% end %>
  • <% end %> + + <% if can_manage_experiment_users?(experiment) %> +
  • + <%= link_to edit_access_permissions_project_experiment_path(project, experiment), data: { action: 'remote-modal'} do %> + + <%= t('experiments.index.experiment_access') %> + <% end %> +
  • + <% else %> +
  • + <%= link_to access_permissions_project_experiment_path(project, experiment), data: { action: 'remote-modal'} do %> + + <%= t('experiments.index.experiment_access') %> + <% end %> +
  • + <% end %> <% if experiment.active? && can_archive_experiment?(experiment) %>
  • @@ -63,22 +79,6 @@ <% end %>
  • <% end %> - - <% if can_manage_experiment_users?(experiment) %> -
  • - <%= link_to edit_access_permissions_project_experiment_path(project, experiment), data: { action: 'remote-modal'} do %> - - <%= t('experiments.index.experiment_access') %> - <% end %> -
  • - <% else %> -
  • - <%= link_to access_permissions_project_experiment_path(project, experiment), data: { action: 'remote-modal'} do %> - - <%= t('experiments.index.experiment_access') %> - <% end %> -
  • - <% end %>