@perses-dev/dashboards 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Dashboard.js +7 -11
- package/dist/cjs/components/DashboardToolbar.js +4 -4
- package/dist/cjs/components/GridLayout/GridItemContent.js +13 -13
- package/dist/cjs/components/GridLayout/GridLayout.js +24 -21
- package/dist/cjs/components/GridLayout/GridTitle.js +27 -5
- package/dist/cjs/components/Panel/DeletePanelDialog.js +91 -0
- package/dist/cjs/components/Panel/Panel.js +16 -5
- package/dist/cjs/components/Panel/Panel.test.js +12 -4
- package/dist/cjs/components/Panel/PanelContent.js +3 -2
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +13 -12
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +8 -12
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +77 -35
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +48 -0
- package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +86 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +12 -19
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +10 -31
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +2 -2
- package/dist/cjs/components/Variables/Variable.js +19 -11
- package/dist/cjs/components/Variables/VariableEditor.js +207 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
- package/dist/cjs/components/Variables/VariableList.js +50 -69
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +70 -0
- package/dist/cjs/context/DashboardProvider/common.js +18 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +71 -0
- package/dist/cjs/context/DashboardProvider/index.js +29 -0
- package/dist/cjs/context/DashboardProvider/layout-slice.js +200 -0
- package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +156 -0
- package/dist/{context/DashboardAppSlice.js → cjs/context/DashboardProvider/panel-group-slice.js} +18 -25
- package/dist/cjs/context/DatasourceStoreProvider.js +109 -7
- package/dist/cjs/context/TemplateVariableProvider.js +8 -1
- package/dist/cjs/context/index.js +0 -2
- package/dist/cjs/test/testDashboard.js +13 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +6 -7
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +165 -0
- package/dist/components/Dashboard.d.ts +1 -4
- package/dist/components/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard.js +8 -12
- package/dist/components/Dashboard.js.map +1 -1
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +5 -5
- package/dist/components/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +3 -3
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +14 -14
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -3
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +24 -21
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +28 -6
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
- package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
- package/dist/components/Panel/DeletePanelDialog.js +80 -0
- package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +17 -6
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/Panel.test.js +7 -4
- package/dist/components/Panel/Panel.test.js.map +1 -1
- package/dist/components/Panel/PanelContent.d.ts +4 -1
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +3 -2
- package/dist/components/Panel/PanelContent.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +14 -13
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +8 -12
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +78 -36
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelPreview.js +42 -0
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +4 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +75 -0
- package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +13 -20
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +10 -31
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +3 -3
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/Variable.js +21 -13
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +8 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditor.js +196 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/index.js +15 -0
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +48 -72
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +1 -0
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +23 -0
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
- package/dist/context/DashboardProvider/DashboardProvider.js +52 -0
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
- package/dist/context/DashboardProvider/common.d.ts +5 -0
- package/dist/context/DashboardProvider/common.d.ts.map +1 -0
- package/dist/context/DashboardProvider/common.js +17 -0
- package/dist/context/DashboardProvider/common.js.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +32 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js +56 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +3 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -0
- package/dist/context/DashboardProvider/index.js +16 -0
- package/dist/context/DashboardProvider/index.js.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts +57 -0
- package/dist/context/DashboardProvider/layout-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/layout-slice.js +196 -0
- package/dist/context/DashboardProvider/layout-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts +70 -0
- package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js +152 -0
- package/dist/context/DashboardProvider/panel-editing-slice.js.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/panel-group-slice.js +32 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +10 -2
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +111 -9
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider.d.ts +2 -0
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +8 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -1
- package/dist/context/index.d.ts +0 -2
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +0 -2
- package/dist/context/index.js.map +1 -1
- package/dist/test/plugin-registry.d.ts +2 -2
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js.map +1 -1
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +13 -1
- package/dist/test/testDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +6 -7
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +158 -0
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
- package/package.json +4 -4
- package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +0 -40
- package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +0 -38
- package/dist/cjs/components/PanelDrawer/panel-editor-model.js +0 -140
- package/dist/cjs/context/DashboardAppSlice.js +0 -57
- package/dist/cjs/context/DashboardProvider.js +0 -128
- package/dist/cjs/context/LayoutsSlice.js +0 -55
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +0 -7
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelSpecEditor.js +0 -34
- package/dist/components/PanelDrawer/PanelSpecEditor.js.map +0 -1
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +0 -8
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelTypeSelect.js +0 -34
- package/dist/components/PanelDrawer/PanelTypeSelect.js.map +0 -1
- package/dist/components/PanelDrawer/panel-editor-model.d.ts +0 -27
- package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +0 -1
- package/dist/components/PanelDrawer/panel-editor-model.js +0 -133
- package/dist/components/PanelDrawer/panel-editor-model.js.map +0 -1
- package/dist/context/DashboardAppSlice.d.ts +0 -26
- package/dist/context/DashboardAppSlice.d.ts.map +0 -1
- package/dist/context/DashboardAppSlice.js.map +0 -1
- package/dist/context/DashboardProvider.d.ts +0 -36
- package/dist/context/DashboardProvider.d.ts.map +0 -1
- package/dist/context/DashboardProvider.js +0 -107
- package/dist/context/DashboardProvider.js.map +0 -1
- package/dist/context/LayoutsSlice.d.ts +0 -12
- package/dist/context/LayoutsSlice.d.ts.map +0 -1
- package/dist/context/LayoutsSlice.js +0 -43
- package/dist/context/LayoutsSlice.js.map +0 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "VariableEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>VariableEditor
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _useImmer = require("use-immer");
|
|
25
|
+
const _pencil = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pencil"));
|
|
26
|
+
const _trashCan = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/TrashCan"));
|
|
27
|
+
const _variableEditorForm = require("./VariableEditorForm");
|
|
28
|
+
function _interopRequireDefault(obj) {
|
|
29
|
+
return obj && obj.__esModule ? obj : {
|
|
30
|
+
default: obj
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function VariableEditor(props) {
|
|
34
|
+
const [variableDefinitions, setVariableDefinitions] = (0, _useImmer.useImmer)(props.variableDefinitions);
|
|
35
|
+
const [variableEditIdx, setVariableEditIdx] = (0, _react.useState)(null);
|
|
36
|
+
const currentEditingVariableDefinition = typeof variableEditIdx === 'number' && variableDefinitions[variableEditIdx];
|
|
37
|
+
const removeVariable = (index)=>{
|
|
38
|
+
setVariableDefinitions((draft)=>{
|
|
39
|
+
draft.splice(index, 1);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
const addVariable = ()=>{
|
|
43
|
+
setVariableDefinitions((draft)=>{
|
|
44
|
+
draft.push({
|
|
45
|
+
kind: 'TextVariable',
|
|
46
|
+
spec: {
|
|
47
|
+
name: 'NewVariable',
|
|
48
|
+
value: ''
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
const toggleVariableVisibility = (index, visible)=>{
|
|
54
|
+
setVariableDefinitions((draft)=>{
|
|
55
|
+
const v = draft[index];
|
|
56
|
+
if (!v) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!v.spec.display) {
|
|
60
|
+
v.spec.display = {
|
|
61
|
+
hidden: false
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
v.spec.display.hidden = visible === false;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
68
|
+
p: 4,
|
|
69
|
+
children: [
|
|
70
|
+
currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
73
|
+
variant: "h3",
|
|
74
|
+
mb: 2,
|
|
75
|
+
children: "Edit Variable"
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_variableEditorForm.VariableEditForm, {
|
|
78
|
+
initialVariableDefinition: currentEditingVariableDefinition,
|
|
79
|
+
onChange: (definition)=>{
|
|
80
|
+
setVariableDefinitions((draft)=>{
|
|
81
|
+
draft[variableEditIdx] = definition;
|
|
82
|
+
setVariableEditIdx(null);
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
onCancel: ()=>setVariableEditIdx(null)
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
}),
|
|
89
|
+
!currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
90
|
+
children: [
|
|
91
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
92
|
+
direction: "row",
|
|
93
|
+
spacing: 1,
|
|
94
|
+
justifyContent: "end",
|
|
95
|
+
children: [
|
|
96
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
97
|
+
onClick: ()=>{
|
|
98
|
+
props.onCancel();
|
|
99
|
+
},
|
|
100
|
+
children: "Cancel"
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
103
|
+
disabled: props.variableDefinitions === variableDefinitions,
|
|
104
|
+
variant: "contained",
|
|
105
|
+
onClick: ()=>{
|
|
106
|
+
props.onChange(variableDefinitions);
|
|
107
|
+
},
|
|
108
|
+
children: "Apply Changes"
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
113
|
+
variant: "h3",
|
|
114
|
+
mb: 2,
|
|
115
|
+
children: "Variable List"
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
118
|
+
spacing: 2,
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableContainer, {
|
|
121
|
+
component: _material.Paper,
|
|
122
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Table, {
|
|
123
|
+
sx: {
|
|
124
|
+
minWidth: 650
|
|
125
|
+
},
|
|
126
|
+
"aria-label": "simple table",
|
|
127
|
+
children: [
|
|
128
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableHead, {
|
|
129
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableRow, {
|
|
130
|
+
children: [
|
|
131
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
132
|
+
children: "Visibility"
|
|
133
|
+
}),
|
|
134
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
135
|
+
children: "Variable Name"
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
138
|
+
children: "Variable Type"
|
|
139
|
+
}),
|
|
140
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
141
|
+
align: "right",
|
|
142
|
+
children: "Action"
|
|
143
|
+
})
|
|
144
|
+
]
|
|
145
|
+
})
|
|
146
|
+
}),
|
|
147
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableBody, {
|
|
148
|
+
children: variableDefinitions.map((v, idx)=>{
|
|
149
|
+
var ref;
|
|
150
|
+
/*#__PURE__*/ return (0, _jsxRuntime.jsxs)(_material.TableRow, {
|
|
151
|
+
children: [
|
|
152
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
153
|
+
component: "th",
|
|
154
|
+
scope: "row",
|
|
155
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
156
|
+
checked: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) !== true,
|
|
157
|
+
onChange: (e)=>{
|
|
158
|
+
toggleVariableVisibility(idx, e.target.checked);
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
163
|
+
component: "th",
|
|
164
|
+
scope: "row",
|
|
165
|
+
sx: {
|
|
166
|
+
fontWeight: 'bold'
|
|
167
|
+
},
|
|
168
|
+
children: v.spec.name
|
|
169
|
+
}),
|
|
170
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
171
|
+
children: v.kind
|
|
172
|
+
}),
|
|
173
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableCell, {
|
|
174
|
+
align: "right",
|
|
175
|
+
children: [
|
|
176
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
177
|
+
onClick: ()=>setVariableEditIdx(idx),
|
|
178
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {})
|
|
179
|
+
}),
|
|
180
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
181
|
+
onClick: ()=>removeVariable(idx),
|
|
182
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_trashCan.default, {})
|
|
183
|
+
})
|
|
184
|
+
]
|
|
185
|
+
})
|
|
186
|
+
]
|
|
187
|
+
}, v.spec.name);
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
]
|
|
191
|
+
})
|
|
192
|
+
}),
|
|
193
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
194
|
+
display: "flex",
|
|
195
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
196
|
+
onClick: addVariable,
|
|
197
|
+
variant: "contained",
|
|
198
|
+
children: "Add New Variable"
|
|
199
|
+
})
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
})
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
]
|
|
206
|
+
});
|
|
207
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "VariableEditForm", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>VariableEditForm
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _useImmer = require("use-immer");
|
|
25
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
26
|
+
const _variableEditorFormModel = require("./variable-editor-form-model");
|
|
27
|
+
function _interopRequireDefault(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const VARIABLE_TYPES = [
|
|
33
|
+
'ListVariable',
|
|
34
|
+
'TextVariable'
|
|
35
|
+
];
|
|
36
|
+
const SectionHeader = ({ children })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
37
|
+
pb: 2,
|
|
38
|
+
variant: "subtitle1",
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
function VariableEditForm({ initialVariableDefinition , onChange , onCancel }) {
|
|
42
|
+
const [state, setState] = (0, _useImmer.useImmer)((0, _variableEditorFormModel.getInitialState)(initialVariableDefinition));
|
|
43
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
|
|
46
|
+
children: "General"
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
49
|
+
container: true,
|
|
50
|
+
spacing: 2,
|
|
51
|
+
mb: 2,
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
54
|
+
item: true,
|
|
55
|
+
xs: 6,
|
|
56
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
57
|
+
label: "Name",
|
|
58
|
+
value: state.name,
|
|
59
|
+
onChange: (v)=>{
|
|
60
|
+
setState((draft)=>{
|
|
61
|
+
draft.name = v.target.value;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
67
|
+
item: true,
|
|
68
|
+
xs: 6,
|
|
69
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.FormControl, {
|
|
70
|
+
fullWidth: true,
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
73
|
+
id: "variable-type-select-label",
|
|
74
|
+
children: "Type"
|
|
75
|
+
}),
|
|
76
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Select, {
|
|
77
|
+
labelId: "variable-type-select-label",
|
|
78
|
+
id: "variable-type-select",
|
|
79
|
+
label: "Type",
|
|
80
|
+
value: state.kind,
|
|
81
|
+
onChange: (v)=>{
|
|
82
|
+
setState((draft)=>{
|
|
83
|
+
draft.kind = v.target.value;
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
children: VARIABLE_TYPES.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
87
|
+
value: v,
|
|
88
|
+
children: v
|
|
89
|
+
}, v))
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
95
|
+
item: true,
|
|
96
|
+
xs: 6,
|
|
97
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
98
|
+
label: "Label",
|
|
99
|
+
value: state.label,
|
|
100
|
+
onChange: (v)=>{
|
|
101
|
+
setState((draft)=>{
|
|
102
|
+
draft.label = v.target.value;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
108
|
+
item: true,
|
|
109
|
+
xs: 12,
|
|
110
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
111
|
+
label: "Description",
|
|
112
|
+
value: state.description,
|
|
113
|
+
onChange: (v)=>{
|
|
114
|
+
setState((draft)=>{
|
|
115
|
+
draft.description = v.target.value;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}),
|
|
122
|
+
state.kind === 'TextVariable' && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
123
|
+
children: [
|
|
124
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
|
|
125
|
+
children: "Text Options"
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
128
|
+
container: true,
|
|
129
|
+
spacing: 2,
|
|
130
|
+
mb: 2,
|
|
131
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
132
|
+
item: true,
|
|
133
|
+
xs: 12,
|
|
134
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
135
|
+
label: "Value",
|
|
136
|
+
value: state.textVariableFields.value,
|
|
137
|
+
onChange: (v)=>{
|
|
138
|
+
setState((draft)=>{
|
|
139
|
+
draft.textVariableFields.value = v.target.value;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
})
|
|
144
|
+
})
|
|
145
|
+
]
|
|
146
|
+
}),
|
|
147
|
+
state.kind === 'ListVariable' && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
148
|
+
children: [
|
|
149
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
|
|
150
|
+
children: "List Options"
|
|
151
|
+
}),
|
|
152
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
153
|
+
container: true,
|
|
154
|
+
spacing: 2,
|
|
155
|
+
mb: 2,
|
|
156
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
157
|
+
item: true,
|
|
158
|
+
xs: 6,
|
|
159
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginEditor, {
|
|
160
|
+
width: 500,
|
|
161
|
+
pluginType: "Variable",
|
|
162
|
+
pluginKindLabel: "Source",
|
|
163
|
+
value: state.listVariableFields.plugin,
|
|
164
|
+
onChange: (val)=>{
|
|
165
|
+
setState((draft)=>{
|
|
166
|
+
draft.listVariableFields.plugin = val;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
}),
|
|
172
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
|
|
173
|
+
children: "Dropdown Options"
|
|
174
|
+
}),
|
|
175
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
176
|
+
container: true,
|
|
177
|
+
spacing: 1,
|
|
178
|
+
mb: 1,
|
|
179
|
+
children: [
|
|
180
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
181
|
+
item: true,
|
|
182
|
+
xs: 12,
|
|
183
|
+
children: [
|
|
184
|
+
"Allow Multiple",
|
|
185
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
186
|
+
checked: state.listVariableFields.allowMultiple,
|
|
187
|
+
onChange: (e)=>{
|
|
188
|
+
setState((draft)=>{
|
|
189
|
+
draft.listVariableFields.allowMultiple = e.target.checked;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
}),
|
|
195
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
196
|
+
item: true,
|
|
197
|
+
xs: 12,
|
|
198
|
+
children: [
|
|
199
|
+
"Allow All",
|
|
200
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
201
|
+
checked: state.listVariableFields.allowAll,
|
|
202
|
+
onChange: (e)=>{
|
|
203
|
+
setState((draft)=>{
|
|
204
|
+
draft.listVariableFields.allowAll = e.target.checked;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
})
|
|
212
|
+
]
|
|
213
|
+
}),
|
|
214
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
215
|
+
direction: 'row',
|
|
216
|
+
spacing: 2,
|
|
217
|
+
justifyContent: "end",
|
|
218
|
+
children: [
|
|
219
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
220
|
+
onClick: ()=>{
|
|
221
|
+
onCancel();
|
|
222
|
+
},
|
|
223
|
+
children: "Cancel"
|
|
224
|
+
}),
|
|
225
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
226
|
+
variant: "contained",
|
|
227
|
+
onClick: ()=>{
|
|
228
|
+
onChange((0, _variableEditorFormModel.getVariableDefinitionFromState)(state));
|
|
229
|
+
},
|
|
230
|
+
children: "Update Variable"
|
|
231
|
+
})
|
|
232
|
+
]
|
|
233
|
+
})
|
|
234
|
+
]
|
|
235
|
+
});
|
|
236
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./VariableEditorForm"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
getInitialState: ()=>getInitialState,
|
|
25
|
+
getVariableDefinitionFromState: ()=>getVariableDefinitionFromState
|
|
26
|
+
});
|
|
27
|
+
function getInitialState(initialVariableDefinition) {
|
|
28
|
+
var ref;
|
|
29
|
+
var _value;
|
|
30
|
+
const textVariableFields = {
|
|
31
|
+
value: (_value = initialVariableDefinition.spec.value) !== null && _value !== void 0 ? _value : ''
|
|
32
|
+
};
|
|
33
|
+
const listVariableFields = {
|
|
34
|
+
allowMultiple: false,
|
|
35
|
+
allowAll: false,
|
|
36
|
+
plugin: {
|
|
37
|
+
kind: '',
|
|
38
|
+
spec: {}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
if (initialVariableDefinition.kind === 'ListVariable') {
|
|
42
|
+
var _allow_all_value;
|
|
43
|
+
listVariableFields.allowMultiple = (_allow_all_value = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value !== void 0 ? _allow_all_value : false;
|
|
44
|
+
var _allow_all_value1;
|
|
45
|
+
listVariableFields.allowAll = (_allow_all_value1 = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value1 !== void 0 ? _allow_all_value1 : false;
|
|
46
|
+
listVariableFields.plugin = initialVariableDefinition.spec.plugin;
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
name: initialVariableDefinition.spec.name,
|
|
50
|
+
label: (ref = initialVariableDefinition.spec.display) === null || ref === void 0 ? void 0 : ref.label,
|
|
51
|
+
kind: initialVariableDefinition.kind,
|
|
52
|
+
description: '',
|
|
53
|
+
listVariableFields,
|
|
54
|
+
textVariableFields
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function getVariableDefinitionFromState(state) {
|
|
58
|
+
const { name , label , kind } = state;
|
|
59
|
+
const commonSpec = {
|
|
60
|
+
name,
|
|
61
|
+
display: {
|
|
62
|
+
label
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
if (kind === 'TextVariable') {
|
|
66
|
+
const textVariableDefinition = {
|
|
67
|
+
kind,
|
|
68
|
+
spec: {
|
|
69
|
+
...commonSpec,
|
|
70
|
+
...state.textVariableFields
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return textVariableDefinition;
|
|
74
|
+
}
|
|
75
|
+
if (kind === 'ListVariable') {
|
|
76
|
+
const listVariableDefinition = {
|
|
77
|
+
kind,
|
|
78
|
+
spec: {
|
|
79
|
+
...commonSpec,
|
|
80
|
+
allow_multiple: state.listVariableFields.allowMultiple,
|
|
81
|
+
allow_all_value: state.listVariableFields.allowAll,
|
|
82
|
+
plugin: state.listVariableFields.plugin
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return listVariableDefinition;
|
|
86
|
+
}
|
|
87
|
+
throw new Error(`Unknown variable kind: ${kind}`);
|
|
88
|
+
}
|