debian-mirror-gitlab/spec/frontend/monitoring/store_utils.js

50 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-04-22 19:07:51 +05:30
import * as types from '~/monitoring/stores/mutation_types';
2020-05-24 23:13:21 +05:30
import { metricsResult, environmentData, dashboardGitResponse } from './mock_data';
2020-04-22 19:07:51 +05:30
import { metricsDashboardPayload } from './fixture_data';
2020-05-24 23:13:21 +05:30
export const setMetricResult = ({ store, result, group = 0, panel = 0, metric = 0 }) => {
const { dashboard } = store.state.monitoringDashboard;
2020-04-22 19:07:51 +05:30
const { metricId } = dashboard.panelGroups[group].panels[panel].metrics[metric];
2020-05-24 23:13:21 +05:30
store.commit(`monitoringDashboard/${types.RECEIVE_METRIC_RESULT_SUCCESS}`, {
2020-04-22 19:07:51 +05:30
metricId,
result,
});
};
2020-05-24 23:13:21 +05:30
const setEnvironmentData = store => {
store.commit(`monitoringDashboard/${types.RECEIVE_ENVIRONMENTS_DATA_SUCCESS}`, environmentData);
2020-04-22 19:07:51 +05:30
};
2020-05-24 23:13:21 +05:30
export const setupAllDashboards = store => {
store.commit(`monitoringDashboard/${types.SET_ALL_DASHBOARDS}`, dashboardGitResponse);
};
export const setupStoreWithDashboard = store => {
store.commit(
`monitoringDashboard/${types.RECEIVE_METRICS_DASHBOARD_SUCCESS}`,
metricsDashboardPayload,
);
store.commit(
2020-04-22 19:07:51 +05:30
`monitoringDashboard/${types.RECEIVE_METRICS_DASHBOARD_SUCCESS}`,
metricsDashboardPayload,
);
};
2020-05-24 23:13:21 +05:30
export const setupStoreWithVariable = store => {
store.commit(`monitoringDashboard/${types.SET_VARIABLES}`, {
label1: 'pod',
});
};
export const setupStoreWithData = store => {
setupAllDashboards(store);
setupStoreWithDashboard(store);
2020-04-22 19:07:51 +05:30
2020-05-24 23:13:21 +05:30
setMetricResult({ store, result: [], panel: 0 });
setMetricResult({ store, result: metricsResult, panel: 1 });
setMetricResult({ store, result: metricsResult, panel: 2 });
2020-04-22 19:07:51 +05:30
2020-05-24 23:13:21 +05:30
setEnvironmentData(store);
2020-04-22 19:07:51 +05:30
};