@perses-dev/dashboards 0.7.1 → 0.8.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 (161) hide show
  1. package/dist/cjs/components/Dashboard.js +1 -1
  2. package/dist/cjs/components/DashboardToolbar.js +3 -18
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +3 -3
  4. package/dist/cjs/components/GridLayout/GridLayout.js +6 -9
  5. package/dist/cjs/components/GridLayout/GridTitle.js +15 -9
  6. package/dist/cjs/components/Panel/Panel.js +11 -6
  7. package/dist/cjs/components/Panel/Panel.test.js +17 -13
  8. package/dist/cjs/components/Panel/PanelContent.js +15 -0
  9. package/dist/cjs/components/Panel/index.js +29 -0
  10. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +124 -0
  11. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +111 -0
  12. package/dist/cjs/components/PanelDrawer/PanelOptionsEditor.js +19 -0
  13. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +60 -0
  14. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +95 -0
  15. package/dist/cjs/components/{TimeRangeControls.js → TimeRangeControls/TimeRangeControls.js} +20 -31
  16. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +51 -0
  17. package/dist/cjs/components/TimeRangeControls/index.js +29 -0
  18. package/dist/cjs/components/Variables/Variable.js +57 -0
  19. package/dist/cjs/components/Variables/VariableList.js +27 -0
  20. package/dist/cjs/components/{VariableList → Variables}/index.js +1 -0
  21. package/dist/cjs/components/index.js +2 -3
  22. package/dist/cjs/context/DashboardAppSlice.js +45 -0
  23. package/dist/cjs/context/DashboardProvider.js +54 -36
  24. package/dist/cjs/context/LayoutsSlice.js +42 -0
  25. package/dist/cjs/context/QueryStringProvider.js +35 -0
  26. package/dist/cjs/context/TemplateVariableProvider.js +216 -0
  27. package/dist/cjs/context/TimeRangeProvider.js +66 -0
  28. package/dist/cjs/context/index.js +6 -3
  29. package/dist/cjs/css/styles.js +173 -169
  30. package/dist/cjs/test/plugin-registry.js +24 -17
  31. package/dist/cjs/test/render.js +11 -2
  32. package/dist/cjs/test/testDashboard.js +14 -37
  33. package/dist/cjs/views/DashboardApp.js +4 -4
  34. package/dist/cjs/views/ViewDashboard.js +30 -2
  35. package/dist/cjs/views/index.js +1 -1
  36. package/dist/components/Dashboard.d.ts.map +1 -1
  37. package/dist/components/Dashboard.js +1 -1
  38. package/dist/components/DashboardToolbar.d.ts +0 -1
  39. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  40. package/dist/components/DashboardToolbar.js +1 -1
  41. package/dist/components/GridLayout/GridItemContent.d.ts +1 -0
  42. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  43. package/dist/components/GridLayout/GridItemContent.js +1 -1
  44. package/dist/components/GridLayout/GridLayout.d.ts +2 -1
  45. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  46. package/dist/components/GridLayout/GridLayout.js +1 -1
  47. package/dist/components/GridLayout/GridTitle.d.ts +1 -0
  48. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  49. package/dist/components/GridLayout/GridTitle.js +1 -1
  50. package/dist/components/Panel/Panel.d.ts +2 -0
  51. package/dist/components/Panel/Panel.d.ts.map +1 -1
  52. package/dist/components/Panel/Panel.js +1 -1
  53. package/dist/components/Panel/Panel.test.d.ts.map +1 -1
  54. package/dist/components/Panel/Panel.test.js +1 -1
  55. package/dist/components/Panel/PanelContent.d.ts +11 -0
  56. package/dist/components/Panel/PanelContent.d.ts.map +1 -0
  57. package/dist/components/Panel/PanelContent.js +1 -0
  58. package/dist/components/Panel/index.d.ts +2 -0
  59. package/dist/components/Panel/index.d.ts.map +1 -0
  60. package/dist/components/Panel/index.js +1 -0
  61. package/dist/components/PanelDrawer/PanelDrawer.d.ts +4 -0
  62. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -0
  63. package/dist/components/PanelDrawer/PanelDrawer.js +1 -0
  64. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts +2 -0
  65. package/dist/components/PanelDrawer/PanelDrawer.test.d.ts.map +1 -0
  66. package/dist/components/PanelDrawer/PanelDrawer.test.js +1 -0
  67. package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts +9 -0
  68. package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts.map +1 -0
  69. package/dist/components/PanelDrawer/PanelOptionsEditor.js +1 -0
  70. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -0
  71. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -0
  72. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +1 -0
  73. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts +2 -0
  74. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.d.ts.map +1 -0
  75. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +1 -0
  76. package/dist/components/{TimeRangeControls.d.ts → TimeRangeControls/TimeRangeControls.d.ts} +0 -0
  77. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  78. package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -0
  79. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts +2 -0
  80. package/dist/components/TimeRangeControls/TimeRangeControls.test.d.ts.map +1 -0
  81. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +1 -0
  82. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  83. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  84. package/dist/components/TimeRangeControls/index.js +1 -0
  85. package/dist/components/Variables/Variable.d.ts +8 -0
  86. package/dist/components/Variables/Variable.d.ts.map +1 -0
  87. package/dist/components/Variables/Variable.js +1 -0
  88. package/dist/components/Variables/VariableList.d.ts +3 -0
  89. package/dist/components/Variables/VariableList.d.ts.map +1 -0
  90. package/dist/components/Variables/VariableList.js +1 -0
  91. package/dist/components/Variables/index.d.ts +3 -0
  92. package/dist/components/Variables/index.d.ts.map +1 -0
  93. package/dist/components/Variables/index.js +1 -0
  94. package/dist/components/index.d.ts +2 -3
  95. package/dist/components/index.d.ts.map +1 -1
  96. package/dist/components/index.js +1 -1
  97. package/dist/context/DashboardAppSlice.d.ts +26 -0
  98. package/dist/context/DashboardAppSlice.d.ts.map +1 -0
  99. package/dist/context/DashboardAppSlice.js +1 -0
  100. package/dist/context/DashboardProvider.d.ts +8 -19
  101. package/dist/context/DashboardProvider.d.ts.map +1 -1
  102. package/dist/context/DashboardProvider.js +1 -1
  103. package/dist/context/LayoutsSlice.d.ts +12 -0
  104. package/dist/context/LayoutsSlice.d.ts.map +1 -0
  105. package/dist/context/LayoutsSlice.js +1 -0
  106. package/dist/context/QueryStringProvider.d.ts +13 -0
  107. package/dist/context/QueryStringProvider.d.ts.map +1 -0
  108. package/dist/context/QueryStringProvider.js +1 -0
  109. package/dist/context/TemplateVariableProvider.d.ts +25 -0
  110. package/dist/context/TemplateVariableProvider.d.ts.map +1 -0
  111. package/dist/context/TemplateVariableProvider.js +1 -0
  112. package/dist/context/TimeRangeProvider.d.ts +12 -0
  113. package/dist/context/TimeRangeProvider.d.ts.map +1 -0
  114. package/dist/context/TimeRangeProvider.js +1 -0
  115. package/dist/context/index.d.ts +5 -2
  116. package/dist/context/index.d.ts.map +1 -1
  117. package/dist/context/index.js +1 -1
  118. package/dist/css/styles.d.ts +7 -7
  119. package/dist/css/styles.d.ts.map +1 -1
  120. package/dist/css/styles.js +1 -1
  121. package/dist/test/plugin-registry.d.ts +4 -2
  122. package/dist/test/plugin-registry.d.ts.map +1 -1
  123. package/dist/test/plugin-registry.js +1 -1
  124. package/dist/test/render.d.ts +2 -1
  125. package/dist/test/render.d.ts.map +1 -1
  126. package/dist/test/render.js +1 -1
  127. package/dist/test/testDashboard.d.ts.map +1 -1
  128. package/dist/test/testDashboard.js +1 -1
  129. package/dist/views/DashboardApp.js +1 -1
  130. package/dist/views/ViewDashboard.d.ts.map +1 -1
  131. package/dist/views/ViewDashboard.js +1 -1
  132. package/package.json +9 -11
  133. package/dist/cjs/components/AddPanel/AddPanel.js +0 -75
  134. package/dist/cjs/components/VariableAutocomplete.js +0 -63
  135. package/dist/cjs/components/VariableList/VariableList.js +0 -42
  136. package/dist/cjs/components/VariableList/VariableList.test.js +0 -86
  137. package/dist/cjs/context/TemplateVariablesProvider.js +0 -142
  138. package/dist/cjs/context/TimeRangeStateProvider.js +0 -49
  139. package/dist/components/AddPanel/AddPanel.d.ts +0 -8
  140. package/dist/components/AddPanel/AddPanel.d.ts.map +0 -1
  141. package/dist/components/AddPanel/AddPanel.js +0 -1
  142. package/dist/components/TimeRangeControls.d.ts.map +0 -1
  143. package/dist/components/TimeRangeControls.js +0 -1
  144. package/dist/components/VariableAutocomplete.d.ts +0 -21
  145. package/dist/components/VariableAutocomplete.d.ts.map +0 -1
  146. package/dist/components/VariableAutocomplete.js +0 -1
  147. package/dist/components/VariableList/VariableList.d.ts +0 -11
  148. package/dist/components/VariableList/VariableList.d.ts.map +0 -1
  149. package/dist/components/VariableList/VariableList.js +0 -1
  150. package/dist/components/VariableList/VariableList.test.d.ts +0 -2
  151. package/dist/components/VariableList/VariableList.test.d.ts.map +0 -1
  152. package/dist/components/VariableList/VariableList.test.js +0 -1
  153. package/dist/components/VariableList/index.d.ts +0 -2
  154. package/dist/components/VariableList/index.d.ts.map +0 -1
  155. package/dist/components/VariableList/index.js +0 -1
  156. package/dist/context/TemplateVariablesProvider.d.ts +0 -23
  157. package/dist/context/TemplateVariablesProvider.d.ts.map +0 -1
  158. package/dist/context/TemplateVariablesProvider.js +0 -1
  159. package/dist/context/TimeRangeStateProvider.d.ts +0 -22
  160. package/dist/context/TimeRangeStateProvider.d.ts.map +0 -1
  161. package/dist/context/TimeRangeStateProvider.js +0 -1
