diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-23 03:12:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-23 03:12:50 +0300 |
commit | 04dabf41f65cf1c25d80d92b1cc5568bfcca80ee (patch) | |
tree | 4f9bc83d5f9683131c178f3048107ab16ba94d07 /app | |
parent | f19ffffacda2d7f415f682f6e50e3cf06182e15e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
13 files changed, 114 insertions, 36 deletions
diff --git a/app/assets/javascripts/ci/runner/admin_new_runner/admin_new_runner_app.vue b/app/assets/javascripts/ci/runner/admin_new_runner/admin_new_runner_app.vue index 5401c7c1c28..6130b15a3bc 100644 --- a/app/assets/javascripts/ci/runner/admin_new_runner/admin_new_runner_app.vue +++ b/app/assets/javascripts/ci/runner/admin_new_runner/admin_new_runner_app.vue @@ -1,9 +1,13 @@ <script> import { GlSprintf, GlLink, GlModalDirective } from '@gitlab/ui'; +import { createAlert, VARIANT_SUCCESS } from '~/flash'; +import { redirectTo, setUrlParams } from '~/lib/utils/url_utility'; +import { __ } from '~/locale'; import RunnerInstructionsModal from '~/vue_shared/components/runner_instructions/runner_instructions_modal.vue'; import RunnerPlatformsRadioGroup from '~/ci/runner/components/runner_platforms_radio_group.vue'; -import RunnerFormFields from '~/ci/runner/components/runner_form_fields.vue'; -import { DEFAULT_PLATFORM, DEFAULT_ACCESS_LEVEL } from '../constants'; +import RunnerCreateForm from '~/ci/runner/components/runner_create_form.vue'; +import { DEFAULT_PLATFORM, PARAM_KEY_PLATFORM } from '../constants'; +import { saveAlertToLocalStorage } from '../local_storage_alert/save_alert_to_local_storage'; export default { name: 'AdminNewRunnerApp', @@ -12,7 +16,7 @@ export default { GlSprintf, RunnerInstructionsModal, RunnerPlatformsRadioGroup, - RunnerFormFields, + RunnerCreateForm, }, directives: { GlModal: GlModalDirective, @@ -26,17 +30,21 @@ export default { data() { return { platform: DEFAULT_PLATFORM, - runner: { - description: '', - maintenanceNote: '', - paused: false, - accessLevel: DEFAULT_ACCESS_LEVEL, - runUntagged: false, - tagList: '', - maximumTimeout: ' ', - }, }; }, + methods: { + onSaved(runner) { + const registerUrl = setUrlParams( + { [PARAM_KEY_PLATFORM]: this.platform }, + runner.registerAdminUrl, + ); + saveAlertToLocalStorage({ message: __('Runner created.'), variant: VARIANT_SUCCESS }); + redirectTo(registerUrl); + }, + onError(error) { + createAlert({ message: error.message }); + }, + }, modalId: 'runners-legacy-registration-instructions-modal', }; </script> @@ -73,6 +81,6 @@ export default { <hr aria-hidden="true" /> - <runner-form-fields v-model="runner" /> + <runner-create-form @saved="onSaved" @error="onError" /> </div> </template> diff --git a/app/assets/javascripts/ci/runner/admin_register_runner/index.js b/app/assets/javascripts/ci/runner/admin_register_runner/index.js new file mode 100644 index 00000000000..edb2ec65e98 --- /dev/null +++ b/app/assets/javascripts/ci/runner/admin_register_runner/index.js @@ -0,0 +1,5 @@ +import { showAlertFromLocalStorage } from '../local_storage_alert/show_alert_from_local_storage'; + +export const initAdminRegisterRunner = () => { + showAlertFromLocalStorage(); +}; diff --git a/app/assets/javascripts/ci/runner/components/runner_create_form.vue b/app/assets/javascripts/ci/runner/components/runner_create_form.vue new file mode 100644 index 00000000000..5d2a3c53842 --- /dev/null +++ b/app/assets/javascripts/ci/runner/components/runner_create_form.vue @@ -0,0 +1,71 @@ +<script> +import { GlForm, GlButton } from '@gitlab/ui'; +import RunnerFormFields from '~/ci/runner/components/runner_form_fields.vue'; +import runnerCreateMutation from '~/ci/runner/graphql/new/runner_create.mutation.graphql'; +import { modelToUpdateMutationVariables } from 'ee_else_ce/ci/runner/runner_update_form_utils'; +import { captureException } from '../sentry_utils'; +import { DEFAULT_ACCESS_LEVEL } from '../constants'; + +export default { + name: 'RunnerCreateForm', + components: { + GlForm, + GlButton, + RunnerFormFields, + }, + data() { + return { + saving: false, + runner: { + description: '', + maintenanceNote: '', + paused: false, + accessLevel: DEFAULT_ACCESS_LEVEL, + runUntagged: false, + tagList: '', + maximumTimeout: '', + }, + }; + }, + methods: { + async onSubmit() { + this.saving = true; + try { + const { + data: { + runnerCreate: { errors, runner }, + }, + } = await this.$apollo.mutate({ + mutation: runnerCreateMutation, + variables: modelToUpdateMutationVariables(this.runner), + }); + + if (errors?.length) { + this.$emit('error', new Error(errors.join(' '))); + } else { + this.onSuccess(runner); + } + } catch (error) { + captureException({ error, component: this.$options.name }); + this.$emit('error', error); + } finally { + this.saving = false; + } + }, + onSuccess(runner) { + this.$emit('saved', runner); + }, + }, +}; +</script> +<template> + <gl-form @submit.prevent="onSubmit"> + <runner-form-fields v-model="runner" /> + + <div class="gl-display-flex"> + <gl-button type="submit" variant="confirm" class="js-no-auto-disable" :loading="saving"> + {{ __('Submit') }} + </gl-button> + </div> + </gl-form> +</template> diff --git a/app/assets/javascripts/ci/runner/constants.js b/app/assets/javascripts/ci/runner/constants.js index 318eb7e74bd..27c02420036 100644 --- a/app/assets/javascripts/ci/runner/constants.js +++ b/app/assets/javascripts/ci/runner/constants.js @@ -129,6 +129,8 @@ export const PARAM_KEY_SORT = 'sort'; export const PARAM_KEY_AFTER = 'after'; export const PARAM_KEY_BEFORE = 'before'; +export const PARAM_KEY_PLATFORM = 'platform'; + // CiRunnerType export const INSTANCE_TYPE = 'INSTANCE_TYPE'; diff --git a/app/assets/javascripts/ci/runner/graphql/new/runner_create.mutation.graphql b/app/assets/javascripts/ci/runner/graphql/new/runner_create.mutation.graphql new file mode 100644 index 00000000000..d14a594e378 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/new/runner_create.mutation.graphql @@ -0,0 +1,9 @@ +mutation runnerCreate($input: RunnerCreateInput!) { + runnerCreate(input: $input) { + runner { + id + registerAdminUrl + } + errors + } +} diff --git a/app/assets/javascripts/pages/admin/runners/register/index.js b/app/assets/javascripts/pages/admin/runners/register/index.js new file mode 100644 index 00000000000..d7ee2ee369a --- /dev/null +++ b/app/assets/javascripts/pages/admin/runners/register/index.js @@ -0,0 +1,3 @@ +import { initAdminRegisterRunner } from '~/ci/runner/admin_register_runner'; + +initAdminRegisterRunner(); diff --git a/app/assets/javascripts/token_access/components/token_access_app.vue b/app/assets/javascripts/token_access/components/token_access_app.vue index 59d59757735..089159ac87b 100644 --- a/app/assets/javascripts/token_access/components/token_access_app.vue +++ b/app/assets/javascripts/token_access/components/token_access_app.vue @@ -1,5 +1,4 @@ <script> -import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import OutboundTokenAccess from './outbound_token_access.vue'; import InboundTokenAccess from './inbound_token_access.vue'; import OptInJwt from './opt_in_jwt.vue'; @@ -10,17 +9,11 @@ export default { InboundTokenAccess, OptInJwt, }, - mixins: [glFeatureFlagMixin()], - computed: { - inboundTokenAccessEnabled() { - return this.glFeatures.ciInboundJobTokenScope; - }, - }, }; </script> <template> <div> - <inbound-token-access v-if="inboundTokenAccessEnabled" class="gl-pb-5" /> + <inbound-token-access class="gl-pb-5" /> <outbound-token-access class="gl-py-5" /> <opt-in-jwt /> </div> diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 4ca665679c0..b330aacf3e9 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -12,10 +12,6 @@ module Projects before_action :check_builds_available! before_action :define_variables - before_action do - push_frontend_feature_flag(:ci_inbound_job_token_scope, @project) - end - helper_method :highlight_badge feature_category :continuous_integration diff --git a/app/graphql/mutations/ci/project_ci_cd_settings_update.rb b/app/graphql/mutations/ci/project_ci_cd_settings_update.rb index d214aa46cfc..fcba729d460 100644 --- a/app/graphql/mutations/ci/project_ci_cd_settings_update.rb +++ b/app/graphql/mutations/ci/project_ci_cd_settings_update.rb @@ -39,8 +39,6 @@ module Mutations def resolve(full_path:, **args) project = authorized_find!(full_path) - args.delete(:inbound_job_token_scope_enabled) unless Feature.enabled?(:ci_inbound_job_token_scope, project) - settings = project.ci_cd_settings settings.update(args) diff --git a/app/models/ci/job_token/scope.rb b/app/models/ci/job_token/scope.rb index 20775077bd8..f389c642fd8 100644 --- a/app/models/ci/job_token/scope.rb +++ b/app/models/ci/job_token/scope.rb @@ -58,8 +58,7 @@ module Ci end def inbound_accessible?(accessed_project) - # if the flag or setting is disabled any project is considered to be in scope. - return true unless Feature.enabled?(:ci_inbound_job_token_scope, accessed_project) + # if the setting is disabled any project is considered to be in scope. return true unless accessed_project.ci_inbound_job_token_scope_enabled? inbound_linked_as_accessible?(accessed_project) diff --git a/app/models/project.rb b/app/models/project.rb index b1bb0ff2bbb..c88ef4fb9db 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2979,7 +2979,7 @@ class Project < ApplicationRecord end def ci_inbound_job_token_scope_enabled? - return false unless ci_cd_settings + return true unless ci_cd_settings ci_cd_settings.inbound_job_token_scope_enabled? end diff --git a/app/models/project_ci_cd_setting.rb b/app/models/project_ci_cd_setting.rb index 8741a341ad3..cc9003423be 100644 --- a/app/models/project_ci_cd_setting.rb +++ b/app/models/project_ci_cd_setting.rb @@ -20,10 +20,6 @@ class ProjectCiCdSetting < ApplicationRecord attribute :forward_deployment_enabled, default: true attribute :separated_caches, default: true - default_value_for :inbound_job_token_scope_enabled do |settings| - Feature.enabled?(:ci_inbound_job_token_scope, settings.project) - end - chronic_duration_attr :runner_token_expiration_interval_human_readable, :runner_token_expiration_interval def keep_latest_artifacts_available? diff --git a/app/services/ci/job_token_scope/add_project_service.rb b/app/services/ci/job_token_scope/add_project_service.rb index 15553ad6e92..4f745042f07 100644 --- a/app/services/ci/job_token_scope/add_project_service.rb +++ b/app/services/ci/job_token_scope/add_project_service.rb @@ -6,8 +6,6 @@ module Ci include EditScopeValidations def execute(target_project, direction: :outbound) - direction = :outbound if Feature.disabled?(:ci_inbound_job_token_scope) - validate_edit!(project, target_project, current_user) link = allowlist(direction) |