jbox-web/redmine_git_hosting

View on GitHub
app/views/repository_protected_branches/index.html.slim

Summary

Maintainability
Test Coverage
div
  - if User.current.git_allowed_to? :create_repository_protected_branches, @repository
    .contextual
      = link_to l(:label_protected_branch_add),
                new_repository_protected_branch_path(@repository),
                remote: true, class: 'icon icon-add'

  h3
    = l :label_protected_branches
    '
    = link_to_external "(#{l :label_gitolite_documentation})",
                       'https://gitolite.com/gitolite/conf.html#rules'

  - if @repository_protected_branches.any?
    table#protected_branches.list[
      data-update-url="#{sort_repository_protected_branches_url}"
      style="opacity: #{@repository.protected_branches_enabled? ? '1' : '0.5'}"]
      thead
        tr
          th
          th = l :label_permissions
          th = l :label_branch_path
          th = l :label_user_list
          th

      tbody
        - @repository_protected_branches.each do |protected_branch|
          tr.protected_branch id="protected_branch_#{protected_branch.id}"
            td
              span.handle
                | [drag]
            td
              - color = protected_branch.permissions == '-' ? 'error' : 'success'
              span.label class="label-#{color}"
                = protected_branch.permissions

            td style='font-family: Consolas;'
              = protected_branch.path

            td
              - cnt = 0
              - protected_branch.users.each do |user|
                - if cnt.positive?
                  ' ,
                = link_to_user user
                - cnt += 1

            td.buttons
              - if User.current.git_allowed_to? :edit_repository_protected_branches, @repository
                = link_to l(:button_edit),
                          edit_repository_protected_branch_path(@repository, protected_branch),
                          remote: true,
                          class: 'icon icon-edit'
                = link_to l(:button_clone),
                          clone_repository_protected_branch_path(@repository, protected_branch),
                          remote: true,
                          class: 'icon icon-copy'
                = link_to l(:button_delete),
                          repository_protected_branch_path(@repository, protected_branch),
                          remote: true,
                          method: :delete,
                          data: { confirm: l(:text_are_you_sure) },
                          class: 'icon icon-del'

    - unless @repository.protected_branches_enabled?
      em = l :protected_branches_reminder

  - else
    p.nodata = l :label_no_data

javascript:
  $(document).ready(function() { setSortableElement('#protected_branches tbody', '#protected_branches'); });