Commit 60334a6a authored by Martin Wortschack's avatar Martin Wortschack

Merge branch '201846-embed-add-link-to-embedded-panels-to-go-to-logs-page-fe' into 'master'

Show View logs in embed

Closes #201846

See merge request gitlab-org/gitlab!25217
parents a97733da 696e4ff8
...@@ -6,7 +6,7 @@ import { gqClient, parseEnvironmentsResponse, removeLeadingSlash } from './utils ...@@ -6,7 +6,7 @@ import { gqClient, parseEnvironmentsResponse, removeLeadingSlash } from './utils
import trackDashboardLoad from '../monitoring_tracking_helper'; import trackDashboardLoad from '../monitoring_tracking_helper';
import getEnvironments from '../queries/getEnvironments.query.graphql'; import getEnvironments from '../queries/getEnvironments.query.graphql';
import statusCodes from '../../lib/utils/http_status'; import statusCodes from '../../lib/utils/http_status';
import { backOff } from '../../lib/utils/common_utils'; import { backOff, convertObjectPropsToCamelCase } from '../../lib/utils/common_utils';
import { s__, sprintf } from '../../locale'; import { s__, sprintf } from '../../locale';
import { PROMETHEUS_TIMEOUT } from '../constants'; import { PROMETHEUS_TIMEOUT } from '../constants';
...@@ -52,6 +52,8 @@ export const requestMetricsDashboard = ({ commit }) => { ...@@ -52,6 +52,8 @@ export const requestMetricsDashboard = ({ commit }) => {
export const receiveMetricsDashboardSuccess = ({ commit, dispatch }, { response, params }) => { export const receiveMetricsDashboardSuccess = ({ commit, dispatch }, { response, params }) => {
commit(types.SET_ALL_DASHBOARDS, response.all_dashboards); commit(types.SET_ALL_DASHBOARDS, response.all_dashboards);
commit(types.RECEIVE_METRICS_DATA_SUCCESS, response.dashboard); commit(types.RECEIVE_METRICS_DATA_SUCCESS, response.dashboard);
commit(types.SET_ENDPOINTS, convertObjectPropsToCamelCase(response.metrics_data));
return dispatch('fetchPrometheusMetrics', params); return dispatch('fetchPrometheusMetrics', params);
}; };
export const receiveMetricsDashboardFailure = ({ commit }, error) => { export const receiveMetricsDashboardFailure = ({ commit }, error) => {
......
import Vue from 'vue'; import Vue from 'vue';
import pick from 'lodash/pick';
import { slugify } from '~/lib/utils/text_utility'; import { slugify } from '~/lib/utils/text_utility';
import * as types from './mutation_types'; import * as types from './mutation_types';
import { normalizeMetric, normalizeQueryResult } from './utils'; import { normalizeMetric, normalizeQueryResult } from './utils';
...@@ -174,15 +175,19 @@ export default { ...@@ -174,15 +175,19 @@ export default {
state: emptyStateFromError(error), state: emptyStateFromError(error),
}); });
}, },
[types.SET_ENDPOINTS](state, endpoints = {}) {
[types.SET_ENDPOINTS](state, endpoints) { const endpointKeys = [
state.metricsEndpoint = endpoints.metricsEndpoint; 'metricsEndpoint',
state.deploymentsEndpoint = endpoints.deploymentsEndpoint; 'deploymentsEndpoint',
state.dashboardEndpoint = endpoints.dashboardEndpoint; 'dashboardEndpoint',
state.dashboardsEndpoint = endpoints.dashboardsEndpoint; 'dashboardsEndpoint',
state.currentDashboard = endpoints.currentDashboard; 'currentDashboard',
state.projectPath = endpoints.projectPath; 'projectPath',
state.logsPath = endpoints.logsPath || state.logsPath; 'logsPath',
];
Object.entries(pick(endpoints, endpointKeys)).forEach(([key, value]) => {
state[key] = value;
});
}, },
[types.SET_TIME_RANGE](state, timeRange) { [types.SET_TIME_RANGE](state, timeRange) {
state.timeRange = timeRange; state.timeRange = timeRange;
......
---
title: Show View logs link in embed metrics
merge_request: 25217
author:
type: added
...@@ -91,16 +91,37 @@ describe('Monitoring mutations', () => { ...@@ -91,16 +91,37 @@ describe('Monitoring mutations', () => {
expect(stateCopy.projectPath).toEqual('/gitlab-org/gitlab-foss'); expect(stateCopy.projectPath).toEqual('/gitlab-org/gitlab-foss');
}); });
it('should not remove default value of logsPath', () => { it('should not remove previously set properties', () => {
const defaultLogsPath = stateCopy.logsPath; const defaultLogsPath = stateCopy.logsPath;
mutations[types.SET_ENDPOINTS](stateCopy, {
logsPath: defaultLogsPath,
});
mutations[types.SET_ENDPOINTS](stateCopy, { mutations[types.SET_ENDPOINTS](stateCopy, {
dashboardEndpoint: 'dashboard.json', dashboardEndpoint: 'dashboard.json',
}); });
mutations[types.SET_ENDPOINTS](stateCopy, {
projectPath: '/gitlab-org/gitlab-foss',
});
expect(stateCopy.logsPath).toBe(defaultLogsPath); expect(stateCopy).toMatchObject({
logsPath: defaultLogsPath,
dashboardEndpoint: 'dashboard.json',
projectPath: '/gitlab-org/gitlab-foss',
});
});
it('should not update unknown properties', () => {
mutations[types.SET_ENDPOINTS](stateCopy, {
dashboardEndpoint: 'dashboard.json',
someOtherProperty: 'some invalid value', // someOtherProperty is not allowed
});
expect(stateCopy.dashboardEndpoint).toBe('dashboard.json');
expect(stateCopy.someOtherProperty).toBeUndefined();
}); });
}); });
describe('Individual panel/metric results', () => { describe('Individual panel/metric results', () => {
const metricId = '12_system_metrics_kubernetes_container_memory_total'; const metricId = '12_system_metrics_kubernetes_container_memory_total';
const result = [ const result = [
......
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