Merge branch 'master' into refactor-clusters
This commit is contained in:
commit
694cfeb7b7
|
@ -1,6 +1,7 @@
|
|||
/* globals Flash */
|
||||
import Visibility from 'visibilityjs';
|
||||
import axios from 'axios';
|
||||
import setAxiosCsrfToken from './lib/utils/axios_utils';
|
||||
import Poll from './lib/utils/poll';
|
||||
import { s__ } from './locale';
|
||||
import initSettingsPanels from './settings_panels';
|
||||
|
@ -17,6 +18,7 @@ import Flash from './flash';
|
|||
class ClusterService {
|
||||
constructor(options = {}) {
|
||||
this.options = options;
|
||||
setAxiosCsrfToken();
|
||||
}
|
||||
fetchData() {
|
||||
return axios.get(this.options.endpoint);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import axios from 'axios';
|
||||
import csrf from './csrf';
|
||||
|
||||
export default function setAxiosCsrfToken() {
|
||||
axios.defaults.headers.common[csrf.headerKey] = csrf.token;
|
||||
}
|
|
@ -72,7 +72,7 @@
|
|||
}
|
||||
|
||||
.boards-list {
|
||||
height: calc(100vh - 152px);
|
||||
height: calc(100vh - 105px);
|
||||
width: 100%;
|
||||
padding-top: 25px;
|
||||
padding-bottom: 25px;
|
||||
|
@ -81,10 +81,14 @@
|
|||
overflow-x: scroll;
|
||||
white-space: nowrap;
|
||||
|
||||
@media (min-width: $screen-sm-min) {
|
||||
@media (min-width: $screen-sm-min) and (max-width: $screen-sm-max) {
|
||||
height: calc(100vh - 90px);
|
||||
}
|
||||
|
||||
@media (min-width: $screen-md-min) {
|
||||
height: 475px; // Needed for PhantomJS
|
||||
// scss-lint:disable DuplicateProperty
|
||||
height: calc(100vh - 222px);
|
||||
height: calc(100vh - 160px);
|
||||
// scss-lint:enable DuplicateProperty
|
||||
min-height: 475px;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@ class Admin::ApplicationsController < Admin::ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@application = Doorkeeper::Application.new(application_params)
|
||||
@application = Applications::CreateService.new(current_user, application_params).execute(request)
|
||||
|
||||
if @application.save
|
||||
redirect_to_admin_page
|
||||
if @application.persisted?
|
||||
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
|
||||
|
||||
redirect_to admin_application_url(@application)
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
@ -41,13 +43,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
|
|||
redirect_to admin_applications_url, status: 302, notice: 'Application was successfully destroyed.'
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def redirect_to_admin_page
|
||||
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
|
||||
redirect_to admin_application_url(@application)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_application
|
||||
|
|
|
@ -16,25 +16,18 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
|
|||
end
|
||||
|
||||
def create
|
||||
@application = Doorkeeper::Application.new(application_params)
|
||||
@application = Applications::CreateService.new(current_user, create_application_params).execute(request)
|
||||
|
||||
@application.owner = current_user
|
||||
if @application.persisted?
|
||||
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
|
||||
|
||||
if @application.save
|
||||
redirect_to_oauth_application_page
|
||||
redirect_to oauth_application_url(@application)
|
||||
else
|
||||
set_index_vars
|
||||
render :index
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def redirect_to_oauth_application_page
|
||||
flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
|
||||
redirect_to oauth_application_url(@application)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def verify_user_oauth_applications_enabled
|
||||
|
@ -61,4 +54,10 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
|
|||
rescue_from ActiveRecord::RecordNotFound do |exception|
|
||||
render "errors/not_found", layout: "errors", status: 404
|
||||
end
|
||||
|
||||
def create_application_params
|
||||
application_params.tap do |params|
|
||||
params[:owner] = current_user
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@key = Keys::CreateService.new(current_user, key_params).execute
|
||||
@key = Keys::CreateService.new(current_user, key_params.merge(ip_address: request.remote_ip)).execute
|
||||
|
||||
if @key.persisted?
|
||||
redirect_to_profile_key_path
|
||||
redirect_to profile_key_path(@key)
|
||||
else
|
||||
@keys = current_user.keys.select(&:persisted?)
|
||||
render :index
|
||||
|
@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def redirect_to_profile_key_path
|
||||
redirect_to profile_key_path(@key)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def key_params
|
||||
|
|
|
@ -110,7 +110,7 @@ class Environment < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def ref_path
|
||||
"refs/#{Repository::REF_ENVIRONMENTS}/#{generate_slug}"
|
||||
"refs/#{Repository::REF_ENVIRONMENTS}/#{slug}"
|
||||
end
|
||||
|
||||
def formatted_external_url
|
||||
|
@ -164,6 +164,10 @@ class Environment < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def slug
|
||||
super.presence || generate_slug
|
||||
end
|
||||
|
||||
# An environment name is not necessarily suitable for use in URLs, DNS
|
||||
# or other third-party contexts, so provide a slugified version. A slug has
|
||||
# the following properties:
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
module Applications
|
||||
class CreateService
|
||||
def initialize(current_user, params)
|
||||
@current_user = current_user
|
||||
@params = params
|
||||
@ip_address = @params.delete(:ip_address)
|
||||
end
|
||||
|
||||
def execute(request = nil)
|
||||
Doorkeeper::Application.create(@params)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,6 +4,7 @@ module Keys
|
|||
|
||||
def initialize(user, params)
|
||||
@user, @params = user, params
|
||||
@ip_address = @params.delete(:ip_address)
|
||||
end
|
||||
|
||||
def notification_service
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Avoid regenerating the ref path for the environment
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -501,7 +501,7 @@ production: &base
|
|||
# Gitaly settings
|
||||
gitaly:
|
||||
# Path to the directory containing Gitaly client executables.
|
||||
client_path: /home/git/gitaly
|
||||
client_path: /home/git/gitaly/bin
|
||||
# Default Gitaly authentication token. Can be overriden per storage. Can
|
||||
# be left blank when Gitaly is running locally on a Unix socket, which
|
||||
# is the normal way to deploy Gitaly.
|
||||
|
|
|
@ -547,6 +547,15 @@ describe Environment do
|
|||
|
||||
expect(environment.slug).to eq(original_slug)
|
||||
end
|
||||
|
||||
it "regenerates the slug if nil" do
|
||||
environment = build(:environment, slug: nil)
|
||||
|
||||
new_slug = environment.slug
|
||||
|
||||
expect(new_slug).not_to be_nil
|
||||
expect(environment.slug).to eq(new_slug)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#generate_slug' do
|
||||
|
@ -583,6 +592,12 @@ describe Environment do
|
|||
it 'returns a path that uses the slug and does not have spaces' do
|
||||
expect(environment.ref_path).to start_with('refs/environments/staging-review-1-')
|
||||
end
|
||||
|
||||
it "doesn't change when the slug is nil initially" do
|
||||
environment.slug = nil
|
||||
|
||||
expect(environment.ref_path).to eq(environment.ref_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#external_url_for' do
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ::Applications::CreateService do
|
||||
let(:user) { create(:user) }
|
||||
let(:params) { attributes_for(:application) }
|
||||
let(:request) { ActionController::TestRequest.new(remote_ip: '127.0.0.1') }
|
||||
|
||||
subject { described_class.new(user, params) }
|
||||
|
||||
it 'creates an application' do
|
||||
expect { subject.execute(request) }.to change { Doorkeeper::Application.count }.by(1)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue