Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-11-24 10:37:22 +0300
committerTimothy Andrew <mail@timothyandrew.net>2016-12-16 13:59:31 +0300
commit4d6da770de94f4bf140507cdf43461b67269ce28 (patch)
treed637ccdf6af0475af83b01e9f8371c5f06f6f880 /app
parentac9835c602f1c9b5a35ef40df079faf1d4b91f7b (diff)
Implement minor changes from @dbalexandre's review.
- Mainly whitespace changes. - Require the migration adding the `scope` column to the `personal_access_tokens` table to have downtime, since API calls will fail if the new code is in place, but the migration hasn't run. - Minor refactoring - load `@scopes` in a `before_action`, since we're doing it in three different places.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/applications_controller.rb3
-rw-r--r--app/controllers/concerns/oauth_applications.rb5
-rw-r--r--app/controllers/oauth/applications_controller.rb6
-rw-r--r--app/views/doorkeeper/applications/_form.html.haml1
-rw-r--r--app/views/doorkeeper/applications/show.html.haml1
5 files changed, 7 insertions, 9 deletions
diff --git a/app/controllers/admin/applications_controller.rb b/app/controllers/admin/applications_controller.rb
index 759044910bb..62f62e99a97 100644
--- a/app/controllers/admin/applications_controller.rb
+++ b/app/controllers/admin/applications_controller.rb
@@ -2,6 +2,7 @@ class Admin::ApplicationsController < Admin::ApplicationController
include OauthApplications
before_action :set_application, only: [:show, :edit, :update, :destroy]
+ before_action :load_scopes, only: [:new, :edit]
def index
@applications = Doorkeeper::Application.where("owner_id IS NULL")
@@ -12,11 +13,9 @@ class Admin::ApplicationsController < Admin::ApplicationController
def new
@application = Doorkeeper::Application.new
- @scopes = Doorkeeper.configuration.scopes
end
def edit
- @scopes = Doorkeeper.configuration.scopes
end
def create
diff --git a/app/controllers/concerns/oauth_applications.rb b/app/controllers/concerns/oauth_applications.rb
index 34ad43ededd..7210ed3eb32 100644
--- a/app/controllers/concerns/oauth_applications.rb
+++ b/app/controllers/concerns/oauth_applications.rb
@@ -7,8 +7,13 @@ module OauthApplications
def prepare_scopes
scopes = params.dig(:doorkeeper_application, :scopes)
+
if scopes
params[:doorkeeper_application][:scopes] = scopes.join(' ')
end
end
+
+ def load_scopes
+ @scopes = Doorkeeper.configuration.scopes
+ end
end
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb
index b5449a6c30e..2ae4785b12c 100644
--- a/app/controllers/oauth/applications_controller.rb
+++ b/app/controllers/oauth/applications_controller.rb
@@ -7,6 +7,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
before_action :verify_user_oauth_applications_enabled
before_action :authenticate_user!
before_action :add_gon_variables
+ before_action :load_scopes, only: [:index, :create, :edit]
layout 'profile'
@@ -14,10 +15,6 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
set_index_vars
end
- def edit
- @scopes = Doorkeeper.configuration.scopes
- end
-
def create
@application = Doorkeeper::Application.new(application_params)
@@ -45,7 +42,6 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
@authorized_tokens = current_user.oauth_authorized_tokens
@authorized_anonymous_tokens = @authorized_tokens.reject(&:application)
@authorized_apps = @authorized_tokens.map(&:application).uniq.reject(&:nil?)
- @scopes = Doorkeeper.configuration.scopes
# Don't overwrite a value possibly set by `create`
@application ||= Doorkeeper::Application.new
diff --git a/app/views/doorkeeper/applications/_form.html.haml b/app/views/doorkeeper/applications/_form.html.haml
index 6fdb04077b6..96677dc1a4d 100644
--- a/app/views/doorkeeper/applications/_form.html.haml
+++ b/app/views/doorkeeper/applications/_form.html.haml
@@ -25,6 +25,5 @@
= label_tag "doorkeeper_application_scopes_#{scope}", scope
%span= "(#{t(scope, scope: [:doorkeeper, :scopes])})"
-
.prepend-top-default
= f.submit 'Save application', class: "btn btn-create"
diff --git a/app/views/doorkeeper/applications/show.html.haml b/app/views/doorkeeper/applications/show.html.haml
index a18e133c8de..5473a8e0ddc 100644
--- a/app/views/doorkeeper/applications/show.html.haml
+++ b/app/views/doorkeeper/applications/show.html.haml
@@ -34,7 +34,6 @@
%span.scope-name= scope
= "(#{t(scope, scope: [:doorkeeper, :scopes])})"
-
.form-actions
= link_to 'Edit', edit_oauth_application_path(@application), class: 'btn btn-primary wide pull-left'
= render 'delete_form', application: @application, submit_btn_css: 'btn btn-danger prepend-left-10'