@@ -12,173 +12,177 @@
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.default = {
16
- '&.react-grid-layout': {
17
- position: 'relative',
18
- transition: 'height 200ms ease',
19
- },
20
- '&.react-grid-item': {
21
- transition: 'all 200ms ease',
22
- transitionProperty: 'left, top',
23
- },
24
- '&.react-grid-item img': {
25
- pointerEvents: 'none',
26
- userSelect: 'none',
27
- },
28
- '&.react-grid-item.cssTransforms': {
29
- transitionProperty: 'transform',
30
- },
31
- '&.react-grid-item.resizing': {
32
- zIndex: 1,
33
- willChange: 'width, height',
34
- },
35
- '&.react-grid-item.react-draggable-dragging': {
36
- transition: 'none',
37
- zIndex: 3,
38
- willChange: 'transform',
39
- },
40
- '&.react-grid-item.dropping': {
41
- visibility: 'hidden',
42
- },
43
- '&.react-grid-item.react-grid-placeholder': {
44
- background: 'red',
45
- opacity: 0.2,
46
- transitionDuration: '100ms',
47
- zIndex: 2,
48
- userSelect: 'none',
49
- '-webkit-user-select': 'none',
50
- '-moz-user-select': 'none',
51
- '-ms-user-select': 'none',
52
- '-o-user-select': 'none',
53
- },
54
- '&.react-grid-item > .react-resizable-handle': {
55
- position: 'absolute',
56
- width: '20px',
57
- height: '20px',
58
- },
59
- '&.react-grid-item > .react-resizable-handle::after': {
60
- content: '""',
61
- position: 'absolute',
62
- right: '3px',
63
- bottom: '3px',
64
- width: '5px',
65
- height: '5px',
66
- borderRight: '2px solid rgba(0, 0, 0, 0.4)',
67
- borderBottom: '2px solid rgba(0, 0, 0, 0.4)',
68
- },
69
- '&.react-resizable-hide > .react-resizable-handle': {
70
- display: 'none',
71
- },
72
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-sw': {
73
- bottom: '0',
74
- left: '0',
75
- cursor: 'sw-resize',
76
- transform: 'rotate(90deg)',
77
- },
78
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-se': {
79
- bottom: '0',
80
- right: '0',
81
- cursor: 'se-resize',
82
- },
83
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-nw': {
84
- top: '0',
85
- left: '0',
86
- cursor: 'nw-resize',
87
- transform: 'rotate(180deg)',
88
- },
89
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-ne': {
90
- top: '0',
91
- right: '0',
92
- cursor: 'ne-resize',
93
- transform: 'rotate(270deg)',
94
- },
95
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w, &.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
96
- top: '50%',
97
- marginTop: '-10px',
98
- cursor: 'ew-resize',
99
- },
100
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w': {
101
- left: '0',
102
- transform: 'rotate(135deg)',
103
- },
104
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
105
- right: '0',
106
- transform: 'rotate(315deg)',
107
- },
108
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n, &.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
109
- left: '50%',
110
- marginLeft: '-10px',
111
- cursor: 'ns-resize',
112
- },
113
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n': {
114
- top: '0',
115
- transform: 'rotate(225deg)',
116
- },
117
- '&.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
118
- bottom: '0',
119
- transform: 'rotate(45deg)',
120
- },
121
- '&.react-resizable': {
122
- position: 'relative',
123
- },
124
- '&.react-resizable-handle': {
125
- position: 'absolute',
126
- width: '20px',
127
- height: '20px',
128
- backgroundRepeat: 'no-repeat',
129
- backgroundOrigin: 'content-box',
130
- boxSizing: 'border-box',
131
- backgroundImage: `url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+')`,
132
- backgroundPosition: 'bottom right',
133
- padding: '0 3px 3px 0',
134
- },
135
- '&.react-resizable-handle-sw': {
136
- bottom: '0',
137
- left: '0',
138
- cursor: 'sw-resize',
139
- transform: 'rotate(90deg)',
140
- },
141
- '&.react-resizable-handle-se': {
142
- bottom: '0',
143
- right: '0',
144
- cursor: 'se-resize',
145
- },
146
- '&.react-resizable-handle-nw': {
147
- top: '0',
148
- left: '0',
149
- cursor: 'nw-resize',
150
- transform: 'rotate(180deg)',
151
- },
152
- '&.react-resizable-handle-ne': {
153
- top: '0',
154
- right: '0',
155
- cursor: 'ne-resize',
156
- transform: 'rotate(270deg)',
157
- },
158
- '&.react-resizable-handle-w, .react-resizable-handle-e': {
159
- top: '50%',
160
- marginTop: '-10px',
161
- cursor: 'ew-resize',
162
- },
163
- '&.react-resizable-handle-w': {
164
- left: '0',
165
- transform: 'rotate(135deg)',
166
- },
167
- '&.react-resizable-handle-e': {
168
- right: '0',
169
- transform: 'rotate(315deg)',
170
- },
171
- '&.react-resizable-handle-n, .react-resizable-handle-s': {
172
- left: '50%',
173
- marginLeft: '-10px',
174
- cursor: 'ns-resize',
175
- },
176
- '&.react-resizable-handle-n': {
177
- top: '0',
178
- transform: 'rotate(225deg)',
179
- },
180
- '&.react-resizable-handle-s': {
181
- bottom: '0',
182
- transform: 'rotate(45deg)',
183
- },
15
+ exports.styles = void 0;
16
+ const styles = (theme) => {
17
+ return {
18
+ '&.react-grid-layout': {
19
+ position: 'relative',
20
+ transition: 'height 200ms ease',
21
+ },
22
+ '&.react-grid-item': {
23
+ transition: 'all 200ms ease',
24
+ transitionProperty: 'left, top',
25
+ },
26
+ '&.react-grid-item img': {
27
+ pointerEvents: 'none',
28
+ userSelect: 'none',
29
+ },
30
+ '&.react-grid-item.cssTransforms': {
31
+ transitionProperty: 'transform',
32
+ },
33
+ '&.react-grid-item.resizing': {
34
+ zIndex: 1,
35
+ willChange: 'width, height',
36
+ },
37
+ '&.react-grid-item.react-draggable-dragging': {
38
+ transition: 'none',
39
+ zIndex: 3,
40
+ willChange: 'transform',
41
+ },
42
+ '&.react-grid-item.dropping': {
43
+ visibility: 'hidden',
44
+ },
45
+ '&.react-grid-item.react-grid-placeholder': {
46
+ background: theme.palette.primary.main,
47
+ opacity: 0.2,
48
+ transitionDuration: '100ms',
49
+ zIndex: 2,
50
+ userSelect: 'none',
51
+ WebkitUserSelect: 'none',
52
+ MozUserSelect: 'none',
53
+ msUserSelect: 'none',
54
+ OUserSelect: 'none',
55
+ },
56
+ '&.react-grid-item > .react-resizable-handle': {
57
+ position: 'absolute',
58
+ width: '20px',
59
+ height: '20px',
60
+ },
61
+ '&.react-grid-item > .react-resizable-handle::after': {
62
+ content: '""',
63
+ position: 'absolute',
64
+ right: '3px',
65
+ bottom: '3px',
66
+ width: '5px',
67
+ height: '5px',
68
+ borderRight: '2px solid rgba(0, 0, 0, 0.4)',
69
+ borderBottom: '2px solid rgba(0, 0, 0, 0.4)',
70
+ },
71
+ '&.react-resizable-hide > .react-resizable-handle': {
72
+ display: 'none',
73
+ },
74
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-sw': {
75
+ bottom: '0',
76
+ left: '0',
77
+ cursor: 'sw-resize',
78
+ transform: 'rotate(90deg)',
79
+ },
80
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-se': {
81
+ bottom: '0',
82
+ right: '0',
83
+ cursor: 'se-resize',
84
+ },
85
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-nw': {
86
+ top: '0',
87
+ left: '0',
88
+ cursor: 'nw-resize',
89
+ transform: 'rotate(180deg)',
90
+ },
91
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-ne': {
92
+ top: '0',
93
+ right: '0',
94
+ cursor: 'ne-resize',
95
+ transform: 'rotate(270deg)',
96
+ },
97
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w, &.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
98
+ top: '50%',
99
+ marginTop: '-10px',
100
+ cursor: 'ew-resize',
101
+ },
102
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-w': {
103
+ left: '0',
104
+ transform: 'rotate(135deg)',
105
+ },
106
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-e': {
107
+ right: '0',
108
+ transform: 'rotate(315deg)',
109
+ },
110
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n, &.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
111
+ left: '50%',
112
+ marginLeft: '-10px',
113
+ cursor: 'ns-resize',
114
+ },
115
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-n': {
116
+ top: '0',
117
+ transform: 'rotate(225deg)',
118
+ },
119
+ '&.react-grid-item > .react-resizable-handle.react-resizable-handle-s': {
120
+ bottom: '0',
121
+ transform: 'rotate(45deg)',
122
+ },
123
+ '&.react-resizable': {
124
+ position: 'relative',
125
+ },
126
+ '&.react-resizable-handle': {
127
+ position: 'absolute',
128
+ width: '20px',
129
+ height: '20px',
130
+ backgroundRepeat: 'no-repeat',
131
+ backgroundOrigin: 'content-box',
132
+ boxSizing: 'border-box',
133
+ backgroundImage: `url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2IDYiIHN0eWxlPSJiYWNrZ3JvdW5kLWNvbG9yOiNmZmZmZmYwMCIgeD0iMHB4IiB5PSIwcHgiIHdpZHRoPSI2cHgiIGhlaWdodD0iNnB4Ij48ZyBvcGFjaXR5PSIwLjMwMiI+PHBhdGggZD0iTSA2IDYgTCAwIDYgTCAwIDQuMiBMIDQgNC4yIEwgNC4yIDQuMiBMIDQuMiAwIEwgNiAwIEwgNiA2IEwgNiA2IFoiIGZpbGw9IiMwMDAwMDAiLz48L2c+PC9zdmc+')`,
134
+ backgroundPosition: 'bottom right',
135
+ padding: '0 3px 3px 0',
136
+ },
137
+ '&.react-resizable-handle-sw': {
138
+ bottom: '0',
139
+ left: '0',
140
+ cursor: 'sw-resize',
141
+ transform: 'rotate(90deg)',
142
+ },
143
+ '&.react-resizable-handle-se': {
144
+ bottom: '0',
145
+ right: '0',
146
+ cursor: 'se-resize',
147
+ },
148
+ '&.react-resizable-handle-nw': {
149
+ top: '0',
150
+ left: '0',
151
+ cursor: 'nw-resize',
152
+ transform: 'rotate(180deg)',
153
+ },
154
+ '&.react-resizable-handle-ne': {
155
+ top: '0',
156
+ right: '0',
157
+ cursor: 'ne-resize',
158
+ transform: 'rotate(270deg)',
159
+ },
160
+ '&.react-resizable-handle-w, .react-resizable-handle-e': {
161
+ top: '50%',
162
+ marginTop: '-10px',
163
+ cursor: 'ew-resize',
164
+ },
165
+ '&.react-resizable-handle-w': {
166
+ left: '0',
167
+ transform: 'rotate(135deg)',
168
+ },
169
+ '&.react-resizable-handle-e': {
170
+ right: '0',
171
+ transform: 'rotate(315deg)',
172
+ },
173
+ '&.react-resizable-handle-n, .react-resizable-handle-s': {
174
+ left: '50%',
175
+ marginLeft: '-10px',
176
+ cursor: 'ns-resize',
177
+ },
178
+ '&.react-resizable-handle-n': {
179
+ top: '0',
180
+ transform: 'rotate(225deg)',
181
+ },
182
+ '&.react-resizable-handle-s': {
183
+ bottom: '0',
184
+ transform: 'rotate(45deg)',
185
+ },
186
+ };
184
187
  };
