Commit 183746af authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch...

Merge branch '271401-ensure-we-don-t-show-warning-when-there-are-1000-epics-on-a-roadmap' into 'master'

Ensure we don't show warning when there are <1000 epics on a roadmap

See merge request gitlab-org/gitlab!47884
parents 801d158b 778f6a29
...@@ -2,7 +2,6 @@ import FilteredSearchTokenKeysEpics from 'ee/filtered_search/filtered_search_tok ...@@ -2,7 +2,6 @@ import FilteredSearchTokenKeysEpics from 'ee/filtered_search/filtered_search_tok
import initEpicCreateApp from 'ee/epic/epic_bundle'; import initEpicCreateApp from 'ee/epic/epic_bundle';
import initRoadmap from 'ee/roadmap/roadmap_bundle'; import initRoadmap from 'ee/roadmap/roadmap_bundle';
import initFilteredSearch from '~/pages/search/init_filtered_search'; import initFilteredSearch from '~/pages/search/init_filtered_search';
import UserCallout from '~/user_callout';
initFilteredSearch({ initFilteredSearch({
page: 'epics', page: 'epics',
...@@ -14,6 +13,3 @@ initFilteredSearch({ ...@@ -14,6 +13,3 @@ initFilteredSearch({
}); });
initEpicCreateApp(true); initEpicCreateApp(true);
initRoadmap(); initRoadmap();
// eslint-disable-next-line no-new
new UserCallout({ className: 'js-epics-limit-callout' });
<script> <script>
import { GlLoadingIcon } from '@gitlab/ui'; import Cookies from 'js-cookie';
import { GlLoadingIcon, GlAlert } from '@gitlab/ui';
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import { __, s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import EpicsListEmpty from './epics_list_empty.vue'; import EpicsListEmpty from './epics_list_empty.vue';
...@@ -8,11 +10,23 @@ import RoadmapFilters from './roadmap_filters.vue'; ...@@ -8,11 +10,23 @@ import RoadmapFilters from './roadmap_filters.vue';
import RoadmapShell from './roadmap_shell.vue'; import RoadmapShell from './roadmap_shell.vue';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import { EXTEND_AS } from '../constants'; import {
EXTEND_AS,
EPICS_LIMIT_DISMISSED_COOKIE_NAME,
EPICS_LIMIT_DISMISSED_COOKIE_TIMEOUT,
} from '../constants';
export default { export default {
i18n: {
warningTitle: s__('GroupRoadmap|Some of your epics might not be visible'),
warningBody: s__(
'GroupRoadmap|Roadmaps can display up to 1,000 epics. These appear in your selected sort order.',
),
warningButtonLabel: __('Learn more'),
},
components: { components: {
EpicsListEmpty, EpicsListEmpty,
GlAlert,
GlLoadingIcon, GlLoadingIcon,
RoadmapFilters, RoadmapFilters,
RoadmapShell, RoadmapShell,
...@@ -32,6 +46,11 @@ export default { ...@@ -32,6 +46,11 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
isWarningDismissed: Cookies.get(EPICS_LIMIT_DISMISSED_COOKIE_NAME) === 'true',
};
},
computed: { computed: {
...mapState([ ...mapState([
'currentGroupId', 'currentGroupId',
...@@ -63,6 +82,9 @@ export default { ...@@ -63,6 +82,9 @@ export default {
const last = this.timeframe.length - 1; const last = this.timeframe.length - 1;
return this.timeframe[last]; return this.timeframe[last];
}, },
isWarningVisible() {
return !this.isWarningDismissed && this.epics.length > gon?.roadmap_epics_limit;
},
}, },
mounted() { mounted() {
this.fetchEpics(); this.fetchEpics();
...@@ -125,6 +147,12 @@ export default { ...@@ -125,6 +147,12 @@ export default {
.catch(() => {}); .catch(() => {});
}); });
}, },
dismissTooManyEpicsWarning() {
Cookies.set(EPICS_LIMIT_DISMISSED_COOKIE_NAME, 'true', {
expires: EPICS_LIMIT_DISMISSED_COOKIE_TIMEOUT,
});
this.isWarningDismissed = true;
},
}, },
}; };
</script> </script>
...@@ -132,6 +160,17 @@ export default { ...@@ -132,6 +160,17 @@ export default {
<template> <template>
<div class="roadmap-app-container gl-h-full"> <div class="roadmap-app-container gl-h-full">
<roadmap-filters v-if="showFilteredSearchbar" /> <roadmap-filters v-if="showFilteredSearchbar" />
<gl-alert
v-if="isWarningVisible"
variant="warning"
:title="$options.i18n.warningTitle"
:primary-button-text="$options.i18n.warningButtonLabel"
primary-button-link="https://docs.gitlab.com/ee/user/group/roadmap/"
data-testid="epics_limit_callout"
@dismiss="dismissTooManyEpicsWarning"
>
{{ $options.i18n.warningBody }}
</gl-alert>
<div :class="{ 'overflow-reset': epicsFetchResultEmpty }" class="roadmap-container"> <div :class="{ 'overflow-reset': epicsFetchResultEmpty }" class="roadmap-container">
<gl-loading-icon v-if="epicsFetchInProgress" class="gl-mt-5" size="md" /> <gl-loading-icon v-if="epicsFetchInProgress" class="gl-mt-5" size="md" />
<epics-list-empty <epics-list-empty
......
...@@ -63,3 +63,7 @@ export const EPIC_LEVEL_MARGIN = { ...@@ -63,3 +63,7 @@ export const EPIC_LEVEL_MARGIN = {
3: 'ml-8', 3: 'ml-8',
4: 'ml-10', 4: 'ml-10',
}; };
export const EPICS_LIMIT_DISMISSED_COOKIE_NAME = 'epics_limit_warning_dismissed';
export const EPICS_LIMIT_DISMISSED_COOKIE_TIMEOUT = 365;
...@@ -5,8 +5,6 @@ module Groups ...@@ -5,8 +5,6 @@ module Groups
include IssuableCollections include IssuableCollections
include EpicsActions include EpicsActions
EPICS_ROADMAP_LIMIT = 1000
before_action :check_epics_available! before_action :check_epics_available!
before_action :persist_roadmap_layout, only: [:show] before_action :persist_roadmap_layout, only: [:show]
before_action do before_action do
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
- @content_wrapper_class = "group-epics-roadmap-wrapper" - @content_wrapper_class = "group-epics-roadmap-wrapper"
- @content_class = "group-epics-roadmap" - @content_class = "group-epics-roadmap"
- breadcrumb_title _("Epics Roadmap") - breadcrumb_title _("Epics Roadmap")
- epics_limit_feature = 'epics_limit_warning_dismissed'
- sub_epics_feature_available = @group.feature_available?(:subepics) - sub_epics_feature_available = @group.feature_available?(:subepics)
- allow_sub_epics = sub_epics_feature_available ? 'true' : 'false' - allow_sub_epics = sub_epics_feature_available ? 'true' : 'false'
- page_title _("Epics Roadmap") - page_title _("Epics Roadmap")
...@@ -17,15 +16,6 @@ ...@@ -17,15 +16,6 @@
- if !Feature.enabled?(:async_filtering, @group) - if !Feature.enabled?(:async_filtering, @group)
= render 'shared/epic/search_bar', type: :epics, show_roadmap_presets: true, hide_extra_sort_options: true = render 'shared/epic/search_bar', type: :epics, show_roadmap_presets: true, hide_extra_sort_options: true
- if @epics_count > Groups::RoadmapController::EPICS_ROADMAP_LIMIT && show_callout?(epics_limit_feature)
.warning_message.mb-0.js-epics-limit-callout{ role: 'alert', data: { uid: epics_limit_feature } }
%button.js-close-callout.close{ type: "button", target: ".js-epics-limit-callout", "aria-hidden": true, "aria-label": _("Close") }
= sprite_icon("close")
%p
= s_("Some of your epics may not be visible. A roadmap is limited to the first 1,000 epics, in your selected sort order.")
%a.btn.btn-outline-warning#js-learn-more{ "href" => "https://docs.gitlab.com/ee/user/group/roadmap/" }
= _("Learn more")
#js-roadmap{ data: { epics_path: group_epics_path(@group, format: :json), #js-roadmap{ data: { epics_path: group_epics_path(@group, format: :json),
group_id: @group.id, group_id: @group.id,
full_path: @group.full_path, full_path: @group.full_path,
......
---
title: Ensure we don't show warning when there are <1000 epics on a roadmap
merge_request: 47884
author:
type: fixed
# frozen_string_literal: true
module EE
module Gitlab
module GonHelper
extend ::Gitlab::Utils::Override
override :add_gon_variables
def add_gon_variables
super
gon.roadmap_epics_limit = 1000
end
end
end
end
...@@ -156,36 +156,36 @@ RSpec.describe 'group epic roadmap', :js do ...@@ -156,36 +156,36 @@ RSpec.describe 'group epic roadmap', :js do
end end
end end
context 'when over 1000 epics exist for the group' do context 'when over 1000 epics match roadmap filters' do
before do before do
stub_const('Groups::RoadmapController::EPICS_ROADMAP_LIMIT', 1)
create_list(:epic, 2, group: group, start_date: 10.days.ago, end_date: 1.day.ago) create_list(:epic, 2, group: group, start_date: 10.days.ago, end_date: 1.day.ago)
visit group_roadmap_path(group) visit group_roadmap_path(group)
wait_for_requests wait_for_requests
execute_script("gon.roadmap_epics_limit = 1;")
end end
describe 'roadmap page' do describe 'roadmap page' do
it 'renders warning callout banner' do it 'renders warning callout banner' do
page.within('.content-wrapper .content') do page.within('.content-wrapper .content') do
expect(page).to have_selector('.js-epics-limit-callout', count: 1) expect(page).to have_selector('[data-testid="epics_limit_callout"]', count: 1)
expect(find('.js-epics-limit-callout')).to have_content 'Some of your epics may not be visible. A roadmap is limited to the first 1,000 epics, in your selected sort order.' expect(find('[data-testid="epics_limit_callout"]')).to have_content 'Some of your epics might not be visible Roadmaps can display up to 1,000 epics. These appear in your selected sort order.'
end end
page.within('.js-epics-limit-callout') do page.within('[data-testid="epics_limit_callout"]') do
expect(find_link('Learn more')[:href]).to eq("https://docs.gitlab.com/ee/user/group/roadmap/") expect(find_link('Learn more')[:href]).to eq("https://docs.gitlab.com/ee/user/group/roadmap/")
end end
end end
it 'is removed after dismissal and even after reload' do it 'is removed after dismissal and even after reload' do
page.within('.js-epics-limit-callout') do page.within('[data-testid="epics_limit_callout"]') do
find('.js-close-callout').click find('.gl-alert-dismiss').click
end end
expect(page).not_to have_selector('.js-epics-limit-callout') expect(page).not_to have_selector('[data-testid="epics_limit_callout"]')
refresh refresh
expect(page).not_to have_selector('.js-epics-limit-callout') expect(page).not_to have_selector('[data-testid="epics_limit_callout"]')
end end
end end
end end
......
import { GlLoadingIcon } from '@gitlab/ui'; import Cookies from 'js-cookie';
import { GlAlert, GlLoadingIcon } from '@gitlab/ui';
import { mount, shallowMount, createLocalVue } from '@vue/test-utils'; import { mount, shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex'; import Vuex from 'vuex';
import EpicsListEmpty from 'ee/roadmap/components/epics_list_empty.vue'; import EpicsListEmpty from 'ee/roadmap/components/epics_list_empty.vue';
...@@ -14,6 +15,7 @@ import { ...@@ -14,6 +15,7 @@ import {
basePath, basePath,
epicsPath, epicsPath,
mockFormattedEpic, mockFormattedEpic,
mockFormattedChildEpic2,
mockGroupId, mockGroupId,
mockNewEpicEndpoint, mockNewEpicEndpoint,
mockSortedBy, mockSortedBy,
...@@ -239,4 +241,29 @@ describe('RoadmapApp', () => { ...@@ -239,4 +241,29 @@ describe('RoadmapApp', () => {
}); });
}); });
}); });
describe('roadmap epics limit warning', () => {
beforeEach(() => {
wrapper = createComponent();
store.commit(types.RECEIVE_EPICS_SUCCESS, [mockFormattedEpic, mockFormattedChildEpic2]);
window.gon.roadmap_epics_limit = 1;
});
it('displays warning when epics limit is reached', () => {
expect(wrapper.find(GlAlert).exists()).toBe(true);
expect(wrapper.find(GlAlert).text()).toContain(
'Roadmaps can display up to 1,000 epics. These appear in your selected sort order.',
);
});
it('sets epics_limit_warning_dismissed cookie to true when dismissing alert', () => {
wrapper.find(GlAlert).vm.$emit('dismiss');
expect(Cookies.get('epics_limit_warning_dismissed')).toBe('true');
return wrapper.vm.$nextTick(() => {
expect(wrapper.find(GlAlert).exists()).toBe(false);
});
});
});
}); });
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe EE::Gitlab::GonHelper do
let(:helper) do
Class.new do
include Gitlab::GonHelper
def current_user
nil
end
end.new
end
describe '#add_gon_variables' do
let(:gon) { instance_double('gon').as_null_object }
before do
allow(helper).to receive(:gon).and_return(gon)
end
it 'includes ee exclusive settings' do
expect(gon).to receive(:roadmap_epics_limit=).with(1000)
helper.add_gon_variables
end
end
end
...@@ -83,3 +83,5 @@ module Gitlab ...@@ -83,3 +83,5 @@ module Gitlab
end end
end end
end end
Gitlab::GonHelper.prepend_if_ee('EE::Gitlab::GonHelper')
...@@ -13351,6 +13351,12 @@ msgstr "" ...@@ -13351,6 +13351,12 @@ msgstr ""
msgid "GroupRoadmap|No start date – %{dateWord}" msgid "GroupRoadmap|No start date – %{dateWord}"
msgstr "" msgstr ""
msgid "GroupRoadmap|Roadmaps can display up to 1,000 epics. These appear in your selected sort order."
msgstr ""
msgid "GroupRoadmap|Some of your epics might not be visible"
msgstr ""
msgid "GroupRoadmap|Something went wrong while fetching epics" msgid "GroupRoadmap|Something went wrong while fetching epics"
msgstr "" msgstr ""
...@@ -25368,9 +25374,6 @@ msgstr "" ...@@ -25368,9 +25374,6 @@ msgstr ""
msgid "Some of the designs you tried uploading did not change:" msgid "Some of the designs you tried uploading did not change:"
msgstr "" msgstr ""
msgid "Some of your epics may not be visible. A roadmap is limited to the first 1,000 epics, in your selected sort order."
msgstr ""
msgid "Someone edited the issue at the same time you did. Please check out %{linkStart}the issue%{linkEnd} and make sure your changes will not unintentionally remove theirs." msgid "Someone edited the issue at the same time you did. Please check out %{linkStart}the issue%{linkEnd} and make sure your changes will not unintentionally remove theirs."
msgstr "" 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