Commit 0d3ad66b authored by Simon Knox's avatar Simon Knox

Add burnup feature flag and column for chart

Add a wrapper charts component, so I can add a burnup chart to it
parent 2e147c78
...@@ -5,6 +5,9 @@ class Groups::MilestonesController < Groups::ApplicationController ...@@ -5,6 +5,9 @@ class Groups::MilestonesController < Groups::ApplicationController
before_action :milestone, only: [:edit, :show, :update, :merge_requests, :participants, :labels, :destroy] before_action :milestone, only: [:edit, :show, :update, :merge_requests, :participants, :labels, :destroy]
before_action :authorize_admin_milestones!, only: [:edit, :new, :create, :update, :destroy] before_action :authorize_admin_milestones!, only: [:edit, :new, :create, :update, :destroy]
before_action do
push_frontend_feature_flag(:burnup_charts, group)
end
def index def index
respond_to do |format| respond_to do |format|
......
...@@ -6,6 +6,9 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -6,6 +6,9 @@ class Projects::MilestonesController < Projects::ApplicationController
before_action :check_issuables_available! before_action :check_issuables_available!
before_action :milestone, only: [:edit, :update, :destroy, :show, :merge_requests, :participants, :labels, :promote] before_action :milestone, only: [:edit, :update, :destroy, :show, :merge_requests, :participants, :labels, :promote]
before_action do
push_frontend_feature_flag(:burnup_charts, project)
end
# Allow read any milestone # Allow read any milestone
before_action :authorize_read_milestone! before_action :authorize_read_milestone!
......
<script>
import { GlDeprecatedButton, GlButtonGroup } from '@gitlab/ui';
import { __ } from '~/locale';
import BurndownChart from './burndown_chart.vue';
export default {
burnupChartsEnabled: gon.features.burnupCharts,
components: {
GlDeprecatedButton,
GlButtonGroup,
BurndownChart,
},
props: {
startDate: {
type: String,
required: true,
},
dueDate: {
type: String,
required: true,
},
openIssuesCount: {
type: Array,
required: false,
default: () => [],
},
openIssuesWeight: {
type: Array,
required: false,
default: () => [],
},
},
data() {
return {
issuesSelected: true,
};
},
computed: {
title() {
return this.$options.burnupChartsEnabled ? __('Charts') : __('Burndown chart');
},
},
methods: {
showIssueCount() {
this.issuesSelected = true;
},
showIssueWeight() {
this.issuesSelected = false;
},
},
};
</script>
<template>
<div data-qa-selector="burndown_chart">
<div class="burndown-header d-flex align-items-center">
<h3>{{ title }}</h3>
<gl-button-group class="ml-3 js-burndown-data-selector">
<gl-deprecated-button
ref="totalIssuesButton"
:variant="issuesSelected ? 'primary' : 'inverted-primary'"
size="sm"
@click="showIssueCount"
>
{{ __('Issues') }}
</gl-deprecated-button>
<gl-deprecated-button
ref="totalWeightButton"
:variant="issuesSelected ? 'inverted-primary' : 'primary'"
size="sm"
data-qa-selector="weight_button"
@click="showIssueWeight"
>
{{ __('Issue weight') }}
</gl-deprecated-button>
</gl-button-group>
</div>
<div v-if="$options.burnupChartsEnabled" class="row">
<burndown-chart
:start-date="startDate"
:due-date="dueDate"
:open-issues-count="openIssuesCount"
:open-issues-weight="openIssuesWeight"
:issues-selected="issuesSelected"
class="col-md-6"
/>
</div>
<burndown-chart
v-else
:show-title="false"
:start-date="startDate"
:due-date="dueDate"
:open-issues-count="openIssuesCount"
:open-issues-weight="openIssuesWeight"
:issues-selected="issuesSelected"
/>
</div>
</template>
<script> <script>
import { GlDeprecatedButton, GlButtonGroup } from '@gitlab/ui';
import { GlLineChart } from '@gitlab/ui/dist/charts'; import { GlLineChart } from '@gitlab/ui/dist/charts';
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
import ResizableChartContainer from '~/vue_shared/components/resizable_chart/resizable_chart_container.vue'; import ResizableChartContainer from '~/vue_shared/components/resizable_chart/resizable_chart_container.vue';
import { s__, __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
export default { export default {
components: { components: {
GlDeprecatedButton,
GlButtonGroup,
GlLineChart, GlLineChart,
ResizableChartContainer, ResizableChartContainer,
}, },
...@@ -31,10 +28,19 @@ export default { ...@@ -31,10 +28,19 @@ export default {
required: false, required: false,
default: () => [], default: () => [],
}, },
issuesSelected: {
type: Boolean,
required: false,
default: true,
},
showTitle: {
type: Boolean,
required: false,
default: true,
},
}, },
data() { data() {
return { return {
issuesSelected: true,
tooltip: { tooltip: {
title: '', title: '',
content: '', content: '',
...@@ -44,15 +50,7 @@ export default { ...@@ -44,15 +50,7 @@ export default {
computed: { computed: {
dataSeries() { dataSeries() {
let name; let name;
let data; const data = this.issuesSelected ? this.openIssuesCount : this.openIssuesWeight;
if (this.issuesSelected) {
name = s__('BurndownChartLabel|Open issues');
data = this.openIssuesCount;
} else {
name = s__('BurndownChartLabel|Open issue weight');
data = this.openIssuesWeight;
}
const series = [ const series = [
{ {
...@@ -132,27 +130,8 @@ export default { ...@@ -132,27 +130,8 @@ export default {
<template> <template>
<div data-qa-selector="burndown_chart"> <div data-qa-selector="burndown_chart">
<div class="burndown-header d-flex align-items-center"> <div v-if="showTitle" class="burndown-header d-flex align-items-center">
<h3>{{ __('Burndown chart') }}</h3> <h3>{{ __('Burndown chart') }}</h3>
<gl-button-group class="ml-3 js-burndown-data-selector">
<gl-deprecated-button
ref="totalIssuesButton"
:variant="issuesSelected ? 'primary' : 'inverted-primary'"
size="sm"
@click="showIssueCount"
>
{{ __('Issues') }}
</gl-deprecated-button>
<gl-deprecated-button
ref="totalWeightButton"
:variant="issuesSelected ? 'inverted-primary' : 'primary'"
size="sm"
data-qa-selector="weight_button"
@click="showIssueWeight"
>
{{ __('Issue weight') }}
</gl-deprecated-button>
</gl-button-group>
</div> </div>
<resizable-chart-container class="burndown-chart"> <resizable-chart-container class="burndown-chart">
<gl-line-chart <gl-line-chart
......
import Vue from 'vue'; import Vue from 'vue';
import $ from 'jquery'; import $ from 'jquery';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import BurndownChart from './components/burndown_chart.vue'; import BurnCharts from './components/burn_charts.vue';
import BurndownChartData from './burndown_chart_data'; import BurndownChartData from './burndown_chart_data';
import Flash from '~/flash'; import Flash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -36,10 +36,10 @@ export default () => { ...@@ -36,10 +36,10 @@ export default () => {
return new Vue({ return new Vue({
el: container, el: container,
components: { components: {
BurndownChart, BurnCharts,
}, },
render(createElement) { render(createElement) {
return createElement('burndown-chart', { return createElement('burn-charts', {
props: { props: {
startDate, startDate,
dueDate, dueDate,
......
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