Commit 974fa05f authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'internationalization-time-series-wrapper' into 'master'

Allows average and max legend text in time series wrapper to be overwritten by props

See merge request gitlab-org/gitlab!16832
parents d65bca6d 9c1bbbaa
<script> <script>
import { __ } from '~/locale'; import { s__, __ } from '~/locale';
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';
...@@ -52,6 +52,16 @@ export default { ...@@ -52,6 +52,16 @@ export default {
required: false, required: false,
default: () => [], default: () => [],
}, },
legendAverageText: {
type: String,
required: false,
default: s__('Metrics|Avg'),
},
legendMaxText: {
type: String,
required: false,
default: s__('Metrics|Max'),
},
}, },
data() { data() {
return { return {
...@@ -260,7 +270,6 @@ export default { ...@@ -260,7 +270,6 @@ export default {
<slot></slot> <slot></slot>
</div> </div>
</div> </div>
<component <component
:is="glChartComponent" :is="glChartComponent"
ref="chart" ref="chart"
...@@ -271,6 +280,8 @@ export default { ...@@ -271,6 +280,8 @@ export default {
:thresholds="thresholds" :thresholds="thresholds"
:width="width" :width="width"
:height="height" :height="height"
:average-text="legendAverageText"
:max-text="legendMaxText"
@updated="onChartUpdated" @updated="onChartUpdated"
> >
<template v-if="tooltip.isDeployment"> <template v-if="tooltip.isDeployment">
......
---
title: Provides internationalization support to chart legends
merge_request: 16832
author:
type: added
...@@ -9858,6 +9858,9 @@ msgstr "" ...@@ -9858,6 +9858,9 @@ msgstr ""
msgid "Metrics|Add metric" msgid "Metrics|Add metric"
msgstr "" msgstr ""
msgid "Metrics|Avg"
msgstr ""
msgid "Metrics|Check out the CI/CD documentation on deploying to an environment" msgid "Metrics|Check out the CI/CD documentation on deploying to an environment"
msgstr "" msgstr ""
...@@ -9888,6 +9891,9 @@ msgstr "" ...@@ -9888,6 +9891,9 @@ msgstr ""
msgid "Metrics|Legend label (optional)" msgid "Metrics|Legend label (optional)"
msgstr "" msgstr ""
msgid "Metrics|Max"
msgstr ""
msgid "Metrics|Must be a valid PromQL query." msgid "Metrics|Must be a valid PromQL query."
msgstr "" msgstr ""
......
...@@ -60,6 +60,18 @@ describe('Time series component', () => { ...@@ -60,6 +60,18 @@ describe('Time series component', () => {
expect(timeSeriesChart.find('.js-graph-widgets').text()).toBe(mockWidgets); expect(timeSeriesChart.find('.js-graph-widgets').text()).toBe(mockWidgets);
}); });
it('allows user to override max value label text using prop', () => {
timeSeriesChart.setProps({ legendMaxText: 'legendMaxText' });
expect(timeSeriesChart.props().legendMaxText).toBe('legendMaxText');
});
it('allows user to override average value label text using prop', () => {
timeSeriesChart.setProps({ legendAverageText: 'averageText' });
expect(timeSeriesChart.props().legendAverageText).toBe('averageText');
});
describe('methods', () => { describe('methods', () => {
describe('formatTooltipText', () => { describe('formatTooltipText', () => {
const mockDate = deploymentData[0].created_at; const mockDate = deploymentData[0].created_at;
......
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