Commit b1721584 authored by Simon Knox's avatar Simon Knox

Better check for feature using mixin

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