Skip to content
代码片段 群组 项目
未验证 提交 56f801dc 编辑于 作者: Elwyn Benson's avatar Elwyn Benson 提交者: GitLab
浏览文件

Merge branch '454019-follow-up-from-analytics-dashboard-observability' into 'master'

Apply follow suggestions to analytics dashboard files

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/149722



Merged-by: default avatarElwyn Benson <ebenson@gitlab.com>
Approved-by: default avatarElwyn Benson <ebenson@gitlab.com>
Co-authored-by: default avatarJiaan Louw <jlouw@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -179,16 +179,7 @@ export default { ...@@ -179,16 +179,7 @@ export default {
return { return {
...dashboard, ...dashboard,
panels: panels: this.getDashboardPanels(dashboard),
// Panel ids need to remain consistent and they are unique to the
// frontend. Thus they don't get saved with GraphQL and we need to
// reference the saved panels array to persist the ids.
this.savedPanels ||
dashboard.panels?.nodes?.map((panel) => ({
...panel,
id: getUniquePanelId(),
})) ||
[],
}; };
}, },
result() { result() {
...@@ -250,6 +241,19 @@ export default { ...@@ -250,6 +241,19 @@ export default {
createNewDashboard() { createNewDashboard() {
return NEW_DASHBOARD(); return NEW_DASHBOARD();
}, },
getDashboardPanels(dashboard) {
// Panel ids need to remain consistent and they are unique to the
// frontend. Thus they don't get saved with GraphQL and we need to
// reference the saved panels array to persist the ids.
if (this.savedPanels) return this.savedPanels;
const panels = dashboard.panels?.nodes || [];
return panels.map(({ id, ...panel }) => ({
...panel,
id: getUniquePanelId(),
}));
},
async saveDashboard(dashboardSlug, dashboard) { async saveDashboard(dashboardSlug, dashboard) {
this.validateDashboardTitle(dashboard.title, true); this.validateDashboardTitle(dashboard.title, true);
if (this.titleValidationError) { if (this.titleValidationError) {
......
...@@ -26,7 +26,6 @@ import { ...@@ -26,7 +26,6 @@ import {
TEST_EMPTY_DASHBOARD_SVG_PATH, TEST_EMPTY_DASHBOARD_SVG_PATH,
} from 'ee_jest/analytics/analytics_dashboards/mock_data'; } from 'ee_jest/analytics/analytics_dashboards/mock_data';
import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal'; import { confirmAction } from '~/lib/utils/confirm_via_gl_modal/confirm_via_gl_modal';
import { createNewVisualizationPanel } from 'ee/analytics/analytics_dashboards/utils';
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
import { dashboard, builtinDashboard, mockDateRangeFilterChangePayload } from './mock_data'; import { dashboard, builtinDashboard, mockDateRangeFilterChangePayload } from './mock_data';
...@@ -472,8 +471,18 @@ describe('CustomizableDashboard', () => { ...@@ -472,8 +471,18 @@ describe('CustomizableDashboard', () => {
expect(panels).toHaveLength(3); expect(panels).toHaveLength(3);
expect(panels[2]).toMatchObject({ expect(panels[2]).toMatchObject({
...createNewVisualizationPanel(TEST_VISUALIZATION()),
id: expect.stringContaining('panel-'), id: expect.stringContaining('panel-'),
title: 'Test visualization',
gridAttributes: { width: 4, height: 3 },
queryOverrides: {},
options: {},
visualization: {
version: 1,
type: 'LineChart',
slug: 'test_visualization',
data: { type: 'cube_analytics', query: expect.any(Object) },
errors: null,
},
}); });
}); });
}); });
......
...@@ -96,7 +96,7 @@ describe('GridstackWrapper', () => { ...@@ -96,7 +96,7 @@ describe('GridstackWrapper', () => {
expect(mockGridLoad).toHaveBeenCalledWith(dashboard.panels.map(parsePanelToGridItem)); expect(mockGridLoad).toHaveBeenCalledWith(dashboard.panels.map(parsePanelToGridItem));
}); });
it('does not render a the grab cursor on grid panels', () => { it('does not render the grab cursor on grid panels', () => {
expect(findGridStackPanels().at(0).classes()).not.toContain('gl-cursor-grab'); expect(findGridStackPanels().at(0).classes()).not.toContain('gl-cursor-grab');
}); });
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册