@perses-dev/dashboards 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Dashboard.js +4 -5
- package/dist/cjs/components/DashboardToolbar.js +18 -5
- package/dist/cjs/components/GridLayout/GridItemContent.js +3 -11
- package/dist/cjs/components/GridLayout/GridLayout.js +20 -20
- package/dist/cjs/components/GridLayout/GridTitle.js +9 -11
- package/dist/cjs/components/Panel/DeletePanelDialog.js +12 -10
- package/dist/cjs/components/Panel/Panel.js +12 -22
- package/dist/cjs/components/Panel/Panel.test.js +5 -3
- package/dist/cjs/components/Panel/index.js +1 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -1
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +13 -5
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +21 -15
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +9 -3
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -111
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +22 -16
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
- package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
- package/dist/cjs/components/Variables/Variable.js +1 -0
- package/dist/cjs/components/Variables/VariableEditor.js +40 -6
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +9 -5
- package/dist/cjs/components/Variables/VariableList.js +0 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +26 -8
- package/dist/cjs/context/DashboardProvider/common.js +10 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +122 -29
- package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +70 -0
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +85 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +182 -0
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +89 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +83 -18
- package/dist/cjs/context/DashboardProvider/panel-slice.js +36 -0
- package/dist/cjs/context/TimeRangeProvider.js +20 -44
- package/dist/cjs/context/index.js +1 -1
- package/dist/cjs/context/useDashboardSpec.js +90 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/test/render.js +25 -5
- package/dist/cjs/test/setup-tests.js +4 -1
- package/dist/cjs/test/testDashboard.js +11 -10
- package/dist/cjs/utils/index.js +28 -0
- package/dist/cjs/utils/time-range-params.js +151 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -5
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +42 -93
- package/dist/components/Dashboard.js +5 -6
- package/dist/components/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +20 -7
- package/dist/components/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +4 -12
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -3
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +22 -22
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts +2 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +10 -12
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts +0 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -1
- package/dist/components/Panel/DeletePanelDialog.js +13 -11
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +2 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +12 -22
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.d.ts +1 -1
- package/dist/components/Panel/Panel.test.d.ts.map +1 -1
- package/dist/components/Panel/Panel.test.js +5 -3
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +1 -0
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +2 -2
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +13 -5
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +22 -16
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +9 -3
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -112
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -15
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
- package/dist/components/PanelGroupDialog/index.d.ts +3 -0
- package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/index.js +16 -0
- package/dist/components/PanelGroupDialog/index.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/Variables/Variable.js +1 -0
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +40 -6
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +9 -5
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableList.js +0 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +10 -5
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +26 -8
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +7 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +8 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +65 -22
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +133 -26
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts +23 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.js +64 -0
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts +36 -0
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/delete-panel-slice.js +81 -0
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +3 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +56 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js +178 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +33 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +83 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +60 -11
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +85 -18
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.d.ts +23 -0
- package/dist/context/DashboardProvider/panel-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-slice.js +32 -0
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -0
- package/dist/context/TimeRangeProvider.d.ts +9 -2
- package/dist/context/TimeRangeProvider.d.ts.map +1 -1
- package/dist/context/TimeRangeProvider.js +15 -43
- package/dist/context/TimeRangeProvider.js.map +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboardSpec.d.ts +11 -0
- package/dist/context/useDashboardSpec.d.ts.map +1 -0
- package/dist/context/useDashboardSpec.js +84 -0
- package/dist/context/useDashboardSpec.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/test/render.d.ts +2 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +25 -5
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.d.ts.map +1 -1
- package/dist/test/setup-tests.js +4 -0
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +11 -10
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/time-range-params.d.ts +25 -0
- package/dist/utils/time-range-params.d.ts.map +1 -0
- package/dist/utils/time-range-params.js +143 -0
- package/dist/utils/time-range-params.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +1 -4
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +5 -22
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +45 -96
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +5 -4
- package/dist/cjs/context/DashboardProvider/layout-slice.js +0 -200
- package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +0 -156
- package/dist/cjs/context/QueryStringProvider.js +0 -89
- package/dist/context/DashboardProvider/layout-slice.d.ts +0 -57
- package/dist/context/DashboardProvider/layout-slice.d.ts.map +0 -1
- package/dist/context/DashboardProvider/layout-slice.js +0 -196
- package/dist/context/DashboardProvider/layout-slice.js.map +0 -1
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts +0 -70
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +0 -1
- package/dist/context/DashboardProvider/panel-editing-slice.js +0 -152
- package/dist/context/DashboardProvider/panel-editing-slice.js.map +0 -1
- package/dist/context/QueryStringProvider.d.ts +0 -13
- package/dist/context/QueryStringProvider.d.ts.map +0 -1
- package/dist/context/QueryStringProvider.js +0 -40
- package/dist/context/QueryStringProvider.js.map +0 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createPanelEditorSlice", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>createPanelEditorSlice
|
|
20
|
+
});
|
|
21
|
+
const _functions = require("../../utils/functions");
|
|
22
|
+
const _common = require("./common");
|
|
23
|
+
function createPanelEditorSlice() {
|
|
24
|
+
// Return the state creator function for Zustand that uses the panels provided as intitial state
|
|
25
|
+
return (set, get)=>{
|
|
26
|
+
return {
|
|
27
|
+
panelEditor: undefined,
|
|
28
|
+
openEditPanel (panelGroupItemId) {
|
|
29
|
+
var ref;
|
|
30
|
+
const { panels , panelGroups } = get();
|
|
31
|
+
// Figure out the panel key at that location
|
|
32
|
+
const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
33
|
+
const panelKey = (ref = panelGroups[panelGroupId]) === null || ref === void 0 ? void 0 : ref.itemPanelKeys[panelGroupLayoutId];
|
|
34
|
+
if (panelKey === undefined) {
|
|
35
|
+
throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);
|
|
36
|
+
}
|
|
37
|
+
// Find the panel to edit
|
|
38
|
+
const panelToEdit = panels[panelKey];
|
|
39
|
+
if (panelToEdit === undefined) {
|
|
40
|
+
throw new Error(`Cannot find Panel with key '${panelKey}'`);
|
|
41
|
+
}
|
|
42
|
+
var _description;
|
|
43
|
+
const editorState = {
|
|
44
|
+
mode: 'Edit',
|
|
45
|
+
initialValues: {
|
|
46
|
+
name: panelToEdit.spec.display.name,
|
|
47
|
+
description: (_description = panelToEdit.spec.display.description) !== null && _description !== void 0 ? _description : '',
|
|
48
|
+
groupId: panelGroupItemId.panelGroupId,
|
|
49
|
+
kind: panelToEdit.spec.plugin.kind,
|
|
50
|
+
spec: panelToEdit.spec.plugin.spec
|
|
51
|
+
},
|
|
52
|
+
applyChanges: (next)=>{
|
|
53
|
+
const panelDefinititon = createPanelDefinitionFromEditorValues(next);
|
|
54
|
+
set((draft)=>{
|
|
55
|
+
draft.panels[panelKey] = panelDefinititon;
|
|
56
|
+
// If the panel didn't change groups, nothing else to do
|
|
57
|
+
if (next.groupId === panelGroupId) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
// Move panel to the new group
|
|
61
|
+
const existingGroup = draft.panelGroups[panelGroupId];
|
|
62
|
+
if (existingGroup === undefined) {
|
|
63
|
+
throw new Error(`Missing panel group ${panelGroupId}`);
|
|
64
|
+
}
|
|
65
|
+
const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout)=>layout.i === panelGroupLayoutId);
|
|
66
|
+
const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];
|
|
67
|
+
const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];
|
|
68
|
+
if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {
|
|
69
|
+
throw new Error(`Missing panel group item ${panelGroupLayoutId}`);
|
|
70
|
+
}
|
|
71
|
+
// Remove item from the old group
|
|
72
|
+
existingGroup.itemLayouts.splice(existingLayoutIdx, 1);
|
|
73
|
+
delete existingGroup.itemPanelKeys[panelGroupLayoutId];
|
|
74
|
+
// Add item to the end of the new group
|
|
75
|
+
const newGroup = draft.panelGroups[next.groupId];
|
|
76
|
+
if (newGroup === undefined) {
|
|
77
|
+
throw new Error(`Could not find new group ${next.groupId}`);
|
|
78
|
+
}
|
|
79
|
+
newGroup.itemLayouts.push({
|
|
80
|
+
i: existingLayout.i,
|
|
81
|
+
x: 0,
|
|
82
|
+
y: getYForNewRow(newGroup),
|
|
83
|
+
w: existingLayout.w,
|
|
84
|
+
h: existingLayout.h
|
|
85
|
+
});
|
|
86
|
+
newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
close: ()=>{
|
|
90
|
+
set((state)=>{
|
|
91
|
+
state.panelEditor = undefined;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
// Open the editor with the new state
|
|
96
|
+
set((state)=>{
|
|
97
|
+
state.panelEditor = editorState;
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
openAddPanel (panelGroupId) {
|
|
101
|
+
// If a panel group isn't supplied, add to the first group
|
|
102
|
+
if (panelGroupId === undefined) {
|
|
103
|
+
const firstGroupId = get().panelGroupOrder[0];
|
|
104
|
+
if (firstGroupId === undefined) {
|
|
105
|
+
throw new Error('No panel groups to add a panel to');
|
|
106
|
+
}
|
|
107
|
+
panelGroupId = firstGroupId;
|
|
108
|
+
}
|
|
109
|
+
const editorState = {
|
|
110
|
+
mode: 'Add',
|
|
111
|
+
initialValues: {
|
|
112
|
+
name: '',
|
|
113
|
+
description: '',
|
|
114
|
+
groupId: panelGroupId,
|
|
115
|
+
// TODO: If we knew what plugins were available (and how to create the initial spec), we might be able to
|
|
116
|
+
// set a smarter default here?
|
|
117
|
+
kind: '',
|
|
118
|
+
spec: {}
|
|
119
|
+
},
|
|
120
|
+
applyChanges: (next)=>{
|
|
121
|
+
const panelDef = createPanelDefinitionFromEditorValues(next);
|
|
122
|
+
const panelKey = (0, _functions.removeWhiteSpacesAndSpecialCharacters)(next.name);
|
|
123
|
+
set((draft)=>{
|
|
124
|
+
// Add a panel
|
|
125
|
+
draft.panels[panelKey] = panelDef;
|
|
126
|
+
// Also add a panel group item referencing the panel
|
|
127
|
+
const group = draft.panelGroups[next.groupId];
|
|
128
|
+
if (group === undefined) {
|
|
129
|
+
throw new Error(`Missing panel group ${next.groupId}`);
|
|
130
|
+
}
|
|
131
|
+
const layout = {
|
|
132
|
+
i: (0, _common.generateId)().toString(),
|
|
133
|
+
x: 0,
|
|
134
|
+
y: getYForNewRow(group),
|
|
135
|
+
w: 12,
|
|
136
|
+
h: 6
|
|
137
|
+
};
|
|
138
|
+
group.itemLayouts.push(layout);
|
|
139
|
+
group.itemPanelKeys[layout.i] = panelKey;
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
close: ()=>{
|
|
143
|
+
set((state)=>{
|
|
144
|
+
state.panelEditor = undefined;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
// Open the editor with the new state
|
|
149
|
+
set((state)=>{
|
|
150
|
+
state.panelEditor = editorState;
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
// Helper to create PanelDefinitions when saving
|
|
157
|
+
function createPanelDefinitionFromEditorValues(editorValues) {
|
|
158
|
+
return {
|
|
159
|
+
kind: 'Panel',
|
|
160
|
+
spec: {
|
|
161
|
+
display: {
|
|
162
|
+
name: editorValues.name,
|
|
163
|
+
description: editorValues.description !== '' ? editorValues.description : undefined
|
|
164
|
+
},
|
|
165
|
+
plugin: {
|
|
166
|
+
kind: editorValues.kind,
|
|
167
|
+
spec: editorValues.spec
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
// Given a PanelGroup, will find the Y coordinate for adding a new row to the grid, taking into account the items present
|
|
173
|
+
function getYForNewRow(group) {
|
|
174
|
+
let newRowY = 0;
|
|
175
|
+
for (const layout of group.itemLayouts){
|
|
176
|
+
const itemMaxY = layout.y + layout.h;
|
|
177
|
+
if (itemMaxY > newRowY) {
|
|
178
|
+
newRowY = itemMaxY;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return newRowY;
|
|
182
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createPanelGroupEditorSlice", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>createPanelGroupEditorSlice
|
|
20
|
+
});
|
|
21
|
+
const _common = require("./common");
|
|
22
|
+
const createPanelGroupEditorSlice = (set, get)=>({
|
|
23
|
+
panelGroupEditor: undefined,
|
|
24
|
+
openAddPanelGroup: ()=>{
|
|
25
|
+
// Create the editor state
|
|
26
|
+
const editor = {
|
|
27
|
+
mode: 'Add',
|
|
28
|
+
initialValues: {
|
|
29
|
+
title: '',
|
|
30
|
+
isCollapsed: false
|
|
31
|
+
},
|
|
32
|
+
applyChanges (next) {
|
|
33
|
+
const newGroup = {
|
|
34
|
+
id: (0, _common.generateId)(),
|
|
35
|
+
itemLayouts: [],
|
|
36
|
+
itemPanelKeys: {},
|
|
37
|
+
...next
|
|
38
|
+
};
|
|
39
|
+
set((draft)=>{
|
|
40
|
+
draft.panelGroups[newGroup.id] = newGroup;
|
|
41
|
+
draft.panelGroupOrder.unshift(newGroup.id);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
close () {
|
|
45
|
+
set((draft)=>{
|
|
46
|
+
draft.panelGroupEditor = undefined;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
// Open the editor
|
|
51
|
+
set((draft)=>{
|
|
52
|
+
draft.panelGroupEditor = editor;
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
openEditPanelGroup: (panelGroupId)=>{
|
|
56
|
+
const existingGroup = get().panelGroups[panelGroupId];
|
|
57
|
+
if (existingGroup === undefined) {
|
|
58
|
+
throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
|
|
59
|
+
}
|
|
60
|
+
var _title;
|
|
61
|
+
// Create the editor state
|
|
62
|
+
const editor = {
|
|
63
|
+
mode: 'Edit',
|
|
64
|
+
initialValues: {
|
|
65
|
+
title: (_title = existingGroup.title) !== null && _title !== void 0 ? _title : '',
|
|
66
|
+
isCollapsed: existingGroup.isCollapsed
|
|
67
|
+
},
|
|
68
|
+
applyChanges (next) {
|
|
69
|
+
set((draft)=>{
|
|
70
|
+
const group = draft.panelGroups[panelGroupId];
|
|
71
|
+
if (group === undefined) {
|
|
72
|
+
throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
|
|
73
|
+
}
|
|
74
|
+
group.title = next.title;
|
|
75
|
+
group.isCollapsed = next.isCollapsed;
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
close () {
|
|
79
|
+
set((draft)=>{
|
|
80
|
+
draft.panelGroupEditor = undefined;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// Open the editor
|
|
85
|
+
set((draft)=>{
|
|
86
|
+
draft.panelGroupEditor = editor;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
@@ -18,21 +18,86 @@ Object.defineProperty(exports, "createPanelGroupSlice", {
|
|
|
18
18
|
enumerable: true,
|
|
19
19
|
get: ()=>createPanelGroupSlice
|
|
20
20
|
});
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
const _core = require("@perses-dev/core");
|
|
22
|
+
const _common = require("./common");
|
|
23
|
+
function createPanelGroupSlice(layouts) {
|
|
24
|
+
// Convert the initial layouts from the JSON
|
|
25
|
+
const panelGroups = {};
|
|
26
|
+
const panelGroupIdOrder = [];
|
|
27
|
+
for (const layout of layouts){
|
|
28
|
+
var ref, ref1, ref2;
|
|
29
|
+
const itemLayouts = [];
|
|
30
|
+
const itemPanelKeys = {};
|
|
31
|
+
// Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
|
|
32
|
+
for (const item of layout.spec.items){
|
|
33
|
+
const panelGroupLayoutId = (0, _common.generateId)().toString();
|
|
34
|
+
itemLayouts.push({
|
|
35
|
+
i: panelGroupLayoutId,
|
|
36
|
+
w: item.width,
|
|
37
|
+
h: item.height,
|
|
38
|
+
x: item.x,
|
|
39
|
+
y: item.y
|
|
40
|
+
});
|
|
41
|
+
itemPanelKeys[panelGroupLayoutId] = (0, _core.getPanelKeyFromRef)(item.content);
|
|
42
|
+
}
|
|
43
|
+
// Create the panel group and keep track of the ID order
|
|
44
|
+
const panelGroupId = (0, _common.generateId)();
|
|
45
|
+
panelGroups[panelGroupId] = {
|
|
46
|
+
id: panelGroupId,
|
|
47
|
+
isCollapsed: ((ref = layout.spec.display) === null || ref === void 0 ? void 0 : (ref1 = ref.collapse) === null || ref1 === void 0 ? void 0 : ref1.open) === false,
|
|
48
|
+
title: (ref2 = layout.spec.display) === null || ref2 === void 0 ? void 0 : ref2.title,
|
|
49
|
+
itemLayouts,
|
|
50
|
+
itemPanelKeys
|
|
51
|
+
};
|
|
52
|
+
panelGroupIdOrder.push(panelGroupId);
|
|
53
|
+
}
|
|
54
|
+
// Return the state creator function for Zustand
|
|
55
|
+
return (set)=>({
|
|
56
|
+
panelGroups,
|
|
57
|
+
panelGroupOrder: panelGroupIdOrder,
|
|
58
|
+
previousPanelGroupState: {
|
|
59
|
+
panelGroups,
|
|
60
|
+
panelGroupIdOrder
|
|
61
|
+
},
|
|
62
|
+
savePanelGroups () {
|
|
63
|
+
set((state)=>{
|
|
64
|
+
state.previousPanelGroupState = {
|
|
65
|
+
panelGroups: state.panelGroups,
|
|
66
|
+
panelGroupIdOrder: state.panelGroupOrder
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
resetPanelGroups () {
|
|
71
|
+
set((state)=>{
|
|
72
|
+
state.panelGroups = state.previousPanelGroupState.panelGroups;
|
|
73
|
+
state.panelGroupOrder = state.previousPanelGroupState.panelGroupIdOrder;
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
swapPanelGroups (x, y) {
|
|
77
|
+
set((state)=>{
|
|
78
|
+
if (x < 0 || x >= state.panelGroupOrder.length || y < 0 || y >= state.panelGroupOrder.length) {
|
|
79
|
+
throw new Error('index out of bound');
|
|
80
|
+
}
|
|
81
|
+
const xPanelGroup = state.panelGroupOrder[x];
|
|
82
|
+
const yPanelGroup = state.panelGroupOrder[y];
|
|
83
|
+
if (xPanelGroup === undefined || yPanelGroup === undefined) {
|
|
84
|
+
throw new Error('panel group is undefined');
|
|
85
|
+
}
|
|
86
|
+
// assign yPanelGroup to layouts[x] and assign xGroup to layouts[y], swapping two panel groups
|
|
87
|
+
[state.panelGroupOrder[x], state.panelGroupOrder[y]] = [
|
|
88
|
+
yPanelGroup,
|
|
89
|
+
xPanelGroup
|
|
90
|
+
];
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
updatePanelGroupLayouts (panelGroupId, itemLayouts) {
|
|
94
|
+
set((state)=>{
|
|
95
|
+
const group = state.panelGroups[panelGroupId];
|
|
96
|
+
if (group === undefined) {
|
|
97
|
+
throw new Error(`Cannot find panel group ${panelGroupId}`);
|
|
98
|
+
}
|
|
99
|
+
group.itemLayouts = itemLayouts;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createPanelSlice", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>createPanelSlice
|
|
20
|
+
});
|
|
21
|
+
function createPanelSlice(panels) {
|
|
22
|
+
return (set)=>({
|
|
23
|
+
panels,
|
|
24
|
+
previousPanels: panels,
|
|
25
|
+
resetPanels () {
|
|
26
|
+
set((state)=>{
|
|
27
|
+
state.panels = state.previousPanels;
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
savePanels () {
|
|
31
|
+
set((state)=>{
|
|
32
|
+
state.previousPanels = state.panels;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -14,14 +14,18 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
TimeRangeProvider: ()=>TimeRangeProvider,
|
|
25
|
+
useDashboardTimeRange: ()=>useDashboardTimeRange
|
|
20
26
|
});
|
|
21
27
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
28
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
|
-
const _dateFns = require("date-fns");
|
|
24
|
-
const _core = require("@perses-dev/core");
|
|
25
29
|
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
26
30
|
function _getRequireWildcardCache(nodeInterop) {
|
|
27
31
|
if (typeof WeakMap !== "function") return null;
|
|
@@ -63,47 +67,12 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
63
67
|
return newObj;
|
|
64
68
|
}
|
|
65
69
|
function TimeRangeProvider(props) {
|
|
66
|
-
const {
|
|
67
|
-
|
|
68
|
-
const defaultTimeRange = (0, _core.isRelativeTimeRange)(initialTimeRange) ? (0, _core.toAbsoluteTimeRange)(initialTimeRange) : initialTimeRange;
|
|
69
|
-
const [timeRange, setActiveTimeRange] = (0, _react.useState)(defaultTimeRange);
|
|
70
|
-
const setTimeRange = (0, _react.useCallback)((value)=>{
|
|
71
|
-
if (onTimeRangeChange !== undefined) {
|
|
72
|
-
// optional callback to override default behavior
|
|
73
|
-
onTimeRangeChange(value);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if ((0, _core.isRelativeTimeRange)(value)) {
|
|
77
|
-
if (setQueryString) {
|
|
78
|
-
queryString.set('start', value.pastDuration);
|
|
79
|
-
// end not required for relative time but may have been set by AbsoluteTimePicker or zoom
|
|
80
|
-
queryString.delete('end');
|
|
81
|
-
setQueryString(queryString);
|
|
82
|
-
} else {
|
|
83
|
-
setActiveTimeRange((0, _core.toAbsoluteTimeRange)(value));
|
|
84
|
-
}
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
// allows app to specify whether query params should be source of truth for active time range
|
|
88
|
-
if (setQueryString) {
|
|
89
|
-
// Absolute URL example) ?start=1663707045000&end=1663713330000
|
|
90
|
-
// currently set from ViewDashboard initial queryString, AbsoluteTimePicker, or LineChart panel onDataZoom
|
|
91
|
-
const startUnixMs = (0, _dateFns.getUnixTime)(value.start) * 1000;
|
|
92
|
-
const endUnixMs = (0, _dateFns.getUnixTime)(value.end) * 1000;
|
|
93
|
-
queryString.set('start', startUnixMs.toString());
|
|
94
|
-
queryString.set('end', endUnixMs.toString());
|
|
95
|
-
setQueryString(queryString);
|
|
96
|
-
} else {
|
|
97
|
-
setActiveTimeRange(value);
|
|
98
|
-
}
|
|
99
|
-
}, [
|
|
100
|
-
queryString,
|
|
101
|
-
setQueryString,
|
|
102
|
-
onTimeRangeChange
|
|
103
|
-
]);
|
|
70
|
+
const { timeRange , children , setTimeRange } = props;
|
|
71
|
+
// TODO: fix no-op, pass paramsEnabled as false in useSetTimeRangeParams as workaround
|
|
104
72
|
const ctx = (0, _react.useMemo)(()=>({
|
|
105
73
|
timeRange,
|
|
106
|
-
setTimeRange
|
|
74
|
+
setTimeRange: setTimeRange !== null && setTimeRange !== void 0 ? setTimeRange : ()=>{
|
|
75
|
+
/* no-op */ }
|
|
107
76
|
}), [
|
|
108
77
|
timeRange,
|
|
109
78
|
setTimeRange
|
|
@@ -113,3 +82,10 @@ function TimeRangeProvider(props) {
|
|
|
113
82
|
children: children
|
|
114
83
|
});
|
|
115
84
|
}
|
|
85
|
+
function useDashboardTimeRange() {
|
|
86
|
+
const { timeRange , setTimeRange } = (0, _pluginSystem.useTimeRangeContext)();
|
|
87
|
+
return {
|
|
88
|
+
timeRange,
|
|
89
|
+
setTimeRange
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -16,9 +16,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./DashboardProvider"), exports);
|
|
18
18
|
_exportStar(require("./DatasourceStoreProvider"), exports);
|
|
19
|
-
_exportStar(require("./QueryStringProvider"), exports);
|
|
20
19
|
_exportStar(require("./TemplateVariableProvider"), exports);
|
|
21
20
|
_exportStar(require("./TimeRangeProvider"), exports);
|
|
21
|
+
_exportStar(require("./useDashboardSpec"), exports);
|
|
22
22
|
function _exportStar(from, to) {
|
|
23
23
|
Object.keys(from).forEach(function(k) {
|
|
24
24
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "useDashboardSpec", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>useDashboardSpec
|
|
20
|
+
});
|
|
21
|
+
const _core = require("@perses-dev/core");
|
|
22
|
+
const _dashboardProvider = require("./DashboardProvider");
|
|
23
|
+
const _templateVariableProvider = require("./TemplateVariableProvider");
|
|
24
|
+
function useDashboardSpec() {
|
|
25
|
+
const { panels , panelGroups , panelGroupOrder , defaultTimeRange , reset: resetDashboardStore , } = (0, _dashboardProvider.useDashboardStore)(({ panels , panelGroups , panelGroupOrder , defaultTimeRange , reset })=>({
|
|
26
|
+
panels,
|
|
27
|
+
panelGroups,
|
|
28
|
+
panelGroupOrder,
|
|
29
|
+
defaultTimeRange,
|
|
30
|
+
reset
|
|
31
|
+
}));
|
|
32
|
+
const { setVariableDefinitions } = (0, _templateVariableProvider.useTemplateVariableActions)();
|
|
33
|
+
const variables = (0, _templateVariableProvider.useTemplateVariableDefinitions)();
|
|
34
|
+
const layouts = convertPanelGroupsToLayouts(panelGroups, panelGroupOrder);
|
|
35
|
+
const spec = {
|
|
36
|
+
panels,
|
|
37
|
+
layouts,
|
|
38
|
+
variables,
|
|
39
|
+
duration: defaultTimeRange.pastDuration
|
|
40
|
+
};
|
|
41
|
+
const resetSpec = (spec)=>{
|
|
42
|
+
setVariableDefinitions(spec.variables);
|
|
43
|
+
// TODO: Should we call reset on the dashboard store with the spec?
|
|
44
|
+
resetDashboardStore();
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
spec,
|
|
48
|
+
resetSpec
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function convertPanelGroupsToLayouts(panelGroups, panelGroupOrder) {
|
|
52
|
+
const layouts = [];
|
|
53
|
+
panelGroupOrder.map((groupOrderId)=>{
|
|
54
|
+
const group = panelGroups[groupOrderId];
|
|
55
|
+
if (group === undefined) {
|
|
56
|
+
throw new Error('panel group not found');
|
|
57
|
+
}
|
|
58
|
+
const { title , isCollapsed , itemLayouts , itemPanelKeys } = group;
|
|
59
|
+
let display = undefined;
|
|
60
|
+
if (title) {
|
|
61
|
+
display = {
|
|
62
|
+
title,
|
|
63
|
+
collapse: {
|
|
64
|
+
open: !isCollapsed
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const layout = {
|
|
69
|
+
kind: 'Grid',
|
|
70
|
+
spec: {
|
|
71
|
+
display,
|
|
72
|
+
items: itemLayouts.map((layout)=>{
|
|
73
|
+
const panelKey = itemPanelKeys[layout.i];
|
|
74
|
+
if (panelKey === undefined) {
|
|
75
|
+
throw new Error(`Missing panel key of layout ${layout.i}`);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
x: layout.x,
|
|
79
|
+
y: layout.y,
|
|
80
|
+
width: layout.w,
|
|
81
|
+
height: layout.h,
|
|
82
|
+
content: (0, _core.createPanelRef)(panelKey)
|
|
83
|
+
};
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
layouts.push(layout);
|
|
88
|
+
});
|
|
89
|
+
return layouts;
|
|
90
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
_exportStar(require("./components"), exports);
|
|
18
18
|
_exportStar(require("./context"), exports);
|
|
19
|
+
_exportStar(require("./utils"), exports);
|
|
19
20
|
_exportStar(require("./views"), exports);
|
|
20
21
|
function _exportStar(from, to) {
|
|
21
22
|
Object.keys(from).forEach(function(k) {
|
package/dist/cjs/test/render.js
CHANGED
|
@@ -20,8 +20,13 @@ Object.defineProperty(exports, "renderWithContext", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _react = require("@testing-library/react");
|
|
23
|
+
const _reactRouterDom = require("react-router-dom");
|
|
24
|
+
const _history = require("history");
|
|
25
|
+
const _useQueryParams = require("use-query-params");
|
|
26
|
+
const _reactRouter6 = require("use-query-params/adapters/react-router-6");
|
|
23
27
|
const _reactQuery = require("@tanstack/react-query");
|
|
24
|
-
|
|
28
|
+
const _components = require("@perses-dev/components");
|
|
29
|
+
function renderWithContext(ui, options, history) {
|
|
25
30
|
// Create a new QueryClient for each test to avoid caching issues
|
|
26
31
|
const queryClient = new _reactQuery.QueryClient({
|
|
27
32
|
defaultOptions: {
|
|
@@ -31,8 +36,23 @@ function renderWithContext(ui, options) {
|
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
const BaseRender = ()=>{
|
|
40
|
+
const HistoryRouter = _reactRouterDom.unstable_HistoryRouter;
|
|
41
|
+
history = history !== null && history !== void 0 ? history : (0, _history.createMemoryHistory)();
|
|
42
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(HistoryRouter, {
|
|
43
|
+
history: history,
|
|
44
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactQuery.QueryClientProvider, {
|
|
45
|
+
client: queryClient,
|
|
46
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_useQueryParams.QueryParamProvider, {
|
|
47
|
+
adapter: _reactRouter6.ReactRouter6Adapter,
|
|
48
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ChartsThemeProvider, {
|
|
49
|
+
themeName: "perses",
|
|
50
|
+
chartsTheme: _components.testChartsTheme,
|
|
51
|
+
children: ui
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
return (0, _react.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(BaseRender, {}), options);
|
|
38
58
|
}
|
|
@@ -10,11 +10,14 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
// Add testing library assertions
|
|
14
13
|
"use strict";
|
|
15
14
|
Object.defineProperty(exports, "__esModule", {
|
|
16
15
|
value: true
|
|
17
16
|
});
|
|
17
|
+
const _reactIntersectionObserver = require("react-intersection-observer");
|
|
18
18
|
require("@testing-library/jest-dom/extend-expect");
|
|
19
19
|
// Always mock e-charts during tests since we don't have a proper canvas in jsdom
|
|
20
20
|
jest.mock('echarts/core');
|
|
21
|
+
// Tell react-intersection-observer that everything should be considered in-view for tests (see package documentation
|
|
22
|
+
// for other options)
|
|
23
|
+
(0, _reactIntersectionObserver.defaultFallbackInView)(true);
|