@perses-dev/dashboards 0.19.0 → 0.21.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 +18 -5
- package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +74 -0
- package/dist/cjs/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
- package/dist/cjs/components/GridLayout/GridTitle.js +38 -22
- package/dist/cjs/components/Panel/PanelHeader.js +59 -26
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +29 -8
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +11 -6
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +9 -2
- package/dist/cjs/components/Variables/Variable.js +5 -3
- package/dist/cjs/components/Variables/VariableEditor.js +123 -104
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +69 -57
- package/dist/cjs/components/Variables/VariableList.js +7 -20
- package/dist/cjs/components/Variables/variable-model.js +12 -1
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -0
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +10 -1
- package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +33 -0
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +14 -14
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +19 -6
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
- package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +3 -0
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +63 -0
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -0
- package/dist/components/DiscardChangesConfirmationDialog/index.d.ts +2 -0
- package/dist/components/DiscardChangesConfirmationDialog/index.d.ts.map +1 -0
- package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
- package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js.map +1 -1
- package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
- package/dist/components/GridLayout/GridTitle.js +38 -22
- package/dist/components/GridLayout/GridTitle.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +61 -28
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +32 -11
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +12 -7
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +5 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +9 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/Variable.js +5 -3
- 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 +121 -102
- 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 +70 -58
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +7 -20
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +7 -0
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +10 -0
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +2 -0
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +5 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +8 -0
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts +15 -0
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts.map +1 -0
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.js +27 -0
- package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -0
- package/dist/context/DashboardProvider/index.d.ts +1 -0
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- 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 +16 -16
- 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 +2 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +4 -4
- package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -67
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +0 -8
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +0 -1
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -56
- package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +0 -1
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +0 -2
- package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +0 -1
|
@@ -26,12 +26,18 @@ const _pencil = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pe
|
|
|
26
26
|
const _trashCan = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/TrashCan"));
|
|
27
27
|
const _arrowUp = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowUp"));
|
|
28
28
|
const _arrowDown = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ArrowDown"));
|
|
29
|
+
const _context = require("../../context");
|
|
29
30
|
const _variableEditorForm = require("./VariableEditorForm");
|
|
31
|
+
const _variableModel = require("./variable-model");
|
|
30
32
|
function _interopRequireDefault(obj) {
|
|
31
33
|
return obj && obj.__esModule ? obj : {
|
|
32
34
|
default: obj
|
|
33
35
|
};
|
|
34
36
|
}
|
|
37
|
+
function getVariableLabelByKind(kind) {
|
|
38
|
+
var ref;
|
|
39
|
+
return (ref = _variableModel.VARIABLE_TYPES.find((variableType)=>variableType.kind === kind)) === null || ref === void 0 ? void 0 : ref.label;
|
|
40
|
+
}
|
|
35
41
|
function getValidation(variableDefinitions) {
|
|
36
42
|
const errors = [];
|
|
37
43
|
/** Variable names must be unique */ const variableNames = variableDefinitions.map((variableDefinition)=>variableDefinition.spec.name);
|
|
@@ -51,6 +57,23 @@ function VariableEditor(props) {
|
|
|
51
57
|
variableDefinitions
|
|
52
58
|
]);
|
|
53
59
|
const currentEditingVariableDefinition = typeof variableEditIdx === 'number' && variableDefinitions[variableEditIdx];
|
|
60
|
+
const { openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog } = (0, _context.useDiscardChangesConfirmationDialog)();
|
|
61
|
+
const handleCancel = ()=>{
|
|
62
|
+
if (JSON.stringify(props.variableDefinitions) !== JSON.stringify(variableDefinitions)) {
|
|
63
|
+
openDiscardChangesConfirmationDialog({
|
|
64
|
+
onDiscardChanges: ()=>{
|
|
65
|
+
closeDiscardChangesConfirmationDialog();
|
|
66
|
+
props.onCancel();
|
|
67
|
+
},
|
|
68
|
+
onCancel: ()=>{
|
|
69
|
+
closeDiscardChangesConfirmationDialog();
|
|
70
|
+
},
|
|
71
|
+
description: 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.'
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
props.onCancel();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
54
77
|
const removeVariable = (index)=>{
|
|
55
78
|
setVariableDefinitions((draft)=>{
|
|
56
79
|
draft.splice(index, 1);
|
|
@@ -66,6 +89,7 @@ function VariableEditor(props) {
|
|
|
66
89
|
}
|
|
67
90
|
});
|
|
68
91
|
});
|
|
92
|
+
setVariableEditIdx(variableDefinitions.length);
|
|
69
93
|
};
|
|
70
94
|
const toggleVariableVisibility = (index, visible)=>{
|
|
71
95
|
setVariableDefinitions((draft)=>{
|
|
@@ -103,6 +127,7 @@ function VariableEditor(props) {
|
|
|
103
127
|
}
|
|
104
128
|
});
|
|
105
129
|
};
|
|
130
|
+
var ref;
|
|
106
131
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
107
132
|
children: [
|
|
108
133
|
currentEditingVariableDefinition && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variableEditorForm.VariableEditForm, {
|
|
@@ -122,12 +147,12 @@ function VariableEditor(props) {
|
|
|
122
147
|
display: 'flex',
|
|
123
148
|
alignItems: 'center',
|
|
124
149
|
padding: (theme)=>theme.spacing(1, 2),
|
|
125
|
-
borderBottom: (theme)=>`1px solid ${theme.palette.
|
|
150
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
126
151
|
},
|
|
127
152
|
children: [
|
|
128
153
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
129
154
|
variant: "h2",
|
|
130
|
-
children: "
|
|
155
|
+
children: "Variables"
|
|
131
156
|
}),
|
|
132
157
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
133
158
|
direction: "row",
|
|
@@ -143,131 +168,125 @@ function VariableEditor(props) {
|
|
|
143
168
|
children: "Apply"
|
|
144
169
|
}),
|
|
145
170
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
171
|
+
color: "secondary",
|
|
146
172
|
variant: "outlined",
|
|
147
|
-
onClick:
|
|
148
|
-
props.onCancel();
|
|
149
|
-
},
|
|
173
|
+
onClick: handleCancel,
|
|
150
174
|
children: "Cancel"
|
|
151
175
|
})
|
|
152
176
|
]
|
|
153
177
|
})
|
|
154
178
|
]
|
|
155
179
|
}),
|
|
156
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
180
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
157
181
|
padding: 2,
|
|
158
182
|
sx: {
|
|
159
183
|
overflowY: 'scroll'
|
|
160
184
|
},
|
|
161
|
-
children:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
185
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
186
|
+
spacing: 2,
|
|
187
|
+
children: [
|
|
188
|
+
!validation.isValid && validation.errors.map((error)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
|
|
189
|
+
severity: "error",
|
|
190
|
+
children: error
|
|
191
|
+
}, error)),
|
|
192
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableContainer, {
|
|
193
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Table, {
|
|
194
|
+
sx: {
|
|
195
|
+
minWidth: 650
|
|
196
|
+
},
|
|
197
|
+
"aria-label": "simple table",
|
|
198
|
+
children: [
|
|
199
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableHead, {
|
|
200
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableRow, {
|
|
201
|
+
children: [
|
|
202
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(TableCell, {
|
|
203
|
+
children: "Visibility"
|
|
204
|
+
}),
|
|
205
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(TableCell, {
|
|
206
|
+
children: "Name"
|
|
207
|
+
}),
|
|
208
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(TableCell, {
|
|
209
|
+
children: "Type"
|
|
210
|
+
}),
|
|
211
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(TableCell, {
|
|
212
|
+
align: "right",
|
|
213
|
+
children: "Action"
|
|
214
|
+
})
|
|
215
|
+
]
|
|
216
|
+
})
|
|
217
|
+
}),
|
|
218
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableBody, {
|
|
219
|
+
children: variableDefinitions.map((v, idx)=>{
|
|
220
|
+
var ref1;
|
|
221
|
+
/*#__PURE__*/ return (0, _jsxRuntime.jsxs)(_material.TableRow, {
|
|
184
222
|
children: [
|
|
185
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
186
|
-
|
|
223
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(TableCell, {
|
|
224
|
+
component: "th",
|
|
225
|
+
scope: "row",
|
|
226
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Switch, {
|
|
227
|
+
checked: ((ref1 = v.spec.display) === null || ref1 === void 0 ? void 0 : ref1.hidden) !== true,
|
|
228
|
+
onChange: (e)=>{
|
|
229
|
+
toggleVariableVisibility(idx, e.target.checked);
|
|
230
|
+
}
|
|
231
|
+
})
|
|
187
232
|
}),
|
|
188
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
189
|
-
|
|
233
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(TableCell, {
|
|
234
|
+
component: "th",
|
|
235
|
+
scope: "row",
|
|
236
|
+
sx: {
|
|
237
|
+
fontWeight: 'bold'
|
|
238
|
+
},
|
|
239
|
+
children: v.spec.name
|
|
190
240
|
}),
|
|
191
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
192
|
-
children:
|
|
241
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(TableCell, {
|
|
242
|
+
children: (ref = getVariableLabelByKind(v.kind)) !== null && ref !== void 0 ? ref : v.kind
|
|
193
243
|
}),
|
|
194
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
244
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(TableCell, {
|
|
195
245
|
align: "right",
|
|
196
|
-
children:
|
|
246
|
+
children: [
|
|
247
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
248
|
+
onClick: ()=>changeVariableOrder(idx, 'up'),
|
|
249
|
+
disabled: idx === 0,
|
|
250
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowUp.default, {})
|
|
251
|
+
}),
|
|
252
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
253
|
+
onClick: ()=>changeVariableOrder(idx, 'down'),
|
|
254
|
+
disabled: idx === variableDefinitions.length - 1,
|
|
255
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_arrowDown.default, {})
|
|
256
|
+
}),
|
|
257
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
258
|
+
onClick: ()=>setVariableEditIdx(idx),
|
|
259
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {})
|
|
260
|
+
}),
|
|
261
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
262
|
+
onClick: ()=>removeVariable(idx),
|
|
263
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_trashCan.default, {})
|
|
264
|
+
})
|
|
265
|
+
]
|
|
197
266
|
})
|
|
198
267
|
]
|
|
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, {
|
|
205
|
-
children: [
|
|
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
|
-
})
|
|
215
|
-
}),
|
|
216
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
217
|
-
component: "th",
|
|
218
|
-
scope: "row",
|
|
219
|
-
sx: {
|
|
220
|
-
fontWeight: 'bold'
|
|
221
|
-
},
|
|
222
|
-
children: v.spec.name
|
|
223
|
-
}),
|
|
224
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
225
|
-
children: v.kind
|
|
226
|
-
}),
|
|
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
|
-
]
|
|
249
|
-
})
|
|
250
|
-
]
|
|
251
|
-
}, v.spec.name);
|
|
252
|
-
})
|
|
268
|
+
}, v.spec.name);
|
|
253
269
|
})
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
})
|
|
270
|
+
})
|
|
271
|
+
]
|
|
264
272
|
})
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
273
|
+
}),
|
|
274
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
275
|
+
display: "flex",
|
|
276
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
277
|
+
onClick: addVariable,
|
|
278
|
+
variant: "contained",
|
|
279
|
+
children: "Add New"
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
]
|
|
283
|
+
})
|
|
268
284
|
})
|
|
269
285
|
]
|
|
270
286
|
})
|
|
271
287
|
]
|
|
272
288
|
});
|
|
273
289
|
}
|
|
290
|
+
const TableCell = (0, _material.styled)(_material.TableCell)(({ theme })=>({
|
|
291
|
+
borderBottom: `solid 1px ${theme.palette.divider}`
|
|
292
|
+
}));
|
|
@@ -25,6 +25,7 @@ const _useImmer = require("use-immer");
|
|
|
25
25
|
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
26
26
|
const _components = require("@perses-dev/components");
|
|
27
27
|
const _refresh = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Refresh"));
|
|
28
|
+
const _clipboardOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ClipboardOutline"));
|
|
28
29
|
const _variableModel = require("../variable-model");
|
|
29
30
|
const _variableEditorFormModel = require("./variable-editor-form-model");
|
|
30
31
|
function _interopRequireDefault(obj) {
|
|
@@ -71,10 +72,6 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
71
72
|
}
|
|
72
73
|
return newObj;
|
|
73
74
|
}
|
|
74
|
-
const VARIABLE_TYPES = [
|
|
75
|
-
'ListVariable',
|
|
76
|
-
'TextVariable'
|
|
77
|
-
];
|
|
78
75
|
const DEFAULT_MAX_PREVIEW_VALUES = 50;
|
|
79
76
|
// TODO: Replace with proper validation library
|
|
80
77
|
function getValidation(state) {
|
|
@@ -96,7 +93,7 @@ const SectionHeader = ({ children })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_mater
|
|
|
96
93
|
variant: "subtitle1",
|
|
97
94
|
children: children
|
|
98
95
|
});
|
|
99
|
-
function VariableListPreview({ definition }) {
|
|
96
|
+
function VariableListPreview({ definition , onRefresh }) {
|
|
100
97
|
const { data , isFetching , error } = (0, _variableModel.useListVariablePluginValues)(definition);
|
|
101
98
|
const [maxValues, setMaxValues] = (0, _react.useState)(DEFAULT_MAX_PREVIEW_VALUES);
|
|
102
99
|
const showAll = ()=>{
|
|
@@ -109,6 +106,40 @@ function VariableListPreview({ definition }) {
|
|
|
109
106
|
const errorMessage = error === null || error === void 0 ? void 0 : error.message;
|
|
110
107
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
111
108
|
children: [
|
|
109
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
110
|
+
direction: 'row',
|
|
111
|
+
spacing: 1,
|
|
112
|
+
alignItems: "center",
|
|
113
|
+
children: [
|
|
114
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
115
|
+
variant: "caption",
|
|
116
|
+
children: "Preview Values"
|
|
117
|
+
}),
|
|
118
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
119
|
+
title: "Refresh Values",
|
|
120
|
+
placement: "right",
|
|
121
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
122
|
+
onClick: onRefresh,
|
|
123
|
+
size: "small",
|
|
124
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_refresh.default, {})
|
|
125
|
+
})
|
|
126
|
+
}),
|
|
127
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
128
|
+
title: "Copy Values to Clipboard",
|
|
129
|
+
placement: "right",
|
|
130
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
131
|
+
onClick: async ()=>{
|
|
132
|
+
if (data === null || data === void 0 ? void 0 : data.length) {
|
|
133
|
+
await navigator.clipboard.writeText(data.map((d)=>d.label).join(','));
|
|
134
|
+
alert('Copied to clipboard!');
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
size: "small",
|
|
138
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_clipboardOutline.default, {})
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
]
|
|
142
|
+
}),
|
|
112
143
|
errorMessage && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
|
|
113
144
|
severity: "error",
|
|
114
145
|
children: errorMessage
|
|
@@ -168,12 +199,12 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
168
199
|
display: 'flex',
|
|
169
200
|
alignItems: 'center',
|
|
170
201
|
padding: (theme)=>theme.spacing(1, 2),
|
|
171
|
-
borderBottom: (theme)=>`1px solid ${theme.palette.
|
|
202
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
172
203
|
},
|
|
173
204
|
children: [
|
|
174
205
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
175
206
|
variant: "h2",
|
|
176
|
-
children: "
|
|
207
|
+
children: "Edit Variable"
|
|
177
208
|
}),
|
|
178
209
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
179
210
|
direction: "row",
|
|
@@ -191,6 +222,7 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
191
222
|
children: "Update"
|
|
192
223
|
}),
|
|
193
224
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
225
|
+
color: "secondary",
|
|
194
226
|
variant: "outlined",
|
|
195
227
|
onClick: ()=>{
|
|
196
228
|
onCancel();
|
|
@@ -207,11 +239,6 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
207
239
|
overflowY: 'scroll'
|
|
208
240
|
},
|
|
209
241
|
children: [
|
|
210
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
211
|
-
variant: "h3",
|
|
212
|
-
mb: 2,
|
|
213
|
-
children: "Edit Variable"
|
|
214
|
-
}),
|
|
215
242
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(SectionHeader, {
|
|
216
243
|
children: "General"
|
|
217
244
|
}),
|
|
@@ -257,10 +284,10 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
257
284
|
draft.kind = v.target.value;
|
|
258
285
|
});
|
|
259
286
|
},
|
|
260
|
-
children: VARIABLE_TYPES.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
261
|
-
value: v,
|
|
262
|
-
children: v
|
|
263
|
-
}, v))
|
|
287
|
+
children: _variableModel.VARIABLE_TYPES.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
288
|
+
value: v.kind,
|
|
289
|
+
children: v.label
|
|
290
|
+
}, v.kind))
|
|
264
291
|
})
|
|
265
292
|
]
|
|
266
293
|
})
|
|
@@ -270,7 +297,7 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
270
297
|
xs: 6,
|
|
271
298
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
272
299
|
fullWidth: true,
|
|
273
|
-
label: "Label",
|
|
300
|
+
label: "Display Label",
|
|
274
301
|
value: state.title,
|
|
275
302
|
onChange: (v)=>{
|
|
276
303
|
setState((draft)=>{
|
|
@@ -334,18 +361,6 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
334
361
|
item: true,
|
|
335
362
|
xs: 6,
|
|
336
363
|
children: [
|
|
337
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
338
|
-
sx: {
|
|
339
|
-
mb: 1
|
|
340
|
-
},
|
|
341
|
-
label: "Capturing Regexp",
|
|
342
|
-
value: state.listVariableFields.capturing_regexp,
|
|
343
|
-
onChange: (e)=>{
|
|
344
|
-
setState((draft)=>{
|
|
345
|
-
draft.listVariableFields.capturing_regexp = e.target.value;
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
}),
|
|
349
364
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.ClickAwayListener, {
|
|
350
365
|
onClickAway: ()=>refreshPreview(),
|
|
351
366
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {})
|
|
@@ -363,38 +378,35 @@ function VariableEditForm({ initialVariableDefinition , onChange , onCancel })
|
|
|
363
378
|
})
|
|
364
379
|
]
|
|
365
380
|
}),
|
|
366
|
-
state.listVariableFields.plugin.kind && /*#__PURE__*/ (0, _jsxRuntime.
|
|
381
|
+
state.listVariableFields.plugin.kind && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
367
382
|
item: true,
|
|
368
383
|
xs: 12,
|
|
369
|
-
children:
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
]
|
|
392
|
-
}),
|
|
393
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(VariableListPreview, {
|
|
384
|
+
children: [
|
|
385
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
386
|
+
sx: {
|
|
387
|
+
mb: 1
|
|
388
|
+
},
|
|
389
|
+
label: "Capturing Regexp Filter",
|
|
390
|
+
value: state.listVariableFields.capturing_regexp,
|
|
391
|
+
onChange: (e)=>{
|
|
392
|
+
setState((draft)=>{
|
|
393
|
+
draft.listVariableFields.capturing_regexp = e.target.value;
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
}),
|
|
397
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
398
|
+
FallbackComponent: ()=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
399
|
+
children: "Error previewing values"
|
|
400
|
+
}),
|
|
401
|
+
resetKeys: [
|
|
402
|
+
previewSpec
|
|
403
|
+
],
|
|
404
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(VariableListPreview, {
|
|
405
|
+
onRefresh: refreshPreview,
|
|
394
406
|
definition: previewSpec
|
|
395
407
|
})
|
|
396
|
-
|
|
397
|
-
|
|
408
|
+
})
|
|
409
|
+
]
|
|
398
410
|
})
|
|
399
411
|
]
|
|
400
412
|
}),
|
|
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "TemplateVariableList", {
|
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
23
|
const _material = require("@mui/material");
|
|
24
|
-
const _eye = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Eye"));
|
|
25
24
|
const _pencil = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Pencil"));
|
|
26
25
|
const _pinOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOutline"));
|
|
27
26
|
const _pinOffOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/PinOffOutline"));
|
|
@@ -78,8 +77,6 @@ function TemplateVariableList(props) {
|
|
|
78
77
|
const [isPin, setIsPin] = (0, _react.useState)(props.initialVariableIsSticky);
|
|
79
78
|
const variableDefinitions = (0, _context.useTemplateVariableDefinitions)();
|
|
80
79
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
81
|
-
const [showVariablesInEditMode, setShowVariablesInEditMode] = (0, _react.useState)(true);
|
|
82
|
-
const showVariables = isEditMode ? showVariablesInEditMode : true;
|
|
83
80
|
const { setVariableDefinitions } = (0, _context.useTemplateVariableActions)();
|
|
84
81
|
const scrollTrigger = (0, _material.useScrollTrigger)({
|
|
85
82
|
disableHysteresis: true
|
|
@@ -107,23 +104,13 @@ function TemplateVariableList(props) {
|
|
|
107
104
|
}
|
|
108
105
|
})
|
|
109
106
|
}),
|
|
110
|
-
isEditMode && /*#__PURE__*/ (0, _jsxRuntime.
|
|
107
|
+
isEditMode && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
111
108
|
pb: 2,
|
|
112
|
-
children:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
showVariablesInEditMode ? 'Hide' : 'Show',
|
|
118
|
-
" Variables"
|
|
119
|
-
]
|
|
120
|
-
}),
|
|
121
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
122
|
-
onClick: ()=>setIsEditing(true),
|
|
123
|
-
startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {}),
|
|
124
|
-
children: "Edit Variables"
|
|
125
|
-
})
|
|
126
|
-
]
|
|
109
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
110
|
+
onClick: ()=>setIsEditing(true),
|
|
111
|
+
startIcon: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pencil.default, {}),
|
|
112
|
+
children: "Edit Variables"
|
|
113
|
+
})
|
|
127
114
|
}),
|
|
128
115
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.AppBar, {
|
|
129
116
|
color: 'inherit',
|
|
@@ -141,7 +128,7 @@ function TemplateVariableList(props) {
|
|
|
141
128
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
|
|
142
129
|
direction: "row",
|
|
143
130
|
spacing: 1,
|
|
144
|
-
children:
|
|
131
|
+
children: variableDefinitions.map((v)=>{
|
|
145
132
|
var ref;
|
|
146
133
|
/*#__PURE__*/ return (0, _jsxRuntime.jsx)(_material.Box, {
|
|
147
134
|
display: ((ref = v.spec.display) === null || ref === void 0 ? void 0 : ref.hidden) ? 'none' : undefined,
|
|
@@ -23,7 +23,8 @@ function _export(target, all) {
|
|
|
23
23
|
_export(exports, {
|
|
24
24
|
filterVariableList: ()=>filterVariableList,
|
|
25
25
|
useListVariablePluginValues: ()=>useListVariablePluginValues,
|
|
26
|
-
getVariableValuesKey: ()=>getVariableValuesKey
|
|
26
|
+
getVariableValuesKey: ()=>getVariableValuesKey,
|
|
27
|
+
VARIABLE_TYPES: ()=>VARIABLE_TYPES
|
|
27
28
|
});
|
|
28
29
|
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
29
30
|
const _reactQuery = require("@tanstack/react-query");
|
|
@@ -104,3 +105,13 @@ function useListVariablePluginValues(definition) {
|
|
|
104
105
|
function getVariableValuesKey(v) {
|
|
105
106
|
return Object.values(v).map((v)=>JSON.stringify(v.value)).join(',');
|
|
106
107
|
}
|
|
108
|
+
const VARIABLE_TYPES = [
|
|
109
|
+
{
|
|
110
|
+
label: 'List',
|
|
111
|
+
kind: 'ListVariable'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: 'Text',
|
|
115
|
+
kind: 'TextVariable'
|
|
116
|
+
}
|
|
117
|
+
];
|
|
@@ -24,7 +24,7 @@ _exportStar(require("./Panel"), exports);
|
|
|
24
24
|
_exportStar(require("./PanelDrawer"), exports);
|
|
25
25
|
_exportStar(require("./PanelGroupDialog"), exports);
|
|
26
26
|
_exportStar(require("./TimeRangeControls"), exports);
|
|
27
|
-
_exportStar(require("./
|
|
27
|
+
_exportStar(require("./DiscardChangesConfirmationDialog"), exports);
|
|
28
28
|
_exportStar(require("./Variables"), exports);
|
|
29
29
|
function _exportStar(from, to) {
|
|
30
30
|
Object.keys(from).forEach(function(k) {
|
|
@@ -37,6 +37,7 @@ const _panelEditorSlice = require("./panel-editor-slice");
|
|
|
37
37
|
const _panelSlice = require("./panel-slice");
|
|
38
38
|
const _deletePanelGroupSlice = require("./delete-panel-group-slice");
|
|
39
39
|
const _deletePanelSlice = require("./delete-panel-slice");
|
|
40
|
+
const _discardChangesDialogSlice = require("./discard-changes-dialog-slice");
|
|
40
41
|
function _interopRequireDefault(obj) {
|
|
41
42
|
return obj && obj.__esModule ? obj : {
|
|
42
43
|
default: obj
|
|
@@ -72,6 +73,7 @@ function initStore(props) {
|
|
|
72
73
|
...(0, _deletePanelGroupSlice.createDeletePanelGroupSlice)(...args),
|
|
73
74
|
...(0, _panelEditorSlice.createPanelEditorSlice)()(...args),
|
|
74
75
|
...(0, _deletePanelSlice.createDeletePanelSlice)()(...args),
|
|
76
|
+
...(0, _discardChangesDialogSlice.createDiscardChangesDialogSlice)(...args),
|
|
75
77
|
metadata,
|
|
76
78
|
defaultTimeRange: {
|
|
77
79
|
pastDuration: duration
|