small code fixes

This commit is contained in:
Mojca Lorber 2017-06-02 15:39:10 +02:00
parent 13bf4ad229
commit da98788031
4 changed files with 11 additions and 14 deletions

View file

@ -11,7 +11,7 @@ function init() {
}
function initCreateNewModal() {
var link = $("[data-action='create-new-repository']");
var link = $("#create-new-repository");
var modal = $("#create-new-modal");
var submitBtn = modal.find(".modal-footer [data-action='submit']");
@ -25,13 +25,13 @@ function initCreateNewModal() {
modalBody.html(data.html);
modalBody.find("form")
.on("ajax:success", function(ev2, data2, status2) {
.on("ajax:success", function(ev, data, status) {
// Redirect to index page
$(location).attr("href", data2.url);
$(location).attr("href", data.url);
})
.on("ajax:error", function(ev2, data2, status2) {
.on("ajax:error", function(ev, data, status) {
// Display errors if needed
$(this).renderFormErrors("repository", data2.responseJSON);
$(this).renderFormErrors("repository", data.responseJSON);
});
modal.modal("show");

View file

@ -115,8 +115,7 @@ class RepositoriesController < ApplicationController
end
def check_create_permissions
render_403 unless can_create_new_repository(@team) &&
@repositories.count < Constants::REPOSITORIES_LIMIT
render_403 unless can_create_new_repository(@team)
end
def check_edit_and_destroy_permissions

View file

@ -1054,7 +1054,7 @@ module PermissionHelper
end
def can_create_new_repository(team)
is_admin_of_team(team)
is_admin_of_team(team) && team.repositories.count < Constants::REPOSITORIES_LIMIT
end
def can_view_repositories(team)

View file

@ -3,6 +3,7 @@
<% if current_team %>
<%= render partial: "repositories/breadcrumbs.html.erb",
locals: { teams: @teams, current_team: current_team, type: @type } %>
<%= render partial: "repositories/index/create_new_modal.html.erb" %>
<% active_repo = @repositories.find_by_id(params[:repository]) %>
<% active_repo = @repositories.first if !active_repo %>
@ -19,15 +20,13 @@
<% end %>
<!-- Add new repository tab -->
<li role="presentation"
<% unless can_create_new_repository(current_team) &&
@repositories.count < Constants::REPOSITORIES_LIMIT %>
<% unless can_create_new_repository(current_team) %>
class="disabled"
<% end %>>
<a href='#'
data-url="<%= create_new_modal_team_repositories_path %>"
<% if can_create_new_repository(current_team) &&
@repositories.count < Constants::REPOSITORIES_LIMIT %>
data-action='create-new-repository'
<% if can_create_new_repository(current_team) %>
id='create-new-repository'
<% end %>>
<span class="glyphicon glyphicon-plus"></span>
<span class="hidden-xs">&nbsp;<%= t('repositories.index.add_new_repository_tab') %></span>
@ -88,4 +87,3 @@
<% end %>
<%= javascript_include_tag "repositories/index", "data-turbolinks-track" => true %>
<%= render partial: "repositories/index/create_new_modal.html.erb" %>