From 9121438ba2efc234efdc8ab803c9e50e043e39c6 Mon Sep 17 00:00:00 2001 From: Sheldon Led Date: Fri, 5 Dec 2025 08:25:22 -0300 Subject: [PATCH 1/4] Allow groups to update `display_gitlab_credits_user_data` --- .../groups/settings/_permissions.html.haml | 1 + doc/user/group/manage.md | 37 ++++++++ .../controllers/concerns/ee/groups/params.rb | 3 +- ee/app/services/ee/groups/create_service.rb | 1 + ee/app/services/ee/groups/update_service.rb | 3 +- .../_gitlab_credits_dashboard.html.haml | 10 +++ .../features/groups/group_settings_spec.rb | 84 ++++++++++++++++++- locale/gitlab.pot | 9 ++ 8 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 ee/app/views/groups/settings/_gitlab_credits_dashboard.html.haml diff --git a/app/views/groups/settings/_permissions.html.haml b/app/views/groups/settings/_permissions.html.haml index a3af4615561d6a..400850df9cb8a3 100644 --- a/app/views/groups/settings/_permissions.html.haml +++ b/app/views/groups/settings/_permissions.html.haml @@ -61,5 +61,6 @@ = render_if_exists 'groups/settings/pages_access_control', f: f, group: @group = render_if_exists 'groups/settings/crm', f: f, group: @group = render_if_exists 'groups/settings/secret_manager', f: f, group: @group + = render_if_exists 'groups/settings/gitlab_credits_dashboard', f: f, group: @group = f.submit _('Save changes'), pajamas_button: true, class: 'gl-mt-3', data: { testid: 'save-permissions-changes-button' } diff --git a/doc/user/group/manage.md b/doc/user/group/manage.md index aaebec0c2a1f4d..86659c77e3e9c9 100644 --- a/doc/user/group/manage.md +++ b/doc/user/group/manage.md @@ -722,3 +722,40 @@ You can view the most recent actions taken in a group, either in your browser or To view the activity feed in Atom format, select the **RSS** ({{< icon name="rss" >}}) icon. + +## GitLab Credits dashboard + +{{< history >}} + +- Namespace setting to allow the display of user data + [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/215371) in GitLab 18.7 + [with a flag](../../administration/feature_flags/_index.md) named `usage_billing_dev`. + +{{< /history >}} + +{{< alert type="flag" >}} + +The availability of this feature is controlled by a feature flag. +For more information, see the history. + +{{< /alert >}} + +{{< details >}} + +- Tier: Premium, Ultimate +- Offering: GitLab.com + +{{< /details >}} + +Prerequisites: + +- You must be an group owner. +- You must be on a top-level group. + +To enable the display of user data on the GitLab Credits dashboard: + +1. On the top bar, select **Search or go to** and find your group. +1. Select **Settings** > **General**. +1. Expand the **Permissions and group features** section. +1. For the **GitLab Credits dashboard**, select the **Display user data** checkbox. +1. Select **Save changes**. diff --git a/ee/app/controllers/concerns/ee/groups/params.rb b/ee/app/controllers/concerns/ee/groups/params.rb index 1966142578c6c6..dffd2eca66abf4 100644 --- a/ee/app/controllers/concerns/ee/groups/params.rb +++ b/ee/app/controllers/concerns/ee/groups/params.rb @@ -30,7 +30,8 @@ def group_params_ee :new_user_signups_cap, :seat_control, :remove_dormant_members, - :remove_dormant_members_period + :remove_dormant_members_period, + :display_gitlab_credits_user_data ].tap do |params_ee| params_ee << { insight_attributes: [:id, :project_id, :_destroy] } if current_group&.insights_available? diff --git a/ee/app/services/ee/groups/create_service.rb b/ee/app/services/ee/groups/create_service.rb index 3f48f52c36fca8..ed671f4738f04a 100644 --- a/ee/app/services/ee/groups/create_service.rb +++ b/ee/app/services/ee/groups/create_service.rb @@ -56,6 +56,7 @@ def remove_unallowed_params params.delete(:repository_size_limit) unless current_user&.can_admin_all_resources? params.delete(:remove_dormant_members) params.delete(:remove_dormant_members_period) + params.delete(:display_gitlab_credits_user_data) super end diff --git a/ee/app/services/ee/groups/update_service.rb b/ee/app/services/ee/groups/update_service.rb index 6f138c819bb123..61e896120347ff 100644 --- a/ee/app/services/ee/groups/update_service.rb +++ b/ee/app/services/ee/groups/update_service.rb @@ -10,7 +10,8 @@ module UpdateService :remove_dormant_members_period, :allow_enterprise_bypass_placeholder_confirmation, :enterprise_bypass_expires_at, - :enabled_foundational_flows + :enabled_foundational_flows, + :display_gitlab_credits_user_data ].freeze override :execute diff --git a/ee/app/views/groups/settings/_gitlab_credits_dashboard.html.haml b/ee/app/views/groups/settings/_gitlab_credits_dashboard.html.haml new file mode 100644 index 00000000000000..4857cff9fe0542 --- /dev/null +++ b/ee/app/views/groups/settings/_gitlab_credits_dashboard.html.haml @@ -0,0 +1,10 @@ +- return unless Feature.enabled?(:usage_billing_dev, @group) +- return unless ::Gitlab::Saas.feature_available?(:gitlab_com_subscriptions) +- return unless @group.feature_available?(:group_usage_billing) +- return unless @group.root? + +.form-group + %h5= _('GitLab Credits dashboard') + = f.gitlab_ui_checkbox_component :display_gitlab_credits_user_data, s_('UsageBilling|Display user data'), + help_text: s_('UsageBilling|If selected, individual usernames and their credit usage are visible on the GitLab Credits dashboard. If your organization needs to restrict access to individual user activity for compliance or privacy reasons, clear this checkbox.'), + checkbox_options: { checked: group.namespace_settings&.display_gitlab_credits_user_data } diff --git a/ee/spec/features/groups/group_settings_spec.rb b/ee/spec/features/groups/group_settings_spec.rb index b4ec1fc8f8039c..0eec58873a715a 100644 --- a/ee/spec/features/groups/group_settings_spec.rb +++ b/ee/spec/features/groups/group_settings_spec.rb @@ -420,7 +420,7 @@ end end - context 'Dormant members', :saas, :aggregate_failures, feature_category: :user_management do + context 'Dormant members', :aggregate_failures, feature_category: :user_management do before do visit edit_group_path(group) end @@ -499,6 +499,88 @@ def service_access_token_expiration_enforced_selector end end + context 'for gitlab credits dashboard' do + context 'when in saas', :saas_gitlab_com_subscriptions do + it 'hides checkbox when usage_billing_dev is disabled' do + stub_feature_flags(usage_billing_dev: false) + stub_licensed_features(group_usage_billing: true) + + visit edit_group_path(group) + + within_testid('permissions-settings') do + expect(page).not_to have_content('GitLab Credits dashboard') + expect(page).not_to have_content('Display user data') + end + end + + it 'hides checkbox when group does not have usage billing feature' do + stub_feature_flags(usage_billing_dev: true) + stub_licensed_features(group_usage_billing: false) + + visit edit_group_path(group) + + within_testid('permissions-settings') do + expect(page).not_to have_content('GitLab Credits dashboard') + expect(page).not_to have_content('Display user data') + end + end + + it 'shows the checkbox when both feature flag and group feature are enabled' do + stub_feature_flags(usage_billing_dev: true) + stub_licensed_features(group_usage_billing: true) + + visit edit_group_path(group) + + within_testid('permissions-settings') do + expect(page).to have_content('GitLab Credits dashboard') + expect(page).to have_content('Display user data') + end + end + + it 'changes display user data', :js do + stub_feature_flags(usage_billing_dev: true) + stub_licensed_features(group_usage_billing: true) + + visit edit_group_path(group) + + expect(group.namespace_settings.display_gitlab_credits_user_data).to be_falsey + within_testid('permissions-settings') do + expect(page).to have_unchecked_field(_('Display user data')) + end + + within_testid('permissions-settings') do + check _('Display user data') + click_button _('Save changes') + end + + expect(page).to have_content( + format( + _("Group '%{group_name}' was successfully updated."), + group_name: group.name + ) + ) + + page.refresh + + expect(page).to have_checked_field(_('Display user data')) + end + end + + context 'when not in saas' do + it 'does not show the checkbox' do + stub_feature_flags(usage_billing_dev: true) + stub_licensed_features(group_usage_billing: true) + + visit edit_group_path(group) + + within_testid('permissions-settings') do + expect(page).not_to have_content('GitLab Credits dashboard') + expect(page).not_to have_content('Display user data') + end + end + end + end + context 'for disable personal access tokens setting' do before do stub_licensed_features(disable_personal_access_tokens: true) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index ea52711dad2bde..7516c4524a446f 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -30964,6 +30964,9 @@ msgstr "" msgid "GitLab Credits" msgstr "" +msgid "GitLab Credits dashboard" +msgstr "" + msgid "GitLab Duo" msgstr "" @@ -71782,6 +71785,9 @@ msgstr "" msgid "UsageBilling|Date/Time" msgstr "" +msgid "UsageBilling|Display user data" +msgstr "" + msgid "UsageBilling|Enable on-demand billing" msgstr "" @@ -71806,6 +71812,9 @@ msgstr "" msgid "UsageBilling|GitLab Credits usage" msgstr "" +msgid "UsageBilling|If selected, individual usernames and their credit usage are visible on the GitLab Credits dashboard. If your organization needs to restrict access to individual user activity for compliance or privacy reasons, clear this checkbox." +msgstr "" + msgid "UsageBilling|Included credits" msgstr "" -- GitLab From ed3b907a482f5ee8bfbd6c4ab937eae6e86dcb00 Mon Sep 17 00:00:00 2001 From: Sheldon Led Date: Fri, 5 Dec 2025 09:58:05 -0300 Subject: [PATCH 2/4] Remove doc update --- doc/user/group/manage.md | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/doc/user/group/manage.md b/doc/user/group/manage.md index 86659c77e3e9c9..aaebec0c2a1f4d 100644 --- a/doc/user/group/manage.md +++ b/doc/user/group/manage.md @@ -722,40 +722,3 @@ You can view the most recent actions taken in a group, either in your browser or To view the activity feed in Atom format, select the **RSS** ({{< icon name="rss" >}}) icon. - -## GitLab Credits dashboard - -{{< history >}} - -- Namespace setting to allow the display of user data - [introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/215371) in GitLab 18.7 - [with a flag](../../administration/feature_flags/_index.md) named `usage_billing_dev`. - -{{< /history >}} - -{{< alert type="flag" >}} - -The availability of this feature is controlled by a feature flag. -For more information, see the history. - -{{< /alert >}} - -{{< details >}} - -- Tier: Premium, Ultimate -- Offering: GitLab.com - -{{< /details >}} - -Prerequisites: - -- You must be an group owner. -- You must be on a top-level group. - -To enable the display of user data on the GitLab Credits dashboard: - -1. On the top bar, select **Search or go to** and find your group. -1. Select **Settings** > **General**. -1. Expand the **Permissions and group features** section. -1. For the **GitLab Credits dashboard**, select the **Display user data** checkbox. -1. Select **Save changes**. -- GitLab From 9455f51435227d7f244a6ed327ef269d7eee5d21 Mon Sep 17 00:00:00 2001 From: Ammar Alakkad Date: Tue, 9 Dec 2025 09:59:21 +0300 Subject: [PATCH 3/4] Protected display_gitlab_credits_user_data with licensed feature --- ee/app/controllers/concerns/ee/groups/params.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ee/app/controllers/concerns/ee/groups/params.rb b/ee/app/controllers/concerns/ee/groups/params.rb index dffd2eca66abf4..991e5ba4a33f6c 100644 --- a/ee/app/controllers/concerns/ee/groups/params.rb +++ b/ee/app/controllers/concerns/ee/groups/params.rb @@ -30,8 +30,7 @@ def group_params_ee :new_user_signups_cap, :seat_control, :remove_dormant_members, - :remove_dormant_members_period, - :display_gitlab_credits_user_data + :remove_dormant_members_period ].tap do |params_ee| params_ee << { insight_attributes: [:id, :project_id, :_destroy] } if current_group&.insights_available? @@ -106,6 +105,8 @@ def group_params_ee params_ee << :allow_enterprise_bypass_placeholder_confirmation params_ee << :enterprise_bypass_expires_at end + + params_ee << :display_gitlab_credits_user_data if current_group&.feature_available?(:group_usage_billing) end end # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize -- GitLab From d7340d19484501249de28022c7a1532cc804efc7 Mon Sep 17 00:00:00 2001 From: Ammar Alakkad Date: Wed, 10 Dec 2025 11:23:14 +0300 Subject: [PATCH 4/4] Update translation namespace --- .../_gitlab_credits_dashboard.html.haml | 8 ++++---- locale/gitlab.pot | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/ee/app/views/groups/settings/_gitlab_credits_dashboard.html.haml b/ee/app/views/groups/settings/_gitlab_credits_dashboard.html.haml index 4857cff9fe0542..2963abf2255b8b 100644 --- a/ee/app/views/groups/settings/_gitlab_credits_dashboard.html.haml +++ b/ee/app/views/groups/settings/_gitlab_credits_dashboard.html.haml @@ -4,7 +4,7 @@ - return unless @group.root? .form-group - %h5= _('GitLab Credits dashboard') - = f.gitlab_ui_checkbox_component :display_gitlab_credits_user_data, s_('UsageBilling|Display user data'), - help_text: s_('UsageBilling|If selected, individual usernames and their credit usage are visible on the GitLab Credits dashboard. If your organization needs to restrict access to individual user activity for compliance or privacy reasons, clear this checkbox.'), - checkbox_options: { checked: group.namespace_settings&.display_gitlab_credits_user_data } + %h5= s_('GroupSettingsUsageBilling|GitLab Credits dashboard') + = f.gitlab_ui_checkbox_component :display_gitlab_credits_user_data, s_('GroupSettingsUsageBilling|Display user data'), + help_text: s_('GroupSettingsUsageBilling|If selected, individual usernames and their credit usage are visible on the GitLab Credits dashboard. If your organization needs to restrict access to individual user activity for compliance or privacy reasons, clear this checkbox.'), + checkbox_options: { checked: @group.namespace_settings&.display_gitlab_credits_user_data } diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 7516c4524a446f..128340b6106dab 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -30964,9 +30964,6 @@ msgstr "" msgid "GitLab Credits" msgstr "" -msgid "GitLab Credits dashboard" -msgstr "" - msgid "GitLab Duo" msgstr "" @@ -33064,6 +33061,15 @@ msgstr "" msgid "GroupSelect|Select a group" msgstr "" +msgid "GroupSettingsUsageBilling|Display user data" +msgstr "" + +msgid "GroupSettingsUsageBilling|GitLab Credits dashboard" +msgstr "" + +msgid "GroupSettingsUsageBilling|If selected, individual usernames and their credit usage are visible on the GitLab Credits dashboard. If your organization needs to restrict access to individual user activity for compliance or privacy reasons, clear this checkbox." +msgstr "" + msgid "GroupSettings|Add additional webhook triggers for group access token expiration" msgstr "" @@ -71785,9 +71791,6 @@ msgstr "" msgid "UsageBilling|Date/Time" msgstr "" -msgid "UsageBilling|Display user data" -msgstr "" - msgid "UsageBilling|Enable on-demand billing" msgstr "" @@ -71812,9 +71815,6 @@ msgstr "" msgid "UsageBilling|GitLab Credits usage" msgstr "" -msgid "UsageBilling|If selected, individual usernames and their credit usage are visible on the GitLab Credits dashboard. If your organization needs to restrict access to individual user activity for compliance or privacy reasons, clear this checkbox." -msgstr "" - msgid "UsageBilling|Included credits" msgstr "" -- GitLab