Commit f4f62025 authored by Serhii Yarynovskyi's avatar Serhii Yarynovskyi Committed by Douglas Barbosa Alexandre

Remove customize homepage banner

parent a7b7f5ae
<script>
import { GlBanner } from '@gitlab/ui';
import axios from '~/lib/utils/axios_utils';
import { s__ } from '~/locale';
import Tracking from '~/tracking';
const trackingMixin = Tracking.mixin();
export default {
components: {
GlBanner,
},
mixins: [trackingMixin],
inject: {
svgPath: {
default: '',
},
preferencesBehaviorPath: {
default: '',
},
calloutsPath: {
default: '',
},
calloutsFeatureId: {
default: '',
},
trackLabel: {
default: '',
},
},
i18n: {
title: s__('CustomizeHomepageBanner|Do you want to customize this page?'),
body: s__(
'CustomizeHomepageBanner|This page shows a list of your projects by default but it can be changed to show projects\' activity, groups, your to-do list, assigned issues, assigned merge requests, and more. You can change this under "Homepage content" in your preferences',
),
button_text: s__('CustomizeHomepageBanner|Go to preferences'),
},
data() {
return {
visible: true,
tracking: {
label: this.trackLabel,
},
};
},
created() {
this.$nextTick(() => {
this.addTrackingAttributesToButton();
});
},
mounted() {
this.trackOnShow();
},
methods: {
handleClose() {
axios
.post(this.calloutsPath, {
feature_name: this.calloutsFeatureId,
})
.catch((e) => {
// eslint-disable-next-line @gitlab/require-i18n-strings, no-console
console.error('Failed to dismiss banner.', e);
});
this.visible = false;
this.track('click_dismiss');
},
trackOnShow() {
if (this.visible) this.track('show_home_page_banner');
},
addTrackingAttributesToButton() {
// we can't directly add these on the button like we need to due to
// button not being modifiable currently
// https://gitlab.com/gitlab-org/gitlab-ui/-/blob/9209ec424e5cca14bc8a1b5c9fa12636d8c83dad/src/components/base/banner/banner.vue#L60
const button = this.$refs.banner.$el.querySelector(
`[href='${this.preferencesBehaviorPath}']`,
);
if (button) {
button.setAttribute('data-track-action', 'click_go_to_preferences');
button.setAttribute('data-track-label', this.trackLabel);
}
},
},
};
</script>
<template>
<gl-banner
v-if="visible"
ref="banner"
:title="$options.i18n.title"
:button-text="$options.i18n.button_text"
:button-link="preferencesBehaviorPath"
:svg-path="svgPath"
@close="handleClose"
>
<p>
{{ $options.i18n.body }}
</p>
</gl-banner>
</template>
import ProjectsList from '~/projects_list'; import ProjectsList from '~/projects_list';
import initCustomizeHomepageBanner from './init_customize_homepage_banner';
new ProjectsList(); // eslint-disable-line no-new new ProjectsList(); // eslint-disable-line no-new
initCustomizeHomepageBanner();
import Vue from 'vue';
import CustomizeHomepageBanner from './components/customize_homepage_banner.vue';
export default () => {
const el = document.querySelector('.js-customize-homepage-banner');
if (!el) {
return false;
}
return new Vue({
el,
provide: { ...el.dataset },
render: (createElement) => createElement(CustomizeHomepageBanner),
});
};
...@@ -6,7 +6,6 @@ module Users ...@@ -6,7 +6,6 @@ module Users
GCP_SIGNUP_OFFER = 'gcp_signup_offer' GCP_SIGNUP_OFFER = 'gcp_signup_offer'
SUGGEST_POPOVER_DISMISSED = 'suggest_popover_dismissed' SUGGEST_POPOVER_DISMISSED = 'suggest_popover_dismissed'
TABS_POSITION_HIGHLIGHT = 'tabs_position_highlight' TABS_POSITION_HIGHLIGHT = 'tabs_position_highlight'
CUSTOMIZE_HOMEPAGE = 'customize_homepage'
FEATURE_FLAGS_NEW_VERSION = 'feature_flags_new_version' FEATURE_FLAGS_NEW_VERSION = 'feature_flags_new_version'
REGISTRATION_ENABLED_CALLOUT = 'registration_enabled_callout' REGISTRATION_ENABLED_CALLOUT = 'registration_enabled_callout'
UNFINISHED_TAG_CLEANUP_CALLOUT = 'unfinished_tag_cleanup_callout' UNFINISHED_TAG_CLEANUP_CALLOUT = 'unfinished_tag_cleanup_callout'
...@@ -36,10 +35,6 @@ module Users ...@@ -36,10 +35,6 @@ module Users
!user_dismissed?(SUGGEST_POPOVER_DISMISSED) !user_dismissed?(SUGGEST_POPOVER_DISMISSED)
end end
def show_customize_homepage_banner?
current_user.default_dashboard? && !user_dismissed?(CUSTOMIZE_HOMEPAGE)
end
def show_feature_flags_new_version? def show_feature_flags_new_version?
!user_dismissed?(FEATURE_FLAGS_NEW_VERSION) !user_dismissed?(FEATURE_FLAGS_NEW_VERSION)
end end
......
...@@ -844,10 +844,6 @@ class User < ApplicationRecord ...@@ -844,10 +844,6 @@ class User < ApplicationRecord
# Instance methods # Instance methods
# #
def default_dashboard?
dashboard == self.class.column_defaults['dashboard']
end
def full_path def full_path
username username
end end
......
...@@ -24,7 +24,6 @@ module Users ...@@ -24,7 +24,6 @@ module Users
buy_pipeline_minutes_notification_dot: 19, # EE-only buy_pipeline_minutes_notification_dot: 19, # EE-only
personal_access_token_expiry: 21, # EE-only personal_access_token_expiry: 21, # EE-only
suggest_pipeline: 22, suggest_pipeline: 22,
customize_homepage: 23,
feature_flags_new_version: 24, feature_flags_new_version: 24,
registration_enabled_callout: 25, registration_enabled_callout: 25,
new_user_signups_cap_reached: 26, # EE-only new_user_signups_cap_reached: 26, # EE-only
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
= render_if_exists "shared/namespace_user_cap_reached_alert" = render_if_exists "shared/namespace_user_cap_reached_alert"
= render_if_exists "shared/new_user_signups_cap_reached_alert" = render_if_exists "shared/new_user_signups_cap_reached_alert"
= yield :page_level_alert = yield :page_level_alert
= yield :customize_homepage_banner
- unless @hide_breadcrumbs - unless @hide_breadcrumbs
= render "layouts/nav/breadcrumbs" = render "layouts/nav/breadcrumbs"
%div{ class: "#{(container_class unless @no_container)} #{@content_class}" } %div{ class: "#{(container_class unless @no_container)} #{@content_class}" }
......
- if show_customize_homepage_banner?
= content_for :customize_homepage_banner do
.gl-display-none.gl-md-display-block{ class: "gl-pt-6! gl-pb-2! #{(container_class unless @no_container)} #{@content_class}" }
.js-customize-homepage-banner{ data: { svg_path: image_path('illustrations/monitoring/getting_started.svg'),
preferences_behavior_path: profile_preferences_path(anchor: 'behavior'),
callouts_path: callouts_path,
callouts_feature_id: Users::CalloutsHelper::CUSTOMIZE_HOMEPAGE,
track_label: 'home_page' } }
= render template: 'dashboard/projects/index'
...@@ -17190,7 +17190,6 @@ Name of the feature that the callout is for. ...@@ -17190,7 +17190,6 @@ Name of the feature that the callout is for.
| <a id="usercalloutfeaturenameenumcanary_deployment"></a>`CANARY_DEPLOYMENT` | Callout feature name for canary_deployment. | | <a id="usercalloutfeaturenameenumcanary_deployment"></a>`CANARY_DEPLOYMENT` | Callout feature name for canary_deployment. |
| <a id="usercalloutfeaturenameenumcloud_licensing_subscription_activation_banner"></a>`CLOUD_LICENSING_SUBSCRIPTION_ACTIVATION_BANNER` | Callout feature name for cloud_licensing_subscription_activation_banner. | | <a id="usercalloutfeaturenameenumcloud_licensing_subscription_activation_banner"></a>`CLOUD_LICENSING_SUBSCRIPTION_ACTIVATION_BANNER` | Callout feature name for cloud_licensing_subscription_activation_banner. |
| <a id="usercalloutfeaturenameenumcluster_security_warning"></a>`CLUSTER_SECURITY_WARNING` | Callout feature name for cluster_security_warning. | | <a id="usercalloutfeaturenameenumcluster_security_warning"></a>`CLUSTER_SECURITY_WARNING` | Callout feature name for cluster_security_warning. |
| <a id="usercalloutfeaturenameenumcustomize_homepage"></a>`CUSTOMIZE_HOMEPAGE` | Callout feature name for customize_homepage. |
| <a id="usercalloutfeaturenameenumeoa_bronze_plan_banner"></a>`EOA_BRONZE_PLAN_BANNER` | Callout feature name for eoa_bronze_plan_banner. | | <a id="usercalloutfeaturenameenumeoa_bronze_plan_banner"></a>`EOA_BRONZE_PLAN_BANNER` | Callout feature name for eoa_bronze_plan_banner. |
| <a id="usercalloutfeaturenameenumfeature_flags_new_version"></a>`FEATURE_FLAGS_NEW_VERSION` | Callout feature name for feature_flags_new_version. | | <a id="usercalloutfeaturenameenumfeature_flags_new_version"></a>`FEATURE_FLAGS_NEW_VERSION` | Callout feature name for feature_flags_new_version. |
| <a id="usercalloutfeaturenameenumgcp_signup_offer"></a>`GCP_SIGNUP_OFFER` | Callout feature name for gcp_signup_offer. | | <a id="usercalloutfeaturenameenumgcp_signup_offer"></a>`GCP_SIGNUP_OFFER` | Callout feature name for gcp_signup_offer. |
...@@ -93,7 +93,7 @@ RSpec.describe RootController do ...@@ -93,7 +93,7 @@ RSpec.describe RootController do
it 'renders the default dashboard' do it 'renders the default dashboard' do
get :index get :index
expect(response).to render_template 'root/index' expect(response).to render_template 'dashboard/projects/index'
end end
end end
end end
......
...@@ -10406,15 +10406,6 @@ msgstr "" ...@@ -10406,15 +10406,6 @@ msgstr ""
msgid "Customize your pipeline configuration." msgid "Customize your pipeline configuration."
msgstr "" msgstr ""
msgid "CustomizeHomepageBanner|Do you want to customize this page?"
msgstr ""
msgid "CustomizeHomepageBanner|Go to preferences"
msgstr ""
msgid "CustomizeHomepageBanner|This page shows a list of your projects by default but it can be changed to show projects' activity, groups, your to-do list, assigned issues, assigned merge requests, and more. You can change this under \"Homepage content\" in your preferences"
msgstr ""
msgid "Cycle Time" msgid "Cycle Time"
msgstr "" msgstr ""
......
...@@ -131,28 +131,10 @@ RSpec.describe RootController do ...@@ -131,28 +131,10 @@ RSpec.describe RootController do
context 'who uses the default dashboard setting', :aggregate_failures do context 'who uses the default dashboard setting', :aggregate_failures do
render_views render_views
context 'with customize homepage banner' do
it 'renders the default dashboard' do it 'renders the default dashboard' do
get :index get :index
expect(response).to render_template 'root/index' expect(response).to render_template 'dashboard/projects/index'
expect(response.body).to have_css('.js-customize-homepage-banner')
end
end
context 'without customize homepage banner' do
before do
Users::DismissCalloutService.new(
container: nil, current_user: user, params: { feature_name: Users::CalloutsHelper::CUSTOMIZE_HOMEPAGE }
).execute
end
it 'renders the default dashboard' do
get :index
expect(response).to render_template 'root/index'
expect(response.body).not_to have_css('.js-customize-homepage-banner')
end
end end
end end
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Root path' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
before do
project.add_developer(user)
sign_in(user)
end
it 'shows the customize banner', :js do
visit root_path
expect(page).to have_content('Do you want to customize this page?')
end
end
import { GlBanner } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter';
import { mockTracking, unmockTracking, triggerEvent } from 'helpers/tracking_helper';
import axios from '~/lib/utils/axios_utils';
import CustomizeHomepageBanner from '~/pages/dashboard/projects/index/components/customize_homepage_banner.vue';
const svgPath = '/illustrations/background';
const provide = {
svgPath,
preferencesBehaviorPath: 'some/behavior/path',
calloutsPath: 'call/out/path',
calloutsFeatureId: 'some-feature-id',
trackLabel: 'home_page',
};
const createComponent = () => {
return shallowMount(CustomizeHomepageBanner, { provide, stubs: { GlBanner } });
};
describe('CustomizeHomepageBanner', () => {
let trackingSpy;
let mockAxios;
let wrapper;
beforeEach(() => {
mockAxios = new MockAdapter(axios);
document.body.dataset.page = 'some:page';
trackingSpy = mockTracking('_category_', undefined, jest.spyOn);
wrapper = createComponent();
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
mockAxios.restore();
unmockTracking();
});
it('should render the banner when not dismissed', () => {
expect(wrapper.find(GlBanner).exists()).toBe(true);
});
it('should close the banner when dismiss is clicked', async () => {
mockAxios.onPost(provide.calloutsPath).replyOnce(200);
expect(wrapper.find(GlBanner).exists()).toBe(true);
wrapper.find(GlBanner).vm.$emit('close');
await wrapper.vm.$nextTick();
expect(wrapper.find(GlBanner).exists()).toBe(false);
});
it('includes the body text from options', () => {
expect(wrapper.html()).toContain(wrapper.vm.$options.i18n.body);
});
describe('tracking', () => {
const preferencesTrackingEvent = 'click_go_to_preferences';
const mockTrackingOnWrapper = () => {
unmockTracking();
trackingSpy = mockTracking('_category_', wrapper.element, jest.spyOn);
};
it('sets the needed data attributes for tracking button', async () => {
await wrapper.vm.$nextTick();
const button = wrapper.find(`[href='${wrapper.vm.preferencesBehaviorPath}']`);
expect(button.attributes('data-track-action')).toEqual(preferencesTrackingEvent);
expect(button.attributes('data-track-label')).toEqual(provide.trackLabel);
});
it('sends a tracking event when the banner is shown', () => {
const trackCategory = undefined;
const trackEvent = 'show_home_page_banner';
expect(trackingSpy).toHaveBeenCalledWith(trackCategory, trackEvent, {
label: provide.trackLabel,
});
});
it('sends a tracking event when the banner is dismissed', async () => {
mockTrackingOnWrapper();
mockAxios.onPost(provide.calloutsPath).replyOnce(200);
const trackCategory = undefined;
const trackEvent = 'click_dismiss';
wrapper.find(GlBanner).vm.$emit('close');
await wrapper.vm.$nextTick();
expect(trackingSpy).toHaveBeenCalledWith(trackCategory, trackEvent, {
label: provide.trackLabel,
});
});
it('sends a tracking event when the button is clicked', async () => {
mockTrackingOnWrapper();
mockAxios.onPost(provide.calloutsPath).replyOnce(200);
const button = wrapper.find(`[href='${wrapper.vm.preferencesBehaviorPath}']`);
triggerEvent(button.element);
await wrapper.vm.$nextTick();
expect(trackingSpy).toHaveBeenCalledWith('_category_', preferencesTrackingEvent, {
label: provide.trackLabel,
});
});
});
});
...@@ -61,36 +61,6 @@ RSpec.describe Users::CalloutsHelper do ...@@ -61,36 +61,6 @@ RSpec.describe Users::CalloutsHelper do
end end
end end
describe '.show_customize_homepage_banner?' do
subject { helper.show_customize_homepage_banner? }
context 'when user has not dismissed' do
before do
allow(helper).to receive(:user_dismissed?).with(described_class::CUSTOMIZE_HOMEPAGE) { false }
end
context 'when user is on the default dashboard' do
it { is_expected.to be true }
end
context 'when user is not on the default dashboard' do
before do
user.dashboard = 'stars'
end
it { is_expected.to be false }
end
end
context 'when user dismissed' do
before do
allow(helper).to receive(:user_dismissed?).with(described_class::CUSTOMIZE_HOMEPAGE) { true }
end
it { is_expected.to be false }
end
end
describe '.render_flash_user_callout' do describe '.render_flash_user_callout' do
it 'renders the flash_user_callout partial' do it 'renders the flash_user_callout partial' do
expect(helper).to receive(:render) expect(helper).to receive(:render)
......
...@@ -6138,20 +6138,6 @@ RSpec.describe User do ...@@ -6138,20 +6138,6 @@ RSpec.describe User do
end end
end end
describe '#default_dashboard?' do
it 'is the default dashboard' do
user = build(:user)
expect(user.default_dashboard?).to be true
end
it 'is not the default dashboard' do
user = build(:user, dashboard: 'stars')
expect(user.default_dashboard?).to be false
end
end
describe '.dormant' do describe '.dormant' do
it 'returns dormant users' do it 'returns dormant users' do
freeze_time do freeze_time do
......
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