Commit 694cfeb7 authored by Eric Eastwood's avatar Eric Eastwood

Merge branch 'master' into refactor-clusters

parents 600d5f4f f580e497
/* globals Flash */ /* globals Flash */
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import axios from 'axios'; import axios from 'axios';
import setAxiosCsrfToken from './lib/utils/axios_utils';
import Poll from './lib/utils/poll'; import Poll from './lib/utils/poll';
import { s__ } from './locale'; import { s__ } from './locale';
import initSettingsPanels from './settings_panels'; import initSettingsPanels from './settings_panels';
...@@ -17,6 +18,7 @@ import Flash from './flash'; ...@@ -17,6 +18,7 @@ import Flash from './flash';
class ClusterService { class ClusterService {
constructor(options = {}) { constructor(options = {}) {
this.options = options; this.options = options;
setAxiosCsrfToken();
} }
fetchData() { fetchData() {
return axios.get(this.options.endpoint); return axios.get(this.options.endpoint);
......
import axios from 'axios';
import csrf from './csrf';
export default function setAxiosCsrfToken() {
axios.defaults.headers.common[csrf.headerKey] = csrf.token;
}
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
} }
.boards-list { .boards-list {
height: calc(100vh - 152px); height: calc(100vh - 105px);
width: 100%; width: 100%;
padding-top: 25px; padding-top: 25px;
padding-bottom: 25px; padding-bottom: 25px;
...@@ -81,10 +81,14 @@ ...@@ -81,10 +81,14 @@
overflow-x: scroll; overflow-x: scroll;
white-space: nowrap; 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 height: 475px; // Needed for PhantomJS
// scss-lint:disable DuplicateProperty // scss-lint:disable DuplicateProperty
height: calc(100vh - 222px); height: calc(100vh - 160px);
// scss-lint:enable DuplicateProperty // scss-lint:enable DuplicateProperty
min-height: 475px; min-height: 475px;
} }
......
...@@ -19,10 +19,12 @@ class Admin::ApplicationsController < Admin::ApplicationController ...@@ -19,10 +19,12 @@ class Admin::ApplicationsController < Admin::ApplicationController
end end
def create def create
@application = Doorkeeper::Application.new(application_params) @application = Applications::CreateService.new(current_user, application_params).execute(request)
if @application.save if @application.persisted?
redirect_to_admin_page flash[:notice] = I18n.t(:notice, scope: [:doorkeeper, :flash, :applications, :create])
redirect_to admin_application_url(@application)
else else
render :new render :new
end end
...@@ -41,13 +43,6 @@ class Admin::ApplicationsController < Admin::ApplicationController ...@@ -41,13 +43,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
redirect_to admin_applications_url, status: 302, notice: 'Application was successfully destroyed.' redirect_to admin_applications_url, status: 302, notice: 'Application was successfully destroyed.'
end 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 private
def set_application def set_application
......
...@@ -16,25 +16,18 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController ...@@ -16,25 +16,18 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
end end
def create 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_url(@application)
redirect_to_oauth_application_page
else else
set_index_vars set_index_vars
render :index render :index
end end
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 private
def verify_user_oauth_applications_enabled def verify_user_oauth_applications_enabled
...@@ -61,4 +54,10 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController ...@@ -61,4 +54,10 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
rescue_from ActiveRecord::RecordNotFound do |exception| rescue_from ActiveRecord::RecordNotFound do |exception|
render "errors/not_found", layout: "errors", status: 404 render "errors/not_found", layout: "errors", status: 404
end end
def create_application_params
application_params.tap do |params|
params[:owner] = current_user
end
end
end end
...@@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController ...@@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController
end end
def create 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? if @key.persisted?
redirect_to_profile_key_path redirect_to profile_key_path(@key)
else else
@keys = current_user.keys.select(&:persisted?) @keys = current_user.keys.select(&:persisted?)
render :index render :index
...@@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController ...@@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController
end end
end end
protected
def redirect_to_profile_key_path
redirect_to profile_key_path(@key)
end
private private
def key_params def key_params
......
...@@ -110,7 +110,7 @@ class Environment < ActiveRecord::Base ...@@ -110,7 +110,7 @@ class Environment < ActiveRecord::Base
end end
def ref_path def ref_path
"refs/#{Repository::REF_ENVIRONMENTS}/#{generate_slug}" "refs/#{Repository::REF_ENVIRONMENTS}/#{slug}"
end end
def formatted_external_url def formatted_external_url
...@@ -164,6 +164,10 @@ class Environment < ActiveRecord::Base ...@@ -164,6 +164,10 @@ class Environment < ActiveRecord::Base
end end
end end
def slug
super.presence || generate_slug
end
# An environment name is not necessarily suitable for use in URLs, DNS # 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 # or other third-party contexts, so provide a slugified version. A slug has
# the following properties: # the following properties:
......
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 ...@@ -4,6 +4,7 @@ module Keys
def initialize(user, params) def initialize(user, params)
@user, @params = user, params @user, @params = user, params
@ip_address = @params.delete(:ip_address)
end end
def notification_service def notification_service
......
---
title: Avoid regenerating the ref path for the environment
merge_request:
author:
type: fixed
...@@ -501,7 +501,7 @@ production: &base ...@@ -501,7 +501,7 @@ production: &base
# Gitaly settings # Gitaly settings
gitaly: gitaly:
# Path to the directory containing Gitaly client executables. # 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 # Default Gitaly authentication token. Can be overriden per storage. Can
# be left blank when Gitaly is running locally on a Unix socket, which # be left blank when Gitaly is running locally on a Unix socket, which
# is the normal way to deploy Gitaly. # is the normal way to deploy Gitaly.
......
...@@ -547,6 +547,15 @@ describe Environment do ...@@ -547,6 +547,15 @@ describe Environment do
expect(environment.slug).to eq(original_slug) expect(environment.slug).to eq(original_slug)
end 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 end
describe '#generate_slug' do describe '#generate_slug' do
...@@ -583,6 +592,12 @@ describe Environment do ...@@ -583,6 +592,12 @@ describe Environment do
it 'returns a path that uses the slug and does not have spaces' 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-') expect(environment.ref_path).to start_with('refs/environments/staging-review-1-')
end 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 end
describe '#external_url_for' do describe '#external_url_for' do
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment