@perses-dev/dashboards 0.0.0-snapshot-color-palette-gen-test-0ebddd6 → 0.0.0-snapshot-saving-defaults-refinements-1b25cec
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/DashboardStickyToolbar/DashboardStickyToolbar.js +79 -0
- package/dist/cjs/{stories/decorators/WithQueryParams.js → components/DashboardStickyToolbar/index.js} +11 -12
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -24
- package/dist/cjs/components/EditJsonButton/EditJsonButton.js +1 -0
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +5 -0
- package/dist/cjs/components/GridLayout/GridItemContent.js +22 -4
- package/dist/cjs/components/GridLayout/GridLayout.js +31 -2
- package/dist/cjs/components/GridLayout/GridTitle.js +30 -9
- package/dist/cjs/components/Panel/Panel.js +2 -2
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +41 -34
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +32 -18
- package/dist/cjs/components/PanelDrawer/usePanelEditor.js +87 -0
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +92 -0
- package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +28 -0
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +81 -0
- package/dist/cjs/components/SaveDashboardButton/index.js +28 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +5 -5
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +124 -198
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +178 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
- package/dist/cjs/components/Variables/VariableList.js +16 -55
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/components/index.js +3 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +9 -8
- package/dist/cjs/context/DashboardProvider/common.js +26 -6
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -4
- package/dist/cjs/context/DashboardProvider/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +8 -32
- package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +33 -0
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +56 -7
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +2 -0
- package/dist/cjs/context/TemplateVariableProvider/utils.js +44 -0
- package/dist/cjs/context/useDashboard.js +4 -4
- package/dist/cjs/stories/decorators/WithDatasourceStore.js +2 -47
- package/dist/cjs/stories/decorators/index.js +0 -4
- package/dist/cjs/test/datasource-provider.js +70 -0
- package/dist/cjs/test/index.js +1 -0
- package/dist/cjs/test/plugin-registry.js +11 -5
- package/dist/cjs/test/render.js +35 -13
- package/dist/cjs/test/testDashboard.js +79 -79
- package/dist/cjs/utils/index.js +1 -0
- package/dist/cjs/{stories/decorators/WithQueryClient.js → utils/time.js} +9 -11
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +9 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +68 -0
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -0
- package/dist/components/DashboardStickyToolbar/index.d.ts +2 -0
- package/dist/components/DashboardStickyToolbar/index.d.ts.map +1 -0
- package/dist/{stories/decorators/WithQueryClient.js → components/DashboardStickyToolbar/index.js} +2 -10
- package/dist/components/DashboardStickyToolbar/index.js.map +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +10 -26
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js +1 -0
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +5 -0
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +1 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +22 -4
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +31 -2
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +30 -9
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- 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 +3 -3
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +42 -35
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +32 -18
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.d.ts +15 -0
- package/dist/components/PanelDrawer/usePanelEditor.d.ts.map +1 -0
- package/dist/components/PanelDrawer/usePanelEditor.js +84 -0
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +3 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +86 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/SaveChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/{stories/decorators/WithQueryParams.js → components/SaveChangesConfirmationDialog/index.js} +2 -10
- package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +10 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +75 -0
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -0
- package/dist/components/SaveDashboardButton/index.d.ts +2 -0
- package/dist/components/SaveDashboardButton/index.d.ts.map +1 -0
- package/dist/components/SaveDashboardButton/index.js +15 -0
- package/dist/components/SaveDashboardButton/index.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +6 -6
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -2
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +127 -196
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +16 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +122 -0
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.js +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -8
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +1 -7
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +18 -52
- 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 +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +4 -3
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +9 -8
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.d.ts +3 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -1
- package/dist/context/DashboardProvider/common.js +17 -2
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +6 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +11 -3
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/index.d.ts +1 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js +1 -0
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +3 -6
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +9 -33
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js +27 -0
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +10 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +51 -7
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +2 -0
- package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.d.ts +7 -0
- package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -0
- package/dist/context/TemplateVariableProvider/utils.js +40 -0
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -0
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +4 -4
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDatasourceStore.js +1 -46
- package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
- package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
- package/dist/stories/decorators/index.js +0 -4
- package/dist/stories/decorators/index.js.map +1 -1
- package/dist/test/datasource-provider.d.ts +6 -0
- package/dist/test/datasource-provider.d.ts.map +1 -0
- package/dist/test/datasource-provider.js +60 -0
- package/dist/test/datasource-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 +1 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +11 -5
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +35 -13
- package/dist/test/render.js.map +1 -1
- package/dist/test/testDashboard.js +79 -79
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/time.d.ts +5 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +23 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +3 -2
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/package.json +7 -6
- package/dist/cjs/stories/decorators/WithPluginRegistry.js +0 -91
- package/dist/cjs/stories/decorators/WithTimeRange.js +0 -38
- package/dist/stories/decorators/WithPluginRegistry.js +0 -46
- package/dist/stories/decorators/WithPluginRegistry.js.map +0 -1
- package/dist/stories/decorators/WithQueryClient.js.map +0 -1
- package/dist/stories/decorators/WithQueryParams.js.map +0 -1
- package/dist/stories/decorators/WithTimeRange.js +0 -32
- package/dist/stories/decorators/WithTimeRange.js.map +0 -1
|
@@ -19,66 +19,27 @@ Object.defineProperty(exports, "TemplateVariableList", {
|
|
|
19
19
|
get: ()=>TemplateVariableList
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const _react = require("react");
|
|
23
22
|
const _material = require("@mui/material");
|
|
24
|
-
const _pinOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOutline"));
|
|
25
|
-
const _pinOffOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOffOutline"));
|
|
26
23
|
const _context = require("../../context");
|
|
27
24
|
const _templateVariable = require("./TemplateVariable");
|
|
28
|
-
function _interopRequireDefault(obj) {
|
|
29
|
-
return obj && obj.__esModule ? obj : {
|
|
30
|
-
default: obj
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
25
|
const VARIABLE_INPUT_MIN_WIDTH = '120px';
|
|
34
26
|
const VARIABLE_INPUT_MAX_WIDTH = '240px';
|
|
35
|
-
function TemplateVariableList(
|
|
36
|
-
const [isPin, setIsPin] = (0, _react.useState)(props.initialVariableIsSticky);
|
|
27
|
+
function TemplateVariableList() {
|
|
37
28
|
const variableDefinitions = (0, _context.useTemplateVariableDefinitions)();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
backgroundColor: 'inherit',
|
|
53
|
-
...props.sx
|
|
54
|
-
},
|
|
55
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
56
|
-
display: "flex",
|
|
57
|
-
flexWrap: "wrap",
|
|
58
|
-
alignItems: "start",
|
|
59
|
-
my: isSticky ? 2 : 0,
|
|
60
|
-
ml: isSticky ? 2 : 0,
|
|
61
|
-
children: [
|
|
62
|
-
variableDefinitions.map((v)=>{
|
|
63
|
-
var ref;
|
|
64
|
-
/*#__PURE__*/ return (0, _jsxRuntime.jsx)(_material.Box, {
|
|
65
|
-
display: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) ? 'none' : undefined,
|
|
66
|
-
minWidth: VARIABLE_INPUT_MIN_WIDTH,
|
|
67
|
-
maxWidth: VARIABLE_INPUT_MAX_WIDTH,
|
|
68
|
-
marginBottom: 1,
|
|
69
|
-
marginRight: 1,
|
|
70
|
-
"data-testid": "template-variable",
|
|
71
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_templateVariable.TemplateVariable, {
|
|
72
|
-
name: v.spec.name
|
|
73
|
-
}, v.spec.name)
|
|
74
|
-
}, v.spec.name);
|
|
75
|
-
}),
|
|
76
|
-
props.initialVariableIsSticky && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
77
|
-
onClick: ()=>setIsPin(!isPin),
|
|
78
|
-
children: isPin ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pinOutline.default, {}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pinOffOutline.default, {})
|
|
79
|
-
})
|
|
80
|
-
]
|
|
81
|
-
})
|
|
29
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
30
|
+
children: variableDefinitions.map((v)=>{
|
|
31
|
+
var ref;
|
|
32
|
+
/*#__PURE__*/ return (0, _jsxRuntime.jsx)(_material.Box, {
|
|
33
|
+
display: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) ? 'none' : undefined,
|
|
34
|
+
minWidth: VARIABLE_INPUT_MIN_WIDTH,
|
|
35
|
+
maxWidth: VARIABLE_INPUT_MAX_WIDTH,
|
|
36
|
+
marginBottom: 1,
|
|
37
|
+
marginRight: 1,
|
|
38
|
+
"data-testid": "template-variable",
|
|
39
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_templateVariable.TemplateVariable, {
|
|
40
|
+
name: v.spec.name
|
|
41
|
+
}, v.spec.name)
|
|
42
|
+
}, v.spec.name);
|
|
82
43
|
})
|
|
83
|
-
})
|
|
44
|
+
});
|
|
84
45
|
}
|
|
@@ -19,6 +19,7 @@ _exportStar(require("./TemplateVariable"), exports);
|
|
|
19
19
|
_exportStar(require("./VariableEditor"), exports);
|
|
20
20
|
_exportStar(require("./VariableEditorForm"), exports);
|
|
21
21
|
_exportStar(require("./VariableList"), exports);
|
|
22
|
+
_exportStar(require("./variable-model"), exports);
|
|
22
23
|
function _exportStar(from, to) {
|
|
23
24
|
Object.keys(from).forEach(function(k) {
|
|
24
25
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -18,6 +18,7 @@ _exportStar(require("./AddGroupButton"), exports);
|
|
|
18
18
|
_exportStar(require("./AddPanelButton"), exports);
|
|
19
19
|
_exportStar(require("./Dashboard"), exports);
|
|
20
20
|
_exportStar(require("./DashboardToolbar"), exports);
|
|
21
|
+
_exportStar(require("./DashboardStickyToolbar"), exports);
|
|
21
22
|
_exportStar(require("./DeletePanelDialog"), exports);
|
|
22
23
|
_exportStar(require("./DeletePanelGroupDialog"), exports);
|
|
23
24
|
_exportStar(require("./DiscardChangesConfirmationDialog"), exports);
|
|
@@ -30,6 +31,8 @@ _exportStar(require("./Panel"), exports);
|
|
|
30
31
|
_exportStar(require("./PanelDrawer"), exports);
|
|
31
32
|
_exportStar(require("./PanelGroupDialog"), exports);
|
|
32
33
|
_exportStar(require("./QuerySummaryTable"), exports);
|
|
34
|
+
_exportStar(require("./SaveChangesConfirmationDialog"), exports);
|
|
35
|
+
_exportStar(require("./SaveDashboardButton"), exports);
|
|
33
36
|
_exportStar(require("./TimeRangeControls"), exports);
|
|
34
37
|
_exportStar(require("./ToolbarIconButton"), exports);
|
|
35
38
|
_exportStar(require("./Variables"), exports);
|
|
@@ -39,8 +39,10 @@ const _panelSlice = require("./panel-slice");
|
|
|
39
39
|
const _deletePanelGroupSlice = require("./delete-panel-group-slice");
|
|
40
40
|
const _deletePanelSlice = require("./delete-panel-slice");
|
|
41
41
|
const _discardChangesDialogSlice = require("./discard-changes-dialog-slice");
|
|
42
|
+
const _saveChangesDialogSlice = require("./save-changes-dialog-slice");
|
|
42
43
|
const _duplicatePanelSlice = require("./duplicate-panel-slice");
|
|
43
44
|
const _editJsonDialogSlice = require("./edit-json-dialog-slice");
|
|
45
|
+
const _common = require("./common");
|
|
44
46
|
const DashboardContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
45
47
|
function useDashboardStore(selector) {
|
|
46
48
|
const store = (0, _react.useContext)(DashboardContext);
|
|
@@ -61,12 +63,11 @@ function DashboardProvider(props) {
|
|
|
61
63
|
const [store] = (0, _react.useState)(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders
|
|
62
64
|
(0, _react.useEffect)(()=>{
|
|
63
65
|
if (plugin === undefined) return;
|
|
64
|
-
const
|
|
65
|
-
// set default panel kind and
|
|
66
|
+
const defaultPanelSpec = plugin.createInitialOptions();
|
|
67
|
+
// set default panel kind, spec, and queries for add panel editor
|
|
66
68
|
store.setState({
|
|
67
69
|
initialValues: {
|
|
68
|
-
|
|
69
|
-
spec
|
|
70
|
+
panelDefinition: (0, _common.createPanelDefinition)(defaultPanelKind, defaultPanelSpec)
|
|
70
71
|
}
|
|
71
72
|
});
|
|
72
73
|
}, [
|
|
@@ -98,16 +99,15 @@ function initStore(props) {
|
|
|
98
99
|
...(0, _duplicatePanelSlice.createDuplicatePanelSlice)()(...args),
|
|
99
100
|
/* General */ ...(0, _discardChangesDialogSlice.createDiscardChangesDialogSlice)(...args),
|
|
100
101
|
...(0, _editJsonDialogSlice.createEditJsonDialogSlice)(...args),
|
|
102
|
+
...(0, _saveChangesDialogSlice.createSaveChangesDialogSlice)(...args),
|
|
101
103
|
metadata,
|
|
102
104
|
display,
|
|
103
|
-
|
|
104
|
-
pastDuration: duration
|
|
105
|
-
},
|
|
105
|
+
duration,
|
|
106
106
|
isEditMode: !!isEditMode,
|
|
107
107
|
setEditMode: (isEditMode)=>set({
|
|
108
108
|
isEditMode
|
|
109
109
|
}),
|
|
110
|
-
setDashboard: ({ metadata , spec: { display , panels ={} , layouts =[] } })=>{
|
|
110
|
+
setDashboard: ({ metadata , spec: { display , panels ={} , layouts =[] , duration } })=>{
|
|
111
111
|
set((state)=>{
|
|
112
112
|
state.metadata = metadata;
|
|
113
113
|
state.display = display;
|
|
@@ -115,6 +115,7 @@ function initStore(props) {
|
|
|
115
115
|
const { panelGroups , panelGroupOrder } = (0, _panelGroupSlice.convertLayoutsToPanelGroups)(layouts);
|
|
116
116
|
state.panelGroups = panelGroups;
|
|
117
117
|
state.panelGroupOrder = panelGroupOrder;
|
|
118
|
+
state.duration = duration;
|
|
118
119
|
});
|
|
119
120
|
}
|
|
120
121
|
};
|
|
@@ -10,15 +10,19 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
* The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).
|
|
15
|
-
*/ "use strict";
|
|
13
|
+
"use strict";
|
|
16
14
|
Object.defineProperty(exports, "__esModule", {
|
|
17
15
|
value: true
|
|
18
16
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
generateId: ()=>generateId,
|
|
25
|
+
createPanelDefinition: ()=>createPanelDefinition
|
|
22
26
|
});
|
|
23
27
|
function generateId() {
|
|
24
28
|
if (globalThis.dashboardStoreId === undefined) {
|
|
@@ -26,3 +30,19 @@ function generateId() {
|
|
|
26
30
|
}
|
|
27
31
|
return globalThis.dashboardStoreId++;
|
|
28
32
|
}
|
|
33
|
+
function createPanelDefinition(defaultPanelKind, defaultPanelSpec) {
|
|
34
|
+
return {
|
|
35
|
+
kind: 'Panel',
|
|
36
|
+
spec: {
|
|
37
|
+
display: {
|
|
38
|
+
name: '',
|
|
39
|
+
description: undefined
|
|
40
|
+
},
|
|
41
|
+
plugin: {
|
|
42
|
+
kind: defaultPanelKind !== null && defaultPanelKind !== void 0 ? defaultPanelKind : '',
|
|
43
|
+
spec: defaultPanelSpec !== null && defaultPanelSpec !== void 0 ? defaultPanelSpec : {}
|
|
44
|
+
},
|
|
45
|
+
queries: []
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -33,7 +33,8 @@ _export(exports, {
|
|
|
33
33
|
usePanelActions: ()=>usePanelActions,
|
|
34
34
|
usePanelEditor: ()=>usePanelEditor,
|
|
35
35
|
useDeletePanelDialog: ()=>useDeletePanelDialog,
|
|
36
|
-
|
|
36
|
+
useDashboardDuration: ()=>useDashboardDuration,
|
|
37
|
+
useSaveChangesConfirmationDialog: ()=>useSaveChangesConfirmationDialog,
|
|
37
38
|
useDiscardChangesConfirmationDialog: ()=>useDiscardChangesConfirmationDialog,
|
|
38
39
|
useEditJsonDialog: ()=>useEditJsonDialog
|
|
39
40
|
});
|
|
@@ -189,9 +190,17 @@ function useDeletePanelDialog() {
|
|
|
189
190
|
// TODO: Refactor similar to other dialogs/editors so these are on the editor state itself
|
|
190
191
|
return (0, _dashboardProvider.useDashboardStore)(selectDeletePanelDialog);
|
|
191
192
|
}
|
|
192
|
-
const
|
|
193
|
-
function
|
|
194
|
-
return (0, _dashboardProvider.useDashboardStore)(
|
|
193
|
+
const selectDashboardDuration = (state)=>state.duration;
|
|
194
|
+
function useDashboardDuration() {
|
|
195
|
+
return (0, _dashboardProvider.useDashboardStore)(selectDashboardDuration);
|
|
196
|
+
}
|
|
197
|
+
const selectSaveChangesConfirmationDialog = ({ saveChangesConfirmationDialog , openSaveChangesConfirmationDialog , closeSaveChangesConfirmationDialog })=>({
|
|
198
|
+
saveChangesConfirmationDialog,
|
|
199
|
+
openSaveChangesConfirmationDialog,
|
|
200
|
+
closeSaveChangesConfirmationDialog
|
|
201
|
+
});
|
|
202
|
+
function useSaveChangesConfirmationDialog() {
|
|
203
|
+
return (0, _dashboardProvider.useDashboardStore)(selectSaveChangesConfirmationDialog);
|
|
195
204
|
}
|
|
196
205
|
const selectDiscardChangesConfirmationDialog = ({ discardChangesConfirmationDialog , openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog })=>({
|
|
197
206
|
discardChangesConfirmationDialog,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
_exportStar(require("./common"), exports);
|
|
17
18
|
_exportStar(require("./dashboard-provider-api"), exports);
|
|
18
19
|
_exportStar(require("./DashboardProvider"), exports);
|
|
19
20
|
function _exportStar(from, to) {
|
|
@@ -40,20 +40,15 @@ function createPanelEditorSlice() {
|
|
|
40
40
|
if (panelToEdit === undefined) {
|
|
41
41
|
throw new Error(`Cannot find Panel with key '${panelKey}'`);
|
|
42
42
|
}
|
|
43
|
-
var _description;
|
|
44
43
|
const editorState = {
|
|
45
44
|
mode: 'Edit',
|
|
46
45
|
initialValues: {
|
|
47
|
-
name: panelToEdit.spec.display.name,
|
|
48
|
-
description: (_description = panelToEdit.spec.display.description) !== null && _description !== void 0 ? _description : '',
|
|
49
46
|
groupId: panelGroupItemId.panelGroupId,
|
|
50
|
-
|
|
51
|
-
spec: panelToEdit.spec.plugin.spec
|
|
47
|
+
panelDefinition: panelToEdit
|
|
52
48
|
},
|
|
53
49
|
applyChanges: (next)=>{
|
|
54
|
-
const panelDefinititon = createPanelDefinitionFromEditorValues(next);
|
|
55
50
|
set((state)=>{
|
|
56
|
-
state.panels[panelKey] =
|
|
51
|
+
state.panels[panelKey] = next.panelDefinition;
|
|
57
52
|
// If the panel didn't change groups, nothing else to do
|
|
58
53
|
if (next.groupId === panelGroupId) {
|
|
59
54
|
return;
|
|
@@ -99,7 +94,7 @@ function createPanelEditorSlice() {
|
|
|
99
94
|
});
|
|
100
95
|
},
|
|
101
96
|
openAddPanel (panelGroupId) {
|
|
102
|
-
var ref
|
|
97
|
+
var ref;
|
|
103
98
|
// If a panel group isn't supplied, add to the first group or create a group if there aren't any
|
|
104
99
|
let newGroup = undefined;
|
|
105
100
|
panelGroupId !== null && panelGroupId !== void 0 ? panelGroupId : panelGroupId = get().panelGroupOrder[0];
|
|
@@ -108,22 +103,19 @@ function createPanelEditorSlice() {
|
|
|
108
103
|
newGroup.title = 'Panel Group';
|
|
109
104
|
panelGroupId = newGroup.id;
|
|
110
105
|
}
|
|
111
|
-
var
|
|
106
|
+
var ref1;
|
|
112
107
|
const editorState = {
|
|
113
108
|
mode: 'Add',
|
|
114
109
|
initialValues: {
|
|
115
|
-
name: '',
|
|
116
|
-
description: '',
|
|
117
110
|
groupId: panelGroupId,
|
|
118
|
-
|
|
119
|
-
spec: (ref3 = (ref1 = get().initialValues) === null || ref1 === void 0 ? void 0 : ref1.spec) !== null && ref3 !== void 0 ? ref3 : {}
|
|
111
|
+
panelDefinition: (ref1 = (ref = get().initialValues) === null || ref === void 0 ? void 0 : ref.panelDefinition) !== null && ref1 !== void 0 ? ref1 : (0, _common.createPanelDefinition)()
|
|
120
112
|
},
|
|
121
113
|
applyChanges: (next)=>{
|
|
122
|
-
const
|
|
123
|
-
const panelKey = (0, _panelUtils.getValidPanelKey)(
|
|
114
|
+
const name = next.panelDefinition.spec.display.name;
|
|
115
|
+
const panelKey = (0, _panelUtils.getValidPanelKey)(name, get().panels);
|
|
124
116
|
set((state)=>{
|
|
125
117
|
// Add a panel
|
|
126
|
-
state.panels[panelKey] =
|
|
118
|
+
state.panels[panelKey] = next.panelDefinition;
|
|
127
119
|
// Also add a panel group item referencing the panel
|
|
128
120
|
const group = state.panelGroups[next.groupId];
|
|
129
121
|
if (group === undefined) {
|
|
@@ -158,19 +150,3 @@ function createPanelEditorSlice() {
|
|
|
158
150
|
};
|
|
159
151
|
};
|
|
160
152
|
}
|
|
161
|
-
// Helper to create PanelDefinitions when saving
|
|
162
|
-
function createPanelDefinitionFromEditorValues(editorValues) {
|
|
163
|
-
return {
|
|
164
|
-
kind: 'Panel',
|
|
165
|
-
spec: {
|
|
166
|
-
display: {
|
|
167
|
-
name: editorValues.name,
|
|
168
|
-
description: editorValues.description !== '' ? editorValues.description : undefined
|
|
169
|
-
},
|
|
170
|
-
plugin: {
|
|
171
|
-
kind: editorValues.kind,
|
|
172
|
-
spec: editorValues.spec
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "createSaveChangesDialogSlice", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>createSaveChangesDialogSlice
|
|
20
|
+
});
|
|
21
|
+
const createSaveChangesDialogSlice = (set)=>({
|
|
22
|
+
isOpen: false,
|
|
23
|
+
openSaveChangesConfirmationDialog (dialog) {
|
|
24
|
+
set((state)=>{
|
|
25
|
+
state.saveChangesConfirmationDialog = dialog;
|
|
26
|
+
}, false, 'openSaveChangesConfirmationDialog');
|
|
27
|
+
},
|
|
28
|
+
closeSaveChangesConfirmationDialog () {
|
|
29
|
+
set((state)=>{
|
|
30
|
+
state.saveChangesConfirmationDialog = undefined;
|
|
31
|
+
}, false, 'closeSaveChangesConfirmationDialog');
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -33,9 +33,16 @@ const _react = require("react");
|
|
|
33
33
|
const _zustand = require("zustand");
|
|
34
34
|
const _immer = require("zustand/middleware/immer");
|
|
35
35
|
const _middleware = require("zustand/middleware");
|
|
36
|
+
const _immer1 = /*#__PURE__*/ _interopRequireDefault(require("immer"));
|
|
36
37
|
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
38
|
+
const _utils = require("./utils");
|
|
37
39
|
const _hydrationUtils = require("./hydrationUtils");
|
|
38
40
|
const _queryParams = require("./query-params");
|
|
41
|
+
function _interopRequireDefault(obj) {
|
|
42
|
+
return obj && obj.__esModule ? obj : {
|
|
43
|
+
default: obj
|
|
44
|
+
};
|
|
45
|
+
}
|
|
39
46
|
const TemplateVariableStoreContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
40
47
|
function useTemplateVariableStoreCtx() {
|
|
41
48
|
const context = (0, _react.useContext)(TemplateVariableStoreContext);
|
|
@@ -80,7 +87,9 @@ function useTemplateVariableActions() {
|
|
|
80
87
|
setVariableValue: s.setVariableValue,
|
|
81
88
|
setVariableLoading: s.setVariableLoading,
|
|
82
89
|
setVariableOptions: s.setVariableOptions,
|
|
83
|
-
setVariableDefinitions: s.setVariableDefinitions
|
|
90
|
+
setVariableDefinitions: s.setVariableDefinitions,
|
|
91
|
+
setVariableDefaultValues: s.setVariableDefaultValues,
|
|
92
|
+
getSavedVariablesStatus: s.getSavedVariablesStatus
|
|
84
93
|
};
|
|
85
94
|
});
|
|
86
95
|
}
|
|
@@ -123,14 +132,16 @@ function PluginProvider({ children }) {
|
|
|
123
132
|
}
|
|
124
133
|
function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , queryParams }) {
|
|
125
134
|
const initialParams = (0, _queryParams.getInitalValuesFromQueryParameters)(queryParams ? queryParams[0] : {});
|
|
126
|
-
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set)=>
|
|
135
|
+
const store = (0, _zustand.createStore)()((0, _middleware.devtools)((0, _immer.immer)((set, get)=>{
|
|
136
|
+
return {
|
|
127
137
|
variableState: (0, _hydrationUtils.hydrateTemplateVariableStates)(initialVariableDefinitions, initialParams),
|
|
128
138
|
variableDefinitions: initialVariableDefinitions,
|
|
129
139
|
setVariableDefinitions (definitions) {
|
|
130
140
|
set((state)=>{
|
|
131
141
|
state.variableDefinitions = definitions;
|
|
132
142
|
state.variableState = (0, _hydrationUtils.hydrateTemplateVariableStates)(definitions, initialParams);
|
|
133
|
-
}
|
|
143
|
+
}, false, '[Variables] setVariableDefinitions' // Used for action name in Redux devtools
|
|
144
|
+
);
|
|
134
145
|
},
|
|
135
146
|
setVariableOptions (name, options) {
|
|
136
147
|
set((state)=>{
|
|
@@ -139,7 +150,7 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , query
|
|
|
139
150
|
return;
|
|
140
151
|
}
|
|
141
152
|
varState.options = options;
|
|
142
|
-
});
|
|
153
|
+
}, false, '[Variables] setVariableOptions');
|
|
143
154
|
},
|
|
144
155
|
setVariableLoading (name, loading) {
|
|
145
156
|
set((state)=>{
|
|
@@ -148,7 +159,7 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , query
|
|
|
148
159
|
return;
|
|
149
160
|
}
|
|
150
161
|
varState.loading = loading;
|
|
151
|
-
});
|
|
162
|
+
}, false, '[Variables] setVariableLoading');
|
|
152
163
|
},
|
|
153
164
|
setVariableValue: (name, value)=>set((state)=>{
|
|
154
165
|
let val = value;
|
|
@@ -171,8 +182,46 @@ function createTemplateVariableSrvStore({ initialVariableDefinitions =[] , query
|
|
|
171
182
|
});
|
|
172
183
|
}
|
|
173
184
|
varState.value = val;
|
|
174
|
-
})
|
|
175
|
-
|
|
185
|
+
}, false, '[Variables] setVariableValue'),
|
|
186
|
+
setVariableDefaultValues: ()=>{
|
|
187
|
+
const variableDefinitions = get().variableDefinitions;
|
|
188
|
+
const variableState = get().variableState;
|
|
189
|
+
const updatedVariables = (0, _immer1.default)(variableDefinitions, (draft)=>{
|
|
190
|
+
draft.forEach((variable, index)=>{
|
|
191
|
+
if (variable.kind === 'ListVariable') {
|
|
192
|
+
const currentVariable = variableState[variable.spec.name];
|
|
193
|
+
if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== undefined) {
|
|
194
|
+
draft[index] = {
|
|
195
|
+
kind: 'ListVariable',
|
|
196
|
+
spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
|
|
197
|
+
specDraft.default_value = currentVariable.value;
|
|
198
|
+
})
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
} else if (variable.kind === 'TextVariable') {
|
|
202
|
+
const currentVariable1 = variableState[variable.spec.name];
|
|
203
|
+
const currentVariableValue = typeof (currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) === 'string' ? currentVariable1.value : '';
|
|
204
|
+
if ((currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) !== undefined) {
|
|
205
|
+
draft[index] = {
|
|
206
|
+
kind: 'TextVariable',
|
|
207
|
+
spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
|
|
208
|
+
specDraft.value = currentVariableValue;
|
|
209
|
+
})
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
set((state)=>{
|
|
216
|
+
state.variableDefinitions = updatedVariables;
|
|
217
|
+
}, false, '[Variables] setVariableDefaultValues');
|
|
218
|
+
return updatedVariables;
|
|
219
|
+
},
|
|
220
|
+
getSavedVariablesStatus: ()=>{
|
|
221
|
+
return (0, _utils.checkSavedDefaultVariableStatus)(get().variableDefinitions, get().variableState);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
})));
|
|
176
225
|
return store;
|
|
177
226
|
}
|
|
178
227
|
function TemplateVariableProvider({ children , initialVariableDefinitions =[] }) {
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "hydrateTemplateVariableStates", {
|
|
|
19
19
|
get: ()=>hydrateTemplateVariableStates
|
|
20
20
|
});
|
|
21
21
|
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
22
|
+
// TODO: move to TemplateVariableProvider/utils.ts
|
|
22
23
|
function hydrateTemplateVariableState(variable, initialValue) {
|
|
23
24
|
const varState = {
|
|
24
25
|
value: null,
|
|
@@ -32,6 +33,7 @@ function hydrateTemplateVariableState(variable, initialValue) {
|
|
|
32
33
|
varState.options = [];
|
|
33
34
|
var ref;
|
|
34
35
|
varState.value = (ref = initialValue !== null && initialValue !== void 0 ? initialValue : variable.spec.default_value) !== null && ref !== void 0 ? ref : null;
|
|
36
|
+
// TODO: smarter fallbacks for default_value when allow_all_value is true
|
|
35
37
|
if (varState.options.length > 0 && !varState.value) {
|
|
36
38
|
var ref1;
|
|
37
39
|
var ref2;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "checkSavedDefaultVariableStatus", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>checkSavedDefaultVariableStatus
|
|
20
|
+
});
|
|
21
|
+
function checkSavedDefaultVariableStatus(definitions, varState) {
|
|
22
|
+
let isSavedVariableModified = false;
|
|
23
|
+
const modifiedVariableNames = [];
|
|
24
|
+
for (const savedVariable of definitions){
|
|
25
|
+
if (savedVariable.kind === 'ListVariable') {
|
|
26
|
+
const currentVariable = varState[savedVariable.spec.name];
|
|
27
|
+
if ((currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== null && (currentVariable === null || currentVariable === void 0 ? void 0 : currentVariable.value) !== savedVariable.spec.default_value) {
|
|
28
|
+
modifiedVariableNames.push(savedVariable.spec.name);
|
|
29
|
+
isSavedVariableModified = true;
|
|
30
|
+
}
|
|
31
|
+
} else if (savedVariable.kind === 'TextVariable') {
|
|
32
|
+
const currentVariable1 = varState[savedVariable.spec.name];
|
|
33
|
+
const currentVariableValue = typeof (currentVariable1 === null || currentVariable1 === void 0 ? void 0 : currentVariable1.value) === 'string' ? currentVariable1.value : '';
|
|
34
|
+
if (savedVariable.spec.value !== currentVariableValue) {
|
|
35
|
+
modifiedVariableNames.push(savedVariable.spec.name);
|
|
36
|
+
isSavedVariableModified = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
isSavedVariableModified,
|
|
42
|
+
modifiedVariableNames
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -22,14 +22,14 @@ const _core = require("@perses-dev/core");
|
|
|
22
22
|
const _dashboardProvider = require("./DashboardProvider");
|
|
23
23
|
const _templateVariableProvider = require("./TemplateVariableProvider");
|
|
24
24
|
function useDashboard() {
|
|
25
|
-
const { panels , panelGroups , panelGroupOrder ,
|
|
25
|
+
const { panels , panelGroups , panelGroupOrder , setDashboard: setDashboardResource , metadata , display , duration , } = (0, _dashboardProvider.useDashboardStore)(({ panels , panelGroups , panelGroupOrder , setDashboard , metadata , display , duration })=>({
|
|
26
26
|
panels,
|
|
27
27
|
panelGroups,
|
|
28
28
|
panelGroupOrder,
|
|
29
|
-
defaultTimeRange,
|
|
30
29
|
setDashboard,
|
|
31
30
|
metadata,
|
|
32
|
-
display
|
|
31
|
+
display,
|
|
32
|
+
duration
|
|
33
33
|
}));
|
|
34
34
|
const { setVariableDefinitions } = (0, _templateVariableProvider.useTemplateVariableActions)();
|
|
35
35
|
const variables = (0, _templateVariableProvider.useTemplateVariableDefinitions)();
|
|
@@ -42,7 +42,7 @@ function useDashboard() {
|
|
|
42
42
|
panels,
|
|
43
43
|
layouts,
|
|
44
44
|
variables,
|
|
45
|
-
duration
|
|
45
|
+
duration
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
const setDashboard = (dashboardResource)=>{
|
|
@@ -20,62 +20,17 @@ Object.defineProperty(exports, "WithDatasourceStore", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _dashboards = require("@perses-dev/dashboards");
|
|
23
|
-
const
|
|
23
|
+
const _test = require("../../test");
|
|
24
24
|
// Type guard because storybook types parameters as `any`
|
|
25
25
|
function isWithDatasourceStoreParameter(parameter) {
|
|
26
26
|
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
27
27
|
}
|
|
28
|
-
const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
|
|
29
|
-
const prometheusDemo = {
|
|
30
|
-
kind: 'GlobalDatasource',
|
|
31
|
-
metadata: {
|
|
32
|
-
name: 'PrometheusDemo',
|
|
33
|
-
created_at: '0001-01-01T00:00:00Z',
|
|
34
|
-
updated_at: '0001-01-01T00:00:00Z',
|
|
35
|
-
version: 0
|
|
36
|
-
},
|
|
37
|
-
spec: {
|
|
38
|
-
default: true,
|
|
39
|
-
plugin: {
|
|
40
|
-
kind: 'PrometheusDatasource',
|
|
41
|
-
spec: {
|
|
42
|
-
direct_url: prometheusDemoUrl
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
28
|
const WithDatasourceStore = (Story, context)=>{
|
|
48
29
|
const initParameter = context.parameters.withDatasourceStore;
|
|
49
30
|
const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;
|
|
50
31
|
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
51
|
-
// This default currently defines the bare minimum to get a story working in
|
|
52
|
-
// the `Dashboard` storybook with the Prometheus demo api. We'll likely want
|
|
53
|
-
// to expand it to do more in the future.
|
|
54
|
-
const defaultDatasourceProps = {
|
|
55
|
-
dashboardResource: _constants.EMPTY_DASHBOARD_RESOURCE,
|
|
56
|
-
datasourceApi: {
|
|
57
|
-
getDatasource: ()=>{
|
|
58
|
-
return Promise.resolve(undefined);
|
|
59
|
-
},
|
|
60
|
-
getGlobalDatasource: (selector)=>{
|
|
61
|
-
if (selector.kind === 'PrometheusDatasource') {
|
|
62
|
-
return Promise.resolve({
|
|
63
|
-
resource: prometheusDemo,
|
|
64
|
-
proxyUrl: prometheusDemoUrl
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return Promise.resolve(undefined);
|
|
68
|
-
},
|
|
69
|
-
listDatasources: ()=>{
|
|
70
|
-
return Promise.resolve([]);
|
|
71
|
-
},
|
|
72
|
-
listGlobalDatasources: ()=>{
|
|
73
|
-
return Promise.resolve([]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
32
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_dashboards.DatasourceStoreProvider, {
|
|
78
|
-
...defaultDatasourceProps,
|
|
33
|
+
..._test.defaultDatasourceProps,
|
|
79
34
|
...props,
|
|
80
35
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
81
36
|
});
|
|
@@ -17,11 +17,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
17
17
|
_exportStar(require("./constants"), exports);
|
|
18
18
|
_exportStar(require("./WithDashboard"), exports);
|
|
19
19
|
_exportStar(require("./WithDatasourceStore"), exports);
|
|
20
|
-
_exportStar(require("./WithPluginRegistry"), exports);
|
|
21
|
-
_exportStar(require("./WithQueryClient"), exports);
|
|
22
|
-
_exportStar(require("./WithQueryParams"), exports);
|
|
23
20
|
_exportStar(require("./WithTemplateVariables"), exports);
|
|
24
|
-
_exportStar(require("./WithTimeRange"), exports);
|
|
25
21
|
function _exportStar(from, to) {
|
|
26
22
|
Object.keys(from).forEach(function(k) {
|
|
27
23
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|