@perses-dev/dashboards 0.37.2 → 0.39.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 +3 -2
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +12 -52
- package/dist/cjs/components/GridLayout/GridItemContent.js +3 -1
- package/dist/cjs/components/GridLayout/GridLayout.js +1 -0
- package/dist/cjs/components/Panel/Panel.js +8 -3
- package/dist/cjs/components/Panel/PanelHeader.js +7 -3
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +3 -1
- package/dist/cjs/components/Variables/EditVariablesButton.js +2 -0
- package/dist/cjs/components/Variables/TemplateVariable.js +22 -18
- package/dist/cjs/components/Variables/VariableEditor.js +271 -99
- package/dist/cjs/components/Variables/VariableList.js +38 -18
- package/dist/cjs/components/Variables/index.js +0 -2
- package/dist/cjs/context/DatasourceStoreProvider.js +22 -18
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +71 -24
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +55 -5
- package/dist/cjs/context/TemplateVariableProvider/utils.js +39 -7
- package/dist/cjs/test/render.js +1 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -2
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +4 -3
- package/dist/components/Dashboard/Dashboard.d.ts +3 -1
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard/Dashboard.js +3 -2
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +11 -46
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +3 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +1 -0
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +20 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +8 -3
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +2 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +7 -3
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +3 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +3 -1
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +2 -1
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +21 -17
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +7 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +261 -95
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +5 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +31 -17
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +0 -2
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +0 -2
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +4 -3
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +22 -18
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +39 -10
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +76 -27
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts +9 -2
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +60 -5
- package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.d.ts +27 -2
- package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.js +46 -4
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
- package/dist/test/render.js +2 -2
- package/dist/test/render.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +9 -4
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +4 -3
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -399
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +0 -178
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +0 -29
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -91
- package/dist/cjs/components/Variables/variable-model.js +0 -117
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +0 -10
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -354
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +0 -16
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +0 -122
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/index.d.ts +0 -3
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/index.js +0 -16
- package/dist/components/Variables/VariableEditorForm/index.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +0 -23
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -79
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +0 -1
- package/dist/components/Variables/variable-model.d.ts +0 -16
- package/dist/components/Variables/variable-model.d.ts.map +0 -1
- package/dist/components/Variables/variable-model.js +0 -105
- package/dist/components/Variables/variable-model.js.map +0 -1
|
@@ -24,7 +24,7 @@ const _components = require("@perses-dev/components");
|
|
|
24
24
|
const _context = require("../../context");
|
|
25
25
|
const _gridLayout = require("../GridLayout");
|
|
26
26
|
const _emptyDashboard = require("../EmptyDashboard");
|
|
27
|
-
function Dashboard({ emptyDashboardProps , ...boxProps }) {
|
|
27
|
+
function Dashboard({ emptyDashboardProps , panelOptions , ...boxProps }) {
|
|
28
28
|
const panelGroupIds = (0, _context.usePanelGroupIds)();
|
|
29
29
|
const isEmpty = !panelGroupIds.length;
|
|
30
30
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
@@ -46,7 +46,8 @@ function Dashboard({ emptyDashboardProps , ...boxProps }) {
|
|
|
46
46
|
})
|
|
47
47
|
}),
|
|
48
48
|
!isEmpty && panelGroupIds.map((panelGroupId)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridLayout.GridLayout, {
|
|
49
|
-
panelGroupId: panelGroupId
|
|
49
|
+
panelGroupId: panelGroupId,
|
|
50
|
+
panelOptions: panelOptions
|
|
50
51
|
}, panelGroupId))
|
|
51
52
|
]
|
|
52
53
|
})
|
package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js
CHANGED
|
@@ -14,62 +14,22 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "DashboardDiscardChangesConfirmationDialog", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()=>
|
|
19
|
+
get: ()=>DashboardDiscardChangesConfirmationDialog
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
const
|
|
23
|
-
const _close = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Close"));
|
|
22
|
+
const _components = require("@perses-dev/components");
|
|
24
23
|
const _context = require("../../context");
|
|
25
|
-
|
|
26
|
-
return obj && obj.__esModule ? obj : {
|
|
27
|
-
default: obj
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
const DiscardChangesConfirmationDialog = ()=>{
|
|
24
|
+
const DashboardDiscardChangesConfirmationDialog = ()=>{
|
|
31
25
|
const { discardChangesConfirmationDialog: dialog } = (0, _context.useDiscardChangesConfirmationDialog)();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
41
|
-
"aria-label": "Close",
|
|
42
|
-
onClick: dialog.onCancel,
|
|
43
|
-
sx: (theme)=>({
|
|
44
|
-
position: 'absolute',
|
|
45
|
-
top: theme.spacing(0.5),
|
|
46
|
-
right: theme.spacing(0.5)
|
|
47
|
-
}),
|
|
48
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_close.default, {})
|
|
49
|
-
}),
|
|
50
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.DialogContent, {
|
|
51
|
-
dividers: true,
|
|
52
|
-
sx: {
|
|
53
|
-
width: '500px'
|
|
54
|
-
},
|
|
55
|
-
children: dialog.description || 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.'
|
|
56
|
-
}),
|
|
57
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.DialogActions, {
|
|
58
|
-
children: [
|
|
59
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
60
|
-
variant: "contained",
|
|
61
|
-
onClick: dialog.onDiscardChanges,
|
|
62
|
-
children: "Discard Changes"
|
|
63
|
-
}),
|
|
64
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
65
|
-
variant: "outlined",
|
|
66
|
-
color: "secondary",
|
|
67
|
-
onClick: dialog.onCancel,
|
|
68
|
-
children: "Cancel"
|
|
69
|
-
})
|
|
70
|
-
]
|
|
71
|
-
})
|
|
72
|
-
]
|
|
73
|
-
})
|
|
26
|
+
if (dialog === undefined) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.DiscardChangesConfirmationDialog, {
|
|
30
|
+
description: dialog.description || 'You have unsaved changes in this dashboard. Are you sure you want to discard these changes? Changes cannot be recovered.',
|
|
31
|
+
isOpen: true,
|
|
32
|
+
onCancel: dialog.onCancel,
|
|
33
|
+
onDiscardChanges: dialog.onDiscardChanges
|
|
74
34
|
});
|
|
75
35
|
};
|
|
@@ -54,7 +54,9 @@ function GridItemContent(props) {
|
|
|
54
54
|
},
|
|
55
55
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_panel.Panel, {
|
|
56
56
|
definition: panelDefinition,
|
|
57
|
-
editHandlers: editHandlers
|
|
57
|
+
editHandlers: editHandlers,
|
|
58
|
+
panelOptions: props.panelOptions,
|
|
59
|
+
panelGroupItemId: panelGroupItemId
|
|
58
60
|
})
|
|
59
61
|
});
|
|
60
62
|
}
|
|
@@ -105,6 +105,7 @@ function GridLayout(props) {
|
|
|
105
105
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
106
106
|
FallbackComponent: _components.ErrorAlert,
|
|
107
107
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridItemContent.GridItemContent, {
|
|
108
|
+
panelOptions: props.panelOptions,
|
|
108
109
|
panelGroupItemId: {
|
|
109
110
|
panelGroupId,
|
|
110
111
|
panelGroupItemLayoutId: i
|
|
@@ -32,7 +32,8 @@ function _interopRequireDefault(obj) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
35
|
-
|
|
35
|
+
var ref;
|
|
36
|
+
const { definition , editHandlers , onMouseEnter , onMouseLeave , sx , panelOptions , panelGroupItemId , ...others } = props;
|
|
36
37
|
// Make sure we have an ID we can use for aria attributes
|
|
37
38
|
const generatedPanelId = (0, _components.useId)('Panel');
|
|
38
39
|
const headerId = `${generatedPanelId}-header`;
|
|
@@ -50,7 +51,7 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
|
50
51
|
width,
|
|
51
52
|
height
|
|
52
53
|
]);
|
|
53
|
-
const { ref , inView } = (0, _reactIntersectionObserver.useInView)({
|
|
54
|
+
const { ref: ref1 , inView } = (0, _reactIntersectionObserver.useInView)({
|
|
54
55
|
threshold: 0.3,
|
|
55
56
|
initialInView: false,
|
|
56
57
|
triggerOnce: true
|
|
@@ -63,7 +64,7 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
|
63
64
|
onMouseLeave === null || onMouseLeave === void 0 ? void 0 : onMouseLeave(e);
|
|
64
65
|
};
|
|
65
66
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Card, {
|
|
66
|
-
ref:
|
|
67
|
+
ref: ref1,
|
|
67
68
|
component: "section",
|
|
68
69
|
sx: (0, _components.combineSx)({
|
|
69
70
|
width: '100%',
|
|
@@ -80,6 +81,10 @@ const Panel = /*#__PURE__*/ (0, _react.memo)(function Panel(props) {
|
|
|
80
81
|
...others,
|
|
81
82
|
children: [
|
|
82
83
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_panelHeader.PanelHeader, {
|
|
84
|
+
extra: panelOptions === null || panelOptions === void 0 ? void 0 : (ref = panelOptions.extra) === null || ref === void 0 ? void 0 : ref.call(panelOptions, {
|
|
85
|
+
panelDefinition: definition,
|
|
86
|
+
panelGroupItemId
|
|
87
|
+
}),
|
|
83
88
|
id: headerId,
|
|
84
89
|
title: definition.spec.display.name,
|
|
85
90
|
description: definition.spec.display.description,
|
|
@@ -33,7 +33,7 @@ function _interopRequireDefault(obj) {
|
|
|
33
33
|
default: obj
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function PanelHeader({ id , title: rawTitle , description: rawDescription , editHandlers , sx , ...rest }) {
|
|
36
|
+
function PanelHeader({ id , title: rawTitle , description: rawDescription , editHandlers , sx , extra , ...rest }) {
|
|
37
37
|
const titleElementId = `${id}-title`;
|
|
38
38
|
const descriptionTooltipId = `${id}-description`;
|
|
39
39
|
const title = (0, _pluginSystem.useReplaceVariablesInString)(rawTitle);
|
|
@@ -140,11 +140,15 @@ function PanelHeader({ id , title: rawTitle , description: rawDescription , edit
|
|
|
140
140
|
})
|
|
141
141
|
]
|
|
142
142
|
}),
|
|
143
|
-
action: /*#__PURE__*/ (0, _jsxRuntime.
|
|
143
|
+
action: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(HeaderActionWrapper, {
|
|
144
144
|
direction: "row",
|
|
145
145
|
spacing: 0.25,
|
|
146
146
|
alignItems: "center",
|
|
147
|
-
children:
|
|
147
|
+
children: [
|
|
148
|
+
editHandlers === undefined && extra,
|
|
149
|
+
" ",
|
|
150
|
+
actions
|
|
151
|
+
]
|
|
148
152
|
}),
|
|
149
153
|
sx: (0, _components.combineSx)((theme)=>({
|
|
150
154
|
padding: theme.spacing(1),
|
|
@@ -34,7 +34,9 @@ const SaveDashboardButton = ({ onSave , isDisabled , variant ='contained' })=>{
|
|
|
34
34
|
const { openSaveChangesConfirmationDialog , closeSaveChangesConfirmationDialog } = (0, _context.useSaveChangesConfirmationDialog)();
|
|
35
35
|
const onSaveButtonClick = ()=>{
|
|
36
36
|
const isSavedDurationModified = (0, _core.isRelativeTimeRange)(timeRange) && dashboard.spec.duration !== timeRange.pastDuration;
|
|
37
|
-
// Save dashboard
|
|
37
|
+
// Save dashboard
|
|
38
|
+
// - if active timeRange from plugin-system is relative and different from currently saved
|
|
39
|
+
// - or if the saved variables are different from currently saved
|
|
38
40
|
if (isSavedDurationModified || isSavedVariableModified) {
|
|
39
41
|
openSaveChangesConfirmationDialog({
|
|
40
42
|
onSaveChanges: (saveDefaultTimeRange, saveDefaultVariables)=>{
|
|
@@ -34,6 +34,7 @@ function _interopRequireDefault(obj) {
|
|
|
34
34
|
function EditVariablesButton({ variant ='text' , label ='Variables' , color ='primary' , fullWidth }) {
|
|
35
35
|
const [isVariableEditorOpen, setIsVariableEditorOpen] = (0, _react.useState)(false);
|
|
36
36
|
const variableDefinitions = (0, _context.useTemplateVariableDefinitions)();
|
|
37
|
+
const externalVariableDefinitions = (0, _context.useTemplateExternalVariableDefinitions)();
|
|
37
38
|
const { setVariableDefinitions } = (0, _context.useTemplateVariableActions)();
|
|
38
39
|
const openVariableEditor = ()=>{
|
|
39
40
|
setIsVariableEditorOpen(true);
|
|
@@ -70,6 +71,7 @@ function EditVariablesButton({ variant ='text' , label ='Variables' , color ='pr
|
|
|
70
71
|
"data-testid": "variable-editor",
|
|
71
72
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variableEditor.VariableEditor, {
|
|
72
73
|
variableDefinitions: variableDefinitions,
|
|
74
|
+
externalVariableDefinitions: externalVariableDefinitions,
|
|
73
75
|
onCancel: closeVariableEditor,
|
|
74
76
|
onChange: (variables)=>{
|
|
75
77
|
setVariableDefinitions(variables);
|
|
@@ -22,20 +22,22 @@ const _jsxRuntime = require("react/jsx-runtime");
|
|
|
22
22
|
const _react = require("react");
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
24
|
const _core = require("@perses-dev/core");
|
|
25
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
25
26
|
const _context = require("../../context");
|
|
26
|
-
|
|
27
|
-
function TemplateVariable({ name }) {
|
|
27
|
+
function TemplateVariable({ name , source }) {
|
|
28
28
|
var ref;
|
|
29
|
-
const ctx = (0, _context.useTemplateVariable)(name);
|
|
29
|
+
const ctx = (0, _context.useTemplateVariable)(name, source);
|
|
30
30
|
const kind = (ref = ctx.definition) === null || ref === void 0 ? void 0 : ref.kind;
|
|
31
31
|
switch(kind){
|
|
32
32
|
case 'TextVariable':
|
|
33
33
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(TextVariable, {
|
|
34
|
-
name: name
|
|
34
|
+
name: name,
|
|
35
|
+
source: source
|
|
35
36
|
});
|
|
36
37
|
case 'ListVariable':
|
|
37
38
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(ListVariable, {
|
|
38
|
-
name: name
|
|
39
|
+
name: name,
|
|
40
|
+
source: source
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
@@ -45,26 +47,27 @@ function TemplateVariable({ name }) {
|
|
|
45
47
|
]
|
|
46
48
|
});
|
|
47
49
|
}
|
|
48
|
-
function ListVariable({ name }) {
|
|
50
|
+
function ListVariable({ name , source }) {
|
|
49
51
|
var ref, ref1, ref2, ref3;
|
|
50
|
-
const ctx = (0, _context.useTemplateVariable)(name);
|
|
52
|
+
const ctx = (0, _context.useTemplateVariable)(name, source);
|
|
51
53
|
const definition = ctx.definition;
|
|
52
|
-
const variablesOptionsQuery = (0,
|
|
54
|
+
const variablesOptionsQuery = (0, _pluginSystem.useListVariablePluginValues)(definition);
|
|
53
55
|
const { setVariableValue , setVariableLoading , setVariableOptions } = (0, _context.useTemplateVariableActions)();
|
|
54
56
|
const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_multiple) === true;
|
|
55
57
|
const allowAllValue = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_all_value) === true;
|
|
56
58
|
var ref4;
|
|
57
59
|
const title = (ref4 = (ref = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref4 !== void 0 ? ref4 : name;
|
|
58
60
|
(0, _react.useEffect)(()=>{
|
|
59
|
-
setVariableLoading(name, variablesOptionsQuery.isFetching);
|
|
61
|
+
setVariableLoading(name, variablesOptionsQuery.isFetching, source);
|
|
60
62
|
if (variablesOptionsQuery.data) {
|
|
61
|
-
setVariableOptions(name, variablesOptionsQuery.data);
|
|
63
|
+
setVariableOptions(name, variablesOptionsQuery.data, source);
|
|
62
64
|
}
|
|
63
65
|
}, [
|
|
64
66
|
variablesOptionsQuery,
|
|
65
67
|
name,
|
|
66
68
|
setVariableLoading,
|
|
67
|
-
setVariableOptions
|
|
69
|
+
setVariableOptions,
|
|
70
|
+
source
|
|
68
71
|
]);
|
|
69
72
|
let value = (ref1 = ctx.state) === null || ref1 === void 0 ? void 0 : ref1.value;
|
|
70
73
|
const options = (ref2 = ctx.state) === null || ref2 === void 0 ? void 0 : ref2.options;
|
|
@@ -112,14 +115,15 @@ function ListVariable({ name }) {
|
|
|
112
115
|
const firstOption = finalOptions === null || finalOptions === void 0 ? void 0 : finalOptions[0];
|
|
113
116
|
// If there is no value but there are options, set the value to the first option.
|
|
114
117
|
if (!value && firstOption) {
|
|
115
|
-
setVariableValue(name, firstOption.value);
|
|
118
|
+
setVariableValue(name, firstOption.value, source);
|
|
116
119
|
}
|
|
117
120
|
}, [
|
|
118
121
|
finalOptions,
|
|
119
122
|
setVariableValue,
|
|
120
123
|
value,
|
|
121
124
|
name,
|
|
122
|
-
allowMultiple
|
|
125
|
+
allowMultiple,
|
|
126
|
+
source
|
|
123
127
|
]);
|
|
124
128
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
125
129
|
display: 'flex',
|
|
@@ -142,11 +146,11 @@ function ListVariable({ name }) {
|
|
|
142
146
|
// Must be selected
|
|
143
147
|
if (e.target.value === null || e.target.value.length === 0) {
|
|
144
148
|
if (allowAllValue) {
|
|
145
|
-
setVariableValue(name, _core.DEFAULT_ALL_VALUE);
|
|
149
|
+
setVariableValue(name, _core.DEFAULT_ALL_VALUE, source);
|
|
146
150
|
}
|
|
147
151
|
return;
|
|
148
152
|
}
|
|
149
|
-
setVariableValue(name, e.target.value);
|
|
153
|
+
setVariableValue(name, e.target.value, source);
|
|
150
154
|
},
|
|
151
155
|
multiple: allowMultiple,
|
|
152
156
|
children: [
|
|
@@ -171,9 +175,9 @@ function ListVariable({ name }) {
|
|
|
171
175
|
})
|
|
172
176
|
});
|
|
173
177
|
}
|
|
174
|
-
function TextVariable({ name }) {
|
|
178
|
+
function TextVariable({ name , source }) {
|
|
175
179
|
var ref;
|
|
176
|
-
const { state , definition } = (0, _context.useTemplateVariable)(name);
|
|
180
|
+
const { state , definition } = (0, _context.useTemplateVariable)(name, source);
|
|
177
181
|
var ref1;
|
|
178
182
|
const [tempValue, setTempValue] = (0, _react.useState)((ref1 = state === null || state === void 0 ? void 0 : state.value) !== null && ref1 !== void 0 ? ref1 : '');
|
|
179
183
|
const { setVariableValue } = (0, _context.useTemplateVariableActions)();
|
|
@@ -187,7 +191,7 @@ function TextVariable({ name }) {
|
|
|
187
191
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
188
192
|
value: tempValue,
|
|
189
193
|
onChange: (e)=>setTempValue(e.target.value),
|
|
190
|
-
onBlur: ()=>setVariableValue(name, tempValue),
|
|
194
|
+
onBlur: ()=>setVariableValue(name, tempValue, source),
|
|
191
195
|
placeholder: name,
|
|
192
196
|
label: (ref2 = (ref = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref2 !== void 0 ? ref2 : name
|
|
193
197
|
});
|