@perses-dev/dashboards 0.39.0 → 0.40.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/AddGroupButton/AddGroupButton.js +9 -7
- package/dist/cjs/components/AddGroupButton/index.js +10 -8
- package/dist/cjs/components/AddPanelButton/AddPanelButton.js +9 -7
- package/dist/cjs/components/AddPanelButton/index.js +10 -8
- package/dist/cjs/components/Dashboard/Dashboard.js +11 -9
- package/dist/cjs/components/Dashboard/index.js +10 -8
- package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +18 -16
- package/dist/cjs/components/DashboardStickyToolbar/index.js +10 -8
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +43 -41
- package/dist/cjs/components/DashboardToolbar/index.js +10 -8
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +12 -10
- package/dist/cjs/components/DeletePanelDialog/index.js +10 -8
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +17 -15
- package/dist/cjs/components/DeletePanelGroupDialog/index.js +10 -8
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +5 -3
- package/dist/cjs/components/DiscardChangesConfirmationDialog/index.js +10 -8
- package/dist/cjs/components/DownloadButton/DownloadButton.js +12 -10
- package/dist/cjs/components/DownloadButton/index.js +10 -8
- package/dist/cjs/components/EditButton/EditButton.js +8 -6
- package/dist/cjs/components/EditButton/index.js +10 -8
- package/dist/cjs/components/EditJsonButton/EditJsonButton.js +10 -8
- package/dist/cjs/components/EditJsonButton/index.js +10 -8
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +29 -23
- package/dist/cjs/components/EditJsonDialog/index.js +10 -8
- package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +18 -16
- package/dist/cjs/components/EmptyDashboard/index.js +10 -8
- package/dist/cjs/components/GridLayout/GridContainer.js +5 -3
- package/dist/cjs/components/GridLayout/GridItemContent.js +33 -14
- package/dist/cjs/components/GridLayout/GridLayout.js +18 -16
- package/dist/cjs/components/GridLayout/GridTitle.js +35 -33
- package/dist/cjs/components/GridLayout/index.js +13 -11
- package/dist/cjs/components/Panel/Panel.js +17 -22
- package/dist/cjs/components/Panel/PanelContent.js +8 -6
- package/dist/cjs/components/Panel/PanelHeader.js +33 -31
- package/dist/cjs/components/Panel/index.js +10 -8
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +25 -77
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +269 -141
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +11 -9
- package/dist/cjs/components/PanelDrawer/index.js +10 -8
- package/dist/cjs/components/PanelDrawer/usePanelEditor.js +3 -1
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +18 -16
- package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +15 -11
- package/dist/cjs/components/PanelGroupDialog/index.js +10 -8
- package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +46 -44
- package/dist/cjs/components/QuerySummaryTable/index.js +10 -8
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +23 -21
- package/dist/cjs/components/SaveChangesConfirmationDialog/index.js +10 -8
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +8 -8
- package/dist/cjs/components/SaveDashboardButton/index.js +10 -8
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +40 -16
- package/dist/cjs/components/TimeRangeControls/index.js +10 -8
- package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +5 -3
- package/dist/cjs/components/ToolbarIconButton/index.js +10 -8
- package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +140 -0
- package/dist/cjs/components/Variables/EditVariablesButton.js +16 -11
- package/dist/cjs/components/Variables/TemplateVariable.js +116 -69
- package/dist/cjs/components/Variables/VariableEditor.js +282 -204
- package/dist/cjs/components/Variables/VariableList.js +19 -15
- package/dist/cjs/components/Variables/index.js +14 -11
- package/dist/cjs/components/index.js +31 -29
- package/dist/cjs/constants/grid-layout-config.js +6 -2
- package/dist/cjs/constants/index.js +11 -9
- package/dist/cjs/constants/user-interface-text.js +6 -2
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +40 -34
- package/dist/cjs/context/DashboardProvider/common.js +6 -2
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +70 -38
- package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +5 -3
- package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/edit-json-dialog-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/index.js +12 -10
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +13 -11
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +8 -6
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +15 -7
- package/dist/cjs/context/DashboardProvider/panel-slice.js +3 -1
- package/dist/cjs/context/DashboardProvider/save-changes-dialog-slice.js +3 -1
- package/dist/cjs/context/DatasourceStoreProvider.js +114 -45
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +125 -34
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +12 -10
- package/dist/cjs/context/TemplateVariableProvider/index.js +10 -8
- package/dist/cjs/context/TemplateVariableProvider/query-params.js +17 -7
- package/dist/cjs/context/TemplateVariableProvider/utils.js +15 -7
- package/dist/cjs/context/index.js +13 -11
- package/dist/cjs/context/useDashboard.js +8 -6
- package/dist/cjs/index.js +12 -10
- package/dist/cjs/stories/decorators/WithDashboard.js +6 -4
- package/dist/cjs/stories/decorators/WithDatasourceStore.js +6 -4
- package/dist/cjs/stories/decorators/WithTemplateVariables.js +6 -4
- package/dist/cjs/stories/decorators/constants.js +5 -3
- package/dist/cjs/stories/decorators/index.js +13 -11
- package/dist/cjs/test/dashboard-provider.js +8 -4
- package/dist/cjs/test/datasource-provider.js +16 -12
- package/dist/cjs/test/index.js +13 -11
- package/dist/cjs/test/plugin-registry.js +6 -4
- package/dist/cjs/test/render.js +27 -20
- package/dist/cjs/test/setup-tests.js +2 -2
- package/dist/cjs/test/testDashboard.js +13 -11
- package/dist/cjs/utils/index.js +11 -9
- package/dist/cjs/utils/panelUtils.js +9 -3
- package/dist/cjs/utils/time.js +5 -3
- package/dist/cjs/validation/index.js +30 -0
- package/dist/cjs/validation/panel.js +29 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +20 -16
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +63 -19
- package/dist/cjs/views/ViewDashboard/index.js +10 -8
- package/dist/cjs/views/index.js +10 -8
- package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
- package/dist/components/AddGroupButton/index.js.map +1 -1
- package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
- package/dist/components/AddPanelButton/index.js.map +1 -1
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Dashboard/index.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardStickyToolbar/index.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/index.js.map +1 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
- package/dist/components/DeletePanelDialog/index.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -2
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/index.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/index.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
- package/dist/components/DownloadButton/index.js.map +1 -1
- package/dist/components/EditButton/EditButton.js.map +1 -1
- package/dist/components/EditButton/index.js.map +1 -1
- package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
- package/dist/components/EditJsonButton/index.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +4 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +12 -8
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/EditJsonDialog/index.js.map +1 -1
- package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
- package/dist/components/EmptyDashboard/index.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +27 -10
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +2 -2
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/GridLayout/index.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +4 -11
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- 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 +22 -76
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +4 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +223 -138
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +2 -2
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelDrawer/index.js.map +1 -1
- package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
- package/dist/components/PanelGroupDialog/index.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +4 -4
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/QuerySummaryTable/index.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/index.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +1 -3
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/SaveDashboardButton/index.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +19 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -1
- package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/components/ToolbarIconButton/index.js.map +1 -1
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts +8 -0
- package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -0
- package/dist/components/Variables/BuiltinVariableAccordions.js +127 -0
- package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -0
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +3 -0
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +10 -1
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +91 -54
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +2 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +231 -157
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.js +6 -6
- 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.js.map +1 -1
- package/dist/constants/grid-layout-config.js.map +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +5 -5
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/common.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +2 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js +2 -2
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +7 -7
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +2 -2
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +3 -3
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +14 -10
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +107 -40
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +10 -4
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +93 -18
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +7 -7
- package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/TemplateVariableProvider/index.js.map +1 -1
- package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.js +3 -3
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.js +1 -1
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/stories/decorators/WithDashboard.js.map +1 -1
- package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
- package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
- package/dist/stories/decorators/constants.js +2 -2
- package/dist/stories/decorators/constants.js.map +1 -1
- package/dist/stories/decorators/index.js.map +1 -1
- package/dist/test/dashboard-provider.js.map +1 -1
- package/dist/test/datasource-provider.d.ts.map +1 -1
- package/dist/test/datasource-provider.js +5 -7
- package/dist/test/datasource-provider.js.map +1 -1
- package/dist/test/index.js.map +1 -1
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +6 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/testDashboard.js +10 -10
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/panelUtils.js.map +1 -1
- package/dist/utils/time.js.map +1 -1
- package/dist/validation/index.d.ts +2 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +15 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/panel.d.ts +19 -0
- package/dist/validation/panel.d.ts.map +1 -0
- package/dist/validation/panel.js +21 -0
- package/dist/validation/panel.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +4 -2
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +49 -7
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/index.js.map +1 -1
- package/dist/views/index.js.map +1 -1
- package/package.json +8 -7
|
@@ -14,71 +14,64 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
TemplateVariable: function() {
|
|
25
|
+
return TemplateVariable;
|
|
26
|
+
},
|
|
27
|
+
useListVariableState: function() {
|
|
28
|
+
return useListVariableState;
|
|
29
|
+
}
|
|
20
30
|
});
|
|
21
|
-
const
|
|
31
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
22
32
|
const _react = require("react");
|
|
23
33
|
const _material = require("@mui/material");
|
|
24
34
|
const _core = require("@perses-dev/core");
|
|
25
|
-
const
|
|
35
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
26
36
|
const _context = require("../../context");
|
|
27
37
|
function TemplateVariable({ name , source }) {
|
|
28
|
-
var
|
|
38
|
+
var _ctx_definition;
|
|
29
39
|
const ctx = (0, _context.useTemplateVariable)(name, source);
|
|
30
|
-
const kind = (
|
|
40
|
+
const kind = (_ctx_definition = ctx.definition) === null || _ctx_definition === void 0 ? void 0 : _ctx_definition.kind;
|
|
31
41
|
switch(kind){
|
|
32
42
|
case 'TextVariable':
|
|
33
|
-
return /*#__PURE__*/ (0,
|
|
43
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(TextVariable, {
|
|
34
44
|
name: name,
|
|
35
45
|
source: source
|
|
36
46
|
});
|
|
37
47
|
case 'ListVariable':
|
|
38
|
-
return /*#__PURE__*/ (0,
|
|
48
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(ListVariable, {
|
|
39
49
|
name: name,
|
|
40
50
|
source: source
|
|
41
51
|
});
|
|
42
52
|
}
|
|
43
|
-
return /*#__PURE__*/ (0,
|
|
53
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
44
54
|
children: [
|
|
45
55
|
"Unsupported Variable Kind: $",
|
|
46
56
|
kind
|
|
47
57
|
]
|
|
48
58
|
});
|
|
49
59
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
const { setVariableValue , setVariableLoading , setVariableOptions } = (0, _context.useTemplateVariableActions)();
|
|
56
|
-
const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_multiple) === true;
|
|
57
|
-
const allowAllValue = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_all_value) === true;
|
|
58
|
-
var ref4;
|
|
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;
|
|
60
|
-
(0, _react.useEffect)(()=>{
|
|
61
|
-
setVariableLoading(name, variablesOptionsQuery.isFetching, source);
|
|
62
|
-
if (variablesOptionsQuery.data) {
|
|
63
|
-
setVariableOptions(name, variablesOptionsQuery.data, source);
|
|
64
|
-
}
|
|
65
|
-
}, [
|
|
66
|
-
variablesOptionsQuery,
|
|
67
|
-
name,
|
|
68
|
-
setVariableLoading,
|
|
69
|
-
setVariableOptions,
|
|
70
|
-
source
|
|
60
|
+
function useListVariableState(spec, state, variablesOptionsQuery) {
|
|
61
|
+
const allowMultiple = (spec === null || spec === void 0 ? void 0 : spec.allowMultiple) === true;
|
|
62
|
+
const allowAllValue = (spec === null || spec === void 0 ? void 0 : spec.allowAllValue) === true;
|
|
63
|
+
const loading = (0, _react.useMemo)(()=>variablesOptionsQuery.isFetching || false, [
|
|
64
|
+
variablesOptionsQuery
|
|
71
65
|
]);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const loading = (ref3 = ctx.state) === null || ref3 === void 0 ? void 0 : ref3.loading;
|
|
66
|
+
const options = variablesOptionsQuery.data;
|
|
67
|
+
let value = state === null || state === void 0 ? void 0 : state.value;
|
|
75
68
|
// Make sure value is an array if allowMultiple is true
|
|
76
69
|
if (allowMultiple && !Array.isArray(value)) {
|
|
77
70
|
value = typeof value === 'string' ? [
|
|
78
71
|
value
|
|
79
72
|
] : [];
|
|
80
73
|
}
|
|
81
|
-
const
|
|
74
|
+
const viewOptions = (0, _react.useMemo)(()=>{
|
|
82
75
|
let computedOptions = options ? [
|
|
83
76
|
...options
|
|
84
77
|
] : [];
|
|
@@ -97,51 +90,100 @@ function ListVariable({ name , source }) {
|
|
|
97
90
|
options,
|
|
98
91
|
allowAllValue
|
|
99
92
|
]);
|
|
100
|
-
const valueIsInOptions = (0, _react.useMemo)(()=>Boolean(
|
|
93
|
+
const valueIsInOptions = (0, _react.useMemo)(()=>Boolean(viewOptions.find((v)=>{
|
|
101
94
|
if (allowMultiple) {
|
|
102
95
|
return value.includes(v.value);
|
|
103
96
|
}
|
|
104
97
|
return value === v.value;
|
|
105
98
|
})), [
|
|
106
|
-
|
|
99
|
+
viewOptions,
|
|
107
100
|
value,
|
|
108
101
|
allowMultiple
|
|
109
102
|
]);
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
103
|
+
value = (0, _react.useMemo)(()=>{
|
|
104
|
+
var _viewOptions_;
|
|
105
|
+
const firstOptionValue = viewOptions === null || viewOptions === void 0 ? void 0 : (_viewOptions_ = viewOptions[allowAllValue ? 1 : 0]) === null || _viewOptions_ === void 0 ? void 0 : _viewOptions_.value;
|
|
106
|
+
// If there is no value but there are options, or the value is not in options, we set the value to the first option.
|
|
107
|
+
if (firstOptionValue) {
|
|
108
|
+
if (!valueIsInOptions || !value || value.length === 0) {
|
|
109
|
+
return allowMultiple ? [
|
|
110
|
+
firstOptionValue
|
|
111
|
+
] : firstOptionValue;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return value;
|
|
115
|
+
}, [
|
|
116
|
+
viewOptions,
|
|
117
|
+
value,
|
|
118
|
+
valueIsInOptions,
|
|
119
|
+
allowMultiple,
|
|
120
|
+
allowAllValue
|
|
121
|
+
]);
|
|
122
|
+
// Once we computed value, we set it as the selected one, if it is available in the options
|
|
123
|
+
const selectedValue = value && valueIsInOptions ? value : allowMultiple ? [] : '';
|
|
124
|
+
return {
|
|
125
|
+
value,
|
|
126
|
+
loading,
|
|
127
|
+
options,
|
|
128
|
+
selectedValue,
|
|
129
|
+
viewOptions
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function ListVariable({ name , source }) {
|
|
133
|
+
var _definition_spec_display;
|
|
134
|
+
const ctx = (0, _context.useTemplateVariable)(name, source);
|
|
135
|
+
const definition = ctx.definition;
|
|
136
|
+
const variablesOptionsQuery = (0, _pluginsystem.useListVariablePluginValues)(definition);
|
|
137
|
+
const { setVariableValue , setVariableLoading , setVariableOptions } = (0, _context.useTemplateVariableActions)();
|
|
138
|
+
const { selectedValue , value , loading , options , viewOptions } = useListVariableState(definition === null || definition === void 0 ? void 0 : definition.spec, ctx.state, variablesOptionsQuery);
|
|
139
|
+
var _definition_spec_display_name;
|
|
140
|
+
const title = (_definition_spec_display_name = (_definition_spec_display = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || _definition_spec_display === void 0 ? void 0 : _definition_spec_display.name) !== null && _definition_spec_display_name !== void 0 ? _definition_spec_display_name : name;
|
|
141
|
+
const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allowMultiple) === true;
|
|
142
|
+
const allowAllValue = (definition === null || definition === void 0 ? void 0 : definition.spec.allowAllValue) === true;
|
|
143
|
+
// Update value when changed
|
|
114
144
|
(0, _react.useEffect)(()=>{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (!value && firstOption) {
|
|
118
|
-
setVariableValue(name, firstOption.value, source);
|
|
145
|
+
if (value) {
|
|
146
|
+
setVariableValue(name, value, source);
|
|
119
147
|
}
|
|
120
148
|
}, [
|
|
121
|
-
finalOptions,
|
|
122
149
|
setVariableValue,
|
|
150
|
+
name,
|
|
123
151
|
value,
|
|
152
|
+
source
|
|
153
|
+
]);
|
|
154
|
+
// Update loading when changed
|
|
155
|
+
(0, _react.useEffect)(()=>{
|
|
156
|
+
setVariableLoading(name, loading, source);
|
|
157
|
+
}, [
|
|
158
|
+
setVariableLoading,
|
|
124
159
|
name,
|
|
125
|
-
|
|
160
|
+
loading,
|
|
126
161
|
source
|
|
127
162
|
]);
|
|
128
|
-
|
|
163
|
+
// Update options when changed
|
|
164
|
+
(0, _react.useEffect)(()=>{
|
|
165
|
+
if (options) {
|
|
166
|
+
setVariableOptions(name, options, source);
|
|
167
|
+
}
|
|
168
|
+
}, [
|
|
169
|
+
setVariableOptions,
|
|
170
|
+
name,
|
|
171
|
+
options,
|
|
172
|
+
source
|
|
173
|
+
]);
|
|
174
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
129
175
|
display: 'flex',
|
|
130
|
-
children: /*#__PURE__*/ (0,
|
|
176
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.FormControl, {
|
|
131
177
|
fullWidth: true,
|
|
132
178
|
children: [
|
|
133
|
-
/*#__PURE__*/ (0,
|
|
179
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.InputLabel, {
|
|
134
180
|
id: name,
|
|
135
181
|
children: title
|
|
136
182
|
}),
|
|
137
|
-
/*#__PURE__*/ (0,
|
|
138
|
-
sx: {
|
|
139
|
-
minWidth: 100,
|
|
140
|
-
maxWidth: 250
|
|
141
|
-
},
|
|
183
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Select, {
|
|
142
184
|
id: name,
|
|
143
185
|
label: title,
|
|
144
|
-
value:
|
|
186
|
+
value: selectedValue,
|
|
145
187
|
onChange: (e)=>{
|
|
146
188
|
// Must be selected
|
|
147
189
|
if (e.target.value === null || e.target.value.length === 0) {
|
|
@@ -154,45 +196,50 @@ function ListVariable({ name , source }) {
|
|
|
154
196
|
},
|
|
155
197
|
multiple: allowMultiple,
|
|
156
198
|
children: [
|
|
157
|
-
loading && /*#__PURE__*/ (0,
|
|
199
|
+
loading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
158
200
|
value: "loading",
|
|
159
201
|
disabled: true,
|
|
160
202
|
children: "Loading"
|
|
161
203
|
}),
|
|
162
|
-
|
|
204
|
+
viewOptions.length === 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
163
205
|
value: "empty",
|
|
164
206
|
disabled: true,
|
|
165
207
|
children: "No options"
|
|
166
208
|
}),
|
|
167
|
-
|
|
209
|
+
viewOptions.map((option)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
168
210
|
value: option.value,
|
|
169
211
|
children: option.label
|
|
170
212
|
}, option.value))
|
|
171
213
|
]
|
|
172
214
|
}),
|
|
173
|
-
loading && /*#__PURE__*/ (0,
|
|
215
|
+
loading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.LinearProgress, {})
|
|
174
216
|
]
|
|
175
217
|
})
|
|
176
218
|
});
|
|
177
219
|
}
|
|
178
220
|
function TextVariable({ name , source }) {
|
|
179
|
-
var
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const
|
|
221
|
+
var _definition_spec_display;
|
|
222
|
+
const ctx = (0, _context.useTemplateVariable)(name, source);
|
|
223
|
+
const state = ctx.state;
|
|
224
|
+
const definition = ctx.definition;
|
|
225
|
+
var _state_value;
|
|
226
|
+
const [tempValue, setTempValue] = (0, _react.useState)((_state_value = state === null || state === void 0 ? void 0 : state.value) !== null && _state_value !== void 0 ? _state_value : '');
|
|
183
227
|
const { setVariableValue } = (0, _context.useTemplateVariableActions)();
|
|
184
228
|
(0, _react.useEffect)(()=>{
|
|
185
|
-
var
|
|
186
|
-
setTempValue((
|
|
229
|
+
var _state_value;
|
|
230
|
+
setTempValue((_state_value = state === null || state === void 0 ? void 0 : state.value) !== null && _state_value !== void 0 ? _state_value : '');
|
|
187
231
|
}, [
|
|
188
232
|
state === null || state === void 0 ? void 0 : state.value
|
|
189
233
|
]);
|
|
190
|
-
var
|
|
191
|
-
return /*#__PURE__*/ (0,
|
|
234
|
+
var _definition_spec_display_name, _definition_spec_constant;
|
|
235
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
192
236
|
value: tempValue,
|
|
193
237
|
onChange: (e)=>setTempValue(e.target.value),
|
|
194
238
|
onBlur: ()=>setVariableValue(name, tempValue, source),
|
|
195
239
|
placeholder: name,
|
|
196
|
-
label: (
|
|
240
|
+
label: (_definition_spec_display_name = (_definition_spec_display = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || _definition_spec_display === void 0 ? void 0 : _definition_spec_display.name) !== null && _definition_spec_display_name !== void 0 ? _definition_spec_display_name : name,
|
|
241
|
+
InputProps: {
|
|
242
|
+
readOnly: (_definition_spec_constant = definition === null || definition === void 0 ? void 0 : definition.spec.constant) !== null && _definition_spec_constant !== void 0 ? _definition_spec_constant : false
|
|
243
|
+
}
|
|
197
244
|
});
|
|
198
245
|
}
|