diff options
Diffstat (limited to 'app/assets/javascripts/pages/admin/application_settings')
2 files changed, 51 insertions, 39 deletions
diff --git a/app/assets/javascripts/pages/admin/application_settings/general/components/signup_form.vue b/app/assets/javascripts/pages/admin/application_settings/general/components/signup_form.vue index 9850113d4be..c2510a16d2f 100644 --- a/app/assets/javascripts/pages/admin/application_settings/general/components/signup_form.vue +++ b/app/assets/javascripts/pages/admin/application_settings/general/components/signup_form.vue @@ -11,7 +11,7 @@ import { } from '@gitlab/ui'; import { toSafeInteger } from 'lodash'; import csrf from '~/lib/utils/csrf'; -import { __, s__, sprintf } from '~/locale'; +import { __, n__, s__, sprintf } from '~/locale'; import SignupCheckbox from './signup_checkbox.vue'; const DENYLIST_TYPE_RAW = 'raw'; @@ -51,6 +51,7 @@ export default { 'supportedSyntaxLinkUrl', 'emailRestrictions', 'afterSignUpText', + 'pendingUserCount', ], data() { return { @@ -105,8 +106,9 @@ export default { canUsersBeAccidentallyApproved() { const hasUserCapBeenToggledOff = this.requireAdminApprovalAfterUserSignup && !this.form.requireAdminApproval; + const currentlyPendingUsers = this.pendingUserCount > 0; - return this.hasUserCapBeenIncreased || hasUserCapBeenToggledOff; + return (this.hasUserCapBeenIncreased || hasUserCapBeenToggledOff) && currentlyPendingUsers; }, signupEnabledHelpText() { const text = sprintf( @@ -132,13 +134,39 @@ export default { return text; }, + approveUsersModal() { + const { pendingUserCount } = this; + + return { + id: 'signup-settings-modal', + text: n__( + 'ApplicationSettings|By making this change, you will automatically approve %d user with the pending approval status.', + 'ApplicationSettings|By making this change, you will automatically approve %d users with the pending approval status.', + pendingUserCount, + ), + actionPrimary: { + text: n__( + 'ApplicationSettings|Approve %d user', + 'ApplicationSettings|Approve %d users', + pendingUserCount, + ), + attributes: { + variant: 'confirm', + }, + }, + actionCancel: { + text: __('Cancel'), + }, + title: s__('ApplicationSettings|Approve users in the pending approval status?'), + }; + }, }, watch: { showModal(value) { if (value === true) { - this.$refs[this.$options.modal.id].show(); + this.$refs[this.approveUsersModal.id].show(); } else { - this.$refs[this.$options.modal.id].hide(); + this.$refs[this.approveUsersModal.id].hide(); } }, }, @@ -196,22 +224,6 @@ export default { afterSignUpTextGroupLabel: s__('ApplicationSettings|After sign up text'), afterSignUpTextGroupDescription: s__('ApplicationSettings|Markdown enabled'), }, - modal: { - id: 'signup-settings-modal', - actionPrimary: { - text: s__('ApplicationSettings|Approve users'), - attributes: { - variant: 'confirm', - }, - }, - actionCancel: { - text: __('Cancel'), - }, - title: s__('ApplicationSettings|Approve all users in the pending approval status?'), - text: s__( - 'ApplicationSettings|By making this change, you will automatically approve all users in pending approval status.', - ), - }, }; </script> @@ -403,15 +415,15 @@ export default { </gl-button> <gl-modal - :ref="$options.modal.id" - :modal-id="$options.modal.id" - :action-cancel="$options.modal.actionCancel" - :action-primary="$options.modal.actionPrimary" - :title="$options.modal.title" + :ref="approveUsersModal.id" + :modal-id="approveUsersModal.id" + :action-cancel="approveUsersModal.actionCancel" + :action-primary="approveUsersModal.actionPrimary" + :title="approveUsersModal.title" @primary="submitForm" @hide="modalHideHandler" > - {{ $options.modal.text }} + {{ approveUsersModal.text }} </gl-modal> </form> </template> diff --git a/app/assets/javascripts/pages/admin/application_settings/metrics_and_profiling/usage_statistics.js b/app/assets/javascripts/pages/admin/application_settings/metrics_and_profiling/usage_statistics.js index bf27b1a81ff..4c312a008cb 100644 --- a/app/assets/javascripts/pages/admin/application_settings/metrics_and_profiling/usage_statistics.js +++ b/app/assets/javascripts/pages/admin/application_settings/metrics_and_profiling/usage_statistics.js @@ -8,34 +8,34 @@ export const HELPER_TEXT_SERVICE_PING_ENABLED = __( 'You can enable Registration Features because Service Ping is enabled. To continue using Registration Features in the future, you will also need to register with GitLab via a new cloud licensing service.', ); -function setHelperText(usagePingCheckbox) { +function setHelperText(servicePingCheckbox) { const helperTextId = document.getElementById('service_ping_features_helper_text'); - const usagePingFeaturesLabel = document.getElementById('service_ping_features_label'); + const servicePingFeaturesLabel = document.getElementById('service_ping_features_label'); - const usagePingFeaturesCheckbox = document.getElementById( + const servicePingFeaturesCheckbox = document.getElementById( 'application_setting_usage_ping_features_enabled', ); - helperTextId.textContent = usagePingCheckbox.checked + helperTextId.textContent = servicePingCheckbox.checked ? HELPER_TEXT_SERVICE_PING_ENABLED : HELPER_TEXT_SERVICE_PING_DISABLED; - usagePingFeaturesLabel.classList.toggle('gl-cursor-not-allowed', !usagePingCheckbox.checked); + servicePingFeaturesLabel.classList.toggle('gl-cursor-not-allowed', !servicePingCheckbox.checked); - usagePingFeaturesCheckbox.disabled = !usagePingCheckbox.checked; + servicePingFeaturesCheckbox.disabled = !servicePingCheckbox.checked; - if (!usagePingCheckbox.checked) { - usagePingFeaturesCheckbox.disabled = true; - usagePingFeaturesCheckbox.checked = false; + if (!servicePingCheckbox.checked) { + servicePingFeaturesCheckbox.disabled = true; + servicePingFeaturesCheckbox.checked = false; } } export default function initSetHelperText() { - const usagePingCheckbox = document.getElementById('application_setting_usage_ping_enabled'); + const servicePingCheckbox = document.getElementById('application_setting_usage_ping_enabled'); - setHelperText(usagePingCheckbox); - usagePingCheckbox.addEventListener('change', () => { - setHelperText(usagePingCheckbox); + setHelperText(servicePingCheckbox); + servicePingCheckbox.addEventListener('change', () => { + setHelperText(servicePingCheckbox); }); } |