188
+ exports.styles = styles;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mockPluginRegistryProps = void 0;
3
+ exports.FAKE_PANEL_PLUGIN = exports.mockPluginRegistryProps = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
5
  /**
5
6
  * Helper for mocking `PluginRegistry` data during tests. Returns props that can be spread on the `PluginRegistry`
6
7
  * component so that it will load the mock plugins you setup. You can use the `addMockPlugin` function that's returned
@@ -8,29 +9,26 @@ exports.mockPluginRegistryProps = void 0;
8
9
  */
9
10
  function mockPluginRegistryProps() {
10
11
  const mockPluginResource = {
11
- kind: 'Plugin',
12
+ kind: 'PluginModule',
12
13
  metadata: {
13
- name: 'Fake Plugin for Tests',
14
+ name: 'Fake Plugin Module for Tests',
14
15
  },
15
16
  spec: {
16
- supported_kinds: {},
17
+ plugins: [],
17
18
  },
18
19
  };
20
+ const mockPluginModule = {};
19
21
  // Allow adding mock plugins in tests
20
- const mockSetupFunctions = [];
21
- const addMockPlugin = (config) => {
22
- mockPluginResource.spec.supported_kinds[config.kind] = config.pluginType;
23
- mockSetupFunctions.push((registerPlugin) => {
24
- registerPlugin(config);
22
+ const addMockPlugin = (pluginType, kind, plugin) => {
23
+ mockPluginResource.spec.plugins.push({
24
+ pluginType,
25
+ kind,
26
+ display: {
27
+ name: `Fake ${pluginType} Plugin for ${kind}`,
28
+ },
25
29
  });
26
- };
27
- // Our mock plugin module just calls all the setup functions that were added
28
- const mockPluginModule = {
29
- setup(registerPlugin) {
30
- for (const setup of mockSetupFunctions) {
31
- setup(registerPlugin);
32
- }
33
- },
30
+ // "Export" on the module under the same name as the kind the plugin handles
31
+ mockPluginModule[kind] = plugin;
34
32
  };
35
33
  const pluginRegistryProps = {
36
34
  getInstalledPlugins() {
@@ -46,3 +44,12 @@ function mockPluginRegistryProps() {
46
44
  };
47
45
  }
48
46
  exports.mockPluginRegistryProps = mockPluginRegistryProps;
47
+ exports.FAKE_PANEL_PLUGIN = {
48
+ PanelComponent: () => {
49
+ return (0, jsx_runtime_1.jsx)("div", { role: "figure", children: "FakePanel chart" });
50
+ },
51
+ OptionsEditorComponent: () => {
52
+ return (0, jsx_runtime_1.jsx)("div", { children: "Edit options here" });
53
+ },
54
+ createInitialOptions: () => ({}),
55
+ };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.renderWithContext = void 0;
4
7
  const jsx_runtime_1 = require("react/jsx-runtime");
@@ -16,11 +19,17 @@ const jsx_runtime_1 = require("react/jsx-runtime");
16
19
  // limitations under the License.
17
20
  const react_1 = require("@testing-library/react");
18
21
  const react_query_1 = require("react-query");
22
+ const context_1 = require("../context");
23
+ const testDashboard_1 = __importDefault(require("./testDashboard"));
19
24
  const queryClient = new react_query_1.QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false } } });
25
+ const initialStore = {
26
+ isEditMode: true,
27
+ dashboardSpec: testDashboard_1.default.spec,
28
+ };
20
29
  /**
21
30
  * Test helper to render a React component with some common app-level providers wrapped around it.
22
31
  */
23
- function renderWithContext(ui, options) {
24
- return (0, react_1.render)((0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: ui }), options);
32
+ function renderWithContext(ui, initialState = initialStore, options) {
33
+ return (0, react_1.render)((0, jsx_runtime_1.jsx)(context_1.DashboardProvider, { initialState: initialState, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: ui }) }), options);
25
34
  }
