Commit d1daccdb authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Adds a stub filter bar component

Adds a placeholder filter bar component
and some basic specs to check it renders
parent a76a8d62
...@@ -19,6 +19,7 @@ import StageTableNav from './stage_table_nav.vue'; ...@@ -19,6 +19,7 @@ import StageTableNav from './stage_table_nav.vue';
import CustomStageForm from './custom_stage_form.vue'; import CustomStageForm from './custom_stage_form.vue';
import PathNavigation from './path_navigation.vue'; import PathNavigation from './path_navigation.vue';
import MetricCard from '../../shared/components/metric_card.vue'; import MetricCard from '../../shared/components/metric_card.vue';
import FilterBar from './filter_bar.vue';
export default { export default {
name: 'CycleAnalytics', name: 'CycleAnalytics',
...@@ -37,6 +38,7 @@ export default { ...@@ -37,6 +38,7 @@ export default {
StageTableNav, StageTableNav,
PathNavigation, PathNavigation,
MetricCard, MetricCard,
FilterBar,
}, },
mixins: [glFeatureFlagsMixin(), UrlSyncMixin], mixins: [glFeatureFlagsMixin(), UrlSyncMixin],
props: { props: {
...@@ -56,6 +58,14 @@ export default { ...@@ -56,6 +58,14 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
milestonesPath: {
type: String,
required: true,
},
labelsPath: {
type: String,
required: true,
},
}, },
computed: { computed: {
...mapState([ ...mapState([
...@@ -119,12 +129,25 @@ export default { ...@@ -119,12 +129,25 @@ export default {
stageCount() { stageCount() {
return this.activeStages.length; return this.activeStages.length;
}, },
hasProject() {
return this.selectedProjectIds.length;
},
}, },
mounted() { mounted() {
const {
glFeatures: {
cycleAnalyticsScatterplotEnabled: hasDurationChart,
cycleAnalyticsScatterplotMedianEnabled: hasDurationChartMedian,
valueStreamAnalyticsPathNavigation: hasPathNavigation,
valueStreamAnalyticsFilterBar: hasFilterBar,
},
} = this;
this.setFeatureFlags({ this.setFeatureFlags({
hasDurationChart: this.glFeatures.cycleAnalyticsScatterplotEnabled, hasDurationChart,
hasDurationChartMedian: this.glFeatures.cycleAnalyticsScatterplotMedianEnabled, hasDurationChartMedian,
hasPathNavigation: this.glFeatures.valueStreamAnalyticsPathNavigation, hasPathNavigation,
hasFilterBar,
}); });
}, },
methods: { methods: {
...@@ -232,6 +255,11 @@ export default { ...@@ -232,6 +255,11 @@ export default {
:default-projects="selectedProjects" :default-projects="selectedProjects"
@selected="onProjectsSelect" @selected="onProjectsSelect"
/> />
<filter-bar
v-if="featureFlags.hasFilterBar"
class="js-filter-bar filtered-search-box mx-2 gl-display-none"
:disabled="!hasProject"
/>
<div <div
v-if="shouldDisplayFilters" v-if="shouldDisplayFilters"
class="ml-0 ml-md-auto mt-2 mt-md-0 d-flex flex-column flex-md-row align-items-md-center justify-content-md-end" class="ml-0 ml-md-auto mt-2 mt-md-0 d-flex flex-column flex-md-row align-items-md-center justify-content-md-end"
......
<script>
export default {
name: 'FilterBar',
components: {},
props: {
disabled: {
type: Boolean,
required: false,
default: false,
},
},
};
</script>
<template>
<div></div>
</template>
...@@ -6,9 +6,17 @@ import { parseBoolean } from '~/lib/utils/common_utils'; ...@@ -6,9 +6,17 @@ import { parseBoolean } from '~/lib/utils/common_utils';
export default () => { export default () => {
const el = document.querySelector('#js-cycle-analytics-app'); const el = document.querySelector('#js-cycle-analytics-app');
const { emptyStateSvgPath, noDataSvgPath, noAccessSvgPath, hideGroupDropDown } = el.dataset; const {
emptyStateSvgPath,
noDataSvgPath,
noAccessSvgPath,
hideGroupDropDown,
milestonesPath = '',
labelsPath = '',
} = el.dataset;
const initialData = buildCycleAnalyticsInitialData(el.dataset); const initialData = buildCycleAnalyticsInitialData(el.dataset);
const store = createStore(); const store = createStore();
store.dispatch('initializeCycleAnalytics', initialData); store.dispatch('initializeCycleAnalytics', initialData);
...@@ -23,6 +31,8 @@ export default () => { ...@@ -23,6 +31,8 @@ export default () => {
noDataSvgPath, noDataSvgPath,
noAccessSvgPath, noAccessSvgPath,
hideGroupDropDown: parseBoolean(hideGroupDropDown), hideGroupDropDown: parseBoolean(hideGroupDropDown),
milestonesPath,
labelsPath,
}, },
}), }),
}); });
......
...@@ -159,7 +159,7 @@ RSpec.describe 'Group Value Stream Analytics', :js do ...@@ -159,7 +159,7 @@ RSpec.describe 'Group Value Stream Analytics', :js do
end end
it 'does not show the filter bar' do it 'does not show the filter bar' do
expect(page).to have_selector(filter_bar_selector, visible: false) expect(page).not_to have_selector(filter_bar_selector)
end end
context 'with path navigation feature flag enabled' do context 'with path navigation feature flag enabled' do
...@@ -180,7 +180,7 @@ RSpec.describe 'Group Value Stream Analytics', :js do ...@@ -180,7 +180,7 @@ RSpec.describe 'Group Value Stream Analytics', :js do
end end
it 'shows the filter bar' do it 'shows the filter bar' do
expect(page).to have_selector(filter_bar_selector, visible: true) expect(page).to have_selector(filter_bar_selector, visible: :hidden)
end end
end end
end end
......
...@@ -14,6 +14,7 @@ import StageTable from 'ee/analytics/cycle_analytics/components/stage_table.vue' ...@@ -14,6 +14,7 @@ import StageTable from 'ee/analytics/cycle_analytics/components/stage_table.vue'
import StageTableNav from 'ee/analytics/cycle_analytics/components/stage_table_nav.vue'; import StageTableNav from 'ee/analytics/cycle_analytics/components/stage_table_nav.vue';
import StageNavItem from 'ee/analytics/cycle_analytics/components/stage_nav_item.vue'; import StageNavItem from 'ee/analytics/cycle_analytics/components/stage_nav_item.vue';
import AddStageButton from 'ee/analytics/cycle_analytics/components/add_stage_button.vue'; import AddStageButton from 'ee/analytics/cycle_analytics/components/add_stage_button.vue';
import FilterBar from 'ee/analytics/cycle_analytics/components/filter_bar.vue';
import DurationChart from 'ee/analytics/cycle_analytics/components/duration_chart.vue'; import DurationChart from 'ee/analytics/cycle_analytics/components/duration_chart.vue';
import Daterange from 'ee/analytics/shared/components/daterange.vue'; import Daterange from 'ee/analytics/shared/components/daterange.vue';
import TypeOfWorkCharts from 'ee/analytics/cycle_analytics/components/type_of_work_charts.vue'; import TypeOfWorkCharts from 'ee/analytics/cycle_analytics/components/type_of_work_charts.vue';
...@@ -29,6 +30,8 @@ import UrlSyncMixin from 'ee/analytics/shared/mixins/url_sync_mixin'; ...@@ -29,6 +30,8 @@ import UrlSyncMixin from 'ee/analytics/shared/mixins/url_sync_mixin';
const noDataSvgPath = 'path/to/no/data'; const noDataSvgPath = 'path/to/no/data';
const noAccessSvgPath = 'path/to/no/access'; const noAccessSvgPath = 'path/to/no/access';
const emptyStateSvgPath = 'path/to/empty/state'; const emptyStateSvgPath = 'path/to/empty/state';
const milestonesPath = '/some/milestones/endpoint';
const labelsPath = '/some/labels/endpoint';
const hideGroupDropDown = false; const hideGroupDropDown = false;
const selectedGroup = convertObjectPropsToCamelCase(mockData.group); const selectedGroup = convertObjectPropsToCamelCase(mockData.group);
...@@ -53,6 +56,7 @@ function createComponent({ ...@@ -53,6 +56,7 @@ function createComponent({
withStageSelected = false, withStageSelected = false,
scatterplotEnabled = true, scatterplotEnabled = true,
pathNavigationEnabled = false, pathNavigationEnabled = false,
filterBarEnabled = false,
props = {}, props = {},
} = {}) { } = {}) {
const func = shallow ? shallowMount : mount; const func = shallow ? shallowMount : mount;
...@@ -64,6 +68,8 @@ function createComponent({ ...@@ -64,6 +68,8 @@ function createComponent({
emptyStateSvgPath, emptyStateSvgPath,
noDataSvgPath, noDataSvgPath,
noAccessSvgPath, noAccessSvgPath,
milestonesPath,
labelsPath,
baseStagesEndpoint: mockData.endpoints.baseStagesEndpoint, baseStagesEndpoint: mockData.endpoints.baseStagesEndpoint,
hideGroupDropDown, hideGroupDropDown,
...props, ...props,
...@@ -72,6 +78,7 @@ function createComponent({ ...@@ -72,6 +78,7 @@ function createComponent({
glFeatures: { glFeatures: {
cycleAnalyticsScatterplotEnabled: scatterplotEnabled, cycleAnalyticsScatterplotEnabled: scatterplotEnabled,
valueStreamAnalyticsPathNavigation: pathNavigationEnabled, valueStreamAnalyticsPathNavigation: pathNavigationEnabled,
valueStreamAnalyticsFilterBar: filterBarEnabled,
}, },
}, },
...opts, ...opts,
...@@ -150,6 +157,10 @@ describe('Cycle Analytics component', () => { ...@@ -150,6 +157,10 @@ describe('Cycle Analytics component', () => {
expect(wrapper.find(AddStageButton).exists()).toBe(flag); expect(wrapper.find(AddStageButton).exists()).toBe(flag);
}; };
const displaysFilterBar = flag => {
expect(wrapper.find(FilterBar).exists()).toBe(flag);
};
beforeEach(() => { beforeEach(() => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
wrapper = createComponent(); wrapper = createComponent();
...@@ -294,6 +305,10 @@ describe('Cycle Analytics component', () => { ...@@ -294,6 +305,10 @@ describe('Cycle Analytics component', () => {
}); });
}); });
it('displays the duration chart', () => {
displaysDurationChart(true);
});
describe('path navigation', () => { describe('path navigation', () => {
describe('disabled', () => { describe('disabled', () => {
it('does not display the path navigation', () => { it('does not display the path navigation', () => {
...@@ -315,8 +330,25 @@ describe('Cycle Analytics component', () => { ...@@ -315,8 +330,25 @@ describe('Cycle Analytics component', () => {
}); });
}); });
it('displays the duration chart', () => { describe('filter bar', () => {
displaysDurationChart(true); describe('disabled', () => {
it('does not display the filter bar', () => {
displaysFilterBar(false);
});
});
describe('enabled', () => {
beforeEach(() => {
wrapper = createComponent({
withStageSelected: true,
filterBarEnabled: true,
});
});
it('displays the filter bar', () => {
displaysFilterBar(true);
});
});
}); });
describe('StageTable', () => { describe('StageTable', () => {
......
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