@perses-dev/dashboards 0.15.0 → 0.17.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/DashboardToolbar/DashboardToolbar.js +8 -12
- package/dist/cjs/components/DownloadButton/DownloadButton.js +109 -0
- package/dist/cjs/{utils/component-ids.js → components/DownloadButton/index.js} +11 -14
- package/dist/cjs/components/GridLayout/GridLayout.js +13 -2
- package/dist/cjs/components/GridLayout/GridTitle.js +11 -17
- package/dist/cjs/components/Panel/Panel.js +4 -2
- package/dist/cjs/components/Panel/PanelHeader.js +54 -50
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -3
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +23 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +3 -1
- package/dist/cjs/components/Variables/Variable.js +7 -46
- package/dist/cjs/components/Variables/VariableEditor.js +157 -126
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +353 -161
- package/dist/cjs/components/Variables/VariableList.js +15 -8
- package/dist/cjs/components/Variables/variable-model.js +74 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +40 -15
- package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +5 -9
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +16 -1
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +15 -21
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +8 -12
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.d.ts +3 -0
- package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -0
- package/dist/components/DownloadButton/DownloadButton.js +60 -0
- package/dist/components/DownloadButton/DownloadButton.js.map +1 -0
- package/dist/components/DownloadButton/index.d.ts +2 -0
- package/dist/components/DownloadButton/index.d.ts.map +1 -0
- package/dist/{utils/component-ids.js → components/DownloadButton/index.js} +2 -14
- package/dist/components/DownloadButton/index.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +13 -2
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +11 -17
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +4 -2
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +54 -50
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +1 -3
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js +23 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +4 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +8 -47
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +159 -128
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +315 -162
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +15 -8
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +8 -0
- package/dist/components/Variables/variable-model.d.ts.map +1 -0
- package/dist/components/Variables/variable-model.js +64 -0
- package/dist/components/Variables/variable-model.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +40 -15
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-editor-slice.js +5 -9
- package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +9 -0
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +17 -0
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +15 -21
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +4 -4
- package/dist/utils/component-ids.d.ts +0 -8
- package/dist/utils/component-ids.d.ts.map +0 -1
- package/dist/utils/component-ids.js.map +0 -1
|
@@ -32,9 +32,24 @@ function _interopRequireDefault(obj) {
|
|
|
32
32
|
default: obj
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
function getValidation(variableDefinitions) {
|
|
36
|
+
const errors = [];
|
|
37
|
+
/** Variable names must be unique */ const variableNames = variableDefinitions.map((variableDefinition)=>variableDefinition.spec.name);
|
|
38
|
+
const uniqueVariableNames = new Set(variableNames);
|
|
39
|
+
if (variableNames.length !== uniqueVariableNames.size) {
|
|
40
|
+
errors.push('Variable names must be unique');
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
errors: errors,
|
|
44
|
+
isValid: errors.length === 0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
35
47
|
function VariableEditor(props) {
|
|
36
48
|
const [variableDefinitions, setVariableDefinitions] = (0, _useImmer.useImmer)(props.variableDefinitions);
|
|
37
49
|
const [variableEditIdx, setVariableEditIdx] = (0, _react.useState)(null);
|
|
50
|
+
const validation = (0, _react.useMemo)(()=>getValidation(variableDefinitions), [
|
|
51
|
+
variableDefinitions
|
|
52
|
+
]);
|
|
38
53
|
const currentEditingVariableDefinition = typeof variableEditIdx === 'number' && variableDefinitions[variableEditIdx];
|
|
39
54
|
const removeVariable = (index)=>{
|
|
40
55
|
setVariableDefinitions((draft)=>{
|
|
@@ -88,150 +103,166 @@ function VariableEditor(props) {
|
|
|
88
103
|
}
|
|
89
104
|
});
|
|
90
105
|
};
|
|
91
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(
|
|
92
|
-
p: 4,
|
|
106
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
93
107
|
children: [
|
|
94
|
-
currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
onChange: (definition)=>{
|
|
104
|
-
setVariableDefinitions((draft)=>{
|
|
105
|
-
draft[variableEditIdx] = definition;
|
|
106
|
-
setVariableEditIdx(null);
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
onCancel: ()=>setVariableEditIdx(null)
|
|
110
|
-
})
|
|
111
|
-
]
|
|
108
|
+
currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variableEditorForm.VariableEditForm, {
|
|
109
|
+
initialVariableDefinition: currentEditingVariableDefinition,
|
|
110
|
+
onChange: (definition)=>{
|
|
111
|
+
setVariableDefinitions((draft)=>{
|
|
112
|
+
draft[variableEditIdx] = definition;
|
|
113
|
+
setVariableEditIdx(null);
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
onCancel: ()=>setVariableEditIdx(null)
|
|
112
117
|
}),
|
|
113
118
|
!currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
114
119
|
children: [
|
|
115
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
120
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
121
|
+
sx: {
|
|
122
|
+
display: 'flex',
|
|
123
|
+
alignItems: 'center',
|
|
124
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
125
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.grey[100]}`
|
|
126
|
+
},
|
|
119
127
|
children: [
|
|
120
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
onClick: ()=>{
|
|
124
|
-
props.onChange(variableDefinitions);
|
|
125
|
-
},
|
|
126
|
-
children: "Apply"
|
|
128
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
129
|
+
variant: "h2",
|
|
130
|
+
children: "Template Variables"
|
|
127
131
|
}),
|
|
128
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
133
|
+
direction: "row",
|
|
134
|
+
spacing: 1,
|
|
135
|
+
marginLeft: "auto",
|
|
136
|
+
children: [
|
|
137
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
138
|
+
disabled: props.variableDefinitions === variableDefinitions || !validation.isValid,
|
|
139
|
+
variant: "contained",
|
|
140
|
+
onClick: ()=>{
|
|
141
|
+
props.onChange(variableDefinitions);
|
|
142
|
+
},
|
|
143
|
+
children: "Apply"
|
|
144
|
+
}),
|
|
145
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
146
|
+
variant: "outlined",
|
|
147
|
+
onClick: ()=>{
|
|
148
|
+
props.onCancel();
|
|
149
|
+
},
|
|
150
|
+
children: "Cancel"
|
|
151
|
+
})
|
|
152
|
+
]
|
|
134
153
|
})
|
|
135
154
|
]
|
|
136
155
|
}),
|
|
137
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
143
|
-
spacing: 2,
|
|
156
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
157
|
+
padding: 2,
|
|
158
|
+
sx: {
|
|
159
|
+
overflowY: 'scroll'
|
|
160
|
+
},
|
|
144
161
|
children: [
|
|
145
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
children:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
181
|
-
checked: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) !== true,
|
|
182
|
-
onChange: (e)=>{
|
|
183
|
-
toggleVariableVisibility(idx, e.target.checked);
|
|
184
|
-
}
|
|
162
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
163
|
+
variant: "h3",
|
|
164
|
+
mb: 2,
|
|
165
|
+
children: "Variable List"
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
168
|
+
spacing: 2,
|
|
169
|
+
children: [
|
|
170
|
+
!validation.isValid && validation.errors.map((error)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
|
|
171
|
+
severity: "error",
|
|
172
|
+
children: error
|
|
173
|
+
}, error)),
|
|
174
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableContainer, {
|
|
175
|
+
component: _material.Paper,
|
|
176
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Table, {
|
|
177
|
+
sx: {
|
|
178
|
+
minWidth: 650
|
|
179
|
+
},
|
|
180
|
+
"aria-label": "simple table",
|
|
181
|
+
children: [
|
|
182
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableHead, {
|
|
183
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableRow, {
|
|
184
|
+
children: [
|
|
185
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
186
|
+
children: "Visibility"
|
|
187
|
+
}),
|
|
188
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
189
|
+
children: "Variable Name"
|
|
190
|
+
}),
|
|
191
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
192
|
+
children: "Variable Type"
|
|
193
|
+
}),
|
|
194
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
195
|
+
align: "right",
|
|
196
|
+
children: "Action"
|
|
185
197
|
})
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
children: v.spec.name
|
|
194
|
-
}),
|
|
195
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
196
|
-
children: v.kind
|
|
197
|
-
}),
|
|
198
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableCell, {
|
|
199
|
-
align: "right",
|
|
198
|
+
]
|
|
199
|
+
})
|
|
200
|
+
}),
|
|
201
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableBody, {
|
|
202
|
+
children: variableDefinitions.map((v, idx)=>{
|
|
203
|
+
var ref;
|
|
204
|
+
/*#__PURE__*/ return (0, _jsxRuntime.jsxs)(_material.TableRow, {
|
|
200
205
|
children: [
|
|
201
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
206
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
207
|
+
component: "th",
|
|
208
|
+
scope: "row",
|
|
209
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
210
|
+
checked: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) !== true,
|
|
211
|
+
onChange: (e)=>{
|
|
212
|
+
toggleVariableVisibility(idx, e.target.checked);
|
|
213
|
+
}
|
|
214
|
+
})
|
|
205
215
|
}),
|
|
206
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
216
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
217
|
+
component: "th",
|
|
218
|
+
scope: "row",
|
|
219
|
+
sx: {
|
|
220
|
+
fontWeight: 'bold'
|
|
221
|
+
},
|
|
222
|
+
children: v.spec.name
|
|
210
223
|
}),
|
|
211
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.
|
|
212
|
-
|
|
213
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {})
|
|
224
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
225
|
+
children: v.kind
|
|
214
226
|
}),
|
|
215
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
216
|
-
|
|
217
|
-
children:
|
|
227
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableCell, {
|
|
228
|
+
align: "right",
|
|
229
|
+
children: [
|
|
230
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
231
|
+
onClick: ()=>changeVariableOrder(idx, 'up'),
|
|
232
|
+
disabled: idx === 0,
|
|
233
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowUp.default, {})
|
|
234
|
+
}),
|
|
235
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
236
|
+
onClick: ()=>changeVariableOrder(idx, 'down'),
|
|
237
|
+
disabled: idx === variableDefinitions.length - 1,
|
|
238
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowDown.default, {})
|
|
239
|
+
}),
|
|
240
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
241
|
+
onClick: ()=>setVariableEditIdx(idx),
|
|
242
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {})
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
245
|
+
onClick: ()=>removeVariable(idx),
|
|
246
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_trashCan.default, {})
|
|
247
|
+
})
|
|
248
|
+
]
|
|
218
249
|
})
|
|
219
250
|
]
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
251
|
+
}, v.spec.name);
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
]
|
|
224
255
|
})
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
256
|
+
}),
|
|
257
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
258
|
+
display: "flex",
|
|
259
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
260
|
+
onClick: addVariable,
|
|
261
|
+
variant: "contained",
|
|
262
|
+
children: "Add New Variable"
|
|
263
|
+
})
|
|
264
|
+
})
|
|
265
|
+
]
|
|
235
266
|
})
|
|
236
267
|
]
|
|
237
268
|
})
|