diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /app/assets/javascripts/projects/settings | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'app/assets/javascripts/projects/settings')
4 files changed, 35 insertions, 17 deletions
diff --git a/app/assets/javascripts/projects/settings/components/shared_runners_toggle.vue b/app/assets/javascripts/projects/settings/components/shared_runners_toggle.vue index 91d8fca0487..aa3235b1515 100644 --- a/app/assets/javascripts/projects/settings/components/shared_runners_toggle.vue +++ b/app/assets/javascripts/projects/settings/components/shared_runners_toggle.vue @@ -2,6 +2,7 @@ import { GlAlert, GlToggle, GlTooltip } from '@gitlab/ui'; import axios from '~/lib/utils/axios_utils'; import { __, s__ } from '~/locale'; +import { CC_VALIDATION_REQUIRED_ERROR } from '../constants'; const DEFAULT_ERROR_MESSAGE = __('An error occurred while updating the configuration.'); const REQUIRES_VALIDATION_TEXT = s__( @@ -47,11 +48,13 @@ export default { }; }, computed: { - showCreditCardValidation() { + ccRequiredError() { + return this.errorMessage === CC_VALIDATION_REQUIRED_ERROR && !this.ccAlertDismissed; + }, + genericError() { return ( - this.isCreditCardValidationRequired && - !this.isSharedRunnerEnabled && - !this.successfulValidation && + this.errorMessage && + this.errorMessage !== CC_VALIDATION_REQUIRED_ERROR && !this.ccAlertDismissed ); }, @@ -62,6 +65,7 @@ export default { }, toggleSharedRunners() { this.isLoading = true; + this.ccAlertDismissed = false; this.errorMessage = null; axios @@ -82,20 +86,19 @@ export default { <template> <div> <section class="gl-mt-5"> - <gl-alert v-if="errorMessage" class="gl-mb-3" variant="danger" :dismissible="false"> - {{ errorMessage }} - </gl-alert> - <cc-validation-required-alert - v-if="showCreditCardValidation" + v-if="ccRequiredError" class="gl-pb-5" :custom-message="$options.i18n.REQUIRES_VALIDATION_TEXT" @verifiedCreditCard="creditCardValidated" @dismiss="ccAlertDismissed = true" /> + <gl-alert v-if="genericError" class="gl-mb-3" variant="danger" :dismissible="false"> + {{ errorMessage }} + </gl-alert> + <gl-toggle - v-else ref="sharedRunnersToggle" :disabled="isDisabledAndUnoverridable" :is-loading="isLoading" diff --git a/app/assets/javascripts/projects/settings/components/transfer_project_form.vue b/app/assets/javascripts/projects/settings/components/transfer_project_form.vue index b98e1101884..fe968e74c6d 100644 --- a/app/assets/javascripts/projects/settings/components/transfer_project_form.vue +++ b/app/assets/javascripts/projects/settings/components/transfer_project_form.vue @@ -11,8 +11,12 @@ export default { ConfirmDanger, }, props: { - namespaces: { - type: Object, + groupNamespaces: { + type: Array, + required: true, + }, + userNamespaces: { + type: Array, required: true, }, confirmationPhrase: { @@ -44,10 +48,10 @@ export default { <div> <gl-form-group> <namespace-select - class="qa-namespaces-list" data-testid="transfer-project-namespace" :full-width="true" - :data="namespaces" + :group-namespaces="groupNamespaces" + :user-namespaces="userNamespaces" :selected-namespace="selectedNamespace" @select="handleSelect" /> diff --git a/app/assets/javascripts/projects/settings/constants.js b/app/assets/javascripts/projects/settings/constants.js index f5591c43dc4..9cf1afd334f 100644 --- a/app/assets/javascripts/projects/settings/constants.js +++ b/app/assets/javascripts/projects/settings/constants.js @@ -1,3 +1,5 @@ +import { __ } from '~/locale'; + export const LEVEL_TYPES = { ROLE: 'role', USER: 'user', @@ -18,3 +20,8 @@ export const ACCESS_LEVELS = { }; export const ACCESS_LEVEL_NONE = 0; + +// must match shared_runners_setting in update_service.rb +export const CC_VALIDATION_REQUIRED_ERROR = __( + 'Shared runners enabled cannot be enabled until a valid credit card is on file', +); diff --git a/app/assets/javascripts/projects/settings/init_transfer_project_form.js b/app/assets/javascripts/projects/settings/init_transfer_project_form.js index 47b49031dc9..a5f720bffaa 100644 --- a/app/assets/javascripts/projects/settings/init_transfer_project_form.js +++ b/app/assets/javascripts/projects/settings/init_transfer_project_form.js @@ -3,10 +3,14 @@ import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import TransferProjectForm from './components/transfer_project_form.vue'; const prepareNamespaces = (rawNamespaces = '') => { + if (!rawNamespaces) { + return { groupNamespaces: [], userNamespaces: [] }; + } + const data = JSON.parse(rawNamespaces); return { - group: data?.group.map(convertObjectPropsToCamelCase), - user: data?.user.map(convertObjectPropsToCamelCase), + groupNamespaces: data?.group?.map(convertObjectPropsToCamelCase) || [], + userNamespaces: data?.user?.map(convertObjectPropsToCamelCase) || [], }; }; @@ -35,7 +39,7 @@ export default () => { props: { confirmButtonText, confirmationPhrase, - namespaces: prepareNamespaces(namespaces), + ...prepareNamespaces(namespaces), }, on: { selectNamespace: (id) => { |