26
35
  exports.renderWithContext = renderWithContext;
@@ -23,53 +23,30 @@ const testDashboard = {
23
23
  },
24
24
  spec: {
25
25
  datasource: { kind: 'Prometheus', global: true, name: 'Public Prometheus Demo Server' },
26
- // TODO: Should duration actually be a time range?
27
26
  duration: '24h',
28
- variables: {
29
- job: {
30
- kind: 'PrometheusLabelValues',
27
+ variables: [
28
+ {
29
+ name: 'job',
30
+ kind: 'TextVariable',
31
31
  options: {
32
- label_name: 'job',
33
- match: ['node_uname_info'],
34
- },
35
- display: {
36
- label: 'Job',
37
- },
38
- selection: {
39
- default_value: 'node',
32
+ value: 'node',
40
33
  },
41
34
  },
42
- instance: {
43
- kind: 'PrometheusLabelValues',
35
+ {
36
+ name: 'instance',
37
+ kind: 'TextVariable',
44
38
  options: {
45
- label_name: 'instance',
46
- match: ['node_uname_info{job="node"}'],
47
- },
48
- display: {
49
- label: 'Node',
50
- },
51
- selection: {
52
- default_value: ['demo.do.prometheus.io:9100'],
53
- all_value: '$__all',
39
+ value: 'demo.do.prometheus.io:9100',
54
40
  },
55
41
  },
56
- interval: {
57
- kind: 'Interval',
42
+ {
43
+ name: 'interval',
44
+ kind: 'TextVariable',
58
45
  options: {
59
- values: ['1m', '5m', '10m', '1h'],
60
- auto: {
61
- step_count: 50,
62
- min_interval: '1m',
63
- },
64
- },
65
- display: {
66
- label: 'Interval',
67
- },
68
- selection: {
69
- default_value: '1m',
46
+ value: '1m',
70
47
  },
71
48
  },
72
- },
49
+ ],
73
50
  panels: {
74
51
  cpu: {
75
52
  kind: 'LineChart',
@@ -19,15 +19,15 @@ const jsx_runtime_1 = require("react/jsx-runtime");
19
19
  // limitations under the License.
20
20
  const material_1 = require("@mui/material");
21
21
  const components_1 = require("@perses-dev/components");
22
- const react_1 = require("react");
23
22
  const components_2 = require("../components");
24
- const AddPanel_1 = __importDefault(require("../components/AddPanel/AddPanel"));
23
+ const PanelGroupDialog_1 = __importDefault(require("../components/PanelGroupDialog/PanelGroupDialog"));
24
+ const PanelDrawer_1 = __importDefault(require("../components/PanelDrawer/PanelDrawer"));
25
25
  const DashboardToolbar_1 = require("../components/DashboardToolbar");
26
26
  const context_1 = require("../context");
27
27
  const DashboardApp = (props) => {
28
28
  const { dashboardResource, sx, children, ...others } = props;
29
- const [showAddPanel, setShowAddPanel] = (0, react_1.useState)(false);
30
29
  const { dashboard } = (0, context_1.useDashboard)();
30
+ const { panelGroupDialog } = (0, context_1.useDashboardApp)();
31
31
  return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: (0, components_1.combineSx)({
32
32
  display: 'flex',
33
33
  width: '100%',
@@ -41,6 +41,6 @@ const DashboardApp = (props) => {
41
41
  overflowY: 'auto',
42
42
  display: 'flex',
43
43
  flexDirection: 'column',
44
- }, children: [(0, jsx_runtime_1.jsx)(DashboardToolbar_1.DashboardToolbar, { dashboardName: dashboardResource.metadata.name, onAddPanel: () => setShowAddPanel(true) }), (0, jsx_runtime_1.jsx)(components_2.VariableList, { variables: dashboardResource.spec.variables, sx: { margin: (theme) => theme.spacing(1, 0, 2) } }), (0, jsx_runtime_1.jsx)(components_2.Dashboard, { spec: dashboard }), (0, jsx_runtime_1.jsx)(AddPanel_1.default, { isOpen: showAddPanel, onClose: () => setShowAddPanel(false) }), children] }) }));
44
+ }, children: [(0, jsx_runtime_1.jsx)(DashboardToolbar_1.DashboardToolbar, { dashboardName: dashboardResource.metadata.name }), (0, jsx_runtime_1.jsx)(components_2.TemplateVariableList, {}), (0, jsx_runtime_1.jsx)(components_2.Dashboard, { spec: dashboard }), (0, jsx_runtime_1.jsx)(PanelDrawer_1.default, {}), panelGroupDialog && (0, jsx_runtime_1.jsx)(PanelGroupDialog_1.default, {}), children] }) }));
45
45
  };
