Commit 82a7814f authored by Mike Greiling's avatar Mike Greiling

Merge branch 'remove-ff-from-timeseries' into 'master'

Removes all mention of downloadcsv ff

See merge request gitlab-org/gitlab!16974
parents 3f0a8b36 0938ec2a
<script> <script>
import { __ } from '~/locale'; import { __ } from '~/locale';
import { mapState } from 'vuex';
import { GlLink, GlButton } from '@gitlab/ui'; import { GlLink, GlButton } from '@gitlab/ui';
import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; import { GlAreaChart, GlLineChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
...@@ -70,7 +69,6 @@ export default { ...@@ -70,7 +69,6 @@ export default {
}; };
}, },
computed: { computed: {
...mapState('monitoringDashboard', ['exportMetricsToCsvEnabled']),
chartData() { chartData() {
// Transforms & supplements query data to render appropriate labels & styles // Transforms & supplements query data to render appropriate labels & styles
// Input: [{ queryAttributes1 }, { queryAttributes2 }] // Input: [{ queryAttributes1 }, { queryAttributes2 }]
...@@ -190,18 +188,6 @@ export default { ...@@ -190,18 +188,6 @@ export default {
yAxisLabel() { yAxisLabel() {
return `${this.graphData.y_label}`; return `${this.graphData.y_label}`;
}, },
csvText() {
const chartData = this.chartData[0].data;
const header = `timestamp,${this.graphData.y_label}\r\n`; // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
return chartData.reduce((csv, data) => {
const row = data.join(',');
return `${csv}${row}\r\n`;
}, header);
},
downloadLink() {
const data = new Blob([this.csvText], { type: 'text/plain' });
return window.URL.createObjectURL(data);
},
}, },
watch: { watch: {
containerWidth: 'onResize', containerWidth: 'onResize',
...@@ -270,16 +256,6 @@ export default { ...@@ -270,16 +256,6 @@ export default {
<div class="prometheus-graph"> <div class="prometheus-graph">
<div class="prometheus-graph-header"> <div class="prometheus-graph-header">
<h5 class="prometheus-graph-title js-graph-title">{{ graphData.title }}</h5> <h5 class="prometheus-graph-title js-graph-title">{{ graphData.title }}</h5>
<gl-button
v-if="exportMetricsToCsvEnabled"
:href="downloadLink"
:title="__('Download CSV')"
:aria-label="__('Download CSV')"
style="margin-left: 200px;"
download="chart_metrics.csv"
>
{{ __('Download CSV') }}
</gl-button>
<div class="prometheus-graph-widgets js-graph-widgets"> <div class="prometheus-graph-widgets js-graph-widgets">
<slot></slot> <slot></slot>
</div> </div>
......
...@@ -23,7 +23,6 @@ describe('Time series component', () => { ...@@ -23,7 +23,6 @@ describe('Time series component', () => {
store = createStore(); store = createStore();
store.commit(`monitoringDashboard/${types.RECEIVE_METRICS_DATA_SUCCESS}`, MonitoringMock.data); store.commit(`monitoringDashboard/${types.RECEIVE_METRICS_DATA_SUCCESS}`, MonitoringMock.data);
store.commit(`monitoringDashboard/${types.RECEIVE_DEPLOYMENTS_DATA_SUCCESS}`, deploymentData); store.commit(`monitoringDashboard/${types.RECEIVE_DEPLOYMENTS_DATA_SUCCESS}`, deploymentData);
store.dispatch('monitoringDashboard/setFeatureFlags', { exportMetricsToCsvEnabled: true });
[mockGraphData] = store.state.monitoringDashboard.groups[0].metrics; [mockGraphData] = store.state.monitoringDashboard.groups[0].metrics;
makeTimeSeriesChart = (graphData, type) => makeTimeSeriesChart = (graphData, type) =>
...@@ -61,19 +60,6 @@ describe('Time series component', () => { ...@@ -61,19 +60,6 @@ describe('Time series component', () => {
expect(timeSeriesChart.find('.js-graph-widgets').text()).toBe(mockWidgets); expect(timeSeriesChart.find('.js-graph-widgets').text()).toBe(mockWidgets);
}); });
describe('when exportMetricsToCsvEnabled is disabled', () => {
beforeEach(() => {
store.dispatch('monitoringDashboard/setFeatureFlags', { exportMetricsToCsvEnabled: false });
});
it('does not render the Download CSV button', done => {
timeSeriesChart.vm.$nextTick(() => {
expect(timeSeriesChart.contains('glbutton-stub')).toBe(false);
done();
});
});
});
describe('methods', () => { describe('methods', () => {
describe('formatTooltipText', () => { describe('formatTooltipText', () => {
const mockDate = deploymentData[0].created_at; const mockDate = deploymentData[0].created_at;
...@@ -234,24 +220,6 @@ describe('Time series component', () => { ...@@ -234,24 +220,6 @@ describe('Time series component', () => {
expect(timeSeriesChart.vm.yAxisLabel).toBe('CPU'); expect(timeSeriesChart.vm.yAxisLabel).toBe('CPU');
}); });
}); });
describe('csvText', () => {
it('converts data from json to csv', () => {
const header = `timestamp,${mockGraphData.y_label}`;
const data = mockGraphData.queries[0].result[0].values;
const firstRow = `${data[0][0]},${data[0][1]}`;
expect(timeSeriesChart.vm.csvText).toMatch(`^${header}\r\n${firstRow}`);
});
});
describe('downloadLink', () => {
it('produces a link to download metrics as csv', () => {
const link = timeSeriesChart.vm.downloadLink;
expect(link).toContain('blob:');
});
});
}); });
afterEach(() => { afterEach(() => {
......
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