Commit 627691b0 authored by James Lopez's avatar James Lopez

Merge branch '13233-move-trials-banner-to-group-detail-page' into 'master'

[Frontend] Update trial's banner location for groups

See merge request gitlab-org/gitlab!18524
parents 3abf3991 a1ce76b2
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
= auto_discovery_link_tag(:atom, group_url(@group, rss_url_options), title: "#{@group.name} activity") = auto_discovery_link_tag(:atom, group_url(@group, rss_url_options), title: "#{@group.name} activity")
%div{ class: [("limit-container-width" unless fluid_layout)] } %div{ class: [("limit-container-width" unless fluid_layout)] }
= render_if_exists 'trials/banner', namespace: @group
= render 'groups/home_panel' = render 'groups/home_panel'
.groups-listing{ data: { endpoints: { default: group_children_path(@group, format: :json), shared: group_shared_projects_path(@group, format: :json) } } } .groups-listing{ data: { endpoints: { default: group_children_path(@group, format: :json), shared: group_shared_projects_path(@group, format: :json) } } }
......
...@@ -66,4 +66,8 @@ module BillingPlansHelper ...@@ -66,4 +66,8 @@ module BillingPlansHelper
root = namespace.has_parent? ? namespace.root_ancestor : namespace root = namespace.has_parent? ? namespace.root_ancestor : namespace
root.trial_active? root.trial_active?
end end
def namespace_for_user?(namespace)
namespace == current_user.namespace
end
end end
...@@ -2,20 +2,12 @@ ...@@ -2,20 +2,12 @@
.mb-2= render_billings_gold_trial(current_user, parent_group || namespace) .mb-2= render_billings_gold_trial(current_user, parent_group || namespace)
- if show_trial_banner?(parent_group || namespace) - if namespace_for_user?(namespace)
.user-callout = render_if_exists 'trials/banner', namespace: namespace
.alert.bordered-box.landing.justify-content-start.pl-md-8
%button{ type:"button", class:"btn btn-default close", "data-dismiss":"alert", "aria-label": _("Close") }
= sprite_icon('close', size: 16)
.svg-container
= custom_icon('trial_activated_banner')
.user-callout-copy
%h4
= s_("BillingPlans|Congratulations, your new trial is activated")
.billing-plan-header.content-block.center .billing-plan-header.content-block.center
.billing-plan-logo .billing-plan-logo
- if namespace == current_user.namespace - if namespace_for_user?(namespace)
.avatar-container.s96.home-panel-avatar.append-right-default.float-none.mx-auto.mb-4.mt-1 .avatar-container.s96.home-panel-avatar.append-right-default.float-none.mx-auto.mb-4.mt-1
= user_avatar_without_link(user: current_user, class: 'mb-3', size: 96) = user_avatar_without_link(user: current_user, class: 'mb-3', size: 96)
- elsif @group.avatar_url.present? - elsif @group.avatar_url.present?
...@@ -25,7 +17,7 @@ ...@@ -25,7 +17,7 @@
= group_icon(@group, class: 'avatar avatar-tile s96', width: 96, height: 96, alt: @group.name) = group_icon(@group, class: 'avatar avatar-tile s96', width: 96, height: 96, alt: @group.name)
%h4 %h4
- if namespace == current_user.namespace - if namespace_for_user?(namespace)
= s_("BillingPlans|@%{user_name} you are currently using the %{plan_name} plan.").html_safe % { user_name: current_user.username, plan_name: plan.code.titleize } = s_("BillingPlans|@%{user_name} you are currently using the %{plan_name} plan.").html_safe % { user_name: current_user.username, plan_name: plan.code.titleize }
- else - else
= s_("BillingPlans|%{group_name} is currently using the %{plan_name} plan.").html_safe % { group_name: namespace.full_name, plan_name: plan.code.titleize } = s_("BillingPlans|%{group_name} is currently using the %{plan_name} plan.").html_safe % { group_name: namespace.full_name, plan_name: plan.code.titleize }
......
- return unless show_trial_banner?(namespace)
.user-callout
.alert.bordered-box.landing.justify-content-start.pl-md-8
%button{ type:"button", class:"btn btn-default close", "data-dismiss":"alert", "aria-label": _("Close") }
= sprite_icon('close', size: 16)
.svg-container
= custom_icon('trial_activated_banner')
.user-callout-copy
%h4
= s_("BillingPlans|Congratulations, your new trial is activated")
# frozen_string_literal: true
require 'spec_helper'
describe 'Show trial banner', :js do
include StubRequests
let!(:user) { create(:user) }
let!(:group) { create(:group) }
let!(:bronze_plan) { create(:bronze_plan) }
let(:plans_data) do
JSON.parse(File.read(Rails.root.join('ee/spec/fixtures/gitlab_com_plans.json'))).map do |data|
data.deep_symbolize_keys
end
end
before do
stub_application_setting(check_namespace_plan: true)
allow(Gitlab).to receive(:com?).and_return(true).at_least(:once)
stub_full_request("#{EE::SUBSCRIPTIONS_URL}/gitlab_plans?plan=bronze")
.to_return(status: 200, body: plans_data.to_json)
group.add_owner(user)
create(:gitlab_subscription, namespace: user.namespace, hosted_plan: bronze_plan, trial: true, trial_ends_on: Date.current + 1.month)
create(:gitlab_subscription, namespace: group, hosted_plan: bronze_plan, trial: true, trial_ends_on: Date.current + 1.month)
gitlab_sign_in(user)
end
context "when user's trial is active" do
it 'renders congratulations banner for user in profile billing page' do
visit profile_billings_path + '?trial=true'
expect(page).to have_content('Congratulations, your new trial is activated')
end
end
context "when group's trial is active" do
it 'renders congratulations banner for group in group details page' do
visit group_path(group, trial: true)
expect(find('.user-callout').text).to have_content('Congratulations, your new trial is activated')
end
it 'does not render congratulations banner for group in group billing page' do
visit group_billings_path(group, trial: true)
expect(page).not_to have_content('Congratulations, your new trial is activated')
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment