From c2eb2fb0c404097930dcced2d23fe7e69f46b6f6 Mon Sep 17 00:00:00 2001 From: Kos Palchyk <kpalchyk@gitlab.com> Date: Fri, 24 May 2024 11:16:50 +0000 Subject: [PATCH] Add page stub for admin promotion management --- app/views/admin/users/_tabs.html.haml | 1 + .../role_promotion_requests_controller.rb | 18 +++++++++ .../promotion_management_helper.rb | 7 ++++ .../_role_promotion_requests.html.haml | 2 + .../role_promotion_requests/index.html.haml | 7 ++++ .../users/_role_promotion_requests_tab.haml | 2 + ee/config/routes/admin.rb | 1 + ...role_promotion_requests_controller_spec.rb | 39 +++++++++++++++++++ locale/gitlab.pot | 3 ++ 9 files changed, 80 insertions(+) create mode 100644 ee/app/controllers/admin/role_promotion_requests_controller.rb create mode 100644 ee/app/helpers/gitlab_subscriptions/promotion_management_helper.rb create mode 100644 ee/app/views/admin/role_promotion_requests/_role_promotion_requests.html.haml create mode 100644 ee/app/views/admin/role_promotion_requests/index.html.haml create mode 100644 ee/app/views/admin/users/_role_promotion_requests_tab.haml create mode 100644 ee/spec/controllers/admin/role_promotion_requests_controller_spec.rb diff --git a/app/views/admin/users/_tabs.html.haml b/app/views/admin/users/_tabs.html.haml index fa038426b6905..3c95723479767 100644 --- a/app/views/admin/users/_tabs.html.haml +++ b/app/views/admin/users/_tabs.html.haml @@ -1,3 +1,4 @@ = gl_tabs_nav({ class: 'gl-flex-grow-1 gl-border-0', data: { testid: 'admin-users-tabs' } }) do = gl_tab_link_to s_('AdminUsers|Users'), admin_users_path + = render_if_exists 'admin/users/role_promotion_requests_tab' = gl_tab_link_to s_('AdminUsers|Cohorts'), admin_cohorts_path diff --git a/ee/app/controllers/admin/role_promotion_requests_controller.rb b/ee/app/controllers/admin/role_promotion_requests_controller.rb new file mode 100644 index 0000000000000..887b1c2fc29cb --- /dev/null +++ b/ee/app/controllers/admin/role_promotion_requests_controller.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Admin + class RolePromotionRequestsController < Admin::ApplicationController + include ::MemberManagement::PromotionManagementUtils + + feature_category :seat_cost_management + before_action :verify_role_promotion_requests_enabled! + + def index; end + + private + + def verify_role_promotion_requests_enabled! + render_404 unless promotion_management_applicable? + end + end +end diff --git a/ee/app/helpers/gitlab_subscriptions/promotion_management_helper.rb b/ee/app/helpers/gitlab_subscriptions/promotion_management_helper.rb new file mode 100644 index 0000000000000..f4d9ef05b47d0 --- /dev/null +++ b/ee/app/helpers/gitlab_subscriptions/promotion_management_helper.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module GitlabSubscriptions + module PromotionManagementHelper + include ::MemberManagement::PromotionManagementUtils + end +end diff --git a/ee/app/views/admin/role_promotion_requests/_role_promotion_requests.html.haml b/ee/app/views/admin/role_promotion_requests/_role_promotion_requests.html.haml new file mode 100644 index 0000000000000..07a7210bdb5ce --- /dev/null +++ b/ee/app/views/admin/role_promotion_requests/_role_promotion_requests.html.haml @@ -0,0 +1,2 @@ +#js-admin-users-role-promotion-requests-app{ data: admin_users_data_attributes(@users) } + = render Pajamas::SpinnerComponent.new(size: :lg, class: 'gl-my-7') diff --git a/ee/app/views/admin/role_promotion_requests/index.html.haml b/ee/app/views/admin/role_promotion_requests/index.html.haml new file mode 100644 index 0000000000000..ee030a4a23216 --- /dev/null +++ b/ee/app/views/admin/role_promotion_requests/index.html.haml @@ -0,0 +1,7 @@ +- page_title _("Users") + += render 'admin/users/tabs' + +.tab-content + .tab-pane.active + = render 'role_promotion_requests' diff --git a/ee/app/views/admin/users/_role_promotion_requests_tab.haml b/ee/app/views/admin/users/_role_promotion_requests_tab.haml new file mode 100644 index 0000000000000..01f1da13356f9 --- /dev/null +++ b/ee/app/views/admin/users/_role_promotion_requests_tab.haml @@ -0,0 +1,2 @@ +- if promotion_management_applicable? + = gl_tab_link_to s_('AdminUsers|Role Promotions'), admin_role_promotion_requests_path diff --git a/ee/config/routes/admin.rb b/ee/config/routes/admin.rb index 1feba56890f03..d9c3f67bc4f56 100644 --- a/ee/config/routes/admin.rb +++ b/ee/config/routes/admin.rb @@ -43,6 +43,7 @@ end resource :subscription, only: [:show] + resources :role_promotion_requests, only: :index get 'code_suggestions', to: 'code_suggestions#index' diff --git a/ee/spec/controllers/admin/role_promotion_requests_controller_spec.rb b/ee/spec/controllers/admin/role_promotion_requests_controller_spec.rb new file mode 100644 index 0000000000000..2cf7ca3589eda --- /dev/null +++ b/ee/spec/controllers/admin/role_promotion_requests_controller_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Admin::RolePromotionRequestsController, feature_category: :seat_cost_management do + let(:admin) { create(:admin) } + + let_it_be(:license) { create(:license, plan: License::ULTIMATE_PLAN) } + let(:feature_flag) { true } + let(:feature_settings) { true } + + before do + stub_feature_flags(member_promotion_management: feature_flag) + stub_application_setting(enable_member_promotion_management: feature_settings) + allow(License).to receive(:current).and_return(license) + sign_in(admin) + end + + describe 'GET #index' do + context 'when member promotion management is enabled' do + it 'renders the show template' do + get :index + + expect(response).to have_gitlab_http_status(:ok) + expect(response).to render_template('index') + end + end + + context 'when member promotion management is disabled' do + let(:feature_settings) { false } + + it 'returns 404' do + get :index + + expect(response).to have_gitlab_http_status(:not_found) + end + end + end +end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index ece506571f79f..05b577bfc4969 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -4325,6 +4325,9 @@ msgstr "" msgid "AdminUsers|Restore user access to the account, including web, Git and API." msgstr "" +msgid "AdminUsers|Role Promotions" +msgstr "" + msgid "AdminUsers|Search by name, email, or username" msgstr "" -- GitLab