@perses-dev/dashboards 0.13.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.
Files changed (124) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +13 -14
  2. package/dist/cjs/{css/styles.js → components/GridLayout/GridContainer.js} +66 -39
  3. package/dist/cjs/components/GridLayout/GridLayout.js +51 -64
  4. package/dist/cjs/components/GridLayout/GridTitle.js +3 -2
  5. package/dist/cjs/components/Panel/PanelHeader.js +6 -6
  6. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -2
  7. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +7 -5
  8. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +15 -54
  9. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +25 -11
  10. package/dist/cjs/components/Variables/Variable.js +11 -4
  11. package/dist/cjs/components/Variables/VariableEditor.js +1 -0
  12. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -2
  13. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
  14. package/dist/cjs/components/Variables/VariableList.js +76 -17
  15. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -1
  16. package/dist/cjs/context/DashboardProvider/common.js +3 -3
  17. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +68 -39
  18. package/dist/cjs/context/{TimeRangeProvider.js → TimeRangeProvider/TimeRangeProvider.js} +4 -4
  19. package/dist/cjs/{utils → context/TimeRangeProvider}/index.js +2 -1
  20. package/dist/cjs/{utils/time-range-params.js → context/TimeRangeProvider/query-params.js} +11 -5
  21. package/dist/cjs/index.js +0 -1
  22. package/dist/cjs/test/render.js +0 -1
  23. package/dist/cjs/test/testDashboard.js +1 -1
  24. package/dist/cjs/utils/component-ids.js +3 -3
  25. package/dist/cjs/views/ViewDashboard/DashboardApp.js +3 -1
  26. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +7 -7
  27. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +1 -1
  28. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
  29. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  30. package/dist/components/DashboardToolbar/DashboardToolbar.js +13 -14
  31. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  32. package/dist/components/GridLayout/GridContainer.d.ts +6 -0
  33. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -0
  34. package/dist/{css/styles.js → components/GridLayout/GridContainer.js} +65 -38
  35. package/dist/components/GridLayout/GridContainer.js.map +1 -0
  36. package/dist/components/GridLayout/GridLayout.d.ts +1 -2
  37. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  38. package/dist/components/GridLayout/GridLayout.js +53 -66
  39. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  40. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  41. package/dist/components/GridLayout/GridTitle.js +4 -3
  42. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  43. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  44. package/dist/components/Panel/PanelHeader.js +6 -6
  45. package/dist/components/Panel/PanelHeader.js.map +1 -1
  46. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  47. package/dist/components/PanelDrawer/PanelDrawer.js +1 -2
  48. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  49. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  50. package/dist/components/PanelDrawer/PanelEditorForm.js +8 -6
  51. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  52. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  53. package/dist/components/TimeRangeControls/TimeRangeControls.js +19 -58
  54. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  55. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +25 -11
  56. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  57. package/dist/components/Variables/Variable.js +11 -4
  58. package/dist/components/Variables/Variable.js.map +1 -1
  59. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  60. package/dist/components/Variables/VariableEditor.js +1 -0
  61. package/dist/components/Variables/VariableEditor.js.map +1 -1
  62. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +2 -2
  63. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  64. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -1
  65. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  66. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +3 -3
  67. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  68. package/dist/components/Variables/VariableList.d.ts +5 -1
  69. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  70. package/dist/components/Variables/VariableList.js +38 -18
  71. package/dist/components/Variables/VariableList.js.map +1 -1
  72. package/dist/context/DashboardProvider/DashboardProvider.js +2 -1
  73. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  74. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  75. package/dist/context/DashboardProvider/common.js +4 -4
  76. package/dist/context/DashboardProvider/common.js.map +1 -1
  77. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -1
  78. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  79. package/dist/context/DashboardProvider/dashboard-provider-api.js +70 -41
  80. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  81. package/dist/context/{TimeRangeProvider.d.ts → TimeRangeProvider/TimeRangeProvider.d.ts} +2 -2
  82. package/dist/context/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -0
  83. package/dist/context/{TimeRangeProvider.js → TimeRangeProvider/TimeRangeProvider.js} +4 -4
  84. package/dist/context/TimeRangeProvider/TimeRangeProvider.js.map +1 -0
  85. package/dist/context/TimeRangeProvider/index.d.ts +3 -0
  86. package/dist/context/TimeRangeProvider/index.d.ts.map +1 -0
  87. package/dist/{utils → context/TimeRangeProvider}/index.js +2 -1
  88. package/dist/context/TimeRangeProvider/index.js.map +1 -0
  89. package/dist/{utils/time-range-params.d.ts → context/TimeRangeProvider/query-params.d.ts} +3 -3
  90. package/dist/context/TimeRangeProvider/query-params.d.ts.map +1 -0
  91. package/dist/{utils/time-range-params.js → context/TimeRangeProvider/query-params.js} +13 -7
  92. package/dist/context/TimeRangeProvider/query-params.js.map +1 -0
  93. package/dist/index.d.ts +0 -1
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +0 -1
  96. package/dist/index.js.map +1 -1
  97. package/dist/test/render.js +0 -1
  98. package/dist/test/render.js.map +1 -1
  99. package/dist/test/testDashboard.js +1 -1
  100. package/dist/test/testDashboard.js.map +1 -1
  101. package/dist/utils/component-ids.d.ts.map +1 -1
  102. package/dist/utils/component-ids.js +3 -3
  103. package/dist/utils/component-ids.js.map +1 -1
  104. package/dist/views/ViewDashboard/DashboardApp.d.ts +2 -0
  105. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  106. package/dist/views/ViewDashboard/DashboardApp.js +3 -1
  107. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  108. package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -0
  109. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  110. package/dist/views/ViewDashboard/ViewDashboard.js +7 -7
  111. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  112. package/dist/views/ViewDashboard/tests/panelGroups.test.js +1 -1
  113. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  114. package/package.json +5 -4
  115. package/dist/context/TimeRangeProvider.d.ts.map +0 -1
  116. package/dist/context/TimeRangeProvider.js.map +0 -1
  117. package/dist/css/styles.d.ts +0 -172
  118. package/dist/css/styles.d.ts.map +0 -1
  119. package/dist/css/styles.js.map +0 -1
  120. package/dist/utils/index.d.ts +0 -2
  121. package/dist/utils/index.d.ts.map +0 -1
  122. package/dist/utils/index.js.map +0 -1
  123. package/dist/utils/time-range-params.d.ts.map +0 -1
  124. package/dist/utils/time-range-params.js.map +0 -1
