@perses-dev/dashboards 0.8.1 → 0.10.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 +25 -14
- package/dist/cjs/components/DashboardToolbar.js +148 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +25 -19
- package/dist/cjs/components/GridLayout/GridLayout.js +92 -27
- package/dist/cjs/components/GridLayout/GridTitle.js +91 -31
- package/dist/cjs/components/GridLayout/index.js +18 -19
- package/dist/cjs/components/Panel/DeletePanelDialog.js +91 -0
- package/dist/cjs/components/Panel/Panel.js +156 -55
- package/dist/cjs/components/Panel/Panel.test.js +58 -41
- package/dist/cjs/components/Panel/PanelContent.js +41 -12
- package/dist/cjs/components/Panel/index.js +16 -17
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +84 -108
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +87 -92
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +194 -0
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +48 -0
- package/dist/cjs/components/PanelDrawer/index.js +28 -0
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +86 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +121 -39
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +74 -88
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +120 -38
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +42 -27
- package/dist/cjs/components/TimeRangeControls/index.js +16 -17
- package/dist/cjs/components/Variables/Variable.js +195 -36
- package/dist/cjs/components/Variables/VariableEditor.js +207 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
- package/dist/cjs/components/Variables/VariableList.js +81 -13
- package/dist/cjs/components/Variables/index.js +18 -18
- package/dist/cjs/components/index.js +21 -21
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +70 -0
- package/dist/cjs/context/DashboardProvider/common.js +18 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +71 -0
- package/dist/cjs/context/DashboardProvider/index.js +29 -0
- package/dist/cjs/context/DashboardProvider/layout-slice.js +200 -0
- package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +156 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +38 -0
- package/dist/cjs/context/DatasourceStoreProvider.js +170 -0
- package/dist/cjs/context/QueryStringProvider.js +69 -15
- package/dist/cjs/context/TemplateVariableProvider.js +135 -136
- package/dist/cjs/context/TimeRangeProvider.js +79 -30
- package/dist/cjs/context/index.js +20 -22
- package/dist/cjs/css/styles.js +43 -39
- package/dist/cjs/index.js +19 -20
- package/dist/cjs/test/dashboard-provider.js +51 -0
- package/dist/cjs/test/index.js +18 -18
- package/dist/cjs/test/plugin-registry.js +52 -25
- package/dist/cjs/test/render.js +25 -22
- package/dist/cjs/test/setup-tests.js +4 -2
- package/dist/cjs/test/testDashboard.js +203 -107
- package/dist/cjs/utils/functions.js +9 -5
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +49 -23
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +62 -31
- package/dist/cjs/views/ViewDashboard/index.js +16 -17
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +165 -0
- package/dist/cjs/views/index.js +16 -17
- package/dist/components/Dashboard.d.ts +1 -4
- package/dist/components/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard.js +34 -1
- package/dist/components/Dashboard.js.map +1 -0
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +154 -1
- package/dist/components/DashboardToolbar.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts +3 -3
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +35 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -0
- 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 +102 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -0
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +99 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -0
- package/dist/components/GridLayout/index.js +16 -1
- package/dist/components/GridLayout/index.js.map +1 -0
- package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/Panel/DeletePanelDialog.js +80 -0
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +181 -1
- package/dist/components/Panel/Panel.js.map +1 -0
- package/dist/components/Panel/Panel.test.js +74 -1
- package/dist/components/Panel/Panel.test.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +5 -4
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +41 -1
- package/dist/components/Panel/PanelContent.js.map +1 -0
- package/dist/components/Panel/index.js +15 -1
- package/dist/components/Panel/index.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.d.ts +4 -2
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +96 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js +99 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js +184 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.js +42 -0
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
- package/dist/components/PanelDrawer/index.d.ts +2 -0
- package/dist/components/PanelDrawer/index.d.ts.map +1 -0
- package/dist/components/PanelDrawer/index.js +15 -0
- package/dist/components/PanelDrawer/index.js.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +4 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +75 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +131 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +74 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +137 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +59 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
- package/dist/components/TimeRangeControls/index.js +15 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +210 -1
- package/dist/components/Variables/Variable.js.map +1 -0
- package/dist/components/Variables/VariableEditor.d.ts +8 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditor.js +196 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js +15 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +84 -1
- package/dist/components/Variables/VariableList.js.map +1 -0
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +17 -1
- package/dist/components/Variables/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +20 -1
- package/dist/components/index.js.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +23 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.js +52 -0
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
- package/dist/context/DashboardProvider/common.d.ts +5 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -0
- package/dist/context/DashboardProvider/common.js +17 -0
- package/dist/context/DashboardProvider/common.js.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +32 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js +56 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +3 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -0
- package/dist/context/DashboardProvider/index.js +16 -0
- package/dist/context/DashboardProvider/index.js.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts +57 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.js +196 -0
- package/dist/context/DashboardProvider/layout-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts +70 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js +152 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js +32 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +24 -0
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
- package/dist/context/DatasourceStoreProvider.js +166 -0
- package/dist/context/DatasourceStoreProvider.js.map +1 -0
- package/dist/context/QueryStringProvider.js +40 -1
- package/dist/context/QueryStringProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider.d.ts +8 -3
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +199 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TimeRangeProvider.js +72 -1
- package/dist/context/TimeRangeProvider.js.map +1 -0
- package/dist/context/index.d.ts +3 -4
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +19 -1
- package/dist/context/index.js.map +1 -0
- package/dist/css/styles.js +186 -1
- package/dist/css/styles.js.map +1 -0
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -0
- package/dist/test/dashboard-provider.d.ts +19 -0
- package/dist/test/dashboard-provider.d.ts.map +1 -0
- package/dist/test/dashboard-provider.js +40 -0
- package/dist/test/dashboard-provider.js.map +1 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +17 -1
- package/dist/test/index.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +3 -4
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +74 -1
- package/dist/test/plugin-registry.js.map +1 -0
- package/dist/test/render.d.ts +1 -2
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +34 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.js +18 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +286 -1
- package/dist/test/testDashboard.js.map +1 -0
- package/dist/utils/functions.js +17 -1
- package/dist/utils/functions.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +55 -1
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +79 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
- package/dist/views/ViewDashboard/index.js +15 -1
- package/dist/views/ViewDashboard/index.js.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +158 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/dist/views/index.js +15 -1
- package/dist/views/index.js.map +1 -0
- package/package.json +13 -7
- package/dist/cjs/components/PanelDrawer/PanelOptionsEditor.js +0 -19
- package/dist/cjs/context/DashboardAppSlice.js +0 -45
- package/dist/cjs/context/DashboardProvider.js +0 -98
- package/dist/cjs/context/LayoutsSlice.js +0 -42
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts +0 -9
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelOptionsEditor.js +0 -1
- package/dist/context/DashboardAppSlice.d.ts +0 -26
- package/dist/context/DashboardAppSlice.d.ts.map +0 -1
- package/dist/context/DashboardAppSlice.js +0 -1
- package/dist/context/DashboardProvider.d.ts +0 -34
- package/dist/context/DashboardProvider.d.ts.map +0 -1
- package/dist/context/DashboardProvider.js +0 -1
- package/dist/context/LayoutsSlice.d.ts +0 -12
- package/dist/context/LayoutsSlice.d.ts.map +0 -1
- package/dist/context/LayoutsSlice.js +0 -1
|
@@ -0,0 +1,165 @@
|
|
|
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
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _react = require("@testing-library/react");
|
|
19
|
+
const _userEvent = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/user-event"));
|
|
20
|
+
const _context = require("../../../context");
|
|
21
|
+
const _test = require("../../../test");
|
|
22
|
+
const _testDashboard = /*#__PURE__*/ _interopRequireDefault(require("../../../test/testDashboard"));
|
|
23
|
+
const _dashboardApp = require("../DashboardApp");
|
|
24
|
+
function _interopRequireDefault(obj) {
|
|
25
|
+
return obj && obj.__esModule ? obj : {
|
|
26
|
+
default: obj
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
describe('Panel Groups', ()=>{
|
|
30
|
+
const renderDashboard = ()=>{
|
|
31
|
+
const { store , DashboardProviderSpy } = (0, _test.createDashboardProviderSpy)();
|
|
32
|
+
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.QueryStringProvider, {
|
|
33
|
+
queryString: new URLSearchParams('https://localhost:3000/'),
|
|
34
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TimeRangeProvider, {
|
|
35
|
+
initialTimeRange: {
|
|
36
|
+
pastDuration: '30m'
|
|
37
|
+
},
|
|
38
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TemplateVariableProvider, {
|
|
39
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_context.DashboardProvider, {
|
|
40
|
+
initialState: {
|
|
41
|
+
dashboardSpec: (0, _test.getTestDashboard)().spec,
|
|
42
|
+
isEditMode: true
|
|
43
|
+
},
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardProviderSpy, {}),
|
|
46
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboardApp.DashboardApp, {
|
|
47
|
+
dashboardResource: (0, _test.getTestDashboard)()
|
|
48
|
+
})
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
}));
|
|
54
|
+
const { value: storeApi } = store;
|
|
55
|
+
if (storeApi === undefined) {
|
|
56
|
+
throw new Error('Expected dashboard store to be set after initial render');
|
|
57
|
+
}
|
|
58
|
+
return storeApi;
|
|
59
|
+
};
|
|
60
|
+
beforeEach(()=>{
|
|
61
|
+
const mockIntersectionObserver = jest.fn();
|
|
62
|
+
mockIntersectionObserver.mockReturnValue({
|
|
63
|
+
observe: ()=>null,
|
|
64
|
+
unobserve: ()=>null,
|
|
65
|
+
disconnect: ()=>null
|
|
66
|
+
});
|
|
67
|
+
window.IntersectionObserver = mockIntersectionObserver;
|
|
68
|
+
});
|
|
69
|
+
it('should delete panel', ()=>{
|
|
70
|
+
var ref;
|
|
71
|
+
const storeApi = renderDashboard();
|
|
72
|
+
const panel = _react.screen.getByText('CPU');
|
|
73
|
+
_userEvent.default.hover(panel);
|
|
74
|
+
const deletePanelButton = _react.screen.getByLabelText('delete panel');
|
|
75
|
+
_userEvent.default.click(deletePanelButton);
|
|
76
|
+
_react.screen.getByText('Delete Panel');
|
|
77
|
+
const deleteButton = _react.screen.getByText('Delete');
|
|
78
|
+
_userEvent.default.click(deleteButton);
|
|
79
|
+
const layouts = storeApi.getState().layouts;
|
|
80
|
+
const deletedPanel = _testDashboard.default.spec.panels['cpu'];
|
|
81
|
+
expect((ref = layouts[0]) === null || ref === void 0 ? void 0 : ref.items).toEqual(expect.not.objectContaining(deletedPanel));
|
|
82
|
+
const panels = storeApi.getState().panels;
|
|
83
|
+
// should remove cpu from state.panels since it's not used anymore
|
|
84
|
+
expect(panels).toEqual(expect.not.objectContaining({
|
|
85
|
+
cpu: _testDashboard.default.spec.panels['cpu']
|
|
86
|
+
}));
|
|
87
|
+
});
|
|
88
|
+
it('should only delete panel from panel group if panel is referenced more than once', ()=>{
|
|
89
|
+
var ref;
|
|
90
|
+
const storeApi = renderDashboard();
|
|
91
|
+
const panel = _react.screen.getByText('Disk I/O Utilization');
|
|
92
|
+
_userEvent.default.hover(panel);
|
|
93
|
+
const deletePanelButton = _react.screen.getByLabelText('delete panel');
|
|
94
|
+
_userEvent.default.click(deletePanelButton);
|
|
95
|
+
_react.screen.getByText('Delete Panel');
|
|
96
|
+
const deleteButton = _react.screen.getByText('Delete');
|
|
97
|
+
_userEvent.default.click(deleteButton);
|
|
98
|
+
const layouts = storeApi.getState().layouts;
|
|
99
|
+
const deletedPanel = _testDashboard.default.spec.panels['diskIO'];
|
|
100
|
+
expect((ref = layouts[0]) === null || ref === void 0 ? void 0 : ref.items).toEqual(expect.not.objectContaining(deletedPanel));
|
|
101
|
+
const panels = storeApi.getState().panels;
|
|
102
|
+
// should NOT remove diskIO from state.panels since it's used in another panel group
|
|
103
|
+
expect(panels).toEqual(expect.objectContaining({
|
|
104
|
+
diskIO: _testDashboard.default.spec.panels['diskIO']
|
|
105
|
+
}));
|
|
106
|
+
});
|
|
107
|
+
it('should swap panels', ()=>{
|
|
108
|
+
var ref, ref1, ref2;
|
|
109
|
+
const storeApi = renderDashboard();
|
|
110
|
+
// should move panel down
|
|
111
|
+
const group1 = _react.screen.getByText('CPU Stats');
|
|
112
|
+
_userEvent.default.hover(group1);
|
|
113
|
+
const moveGroupDownBtn = _react.screen.getByLabelText('move group down');
|
|
114
|
+
_userEvent.default.click(moveGroupDownBtn);
|
|
115
|
+
_userEvent.default.unhover(moveGroupDownBtn);
|
|
116
|
+
// should move panel up
|
|
117
|
+
const group2 = _react.screen.getByText('Disk Stats');
|
|
118
|
+
_userEvent.default.hover(group2);
|
|
119
|
+
const moveGroupUpBtn = _react.screen.getByLabelText('move group up');
|
|
120
|
+
_userEvent.default.click(moveGroupUpBtn);
|
|
121
|
+
const layouts = storeApi.getState().layouts;
|
|
122
|
+
expect((ref = layouts[0]) === null || ref === void 0 ? void 0 : ref.title).toBe(undefined);
|
|
123
|
+
expect((ref1 = layouts[1]) === null || ref1 === void 0 ? void 0 : ref1.title).toBe('Disk Stats');
|
|
124
|
+
expect((ref2 = layouts[2]) === null || ref2 === void 0 ? void 0 : ref2.title).toBe('CPU Stats');
|
|
125
|
+
});
|
|
126
|
+
it('should delete a panel group', ()=>{
|
|
127
|
+
const storeApi = renderDashboard();
|
|
128
|
+
const group = _react.screen.getByText('CPU Stats');
|
|
129
|
+
_userEvent.default.hover(group);
|
|
130
|
+
const deleteGroupIcon = _react.screen.getByLabelText('delete group');
|
|
131
|
+
_userEvent.default.click(deleteGroupIcon);
|
|
132
|
+
_react.screen.getByText('Delete Panel Group');
|
|
133
|
+
const deleteButton = _react.screen.getByText('Delete');
|
|
134
|
+
_userEvent.default.click(deleteButton);
|
|
135
|
+
// should remove group from state.layouts
|
|
136
|
+
const layouts = storeApi.getState().layouts;
|
|
137
|
+
expect(layouts).toHaveLength(2);
|
|
138
|
+
const deletedLayout = {
|
|
139
|
+
id: 0,
|
|
140
|
+
title: 'CPU Stats',
|
|
141
|
+
isCollapsed: false,
|
|
142
|
+
items: [
|
|
143
|
+
{
|
|
144
|
+
x: 0,
|
|
145
|
+
y: 0,
|
|
146
|
+
width: 12,
|
|
147
|
+
height: 4,
|
|
148
|
+
content: {
|
|
149
|
+
$ref: '#/spec/panels/cpu'
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
};
|
|
154
|
+
expect(layouts).toEqual(expect.not.objectContaining(deletedLayout));
|
|
155
|
+
const panels = storeApi.getState().panels;
|
|
156
|
+
// should remove cpu from state.panels since it's not used anymore
|
|
157
|
+
expect(panels).toEqual(expect.not.objectContaining({
|
|
158
|
+
cpu: _testDashboard.default.spec.panels['cpu']
|
|
159
|
+
}));
|
|
160
|
+
// should not remove diskIO from state.panels since it's still used in another group
|
|
161
|
+
expect(panels).toEqual(expect.objectContaining({
|
|
162
|
+
diskIO: _testDashboard.default.spec.panels['diskIO']
|
|
163
|
+
}));
|
|
164
|
+
});
|
|
165
|
+
});
|
package/dist/cjs/views/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,19 +10,19 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Object.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./ViewDashboard"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@mui/material';
|
|
3
|
-
|
|
4
|
-
export interface DashboardProps extends BoxProps {
|
|
5
|
-
spec: DashboardSpec;
|
|
6
|
-
}
|
|
3
|
+
export declare type DashboardProps = BoxProps;
|
|
7
4
|
/**
|
|
8
5
|
* Renders a Dashboard for the provided Dashboard spec.
|
|
9
6
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../src/components/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../src/components/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAK9C,oBAAY,cAAc,GAAG,QAAQ,CAAC;AAEtC;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAW9C"}
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { Box } from '@mui/material';
|
|
15
|
+
import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
|
|
16
|
+
import { useLayouts } from '../context';
|
|
17
|
+
import { GridLayout } from './GridLayout';
|
|
18
|
+
/**
|
|
19
|
+
* Renders a Dashboard for the provided Dashboard spec.
|
|
20
|
+
*/ export function Dashboard(props) {
|
|
21
|
+
const { layouts } = useLayouts();
|
|
22
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
23
|
+
...props,
|
|
24
|
+
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
25
|
+
FallbackComponent: ErrorAlert,
|
|
26
|
+
children: layouts.map((layout, groupIndex)=>/*#__PURE__*/ _jsx(GridLayout, {
|
|
27
|
+
groupIndex: groupIndex,
|
|
28
|
+
groupDefinition: layout
|
|
29
|
+
}, layout.id))
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=Dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Dashboard.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { useLayouts } from '../context';\nimport { GridLayout } from './GridLayout';\n\nexport type DashboardProps = BoxProps;\n\n/**\n * Renders a Dashboard for the provided Dashboard spec.\n */\nexport function Dashboard(props: DashboardProps) {\n const { layouts } = useLayouts();\n return (\n <Box {...props}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {layouts.map((layout, groupIndex) => (\n <GridLayout key={layout.id} groupIndex={groupIndex} groupDefinition={layout} />\n ))}\n </ErrorBoundary>\n </Box>\n );\n}\n"],"names":["Box","ErrorBoundary","ErrorAlert","useLayouts","GridLayout","Dashboard","props","layouts","FallbackComponent","map","layout","groupIndex","groupDefinition","id"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,aAAa,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AACnE,SAASC,UAAU,QAAQ,YAAY,CAAC;AACxC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAI1C;;CAEC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAM,EAAEC,OAAO,CAAA,EAAE,GAAGJ,UAAU,EAAE,AAAC;IACjC,qBACE,KAACH,GAAG;QAAE,GAAGM,KAAK;kBACZ,cAAA,KAACL,aAAa;YAACO,iBAAiB,EAAEN,UAAU;sBACzCK,OAAO,CAACE,GAAG,CAAC,CAACC,MAAM,EAAEC,UAAU,iBAC9B,KAACP,UAAU;oBAAiBO,UAAU,EAAEA,UAAU;oBAAEC,eAAe,EAAEF,MAAM;mBAA1DA,MAAM,CAACG,EAAE,CAAqD,AAChF,CAAC;UACY;MACZ,CACN;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../src/components/DashboardToolbar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../src/components/DashboardToolbar.tsx"],"names":[],"mappings":";AAqBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBA6E5D,CAAC"}
|
|
@@ -1 +1,154 @@
|
|
|
1
|
-
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
+
import { Typography, Stack, Button, Box } from '@mui/material';
|
|
15
|
+
import PencilIcon from 'mdi-material-ui/PencilOutline';
|
|
16
|
+
import AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';
|
|
17
|
+
import AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';
|
|
18
|
+
import { ErrorBoundary, ErrorAlert } from '@perses-dev/components';
|
|
19
|
+
import { usePanelGroupDialog, useEditMode, usePanels } from '../context';
|
|
20
|
+
import { TemplateVariableList, TimeRangeControls } from '../components';
|
|
21
|
+
export const DashboardToolbar = (props)=>{
|
|
22
|
+
const { dashboardName } = props;
|
|
23
|
+
const { isEditMode , setEditMode } = useEditMode();
|
|
24
|
+
const { openPanelGroupDialog } = usePanelGroupDialog();
|
|
25
|
+
const { addPanel } = usePanels();
|
|
26
|
+
const onEditButtonClick = ()=>{
|
|
27
|
+
setEditMode(true);
|
|
28
|
+
};
|
|
29
|
+
const onCancelButtonClick = ()=>{
|
|
30
|
+
setEditMode(false);
|
|
31
|
+
};
|
|
32
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
33
|
+
children: isEditMode ? /*#__PURE__*/ _jsxs(Stack, {
|
|
34
|
+
spacing: 2,
|
|
35
|
+
children: [
|
|
36
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
37
|
+
sx: {
|
|
38
|
+
backgroundColor: (theme)=>theme.palette.primary.light + '20'
|
|
39
|
+
},
|
|
40
|
+
children: /*#__PURE__*/ _jsxs(Box, {
|
|
41
|
+
padding: 2,
|
|
42
|
+
display: "flex",
|
|
43
|
+
children: [
|
|
44
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
45
|
+
variant: "h2",
|
|
46
|
+
children: [
|
|
47
|
+
"Edit ",
|
|
48
|
+
dashboardName
|
|
49
|
+
]
|
|
50
|
+
}),
|
|
51
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
52
|
+
direction: "row",
|
|
53
|
+
spacing: 1,
|
|
54
|
+
sx: {
|
|
55
|
+
marginLeft: 'auto'
|
|
56
|
+
},
|
|
57
|
+
children: [
|
|
58
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
59
|
+
variant: "contained",
|
|
60
|
+
children: "Save"
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
63
|
+
variant: "outlined",
|
|
64
|
+
onClick: onCancelButtonClick,
|
|
65
|
+
children: "Cancel"
|
|
66
|
+
})
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
}),
|
|
72
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
73
|
+
sx: {
|
|
74
|
+
display: 'flex',
|
|
75
|
+
width: '100%',
|
|
76
|
+
alignItems: 'flex-start',
|
|
77
|
+
padding: (theme)=>theme.spacing(2)
|
|
78
|
+
},
|
|
79
|
+
children: [
|
|
80
|
+
/*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
81
|
+
FallbackComponent: ErrorAlert,
|
|
82
|
+
children: /*#__PURE__*/ _jsx(TemplateVariableList, {})
|
|
83
|
+
}),
|
|
84
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
85
|
+
direction: 'row',
|
|
86
|
+
spacing: 1,
|
|
87
|
+
sx: {
|
|
88
|
+
marginLeft: 'auto'
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
92
|
+
startIcon: /*#__PURE__*/ _jsx(AddPanelGroupIcon, {}),
|
|
93
|
+
onClick: ()=>openPanelGroupDialog(),
|
|
94
|
+
children: "Add Panel Group"
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
97
|
+
startIcon: /*#__PURE__*/ _jsx(AddPanelIcon, {}),
|
|
98
|
+
onClick: ()=>addPanel(0),
|
|
99
|
+
children: "Add Panel"
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ _jsx(TimeRangeControls, {})
|
|
102
|
+
]
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
}) : /*#__PURE__*/ _jsxs(Stack, {
|
|
108
|
+
spacing: 2,
|
|
109
|
+
padding: 2,
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
112
|
+
sx: {
|
|
113
|
+
display: 'flex',
|
|
114
|
+
width: '100%'
|
|
115
|
+
},
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
118
|
+
variant: "h2",
|
|
119
|
+
children: dashboardName
|
|
120
|
+
}),
|
|
121
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
122
|
+
direction: "row",
|
|
123
|
+
spacing: 2,
|
|
124
|
+
sx: {
|
|
125
|
+
marginLeft: 'auto'
|
|
126
|
+
},
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ _jsx(TimeRangeControls, {}),
|
|
129
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
130
|
+
variant: "outlined",
|
|
131
|
+
startIcon: /*#__PURE__*/ _jsx(PencilIcon, {}),
|
|
132
|
+
onClick: onEditButtonClick,
|
|
133
|
+
sx: {
|
|
134
|
+
marginLeft: 'auto'
|
|
135
|
+
},
|
|
136
|
+
children: "Edit"
|
|
137
|
+
})
|
|
138
|
+
]
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
143
|
+
paddingY: 2,
|
|
144
|
+
children: /*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
145
|
+
FallbackComponent: ErrorAlert,
|
|
146
|
+
children: /*#__PURE__*/ _jsx(TemplateVariableList, {})
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
]
|
|
150
|
+
})
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=DashboardToolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/DashboardToolbar.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Typography, Stack, Button, Box } from '@mui/material';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport AddPanelGroupIcon from 'mdi-material-ui/PlusBoxOutline';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport { ErrorBoundary, ErrorAlert } from '@perses-dev/components';\nimport { usePanelGroupDialog, useEditMode, usePanels } from '../context';\nimport { TemplateVariableList, TimeRangeControls } from '../components';\n\nexport interface DashboardToolbarProps {\n dashboardName: string;\n}\n\nexport const DashboardToolbar = (props: DashboardToolbarProps) => {\n const { dashboardName } = props;\n\n const { isEditMode, setEditMode } = useEditMode();\n const { openPanelGroupDialog } = usePanelGroupDialog();\n const { addPanel } = usePanels();\n\n const onEditButtonClick = () => {\n setEditMode(true);\n };\n\n const onCancelButtonClick = () => {\n setEditMode(false);\n };\n\n return (\n <>\n {isEditMode ? (\n <Stack spacing={2}>\n <Box sx={{ backgroundColor: (theme) => theme.palette.primary.light + '20' }}>\n <Box padding={2} display=\"flex\">\n <Typography variant=\"h2\">Edit {dashboardName}</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n <Button variant=\"contained\">Save</Button>\n <Button variant=\"outlined\" onClick={onCancelButtonClick}>\n Cancel\n </Button>\n </Stack>\n </Box>\n </Box>\n <Box\n sx={{\n display: 'flex',\n width: '100%',\n alignItems: 'flex-start',\n padding: (theme) => theme.spacing(2),\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList />\n </ErrorBoundary>\n <Stack direction={'row'} spacing={1} sx={{ marginLeft: 'auto' }}>\n <Button startIcon={<AddPanelGroupIcon />} onClick={() => openPanelGroupDialog()}>\n Add Panel Group\n </Button>\n <Button startIcon={<AddPanelIcon />} onClick={() => addPanel(0)}>\n Add Panel\n </Button>\n <TimeRangeControls />\n </Stack>\n </Box>\n </Stack>\n ) : (\n <Stack spacing={2} padding={2}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n <Typography variant=\"h2\">{dashboardName}</Typography>\n <Stack direction=\"row\" spacing={2} sx={{ marginLeft: 'auto' }}>\n <TimeRangeControls />\n <Button\n variant=\"outlined\"\n startIcon={<PencilIcon />}\n onClick={onEditButtonClick}\n sx={{ marginLeft: 'auto' }}\n >\n Edit\n </Button>\n </Stack>\n </Box>\n <Box paddingY={2}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TemplateVariableList />\n </ErrorBoundary>\n </Box>\n </Stack>\n )}\n </>\n );\n};\n"],"names":["Typography","Stack","Button","Box","PencilIcon","AddPanelGroupIcon","AddPanelIcon","ErrorBoundary","ErrorAlert","usePanelGroupDialog","useEditMode","usePanels","TemplateVariableList","TimeRangeControls","DashboardToolbar","props","dashboardName","isEditMode","setEditMode","openPanelGroupDialog","addPanel","onEditButtonClick","onCancelButtonClick","spacing","sx","backgroundColor","theme","palette","primary","light","padding","display","variant","direction","marginLeft","onClick","width","alignItems","FallbackComponent","startIcon","paddingY"],"mappings":"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"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { GridItemDefinition } from '@perses-dev/core';
|
|
3
3
|
export interface GridItemContentProps {
|
|
4
|
-
spec: DashboardSpec;
|
|
5
|
-
content: GridItemDefinition['content'];
|
|
6
4
|
groupIndex: number;
|
|
5
|
+
itemIndex: number;
|
|
6
|
+
content: GridItemDefinition['content'];
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Resolves the reference to panel content in a GridItemDefinition and renders the panel.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAsB,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI1E,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;CACxC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAW1D"}
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { getPanelKeyFromRef } from '@perses-dev/core';
|
|
15
|
+
import { usePanels } from '../../context';
|
|
16
|
+
import { Panel } from '../Panel/Panel';
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the reference to panel content in a GridItemDefinition and renders the panel.
|
|
19
|
+
*/ export function GridItemContent(props) {
|
|
20
|
+
const { content , groupIndex , itemIndex } = props;
|
|
21
|
+
// Find the panel referenced in content in the store
|
|
22
|
+
const { panels } = usePanels();
|
|
23
|
+
const panelKey = getPanelKeyFromRef(content);
|
|
24
|
+
const panelDefinition = panels[panelKey];
|
|
25
|
+
if (panelDefinition === undefined) {
|
|
26
|
+
throw new Error(`Panel with key '${panelKey}' was not found`);
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/ _jsx(Panel, {
|
|
29
|
+
definition: panelDefinition,
|
|
30
|
+
groupIndex: groupIndex,
|
|
31
|
+
itemIndex: itemIndex
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=GridItemContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { getPanelKeyFromRef, GridItemDefinition } from '@perses-dev/core';\nimport { usePanels } from '../../context';\nimport { Panel } from '../Panel/Panel';\n\nexport interface GridItemContentProps {\n groupIndex: number;\n itemIndex: number;\n content: GridItemDefinition['content'];\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps) {\n const { content, groupIndex, itemIndex } = props;\n\n // Find the panel referenced in content in the store\n const { panels } = usePanels();\n const panelKey = getPanelKeyFromRef(content);\n const panelDefinition = panels[panelKey];\n if (panelDefinition === undefined) {\n throw new Error(`Panel with key '${panelKey}' was not found`);\n }\n return <Panel definition={panelDefinition} groupIndex={groupIndex} itemIndex={itemIndex} />;\n}\n"],"names":["getPanelKeyFromRef","usePanels","Panel","GridItemContent","props","content","groupIndex","itemIndex","panels","panelKey","panelDefinition","undefined","Error","definition"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,kBAAkB,QAA4B,kBAAkB,CAAC;AAC1E,SAASC,SAAS,QAAQ,eAAe,CAAC;AAC1C,SAASC,KAAK,QAAQ,gBAAgB,CAAC;AAQvC;;CAEC,GACD,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,OAAO,CAAA,EAAEC,UAAU,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGH,KAAK,AAAC;IAEjD,oDAAoD;IACpD,MAAM,EAAEI,MAAM,CAAA,EAAE,GAAGP,SAAS,EAAE,AAAC;IAC/B,MAAMQ,QAAQ,GAAGT,kBAAkB,CAACK,OAAO,CAAC,AAAC;IAC7C,MAAMK,eAAe,GAAGF,MAAM,CAACC,QAAQ,CAAC,AAAC;IACzC,IAAIC,eAAe,KAAKC,SAAS,EAAE;QACjC,MAAM,IAAIC,KAAK,CAAC,CAAC,gBAAgB,EAAEH,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,qBAAO,KAACP,KAAK;QAACW,UAAU,EAAEH,eAAe;QAAEJ,UAAU,EAAEA,UAAU;QAAEC,SAAS,EAAEA,SAAS;MAAI,CAAC;AAC9F,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { BoxProps } from '@mui/material';
|
|
3
|
-
import {
|
|
3
|
+
import { PanelGroupDefinition } from '../../context/DashboardProvider/layout-slice';
|
|
4
4
|
export interface GridLayoutProps extends BoxProps {
|
|
5
5
|
groupIndex: number;
|
|
6
|
-
|
|
7
|
-
renderGridItemContent: (definition: GridItemDefinition, groupIndex: number) => React.ReactNode;
|
|
6
|
+
groupDefinition: PanelGroupDefinition;
|
|
8
7
|
}
|
|
9
8
|
/**
|
|
10
9
|
* Layout component that arranges children in a Grid based on the definition.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAO,QAAQ,EAA0B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAO,QAAQ,EAA0B,MAAM,eAAe,CAAC;AAItE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAMpF,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,oBAAoB,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,eA4ChD"}
|