@perses-dev/dashboards 0.9.0 → 0.10.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 (201) hide show
  1. package/dist/cjs/components/Dashboard.js +7 -11
  2. package/dist/cjs/components/DashboardToolbar.js +4 -4
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +13 -13
  4. package/dist/cjs/components/GridLayout/GridLayout.js +24 -21
  5. package/dist/cjs/components/GridLayout/GridTitle.js +27 -5
  6. package/dist/cjs/components/Panel/DeletePanelDialog.js +91 -0
  7. package/dist/cjs/components/Panel/Panel.js +16 -5
  8. package/dist/cjs/components/Panel/Panel.test.js +12 -4
  9. package/dist/cjs/components/Panel/PanelContent.js +3 -2
  10. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +13 -12
  11. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +8 -12
  12. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +77 -35
  13. package/dist/cjs/components/PanelDrawer/PanelPreview.js +48 -0
  14. package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +86 -0
  15. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +12 -19
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +10 -31
  17. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +2 -2
  18. package/dist/cjs/components/Variables/Variable.js +19 -11
  19. package/dist/cjs/components/Variables/VariableEditor.js +207 -0
  20. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +236 -0
  21. package/dist/cjs/components/Variables/VariableEditorForm/index.js +28 -0
  22. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +88 -0
  23. package/dist/cjs/components/Variables/VariableList.js +50 -69
  24. package/dist/cjs/components/Variables/index.js +1 -0
  25. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +70 -0
  26. package/dist/cjs/context/DashboardProvider/common.js +18 -0
  27. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +71 -0
  28. package/dist/cjs/context/DashboardProvider/index.js +29 -0
  29. package/dist/cjs/context/DashboardProvider/layout-slice.js +200 -0
  30. package/dist/cjs/context/DashboardProvider/panel-editing-slice.js +156 -0
  31. package/dist/{context/DashboardAppSlice.js → cjs/context/DashboardProvider/panel-group-slice.js} +18 -25
  32. package/dist/cjs/context/DatasourceStoreProvider.js +109 -7
  33. package/dist/cjs/context/TemplateVariableProvider.js +8 -1
  34. package/dist/cjs/context/index.js +0 -2
  35. package/dist/cjs/test/testDashboard.js +13 -1
  36. package/dist/cjs/views/ViewDashboard/DashboardApp.js +6 -7
  37. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +165 -0
  38. package/dist/components/Dashboard.d.ts +1 -4
  39. package/dist/components/Dashboard.d.ts.map +1 -1
  40. package/dist/components/Dashboard.js +8 -12
  41. package/dist/components/Dashboard.js.map +1 -1
  42. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  43. package/dist/components/DashboardToolbar.js +5 -5
  44. package/dist/components/DashboardToolbar.js.map +1 -1
  45. package/dist/components/GridLayout/GridItemContent.d.ts +3 -3
  46. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  47. package/dist/components/GridLayout/GridItemContent.js +14 -14
  48. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  49. package/dist/components/GridLayout/GridLayout.d.ts +2 -3
  50. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  51. package/dist/components/GridLayout/GridLayout.js +24 -21
  52. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  53. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  54. package/dist/components/GridLayout/GridTitle.js +28 -6
  55. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  56. package/dist/components/Panel/DeletePanelDialog.d.ts +5 -0
  57. package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -0
  58. package/dist/components/Panel/DeletePanelDialog.js +80 -0
  59. package/dist/components/Panel/DeletePanelDialog.js.map +1 -0
  60. package/dist/components/Panel/Panel.d.ts +1 -1
  61. package/dist/components/Panel/Panel.d.ts.map +1 -1
  62. package/dist/components/Panel/Panel.js +17 -6
  63. package/dist/components/Panel/Panel.js.map +1 -1
  64. package/dist/components/Panel/Panel.test.js +7 -4
  65. package/dist/components/Panel/Panel.test.js.map +1 -1
  66. package/dist/components/Panel/PanelContent.d.ts +4 -1
  67. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  68. package/dist/components/Panel/PanelContent.js +3 -2
  69. package/dist/components/Panel/PanelContent.js.map +1 -1
  70. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  71. package/dist/components/PanelDrawer/PanelDrawer.js +14 -13
  72. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  73. package/dist/components/PanelDrawer/PanelDrawer.test.js +8 -12
  74. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  75. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +3 -3
  76. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  77. package/dist/components/PanelDrawer/PanelEditorForm.js +78 -36
  78. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  79. package/dist/components/PanelDrawer/PanelPreview.d.ts +4 -0
  80. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -0
  81. package/dist/components/PanelDrawer/PanelPreview.js +42 -0
  82. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -0
  83. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +4 -0
  84. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -0
  85. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +75 -0
  86. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -0
  87. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  88. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +13 -20
  89. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  90. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +10 -31
  91. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
  92. package/dist/components/TimeRangeControls/TimeRangeControls.js +3 -3
  93. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  94. package/dist/components/Variables/Variable.js +21 -13
  95. package/dist/components/Variables/Variable.js.map +1 -1
  96. package/dist/components/Variables/VariableEditor.d.ts +8 -0
  97. package/dist/components/Variables/VariableEditor.d.ts.map +1 -0
  98. package/dist/components/Variables/VariableEditor.js +196 -0
  99. package/dist/components/Variables/VariableEditor.js.map +1 -0
  100. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +8 -0
  101. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -0
  102. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +225 -0
  103. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -0
  104. package/dist/components/Variables/VariableEditorForm/index.d.ts +2 -0
  105. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -0
  106. package/dist/components/Variables/VariableEditorForm/index.js +15 -0
  107. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -0
  108. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +21 -0
  109. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -0
  110. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +76 -0
  111. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -0
  112. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  113. package/dist/components/Variables/VariableList.js +48 -72
  114. package/dist/components/Variables/VariableList.js.map +1 -1
  115. package/dist/components/Variables/index.d.ts +1 -0
  116. package/dist/components/Variables/index.d.ts.map +1 -1
  117. package/dist/components/Variables/index.js +1 -0
  118. package/dist/components/Variables/index.js.map +1 -1
  119. package/dist/context/DashboardProvider/DashboardProvider.d.ts +23 -0
  120. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -0
  121. package/dist/context/DashboardProvider/DashboardProvider.js +52 -0
  122. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -0
  123. package/dist/context/DashboardProvider/common.d.ts +5 -0
  124. package/dist/context/DashboardProvider/common.d.ts.map +1 -0
  125. package/dist/context/DashboardProvider/common.js +17 -0
  126. package/dist/context/DashboardProvider/common.js.map +1 -0
  127. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +32 -0
  128. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -0
  129. package/dist/context/DashboardProvider/dashboard-provider-api.js +56 -0
  130. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -0
  131. package/dist/context/DashboardProvider/index.d.ts +3 -0
  132. package/dist/context/DashboardProvider/index.d.ts.map +1 -0
  133. package/dist/context/DashboardProvider/index.js +16 -0
  134. package/dist/context/DashboardProvider/index.js.map +1 -0
  135. package/dist/context/DashboardProvider/layout-slice.d.ts +57 -0
  136. package/dist/context/DashboardProvider/layout-slice.d.ts.map +1 -0
  137. package/dist/context/DashboardProvider/layout-slice.js +196 -0
  138. package/dist/context/DashboardProvider/layout-slice.js.map +1 -0
  139. package/dist/context/DashboardProvider/panel-editing-slice.d.ts +70 -0
  140. package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +1 -0
  141. package/dist/context/DashboardProvider/panel-editing-slice.js +152 -0
  142. package/dist/context/DashboardProvider/panel-editing-slice.js.map +1 -0
  143. package/dist/context/DashboardProvider/panel-group-slice.d.ts +15 -0
  144. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -0
  145. package/dist/context/DashboardProvider/panel-group-slice.js +32 -0
  146. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -0
  147. package/dist/context/DatasourceStoreProvider.d.ts +10 -2
  148. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  149. package/dist/context/DatasourceStoreProvider.js +111 -9
  150. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  151. package/dist/context/TemplateVariableProvider.d.ts +2 -0
  152. package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
  153. package/dist/context/TemplateVariableProvider.js +8 -1
  154. package/dist/context/TemplateVariableProvider.js.map +1 -1
  155. package/dist/context/index.d.ts +0 -2
  156. package/dist/context/index.d.ts.map +1 -1
  157. package/dist/context/index.js +0 -2
  158. package/dist/context/index.js.map +1 -1
  159. package/dist/test/plugin-registry.d.ts +2 -2
  160. package/dist/test/plugin-registry.d.ts.map +1 -1
  161. package/dist/test/plugin-registry.js.map +1 -1
  162. package/dist/test/testDashboard.d.ts.map +1 -1
  163. package/dist/test/testDashboard.js +13 -1
  164. package/dist/test/testDashboard.js.map +1 -1
  165. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  166. package/dist/views/ViewDashboard/DashboardApp.js +6 -7
  167. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  168. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts +2 -0
  169. package/dist/views/ViewDashboard/tests/panelGroups.test.d.ts.map +1 -0
  170. package/dist/views/ViewDashboard/tests/panelGroups.test.js +158 -0
  171. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -0
  172. package/package.json +4 -4
  173. package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +0 -40
  174. package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +0 -38
  175. package/dist/cjs/components/PanelDrawer/panel-editor-model.js +0 -140
  176. package/dist/cjs/context/DashboardAppSlice.js +0 -57
  177. package/dist/cjs/context/DashboardProvider.js +0 -128
  178. package/dist/cjs/context/LayoutsSlice.js +0 -55
  179. package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +0 -7
  180. package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +0 -1
  181. package/dist/components/PanelDrawer/PanelSpecEditor.js +0 -34
  182. package/dist/components/PanelDrawer/PanelSpecEditor.js.map +0 -1
  183. package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +0 -8
  184. package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +0 -1
  185. package/dist/components/PanelDrawer/PanelTypeSelect.js +0 -34
  186. package/dist/components/PanelDrawer/PanelTypeSelect.js.map +0 -1
  187. package/dist/components/PanelDrawer/panel-editor-model.d.ts +0 -27
  188. package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +0 -1
  189. package/dist/components/PanelDrawer/panel-editor-model.js +0 -133
  190. package/dist/components/PanelDrawer/panel-editor-model.js.map +0 -1
  191. package/dist/context/DashboardAppSlice.d.ts +0 -26
  192. package/dist/context/DashboardAppSlice.d.ts.map +0 -1
  193. package/dist/context/DashboardAppSlice.js.map +0 -1
  194. package/dist/context/DashboardProvider.d.ts +0 -36
  195. package/dist/context/DashboardProvider.d.ts.map +0 -1
  196. package/dist/context/DashboardProvider.js +0 -107
  197. package/dist/context/DashboardProvider.js.map +0 -1
  198. package/dist/context/LayoutsSlice.d.ts +0 -12
  199. package/dist/context/LayoutsSlice.d.ts.map +0 -1
  200. package/dist/context/LayoutsSlice.js +0 -43
  201. package/dist/context/LayoutsSlice.js.map +0 -1
