mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 13:13:22 +08:00
Added permissions for deleting and renaming of repositories. [SCI-1269]
This commit is contained in:
parent
9a7048cc7a
commit
5c9a453439
3 changed files with 38 additions and 25 deletions
|
@ -1,6 +1,8 @@
|
|||
class RepositoriesController < ApplicationController
|
||||
before_action :load_vars
|
||||
before_action :check_view_all_permissions, only: :index
|
||||
before_action :check_edit_permissions, only: %(destroy destroy_modal
|
||||
rename_modal update)
|
||||
|
||||
def index
|
||||
render('repositories/index')
|
||||
|
@ -69,6 +71,10 @@ class RepositoriesController < ApplicationController
|
|||
render_403 unless can_view_team_repositories(@team)
|
||||
end
|
||||
|
||||
def check_edit_permissions
|
||||
render_403 unless can_edit_repository(@repository)
|
||||
end
|
||||
|
||||
def repository_params
|
||||
params.require(:repository).permit(:name)
|
||||
end
|
||||
|
|
|
@ -1060,4 +1060,8 @@ module PermissionHelper
|
|||
def can_view_repository(repository)
|
||||
is_normal_user_or_admin_of_team(repository.team)
|
||||
end
|
||||
|
||||
def can_edit_repository(repository)
|
||||
is_admin_of_team(repository.team)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,34 +29,37 @@
|
|||
type="button"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="true">
|
||||
aria-expanded="true"
|
||||
<%= "disabled='disabled'" if !can_edit_repository repo %>>
|
||||
<span class="glyphicon glyphicon-cog"></span>
|
||||
<span class="caret"></span>
|
||||
</div>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<li class="dropdown-header">
|
||||
<%= t("repositories.index.options_dropdown.header") %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('repositories.index.options_dropdown.rename'),
|
||||
team_repository_rename_modal_path(repository_id: repo),
|
||||
class: "rename-repo-option",
|
||||
remote: true %>
|
||||
</li>
|
||||
<li>
|
||||
<!-- TODO -->
|
||||
<a href="#">
|
||||
<%= t("repositories.index.options_dropdown.copy") %>
|
||||
</a>
|
||||
</li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li>
|
||||
<%= link_to t('repositories.index.modal_delete.delete'),
|
||||
team_repository_destroy_modal_path(repository_id: repo),
|
||||
class: "delete-repo-option",
|
||||
remote: true %>
|
||||
</li>
|
||||
</ul>
|
||||
<% if can_edit_repository repo %>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<li class="dropdown-header">
|
||||
<%= t("repositories.index.options_dropdown.header") %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to t('repositories.index.options_dropdown.rename'),
|
||||
team_repository_rename_modal_path(repository_id: repo),
|
||||
class: "rename-repo-option",
|
||||
remote: true %>
|
||||
</li>
|
||||
<li>
|
||||
<!-- TODO -->
|
||||
<a href="#">
|
||||
<%= t("repositories.index.options_dropdown.copy") %>
|
||||
</a>
|
||||
</li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li>
|
||||
<%= link_to t('repositories.index.modal_delete.delete'),
|
||||
team_repository_destroy_modal_path(repository_id: repo),
|
||||
class: "delete-repo-option",
|
||||
remote: true %>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue