Commit 0eb9988e authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents 37e5bbd5 50b69083
<script> <script>
import { __ } from '~/locale'; import { __ } from '~/locale';
import { GlLink } from '@gitlab/ui';
import { GlAreaChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; import { GlAreaChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
import { debounceByAnimationFrame, roundOffFloat } from '~/lib/utils/common_utils'; import { debounceByAnimationFrame, roundOffFloat } from '~/lib/utils/common_utils';
...@@ -14,6 +15,7 @@ export default { ...@@ -14,6 +15,7 @@ export default {
components: { components: {
GlAreaChart, GlAreaChart,
GlChartSeriesLabel, GlChartSeriesLabel,
GlLink,
Icon, Icon,
}, },
inheritAttrs: false, inheritAttrs: false,
...@@ -44,6 +46,10 @@ export default { ...@@ -44,6 +46,10 @@ export default {
required: false, required: false,
default: () => [], default: () => [],
}, },
projectPath: {
type: String,
required: true,
},
thresholds: { thresholds: {
type: Array, type: Array,
required: false, required: false,
...@@ -55,6 +61,7 @@ export default { ...@@ -55,6 +61,7 @@ export default {
tooltip: { tooltip: {
title: '', title: '',
content: [], content: [],
commitUrl: '',
isDeployment: false, isDeployment: false,
sha: '', sha: '',
}, },
...@@ -195,12 +202,13 @@ export default { ...@@ -195,12 +202,13 @@ export default {
this.tooltip.title = dateFormat(params.value, 'dd mmm yyyy, h:MMTT'); this.tooltip.title = dateFormat(params.value, 'dd mmm yyyy, h:MMTT');
this.tooltip.content = []; this.tooltip.content = [];
params.seriesData.forEach(seriesData => { params.seriesData.forEach(seriesData => {
if (seriesData.componentSubType === graphTypes.deploymentData) { this.tooltip.isDeployment = seriesData.componentSubType === graphTypes.deploymentData;
this.tooltip.isDeployment = true; if (this.tooltip.isDeployment) {
const [deploy] = this.recentDeployments.filter( const [deploy] = this.recentDeployments.filter(
deployment => deployment.createdAt === seriesData.value[0], deployment => deployment.createdAt === seriesData.value[0],
); );
this.tooltip.sha = deploy.sha.substring(0, 8); this.tooltip.sha = deploy.sha.substring(0, 8);
this.tooltip.commitUrl = deploy.commitUrl;
} else { } else {
const { seriesName, color } = seriesData; const { seriesName, color } = seriesData;
// seriesData.value contains the chart's [x, y] value pair // seriesData.value contains the chart's [x, y] value pair
...@@ -259,7 +267,7 @@ export default { ...@@ -259,7 +267,7 @@ export default {
</template> </template>
<div slot="tooltipContent" class="d-flex align-items-center"> <div slot="tooltipContent" class="d-flex align-items-center">
<icon name="commit" class="mr-2" /> <icon name="commit" class="mr-2" />
{{ tooltip.sha }} <gl-link :href="tooltip.commitUrl">{{ tooltip.sha }}</gl-link>
</div> </div>
</template> </template>
<template v-else> <template v-else>
......
...@@ -359,6 +359,7 @@ export default { ...@@ -359,6 +359,7 @@ export default {
<monitor-area-chart <monitor-area-chart
v-for="(graphData, graphIndex) in chartsWithData(groupData.metrics)" v-for="(graphData, graphIndex) in chartsWithData(groupData.metrics)"
:key="graphIndex" :key="graphIndex"
:project-path="projectPath"
:graph-data="graphData" :graph-data="graphData"
:deployment-data="deploymentData" :deployment-data="deploymentData"
:thresholds="getGraphAlertValues(graphData.queries)" :thresholds="getGraphAlertValues(graphData.queries)"
......
---
title: Turn commit sha in monitor charts popover to link
merge_request: 29914
author:
type: fixed
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlLink } from '@gitlab/ui';
import { GlAreaChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts'; import { GlAreaChart, GlChartSeriesLabel } from '@gitlab/ui/dist/charts';
import { shallowWrapperContainsSlotText } from 'spec/helpers/vue_test_utils_helper'; import { shallowWrapperContainsSlotText } from 'spec/helpers/vue_test_utils_helper';
import Area from '~/monitoring/components/charts/area.vue'; import Area from '~/monitoring/components/charts/area.vue';
import { createStore } from '~/monitoring/stores'; import { createStore } from '~/monitoring/stores';
import * as types from '~/monitoring/stores/mutation_types'; import * as types from '~/monitoring/stores/mutation_types';
import { TEST_HOST } from 'spec/test_constants';
import MonitoringMock, { deploymentData } from '../mock_data'; import MonitoringMock, { deploymentData } from '../mock_data';
describe('Area component', () => { describe('Area component', () => {
const mockSha = 'mockSha';
const mockWidgets = 'mockWidgets'; const mockWidgets = 'mockWidgets';
const mockSvgPathContent = 'mockSvgPathContent'; const mockSvgPathContent = 'mockSvgPathContent';
const projectPath = `${TEST_HOST}/path/to/project`;
const commitUrl = `${projectPath}/commit/${mockSha}`;
let mockGraphData; let mockGraphData;
let areaChart; let areaChart;
let spriteSpy; let spriteSpy;
...@@ -26,6 +31,7 @@ describe('Area component', () => { ...@@ -26,6 +31,7 @@ describe('Area component', () => {
graphData: mockGraphData, graphData: mockGraphData,
containerWidth: 0, containerWidth: 0,
deploymentData: store.state.monitoringDashboard.deploymentData, deploymentData: store.state.monitoringDashboard.deploymentData,
projectPath,
}, },
slots: { slots: {
default: mockWidgets, default: mockWidgets,
...@@ -88,11 +94,14 @@ describe('Area component', () => { ...@@ -88,11 +94,14 @@ describe('Area component', () => {
); );
}); });
it('renders commit sha in tooltip content', () => { it('renders clickable commit sha in tooltip content', () => {
const mockSha = 'mockSha';
areaChart.vm.tooltip.sha = mockSha; areaChart.vm.tooltip.sha = mockSha;
areaChart.vm.tooltip.commitUrl = commitUrl;
const commitLink = areaChart.find(GlLink);
expect(shallowWrapperContainsSlotText(glAreaChart, 'tooltipContent', mockSha)).toBe(true); expect(shallowWrapperContainsSlotText(commitLink, 'default', mockSha)).toBe(true);
expect(commitLink.attributes('href')).toEqual(commitUrl);
}); });
}); });
}); });
......
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