@@ -12,40 +12,55 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
- import { Grid, FormControl, InputLabel, Select, MenuItem, TextField } from '@mui/material';
15
+ import { FormControl, FormHelperText, Grid, InputLabel, MenuItem, Select, TextField, Typography } from '@mui/material';
16
16
  import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
17
+ import { PluginKindSelect, PluginSpecEditor, usePluginEditor } from '@perses-dev/plugin-system';
17
18
  import { useLayouts } from '../../context';
18
- import { usePanelSpecState } from './panel-editor-model';
19
- import { PanelTypeSelect } from './PanelTypeSelect';
20
- import { PanelSpecEditor } from './PanelSpecEditor';
19
+ import { PanelPreview } from './PanelPreview';
21
20
  export function PanelEditorForm(props) {
21
+ var ref;
22
22
  const { initialValues , onSubmit } = props;
23
23
  const { layouts } = useLayouts();
24
24
  const [name, setName] = useState(initialValues.name);
25
25
  const [description, setDescription] = useState(initialValues.description);
26
- const [group, setGroup] = useState(initialValues.group);
26
+ const [groupIndex, setGroupIndex] = useState(initialValues.groupIndex);
27
27
  const [kind, setKind] = useState(initialValues.kind);
28
- const { spec , onSpecChange } = usePanelSpecState(kind, initialValues.spec);
28
+ const [spec, setSpec] = useState(initialValues.spec);
29
+ // Use common plugin editor logic even though we've split the inputs up in this form
30
+ const pluginEditor = usePluginEditor({
31
+ pluginType: 'Panel',
32
+ value: {
33
+ kind,
34
+ spec
35
+ },
36
+ onChange: (plugin)=>{
37
+ setKind(plugin.kind);
38
+ setSpec(plugin.spec);
39
+ }
40
+ });
29
41
  // Ignore string values (which would be an "empty" value from the Select) since we don't allow them to unset it
30
42
  const handleGroupChange = (e)=>{
31
43
  const { value } = e.target;
32
44
  if (typeof value === 'string') {
33
45
  return;
34
46
  }
35
- setGroup(value);
47
+ setGroupIndex(value);
36
48
  };
37
49
  const handleSubmit = (e)=>{
38
50
  e.preventDefault();
51
+ if (spec === undefined) {
52
+ throw new Error('Cannot submit without a plugin spec');
53
+ }
39
54
  const values = {
40
55
  name,
41
56
  description,
42
- group,
57
+ groupIndex,
43
58
  kind,
44
59
  spec
45
60
  };
46
61
  onSubmit(values);
47
62
  };
48
- var ref;
63
+ var _title, ref1;
49
64
  return /*#__PURE__*/ _jsx("form", {
50
65
  id: panelEditorFormId,
51
66
  onSubmit: handleSubmit,
@@ -58,7 +73,7 @@ export function PanelEditorForm(props) {
58
73
  xs: 8,
59
74
  children: /*#__PURE__*/ _jsx(TextField, {
60
75
  required: true,
61
- label: "Panel Name",
76
+ label: "Name",
62
77
  value: name,
63
78
  variant: "outlined",
64
79
  onChange: (e)=>setName(e.target.value)
@@ -77,15 +92,12 @@ export function PanelEditorForm(props) {
77
92
  required: true,
78
93
  labelId: "select-group",
79
94
  label: "Group",
80
- value: group !== null && group !== void 0 ? group : 0,
95
+ value: groupIndex !== null && groupIndex !== void 0 ? groupIndex : 0,
81
96
  onChange: handleGroupChange,
82
- children: layouts.map((layout, index)=>{
83
- var ref1;
84
- /*#__PURE__*/ return _jsx(MenuItem, {
97
+ children: layouts.map((layout, index)=>/*#__PURE__*/ _jsx(MenuItem, {
85
98
  value: index,
86
- children: (ref = (ref1 = layout.spec.display) === null || ref1 === void 0 ? void 0 : ref1.title) !== null && ref !== void 0 ? ref : `Group ${index + 1}`
87
- }, index);
88
- })
99
+ children: (_title = layout.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
100
+ }, index))
89
101
  })
90
102
  ]
91
103
  })
@@ -94,40 +106,70 @@ export function PanelEditorForm(props) {
94
106
  item: true,
95
107
  xs: 8,
96
108
  children: /*#__PURE__*/ _jsx(TextField, {
97
- label: "Panel Description",
109
+ label: "Description",
98
110
  value: description,
99
111
  variant: "outlined",
100
112
  onChange: (e)=>setDescription(e.target.value)
101
113
  })
102
114
  }),
103
- /*#__PURE__*/ _jsx(Grid, {
115
+ /*#__PURE__*/ _jsxs(Grid, {
104
116
  item: true,
105
117
  xs: 4,
106
- children: /*#__PURE__*/ _jsxs(FormControl, {
107
- children: [
108
- /*#__PURE__*/ _jsx(InputLabel, {
109
- id: "panel-type-label",
110
- children: "Panel Type"
111
- }),
112
- /*#__PURE__*/ _jsx(PanelTypeSelect, {
113
- required: true,
114
- labelId: "panel-type-label",
115
- label: "Panel Type",
116
- value: kind,
117
- onChange: (e)=>setKind(e.target.value)
118
+ children: [
119
+ /*#__PURE__*/ _jsxs(FormControl, {
120
+ disabled: pluginEditor.isLoading,
121
+ error: pluginEditor.error !== null,
122
+ children: [
123
+ /*#__PURE__*/ _jsx(InputLabel, {
124
+ id: "panel-type-label",
125
+ children: "Type"
126
+ }),
127
+ /*#__PURE__*/ _jsx(PluginKindSelect, {
128
+ pluginType: "Panel",
129
+ required: true,
130
+ labelId: "panel-type-label",
131
+ label: "Type",
132
+ value: pluginEditor.pendingKind ? pluginEditor.pendingKind : kind,
133
+ onChange: pluginEditor.onKindChange
134
+ })
135
+ ]
136
+ }),
137
+ /*#__PURE__*/ _jsx(FormHelperText, {
138
+ children: (ref1 = (ref = pluginEditor.error) === null || ref === void 0 ? void 0 : ref.message) !== null && ref1 !== void 0 ? ref1 : ''
139
+ })
140
+ ]
141
+ }),
142
+ /*#__PURE__*/ _jsxs(Grid, {
143
+ item: true,
144
+ xs: 12,
145
+ children: [
146
+ /*#__PURE__*/ _jsx(Typography, {
147
+ variant: "h4",
148
+ marginBottom: 1,
149
+ children: "Preview"
150
+ }),
151
+ /*#__PURE__*/ _jsx(ErrorBoundary, {
152
+ FallbackComponent: ErrorAlert,
153
+ children: /*#__PURE__*/ _jsx(PanelPreview, {
154
+ kind: kind,
155
+ name: name,
156
+ description: description,
157
+ spec: spec,
158
+ groupIndex: groupIndex
118
159
  })
119
- ]
120
- })
160
+ })
161
+ ]
121
162
  }),
122
163
  /*#__PURE__*/ _jsx(Grid, {
123
164
  item: true,
124
165
  xs: 12,
125
166
  children: /*#__PURE__*/ _jsx(ErrorBoundary, {
126
167
  FallbackComponent: ErrorAlert,
127
- children: spec !== undefined && /*#__PURE__*/ _jsx(PanelSpecEditor, {
128
- panelPluginKind: kind,
168
+ children: /*#__PURE__*/ _jsx(PluginSpecEditor, {
169
+ pluginType: "Panel",
170
+ pluginKind: kind,
129
171
  value: spec,
130
- onChange: onSpecChange
172
+ onChange: pluginEditor.onSpecChange
131
173
  })
132
174
  })
133
175
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEventHandler, useState } from 'react';\nimport { Grid, FormControl, InputLabel, Select, MenuItem, TextField, SelectProps } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { useLayouts } from '../../context';\nimport { PanelEditorFormValues, usePanelSpecState } from './panel-editor-model';\nimport { PanelTypeSelect } from './PanelTypeSelect';\nimport { PanelSpecEditor } from './PanelSpecEditor';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorFormValues;\n onSubmit: (values: PanelEditorFormValues) => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const { initialValues, onSubmit } = props;\n\n const { layouts } = useLayouts();\n\n const [name, setName] = useState(initialValues.name);\n const [description, setDescription] = useState(initialValues.description);\n const [group, setGroup] = useState(initialValues.group);\n const [kind, setKind] = useState(initialValues.kind);\n const { spec, onSpecChange } = usePanelSpecState(kind, initialValues.spec);\n\n // Ignore string values (which would be an \"empty\" value from the Select) since we don't allow them to unset it\n const handleGroupChange: SelectProps<number>['onChange'] = (e) => {\n const { value } = e.target;\n if (typeof value === 'string') {\n return;\n }\n setGroup(value);\n };\n\n const handleSubmit: FormEventHandler = (e) => {\n e.preventDefault();\n const values: PanelEditorFormValues = { name, description, group, kind, spec };\n onSubmit(values);\n };\n\n return (\n <form id={panelEditorFormId} onSubmit={handleSubmit}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <TextField\n required\n label=\"Panel Name\"\n value={name}\n variant=\"outlined\"\n onChange={(e) => setName(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl>\n <InputLabel id=\"select-group\">Group</InputLabel>\n <Select required labelId=\"select-group\" label=\"Group\" value={group ?? 0} onChange={handleGroupChange}>\n {layouts.map((layout, index) => (\n <MenuItem key={index} value={index}>\n {layout.spec.display?.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n <Grid item xs={8}>\n <TextField\n label=\"Panel Description\"\n value={description}\n variant=\"outlined\"\n onChange={(e) => setDescription(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl>\n <InputLabel id=\"panel-type-label\">Panel Type</InputLabel>\n <PanelTypeSelect\n required\n labelId=\"panel-type-label\"\n label=\"Panel Type\"\n value={kind}\n onChange={(e) => setKind(e.target.value)}\n />\n </FormControl>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {/* Wait until we have some proper initial spec values before rendering the editor */}\n {spec !== undefined && <PanelSpecEditor panelPluginKind={kind} value={spec} onChange={onSpecChange} />}\n </ErrorBoundary>\n </Grid>\n </Grid>\n </form>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useState","Grid","FormControl","InputLabel","Select","MenuItem","TextField","ErrorAlert","ErrorBoundary","useLayouts","usePanelSpecState","PanelTypeSelect","PanelSpecEditor","PanelEditorForm","props","initialValues","onSubmit","layouts","name","setName","description","setDescription","group","setGroup","kind","setKind","spec","onSpecChange","handleGroupChange","e","value","target","handleSubmit","preventDefault","values","layout","form","id","panelEditorFormId","container","spacing","item","xs","required","label","variant","onChange","labelId","map","index","display","title","FallbackComponent","undefined","panelPluginKind"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAA2BA,QAAQ,QAAQ,OAAO,CAAC;AACnD,SAASC,IAAI,EAAEC,WAAW,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,SAAS,QAAqB,eAAe,CAAC;AACxG,SAASC,UAAU,EAAEC,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cesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEventHandler, useState } from 'react';\nimport {\n FormControl,\n FormHelperText,\n Grid,\n InputLabel,\n MenuItem,\n Select,\n SelectProps,\n TextField,\n Typography,\n} from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PluginKindSelect, PluginSpecEditor, usePluginEditor } from '@perses-dev/plugin-system';\nimport { useLayouts } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editing-slice';\nimport { PanelPreview } from './PanelPreview';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n onSubmit: (values: PanelEditorValues) => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const { initialValues, onSubmit } = props;\n\n const { layouts } = useLayouts();\n\n const [name, setName] = useState(initialValues.name);\n const [description, setDescription] = useState(initialValues.description);\n const [groupIndex, setGroupIndex] = useState(initialValues.groupIndex);\n const [kind, setKind] = useState(initialValues.kind);\n const [spec, setSpec] = useState(initialValues.spec);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind, spec },\n onChange: (plugin) => {\n setKind(plugin.kind);\n setSpec(plugin.spec);\n },\n });\n\n // Ignore string values (which would be an \"empty\" value from the Select) since we don't allow them to unset it\n const handleGroupChange: SelectProps<number>['onChange'] = (e) => {\n const { value } = e.target;\n if (typeof value === 'string') {\n return;\n }\n setGroupIndex(value);\n };\n\n const handleSubmit: FormEventHandler = (e) => {\n e.preventDefault();\n if (spec === undefined) {\n throw new Error('Cannot submit without a plugin spec');\n }\n const values: PanelEditorValues = { name, description, groupIndex, kind, spec };\n onSubmit(values);\n };\n\n return (\n <form id={panelEditorFormId} onSubmit={handleSubmit}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <TextField required label=\"Name\" value={name} variant=\"outlined\" onChange={(e) => setName(e.target.value)} />\n </Grid>\n <Grid item xs={4}>\n <FormControl>\n <InputLabel id=\"select-group\">Group</InputLabel>\n <Select required labelId=\"select-group\" label=\"Group\" value={groupIndex ?? 0} onChange={handleGroupChange}>\n {layouts.map((layout, index) => (\n <MenuItem key={index} value={index}>\n {layout.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n <Grid item xs={8}>\n <TextField\n label=\"Description\"\n value={description}\n variant=\"outlined\"\n onChange={(e) => setDescription(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl disabled={pluginEditor.isLoading} error={pluginEditor.error !== null}>\n <InputLabel id=\"panel-type-label\">Type</InputLabel>\n <PluginKindSelect\n pluginType=\"Panel\"\n required\n labelId=\"panel-type-label\"\n label=\"Type\"\n value={pluginEditor.pendingKind ? pluginEditor.pendingKind : kind}\n onChange={pluginEditor.onKindChange}\n />\n </FormControl>\n <FormHelperText>{pluginEditor.error?.message ?? ''}</FormHelperText>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview kind={kind} name={name} description={description} spec={spec} groupIndex={groupIndex} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PluginSpecEditor pluginType=\"Panel\" pluginKind={kind} value={spec} onChange={pluginEditor.onSpecChange} />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </form>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useState","FormControl","FormHelperText","Grid","InputLabel","MenuItem","Select","TextField","Typography","ErrorAlert","ErrorBoundary","PluginKindSelect","PluginSpecEditor","usePluginEditor","useLayouts","PanelPreview","PanelEditorForm","props","pluginEditor","initialValues","onSubmit","layouts","name","setName","description","setDescription","groupIndex","setGroupIndex","kind","setKind","spec","setSpec","pluginType","value","onChange","plugin","handleGroupChange","e","target","handleSubmit","preventDefault","undefined","Error","values","layout","form","id","panelEditorFormId","container","spacing","item","xs","required","label","variant","labelId","map","index","title","disabled","isLoading","error","pendingKind","onKindChange","message","marginBottom","FallbackComponent","pluginKind","onSpecChange"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAA2BA,QAAQ,QAAQ,OAAO,CAAC;AACnD,SACEC,WAAW,EACXC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,MAAM,EAENC,SAAS,EACTC,UAAU,QACL,eAAe,CAAC;AACvB,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,2BAA2B,CAAC;AAChG,SAASC,UAAU,QAAQ,eAAe,CAAC;AAE3C,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;QA6ElCC,GAAkB;IA5E3C,MAAM,EAAEC,aAAa,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAE1C,MAAM,EAAEI,OAAO,CAAA,EAAE,GAAGP,UAAU,EAAE,AAAC;IAEjC,MAAM,CAACQ,IAAI,EAAEC,OAAO,CAAC,GAAGvB,QAAQ,CAACmB,aAAa,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AAEA,IAAI;gCAAEN,IAAI,EAAEA,IAAI;gCAAEE,WAAW,EAAEA,WAAW;gCAAEM,IAAI,EAAEA,IAAI;gCAAEJ,UAAU,EAAEA,UAAU;8BAAI;0BACxF;;kBACX;8BACP,KAACvB,IAAI;oBAAC+C,IAAI;oBAACC,EAAE,EAAE,EAAE;8BACf,cAAA,KAACzC,aAAa;wBAACwD,iBAAiB,EAAEzD,UAAU;kCAC1C,cAAA,KAACG,gBAAgB;4BAACoB,UAAU,EAAC,OAAO;4BAACmC,UAAU,EAAEvC,IAAI;4BAAEK,KAAK,EAAEH,IAAI;4BAAEI,QAAQ,EAAEhB,YAAY,CAACkD,YAAY;0BAAI;sBAC7F;kBACX;;UACF;MACF,CACP;AACJ,CAAC;AAED;;CAEC,GACD,OAAO,MAAMrB,iBAAiB,GAAG,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { PanelEditorValues } from '../../context/DashboardProvider/panel-editing-slice';
3
+ export declare function PanelPreview({ name, description, kind, spec, groupIndex }: PanelEditorValues): JSX.Element;
4
+ //# sourceMappingURL=PanelPreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAGxF,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,iBAAiB,eAwB5F"}
@@ -0,0 +1,42 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { Box } from '@mui/material';
15
+ import { Panel } from '../Panel';
16
+ export function PanelPreview({ name , description , kind , spec , groupIndex }) {
17
+ const previewValues = {
18
+ definition: {
19
+ kind: 'Panel',
20
+ spec: {
21
+ display: {
22
+ name,
23
+ description
24
+ },
25
+ plugin: {
26
+ kind,
27
+ spec
28
+ }
29
+ }
30
+ },
31
+ groupIndex,
32
+ itemIndex: 0
33
+ };
34
+ return /*#__PURE__*/ _jsx(Box, {
35
+ height: 300,
36
+ children: /*#__PURE__*/ _jsx(Panel, {
37
+ ...previewValues
38
+ })
39
+ });
40
+ }
41
+
42
+ //# sourceMappingURL=PanelPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editing-slice';\nimport { Panel, PanelProps } from '../Panel';\n\nexport function PanelPreview({ name, description, kind, spec, groupIndex }: PanelEditorValues) {\n const previewValues: PanelProps = {\n definition: {\n kind: 'Panel',\n spec: {\n display: {\n name,\n description,\n },\n plugin: {\n kind,\n spec,\n },\n },\n },\n groupIndex,\n itemIndex: 0, // TODO: what should itemIndex be?\n };\n\n return (\n <Box height={300}>\n <Panel {...previewValues} />\n </Box>\n );\n}\n"],"names":["Box","Panel","PanelPreview","name","description","kind","spec","groupIndex","previewValues","definition","display","plugin","itemIndex","height"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AAEpC,SAASC,KAAK,QAAoB,UAAU,CAAC;AAE7C,OAAO,SAASC,YAAY,CAAC,EAAEC,IAAI,CAAA,EAAEC,WAAW,CAAA,EAAEC,IAAI,CAAA,EAAEC,IAAI,CAAA,EAAEC,UAAU,CAAA,EAAqB,EAAE;IAC7F,MAAMC,aAAa,GAAe;QAChCC,UAAU,EAAE;YACVJ,IAAI,EAAE,OAAO;YACbC,IAAI,EAAE;gBACJI,OAAO,EAAE;oBACPP,IAAI;oBACJC,WAAW;iBACZ;gBACDO,MAAM,EAAE;oBACNN,IAAI;oBACJC,IAAI;iBACL;aACF;SACF;QACDC,UAAU;QACVK,SAAS,EAAE,CAAC;KACb,AAAC;IAEF,qBACE,KAACZ,GAAG;QAACa,MAAM,EAAE,GAAG;kBACd,cAAA,KAACZ,KAAK;YAAE,GAAGO,aAAa;UAAI;MACxB,CACN;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ declare const DeletePanelGroupDialog: () => JSX.Element;
3
+ export default DeletePanelGroupDialog;
4
+ //# sourceMappingURL=DeletePanelGroupDialog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeletePanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/DeletePanelGroupDialog.tsx"],"names":[],"mappings":";AAkBA,QAAA,MAAM,sBAAsB,mBA4C3B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -0,0 +1,75 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
15
+ import CloseIcon from 'mdi-material-ui/Close';
16
+ import { usePanelGroupDialog, useLayouts } from '../../context';
17
+ const DeletePanelGroupDialog = ()=>{
18
+ var ref;
19
+ const { layouts , deletePanelGroup } = useLayouts();
20
+ const { deletePanelGroupDialog , closeDeletePanelGroupDialog } = usePanelGroupDialog();
21
+ const groupIndex = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.groupIndex;
22
+ const handleDelete = (e)=>{
23
+ e.preventDefault();
24
+ if (groupIndex == undefined) {
25
+ throw new Error('group index is undefined');
26
+ }
27
+ deletePanelGroup(groupIndex);
28
+ closeDeletePanelGroupDialog();
29
+ };
30
+ return /*#__PURE__*/ _jsxs(Dialog, {
31
+ open: deletePanelGroupDialog !== undefined,
32
+ children: [
33
+ /*#__PURE__*/ _jsx(DialogTitle, {
34
+ children: "Delete Panel Group"
35
+ }),
36
+ /*#__PURE__*/ _jsx(IconButton, {
37
+ "aria-label": "Close",
38
+ onClick: ()=>closeDeletePanelGroupDialog(),
39
+ sx: (theme)=>({
40
+ position: 'absolute',
41
+ top: theme.spacing(0.5),
42
+ right: theme.spacing(0.5)
43
+ }),
44
+ children: /*#__PURE__*/ _jsx(CloseIcon, {})
45
+ }),
46
+ /*#__PURE__*/ _jsxs("form", {
47
+ onSubmit: handleDelete,
48
+ children: [
49
+ /*#__PURE__*/ _jsx(DialogContent, {
50
+ sx: {
51
+ width: '500px'
52
+ },
53
+ children: `Are you sure you want to delete ${groupIndex !== undefined && layouts[groupIndex] !== undefined ? (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.title : 'panel group'}? This will delete all the panels within the group.`
54
+ }),
55
+ /*#__PURE__*/ _jsxs(DialogActions, {
56
+ children: [
57
+ /*#__PURE__*/ _jsx(Button, {
58
+ variant: "contained",
59
+ type: "submit",
60
+ children: "Delete"
61
+ }),
62
+ /*#__PURE__*/ _jsx(Button, {
63
+ onClick: ()=>closeDeletePanelGroupDialog(),
64
+ children: "Cancel"
65
+ })
66
+ ]
67
+ })
68
+ ]
69
+ })
70
+ ]
71
+ });
72
+ };
73
+ export default DeletePanelGroupDialog;
74
+
75
+ //# sourceMappingURL=DeletePanelGroupDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/PanelGroupDialog/DeletePanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { usePanelGroupDialog, useLayouts } from '../../context';\n\nconst DeletePanelGroupDialog = () => {\n const { layouts, deletePanelGroup } = useLayouts();\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog } = usePanelGroupDialog();\n\n const groupIndex = deletePanelGroupDialog?.groupIndex;\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n if (groupIndex == undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(groupIndex);\n closeDeletePanelGroupDialog();\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <DialogTitle>Delete Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>\n {`Are you sure you want to delete ${\n groupIndex !== undefined && layouts[groupIndex] !== undefined ? layouts[groupIndex]?.title : 'panel group'\n }? This will delete all the panels within the group.`}\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelGroupDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n\nexport default DeletePanelGroupDialog;\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","usePanelGroupDialog","useLayouts","DeletePanelGroupDialog","layouts","deletePanelGroup","deletePanelGroupDialog","closeDeletePanelGroupDialog","groupIndex","handleDelete","e","preventDefault","undefined","Error","open","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","width","title","variant","type"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,mBAAmB,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAEhE,MAAMC,sBAAsB,GAAG,IAAM;QAgCuCC,GAAmB;IA/B7F,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A,GAAmB,GAAnBA,OAAO,CAACI,UAAU,CAAC,cAAnBJ,GAAmB,WAAO,GAA1BA,KAAAA,CAA0B,GAA1BA,GAAmB,CAAEsB,KAAK,GAAG,aAAa,CAC3G,mDAAmD,CAAC;sBACvC;kCAChB,MAAC5B,aAAa;;0CACZ,KAACC,MAAM;gCAAC4B,OAAO,EAAC,WAAW;gCAACC,IAAI,EAAC,QAAQ;0CAAC,QAE1C;8BAAS;0CACT,KAAC7B,MAAM;gCAACiB,OAAO,EAAE,IAAMT,2BAA2B,EAAE;0CAAE,QAAM;8BAAS;;sBACvD;;cACX;;MACA,CACT;AACJ,CAAC,AAAC;AAEF,eAAeJ,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"names":[],"mappings":";AAkCA,QAAA,MAAM,gBAAgB,mBA2FrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"PanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"names":[],"mappings":";AAkCA,QAAA,MAAM,gBAAgB,mBAkFrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -14,32 +14,25 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
15
  import { IconButton, Dialog, DialogTitle, DialogContent, FormControl, InputLabel, TextField, Stack, Box, DialogActions, Button, Select, MenuItem } from '@mui/material';
16
16
  import CloseIcon from 'mdi-material-ui/Close';
17
- import { useDashboardApp, useLayouts } from '../../context';
17
+ import { usePanelGroupDialog, useLayouts } from '../../context';
18
18
  const PanelGroupDialog = ()=>{
19
- var ref, ref1, ref2, ref3, ref4;
20
- const { layouts , updateLayout } = useLayouts();
21
- const { panelGroupDialog , closePanelGroupDialog } = useDashboardApp();
19
+ var ref, ref1;
20
+ const { layouts , updatePanelGroup } = useLayouts();
21
+ const { panelGroupDialog , closePanelGroupDialog } = usePanelGroupDialog();
22
22
  const groupIndex = panelGroupDialog === null || panelGroupDialog === void 0 ? void 0 : panelGroupDialog.groupIndex;
23
23
  const isEditingPanelGroup = groupIndex !== undefined;
24
- const [isCollapsed, setIsCollapsed] = useState(isEditingPanelGroup && !((ref1 = (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.spec.display) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.collapse) === null || ref2 === void 0 ? void 0 : ref2.open));
25
- const [name, setName] = useState(isEditingPanelGroup ? (ref4 = (ref3 = layouts[groupIndex]) === null || ref3 === void 0 ? void 0 : ref3.spec.display) === null || ref4 === void 0 ? void 0 : ref4.title : '');
24
+ const [isCollapsed, setIsCollapsed] = useState(isEditingPanelGroup && ((ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.isCollapsed));
25
+ const [name, setName] = useState(isEditingPanelGroup ? (ref1 = layouts[groupIndex]) === null || ref1 === void 0 ? void 0 : ref1.title : '');
26
26
  const handleSubmit = (e)=>{
27
27
  var ref;
28
28
  e.preventDefault();
29
- var _items;
30
- const newLayout = {
31
- kind: 'Grid',
32
- spec: {
33
- display: {
34
- title: name !== null && name !== void 0 ? name : '',
35
- collapse: {
36
- open: !isCollapsed
37
- }
38
- },
39
- items: groupIndex === undefined ? [] : (_items = (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.spec.items) !== null && _items !== void 0 ? _items : []
40
- }
29
+ var ref1;
30
+ const newGroup = {
31
+ isCollapsed,
32
+ title: name !== null && name !== void 0 ? name : '',
33
+ items: groupIndex === undefined ? [] : (ref1 = (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.items) !== null && ref1 !== void 0 ? ref1 : []
41
34
  };
42
- updateLayout(newLayout, groupIndex);
35
+ updatePanelGroup(newGroup, groupIndex);
43
36
  closePanelGroupDialog();
44
37
  };
45
38
  const handleSelectCollapsedStateChange = (e)=>{
@@ -47,7 +40,7 @@ const PanelGroupDialog = ()=>{
47
40
  setIsCollapsed(isCollapsed);
48
41
  };
49
42
  return /*#__PURE__*/ _jsxs(Dialog, {
50
- open: true,
43
+ open: panelGroupDialog !== undefined,
51
44
  children: [
52
45
  /*#__PURE__*/ _jsx(DialogTitle, {
53
46
  children: "Panel Group"
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent, useState } from 'react';\nimport {\n IconButton,\n Dialog,\n DialogTitle,\n DialogContent,\n FormControl,\n InputLabel,\n TextField,\n Stack,\n Box,\n DialogActions,\n Button,\n Select,\n SelectChangeEvent,\n MenuItem,\n} from '@mui/material';\nimport { LayoutDefinition } from '@perses-dev/core';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDashboardApp, useLayouts } from '../../context';\n\nconst PanelGroupDialog = () => {\n const { layouts, updateLayout } = useLayouts();\n const { panelGroupDialog, closePanelGroupDialog } = useDashboardApp();\n\n const groupIndex = panelGroupDialog?.groupIndex;\n\n const isEditingPanelGroup = groupIndex !== undefined;\n\n const [isCollapsed, setIsCollapsed] = useState(\n isEditingPanelGroup && !layouts[groupIndex]?.spec.display?.collapse?.open\n );\n const [name, setName] = useState(isEditingPanelGroup ? layouts[groupIndex]?.spec.display?.title : '');\n\n const handleSubmit = (e: FormEvent) => {\n e.preventDefault();\n const newLayout: LayoutDefinition = {\n kind: 'Grid',\n spec: {\n display: {\n title: name ?? '',\n collapse: {\n open: !isCollapsed,\n },\n },\n items: groupIndex === undefined ? [] : layouts[groupIndex]?.spec.items ?? [],\n },\n };\n updateLayout(newLayout, groupIndex);\n closePanelGroupDialog();\n };\n\n const handleSelectCollapsedStateChange = (e: SelectChangeEvent<string>) => {\n const isCollapsed = e.target.value === 'Close';\n setIsCollapsed(isCollapsed);\n };\n\n return (\n <Dialog open>\n <DialogTitle>Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleSubmit}>\n <DialogContent sx={{ width: '500px' }}>\n <Stack spacing={2}>\n <FormControl>\n <TextField\n required\n label=\"Name\"\n variant=\"outlined\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n />\n </FormControl>\n <Box sx={{ display: 'flex', alignItems: 'center', width: '100%', justifyContent: 'space-between' }}>\n <InputLabel>Collapse State</InputLabel>\n <Select\n required\n displayEmpty\n labelId=\"select-collapse-state\"\n size=\"small\"\n value={isCollapsed ? 'Close' : 'Open'}\n onChange={handleSelectCollapsedStateChange}\n >\n <MenuItem key={'open'} value={'Open'}>\n Open\n </MenuItem>\n <MenuItem key={'close'} value={'Close'}>\n Close\n </MenuItem>\n </Select>\n </Box>\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n {isEditingPanelGroup ? 'Apply' : 'Add'}\n </Button>\n <Button onClick={() => closePanelGroupDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n\nexport default PanelGroupDialog;\n"],"names":["useState","IconButton","Dialog","DialogTitle","DialogContent","FormControl","InputLabel","TextField","Stack","Box","DialogActions","Button","Select","MenuItem","CloseIcon","useDashboardApp","useLayouts","PanelGroupDialog","layouts","updateLayout","panelGroupDialog","closePanelGroupDialog","groupIndex","isEditingPanelGroup","undefined","isCollapsed","setIsCollapsed","spec","display","collapse","open","name","setName","title","handleSubmit","e","preventDefault","newLayout","kind","items","handleSelectCollapsedStateChange","target","value","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","width","required","label","variant","onChange","alignItems","justifyContent","displayEmpty","labelId","size","type"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAAoBA,QAAQ,QAAQ,OAAO,CAAC;AAC5C,SACEC,UAAU,EACVC,MAAM,EACNC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,KAAK,EACLC,GAAG,EACHC,aAAa,EACbC,MAAM,EACNC,MAAM,EAENC,QAAQ,QACH,eAAe,CAAC;AAEvB,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,eAAe,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAE5D,MAAMC,gBAAgB,GAAG,IAAM;QASHC,GAAmB,cAEUA,IAAmB;IAV1E,MAAM,EAAEA,OAAO,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGH,UAAU,EAAE,AAAC;IAC/C,MAAM,EAAEI,gBAAgB,CAAA,EAAEC,qBAAqB,CAAA,EAAE,GAAGN,eAAe,EAAE,AAAC;IAEtE,MAAMO,UAAU,GAAGF,gBAAgB,aAAhBA,gBAAgB,WAAY,GAA5BA,KAAAA,CAA4B,GAA5BA,gBAAgB,CAAEE,UAAU,AAAC;IAEhD,MAAMC,mBAAmB,GAAGD,UAAU,KAAKE,SAAS,AAAC;IAErD,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAG1B,QAAQ,CAC5CuB,mBAAmB,IAAI,CAACL,CAAAA,QAAAA,CAAAA,GAAmB,GAAnBA,OAAO,CAACI,UAAU,CAAC,cAAnBJ,GAAmB,WAA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4CACZC,OAAO,EAAC,uBAAuB;4CAC/BC,IAAI,EAAC,OAAO;4CACZpB,KAAK,EAAEjB,WAAW,GAAG,OAAO,GAAG,MAAM;4CACrCgC,QAAQ,EAAEjB,gCAAgC;;8DAE1C,KAAC3B,QAAQ;oDAAc6B,KAAK,EAAE,MAAM;8DAAE,MAEtC;mDAFe,MAAM,CAEV;8DACX,KAAC7B,QAAQ;oDAAe6B,KAAK,EAAE,OAAO;8DAAE,OAExC;mDAFe,OAAO,CAEX;;0CACJ;;kCACL;;0BACA;sBACM;kCAChB,MAAChC,aAAa;;0CACZ,KAACC,MAAM;gCAAC6C,OAAO,EAAC,WAAW;gCAACO,IAAI,EAAC,QAAQ;0CACtCxC,mBAAmB,GAAG,OAAO,GAAG,KAAK;8BAC/B;0CACT,KAACZ,MAAM;gCAACiC,OAAO,EAAE,IAAMvB,qBAAqB,EAAE;0CAAE,QAAM;8BAAS;;sBACjD;;cACX;;MACA,CACT;AACJ,CAAC,AAAC;AAEF,eAAeJ,gBAAgB,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent, useState } from 'react';\nimport {\n IconButton,\n Dialog,\n DialogTitle,\n DialogContent,\n FormControl,\n InputLabel,\n TextField,\n Stack,\n Box,\n DialogActions,\n Button,\n Select,\n SelectChangeEvent,\n MenuItem,\n} from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { usePanelGroupDialog, useLayouts } from '../../context';\nimport { PanelGroupDefinition } from '../../context/DashboardProvider/layout-slice';\n\nconst PanelGroupDialog = () => {\n const { layouts, updatePanelGroup } = useLayouts();\n const { panelGroupDialog, closePanelGroupDialog } = usePanelGroupDialog();\n\n const groupIndex = panelGroupDialog?.groupIndex;\n\n const isEditingPanelGroup = groupIndex !== undefined;\n\n const [isCollapsed, setIsCollapsed] = useState(isEditingPanelGroup && layouts[groupIndex]?.isCollapsed);\n const [name, setName] = useState(isEditingPanelGroup ? layouts[groupIndex]?.title : '');\n\n const handleSubmit = (e: FormEvent) => {\n e.preventDefault();\n const newGroup: Omit<PanelGroupDefinition, 'id'> = {\n isCollapsed,\n title: name ?? '',\n items: groupIndex === undefined ? [] : layouts[groupIndex]?.items ?? [],\n };\n updatePanelGroup(newGroup, groupIndex);\n closePanelGroupDialog();\n };\n\n const handleSelectCollapsedStateChange = (e: SelectChangeEvent<string>) => {\n const isCollapsed = e.target.value === 'Close';\n setIsCollapsed(isCollapsed);\n };\n\n return (\n <Dialog open={panelGroupDialog !== undefined}>\n <DialogTitle>Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleSubmit}>\n <DialogContent sx={{ width: '500px' }}>\n <Stack spacing={2}>\n <FormControl>\n <TextField\n required\n label=\"Name\"\n variant=\"outlined\"\n value={name}\n onChange={(e) => setName(e.target.value)}\n />\n </FormControl>\n <Box sx={{ display: 'flex', alignItems: 'center', width: '100%', justifyContent: 'space-between' }}>\n <InputLabel>Collapse State</InputLabel>\n <Select\n required\n displayEmpty\n labelId=\"select-collapse-state\"\n size=\"small\"\n value={isCollapsed ? 'Close' : 'Open'}\n onChange={handleSelectCollapsedStateChange}\n >\n <MenuItem key={'open'} value={'Open'}>\n Open\n </MenuItem>\n <MenuItem key={'close'} value={'Close'}>\n Close\n </MenuItem>\n </Select>\n </Box>\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n {isEditingPanelGroup ? 'Apply' : 'Add'}\n </Button>\n <Button onClick={() => closePanelGroupDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n\nexport default PanelGroupDialog;\n"],"names":["useState","IconButton","Dialog","DialogTitle","DialogContent","FormControl","InputLabel","TextField","Stack","Box","DialogActions","Button","Select","MenuItem","CloseIcon","usePanelGroupDialog","useLayouts","PanelGroupDialog","layouts","updatePanelGroup","panelGroupDialog","closePanelGroupDialog","groupIndex","isEditingPanelGroup","undefined","isCollapsed","setIsCollapsed","name","setName","title","handleSubmit","e","preventDefault","newGroup","items","handleSelectCollapsedStateChange","target","value","open","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","width","required","label","variant","onChange","display","alignItems","justifyContent","displayEmpty","labelId","size","type"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAAoBA,QAAQ,QAAQ,OAAO,CAAC;AAC5C,SACEC,UAAU,EACVC,MAAM,EACNC,WAAW,EACXC,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,KAAK,EACLC,GAAG,EACHC,aAAa,EACbC,MAAM,EACNC,MAAM,EAENC,QAAQ,QACH,eAAe,CAAC;AACvB,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,mBAAmB,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAGhE,MAAMC,gBAAgB,GAAG,IAAM;QAQyCC,GAAmB,EAClCA,IAAmB;IAR1E,MAAM,EAAEA,OAAO,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGH,UAAU,EAAE,AAAC;IACnD,MAAM,EAAEI,gBAA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,eAAe;qCAAE;;sDAChG,KAAClD,UAAU;sDAAC,gBAAc;0CAAa;sDACvC,MAACM,MAAM;4CACLsC,QAAQ;4CACRO,YAAY;4CACZC,OAAO,EAAC,uBAAuB;4CAC/BC,IAAI,EAAC,OAAO;4CACZtB,KAAK,EAAEZ,WAAW,GAAG,OAAO,GAAG,MAAM;4CACrC4B,QAAQ,EAAElB,gCAAgC;;8DAE1C,KAACtB,QAAQ;oDAAcwB,KAAK,EAAE,MAAM;8DAAE,MAEtC;mDAFe,MAAM,CAEV;8DACX,KAACxB,QAAQ;oDAAewB,KAAK,EAAE,OAAO;8DAAE,OAExC;mDAFe,OAAO,CAEX;;0CACJ;;kCACL;;0BACA;sBACM;kCAChB,MAAC3B,aAAa;;0CACZ,KAACC,MAAM;gCAACyC,OAAO,EAAC,WAAW;gCAACQ,IAAI,EAAC,QAAQ;0CACtCrC,mBAAmB,GAAG,OAAO,GAAG,KAAK;8BAC/B;0CACT,KAACZ,MAAM;gCAAC6B,OAAO,EAAE,IAAMnB,qBAAqB,EAAE;0CAAE,QAAM;8BAAS;;sBACjD;;cACX;;MACA,CACT;AACJ,CAAC,AAAC;AAEF,eAAeJ,gBAAgB,CAAC"}
@@ -16,6 +16,7 @@ import userEvent from '@testing-library/user-event';
16
16
  import { act } from 'react-dom/test-utils';
17
17
  import { DashboardProvider } from '../../context';
18
18
  import { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';
19
+ import testDashboard from '../../test/testDashboard';
19
20
  import PanelGroupDialog from './PanelGroupDialog';
20
21
  describe('Add Panel Group', ()=>{
21
22
  const renderDialog = ()=>{
@@ -37,7 +38,6 @@ describe('Add Panel Group', ()=>{
37
38
  return storeApi;
38
39
  };
39
40
  it('should add new panel group', async ()=>{
40
- // jest.spyOn(dashboardAppSlice, 'useDashboardApp').mockReturnValue(dashboardApp);
41
41
  const storeApi = renderDialog();
42
42
  // Open the dialog for a new panel group
43
43
  act(()=>storeApi.getState().openPanelGroupDialog());
@@ -46,19 +46,14 @@ describe('Add Panel Group', ()=>{
46
46
  userEvent.click(screen.getByText('Add'));
47
47
  const layouts = storeApi.getState().layouts;
48
48
  expect(layouts).toContainEqual({
49
- kind: 'Grid',
50
- spec: {
51
- display: {
52
- title: 'New Panel Group',
53
- collapse: {
54
- open: true
55
- }
56
- },
57
- items: []
58
- }
49
+ id: 3,
50
+ title: 'New Panel Group',
51
+ isCollapsed: false,
52
+ items: []
59
53
  });
60
54
  });
61
55
  it('should edit existing panel group', async ()=>{
56
+ var ref;
62
57
  const storeApi = renderDialog();
63
58
  // Open the dialog for an existing panel group
64
59
  act(()=>storeApi.getState().openPanelGroupDialog(0));
@@ -68,26 +63,10 @@ describe('Add Panel Group', ()=>{
68
63
  userEvent.click(screen.getByText('Apply'));
69
64
  const layouts = storeApi.getState().layouts;
70
65
  expect(layouts).toContainEqual({
71
- kind: 'Grid',
72
- spec: {
73
- display: {
74
- title: 'New Name',
75
- collapse: {
76
- open: true
77
- }
78
- },
79
- items: [
80
- {
81
- content: {
82
- $ref: '#/spec/panels/cpu'
83
- },
84
- height: 4,
85
- width: 12,
86
- x: 0,
87
- y: 0
88
- }
89
- ]
90
- }
66
+ id: 0,
67
+ title: 'New Name',
68
+ isCollapsed: false,
69
+ items: (ref = testDashboard.spec.layouts[0]) === null || ref === void 0 ? void 0 : ref.spec.items
91
70
  });
92
71
  });
93
72
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport { DashboardProvider } from '../../context';\nimport { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';\nimport PanelGroupDialog from './PanelGroupDialog';\n\ndescribe('Add Panel Group', () => {\n const renderDialog = () => {\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <DashboardProvider initialState={{ dashboardSpec: getTestDashboard().spec, isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelGroupDialog />\n </DashboardProvider>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel group', async () => {\n // jest.spyOn(dashboardAppSlice, 'useDashboardApp').mockReturnValue(dashboardApp);\n const storeApi = renderDialog();\n\n // Open the dialog for a new panel group\n act(() => storeApi.getState().openPanelGroupDialog());\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'New Panel Group');\n userEvent.click(screen.getByText('Add'));\n\n const layouts = storeApi.getState().layouts;\n expect(layouts).toContainEqual({\n kind: 'Grid',\n spec: {\n display: {\n title: 'New Panel Group',\n collapse: {\n open: true,\n },\n },\n items: [],\n },\n });\n });\n\n it('should edit existing panel group', async () => {\n const storeApi = renderDialog();\n\n // Open the dialog for an existing panel group\n act(() => storeApi.getState().openPanelGroupDialog(0));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.clear(nameInput);\n userEvent.type(nameInput, 'New Name');\n userEvent.click(screen.getByText('Apply'));\n\n const layouts = storeApi.getState().layouts;\n expect(layouts).toContainEqual({\n kind: 'Grid',\n spec: {\n display: {\n title: 'New Name',\n collapse: {\n open: true,\n },\n },\n items: [{ content: { $ref: '#/spec/panels/cpu' }, height: 4, width: 12, x: 0, y: 0 }],\n },\n });\n });\n});\n"],"names":["screen","userEvent","act","DashboardProvider","createDashboardProviderSpy","getTestDashboard","renderWithContext","PanelGroupDialog","describe","renderDialog","store","DashboardProviderSpy","initialState","dashboardSpec","spec","isEditMode","value","storeApi","undefined","Error","it","getState","openPanelGroupDialog","nameInput","findByLabelText","type","click","getByText","layouts","expect","toContainEqual","kind","display","title","collapse","open","items","clear","content","$ref","height","width","x","y"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,GAAG,QAAQ,sBAAsB,CAAC;AAC3C,SAASC,iBAAiB,QAAQ,eAAe,CAAC;AAClD,SAASC,0BAA0B,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAQ,YAAY,CAAC;AAC7F,OAAOC,gBAAgB,MAAM,oBAAoB,CAAC;AAElDC,QAAQ,CAAC,iBAAiB,EAAE,IAAM;IAChC,MAAMC,YAAY,GAAG,IAAM;QACzB,MAAM,EAAEC,KAAK,CAAA,EAAEC,oBAAoB,CAAA,EAAE,GAAGP,0BAA0B,EAAE,AAAC;QAErEE,iBAAiB,eACf,MAACH,iBAAiB;YAACS,YAAY,EAAE;gBAAEC,aAAa,EAAER,gBAAgB,EAAE,CAACS,IAAI;gBAAEC,UAAU,EAAE,IAAI;aAAE;;8BAC3F,KAACJ,oBAAoB,KAAG;8BACxB,KAACJ,gBAAgB,KAAG;;UACF,CACrB,CAAC;QAEF,MAAM,EAAES,KAAK,EAAEC,QAAQ,CAAA,EAAE,GAAGP,KAAK,AAAC;QAClC,IAAIO,QAAQ,KAAKC,SAAS,EAAE;YAC1B,MAAM,IAAIC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QAC7E,CAAC;QAED,OAAOF,QAAQ,CAAC;IAClB,CAAC,AAAC;IAEFG,EAAE,CAAC,4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C,OAAO,GAAGX,QAAQ,CAACI,QAAQ,EAAE,CAACO,OAAO,AAAC;QAC5CC,MAAM,CAACD,OAAO,CAAC,CAACE,cAAc,CAAC;YAC7BC,IAAI,EAAE,MAAM;YACZjB,IAAI,EAAE;gBACJkB,OAAO,EAAE;oBACPC,KAAK,EAAE,UAAU;oBACjBC,QAAQ,EAAE;wBACRC,IAAI,EAAE,IAAI;qBACX;iBACF;gBACDC,KAAK,EAAE;oBAAC;wBAAEE,OAAO,EAAE;4BAAEC,IAAI,EAAE,mBAAmB;yBAAE;wBAAEC,MAAM,EAAE,CAAC;wBAAEC,KAAK,EAAE,EAAE;wBAAEC,CAAC,EAAE,CAAC;wBAAEC,CAAC,EAAE,CAAC;qBAAE;iBAAC;aACtF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport { DashboardProvider } from '../../context';\nimport { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';\nimport testDashboard from '../../test/testDashboard';\nimport PanelGroupDialog from './PanelGroupDialog';\n\ndescribe('Add Panel Group', () => {\n const renderDialog = () => {\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <DashboardProvider initialState={{ dashboardSpec: getTestDashboard().spec, isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelGroupDialog />\n </DashboardProvider>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel group', async () => {\n const storeApi = renderDialog();\n\n // Open the dialog for a new panel group\n act(() => storeApi.getState().openPanelGroupDialog());\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'New Panel Group');\n userEvent.click(screen.getByText('Add'));\n\n const layouts = storeApi.getState().layouts;\n expect(layouts).toContainEqual({\n id: 3,\n title: 'New Panel Group',\n isCollapsed: false,\n items: [],\n });\n });\n\n it('should edit existing panel group', async () => {\n const storeApi = renderDialog();\n\n // Open the dialog for an existing panel group\n act(() => storeApi.getState().openPanelGroupDialog(0));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.clear(nameInput);\n userEvent.type(nameInput, 'New Name');\n userEvent.click(screen.getByText('Apply'));\n\n const layouts = storeApi.getState().layouts;\n expect(layouts).toContainEqual({\n id: 0,\n title: 'New Name',\n isCollapsed: false,\n items: testDashboard.spec.layouts[0]?.spec.items,\n });\n });\n});\n"],"names":["screen","userEvent","act","DashboardProvider","createDashboardProviderSpy","getTestDashboard","renderWithContext","testDashboard","PanelGroupDialog","describe","renderDialog","store","DashboardProviderSpy","initialState","dashboardSpec","spec","isEditMode","value","storeApi","undefined","Error","it","getState","openPanelGroupDialog","nameInput","findByLabelText","type","click","getByText","layouts","expect","toContainEqual","id","title","isCollapsed","items","clear"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,GAAG,QAAQ,sBAAsB,CAAC;A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