@perses-dev/dashboards 0.50.0 → 0.51.0-beta.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/Dashboard.js +1 -3
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +3 -3
- package/dist/cjs/components/Datasources/DatasourceEditor.js +2 -5
- package/dist/cjs/components/Datasources/EditDatasourcesButton.js +2 -5
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +4 -3
- package/dist/cjs/components/DownloadButton/DownloadButton.js +135 -29
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +5 -7
- package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +1 -1
- package/dist/cjs/components/GridLayout/GridItemContent.js +4 -3
- package/dist/cjs/components/GridLayout/GridLayout.js +5 -6
- package/dist/cjs/components/GridLayout/GridTitle.js +3 -3
- package/dist/cjs/components/Panel/HeaderIconButton.js +27 -0
- package/dist/cjs/components/Panel/Panel.js +16 -10
- package/dist/cjs/components/Panel/PanelActions.js +365 -0
- package/dist/cjs/components/Panel/PanelContent.js +59 -13
- package/dist/cjs/components/Panel/PanelHeader.js +14 -141
- package/dist/cjs/components/Panel/PanelLinks.js +5 -6
- package/dist/cjs/components/Panel/PanelPluginLoader.js +56 -0
- package/dist/cjs/components/Panel/index.js +1 -0
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +9 -6
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +17 -35
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +4 -5
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
- package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -4
- package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +5 -12
- package/dist/cjs/components/Variables/Variable.js +36 -41
- package/dist/cjs/components/Variables/VariableEditor.js +14 -23
- package/dist/cjs/components/Variables/VariableList.js +4 -6
- package/dist/cjs/constants/styles.js +12 -0
- package/dist/cjs/constants/user-interface-text.js +1 -1
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +5 -6
- package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +1 -1
- package/dist/cjs/context/DashboardProvider/common.js +2 -2
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +13 -3
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -2
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +3 -6
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +1 -2
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +3 -4
- package/dist/cjs/context/DashboardProvider/view-panel-slice.js +1 -2
- package/dist/cjs/context/DatasourceStoreProvider.js +15 -22
- package/dist/cjs/context/VariableProvider/VariableProvider.js +8 -11
- package/dist/cjs/context/VariableProvider/hydrationUtils.js +3 -6
- package/dist/cjs/context/VariableProvider/utils.js +2 -2
- package/dist/cjs/stories/decorators/WithDashboard.js +1 -1
- package/dist/cjs/stories/decorators/WithDatasourceStore.js +1 -1
- package/dist/cjs/stories/decorators/WithVariables.js +1 -1
- package/dist/cjs/test/plugin-registry.js +8 -3
- package/dist/cjs/test/render.js +13 -11
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +4 -3
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -5
- package/dist/components/Dashboard/Dashboard.js +1 -3
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +3 -3
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.js +2 -5
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
- package/dist/components/Datasources/EditDatasourcesButton.js +2 -5
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js +3 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -4
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.d.ts +1 -5
- package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js +94 -29
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +5 -7
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +5 -4
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +6 -7
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +3 -3
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/HeaderIconButton.d.ts +5 -0
- package/dist/components/Panel/HeaderIconButton.d.ts.map +1 -0
- package/dist/components/Panel/HeaderIconButton.js +19 -0
- package/dist/components/Panel/HeaderIconButton.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +7 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +22 -11
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelActions.d.ts +22 -0
- package/dist/components/Panel/PanelActions.d.ts.map +1 -0
- package/dist/components/Panel/PanelActions.js +352 -0
- package/dist/components/Panel/PanelActions.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +5 -4
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +61 -15
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +7 -11
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +18 -140
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/Panel/PanelLinks.js +5 -6
- package/dist/components/Panel/PanelLinks.js.map +1 -1
- package/dist/components/Panel/PanelPluginLoader.d.ts +13 -0
- package/dist/components/Panel/PanelPluginLoader.d.ts.map +1 -0
- package/dist/components/Panel/PanelPluginLoader.js +51 -0
- package/dist/components/Panel/PanelPluginLoader.js.map +1 -0
- package/dist/components/Panel/index.d.ts +1 -0
- package/dist/components/Panel/index.d.ts.map +1 -1
- package/dist/components/Panel/index.js +1 -0
- package/dist/components/Panel/index.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +10 -7
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +17 -35
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +4 -5
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +3 -5
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +2 -4
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.js +5 -12
- package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
- package/dist/components/Variables/Variable.d.ts +2 -2
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +36 -41
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.js +14 -23
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.js +4 -6
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/constants/styles.d.ts +3 -0
- package/dist/constants/styles.d.ts.map +1 -1
- package/dist/constants/styles.js +3 -0
- package/dist/constants/styles.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +1 -1
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +1 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +5 -6
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +1 -1
- package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -1
- package/dist/context/DashboardProvider/common.js +2 -2
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +11 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +13 -4
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js +1 -2
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +3 -6
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +1 -2
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +3 -4
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js +1 -2
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +15 -22
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.js +8 -11
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js +3 -6
- package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/VariableProvider/utils.js +2 -2
- package/dist/context/VariableProvider/utils.js.map +1 -1
- package/dist/stories/decorators/WithDashboard.js +1 -1
- package/dist/stories/decorators/WithDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDatasourceStore.js +1 -1
- package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
- package/dist/stories/decorators/WithVariables.js +1 -1
- package/dist/stories/decorators/WithVariables.js.map +1 -1
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +8 -3
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +9 -7
- package/dist/test/render.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +4 -3
- 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 -5
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +8 -7
|
@@ -51,8 +51,7 @@ function _interop_require_default(obj) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
function getVariableLabelByKind(kind) {
|
|
54
|
-
|
|
55
|
-
return (_VARIABLE_TYPES_find = _pluginsystem.VARIABLE_TYPES.find((variableType)=>variableType.kind === kind)) === null || _VARIABLE_TYPES_find === void 0 ? void 0 : _VARIABLE_TYPES_find.label;
|
|
54
|
+
return _pluginsystem.VARIABLE_TYPES.find((variableType)=>variableType.kind === kind)?.label;
|
|
56
55
|
}
|
|
57
56
|
function getValidation(variableDefinitions) {
|
|
58
57
|
const errors = [];
|
|
@@ -268,16 +267,13 @@ function VariableEditor(props) {
|
|
|
268
267
|
})
|
|
269
268
|
}),
|
|
270
269
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableBody, {
|
|
271
|
-
children: variableDefinitions.map((v, idx)
|
|
272
|
-
var _v_spec_display, _v_spec_display1;
|
|
273
|
-
var _getVariableLabelByKind, _v_spec_display_description;
|
|
274
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableRow, {
|
|
270
|
+
children: variableDefinitions.map((v, idx)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableRow, {
|
|
275
271
|
children: [
|
|
276
272
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
277
273
|
component: "th",
|
|
278
274
|
scope: "row",
|
|
279
275
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
280
|
-
checked:
|
|
276
|
+
checked: v.spec.display?.hidden !== true,
|
|
281
277
|
onChange: (e)=>{
|
|
282
278
|
toggleVariableVisibility(idx, e.target.checked);
|
|
283
279
|
}
|
|
@@ -297,10 +293,10 @@ function VariableEditor(props) {
|
|
|
297
293
|
})
|
|
298
294
|
}),
|
|
299
295
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
300
|
-
children:
|
|
296
|
+
children: getVariableLabelByKind(v.kind) ?? v.kind
|
|
301
297
|
}),
|
|
302
298
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
303
|
-
children:
|
|
299
|
+
children: v.spec.display?.description ?? ''
|
|
304
300
|
}),
|
|
305
301
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(TableCell, {
|
|
306
302
|
align: "right",
|
|
@@ -329,8 +325,7 @@ function VariableEditor(props) {
|
|
|
329
325
|
]
|
|
330
326
|
})
|
|
331
327
|
]
|
|
332
|
-
}, v.spec.name)
|
|
333
|
-
})
|
|
328
|
+
}, v.spec.name))
|
|
334
329
|
})
|
|
335
330
|
]
|
|
336
331
|
})
|
|
@@ -430,16 +425,13 @@ function VariableEditor(props) {
|
|
|
430
425
|
})
|
|
431
426
|
}),
|
|
432
427
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableBody, {
|
|
433
|
-
children: extVar.definitions.map((v)
|
|
434
|
-
var _v_spec_display, _v_spec_display1;
|
|
435
|
-
var _getVariableLabelByKind, _v_spec_display_description;
|
|
436
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableRow, {
|
|
428
|
+
children: extVar.definitions.map((v)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableRow, {
|
|
437
429
|
children: [
|
|
438
430
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
439
431
|
component: "th",
|
|
440
432
|
scope: "row",
|
|
441
433
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
442
|
-
checked:
|
|
434
|
+
checked: v.spec.display?.hidden !== true,
|
|
443
435
|
disabled: true
|
|
444
436
|
})
|
|
445
437
|
}),
|
|
@@ -458,10 +450,10 @@ function VariableEditor(props) {
|
|
|
458
450
|
})
|
|
459
451
|
}),
|
|
460
452
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
461
|
-
children:
|
|
453
|
+
children: getVariableLabelByKind(v.kind) ?? v.kind
|
|
462
454
|
}),
|
|
463
455
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(TableCell, {
|
|
464
|
-
children:
|
|
456
|
+
children: v.spec.display?.description ?? ''
|
|
465
457
|
}),
|
|
466
458
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(TableCell, {
|
|
467
459
|
align: "right",
|
|
@@ -495,8 +487,7 @@ function VariableEditor(props) {
|
|
|
495
487
|
]
|
|
496
488
|
})
|
|
497
489
|
]
|
|
498
|
-
}, v.spec.name)
|
|
499
|
-
})
|
|
490
|
+
}, v.spec.name))
|
|
500
491
|
})
|
|
501
492
|
]
|
|
502
493
|
})
|
|
@@ -522,13 +513,13 @@ function VariableName(props) {
|
|
|
522
513
|
const { name, state } = props;
|
|
523
514
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
524
515
|
children: [
|
|
525
|
-
!
|
|
526
|
-
!
|
|
516
|
+
!state?.overridden && `${name} `,
|
|
517
|
+
!state?.overridden && state?.overriding && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
527
518
|
fontWeight: "normal",
|
|
528
519
|
color: (theme)=>theme.palette.primary.main,
|
|
529
520
|
children: "(overriding)"
|
|
530
521
|
}),
|
|
531
|
-
|
|
522
|
+
state?.overridden && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
532
523
|
children: [
|
|
533
524
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
534
525
|
color: (theme)=>theme.palette.grey[500],
|
|
@@ -50,14 +50,12 @@ function VariableList() {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
function VariableListItem({ spec, source }) {
|
|
53
|
-
var _ctx_state, _spec_display;
|
|
54
53
|
const ctx = (0, _context.useVariableDefinitionAndState)(spec.name, source);
|
|
55
|
-
if (
|
|
54
|
+
if (ctx.state?.overridden) {
|
|
56
55
|
return null;
|
|
57
56
|
}
|
|
58
|
-
var _ref, _ref1;
|
|
59
57
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
60
|
-
display:
|
|
58
|
+
display: spec.display?.hidden ? 'none' : undefined,
|
|
61
59
|
minWidth: `${_constants.MIN_VARIABLE_WIDTH}px`,
|
|
62
60
|
maxWidth: `${_constants.MAX_VARIABLE_WIDTH}px`,
|
|
63
61
|
flexShrink: 0,
|
|
@@ -65,6 +63,6 @@ function VariableListItem({ spec, source }) {
|
|
|
65
63
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Variable.Variable, {
|
|
66
64
|
name: spec.name,
|
|
67
65
|
source: source
|
|
68
|
-
}, (
|
|
69
|
-
}, (
|
|
66
|
+
}, (spec.name + source) ?? '')
|
|
67
|
+
}, (spec.name + source) ?? '');
|
|
70
68
|
}
|
|
@@ -21,6 +21,15 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
HEADER_ACTIONS_CONTAINER_NAME: function() {
|
|
25
|
+
return HEADER_ACTIONS_CONTAINER_NAME;
|
|
26
|
+
},
|
|
27
|
+
HEADER_MEDIUM_WIDTH: function() {
|
|
28
|
+
return HEADER_MEDIUM_WIDTH;
|
|
29
|
+
},
|
|
30
|
+
HEADER_SMALL_WIDTH: function() {
|
|
31
|
+
return HEADER_SMALL_WIDTH;
|
|
32
|
+
},
|
|
24
33
|
MAX_VARIABLE_WIDTH: function() {
|
|
25
34
|
return MAX_VARIABLE_WIDTH;
|
|
26
35
|
},
|
|
@@ -40,3 +49,6 @@ const editButtonStyle = {
|
|
|
40
49
|
};
|
|
41
50
|
const MIN_VARIABLE_WIDTH = 120;
|
|
42
51
|
const MAX_VARIABLE_WIDTH = 500;
|
|
52
|
+
const HEADER_SMALL_WIDTH = 170;
|
|
53
|
+
const HEADER_MEDIUM_WIDTH = 220;
|
|
54
|
+
const HEADER_ACTIONS_CONTAINER_NAME = 'header-actions-container';
|
|
@@ -32,7 +32,6 @@ const TOOLTIP_TEXT = {
|
|
|
32
32
|
// Toolbar buttons
|
|
33
33
|
addPanel: 'Add panel',
|
|
34
34
|
addGroup: 'Add panel group',
|
|
35
|
-
downloadDashboard: 'Download JSON',
|
|
36
35
|
editDatasources: 'Edit datasources',
|
|
37
36
|
editJson: 'Edit JSON',
|
|
38
37
|
editVariables: 'Edit variables',
|
|
@@ -65,5 +64,6 @@ const ARIA_LABEL_TEXT = {
|
|
|
65
64
|
editPanel: (panelName)=>`edit panel ${panelName}`,
|
|
66
65
|
duplicatePanel: (panelName)=>`duplicate panel ${panelName}`,
|
|
67
66
|
deletePanel: (panelName)=>`delete panel ${panelName}`,
|
|
67
|
+
showPanelActions: (panelName)=>`show panel actions for ${panelName}`,
|
|
68
68
|
movePanel: (panelName)=>`move panel ${panelName}`
|
|
69
69
|
};
|
|
@@ -66,13 +66,12 @@ function DashboardProvider(props) {
|
|
|
66
66
|
]);
|
|
67
67
|
// load plugin to retrieve initial spec if default panel kind is defined
|
|
68
68
|
const { defaultPluginKinds } = (0, _pluginsystem.usePluginRegistry)();
|
|
69
|
-
|
|
70
|
-
const defaultPanelKind = (_defaultPluginKinds_Panel = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds['Panel']) !== null && _defaultPluginKinds_Panel !== void 0 ? _defaultPluginKinds_Panel : '';
|
|
69
|
+
const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';
|
|
71
70
|
const { data: plugin } = (0, _pluginsystem.usePlugin)('Panel', defaultPanelKind);
|
|
72
71
|
const [store] = (0, _react.useState)(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders
|
|
73
72
|
(0, _react.useEffect)(()=>{
|
|
74
73
|
if (plugin === undefined) return;
|
|
75
|
-
const defaultPanelSpec = plugin.createInitialOptions();
|
|
74
|
+
const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};
|
|
76
75
|
// set default panel kind, spec, and queries for add panel editor
|
|
77
76
|
store.setState({
|
|
78
77
|
initialValues: {
|
|
@@ -95,8 +94,8 @@ function initStore(props) {
|
|
|
95
94
|
const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;
|
|
96
95
|
let { spec: { layouts, panels } } = dashboardResource;
|
|
97
96
|
// Set fallbacks in case the frontend is used with a non-Perses backend
|
|
98
|
-
layouts = layouts
|
|
99
|
-
panels = panels
|
|
97
|
+
layouts = layouts ?? [];
|
|
98
|
+
panels = panels ?? {};
|
|
100
99
|
const store = (0, _zustand.createStore)()((0, _immer.immer)((0, _middleware.devtools)((...args)=>{
|
|
101
100
|
const [set] = args;
|
|
102
101
|
return {
|
|
@@ -132,7 +131,7 @@ function initStore(props) {
|
|
|
132
131
|
state.panelGroups = panelGroups;
|
|
133
132
|
state.panelGroupOrder = panelGroupOrder;
|
|
134
133
|
state.duration = duration;
|
|
135
|
-
state.refreshInterval = refreshInterval
|
|
134
|
+
state.refreshInterval = refreshInterval ?? _core.DEFAULT_REFRESH_INTERVAL;
|
|
136
135
|
state.datasources = datasources;
|
|
137
136
|
// TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring
|
|
138
137
|
});
|
|
@@ -27,7 +27,7 @@ function DashboardProviderWithQueryParams({ children, initialState }) {
|
|
|
27
27
|
const [viewPanelRef, setViewPanelRef] = (0, _usequeryparams.useQueryParam)('viewPanelRef', _usequeryparams.StringParam);
|
|
28
28
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardProvider.DashboardProvider, {
|
|
29
29
|
initialState: {
|
|
30
|
-
viewPanelRef: viewPanelRef
|
|
30
|
+
viewPanelRef: viewPanelRef ?? undefined,
|
|
31
31
|
setViewPanelRef: setViewPanelRef,
|
|
32
32
|
...initialState
|
|
33
33
|
},
|
|
@@ -43,8 +43,8 @@ function createPanelDefinition(defaultPanelKind, defaultPanelSpec) {
|
|
|
43
43
|
description: undefined
|
|
44
44
|
},
|
|
45
45
|
plugin: {
|
|
46
|
-
kind: defaultPanelKind
|
|
47
|
-
spec: defaultPanelSpec
|
|
46
|
+
kind: defaultPanelKind ?? '',
|
|
47
|
+
spec: defaultPanelSpec ?? {}
|
|
48
48
|
},
|
|
49
49
|
queries: []
|
|
50
50
|
}
|
|
@@ -71,6 +71,9 @@ _export(exports, {
|
|
|
71
71
|
},
|
|
72
72
|
useViewPanel: function() {
|
|
73
73
|
return useViewPanel;
|
|
74
|
+
},
|
|
75
|
+
useViewPanelGroup: function() {
|
|
76
|
+
return useViewPanelGroup;
|
|
74
77
|
}
|
|
75
78
|
});
|
|
76
79
|
const _react = require("react");
|
|
@@ -186,8 +189,7 @@ function useDeletePanelGroupDialog() {
|
|
|
186
189
|
function usePanel(panelGroupItemId) {
|
|
187
190
|
const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
188
191
|
const panel = (0, _DashboardProvider.useDashboardStore)((0, _react.useCallback)((store)=>{
|
|
189
|
-
|
|
190
|
-
const panelKey = (_store_panelGroups_panelGroupId = store.panelGroups[panelGroupId]) === null || _store_panelGroups_panelGroupId === void 0 ? void 0 : _store_panelGroups_panelGroupId.itemPanelKeys[panelGroupLayoutId];
|
|
192
|
+
const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];
|
|
191
193
|
if (panelKey === undefined) return;
|
|
192
194
|
return store.panels[panelKey];
|
|
193
195
|
}, [
|
|
@@ -231,10 +233,18 @@ const selectDashboardDuration = (state)=>state.duration;
|
|
|
231
233
|
function useDashboardDuration() {
|
|
232
234
|
return (0, _DashboardProvider.useDashboardStore)(selectDashboardDuration);
|
|
233
235
|
}
|
|
234
|
-
const selectViewPanel = (state)=>
|
|
236
|
+
const selectViewPanel = (state)=>({
|
|
237
|
+
setViewPanel: state.setViewPanel,
|
|
238
|
+
getViewPanel: state.getViewPanel,
|
|
239
|
+
viewPanelId: state.getViewPanel()
|
|
240
|
+
});
|
|
235
241
|
function useViewPanel() {
|
|
236
242
|
return (0, _DashboardProvider.useDashboardStore)(selectViewPanel);
|
|
237
243
|
}
|
|
244
|
+
const selectViewPanelGroup = (state)=>state.getViewPanel();
|
|
245
|
+
function useViewPanelGroup() {
|
|
246
|
+
return (0, _DashboardProvider.useDashboardStore)(selectViewPanelGroup);
|
|
247
|
+
}
|
|
238
248
|
const selectSaveChangesConfirmationDialog = ({ saveChangesConfirmationDialog, openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog })=>({
|
|
239
249
|
saveChangesConfirmationDialog,
|
|
240
250
|
openSaveChangesConfirmationDialog,
|
|
@@ -60,11 +60,10 @@ function createDeletePanelSlice() {
|
|
|
60
60
|
throw new Error(`Could not find panel ${panelKey}`);
|
|
61
61
|
}
|
|
62
62
|
set((state)=>{
|
|
63
|
-
var _panelGroup_title;
|
|
64
63
|
state.deletePanelDialog = {
|
|
65
64
|
panelGroupItemId: panelGroupItemId,
|
|
66
65
|
panelName: panel.spec.display.name,
|
|
67
|
-
panelGroupName:
|
|
66
|
+
panelGroupName: panelGroup.title ?? ''
|
|
68
67
|
};
|
|
69
68
|
});
|
|
70
69
|
},
|
|
@@ -28,11 +28,10 @@ function createPanelEditorSlice() {
|
|
|
28
28
|
return (set, get)=>({
|
|
29
29
|
panelEditor: undefined,
|
|
30
30
|
openEditPanel (panelGroupItemId) {
|
|
31
|
-
var _panelGroups_panelGroupId;
|
|
32
31
|
const { panels, panelGroups } = get();
|
|
33
32
|
// Figure out the panel key at that location
|
|
34
33
|
const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
|
|
35
|
-
const panelKey =
|
|
34
|
+
const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];
|
|
36
35
|
if (panelKey === undefined) {
|
|
37
36
|
throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);
|
|
38
37
|
}
|
|
@@ -95,21 +94,19 @@ function createPanelEditorSlice() {
|
|
|
95
94
|
});
|
|
96
95
|
},
|
|
97
96
|
openAddPanel (panelGroupId) {
|
|
98
|
-
var _get_initialValues;
|
|
99
97
|
// If a panel group isn't supplied, add to the first group or create a group if there aren't any
|
|
100
98
|
let newGroup = undefined;
|
|
101
|
-
panelGroupId
|
|
99
|
+
panelGroupId ??= get().panelGroupOrder[0];
|
|
102
100
|
if (panelGroupId === undefined) {
|
|
103
101
|
newGroup = (0, _panelgroupslice.createEmptyPanelGroup)();
|
|
104
102
|
newGroup.title = 'Panel Group';
|
|
105
103
|
panelGroupId = newGroup.id;
|
|
106
104
|
}
|
|
107
|
-
var _get_initialValues_panelDefinition;
|
|
108
105
|
const editorState = {
|
|
109
106
|
mode: 'create',
|
|
110
107
|
initialValues: {
|
|
111
108
|
groupId: panelGroupId,
|
|
112
|
-
panelDefinition:
|
|
109
|
+
panelDefinition: get().initialValues?.panelDefinition ?? (0, _common.createPanelDefinition)()
|
|
113
110
|
},
|
|
114
111
|
applyChanges: (next)=>{
|
|
115
112
|
const name = next.panelDefinition.spec.display.name;
|
|
@@ -55,12 +55,11 @@ const createPanelGroupEditorSlice = (set, get)=>({
|
|
|
55
55
|
if (existingGroup === undefined) {
|
|
56
56
|
throw new Error(`Panel group with Id ${panelGroupId} does not exist`);
|
|
57
57
|
}
|
|
58
|
-
var _existingGroup_title;
|
|
59
58
|
// Create the editor state
|
|
60
59
|
const editor = {
|
|
61
60
|
mode: 'Edit',
|
|
62
61
|
initialValues: {
|
|
63
|
-
title:
|
|
62
|
+
title: existingGroup.title ?? '',
|
|
64
63
|
isCollapsed: existingGroup.isCollapsed
|
|
65
64
|
},
|
|
66
65
|
applyChanges (next) {
|
|
@@ -40,7 +40,7 @@ _export(exports, {
|
|
|
40
40
|
const _core = require("@perses-dev/core");
|
|
41
41
|
const _common = require("./common");
|
|
42
42
|
function isPanelGroupItemIdEqual(a, b) {
|
|
43
|
-
return
|
|
43
|
+
return a?.panelGroupId === b?.panelGroupId && a?.panelGroupItemLayoutId === b?.panelGroupItemLayoutId;
|
|
44
44
|
}
|
|
45
45
|
function createPanelGroupSlice(layouts) {
|
|
46
46
|
const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
|
|
@@ -81,7 +81,6 @@ function convertLayoutsToPanelGroups(layouts) {
|
|
|
81
81
|
const panelGroups = {};
|
|
82
82
|
const panelGroupIdOrder = [];
|
|
83
83
|
for (const layout of layouts){
|
|
84
|
-
var _layout_spec_display_collapse, _layout_spec_display, _layout_spec_display1;
|
|
85
84
|
const itemLayouts = [];
|
|
86
85
|
const itemPanelKeys = {};
|
|
87
86
|
// Split layout information from panel keys to make it easier to update just layouts on move/resize of panels
|
|
@@ -100,8 +99,8 @@ function convertLayoutsToPanelGroups(layouts) {
|
|
|
100
99
|
const panelGroupId = (0, _common.generateId)();
|
|
101
100
|
panelGroups[panelGroupId] = {
|
|
102
101
|
id: panelGroupId,
|
|
103
|
-
isCollapsed:
|
|
104
|
-
title:
|
|
102
|
+
isCollapsed: layout.spec.display?.collapse?.open === false,
|
|
103
|
+
title: layout.spec.display?.title,
|
|
105
104
|
itemLayouts,
|
|
106
105
|
itemPanelKeys
|
|
107
106
|
};
|
|
@@ -55,8 +55,7 @@ function getViewPanelGroupId(panelGroups, panelGroupItemId, panelRef) {
|
|
|
55
55
|
// Find the PanelGroupItemId of a Panel from a PanelRef
|
|
56
56
|
function findPanelGroupItemIdOfPanelRef(panelGroups, panelRef) {
|
|
57
57
|
for (const panelGroup of Object.values(panelGroups)){
|
|
58
|
-
|
|
59
|
-
const itemPanel = Object.entries((_panelGroup_itemPanelKeys = panelGroup.itemPanelKeys) !== null && _panelGroup_itemPanelKeys !== void 0 ? _panelGroup_itemPanelKeys : []).find(([_, value])=>value === panelRef);
|
|
58
|
+
const itemPanel = Object.entries(panelGroup.itemPanelKeys ?? []).find(([_, value])=>value === panelRef);
|
|
60
59
|
if (itemPanel) {
|
|
61
60
|
const [key] = itemPanel;
|
|
62
61
|
return {
|
|
@@ -27,9 +27,8 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
27
27
|
function DatasourceStoreProvider(props) {
|
|
28
28
|
const { projectName, datasourceApi, onCreate, children } = props;
|
|
29
29
|
const [dashboardResource, setDashboardResource] = (0, _react.useState)(props.dashboardResource);
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const project = projectName !== null && projectName !== void 0 ? projectName : dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.metadata.project;
|
|
30
|
+
const [savedDatasources, setSavedDatasources] = (0, _react.useState)(props.savedDatasources ?? {});
|
|
31
|
+
const project = projectName ?? dashboardResource?.metadata.project;
|
|
33
32
|
const { getPlugin, listPluginMetadata } = (0, _pluginsystem.usePluginRegistry)();
|
|
34
33
|
const findDatasource = (0, _core.useEvent)(async (selector)=>{
|
|
35
34
|
// Try to find it in dashboard spec
|
|
@@ -99,26 +98,26 @@ function DatasourceStoreProvider(props) {
|
|
|
99
98
|
getPlugin,
|
|
100
99
|
onCreate
|
|
101
100
|
]);
|
|
102
|
-
const listDatasourceSelectItems = (0, _core.useEvent)(async (
|
|
101
|
+
const listDatasourceSelectItems = (0, _core.useEvent)(async (datasourcePluginName)=>{
|
|
103
102
|
const [pluginMetadata, datasources, globalDatasources] = await Promise.all([
|
|
104
103
|
listPluginMetadata([
|
|
105
104
|
'Datasource'
|
|
106
105
|
]),
|
|
107
|
-
project ? datasourceApi.listDatasources(project,
|
|
108
|
-
datasourceApi.listGlobalDatasources(
|
|
106
|
+
project ? datasourceApi.listDatasources(project, datasourcePluginName) : [],
|
|
107
|
+
datasourceApi.listGlobalDatasources(datasourcePluginName)
|
|
109
108
|
]);
|
|
110
109
|
// Find the metadata for the plugin type they asked for, so we can use it for the name of the default datasource
|
|
111
|
-
const datasourcePluginMetadata = pluginMetadata.find((metadata)=>metadata.
|
|
110
|
+
const datasourcePluginMetadata = pluginMetadata.find((metadata)=>metadata.spec.name === datasourcePluginName);
|
|
112
111
|
if (datasourcePluginMetadata === undefined) {
|
|
113
|
-
throw new Error(`Could not find a Datasource plugin with kind '${
|
|
112
|
+
throw new Error(`Could not find a Datasource plugin with kind '${datasourcePluginName}'`);
|
|
114
113
|
}
|
|
115
114
|
// Get helper for computing results properly
|
|
116
|
-
const { results, addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.display.name);
|
|
115
|
+
const { results, addItem } = buildDatasourceSelectItemGroups(datasourcePluginMetadata.spec.display.name);
|
|
117
116
|
// Start with dashboard datasources with the highest precedence
|
|
118
|
-
if (dashboardResource
|
|
117
|
+
if (dashboardResource?.spec.datasources) {
|
|
119
118
|
for(const selectorName in dashboardResource.spec.datasources){
|
|
120
119
|
const spec = dashboardResource.spec.datasources[selectorName];
|
|
121
|
-
if (spec === undefined || spec.plugin.kind !==
|
|
120
|
+
if (spec === undefined || spec.plugin.kind !== datasourcePluginName) continue;
|
|
122
121
|
const saved = selectorName in savedDatasources;
|
|
123
122
|
addItem({
|
|
124
123
|
spec,
|
|
@@ -151,8 +150,7 @@ function DatasourceStoreProvider(props) {
|
|
|
151
150
|
return results;
|
|
152
151
|
});
|
|
153
152
|
const getLocalDatasources = (0, _react.useCallback)(()=>{
|
|
154
|
-
|
|
155
|
-
return (_dashboardResource_spec_datasources = dashboardResource === null || dashboardResource === void 0 ? void 0 : dashboardResource.spec.datasources) !== null && _dashboardResource_spec_datasources !== void 0 ? _dashboardResource_spec_datasources : {};
|
|
153
|
+
return dashboardResource?.spec.datasources ?? {};
|
|
156
154
|
}, [
|
|
157
155
|
dashboardResource
|
|
158
156
|
]);
|
|
@@ -238,8 +236,7 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
238
236
|
const groupIndices = {};
|
|
239
237
|
let currentGroupIndex = 1; // 0 is the default group, always there as it contains at least the first item.
|
|
240
238
|
const addItem = ({ spec, selectorName, selectorGroup: group, editLink, saved })=>{
|
|
241
|
-
|
|
242
|
-
group = group !== null && group !== void 0 ? group : '';
|
|
239
|
+
group = group ?? '';
|
|
243
240
|
// Ensure the default group is always present as soon as an item is added.
|
|
244
241
|
if (isFirst) {
|
|
245
242
|
results.push({
|
|
@@ -247,9 +244,8 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
247
244
|
items: []
|
|
248
245
|
});
|
|
249
246
|
}
|
|
250
|
-
var _groupIndices_group;
|
|
251
247
|
// Create the group if necessary
|
|
252
|
-
let selectItemGroup = results[
|
|
248
|
+
let selectItemGroup = results[groupIndices[group] ?? -1];
|
|
253
249
|
if (!selectItemGroup) {
|
|
254
250
|
groupIndices[group] = currentGroupIndex;
|
|
255
251
|
selectItemGroup = {
|
|
@@ -262,9 +258,8 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
262
258
|
}
|
|
263
259
|
// Add item to the group
|
|
264
260
|
const isOverridden = usedNames.has(selectorName);
|
|
265
|
-
var _spec_display_name;
|
|
266
261
|
selectItemGroup.items.push({
|
|
267
|
-
name:
|
|
262
|
+
name: spec.display?.name ?? selectorName,
|
|
268
263
|
overridden: isOverridden,
|
|
269
264
|
saved,
|
|
270
265
|
selector: {
|
|
@@ -293,9 +288,7 @@ function findDashboardDatasource(dashboardDatasources, selector) {
|
|
|
293
288
|
// At the end, we make sure the overriding item(s) is well flagged so
|
|
294
289
|
if (isOverridden) {
|
|
295
290
|
for(let i = explicitDefaultAdded ? 1 : 0; i < currentGroupIndex; i++){
|
|
296
|
-
|
|
297
|
-
var _results_i_items;
|
|
298
|
-
((_results_i_items = (_results_i = results[i]) === null || _results_i === void 0 ? void 0 : _results_i.items) !== null && _results_i_items !== void 0 ? _results_i_items : []).filter((item)=>item.selector.name === selectorName).forEach((item)=>{
|
|
291
|
+
(results[i]?.items ?? []).filter((item)=>item.selector.name === selectorName).forEach((item)=>{
|
|
299
292
|
item.overriding = true;
|
|
300
293
|
});
|
|
301
294
|
}
|
|
@@ -78,7 +78,7 @@ function useVariableDefinitionStates(variableNames) {
|
|
|
78
78
|
return (0, _traditional.useStoreWithEqualityFn)(store, (s)=>{
|
|
79
79
|
const varStates = {};
|
|
80
80
|
// Collect values of local variables, from the variable state
|
|
81
|
-
const names = variableNames
|
|
81
|
+
const names = variableNames ?? s.variableDefinitions.map((value)=>value.spec.name);
|
|
82
82
|
names.forEach((name)=>{
|
|
83
83
|
const varState = s.variableState.get({
|
|
84
84
|
name
|
|
@@ -111,12 +111,11 @@ function useVariableDefinitionStates(variableNames) {
|
|
|
111
111
|
function useVariableDefinitionAndState(name, source) {
|
|
112
112
|
const store = useVariableDefinitionStoreCtx();
|
|
113
113
|
return (0, _zustand.useStore)(store, (s)=>{
|
|
114
|
-
var _s_externalVariableDefinitions_find;
|
|
115
114
|
const state = s.variableState.get({
|
|
116
115
|
name,
|
|
117
116
|
source
|
|
118
117
|
});
|
|
119
|
-
const definitions = source ?
|
|
118
|
+
const definitions = source ? s.externalVariableDefinitions.find((v)=>v.source === source)?.definitions : s.variableDefinitions;
|
|
120
119
|
const definition = (definitions || []).find((v)=>v.spec.name === name);
|
|
121
120
|
return {
|
|
122
121
|
state,
|
|
@@ -162,12 +161,10 @@ function PluginProvider({ children, builtinVariables }) {
|
|
|
162
161
|
if (v.value === _core.DEFAULT_ALL_VALUE) {
|
|
163
162
|
const definition = (0, _utils.findVariableDefinitionByName)(name, definitions, externalDefinitions);
|
|
164
163
|
// If the variable is a list variable and has a custom all value, then use that value instead
|
|
165
|
-
if (
|
|
164
|
+
if (definition?.kind === 'ListVariable' && definition.spec.customAllValue) {
|
|
166
165
|
v.value = definition.spec.customAllValue;
|
|
167
166
|
} else {
|
|
168
|
-
|
|
169
|
-
var _v_options_map;
|
|
170
|
-
v.value = (_v_options_map = (_v_options = v.options) === null || _v_options === void 0 ? void 0 : _v_options.map((o)=>o.value)) !== null && _v_options_map !== void 0 ? _v_options_map : null;
|
|
167
|
+
v.value = v.options?.map((o)=>o.value) ?? null;
|
|
171
168
|
}
|
|
172
169
|
}
|
|
173
170
|
contextValues[name] = v;
|
|
@@ -246,7 +243,7 @@ function PluginProvider({ children, builtinVariables }) {
|
|
|
246
243
|
}
|
|
247
244
|
}
|
|
248
245
|
];
|
|
249
|
-
builtinVariables
|
|
246
|
+
builtinVariables?.forEach((def)=>result.push(def));
|
|
250
247
|
return result;
|
|
251
248
|
}, [
|
|
252
249
|
absoluteTimeRange,
|
|
@@ -336,7 +333,7 @@ function createVariableDefinitionStore({ initialVariableDefinitions = [], extern
|
|
|
336
333
|
const currentVariable = variableState.get({
|
|
337
334
|
name
|
|
338
335
|
});
|
|
339
|
-
if (
|
|
336
|
+
if (currentVariable?.value !== undefined) {
|
|
340
337
|
draft[index] = {
|
|
341
338
|
kind: 'ListVariable',
|
|
342
339
|
spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
|
|
@@ -348,8 +345,8 @@ function createVariableDefinitionStore({ initialVariableDefinitions = [], extern
|
|
|
348
345
|
const currentVariable = variableState.get({
|
|
349
346
|
name
|
|
350
347
|
});
|
|
351
|
-
const currentVariableValue = typeof
|
|
352
|
-
if (
|
|
348
|
+
const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';
|
|
349
|
+
if (currentVariable?.value !== undefined) {
|
|
353
350
|
draft[index] = {
|
|
354
351
|
kind: 'TextVariable',
|
|
355
352
|
spec: (0, _immer1.default)(variable.spec, (specDraft)=>{
|
|
@@ -32,17 +32,14 @@ function hydrateVariableState(variable, initialValue) {
|
|
|
32
32
|
};
|
|
33
33
|
switch(variable.kind){
|
|
34
34
|
case 'TextVariable':
|
|
35
|
-
varState.value = initialValue
|
|
35
|
+
varState.value = initialValue ?? variable.spec.value;
|
|
36
36
|
break;
|
|
37
37
|
case 'ListVariable':
|
|
38
38
|
varState.options = [];
|
|
39
|
-
|
|
40
|
-
varState.value = (_ref = initialValue !== null && initialValue !== void 0 ? initialValue : variable.spec.defaultValue) !== null && _ref !== void 0 ? _ref : null;
|
|
39
|
+
varState.value = initialValue ?? variable.spec.defaultValue ?? null;
|
|
41
40
|
// TODO: smarter fallbacks for defaultValue when allowAllValue is true
|
|
42
41
|
if (varState.options.length > 0 && !varState.value) {
|
|
43
|
-
|
|
44
|
-
var _varState_options__value;
|
|
45
|
-
const firstOptionValue = (_varState_options__value = (_varState_options_ = varState.options[0]) === null || _varState_options_ === void 0 ? void 0 : _varState_options_.value) !== null && _varState_options__value !== void 0 ? _varState_options__value : null;
|
|
42
|
+
const firstOptionValue = varState.options[0]?.value ?? null;
|
|
46
43
|
if (firstOptionValue !== null) {
|
|
47
44
|
varState.value = variable.spec.allowMultiple ? [
|
|
48
45
|
firstOptionValue
|
|
@@ -43,7 +43,7 @@ function checkSavedDefaultVariableStatus(definitions, varState) {
|
|
|
43
43
|
const currentVariable = varState.get({
|
|
44
44
|
name
|
|
45
45
|
});
|
|
46
|
-
if (
|
|
46
|
+
if (currentVariable?.value !== null && currentVariable?.value !== savedVariable.spec.defaultValue) {
|
|
47
47
|
modifiedVariableNames.push(name);
|
|
48
48
|
isSavedVariableModified = true;
|
|
49
49
|
}
|
|
@@ -51,7 +51,7 @@ function checkSavedDefaultVariableStatus(definitions, varState) {
|
|
|
51
51
|
const currentVariable = varState.get({
|
|
52
52
|
name
|
|
53
53
|
});
|
|
54
|
-
const currentVariableValue = typeof
|
|
54
|
+
const currentVariableValue = typeof currentVariable?.value === 'string' ? currentVariable.value : '';
|
|
55
55
|
if (savedVariable.spec.value !== currentVariableValue) {
|
|
56
56
|
modifiedVariableNames.push(name);
|
|
57
57
|
isSavedVariableModified = true;
|
|
@@ -30,7 +30,7 @@ function isWithDashboardParameter(parameter) {
|
|
|
30
30
|
const WithDashboard = (Story, context)=>{
|
|
31
31
|
const initParameter = context.parameters.withDashboard;
|
|
32
32
|
const parameter = isWithDashboardParameter(initParameter) ? initParameter : undefined;
|
|
33
|
-
const props = parameter
|
|
33
|
+
const props = parameter?.props;
|
|
34
34
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.DashboardProvider, {
|
|
35
35
|
initialState: {
|
|
36
36
|
dashboardResource: _constants.EMPTY_DASHBOARD_RESOURCE
|
|
@@ -30,7 +30,7 @@ function isWithDatasourceStoreParameter(parameter) {
|
|
|
30
30
|
const WithDatasourceStore = (Story, context)=>{
|
|
31
31
|
const initParameter = context.parameters.withDatasourceStore;
|
|
32
32
|
const parameter = isWithDatasourceStoreParameter(initParameter) ? initParameter : undefined;
|
|
33
|
-
const props = parameter
|
|
33
|
+
const props = parameter?.props;
|
|
34
34
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.DatasourceStoreProvider, {
|
|
35
35
|
..._test.defaultDatasourceProps,
|
|
36
36
|
...props,
|
|
@@ -29,7 +29,7 @@ function isWithVariableParameter(parameter) {
|
|
|
29
29
|
const WithVariables = (Story, context)=>{
|
|
30
30
|
const initParameter = context.parameters.withVariables;
|
|
31
31
|
const parameter = isWithVariableParameter(initParameter) ? initParameter : undefined;
|
|
32
|
-
const props = parameter
|
|
32
|
+
const props = parameter?.props;
|
|
33
33
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_dashboards.VariableProvider, {
|
|
34
34
|
...props,
|
|
35
35
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|