Commit 5a40ef3f authored by Alper Akgun's avatar Alper Akgun Committed by Phil Hughes

Update Issue Weights Upgrade CTAs

This is a second iteration on the issue weight upgrade CTA
It tests also dismissable alerts
parent 619b7728
......@@ -21,16 +21,17 @@ export default class UserCallout {
dismissCallout(e) {
const $currentTarget = $(e.currentTarget);
const cookieOptions = {};
if (!$currentTarget.hasClass('js-close-session')) {
cookieOptions.expires = 365;
}
if (this.options.setCalloutPerProject) {
Cookies.set(this.cookieName, 'true', {
expires: 365,
path: this.userCalloutBody.data('projectPath'),
});
} else {
Cookies.set(this.cookieName, 'true', { expires: 365 });
cookieOptions.path = this.userCalloutBody.data('projectPath');
}
Cookies.set(this.cookieName, 'true', cookieOptions);
if ($currentTarget.hasClass('close') || $currentTarget.hasClass('js-close')) {
this.userCalloutBody.remove();
}
......
- promotion_feature = 'promote_weight_sidebar_dismissed'
- trial_cta = Feature.enabled?(:promotion_issue_weight_trial_cta, current_user)
- session_dismissal = Feature.enabled?(:promotion_issue_weight_session_dismiss, current_user)
- tracking_options = { track_label: trial_cta.to_s, track_property: session_dismissal.to_s }
- if show_promotions? && show_callout?(promotion_feature)
.block.js-weight-sidebar-callout.promotion-issue-sidebar{ data: { uid: promotion_feature } }
......@@ -10,7 +13,7 @@
= s_('Promotions|Weight')
.hide-collapsed.js-toggle-container.promotion-issue-weight-sidebar-message
= s_('Promotions|This feature is locked.')
%a.btn-link.js-toggle-button.js-weight-sidebar-callout{ href: '#' }
%a.btn-link.js-toggle-button.js-weight-sidebar-callout{ href: '#', data: { track_event: 'click_callout' }.merge(tracking_options) }
= s_('Promotions|Learn more')
= icon('chevron-down')
.js-toggle-content{ style:'display: none' }
......@@ -24,10 +27,13 @@
%p
- if Gitlab::CurrentSettings.should_check_namespace_plan?
- subscription_link_url = "#{EE::SUBSCRIPTIONS_URL}/plans"
- subscription_link_start = '<a href="%{url}" target="_blank" class="btn-link">'.html_safe % { url: subscription_link_url }
- subscription_link_start = '<a href="%{url}" target="_blank" class="btn-link tr-issue-weights-bronze-features-cta">'.html_safe % { url: subscription_link_url }
= s_("Promotions|See the other features in the %{subscription_link_start}bronze plan%{subscription_link_end}").html_safe % { subscription_link_start: subscription_link_start, subscription_link_end: '</a>'.html_safe }
- else
= s_('Promotions|Improve issues management with Issue weight and GitLab Enterprise Edition.')
%div
= render 'shared/promotions/promotion_link_project', short_form: true, target_blank: true
= link_to s_("Promotions|Don't show me this again"), '#', class: ['btn', 'js-close', 'js-close-callout', 'gl-mt-3']
= render 'shared/promotions/promotion_link_project', short_form: true, target_blank: !trial_cta, trial_cta: trial_cta
- if session_dismissal
= link_to s_("Promotions|Not now, thanks!"), '#', class: ['btn', 'js-close', 'js-close-callout', 'gl-mt-3', 'js-close-session', 'tr-issue-weights-not-now-cta'], data: { track_event: 'click_notnow' }.merge(tracking_options)
- else
= link_to s_("Promotions|Don't show me this again"), '#', class: ['btn', 'js-close', 'js-close-callout', 'gl-mt-3', 'tr-issue-weights-dont-show-me-again'], data: { track_event: 'click_dontshow' }.merge(tracking_options)
- short_form = local_assigns.fetch :short_form, false
- target_blank = local_assigns.fetch :target_blank, false
- trial_cta = local_assigns.fetch :trial_cta, false
- if Gitlab::CurrentSettings.should_check_namespace_plan?
- namespace = @project&.namespace || @group
- if can?(current_user, :admin_namespace, namespace)
- if trial_cta
= link_to s_('Promotions|Try it for free'), new_trial_registration_path, class: 'btn btn-primary issue-weights-trial-cta', target: target_blank ? '_blank' : '_self'
- else
- current_group = @project&.group || @group
= link_to s_('Promotions|Upgrade your plan'), upgrade_plan_path(current_group), class: 'btn btn-primary', target: target_blank ? '_blank' : '_self'
= link_to s_('Promotions|Upgrade your plan'), upgrade_plan_path(current_group), class: 'btn btn-primary issue-weights-upgrade-cta', target: target_blank ? '_blank' : '_self'
- elsif namespace.is_a?(Group)
%p= s_('Promotions|Contact an owner of group %{namespace_name} to upgrade the plan.') % { namespace_name: namespace.name }
- else
......
......@@ -12,6 +12,11 @@ describe 'Promotions', :js do
let!(:issue) { create(:issue, project: project, author: user) }
let(:otherproject) { create(:project, :repository, namespace: otherdeveloper.namespace) }
before do
stub_feature_flags promotion_issue_weight_trial_cta: false,
promotion_issue_weight_session_dismiss: false
end
describe 'if you have a license' do
before do
project.add_maintainer(user)
......@@ -337,6 +342,41 @@ describe 'Promotions', :js do
expect(page).to have_selector('.js-weight-sidebar-callout')
expect(page).to have_selector('.promotion-issue-sidebar-message', visible: false)
end
context 'when checking namespace plans' do
before do
stub_application_setting(check_namespace_plan: true)
group.add_owner(user)
end
it 'appears on the page', :js do
visit project_issue_path(project, issue)
wait_for_requests
find('.btn-link.js-toggle-button.js-weight-sidebar-callout').click
expect(find('.issue-weights-upgrade-cta')).to have_content 'Upgrade your plan'
expect(find('.js-close.js-close-callout.tr-issue-weights-dont-show-me-again')).to have_content "Don't show me this again"
end
context 'when promotion feature flags are enabled' do
before do
stub_feature_flags promotion_issue_weight_trial_cta: true,
promotion_issue_weight_session_dismiss: true
end
it 'appears on the page', :js do
visit project_issue_path(project, issue)
wait_for_requests
find('.btn-link.js-toggle-button.js-weight-sidebar-callout').click
expect(find('.issue-weights-trial-cta')).to have_content 'Try it for free'
expect(find('.js-close-callout.js-close-session.tr-issue-weights-not-now-cta')).to have_content 'Not now, thanks!'
end
end
end
end
describe 'for issue templates', :js do
......
......@@ -17606,6 +17606,9 @@ msgstr ""
msgid "Promotions|Learn more"
msgstr ""
msgid "Promotions|Not now, thanks!"
msgstr ""
msgid "Promotions|See the other features in the %{subscription_link_start}bronze plan%{subscription_link_end}"
msgstr ""
......@@ -17618,6 +17621,9 @@ msgstr ""
msgid "Promotions|Track activity with Contribution Analytics."
msgstr ""
msgid "Promotions|Try it for free"
msgstr ""
msgid "Promotions|Upgrade plan"
msgstr ""
......
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