diff options
Diffstat (limited to 'app')
11 files changed, 22 insertions, 18 deletions
diff --git a/app/assets/javascripts/pages/groups/settings/repository/create_deploy_token/index.js b/app/assets/javascripts/pages/groups/settings/repository/create_deploy_token/index.js new file mode 100644 index 00000000000..6a7c6028c95 --- /dev/null +++ b/app/assets/javascripts/pages/groups/settings/repository/create_deploy_token/index.js @@ -0,0 +1 @@ +import '../show/index'; diff --git a/app/assets/javascripts/runner/group_runners/group_runners_app.vue b/app/assets/javascripts/runner/group_runners/group_runners_app.vue index a82411a2120..a2b666f4c6a 100644 --- a/app/assets/javascripts/runner/group_runners/group_runners_app.vue +++ b/app/assets/javascripts/runner/group_runners/group_runners_app.vue @@ -50,7 +50,8 @@ export default { props: { registrationToken: { type: String, - required: true, + required: false, + default: null, }, groupFullPath: { type: String, @@ -191,6 +192,7 @@ export default { /> <registration-dropdown + v-if="registrationToken" class="gl-ml-auto" :registration-token="registrationToken" :type="$options.GROUP_TYPE" diff --git a/app/controllers/groups/runners_controller.rb b/app/controllers/groups/runners_controller.rb index aeb54527c69..0ee6ddc2662 100644 --- a/app/controllers/groups/runners_controller.rb +++ b/app/controllers/groups/runners_controller.rb @@ -11,6 +11,7 @@ class Groups::RunnersController < Groups::ApplicationController def index finder = Ci::RunnersFinder.new(current_user: current_user, params: { group: @group }) @group_runners_limited_count = finder.execute.except(:limit, :offset).page.total_count_with_limit(:all, limit: 1000) + @group_runner_registration_token = @group.runners_token if can?(current_user, :register_group_runners, group) Gitlab::Tracking.event(self.class.name, 'index', user: current_user, namespace: @group) end diff --git a/app/controllers/groups/settings/repository_controller.rb b/app/controllers/groups/settings/repository_controller.rb index e09d8bf81cc..cb62ea2a543 100644 --- a/app/controllers/groups/settings/repository_controller.rb +++ b/app/controllers/groups/settings/repository_controller.rb @@ -17,13 +17,13 @@ module Groups def create_deploy_token result = Groups::DeployTokens::CreateService.new(@group, current_user, deploy_token_params).execute - @new_deploy_token = result[:deploy_token] if result[:status] == :success + @created_deploy_token = result[:deploy_token] respond_to do |format| format.json do # IMPORTANT: It's a security risk to expose the token value more than just once here! - json = API::Entities::DeployTokenWithToken.represent(@new_deploy_token).as_json + json = API::Entities::DeployTokenWithToken.represent(@created_deploy_token).as_json render json: json, status: result[:http_status] end format.html do @@ -32,6 +32,7 @@ module Groups end end else + @new_deploy_token = result[:deploy_token] respond_to do |format| format.json { render json: { message: result[:message] }, status: result[:http_status] } format.html do diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb index a178b8f7aa3..43c6451577a 100644 --- a/app/controllers/projects/settings/repository_controller.rb +++ b/app/controllers/projects/settings/repository_controller.rb @@ -34,13 +34,13 @@ module Projects def create_deploy_token result = Projects::DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute - @new_deploy_token = result[:deploy_token] if result[:status] == :success + @created_deploy_token = result[:deploy_token] respond_to do |format| format.json do # IMPORTANT: It's a security risk to expose the token value more than just once here! - json = API::Entities::DeployTokenWithToken.represent(@new_deploy_token).as_json + json = API::Entities::DeployTokenWithToken.represent(@created_deploy_token).as_json render json: json, status: result[:http_status] end format.html do @@ -49,6 +49,7 @@ module Projects end end else + @new_deploy_token = result[:deploy_token] respond_to do |format| format.json { render json: { message: result[:message] }, status: result[:http_status] } format.html do diff --git a/app/helpers/ci/runners_helper.rb b/app/helpers/ci/runners_helper.rb index 852eaeca5e3..0de84c0d61f 100644 --- a/app/helpers/ci/runners_helper.rb +++ b/app/helpers/ci/runners_helper.rb @@ -84,7 +84,6 @@ module Ci def group_runners_data_attributes(group) { - registration_token: group.runners_token, group_id: group.id, group_full_path: group.full_path, runner_install_help_page: 'https://docs.gitlab.com/runner/install/', diff --git a/app/helpers/deploy_tokens_helper.rb b/app/helpers/deploy_tokens_helper.rb index d4da928edf1..597823cdac7 100644 --- a/app/helpers/deploy_tokens_helper.rb +++ b/app/helpers/deploy_tokens_helper.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true module DeployTokensHelper - def expand_deploy_tokens_section?(deploy_token) - deploy_token.persisted? || - deploy_token.errors.present? || + def expand_deploy_tokens_section?(new_deploy_token, created_deploy_token) + created_deploy_token || + new_deploy_token.errors.present? || Rails.env.test? end diff --git a/app/serializers/group_access_token_entity.rb b/app/serializers/group_access_token_entity.rb index e832eef1188..76dc3999a61 100644 --- a/app/serializers/group_access_token_entity.rb +++ b/app/serializers/group_access_token_entity.rb @@ -14,13 +14,13 @@ class GroupAccessTokenEntity < API::Entities::PersonalAccessToken group_id: group.path) end - expose :access_level do |token, options| + expose :role do |token, options| group = options.fetch(:group) next unless group next unless token.user - group.member(token.user)&.access_level + group.member(token.user)&.human_access end end # rubocop: enable Gitlab/NamespacedClass diff --git a/app/serializers/project_access_token_entity.rb b/app/serializers/project_access_token_entity.rb index b317057c952..695a5122348 100644 --- a/app/serializers/project_access_token_entity.rb +++ b/app/serializers/project_access_token_entity.rb @@ -15,13 +15,13 @@ class ProjectAccessTokenEntity < API::Entities::PersonalAccessToken project_id: project.path) end - expose :access_level do |token, options| + expose :role do |token, options| project = options.fetch(:project) next unless project next unless token.user - project.member(token.user)&.access_level + project.member(token.user)&.human_access end end # rubocop: enable Gitlab/NamespacedClass diff --git a/app/views/groups/runners/index.html.haml b/app/views/groups/runners/index.html.haml index a67a4f28c93..1146063969b 100644 --- a/app/views/groups/runners/index.html.haml +++ b/app/views/groups/runners/index.html.haml @@ -1,3 +1,3 @@ - page_title s_('Runners|Runners') -#js-group-runners{ data: group_runners_data_attributes(@group).merge( { group_runners_limited_count: @group_runners_limited_count } ) } +#js-group-runners{ data: group_runners_data_attributes(@group).merge( { group_runners_limited_count: @group_runners_limited_count, registration_token: @group_runner_registration_token } ) } diff --git a/app/views/shared/deploy_tokens/_index.html.haml b/app/views/shared/deploy_tokens/_index.html.haml index aa4a3deaac4..79bf35e2726 100644 --- a/app/views/shared/deploy_tokens/_index.html.haml +++ b/app/views/shared/deploy_tokens/_index.html.haml @@ -1,4 +1,4 @@ -- expanded = expand_deploy_tokens_section?(@new_deploy_token) +- expanded = expand_deploy_tokens_section?(@new_deploy_token, @created_deploy_token) %section.settings.no-animate#js-deploy-tokens{ class: ('expanded' if expanded), data: { qa_selector: 'deploy_tokens_settings_content' } } .settings-header @@ -8,11 +8,10 @@ %p = description .settings-content - - if @new_deploy_token.persisted? - = render 'shared/deploy_tokens/new_deploy_token', deploy_token: @new_deploy_token + - if @created_deploy_token + = render 'shared/deploy_tokens/new_deploy_token', deploy_token: @created_deploy_token %h5.gl-mt-0 = s_('DeployTokens|New deploy token') = render 'shared/deploy_tokens/form', group_or_project: group_or_project, token: @new_deploy_token, presenter: @deploy_tokens %hr = render 'shared/deploy_tokens/table', group_or_project: group_or_project, active_tokens: @deploy_tokens - |