@perses-dev/dashboards 0.9.0 → 0.11.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 +6 -11
- package/dist/cjs/components/DashboardToolbar.js +12 -6
- package/dist/cjs/components/GridLayout/GridItemContent.js +7 -15
- package/dist/cjs/components/GridLayout/GridLayout.js +27 -22
- package/dist/cjs/components/GridLayout/GridTitle.js +27 -7
- package/dist/cjs/components/Panel/DeletePanelDialog.js +95 -0
- package/dist/cjs/components/Panel/Panel.js +12 -10
- package/dist/cjs/components/Panel/Panel.test.js +15 -6
- package/dist/cjs/components/Panel/PanelContent.js +3 -2
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +13 -12
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +9 -13
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +87 -39
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +54 -0
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +88 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -118
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -36
- 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 +20 -11
- package/dist/cjs/components/Variables/VariableEditor.js +240 -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 +49 -69
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +82 -0
- package/dist/cjs/context/DashboardProvider/common.js +18 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +164 -0
- package/dist/cjs/context/DashboardProvider/index.js +29 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +175 -0
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +102 -0
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +208 -0
- package/dist/cjs/context/DatasourceStoreProvider.js +109 -7
- package/dist/cjs/context/TemplateVariableProvider.js +8 -1
- package/dist/cjs/context/TimeRangeProvider.js +20 -44
- package/dist/cjs/context/index.js +1 -3
- package/dist/cjs/context/useDashboardSpec.js +61 -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 +24 -11
- package/dist/cjs/utils/index.js +28 -0
- package/dist/cjs/utils/time-range-params.js +145 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +5 -8
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +114 -0
- package/dist/components/Dashboard.d.ts +1 -4
- package/dist/components/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard.js +7 -12
- package/dist/components/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +14 -8
- 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 +7 -15
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -4
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +28 -23
- 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 +28 -8
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- 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 +84 -0
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
- 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 +13 -11
- 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 +10 -6
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/PanelContent.d.ts +4 -1
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +3 -2
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +14 -13
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +9 -13
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +89 -41
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- 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 +48 -0
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +3 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +77 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- 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 -119
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +20 -35
- 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 +22 -13
- package/dist/components/Variables/Variable.js.map +1 -1
- 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 +229 -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 +47 -72
- package/dist/components/Variables/VariableList.js.map +1 -1
- 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 +1 -0
- package/dist/components/Variables/index.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 +25 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.js +64 -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 +74 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js +163 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +5 -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/panel-editor-slice.d.ts +85 -0
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js +171 -0
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +40 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +96 -0
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +80 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js +204 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +10 -2
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +111 -9
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider.d.ts +2 -0
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +8 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -1
- 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 -3
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -3
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboardSpec.d.ts +3 -0
- package/dist/context/useDashboardSpec.d.ts.map +1 -0
- package/dist/context/useDashboardSpec.js +55 -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/plugin-registry.d.ts +2 -2
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.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 +24 -11
- 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 +137 -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 +6 -9
- 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.d.ts +2 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +107 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/package.json +5 -4
- package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +0 -40
- package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +0 -38
- package/dist/cjs/components/PanelDrawer/panel-editor-model.js +0 -140
- package/dist/cjs/context/DashboardAppSlice.js +0 -57
- package/dist/cjs/context/DashboardProvider.js +0 -128
- package/dist/cjs/context/LayoutsSlice.js +0 -55
- package/dist/cjs/context/QueryStringProvider.js +0 -89
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +0 -7
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelSpecEditor.js +0 -34
- package/dist/components/PanelDrawer/PanelSpecEditor.js.map +0 -1
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +0 -8
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelTypeSelect.js +0 -34
- package/dist/components/PanelDrawer/PanelTypeSelect.js.map +0 -1
- package/dist/components/PanelDrawer/panel-editor-model.d.ts +0 -27
- package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +0 -1
- package/dist/components/PanelDrawer/panel-editor-model.js +0 -133
- package/dist/components/PanelDrawer/panel-editor-model.js.map +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 -45
- package/dist/context/DashboardAppSlice.js.map +0 -1
- package/dist/context/DashboardProvider.d.ts +0 -36
- package/dist/context/DashboardProvider.d.ts.map +0 -1
- package/dist/context/DashboardProvider.js +0 -107
- package/dist/context/DashboardProvider.js.map +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 -43
- package/dist/context/LayoutsSlice.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
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
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
|
-
usePanels: ()=>usePanels,
|
|
25
|
-
useEditMode: ()=>useEditMode,
|
|
26
|
-
useDashboard: ()=>useDashboard,
|
|
27
|
-
DashboardContext: ()=>DashboardContext,
|
|
28
|
-
useDashboardStore: ()=>useDashboardStore,
|
|
29
|
-
DashboardProvider: ()=>DashboardProvider
|
|
30
|
-
});
|
|
31
|
-
const _jsxRuntime = require("react/jsx-runtime");
|
|
32
|
-
const _zustand = require("zustand");
|
|
33
|
-
const _immer = require("zustand/middleware/immer");
|
|
34
|
-
const _shallow = /*#__PURE__*/ _interopRequireDefault(require("zustand/shallow"));
|
|
35
|
-
const _react = require("react");
|
|
36
|
-
const _immer1 = /*#__PURE__*/ _interopRequireDefault(require("immer"));
|
|
37
|
-
const _dashboardAppSlice = require("./DashboardAppSlice");
|
|
38
|
-
const _layoutsSlice = require("./LayoutsSlice");
|
|
39
|
-
function _interopRequireDefault(obj) {
|
|
40
|
-
return obj && obj.__esModule ? obj : {
|
|
41
|
-
default: obj
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function usePanels() {
|
|
45
|
-
return useDashboardStore(({ panels , updatePanel })=>({
|
|
46
|
-
panels,
|
|
47
|
-
updatePanel
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
function useEditMode() {
|
|
51
|
-
return useDashboardStore(({ isEditMode , setEditMode })=>({
|
|
52
|
-
isEditMode,
|
|
53
|
-
setEditMode
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
56
|
-
function useDashboard() {
|
|
57
|
-
const selectDashboardSpec = (state)=>{
|
|
58
|
-
return (0, _immer1.default)(state.dashboard, (draftState)=>{
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
60
|
-
draftState.panels = state.panels;
|
|
61
|
-
draftState.layouts = state.layouts;
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
const dashboard = useDashboardStore(selectDashboardSpec);
|
|
65
|
-
return {
|
|
66
|
-
dashboard
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const DashboardContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
70
|
-
function useDashboardStore(selector) {
|
|
71
|
-
const store = (0, _react.useContext)(DashboardContext);
|
|
72
|
-
if (store === undefined) {
|
|
73
|
-
throw new Error('No DashboardContext found. Did you forget a Provider?');
|
|
74
|
-
}
|
|
75
|
-
return (0, _zustand.useStore)(store, selector, _shallow.default);
|
|
76
|
-
}
|
|
77
|
-
function DashboardProvider(props) {
|
|
78
|
-
const { children , initialState: { dashboardSpec , isEditMode } , } = props;
|
|
79
|
-
const { layouts , panels } = dashboardSpec;
|
|
80
|
-
const dashboardStore = (0, _zustand.createStore)()((0, _immer.immer)((set, get, api)=>{
|
|
81
|
-
return {
|
|
82
|
-
...(0, _dashboardAppSlice.createDashboardAppSlice)(set, get, api, []),
|
|
83
|
-
...(0, _layoutsSlice.createLayoutsSlice)(set, get, api, []),
|
|
84
|
-
layouts,
|
|
85
|
-
panels,
|
|
86
|
-
dashboard: dashboardSpec,
|
|
87
|
-
updatePanel: (name, panel, groupIndex = 0)=>{
|
|
88
|
-
return set((state)=>{
|
|
89
|
-
// add new panel to layouts if panels[name] is undefined
|
|
90
|
-
if (state.panels[name] === undefined) {
|
|
91
|
-
var ref;
|
|
92
|
-
// find maximum y so new panel is added to the end of the grid
|
|
93
|
-
let maxY = 0;
|
|
94
|
-
(ref = state.layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.spec.items.forEach((layout)=>{
|
|
95
|
-
if (layout.y > maxY) {
|
|
96
|
-
maxY = layout.y;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
const panelLayout = {
|
|
100
|
-
x: 0,
|
|
101
|
-
y: maxY + 1,
|
|
102
|
-
width: 12,
|
|
103
|
-
height: 6,
|
|
104
|
-
content: {
|
|
105
|
-
$ref: `#/spec/panels/${name}`
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
const layouts = state.layouts;
|
|
109
|
-
if (layouts && layouts[groupIndex]) {
|
|
110
|
-
var ref1;
|
|
111
|
-
(ref1 = layouts[groupIndex]) === null || ref1 === void 0 ? void 0 : ref1.spec.items.push(panelLayout);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
-
state.panels[name] = panel;
|
|
116
|
-
});
|
|
117
|
-
},
|
|
118
|
-
isEditMode: !!isEditMode,
|
|
119
|
-
setEditMode: (isEditMode)=>set({
|
|
120
|
-
isEditMode
|
|
121
|
-
})
|
|
122
|
-
};
|
|
123
|
-
}));
|
|
124
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardContext.Provider, {
|
|
125
|
-
value: dashboardStore,
|
|
126
|
-
children: children
|
|
127
|
-
});
|
|
128
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
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
|
-
createLayoutsSlice: ()=>createLayoutsSlice,
|
|
25
|
-
useLayouts: ()=>useLayouts
|
|
26
|
-
});
|
|
27
|
-
const _immer = require("zustand/middleware/immer");
|
|
28
|
-
const _dashboardProvider = require("./DashboardProvider");
|
|
29
|
-
const createLayoutsSlice = (0, _immer.immer)((set)=>{
|
|
30
|
-
return {
|
|
31
|
-
updateLayout: (layout, index)=>set((state)=>{
|
|
32
|
-
if (index === undefined) {
|
|
33
|
-
state.layouts.unshift(layout);
|
|
34
|
-
} else {
|
|
35
|
-
state.layouts[index] = layout;
|
|
36
|
-
}
|
|
37
|
-
}),
|
|
38
|
-
addItemToLayout: (index, item)=>{
|
|
39
|
-
return set((state)=>{
|
|
40
|
-
const layouts = state.layouts;
|
|
41
|
-
if (layouts && layouts[index]) {
|
|
42
|
-
var ref;
|
|
43
|
-
(ref = layouts[index]) === null || ref === void 0 ? void 0 : ref.spec.items.push(item);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
});
|
|
49
|
-
function useLayouts() {
|
|
50
|
-
return (0, _dashboardProvider.useDashboardStore)(({ layouts , updateLayout , addItemToLayout })=>({
|
|
51
|
-
layouts,
|
|
52
|
-
updateLayout,
|
|
53
|
-
addItemToLayout
|
|
54
|
-
}));
|
|
55
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
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
|
-
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
|
-
QueryStringProvider: ()=>QueryStringProvider,
|
|
25
|
-
useQueryString: ()=>useQueryString
|
|
26
|
-
});
|
|
27
|
-
const _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
29
|
-
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
30
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
31
|
-
if (typeof WeakMap !== "function") return null;
|
|
32
|
-
var cacheBabelInterop = new WeakMap();
|
|
33
|
-
var cacheNodeInterop = new WeakMap();
|
|
34
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
35
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
36
|
-
})(nodeInterop);
|
|
37
|
-
}
|
|
38
|
-
function _interopRequireWildcard(obj, nodeInterop) {
|
|
39
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
40
|
-
return obj;
|
|
41
|
-
}
|
|
42
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
43
|
-
return {
|
|
44
|
-
default: obj
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
48
|
-
if (cache && cache.has(obj)) {
|
|
49
|
-
return cache.get(obj);
|
|
50
|
-
}
|
|
51
|
-
var newObj = {};
|
|
52
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
53
|
-
for(var key in obj){
|
|
54
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
55
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
56
|
-
if (desc && (desc.get || desc.set)) {
|
|
57
|
-
Object.defineProperty(newObj, key, desc);
|
|
58
|
-
} else {
|
|
59
|
-
newObj[key] = obj[key];
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
newObj.default = obj;
|
|
64
|
-
if (cache) {
|
|
65
|
-
cache.set(obj, newObj);
|
|
66
|
-
}
|
|
67
|
-
return newObj;
|
|
68
|
-
}
|
|
69
|
-
function QueryStringProvider(props) {
|
|
70
|
-
const { queryString , setQueryString , children } = props;
|
|
71
|
-
const ctx = (0, _react.useMemo)(()=>({
|
|
72
|
-
queryString,
|
|
73
|
-
setQueryString
|
|
74
|
-
}), [
|
|
75
|
-
queryString,
|
|
76
|
-
setQueryString
|
|
77
|
-
]);
|
|
78
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.QueryStringContext.Provider, {
|
|
79
|
-
value: ctx,
|
|
80
|
-
children: children
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function useQueryString() {
|
|
84
|
-
const ctx = (0, _react.useContext)(_pluginSystem.QueryStringContext);
|
|
85
|
-
if (ctx === undefined) {
|
|
86
|
-
throw new Error('No QueryStringContext found. Did you forget a Provider?');
|
|
87
|
-
}
|
|
88
|
-
return ctx;
|
|
89
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
3
|
-
export interface PanelSpecEditorProps extends OptionsEditorProps<unknown> {
|
|
4
|
-
panelPluginKind: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function PanelSpecEditor(props: PanelSpecEditorProps): JSX.Element | null;
|
|
7
|
-
//# sourceMappingURL=PanelSpecEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PanelSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelSpecEditor.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,kBAAkB,EAAa,MAAM,2BAA2B,CAAC;AAE1E,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB,CAAC,OAAO,CAAC;IACvE,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,sBAkB1D"}
|
|
@@ -1,34 +0,0 @@
|
|
|
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 { usePlugin } from '@perses-dev/plugin-system';
|
|
15
|
-
export function PanelSpecEditor(props) {
|
|
16
|
-
const { panelPluginKind , ...others } = props;
|
|
17
|
-
const { data: plugin , isLoading } = usePlugin('Panel', panelPluginKind, {
|
|
18
|
-
useErrorBoundary: true,
|
|
19
|
-
enabled: panelPluginKind !== ''
|
|
20
|
-
});
|
|
21
|
-
// TODO: Proper loading indicator
|
|
22
|
-
if (isLoading) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
if (plugin === undefined) {
|
|
26
|
-
throw new Error(`Missing OptionsEditorComponent for Panel plugin with kind '${panelPluginKind}'`);
|
|
27
|
-
}
|
|
28
|
-
const { OptionsEditorComponent } = plugin;
|
|
29
|
-
return /*#__PURE__*/ _jsx(OptionsEditorComponent, {
|
|
30
|
-
...others
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=PanelSpecEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelSpecEditor.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 { OptionsEditorProps, usePlugin } from '@perses-dev/plugin-system';\n\nexport interface PanelSpecEditorProps extends OptionsEditorProps<unknown> {\n panelPluginKind: string;\n}\n\nexport function PanelSpecEditor(props: PanelSpecEditorProps) {\n const { panelPluginKind, ...others } = props;\n const { data: plugin, isLoading } = usePlugin('Panel', panelPluginKind, {\n useErrorBoundary: true,\n enabled: panelPluginKind !== '',\n });\n\n // TODO: Proper loading indicator\n if (isLoading) {\n return null;\n }\n\n if (plugin === undefined) {\n throw new Error(`Missing OptionsEditorComponent for Panel plugin with kind '${panelPluginKind}'`);\n }\n\n const { OptionsEditorComponent } = plugin;\n return <OptionsEditorComponent {...others} />;\n}\n"],"names":["usePlugin","PanelSpecEditor","props","panelPluginKind","others","data","plugin","isLoading","useErrorBoundary","enabled","undefined","Error","OptionsEditorComponent"],"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,SAA6BA,SAAS,QAAQ,2BAA2B,CAAC;AAM1E,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,eAAe,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGF,KAAK,AAAC;IAC7C,MAAM,EAAEG,IAAI,EAAEC,MAAM,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGP,SAAS,CAAC,OAAO,EAAEG,eAAe,EAAE;QACtEK,gBAAgB,EAAE,IAAI;QACtBC,OAAO,EAAEN,eAAe,KAAK,EAAE;KAChC,CAAC,AAAC;IAEH,iCAAiC;IACjC,IAAII,SAAS,EAAE;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAID,MAAM,KAAKI,SAAS,EAAE;QACxB,MAAM,IAAIC,KAAK,CAAC,CAAC,2DAA2D,EAAER,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACpG,CAAC;IAED,MAAM,EAAES,sBAAsB,CAAA,EAAE,GAAGN,MAAM,AAAC;IAC1C,qBAAO,KAACM,sBAAsB;QAAE,GAAGR,MAAM;MAAI,CAAC;AAChD,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { SelectProps } from '@mui/material';
|
|
3
|
-
export declare type PanelTypeSelectProps = Omit<SelectProps<string>, 'children'>;
|
|
4
|
-
/**
|
|
5
|
-
* Displays a MUI Select input for selecing a Panel type. Queries the plugin system to get the list of all panel types.
|
|
6
|
-
*/
|
|
7
|
-
export declare function PanelTypeSelect(props: PanelTypeSelectProps): JSX.Element;
|
|
8
|
-
//# sourceMappingURL=PanelTypeSelect.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PanelTypeSelect.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelTypeSelect.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,WAAW,EAAY,MAAM,eAAe,CAAC;AAG9D,oBAAY,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,CAAC;AAEzE;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAiB1D"}
|
|
@@ -1,34 +0,0 @@
|
|
|
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 { Select, MenuItem } from '@mui/material';
|
|
15
|
-
import { useListPluginMetadata } from '@perses-dev/plugin-system';
|
|
16
|
-
/**
|
|
17
|
-
* Displays a MUI Select input for selecing a Panel type. Queries the plugin system to get the list of all panel types.
|
|
18
|
-
*/ export function PanelTypeSelect(props) {
|
|
19
|
-
const { value: propValue , ...others } = props;
|
|
20
|
-
const { data , isLoading } = useListPluginMetadata('Panel');
|
|
21
|
-
// Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
|
|
22
|
-
const value = propValue !== '' && isLoading ? '' : propValue;
|
|
23
|
-
// TODO: Does this need a loading indicator of some kind?
|
|
24
|
-
return /*#__PURE__*/ _jsx(Select, {
|
|
25
|
-
...others,
|
|
26
|
-
value: value,
|
|
27
|
-
children: data === null || data === void 0 ? void 0 : data.map((metadata)=>/*#__PURE__*/ _jsx(MenuItem, {
|
|
28
|
-
value: metadata.kind,
|
|
29
|
-
children: metadata.display.name
|
|
30
|
-
}, metadata.kind))
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=PanelTypeSelect.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelTypeSelect.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 { Select, SelectProps, MenuItem } from '@mui/material';\nimport { useListPluginMetadata } from '@perses-dev/plugin-system';\n\nexport type PanelTypeSelectProps = Omit<SelectProps<string>, 'children'>;\n\n/**\n * Displays a MUI Select input for selecing a Panel type. Queries the plugin system to get the list of all panel types.\n */\nexport function PanelTypeSelect(props: PanelTypeSelectProps) {\n const { value: propValue, ...others } = props;\n const { data, isLoading } = useListPluginMetadata('Panel');\n\n // Pass an empty value while options are still loading so MUI doesn't complain about us using an \"out of range\" value\n const value = propValue !== '' && isLoading ? '' : propValue;\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <Select {...others} value={value}>\n {data?.map((metadata) => (\n <MenuItem key={metadata.kind} value={metadata.kind}>\n {metadata.display.name}\n </MenuItem>\n ))}\n </Select>\n );\n}\n"],"names":["Select","MenuItem","useListPluginMetadata","PanelTypeSelect","props","value","propValue","others","data","isLoading","map","metadata","kind","display","name"],"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,MAAM,EAAeC,QAAQ,QAAQ,eAAe,CAAC;AAC9D,SAASC,qBAAqB,QAAQ,2BAA2B,CAAC;AAIlE;;CAEC,GACD,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,KAAK,EAAEC,SAAS,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGH,KAAK,AAAC;IAC9C,MAAM,EAAEI,IAAI,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGP,qBAAqB,CAAC,OAAO,CAAC,AAAC;IAE3D,qHAAqH;IACrH,MAAMG,KAAK,GAAGC,SAAS,KAAK,EAAE,IAAIG,SAAS,GAAG,EAAE,GAAGH,SAAS,AAAC;IAE7D,yDAAyD;IACzD,qBACE,KAACN,MAAM;QAAE,GAAGO,MAAM;QAAEF,KAAK,EAAEA,KAAK;kBAC7BG,IAAI,aAAJA,IAAI,WAAK,GAATA,KAAAA,CAAS,GAATA,IAAI,CAAEE,GAAG,CAAC,CAACC,QAAQ,iBAClB,KAACV,QAAQ;gBAAqBI,KAAK,EAAEM,QAAQ,CAACC,IAAI;0BAC/CD,QAAQ,CAACE,OAAO,CAACC,IAAI;eADTH,QAAQ,CAACC,IAAI,CAEjB,AACZ,CAAC;MACK,CACT;AACJ,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface PanelEditorFormValues {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
group: number;
|
|
5
|
-
kind: string;
|
|
6
|
-
spec: unknown;
|
|
7
|
-
}
|
|
8
|
-
interface PanelDrawerModel {
|
|
9
|
-
drawerTitle: string;
|
|
10
|
-
submitButtonText: string;
|
|
11
|
-
initialValues: PanelEditorFormValues;
|
|
12
|
-
applyChanges: (values: PanelEditorFormValues) => void;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Returns props that are different depending on whether the PanelDrawer has been opened in add or edit mode. If the
|
|
16
|
-
* drawer isn't open at all, returns undefined.
|
|
17
|
-
*/
|
|
18
|
-
export declare function usePanelDrawerModel(): PanelDrawerModel | undefined;
|
|
19
|
-
/**
|
|
20
|
-
* Manages panel plugin spec state. The spec will be undefined while a plugin is being loaded.
|
|
21
|
-
*/
|
|
22
|
-
export declare function usePanelSpecState(panelPluginKind: string, initialState: unknown): {
|
|
23
|
-
spec: unknown;
|
|
24
|
-
onSpecChange: (next: unknown) => void;
|
|
25
|
-
};
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=panel-editor-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"panel-editor-model.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/panel-editor-model.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAGD,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,qBAAqB,CAAC;IACrC,YAAY,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;CACvD;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,gBAAgB,GAAG,SAAS,CAkFlE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO;;yBAYlD,OAAO;EAUpC"}
|
|
@@ -1,133 +0,0 @@
|
|
|
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 { useMemo } from 'react';
|
|
14
|
-
import { usePlugin } from '@perses-dev/plugin-system';
|
|
15
|
-
import { useImmer } from 'use-immer';
|
|
16
|
-
import { useDashboardApp, usePanels } from '../../context';
|
|
17
|
-
import { removeWhiteSpacesAndSpecialCharacters } from '../../utils/functions';
|
|
18
|
-
/**
|
|
19
|
-
* Returns props that are different depending on whether the PanelDrawer has been opened in add or edit mode. If the
|
|
20
|
-
* drawer isn't open at all, returns undefined.
|
|
21
|
-
*/ export function usePanelDrawerModel() {
|
|
22
|
-
const { panelDrawer } = useDashboardApp();
|
|
23
|
-
const { panels , updatePanel } = usePanels();
|
|
24
|
-
// If we're closed, no model to return
|
|
25
|
-
if (panelDrawer === undefined) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
// If we don't have a panel key, we're adding a new panel
|
|
29
|
-
const { panelKey , groupIndex } = panelDrawer;
|
|
30
|
-
if (panelKey === undefined) {
|
|
31
|
-
return {
|
|
32
|
-
drawerTitle: 'Add Panel',
|
|
33
|
-
submitButtonText: 'Add',
|
|
34
|
-
initialValues: {
|
|
35
|
-
name: '',
|
|
36
|
-
description: '',
|
|
37
|
-
group: groupIndex !== null && groupIndex !== void 0 ? groupIndex : 0,
|
|
38
|
-
kind: '',
|
|
39
|
-
spec: {}
|
|
40
|
-
},
|
|
41
|
-
applyChanges: (values)=>{
|
|
42
|
-
const { name , description , group , kind , spec } = values;
|
|
43
|
-
const panelKey = removeWhiteSpacesAndSpecialCharacters(name);
|
|
44
|
-
updatePanel(panelKey, {
|
|
45
|
-
kind: 'Panel',
|
|
46
|
-
spec: {
|
|
47
|
-
display: {
|
|
48
|
-
name,
|
|
49
|
-
description
|
|
50
|
-
},
|
|
51
|
-
plugin: {
|
|
52
|
-
kind,
|
|
53
|
-
spec
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}, group);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// Otherwise we have a panel key, so we're trying to edit an existing panel
|
|
61
|
-
const existingPanel = panels[panelKey];
|
|
62
|
-
// TODO: Can we better express this via the type system on the dashboard store to avoid these states?
|
|
63
|
-
if (existingPanel === undefined) {
|
|
64
|
-
throw new Error(`Cannot find existing panel '${panelKey}' to edit`);
|
|
65
|
-
}
|
|
66
|
-
if (groupIndex === undefined) {
|
|
67
|
-
throw new Error(`Cannot edit existing panel '${panelKey}' without its group index`);
|
|
68
|
-
}
|
|
69
|
-
var _description;
|
|
70
|
-
return {
|
|
71
|
-
drawerTitle: 'Edit Panel',
|
|
72
|
-
submitButtonText: 'Apply',
|
|
73
|
-
initialValues: {
|
|
74
|
-
name: existingPanel.spec.display.name,
|
|
75
|
-
description: (_description = existingPanel.spec.display.description) !== null && _description !== void 0 ? _description : '',
|
|
76
|
-
group: groupIndex,
|
|
77
|
-
kind: existingPanel.spec.plugin.kind,
|
|
78
|
-
spec: existingPanel.spec.plugin.spec
|
|
79
|
-
},
|
|
80
|
-
applyChanges: (values)=>{
|
|
81
|
-
const { name , description , group , kind , spec } = values;
|
|
82
|
-
updatePanel(panelKey, {
|
|
83
|
-
kind: 'Panel',
|
|
84
|
-
spec: {
|
|
85
|
-
display: {
|
|
86
|
-
name,
|
|
87
|
-
description
|
|
88
|
-
},
|
|
89
|
-
plugin: {
|
|
90
|
-
kind,
|
|
91
|
-
spec
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
if (group !== groupIndex) {
|
|
96
|
-
// TO DO: need to move panel if panel group changes
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Manages panel plugin spec state. The spec will be undefined while a plugin is being loaded.
|
|
103
|
-
*/ export function usePanelSpecState(panelPluginKind, initialState) {
|
|
104
|
-
// Keeping track of spec values by kind allows users to switch between panel types and come back with their old
|
|
105
|
-
// values intact from before the switch
|
|
106
|
-
const [specByKind, setSpecByKind] = useImmer({
|
|
107
|
-
[panelPluginKind]: initialState
|
|
108
|
-
});
|
|
109
|
-
const { data: plugin } = usePlugin('Panel', panelPluginKind, {
|
|
110
|
-
enabled: panelPluginKind !== ''
|
|
111
|
-
});
|
|
112
|
-
const pluginInitialSpec = useMemo(()=>{
|
|
113
|
-
return plugin === null || plugin === void 0 ? void 0 : plugin.createInitialOptions();
|
|
114
|
-
}, [
|
|
115
|
-
plugin
|
|
116
|
-
]);
|
|
117
|
-
var _panelPluginKind;
|
|
118
|
-
// Use the value in specByKind or if unset, use the initial values from the plugin (which could still be undefined)
|
|
119
|
-
const spec = (_panelPluginKind = specByKind[panelPluginKind]) !== null && _panelPluginKind !== void 0 ? _panelPluginKind : pluginInitialSpec;
|
|
120
|
-
// TODO: Do we want to expose more of a immer style API to plugin authors for managing their state, rather than the
|
|
121
|
-
// current "onChange" API?
|
|
122
|
-
const onSpecChange = (next)=>{
|
|
123
|
-
setSpecByKind((draft)=>{
|
|
124
|
-
draft[panelPluginKind] = next;
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
return {
|
|
128
|
-
spec,
|
|
129
|
-
onSpecChange
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
//# sourceMappingURL=panel-editor-model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/panel-editor-model.ts"],"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 { useMemo } from 'react';\nimport { usePlugin } from '@perses-dev/plugin-system';\nimport { useImmer } from 'use-immer';\nimport { useDashboardApp, usePanels } from '../../context';\nimport { removeWhiteSpacesAndSpecialCharacters } from '../../utils/functions';\n\nexport interface PanelEditorFormValues {\n name: string;\n description: string;\n group: number;\n kind: string;\n spec: unknown;\n}\n\n// Props that vary based on whether the PanelDrawer is in add or edit mode\ninterface PanelDrawerModel {\n drawerTitle: string;\n submitButtonText: string;\n initialValues: PanelEditorFormValues;\n applyChanges: (values: PanelEditorFormValues) => void;\n}\n\n/**\n * Returns props that are different depending on whether the PanelDrawer has been opened in add or edit mode. If the\n * drawer isn't open at all, returns undefined.\n */\nexport function usePanelDrawerModel(): PanelDrawerModel | undefined {\n const { panelDrawer } = useDashboardApp();\n const { panels, updatePanel } = usePanels();\n\n // If we're closed, no model to return\n if (panelDrawer === undefined) {\n return undefined;\n }\n\n // If we don't have a panel key, we're adding a new panel\n const { panelKey, groupIndex } = panelDrawer;\n if (panelKey === undefined) {\n return {\n drawerTitle: 'Add Panel',\n submitButtonText: 'Add',\n initialValues: {\n name: '',\n description: '',\n group: groupIndex ?? 0,\n kind: '',\n spec: {},\n },\n applyChanges: (values) => {\n const { name, description, group, kind, spec } = values;\n const panelKey = removeWhiteSpacesAndSpecialCharacters(name);\n updatePanel(\n panelKey,\n {\n kind: 'Panel',\n spec: {\n display: { name, description },\n plugin: {\n kind,\n spec,\n },\n },\n },\n group\n );\n },\n };\n }\n\n // Otherwise we have a panel key, so we're trying to edit an existing panel\n const existingPanel = panels[panelKey];\n\n // TODO: Can we better express this via the type system on the dashboard store to avoid these states?\n if (existingPanel === undefined) {\n throw new Error(`Cannot find existing panel '${panelKey}' to edit`);\n }\n if (groupIndex === undefined) {\n throw new Error(`Cannot edit existing panel '${panelKey}' without its group index`);\n }\n\n return {\n drawerTitle: 'Edit Panel',\n submitButtonText: 'Apply',\n initialValues: {\n name: existingPanel.spec.display.name,\n description: existingPanel.spec.display.description ?? '',\n group: groupIndex,\n kind: existingPanel.spec.plugin.kind,\n spec: existingPanel.spec.plugin.spec, // TODO: Should we clone to be safe?\n },\n applyChanges: (values) => {\n const { name, description, group, kind, spec } = values;\n updatePanel(panelKey, {\n kind: 'Panel',\n spec: {\n display: { name, description },\n plugin: {\n kind,\n spec,\n },\n },\n });\n\n if (group !== groupIndex) {\n // TO DO: need to move panel if panel group changes\n }\n },\n };\n}\n\n/**\n * Manages panel plugin spec state. The spec will be undefined while a plugin is being loaded.\n */\nexport function usePanelSpecState(panelPluginKind: string, initialState: unknown) {\n // Keeping track of spec values by kind allows users to switch between panel types and come back with their old\n // values intact from before the switch\n const [specByKind, setSpecByKind] = useImmer<Record<string, unknown>>({ [panelPluginKind]: initialState });\n const { data: plugin } = usePlugin('Panel', panelPluginKind, { enabled: panelPluginKind !== '' });\n const pluginInitialSpec = useMemo(() => plugin?.createInitialOptions(), [plugin]);\n\n // Use the value in specByKind or if unset, use the initial values from the plugin (which could still be undefined)\n const spec = specByKind[panelPluginKind] ?? pluginInitialSpec;\n\n // TODO: Do we want to expose more of a immer style API to plugin authors for managing their state, rather than the\n // current \"onChange\" API?\n const onSpecChange = (next: unknown) => {\n setSpecByKind((draft) => {\n draft[panelPluginKind] = next;\n });\n };\n\n return {\n spec,\n onSpecChange,\n };\n}\n"],"names":["useMemo","usePlugin","useImmer","useDashboardApp","usePanels","removeWhiteSpacesAndSpecialCharacters","usePanelDrawerModel","panelDrawer","panels","updatePanel","undefined","panelKey","groupIndex","drawerTitle","submitButtonText","initialValues","name","description","group","kind","spec","applyChanges","values","display","plugin","existingPanel","Error","usePanelSpecState","panelPluginKind","initialState","specByKind","setSpecByKind","data","enabled","pluginInitialSpec","createInitialOptions","onSpecChange","next","draft"],"mappings":"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"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
interface PanelDrawer {
|
|
2
|
-
groupIndex?: number;
|
|
3
|
-
panelKey?: string;
|
|
4
|
-
}
|
|
5
|
-
interface PanelGroupDialog {
|
|
6
|
-
groupIndex?: number;
|
|
7
|
-
}
|
|
8
|
-
export interface DashboardAppSlice {
|
|
9
|
-
panelDrawer?: PanelDrawer;
|
|
10
|
-
openPanelDrawer: (panelDrawer: PanelDrawer) => void;
|
|
11
|
-
closePanelDrawer: () => void;
|
|
12
|
-
panelGroupDialog?: PanelGroupDialog;
|
|
13
|
-
openPanelGroupDialog: (groupIndex?: number) => void;
|
|
14
|
-
closePanelGroupDialog: () => void;
|
|
15
|
-
}
|
|
16
|
-
export declare const createDashboardAppSlice: import("zustand").StateCreator<DashboardAppSlice, [], [["zustand/immer", never]], DashboardAppSlice>;
|
|
17
|
-
export declare function useDashboardApp(): {
|
|
18
|
-
panelDrawer: PanelDrawer | undefined;
|
|
19
|
-
openPanelDrawer: (panelDrawer: PanelDrawer) => void;
|
|
20
|
-
closePanelDrawer: () => void;
|
|
21
|
-
panelGroupDialog: PanelGroupDialog | undefined;
|
|
22
|
-
openPanelGroupDialog: (groupIndex?: number | undefined) => void;
|
|
23
|
-
closePanelGroupDialog: () => void;
|
|
24
|
-
};
|
|
25
|
-
export {};
|
|
26
|
-
//# sourceMappingURL=DashboardAppSlice.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardAppSlice.d.ts","sourceRoot":"","sources":["../../src/context/DashboardAppSlice.tsx"],"names":[],"mappings":"AAgBA,UAAU,WAAW;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AACD,UAAU,gBAAgB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,eAAe,EAAE,CAAC,WAAW,EAAE,WAAW,KAAK,IAAI,CAAC;IACpD,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,oBAAoB,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,qBAAqB,EAAE,MAAM,IAAI,CAAC;CACnC;AAED,eAAO,MAAM,uBAAuB,sGAoBjC,CAAC;AAEJ,wBAAgB,eAAe;;;;;;;EAkB9B"}
|
|
@@ -1,45 +0,0 @@
|
|
|
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 { immer } from 'zustand/middleware/immer';
|
|
14
|
-
import { useDashboardStore } from './DashboardProvider';
|
|
15
|
-
export const createDashboardAppSlice = immer((set)=>({
|
|
16
|
-
openPanelDrawer: ({ groupIndex , panelKey })=>set((state)=>{
|
|
17
|
-
state.panelDrawer = {
|
|
18
|
-
groupIndex,
|
|
19
|
-
panelKey
|
|
20
|
-
};
|
|
21
|
-
}),
|
|
22
|
-
closePanelDrawer: ()=>set((state)=>{
|
|
23
|
-
state.panelDrawer = undefined;
|
|
24
|
-
}),
|
|
25
|
-
openPanelGroupDialog: (groupIndex)=>set((state)=>{
|
|
26
|
-
state.panelGroupDialog = {
|
|
27
|
-
groupIndex
|
|
28
|
-
};
|
|
29
|
-
}),
|
|
30
|
-
closePanelGroupDialog: ()=>set((state)=>{
|
|
31
|
-
state.panelGroupDialog = undefined;
|
|
32
|
-
})
|
|
33
|
-
}));
|
|
34
|
-
export function useDashboardApp() {
|
|
35
|
-
return useDashboardStore(({ panelDrawer , openPanelDrawer , closePanelDrawer , panelGroupDialog , openPanelGroupDialog , closePanelGroupDialog , })=>({
|
|
36
|
-
panelDrawer,
|
|
37
|
-
openPanelDrawer,
|
|
38
|
-
closePanelDrawer,
|
|
39
|
-
panelGroupDialog,
|
|
40
|
-
openPanelGroupDialog,
|
|
41
|
-
closePanelGroupDialog
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=DashboardAppSlice.js.map
|