@@ -33,10 +33,14 @@ function _interopRequireDefault(obj) {
33
33
  };
34
34
  }
35
35
  const DashboardToolbar = (props)=>{
36
- const { dashboardName , 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'));
40
+ const dashboardTitle = dashboardTitleComponent ? dashboardTitleComponent : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
41
+ variant: "h2",
42
+ children: dashboardName
43
+ });
40
44
  const onSave = ()=>{
41
45
  setEditMode(false);
42
46
  };
@@ -52,13 +56,7 @@ const DashboardToolbar = (props)=>{
52
56
  padding: 2,
53
57
  display: "flex",
54
58
  children: [
55
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
56
- variant: "h2",
57
- children: [
58
- "Edit ",
59
- dashboardName
60
- ]
61
- }),
59
+ dashboardTitle,
62
60
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
63
61
  direction: "row",
64
62
  spacing: 1,
@@ -91,7 +89,9 @@ const DashboardToolbar = (props)=>{
91
89
  children: [
92
90
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
93
91
  FallbackComponent: _components.ErrorAlert,
94
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {})
92
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {
93
+ initialVariableIsSticky: initialVariableIsSticky
94
+ })
95
95
  }),
96
96
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
97
97
  direction: 'row',
@@ -126,10 +126,7 @@ const DashboardToolbar = (props)=>{
126
126
  width: '100%'
127
127
  },
128
128
  children: [
129
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
130
- variant: "h2",
131
- children: dashboardName
132
- }),
129
+ dashboardTitle,
133
130
  /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
134
131
  direction: "row",
135
132
  spacing: 2,