46
46
  exports.DashboardApp = DashboardApp;
@@ -2,14 +2,42 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ViewDashboard = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // Copyright 2021 The Perses Authors
6
+ // Licensed under the Apache License, Version 2.0 (the "License");
7
+ // you may not use this file except in compliance with the License.
8
+ // You may obtain a copy of the License at
9
+ //
10
+ // http://www.apache.org/licenses/LICENSE-2.0
11
+ //
12
+ // Unless required by applicable law or agreed to in writing, software
13
+ // distributed under the License is distributed on an "AS IS" BASIS,
14
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ // See the License for the specific language governing permissions and
16
+ // limitations under the License.
17
+ const react_1 = require("react");
18
+ const core_1 = require("@perses-dev/core");
19
+ const plugin_system_1 = require("@perses-dev/plugin-system");
5
20
  const context_1 = require("../context");
6
21
  const DashboardApp_1 = require("./DashboardApp");
7
22
  /**
8
23
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
9
24
  */
10
25
  function ViewDashboard(props) {
26
+ var _a;
11
27
  const { dashboardResource: { spec }, children, } = props;
12
- const pastDuration = spec.duration;
13
- return ((0, jsx_runtime_1.jsx)(context_1.DashboardProvider, { initialState: { dashboardSpec: spec }, children: (0, jsx_runtime_1.jsx)(context_1.TimeRangeStateProvider, { initialValue: { pastDuration }, children: (0, jsx_runtime_1.jsx)(context_1.TemplateVariablesProvider, { variableDefinitions: spec.variables, children: (0, jsx_runtime_1.jsx)(DashboardApp_1.DashboardApp, { ...props, children: children }) }) }) }));
28
+ const { queryString, setQueryString } = (0, plugin_system_1.useQueryString)();
29
+ const dashboardDuration = (_a = spec.duration) !== null && _a !== void 0 ? _a : '1h';
30
+ const defaultTimeRange = (0, core_1.getDefaultTimeRange)(dashboardDuration, queryString);
31
+ // TODO: add reusable sync query string or no-op util
32
+ (0, react_1.useEffect)(() => {
33
+ const currentParams = Object.fromEntries([...queryString]);
34
+ // if app does not provide query string implementation, setTimeRange is used instead
35
+ if (!currentParams.start && setQueryString) {
36
+ // default to duration in dashboard definition if start param is not already set
37
+ queryString.set('start', dashboardDuration);
38
+ setQueryString(queryString);
39
+ }
40
+ }, [dashboardDuration, queryString, setQueryString]);
41
+ return ((0, jsx_runtime_1.jsx)(context_1.DashboardProvider, { initialState: { dashboardSpec: spec }, children: (0, jsx_runtime_1.jsx)(context_1.TimeRangeProvider, { initialTimeRange: defaultTimeRange, children: (0, jsx_runtime_1.jsx)(context_1.TemplateVariableProvider, { initialVariableDefinitions: spec.variables, children: (0, jsx_runtime_1.jsx)(DashboardApp_1.DashboardApp, { ...props, children: children }) }) }) }));
14
42
  }
