Commit b1721584 authored by Simon Knox's avatar Simon Knox

Better check for feature using mixin

parent 39abea2b
<script> <script>
import { GlButton, GlButtonGroup } from '@gitlab/ui'; import { GlButton, GlButtonGroup } from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { __ } from '~/locale'; import { __ } from '~/locale';
import BurndownChart from './burndown_chart.vue'; import BurndownChart from './burndown_chart.vue';
...@@ -9,6 +10,7 @@ export default { ...@@ -9,6 +10,7 @@ export default {
GlButtonGroup, GlButtonGroup,
BurndownChart, BurndownChart,
}, },
mixins: [glFeatureFlagsMixin()],
props: { props: {
startDate: { startDate: {
type: String, type: String,
...@@ -32,12 +34,11 @@ export default { ...@@ -32,12 +34,11 @@ export default {
data() { data() {
return { return {
issuesSelected: true, issuesSelected: true,
burnupChartsEnabled: gon.features.burnupCharts,
}; };
}, },
computed: { computed: {
title() { title() {
return this.burnupChartsEnabled ? __('Charts') : __('Burndown chart'); return this.glFeatures.burnupCharts ? __('Charts') : __('Burndown chart');
}, },
issueButtonCategory() { issueButtonCategory() {
return this.issuesSelected ? 'primary' : 'secondary'; return this.issuesSelected ? 'primary' : 'secondary';
...@@ -47,11 +48,8 @@ export default { ...@@ -47,11 +48,8 @@ export default {
}, },
}, },
methods: { methods: {
showIssueCount() { setIssueSelected(selected) {
this.issuesSelected = true; this.issuesSelected = selected;
},
showIssueWeight() {
this.issuesSelected = false;
}, },
}, },
}; };
...@@ -67,7 +65,7 @@ export default { ...@@ -67,7 +65,7 @@ export default {
:category="issueButtonCategory" :category="issueButtonCategory"
variant="info" variant="info"
size="small" size="small"
@click="showIssueCount" @click="setIssueSelected(true)"
> >
{{ __('Issues') }} {{ __('Issues') }}
</gl-button> </gl-button>
...@@ -77,13 +75,13 @@ export default { ...@@ -77,13 +75,13 @@ export default {
variant="info" variant="info"
size="small" size="small"
data-qa-selector="weight_button" data-qa-selector="weight_button"
@click="showIssueWeight" @click="setIssueSelected(false)"
> >
{{ __('Issue weight') }} {{ __('Issue weight') }}
</gl-button> </gl-button>
</gl-button-group> </gl-button-group>
</div> </div>
<div v-if="burnupChartsEnabled" class="row"> <div v-if="glFeatures.burnupCharts" class="row">
<burndown-chart <burndown-chart
:start-date="startDate" :start-date="startDate"
:due-date="dueDate" :due-date="dueDate"
......
...@@ -20,29 +20,17 @@ describe('burndown_chart', () => { ...@@ -20,29 +20,17 @@ describe('burndown_chart', () => {
openIssuesWeight: [], openIssuesWeight: [],
}; };
const createComponent = (props = {}) => { const createComponent = ({ props = {}, featureEnabled = false } = {}) => {
wrapper = shallowMount(BurnCharts, { wrapper = shallowMount(BurnCharts, {
propsData: { propsData: {
...defaultProps, ...defaultProps,
...props, ...props,
}, },
}); provide: {
}; glFeatures: { burnupCharts: featureEnabled },
let origProp;
beforeEach(() => {
origProp = window.gon;
window.gon = {
features: {
burnupCharts: false,
}, },
};
});
afterEach(() => {
window.gon = origProp;
}); });
};
it('includes Issues and Issue weight buttons', () => { it('includes Issues and Issue weight buttons', () => {
createComponent(); createComponent();
...@@ -80,9 +68,7 @@ describe('burndown_chart', () => { ...@@ -80,9 +68,7 @@ describe('burndown_chart', () => {
describe('feature disabled', () => { describe('feature disabled', () => {
beforeEach(() => { beforeEach(() => {
window.gon.features.burnupCharts = false; createComponent({ featureEnabled: false });
createComponent();
}); });
it('does not reduce width of burndown chart', () => { it('does not reduce width of burndown chart', () => {
...@@ -97,9 +83,7 @@ describe('burndown_chart', () => { ...@@ -97,9 +83,7 @@ describe('burndown_chart', () => {
describe('feature enabled', () => { describe('feature enabled', () => {
beforeEach(() => { beforeEach(() => {
window.gon.features.burnupCharts = true; createComponent({ featureEnabled: true });
createComponent();
}); });
it('reduces width of burndown chart', () => { it('reduces width of burndown chart', () => {
......
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