@@ -155,7 +152,9 @@ const DashboardToolbar = (props)=>{
155
152
  paddingY: 2,
156
153
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.ErrorBoundary, {
157
154
  FallbackComponent: _components.ErrorAlert,
158
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {})
155
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variables.TemplateVariableList, {
156
+ initialVariableIsSticky: initialVariableIsSticky
157
+ })
159
158
  })
160
159
  })
161
160
  ]
@@ -14,40 +14,68 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "styles", {
17
+ Object.defineProperty(exports, "GridContainer", {
18
18
  enumerable: true,
19
- get: ()=>styles
19
+ get: ()=>GridContainer
20
20
  });
21
- const styles = (theme)=>{
22
- return {
23
- '&.react-grid-layout': {
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
- '&.react-grid-item': {
55
+ '& .react-grid-item': {
28
56
  transition: 'all 200ms ease',
29
57
  transitionProperty: 'left, top'
30
58
  },
31
- '&.react-grid-item img': {
59
+ '& .react-grid-item img': {
32
60
  pointerEvents: 'none',
33
61
  userSelect: 'none'
34
62
  },
35
- '&.react-grid-item.cssTransforms': {
63
+ '& .react-grid-item.cssTransforms': {
36
64
  transitionProperty: 'transform'
37
65
  },
38
- '&.react-grid-item.resizing': {
66
+ '& .react-grid-item.resizing': {
39
67
  zIndex: 1,
40
68
  willChange: 'width, height'
41
69
  },
42
- '&.react-grid-item.react-draggable-dragging': {
70
+ '& .react-grid-item.react-draggable-dragging': {
43
71
  transition: 'none',
44
72
  zIndex: 3,
45
73
  willChange: 'transform'
46
74
  },
47
- '&.react-grid-item.dropping': {
75
+ '& .react-grid-item.dropping': {
48
76
  visibility: 'hidden'
49
77
  },
50
- '&.react-grid-item.react-grid-placeholder': {
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
- '&.react-grid-item > .react-resizable-handle': {
89
+ '& .react-grid-item > .react-resizable-handle': {
62
90
  position: 'absolute',
63
91
  width: '20px',
64
92
  height: '20px'
65
93
  },
66
- '&.react-grid-item > .react-resizable-handle::after': {
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
- '&.react-resizable-hide > .react-resizable-handle': {
104
+ '& .react-resizable-hide > .react-resizable-handle': {
77
105
  display: 'none'
78
106
  },
79
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-sw': {
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
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-se': {
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
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-nw': {
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
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-ne': {
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
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w, &.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
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
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w': {
135
+ '& .react-grid-item > .react-resizable-handle.react-resizable-handle-w': {
108
136
  left: '0',
109
137
  transform: 'rotate(135deg)'
110
138
  },
111
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
139
+ '& .react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
112
140
  right: '0',
113
141
  transform: 'rotate(315deg)'
114
142
  },
115
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n, &.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
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
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n': {
148
+ '& .react-grid-item > .react-resizable-handle.react-resizable-handle-n': {
121
149
  top: '0',
122
150
  transform: 'rotate(225deg)'
123
151
  },
124
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
152
+ '& .react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
125
153
  bottom: '0',
126
154
  transform: 'rotate(45deg)'
127
155
  },
128
- '&.react-resizable': {
156
+ '& .react-resizable': {
129
157
  position: 'relative'
130
158
  },
131
- '&.react-resizable-handle': {
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
- '&.react-resizable-handle-sw': {
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
- '&.react-resizable-handle-se': {
176
+ '& .react-resizable-handle-se': {
149
177
  bottom: '0',
150
178
  right: '0',
151
179
  cursor: 'se-resize'
152
180
  },
153
- '&.react-resizable-handle-nw': {
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
- '&.react-resizable-handle-ne': {
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
- '&.react-resizable-handle-w, .react-resizable-handle-e': {
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
- '&.react-resizable-handle-w': {
198
+ '& .react-resizable-handle-w': {
171
199
  left: '0',
172
200
  transform: 'rotate(135deg)'
173
201
  },
174
- '&.react-resizable-handle-e': {
202
+ '& .react-resizable-handle-e': {
175
203
  right: '0',
176
204
  transform: 'rotate(315deg)'
177
205
  },
178
- '&.react-resizable-handle-n, .react-resizable-handle-s': {
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
- '&.react-resizable-handle-n': {
211
+ '& .react-resizable-handle-n': {
184
212
  top: '0',
185
213
  transform: 'rotate(225deg)'
186
214
  },
187
- '&.react-resizable-handle-s': {
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 , ...others } = props;
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)(_jsxRuntime.Fragment, {
39
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_gridContainer.GridContainer, {
40
40
  children: [
41
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.GlobalStyles, {
42
- styles: _styles.styles
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.jsxs)(_material.Box, {
45
- ...others,
46
- component: "section",
47
- sx: {
48
- '& + &': {
49
- marginTop: (theme)=>theme.spacing(1)
50
- }
51
- },
52
- children: [
53
- groupDefinition.title !== undefined && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_gridTitle.GridTitle, {
54
- panelGroupId: panelGroupId,
55
- title: groupDefinition.title,
56
- collapse: groupDefinition.isCollapsed === undefined ? undefined : {
57
- isOpen,
58
- onToggleOpen: ()=>setIsOpen((current)=>!current)
59
- }
60
- }),
61
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Collapse, {
62
- in: isOpen,
63
- unmountOnExit: true,
64
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(ResponsiveGridLayout, {
65
- className: "layout",
66
- breakpoints: {
67
- sm: theme.breakpoints.values.sm,
68
- xxs: 0
69
- },
70
- cols: {
71
- sm: 24,
72
- xxs: 2
73
- },
74
- rowHeight: 30,
75
- draggableHandle: '.drag-handle',
76
- resizeHandles: [
77
- 'se'
78
- ],
79
- isDraggable: isEditMode,
80
- isResizable: isEditMode,
81
- containerPadding: [
82
- 0,
83
- 10
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 , deletePanelGroup , moveUp , moveDown } = (0, _context.usePanelGroupActions)(panelGroupId);
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: deletePanelGroup,
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
  });
@@ -56,8 +56,7 @@ const PanelDrawer = ()=>{
56
56
  sx: {
57
57
  display: 'flex',
58
58
  alignItems: 'center',
59
- marginBottom: (theme)=>theme.spacing(2),
60
- paddingBottom: (theme)=>theme.spacing(2),
59
+ padding: (theme)=>theme.spacing(1, 2),
61
60
  borderBottom: (theme)=>`1px solid ${theme.palette.grey[100]}`
62
61
  },
63
62
  children: [
@@ -73,16 +73,18 @@ function PanelEditorForm(props) {
73
73
  };
74
74
  var _title, ref1;
75
75
  return(// Grid maxHeight allows user to scroll inside Drawer to see all content
76
- /*#__PURE__*/ (0, _jsxRuntime.jsx)("form", {
76
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
77
+ component: "form",
77
78
  id: panelEditorFormId,
78
79
  onSubmit: handleSubmit,
80
+ sx: {
81
+ flex: 1,
82
+ overflowY: 'scroll',
83
+ padding: (theme)=>theme.spacing(2)
84
+ },
79
85
  children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
80
86
  container: true,
81
87
  spacing: 2,
82
- sx: {
83
- overflowY: 'scroll',
84
- maxHeight: '90vh'
85
- },
86
88
  children: [
87
89
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
88
90
  item: true,
@@ -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 [showCustomDateSelector, setShowCustomDateSelector] = (0, _react.useState)(false);
92
- const anchorEl = (0, _react.useRef)();
93
- const convertedTimeRange = (0, _react.useMemo)(()=>{
94
- return (0, _core.isRelativeTimeRange)(timeRange) ? (0, _core.toAbsoluteTimeRange)(timeRange) : timeRange;
95
- }, [
96
- timeRange
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
- open: showCustomDateSelector,
109
- onClose: ()=>setShowCustomDateSelector(false),
110
- sx: (theme)=>({
111
- padding: theme.spacing(2)
112
- }),
113
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.AbsoluteTimePicker, {
114
- initialTimeRange: convertedTimeRange,
115
- onChange: (timeRange)=>{
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
  }