15
43
  exports.ViewDashboard = ViewDashboard;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Copyright 2021 The Perses Authors
2
+ // Copyright 2022 The Perses Authors
3
3
  // Licensed under the Apache License, Version 2.0 (the "License");
4
4
  // you may not use this file except in compliance with the License.
5
5
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../src/components/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,IAAI,EAAE,aAAa,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAgB9C"}
1
+ {"version":3,"file":"Dashboard.d.ts","sourceRoot":"","sources":["../../src/components/Dashboard.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,WAAW,cAAe,SAAQ,QAAQ;IAC9C,IAAI,EAAE,aAAa,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAmB9C"}
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{Box}from"@mui/material";import{ErrorBoundary,ErrorAlert}from"@perses-dev/components";import{GridLayout,GridItemContent}from"./GridLayout";export function Dashboard(r){const{spec:o,...t}=r;return _jsx(Box,{...t,children:_jsx(ErrorBoundary,{FallbackComponent:ErrorAlert,children:o.layouts.map(((r,t)=>_jsx(GridLayout,{definition:r,renderGridItemContent:r=>_jsx(GridItemContent,{content:r.content,spec:o})},t)))})})}
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{Box}from"@mui/material";import{ErrorBoundary,ErrorAlert}from"@perses-dev/components";import{GridLayout,GridItemContent}from"./GridLayout";export function Dashboard(r){const{spec:o,...t}=r;return _jsx(Box,{...t,children:_jsx(ErrorBoundary,{FallbackComponent:ErrorAlert,children:o.layouts.map(((r,t)=>_jsx(GridLayout,{groupIndex:t,definition:r,renderGridItemContent:(r,t)=>_jsx(GridItemContent,{content:r.content,spec:o,groupIndex:t})},`${JSON.stringify(o.layouts)} ${t}`)))})})}
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export interface DashboardToolbarProps {
3
3
  dashboardName: string;
4
- onAddPanel: () => void;
5
4
  }
6
5
  export declare const DashboardToolbar: (props: DashboardToolbarProps) => JSX.Element;
7
6
  //# sourceMappingURL=DashboardToolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../src/components/DashboardToolbar.tsx"],"names":[],"mappings":";AAoBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBA4E5D,CAAC"}
1
+ {"version":3,"file":"DashboardToolbar.d.ts","sourceRoot":"","sources":["../../src/components/DashboardToolbar.tsx"],"names":[],"mappings":";AAmBA,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,gBA2D5D,CAAC"}
@@ -1 +1 @@
1
- import{jsxs as _jsxs,jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{Toolbar,Typography,Stack,Button,Box}from"@mui/material";import PencilIcon from"mdi-material-ui/PencilOutline";import AddIcon from"mdi-material-ui/Plus";import{useEditMode,useLayouts}from"../context";import{TimeRangeControls}from"../components";export const DashboardToolbar=i=>{const{dashboardName:t,onAddPanel:n}=i,{isEditMode:o,setEditMode:s}=useEditMode(),{addLayout:a}=useLayouts();return _jsx(Toolbar,{disableGutters:!0,sx:{display:"block",padding:i=>i.spacing(2,0)},children:o?_jsxs(_Fragment,{children:[_jsxs(Box,{sx:{display:"flex",width:"100%"},children:[_jsxs(Typography,{variant:"h2",children:["Edit ",t]}),_jsxs(Stack,{direction:"row",spacing:1,sx:{marginLeft:"auto"},children:[_jsx(TimeRangeControls,{}),_jsx(Button,{variant:"outlined",onClick:()=>{s(!1)},children:"Cancel"}),_jsx(Button,{variant:"contained",children:"Save"})]})]}),_jsxs(Stack,{direction:"row",spacing:1,sx:{display:"flex",justifyContent:"flex-end",width:"100%",padding:i=>i.spacing(2,0)},children:[_jsx(Button,{startIcon:_jsx(AddIcon,{}),onClick:()=>{a({kind:"Grid",spec:{display:{title:"New Group",collapse:{open:!0}},items:[]}})},children:"Add Group"}),_jsx(Button,{startIcon:_jsx(AddIcon,{}),onClick:n,children:"Add Panel"})]})]}):_jsxs(Box,{sx:{display:"flex",width:"100%"},children:[_jsx(Typography,{variant:"h2",children:t}),_jsxs(Stack,{direction:"row",spacing:2,sx:{marginLeft:"auto"},children:[_jsx(TimeRangeControls,{}),_jsx(Button,{variant:"contained",startIcon:_jsx(PencilIcon,{}),onClick:()=>{s(!0)},sx:{marginLeft:"auto"},children:"Edit"})]})]})})};
1
+ import{jsxs as _jsxs,jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{Toolbar,Typography,Stack,Button,Box}from"@mui/material";import PencilIcon from"mdi-material-ui/PencilOutline";import AddIcon from"mdi-material-ui/Plus";import{useDashboardApp,useEditMode}from"../context";import{TimeRangeControls}from"../components";export const DashboardToolbar=n=>{const{dashboardName:o}=n,{isEditMode:i,setEditMode:t}=useEditMode(),{openPanelDrawer:a,openPanelGroupDialog:s}=useDashboardApp();return _jsx(Toolbar,{disableGutters:!0,sx:{display:"block",padding:n=>n.spacing(2,0)},children:i?_jsxs(_Fragment,{children:[_jsxs(Box,{sx:{display:"flex",width:"100%"},children:[_jsxs(Typography,{variant:"h2",children:["Edit ",o]}),_jsxs(Stack,{direction:"row",spacing:1,sx:{marginLeft:"auto"},children:[_jsx(TimeRangeControls,{}),_jsx(Button,{variant:"outlined",onClick:()=>{t(!1)},children:"Cancel"}),_jsx(Button,{variant:"contained",children:"Save"})]})]}),_jsxs(Stack,{direction:"row",spacing:1,sx:{display:"flex",justifyContent:"flex-end",width:"100%",padding:n=>n.spacing(2,0)},children:[_jsx(Button,{startIcon:_jsx(AddIcon,{}),onClick:()=>s(),children:"Add Group"}),_jsx(Button,{startIcon:_jsx(AddIcon,{}),onClick:()=>a({groupIndex:0}),children:"Add Panel"})]})]}):_jsxs(Box,{sx:{display:"flex",width:"100%"},children:[_jsx(Typography,{variant:"h2",children:o}),_jsxs(Stack,{direction:"row",spacing:2,sx:{marginLeft:"auto"},children:[_jsx(TimeRangeControls,{}),_jsx(Button,{variant:"contained",startIcon:_jsx(PencilIcon,{}),onClick:()=>{t(!0)},sx:{marginLeft:"auto"},children:"Edit"})]})]})})};