@perses-dev/dashboards 0.14.0 → 0.15.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 +7 -3
- package/dist/cjs/{css/styles.js → components/GridLayout/GridContainer.js} +66 -39
- package/dist/cjs/components/GridLayout/GridLayout.js +51 -64
- package/dist/cjs/components/GridLayout/GridTitle.js +3 -2
- package/dist/cjs/components/Panel/PanelHeader.js +6 -6
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +15 -54
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +25 -11
- package/dist/cjs/components/Variables/Variable.js +11 -4
- package/dist/cjs/components/Variables/VariableEditor.js +1 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -2
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
- package/dist/cjs/components/Variables/VariableList.js +76 -17
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -1
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +68 -39
- package/dist/cjs/context/{TimeRangeProvider.js → TimeRangeProvider/TimeRangeProvider.js} +4 -4
- package/dist/cjs/{utils → context/TimeRangeProvider}/index.js +2 -1
- package/dist/cjs/{utils/time-range-params.js → context/TimeRangeProvider/query-params.js} +11 -5
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/test/testDashboard.js +1 -1
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -1
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -7
- package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -0
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +7 -3
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/GridLayout/GridContainer.d.ts +6 -0
- package/dist/components/GridLayout/GridContainer.d.ts.map +1 -0
- package/dist/{css/styles.js → components/GridLayout/GridContainer.js} +65 -38
- package/dist/components/GridLayout/GridContainer.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.d.ts +1 -2
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +53 -66
- 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 +4 -3
- 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 +6 -6
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +19 -58
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +25 -11
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
- package/dist/components/Variables/Variable.js +11 -4
- 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 +1 -0
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -2
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +5 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +38 -18
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +2 -1
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +70 -41
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/{TimeRangeProvider.d.ts → TimeRangeProvider/TimeRangeProvider.d.ts} +2 -2
- package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -0
- package/dist/context/{TimeRangeProvider.js → TimeRangeProvider/TimeRangeProvider.js} +4 -4
- package/dist/context/TimeRangeProvider/TimeRangeProvider.js.map +1 -0
- package/dist/context/TimeRangeProvider/index.d.ts +3 -0
- package/dist/context/TimeRangeProvider/index.d.ts.map +1 -0
- package/dist/{utils → context/TimeRangeProvider}/index.js +2 -1
- package/dist/context/TimeRangeProvider/index.js.map +1 -0
- package/dist/{utils/time-range-params.d.ts → context/TimeRangeProvider/query-params.d.ts} +3 -3
- package/dist/context/TimeRangeProvider/query-params.d.ts.map +1 -0
- package/dist/{utils/time-range-params.js → context/TimeRangeProvider/query-params.js} +13 -7
- package/dist/context/TimeRangeProvider/query-params.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/test/testDashboard.js +1 -1
- package/dist/test/testDashboard.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 +2 -1
- 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 +6 -7
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js +1 -1
- package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
- package/package.json +4 -4
- package/dist/context/TimeRangeProvider.d.ts.map +0 -1
- package/dist/context/TimeRangeProvider.js.map +0 -1
- package/dist/css/styles.d.ts +0 -172
- package/dist/css/styles.d.ts.map +0 -1
- package/dist/css/styles.js.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/time-range-params.d.ts.map +0 -1
- package/dist/utils/time-range-params.js.map +0 -1
|
@@ -33,7 +33,7 @@ function _interopRequireDefault(obj) {
|
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
const DashboardToolbar = (props)=>{
|
|
36
|
-
const { dashboardName , dashboardTitleComponent , onEditButtonClick , onCancelButtonClick } = props;
|
|
36
|
+
const { dashboardName , dashboardTitleComponent , initialVariableIsSticky , onEditButtonClick , onCancelButtonClick } = props;
|
|
37
37
|
const { isEditMode , setEditMode } = (0, _context.useEditMode)();
|
|
38
38
|
const { openAddPanelGroup , openAddPanel } = (0, _context.useDashboardActions)();
|
|
39
39
|
const isLaptopSize = (0, _material.useMediaQuery)((0, _material.useTheme)().breakpoints.up('sm'));
|
|
@@ -89,7 +89,9 @@ const DashboardToolbar = (props)=>{
|
|
|
89
89
|
children: [
|
|
90
90
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
91
91
|
FallbackComponent: _components.ErrorAlert,
|
|
92
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {
|
|
92
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {
|
|
93
|
+
initialVariableIsSticky: initialVariableIsSticky
|
|
94
|
+
})
|
|
93
95
|
}),
|
|
94
96
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
95
97
|
direction: 'row',
|
|
@@ -150,7 +152,9 @@ const DashboardToolbar = (props)=>{
|
|
|
150
152
|
paddingY: 2,
|
|
151
153
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
152
154
|
FallbackComponent: _components.ErrorAlert,
|
|
153
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {
|
|
155
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {
|
|
156
|
+
initialVariableIsSticky: initialVariableIsSticky
|
|
157
|
+
})
|
|
154
158
|
})
|
|
155
159
|
})
|
|
156
160
|
]
|
|
@@ -14,40 +14,68 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
Object.defineProperty(exports, "
|
|
17
|
+
Object.defineProperty(exports, "GridContainer", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()=>
|
|
19
|
+
get: ()=>GridContainer
|
|
20
20
|
});
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
function GridContainer(props) {
|
|
25
|
+
const [isFirstRender, setIsFirstRender] = (0, _react.useState)(true);
|
|
26
|
+
(0, _react.useEffect)(()=>{
|
|
27
|
+
if (isFirstRender) {
|
|
28
|
+
setIsFirstRender(false);
|
|
29
|
+
}
|
|
30
|
+
}, [
|
|
31
|
+
isFirstRender
|
|
32
|
+
]);
|
|
33
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(ReactGridLayoutContainer, {
|
|
34
|
+
sx: {
|
|
35
|
+
// This adds spcing between grids (rows) in the overall dashboard
|
|
36
|
+
'& + &': {
|
|
37
|
+
marginTop: (theme)=>theme.spacing(1)
|
|
38
|
+
},
|
|
39
|
+
// This disables the animation of grid items when a grid is first rendered
|
|
40
|
+
// (see https://github.com/react-grid-layout/react-grid-layout/issues/103)
|
|
41
|
+
'& .react-grid-item.cssTransforms': {
|
|
42
|
+
transitionProperty: isFirstRender ? 'none' : 'transform'
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
children: props.children
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* These are the classes needed by react-grid-layout from their CSS stylesheet.
|
|
50
|
+
*/ const ReactGridLayoutContainer = (0, _material.styled)('section')(({ theme })=>({
|
|
51
|
+
'& .react-grid-layout': {
|
|
24
52
|
position: 'relative',
|
|
25
53
|
transition: 'height 200ms ease'
|
|
26
54
|
},
|
|
27
|
-
'
|
|
55
|
+
'& .react-grid-item': {
|
|
28
56
|
transition: 'all 200ms ease',
|
|
29
57
|
transitionProperty: 'left, top'
|
|
30
58
|
},
|
|
31
|
-
'
|
|
59
|
+
'& .react-grid-item img': {
|
|
32
60
|
pointerEvents: 'none',
|
|
33
61
|
userSelect: 'none'
|
|
34
62
|
},
|
|
35
|
-
'
|
|
63
|
+
'& .react-grid-item.cssTransforms': {
|
|
36
64
|
transitionProperty: 'transform'
|
|
37
65
|
},
|
|
38
|
-
'
|
|
66
|
+
'& .react-grid-item.resizing': {
|
|
39
67
|
zIndex: 1,
|
|
40
68
|
willChange: 'width, height'
|
|
41
69
|
},
|
|
42
|
-
'
|
|
70
|
+
'& .react-grid-item.react-draggable-dragging': {
|
|
43
71
|
transition: 'none',
|
|
44
72
|
zIndex: 3,
|
|
45
73
|
willChange: 'transform'
|
|
46
74
|
},
|
|
47
|
-
'
|
|
75
|
+
'& .react-grid-item.dropping': {
|
|
48
76
|
visibility: 'hidden'
|
|
49
77
|
},
|
|
50
|
-
'
|
|
78
|
+
'& .react-grid-item.react-grid-placeholder': {
|
|
51
79
|
background: theme.palette.primary.main,
|
|
52
80
|
opacity: 0.2,
|
|
53
81
|
transitionDuration: '100ms',
|
|
@@ -58,12 +86,12 @@ const styles = (theme)=>{
|
|
|
58
86
|
msUserSelect: 'none',
|
|
59
87
|
OUserSelect: 'none'
|
|
60
88
|
},
|
|
61
|
-
'
|
|
89
|
+
'& .react-grid-item > .react-resizable-handle': {
|
|
62
90
|
position: 'absolute',
|
|
63
91
|
width: '20px',
|
|
64
92
|
height: '20px'
|
|
65
93
|
},
|
|
66
|
-
'
|
|
94
|
+
'& .react-grid-item > .react-resizable-handle::after': {
|
|
67
95
|
content: '""',
|
|
68
96
|
position: 'absolute',
|
|
69
97
|
right: '3px',
|
|
@@ -73,62 +101,62 @@ const styles = (theme)=>{
|
|
|
73
101
|
borderRight: '2px solid rgba(0, 0, 0, 0.4)',
|
|
74
102
|
borderBottom: '2px solid rgba(0, 0, 0, 0.4)'
|
|
75
103
|
},
|
|
76
|
-
'
|
|
104
|
+
'& .react-resizable-hide > .react-resizable-handle': {
|
|
77
105
|
display: 'none'
|
|
78
106
|
},
|
|
79
|
-
'
|
|
107
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-sw': {
|
|
80
108
|
bottom: '0',
|
|
81
109
|
left: '0',
|
|
82
110
|
cursor: 'sw-resize',
|
|
83
111
|
transform: 'rotate(90deg)'
|
|
84
112
|
},
|
|
85
|
-
'
|
|
113
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-se': {
|
|
86
114
|
bottom: '0',
|
|
87
115
|
right: '0',
|
|
88
116
|
cursor: 'se-resize'
|
|
89
117
|
},
|
|
90
|
-
'
|
|
118
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-nw': {
|
|
91
119
|
top: '0',
|
|
92
120
|
left: '0',
|
|
93
121
|
cursor: 'nw-resize',
|
|
94
122
|
transform: 'rotate(180deg)'
|
|
95
123
|
},
|
|
96
|
-
'
|
|
124
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-ne': {
|
|
97
125
|
top: '0',
|
|
98
126
|
right: '0',
|
|
99
127
|
cursor: 'ne-resize',
|
|
100
128
|
transform: 'rotate(270deg)'
|
|
101
129
|
},
|
|
102
|
-
'
|
|
130
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-w, &.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
|
|
103
131
|
top: '50%',
|
|
104
132
|
marginTop: '-10px',
|
|
105
133
|
cursor: 'ew-resize'
|
|
106
134
|
},
|
|
107
|
-
'
|
|
135
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-w': {
|
|
108
136
|
left: '0',
|
|
109
137
|
transform: 'rotate(135deg)'
|
|
110
138
|
},
|
|
111
|
-
'
|
|
139
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
|
|
112
140
|
right: '0',
|
|
113
141
|
transform: 'rotate(315deg)'
|
|
114
142
|
},
|
|
115
|
-
'
|
|
143
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-n, &.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
|
|
116
144
|
left: '50%',
|
|
117
145
|
marginLeft: '-10px',
|
|
118
146
|
cursor: 'ns-resize'
|
|
119
147
|
},
|
|
120
|
-
'
|
|
148
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-n': {
|
|
121
149
|
top: '0',
|
|
122
150
|
transform: 'rotate(225deg)'
|
|
123
151
|
},
|
|
124
|
-
'
|
|
152
|
+
'& .react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
|
|
125
153
|
bottom: '0',
|
|
126
154
|
transform: 'rotate(45deg)'
|
|
127
155
|
},
|
|
128
|
-
'
|
|
156
|
+
'& .react-resizable': {
|
|
129
157
|
position: 'relative'
|
|
130
158
|
},
|
|
131
|
-
'
|
|
159
|
+
'& .react-resizable-handle': {
|
|
132
160
|
position: 'absolute',
|
|
133
161
|
width: '20px',
|
|
134
162
|
height: '20px',
|
|
@@ -139,54 +167,53 @@ const styles = (theme)=>{
|
|
|
139
167
|
backgroundPosition: 'bottom right',
|
|
140
168
|
padding: '0 3px 3px 0'
|
|
141
169
|
},
|
|
142
|
-
'
|
|
170
|
+
'& .react-resizable-handle-sw': {
|
|
143
171
|
bottom: '0',
|
|
144
172
|
left: '0',
|
|
145
173
|
cursor: 'sw-resize',
|
|
146
174
|
transform: 'rotate(90deg)'
|
|
147
175
|
},
|
|
148
|
-
'
|
|
176
|
+
'& .react-resizable-handle-se': {
|
|
149
177
|
bottom: '0',
|
|
150
178
|
right: '0',
|
|
151
179
|
cursor: 'se-resize'
|
|
152
180
|
},
|
|
153
|
-
'
|
|
181
|
+
'& .react-resizable-handle-nw': {
|
|
154
182
|
top: '0',
|
|
155
183
|
left: '0',
|
|
156
184
|
cursor: 'nw-resize',
|
|
157
185
|
transform: 'rotate(180deg)'
|
|
158
186
|
},
|
|
159
|
-
'
|
|
187
|
+
'& .react-resizable-handle-ne': {
|
|
160
188
|
top: '0',
|
|
161
189
|
right: '0',
|
|
162
190
|
cursor: 'ne-resize',
|
|
163
191
|
transform: 'rotate(270deg)'
|
|
164
192
|
},
|
|
165
|
-
'
|
|
193
|
+
'& .react-resizable-handle-w, .react-resizable-handle-e': {
|
|
166
194
|
top: '50%',
|
|
167
195
|
marginTop: '-10px',
|
|
168
196
|
cursor: 'ew-resize'
|
|
169
197
|
},
|
|
170
|
-
'
|
|
198
|
+
'& .react-resizable-handle-w': {
|
|
171
199
|
left: '0',
|
|
172
200
|
transform: 'rotate(135deg)'
|
|
173
201
|
},
|
|
174
|
-
'
|
|
202
|
+
'& .react-resizable-handle-e': {
|
|
175
203
|
right: '0',
|
|
176
204
|
transform: 'rotate(315deg)'
|
|
177
205
|
},
|
|
178
|
-
'
|
|
206
|
+
'& .react-resizable-handle-n, .react-resizable-handle-s': {
|
|
179
207
|
left: '50%',
|
|
180
208
|
marginLeft: '-10px',
|
|
181
209
|
cursor: 'ns-resize'
|
|
182
210
|
},
|
|
183
|
-
'
|
|
211
|
+
'& .react-resizable-handle-n': {
|
|
184
212
|
top: '0',
|
|
185
213
|
transform: 'rotate(225deg)'
|
|
186
214
|
},
|
|
187
|
-
'
|
|
215
|
+
'& .react-resizable-handle-s': {
|
|
188
216
|
bottom: '0',
|
|
189
217
|
transform: 'rotate(45deg)'
|
|
190
218
|
}
|
|
191
|
-
};
|
|
192
|
-
};
|
|
219
|
+
}));
|
|
@@ -23,83 +23,70 @@ const _react = require("react");
|
|
|
23
23
|
const _reactGridLayout = require("react-grid-layout");
|
|
24
24
|
const _material = require("@mui/material");
|
|
25
25
|
const _components = require("@perses-dev/components");
|
|
26
|
-
const _styles = require("../../css/styles");
|
|
27
26
|
const _context = require("../../context");
|
|
28
27
|
const _gridTitle = require("./GridTitle");
|
|
29
28
|
const _gridItemContent = require("./GridItemContent");
|
|
29
|
+
const _gridContainer = require("./GridContainer");
|
|
30
30
|
const ResponsiveGridLayout = (0, _reactGridLayout.WidthProvider)(_reactGridLayout.Responsive);
|
|
31
31
|
function GridLayout(props) {
|
|
32
|
-
const { panelGroupId
|
|
32
|
+
const { panelGroupId /*...others */ } = props;
|
|
33
33
|
const theme = (0, _material.useTheme)();
|
|
34
34
|
const groupDefinition = (0, _context.usePanelGroup)(panelGroupId);
|
|
35
35
|
const { updatePanelGroupLayouts } = (0, _context.usePanelGroupActions)(panelGroupId);
|
|
36
36
|
var ref;
|
|
37
37
|
const [isOpen, setIsOpen] = (0, _react.useState)((ref = !groupDefinition.isCollapsed) !== null && ref !== void 0 ? ref : true);
|
|
38
38
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
39
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(
|
|
39
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_gridContainer.GridContainer, {
|
|
40
40
|
children: [
|
|
41
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(
|
|
42
|
-
|
|
41
|
+
groupDefinition.title !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridTitle.GridTitle, {
|
|
42
|
+
panelGroupId: panelGroupId,
|
|
43
|
+
title: groupDefinition.title,
|
|
44
|
+
collapse: groupDefinition.isCollapsed === undefined ? undefined : {
|
|
45
|
+
isOpen,
|
|
46
|
+
onToggleOpen: ()=>setIsOpen((current)=>!current)
|
|
47
|
+
}
|
|
43
48
|
}),
|
|
44
|
-
/*#__PURE__*/ (0, _jsxRuntime.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
layouts: {
|
|
86
|
-
sm: groupDefinition.itemLayouts
|
|
87
|
-
},
|
|
88
|
-
onLayoutChange: updatePanelGroupLayouts,
|
|
89
|
-
children: groupDefinition.itemLayouts.map(({ i })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
90
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
91
|
-
FallbackComponent: _components.ErrorAlert,
|
|
92
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridItemContent.GridItemContent, {
|
|
93
|
-
panelGroupItemId: {
|
|
94
|
-
panelGroupId,
|
|
95
|
-
panelGroupItemLayoutId: i
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
})
|
|
99
|
-
}, i))
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
]
|
|
49
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Collapse, {
|
|
50
|
+
in: isOpen,
|
|
51
|
+
unmountOnExit: true,
|
|
52
|
+
appear: false,
|
|
53
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(ResponsiveGridLayout, {
|
|
54
|
+
className: "layout",
|
|
55
|
+
breakpoints: {
|
|
56
|
+
sm: theme.breakpoints.values.sm,
|
|
57
|
+
xxs: 0
|
|
58
|
+
},
|
|
59
|
+
cols: {
|
|
60
|
+
sm: 24,
|
|
61
|
+
xxs: 2
|
|
62
|
+
},
|
|
63
|
+
rowHeight: 30,
|
|
64
|
+
draggableHandle: '.drag-handle',
|
|
65
|
+
resizeHandles: [
|
|
66
|
+
'se'
|
|
67
|
+
],
|
|
68
|
+
isDraggable: isEditMode,
|
|
69
|
+
isResizable: isEditMode,
|
|
70
|
+
containerPadding: [
|
|
71
|
+
0,
|
|
72
|
+
10
|
|
73
|
+
],
|
|
74
|
+
layouts: {
|
|
75
|
+
sm: groupDefinition.itemLayouts
|
|
76
|
+
},
|
|
77
|
+
onLayoutChange: updatePanelGroupLayouts,
|
|
78
|
+
children: groupDefinition.itemLayouts.map(({ i })=>/*#__PURE__*/ (0, _jsxRuntime.jsx)("div", {
|
|
79
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
|
|
80
|
+
FallbackComponent: _components.ErrorAlert,
|
|
81
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridItemContent.GridItemContent, {
|
|
82
|
+
panelGroupItemId: {
|
|
83
|
+
panelGroupId,
|
|
84
|
+
panelGroupItemLayoutId: i
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
}, i))
|
|
89
|
+
})
|
|
103
90
|
})
|
|
104
91
|
]
|
|
105
92
|
});
|
|
@@ -37,7 +37,8 @@ function _interopRequireDefault(obj) {
|
|
|
37
37
|
function GridTitle(props) {
|
|
38
38
|
const { panelGroupId , title , collapse } = props;
|
|
39
39
|
const [isHovered, setIsHovered] = (0, _react.useState)(false);
|
|
40
|
-
const { openAddPanel , openEditPanelGroup ,
|
|
40
|
+
const { openAddPanel , openEditPanelGroup , moveUp , moveDown } = (0, _context.usePanelGroupActions)(panelGroupId);
|
|
41
|
+
const { openDeletePanelGroupDialog } = (0, _context.useDeletePanelGroupDialog)();
|
|
41
42
|
const { isEditMode } = (0, _context.useEditMode)();
|
|
42
43
|
const text = /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
43
44
|
variant: "h2",
|
|
@@ -81,7 +82,7 @@ function GridTitle(props) {
|
|
|
81
82
|
}),
|
|
82
83
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
83
84
|
"aria-label": "delete group",
|
|
84
|
-
onClick:
|
|
85
|
+
onClick: ()=>openDeletePanelGroupDialog(panelGroupId),
|
|
85
86
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_deleteOutline.default, {})
|
|
86
87
|
}),
|
|
87
88
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
@@ -95,17 +95,17 @@ function PanelHeader({ id , title , description , editHandlers , isHovered , sx
|
|
|
95
95
|
title: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
96
96
|
id: titleElementId,
|
|
97
97
|
variant: "subtitle1",
|
|
98
|
-
sx: {
|
|
99
|
-
whiteSpace: 'nowrap',
|
|
100
|
-
overflow: 'hidden',
|
|
101
|
-
textOverflow: 'ellipsis'
|
|
102
|
-
},
|
|
103
98
|
children: title
|
|
104
99
|
}),
|
|
105
100
|
action: action,
|
|
106
101
|
sx: (0, _components.combineSx)((theme)=>({
|
|
107
102
|
padding: theme.spacing(1),
|
|
108
|
-
borderBottom: `solid 1px ${theme.palette.divider}
|
|
103
|
+
borderBottom: `solid 1px ${theme.palette.divider}`,
|
|
104
|
+
'.MuiCardHeader-content': {
|
|
105
|
+
whiteSpace: 'nowrap',
|
|
106
|
+
overflow: 'hidden',
|
|
107
|
+
textOverflow: 'ellipsis'
|
|
108
|
+
}
|
|
109
109
|
}), sx),
|
|
110
110
|
...rest
|
|
111
111
|
});
|
|
@@ -25,8 +25,6 @@ _export(exports, {
|
|
|
25
25
|
TimeRangeControls: ()=>TimeRangeControls
|
|
26
26
|
});
|
|
27
27
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
-
const _react = require("react");
|
|
29
|
-
const _material = require("@mui/material");
|
|
30
28
|
const _components = require("@perses-dev/components");
|
|
31
29
|
const _core = require("@perses-dev/core");
|
|
32
30
|
const _context = require("../../context");
|
|
@@ -88,58 +86,21 @@ const TIME_OPTIONS = [
|
|
|
88
86
|
];
|
|
89
87
|
function TimeRangeControls() {
|
|
90
88
|
const { timeRange , setTimeRange } = (0, _context.useDashboardTimeRange)();
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
99
|
-
direction: "row",
|
|
100
|
-
spacing: 1,
|
|
101
|
-
children: [
|
|
102
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Popover, {
|
|
103
|
-
anchorEl: anchorEl.current,
|
|
104
|
-
anchorOrigin: {
|
|
105
|
-
vertical: 'bottom',
|
|
106
|
-
horizontal: 'center'
|
|
89
|
+
const defaultTimeRange = (0, _context.useDefaultTimeRange)();
|
|
90
|
+
// add time shortcut if one does not match duration from dashboard JSON
|
|
91
|
+
if (!TIME_OPTIONS.some((option)=>option.value.pastDuration === defaultTimeRange.pastDuration)) {
|
|
92
|
+
if ((0, _core.isDurationString)(defaultTimeRange.pastDuration)) {
|
|
93
|
+
TIME_OPTIONS.push({
|
|
94
|
+
value: {
|
|
95
|
+
pastDuration: defaultTimeRange.pastDuration
|
|
107
96
|
},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
setTimeRange(timeRange);
|
|
117
|
-
setShowCustomDateSelector(false);
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
}),
|
|
121
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
|
|
122
|
-
fullWidth: true,
|
|
123
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
124
|
-
ref: anchorEl,
|
|
125
|
-
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.TimeRangeSelector, {
|
|
126
|
-
timeOptions: TIME_OPTIONS,
|
|
127
|
-
value: timeRange,
|
|
128
|
-
onSelectChange: (event)=>{
|
|
129
|
-
const duration = event.target.value;
|
|
130
|
-
const relativeTimeInput = {
|
|
131
|
-
pastDuration: duration,
|
|
132
|
-
end: new Date()
|
|
133
|
-
};
|
|
134
|
-
setTimeRange(relativeTimeInput);
|
|
135
|
-
setShowCustomDateSelector(false);
|
|
136
|
-
},
|
|
137
|
-
onCustomClick: ()=>{
|
|
138
|
-
setShowCustomDateSelector(true);
|
|
139
|
-
}
|
|
140
|
-
})
|
|
141
|
-
})
|
|
142
|
-
})
|
|
143
|
-
]
|
|
97
|
+
display: `Last ${defaultTimeRange.pastDuration}`
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.DateTimeRangePicker, {
|
|
102
|
+
timeOptions: TIME_OPTIONS,
|
|
103
|
+
value: timeRange,
|
|
104
|
+
onChange: setTimeRange
|
|
144
105
|
});
|
|
145
106
|
}
|
|
@@ -45,29 +45,43 @@ describe('TimeRangeControls', ()=>{
|
|
|
45
45
|
dashboardResource: _testDashboard.default
|
|
46
46
|
};
|
|
47
47
|
});
|
|
48
|
-
const renderTimeRangeControls = ()=>{
|
|
48
|
+
const renderTimeRangeControls = (testURLParams)=>{
|
|
49
49
|
(0, _test.renderWithContext)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.DashboardProvider, {
|
|
50
50
|
initialState: initialState,
|
|
51
51
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_context.TimeRangeProvider, {
|
|
52
|
-
|
|
52
|
+
initialTimeRange: testDefaultTimeRange,
|
|
53
|
+
enabledURLParams: testURLParams,
|
|
53
54
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeControls.TimeRangeControls, {})
|
|
54
55
|
})
|
|
55
56
|
}), undefined, history);
|
|
56
57
|
};
|
|
57
|
-
it('should
|
|
58
|
-
renderTimeRangeControls();
|
|
59
|
-
expect(_react.screen.getByText('Last
|
|
60
|
-
});
|
|
61
|
-
// TODO: fix setTimeRange no-op, test query params
|
|
62
|
-
it('should be able to select the first option', ()=>{
|
|
63
|
-
renderTimeRangeControls();
|
|
58
|
+
it('should default to dashboard duration and update selected time option when clicked', async ()=>{
|
|
59
|
+
renderTimeRangeControls(false);
|
|
60
|
+
expect(_react.screen.getByText('Last 30 minutes')).toBeInTheDocument();
|
|
64
61
|
const dateButton = _react.screen.getByRole('button');
|
|
65
62
|
_userEvent.default.click(dateButton);
|
|
66
|
-
const
|
|
63
|
+
const firstSelected = _react.screen.getByRole('option', {
|
|
67
64
|
name: 'Last 5 minutes'
|
|
68
65
|
});
|
|
69
|
-
_userEvent.default.click(
|
|
66
|
+
_userEvent.default.click(firstSelected);
|
|
70
67
|
expect(dateButton).toHaveTextContent(/5 minutes/i);
|
|
71
68
|
});
|
|
69
|
+
it('should update URL params with correct time range values', ()=>{
|
|
70
|
+
renderTimeRangeControls(true);
|
|
71
|
+
const dateButton = _react.screen.getByRole('button');
|
|
72
|
+
_userEvent.default.click(dateButton);
|
|
73
|
+
const firstSelected = _react.screen.getByRole('option', {
|
|
74
|
+
name: 'Last 5 minutes'
|
|
75
|
+
});
|
|
76
|
+
_userEvent.default.click(firstSelected);
|
|
77
|
+
expect(history.location.search).toEqual('?start=5m');
|
|
78
|
+
// pick another option from TimeRangeSelector dropdown
|
|
79
|
+
const secondSelected = _react.screen.getByText('Last 12 hours');
|
|
80
|
+
_userEvent.default.click(secondSelected);
|
|
81
|
+
expect(history.location.search).toEqual('?start=12h');
|
|
82
|
+
// back button should return to first option selected
|
|
83
|
+
history.back();
|
|
84
|
+
expect(history.location.search).toEqual('?start=5m');
|
|
85
|
+
});
|
|
72
86
|
// TODO: add additional tests for absolute time selection, other inputs, form validation, etc.
|
|
73
87
|
});
|
|
@@ -57,16 +57,24 @@ function ListVariable({ name }) {
|
|
|
57
57
|
const { data: variablePlugin } = (0, _pluginSystem.usePlugin)('Variable', definition.spec.plugin.kind);
|
|
58
58
|
const { setVariableValue , setVariableLoading , setVariableOptions } = (0, _context.useTemplateVariableActions)();
|
|
59
59
|
const datasourceStore = (0, _pluginSystem.useDatasourceStore)();
|
|
60
|
+
const allVariables = (0, _pluginSystem.useTemplateVariableValues)();
|
|
61
|
+
const { timeRange } = (0, _pluginSystem.useTimeRange)();
|
|
62
|
+
const variablePluginCtx = {
|
|
63
|
+
timeRange,
|
|
64
|
+
datasourceStore,
|
|
65
|
+
variables: allVariables
|
|
66
|
+
};
|
|
60
67
|
const spec = definition.spec.plugin.spec;
|
|
61
68
|
let dependsOnVariables;
|
|
62
69
|
if (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.dependsOn) {
|
|
63
|
-
|
|
70
|
+
const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
|
|
71
|
+
dependsOnVariables = dependencies.variables;
|
|
64
72
|
}
|
|
65
73
|
const variables = (0, _pluginSystem.useTemplateVariableValues)(dependsOnVariables);
|
|
66
74
|
const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_multiple) === true;
|
|
67
75
|
const allowAllValue = (definition === null || definition === void 0 ? void 0 : definition.spec.allow_all_value) === true;
|
|
68
76
|
var ref4;
|
|
69
|
-
const
|
|
77
|
+
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;
|
|
70
78
|
let waitToLoad = false;
|
|
71
79
|
if (dependsOnVariables) {
|
|
72
80
|
waitToLoad = dependsOnVariables.some((v)=>{
|
|
@@ -75,7 +83,6 @@ function ListVariable({ name }) {
|
|
|
75
83
|
});
|
|
76
84
|
}
|
|
77
85
|
const variablesValueKey = getVariableValuesKey(variables);
|
|
78
|
-
const { timeRange } = (0, _pluginSystem.useTimeRange)();
|
|
79
86
|
const variablesOptionsQuery = (0, _reactQuery.useQuery)([
|
|
80
87
|
name,
|
|
81
88
|
definition,
|
|
@@ -165,7 +172,7 @@ function ListVariable({ name }) {
|
|
|
165
172
|
children: [
|
|
166
173
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.InputLabel, {
|
|
167
174
|
id: name,
|
|
168
|
-
children:
|
|
175
|
+
children: title
|
|
169
176
|
}),
|
|
170
177
|
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Select, {
|
|
171
178
|
sx: {
|