@perses-dev/dashboards 0.43.0 → 0.44.0-rc0

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 (269) hide show
  1. package/dist/cjs/components/AddGroupButton/AddGroupButton.js +1 -1
  2. package/dist/cjs/components/AddPanelButton/AddPanelButton.js +2 -2
  3. package/dist/cjs/components/Dashboard/Dashboard.js +1 -1
  4. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +3 -3
  5. package/dist/cjs/components/Datasources/DatasourceEditor.js +1 -1
  6. package/dist/cjs/components/Datasources/EditDatasourcesButton.js +3 -3
  7. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +4 -4
  8. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +1 -1
  9. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +1 -1
  10. package/dist/cjs/components/DownloadButton/DownloadButton.js +2 -2
  11. package/dist/cjs/components/EditButton/EditButton.js +1 -1
  12. package/dist/cjs/components/EditJsonButton/EditJsonButton.js +2 -2
  13. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +7 -7
  14. package/dist/cjs/components/EmptyDashboard/EmptyDashboard.js +3 -3
  15. package/dist/cjs/components/GridLayout/GridContainer.js +1 -1
  16. package/dist/cjs/components/GridLayout/GridItemContent.js +5 -5
  17. package/dist/cjs/components/GridLayout/GridLayout.js +4 -4
  18. package/dist/cjs/components/GridLayout/GridTitle.js +5 -5
  19. package/dist/cjs/components/Panel/Panel.js +3 -2
  20. package/dist/cjs/components/Panel/PanelContent.js +4 -3
  21. package/dist/cjs/components/Panel/PanelHeader.js +2 -2
  22. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +18 -15
  23. package/dist/cjs/components/PanelDrawer/PanelPreview.js +1 -1
  24. package/dist/cjs/components/PanelDrawer/usePanelEditor.js +2 -2
  25. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +1 -1
  26. package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +2 -2
  27. package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
  28. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +7 -7
  29. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +6 -6
  30. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +1 -1
  31. package/dist/cjs/components/Variables/BuiltinVariableAccordions.js +7 -6
  32. package/dist/cjs/components/Variables/EditVariablesButton.js +2 -2
  33. package/dist/cjs/components/Variables/TemplateVariable.js +20 -11
  34. package/dist/cjs/components/Variables/VariableEditor.js +13 -14
  35. package/dist/cjs/components/Variables/VariableList.js +1 -1
  36. package/dist/cjs/constants/styles.js +4 -4
  37. package/dist/cjs/constants/user-interface-text.js +3 -3
  38. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +10 -10
  39. package/dist/cjs/context/DashboardProvider/common.js +3 -3
  40. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +40 -40
  41. package/dist/cjs/context/DashboardProvider/delete-panel-group-slice.js +1 -1
  42. package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +3 -3
  43. package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  44. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +4 -6
  45. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +6 -6
  46. package/dist/cjs/context/DatasourceStoreProvider.js +8 -8
  47. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +81 -77
  48. package/dist/cjs/context/TemplateVariableProvider/query-params.js +7 -7
  49. package/dist/cjs/context/TemplateVariableProvider/utils.js +3 -3
  50. package/dist/cjs/context/useDashboard.js +3 -3
  51. package/dist/cjs/test/dashboard-provider.js +3 -3
  52. package/dist/cjs/test/datasource-provider.js +4 -4
  53. package/dist/cjs/test/render.js +1 -1
  54. package/dist/cjs/utils/panelUtils.js +5 -5
  55. package/dist/cjs/utils/time.js +1 -1
  56. package/dist/cjs/views/ViewDashboard/DashboardApp.js +5 -5
  57. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +3 -3
  58. package/dist/components/AddGroupButton/AddGroupButton.d.ts +1 -2
  59. package/dist/components/AddGroupButton/AddGroupButton.d.ts.map +1 -1
  60. package/dist/components/AddGroupButton/AddGroupButton.js +1 -1
  61. package/dist/components/AddGroupButton/AddGroupButton.js.map +1 -1
  62. package/dist/components/AddPanelButton/AddPanelButton.d.ts +1 -2
  63. package/dist/components/AddPanelButton/AddPanelButton.d.ts.map +1 -1
  64. package/dist/components/AddPanelButton/AddPanelButton.js +2 -2
  65. package/dist/components/AddPanelButton/AddPanelButton.js.map +1 -1
  66. package/dist/components/Dashboard/Dashboard.d.ts +2 -3
  67. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  68. package/dist/components/Dashboard/Dashboard.js +1 -1
  69. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  70. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts +1 -2
  71. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
  72. package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
  73. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +1 -1
  74. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  75. package/dist/components/DashboardToolbar/DashboardToolbar.js +3 -3
  76. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  77. package/dist/components/Datasources/DatasourceEditor.d.ts +1 -2
  78. package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -1
  79. package/dist/components/Datasources/DatasourceEditor.js +1 -1
  80. package/dist/components/Datasources/DatasourceEditor.js.map +1 -1
  81. package/dist/components/Datasources/EditDatasourcesButton.d.ts +1 -2
  82. package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -1
  83. package/dist/components/Datasources/EditDatasourcesButton.js +3 -3
  84. package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -1
  85. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts +1 -2
  86. package/dist/components/DeletePanelDialog/DeletePanelDialog.d.ts.map +1 -1
  87. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +4 -4
  88. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  89. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
  90. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  91. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +1 -1
  92. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  93. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +1 -2
  94. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
  95. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +1 -1
  96. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  97. package/dist/components/DownloadButton/DownloadButton.d.ts +1 -2
  98. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -1
  99. package/dist/components/DownloadButton/DownloadButton.js +2 -2
  100. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  101. package/dist/components/EditButton/EditButton.d.ts +1 -2
  102. package/dist/components/EditButton/EditButton.d.ts.map +1 -1
  103. package/dist/components/EditButton/EditButton.js +1 -1
  104. package/dist/components/EditButton/EditButton.js.map +1 -1
  105. package/dist/components/EditJsonButton/EditJsonButton.d.ts +1 -2
  106. package/dist/components/EditJsonButton/EditJsonButton.d.ts.map +1 -1
  107. package/dist/components/EditJsonButton/EditJsonButton.js +2 -2
  108. package/dist/components/EditJsonButton/EditJsonButton.js.map +1 -1
  109. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts +1 -2
  110. package/dist/components/EditJsonDialog/EditJsonDialog.d.ts.map +1 -1
  111. package/dist/components/EditJsonDialog/EditJsonDialog.js +7 -7
  112. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  113. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts +1 -1
  114. package/dist/components/EmptyDashboard/EmptyDashboard.d.ts.map +1 -1
  115. package/dist/components/EmptyDashboard/EmptyDashboard.js +3 -3
  116. package/dist/components/EmptyDashboard/EmptyDashboard.js.map +1 -1
  117. package/dist/components/GridLayout/GridContainer.d.ts +1 -1
  118. package/dist/components/GridLayout/GridContainer.d.ts.map +1 -1
  119. package/dist/components/GridLayout/GridContainer.js +1 -1
  120. package/dist/components/GridLayout/GridContainer.js.map +1 -1
  121. package/dist/components/GridLayout/GridItemContent.d.ts +1 -2
  122. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  123. package/dist/components/GridLayout/GridItemContent.js +5 -5
  124. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  125. package/dist/components/GridLayout/GridLayout.d.ts +1 -2
  126. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  127. package/dist/components/GridLayout/GridLayout.js +4 -4
  128. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  129. package/dist/components/GridLayout/GridTitle.d.ts +1 -2
  130. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  131. package/dist/components/GridLayout/GridTitle.js +5 -5
  132. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  133. package/dist/components/Panel/Panel.d.ts +2 -2
  134. package/dist/components/Panel/Panel.d.ts.map +1 -1
  135. package/dist/components/Panel/Panel.js +3 -2
  136. package/dist/components/Panel/Panel.js.map +1 -1
  137. package/dist/components/Panel/PanelContent.d.ts +3 -3
  138. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  139. package/dist/components/Panel/PanelContent.js +4 -3
  140. package/dist/components/Panel/PanelContent.js.map +1 -1
  141. package/dist/components/Panel/PanelHeader.d.ts +2 -2
  142. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  143. package/dist/components/Panel/PanelHeader.js +2 -2
  144. package/dist/components/Panel/PanelHeader.js.map +1 -1
  145. package/dist/components/PanelDrawer/PanelDrawer.d.ts +1 -2
  146. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  147. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  148. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -2
  149. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  150. package/dist/components/PanelDrawer/PanelEditorForm.js +18 -15
  151. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  152. package/dist/components/PanelDrawer/PanelPreview.d.ts +1 -2
  153. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  154. package/dist/components/PanelDrawer/PanelPreview.js +1 -1
  155. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  156. package/dist/components/PanelDrawer/usePanelEditor.js +2 -2
  157. package/dist/components/PanelDrawer/usePanelEditor.js.map +1 -1
  158. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +1 -2
  159. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  160. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  161. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -2
  162. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  163. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +1 -1
  164. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  165. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts +1 -2
  166. package/dist/components/QuerySummaryTable/QuerySummaryTable.d.ts.map +1 -1
  167. package/dist/components/QuerySummaryTable/QuerySummaryTable.js +2 -2
  168. package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
  169. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts +1 -2
  170. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
  171. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +4 -4
  172. package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
  173. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts +1 -2
  174. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  175. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +7 -7
  176. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  177. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +1 -2
  178. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  179. package/dist/components/TimeRangeControls/TimeRangeControls.js +3 -3
  180. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  181. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +2 -2
  182. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -1
  183. package/dist/components/ToolbarIconButton/ToolbarIconButton.js +1 -1
  184. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
  185. package/dist/components/Variables/BuiltinVariableAccordions.d.ts +2 -3
  186. package/dist/components/Variables/BuiltinVariableAccordions.d.ts.map +1 -1
  187. package/dist/components/Variables/BuiltinVariableAccordions.js +7 -6
  188. package/dist/components/Variables/BuiltinVariableAccordions.js.map +1 -1
  189. package/dist/components/Variables/EditVariablesButton.d.ts +1 -2
  190. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  191. package/dist/components/Variables/EditVariablesButton.js +2 -2
  192. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  193. package/dist/components/Variables/TemplateVariable.d.ts +2 -3
  194. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  195. package/dist/components/Variables/TemplateVariable.js +20 -11
  196. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  197. package/dist/components/Variables/VariableEditor.d.ts +2 -3
  198. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  199. package/dist/components/Variables/VariableEditor.js +13 -14
  200. package/dist/components/Variables/VariableEditor.js.map +1 -1
  201. package/dist/components/Variables/VariableList.d.ts +2 -3
  202. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  203. package/dist/components/Variables/VariableList.js +1 -1
  204. package/dist/components/Variables/VariableList.js.map +1 -1
  205. package/dist/context/DashboardProvider/DashboardProvider.d.ts +1 -1
  206. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  207. package/dist/context/DashboardProvider/DashboardProvider.js +7 -7
  208. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  209. package/dist/context/DashboardProvider/common.d.ts +2 -2
  210. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  211. package/dist/context/DashboardProvider/common.js.map +1 -1
  212. package/dist/context/DashboardProvider/dashboard-provider-api.js +15 -15
  213. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  214. package/dist/context/DashboardProvider/delete-panel-group-slice.js +1 -1
  215. package/dist/context/DashboardProvider/delete-panel-group-slice.js.map +1 -1
  216. package/dist/context/DashboardProvider/delete-panel-slice.js +3 -3
  217. package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
  218. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -1
  219. package/dist/context/DashboardProvider/duplicate-panel-slice.js +1 -1
  220. package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
  221. package/dist/context/DashboardProvider/edit-json-dialog-slice.js.map +1 -1
  222. package/dist/context/DashboardProvider/panel-editor-slice.js +4 -6
  223. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  224. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  225. package/dist/context/DashboardProvider/panel-group-slice.d.ts +2 -2
  226. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  227. package/dist/context/DashboardProvider/panel-group-slice.js +2 -2
  228. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  229. package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
  230. package/dist/context/DatasourceStoreProvider.d.ts +3 -3
  231. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  232. package/dist/context/DatasourceStoreProvider.js +8 -8
  233. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  234. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +6 -6
  235. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  236. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +70 -66
  237. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  238. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
  239. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  240. package/dist/context/TemplateVariableProvider/query-params.js.map +1 -1
  241. package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
  242. package/dist/context/useDashboard.js +3 -3
  243. package/dist/context/useDashboard.js.map +1 -1
  244. package/dist/stories/decorators/WithDashboard.js.map +1 -1
  245. package/dist/stories/decorators/WithDatasourceStore.js.map +1 -1
  246. package/dist/stories/decorators/WithTemplateVariables.js.map +1 -1
  247. package/dist/test/dashboard-provider.js.map +1 -1
  248. package/dist/test/datasource-provider.js.map +1 -1
  249. package/dist/test/render.js +1 -1
  250. package/dist/test/render.js.map +1 -1
  251. package/dist/test/setup-tests.js.map +1 -1
  252. package/dist/utils/panelUtils.d.ts +1 -1
  253. package/dist/utils/panelUtils.d.ts.map +1 -1
  254. package/dist/utils/panelUtils.js +2 -2
  255. package/dist/utils/panelUtils.js.map +1 -1
  256. package/dist/utils/time.js +1 -1
  257. package/dist/utils/time.js.map +1 -1
  258. package/dist/validation/panel.d.ts +1 -1
  259. package/dist/validation/panel.d.ts.map +1 -1
  260. package/dist/validation/panel.js.map +1 -1
  261. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -1
  262. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  263. package/dist/views/ViewDashboard/DashboardApp.js +5 -5
  264. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  265. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -2
  266. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  267. package/dist/views/ViewDashboard/ViewDashboard.js +3 -3
  268. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  269. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Variables/VariableList.tsx"],"sourcesContent":["// Copyright 2023 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 { VariableDefinition, VariableSpec } from '@perses-dev/core';\nimport {\n ExternalVariableDefinition,\n useTemplateExternalVariableDefinitions,\n useTemplateVariable,\n useTemplateVariableDefinitions,\n} from '../../context';\nimport { MAX_TEMPLATE_VARIABLE_WIDTH, MIN_TEMPLATE_VARIABLE_WIDTH } from '../../constants';\nimport { TemplateVariable } from './TemplateVariable';\n\nexport function TemplateVariableList() {\n const variableDefinitions: VariableDefinition[] = useTemplateVariableDefinitions();\n const externalVariableDefinitions: ExternalVariableDefinition[] = useTemplateExternalVariableDefinitions();\n\n return (\n <>\n {externalVariableDefinitions\n .slice()\n .reverse() // We reverse to have the most prioritized on top\n .map((def) =>\n def.definitions.map((v) => (\n <TemplateVariableListItem key={v.spec.name + def.source} spec={v.spec} source={def.source} />\n ))\n )}\n {variableDefinitions.map((v) => (\n <TemplateVariableListItem key={v.spec.name} spec={v.spec} />\n ))}\n </>\n );\n}\n\nexport function TemplateVariableListItem({ spec, source }: { spec: VariableSpec; source?: string }) {\n const ctx = useTemplateVariable(spec.name, source);\n return (\n <Box\n key={spec.name + source ?? ''}\n display={ctx.state?.overridden || spec.display?.hidden ? 'none' : undefined}\n minWidth={`${MIN_TEMPLATE_VARIABLE_WIDTH}px`}\n maxWidth={`${MAX_TEMPLATE_VARIABLE_WIDTH}px`}\n flexShrink={0}\n data-testid={'template-variable-' + spec.name}\n >\n <TemplateVariable key={spec.name + source ?? ''} name={spec.name} source={source} />\n </Box>\n );\n}\n"],"names":["Box","useTemplateExternalVariableDefinitions","useTemplateVariable","useTemplateVariableDefinitions","MAX_TEMPLATE_VARIABLE_WIDTH","MIN_TEMPLATE_VARIABLE_WIDTH","TemplateVariable","TemplateVariableList","variableDefinitions","externalVariableDefinitions","slice","reverse","map","def","definitions","v","TemplateVariableListItem","spec","source","name","ctx","display","state","overridden","hidden","undefined","minWidth","maxWidth","flexShrink","data-testid"],"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,SAASA,GAAG,QAAQ,gBAAgB;AAEpC,SAEEC,sCAAsC,EACtCC,mBAAmB,EACnBC,8BAA8B,QACzB,gBAAgB;AACvB,SAASC,2BAA2B,EAAEC,2BAA2B,QAAQ,kBAAkB;AAC3F,SAASC,gBAAgB,QAAQ,qBAAqB;AAEtD,OAAO,SAASC;IACd,MAAMC,sBAA4CL;IAClD,MAAMM,8BAA4DR;IAElE,qBACE;;YACGQ,4BACEC,QACAC,UAAU,iDAAiD;aAC3DC,IAAI,CAACC,MACJA,IAAIC,YAAYF,IAAI,CAACG,kBACnB,KAACC;wBAAwDC,MAAMF,EAAEE;wBAAMC,QAAQL,IAAIK;uBAApDH,EAAEE,KAAKE,OAAON,IAAIK;YAGtDV,oBAAoBI,IAAI,CAACG,kBACxB,KAACC;oBAA2CC,MAAMF,EAAEE;mBAArBF,EAAEE,KAAKE;;;AAI9C;AAEA,OAAO,SAASH,yBAAyB,EAAEC,KAAI,EAAEC,OAAM,EAA2C;QAKnFE,YAAyBH;IAJtC,MAAMG,MAAMlB,oBAAoBe,KAAKE,MAAMD;QAUhBD,MAPlBA;IAFT,qBACE,KAACjB;QAECqB,SAASD,CAAAA,CAAAA,aAAAA,IAAIE,mBAAJF,wBAAAA,KAAAA,IAAAA,WAAWG,UAAS,KAAKN,CAAAA,CAAAA,gBAAAA,KAAKI,qBAALJ,2BAAAA,KAAAA,IAAAA,cAAcO,MAAK,IAAI,SAASC;QAClEC,UAAU,CAAC,EAAErB,4BAA4B,EAAE,CAAC;QAC5CsB,UAAU,CAAC,EAAEvB,4BAA4B,EAAE,CAAC;QAC5CwB,YAAY;QACZC,eAAa,uBAAuBZ,KAAKE;kBAEzC,cAAA,KAACb;YAAgDa,MAAMF,KAAKE;YAAMD,QAAQA;WAAnDD,CAAAA,OAAAA,KAAKE,OAAOD,oBAAZD,kBAAAA,OAAsB;OAPxCA,CAAAA,QAAAA,KAAKE,OAAOD,oBAAZD,mBAAAA,QAAsB;AAUjC"}
1
+ {"version":3,"sources":["../../../src/components/Variables/VariableList.tsx"],"sourcesContent":["// Copyright 2023 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 { VariableDefinition, VariableSpec } from '@perses-dev/core';\nimport {\n ExternalVariableDefinition,\n useTemplateExternalVariableDefinitions,\n useTemplateVariable,\n useTemplateVariableDefinitions,\n} from '../../context';\nimport { MAX_TEMPLATE_VARIABLE_WIDTH, MIN_TEMPLATE_VARIABLE_WIDTH } from '../../constants';\nimport { TemplateVariable } from './TemplateVariable';\n\nexport function TemplateVariableList() {\n const variableDefinitions: VariableDefinition[] = useTemplateVariableDefinitions();\n const externalVariableDefinitions: ExternalVariableDefinition[] = useTemplateExternalVariableDefinitions();\n\n return (\n <>\n {externalVariableDefinitions\n .slice()\n .reverse() // We reverse to have the most prioritized on top\n .map((def) =>\n def.definitions.map((v) => (\n <TemplateVariableListItem key={v.spec.name + def.source} spec={v.spec} source={def.source} />\n ))\n )}\n {variableDefinitions.map((v) => (\n <TemplateVariableListItem key={v.spec.name} spec={v.spec} />\n ))}\n </>\n );\n}\n\nexport function TemplateVariableListItem({ spec, source }: { spec: VariableSpec; source?: string }) {\n const ctx = useTemplateVariable(spec.name, source);\n return (\n <Box\n key={spec.name + source ?? ''}\n display={ctx.state?.overridden || spec.display?.hidden ? 'none' : undefined}\n minWidth={`${MIN_TEMPLATE_VARIABLE_WIDTH}px`}\n maxWidth={`${MAX_TEMPLATE_VARIABLE_WIDTH}px`}\n flexShrink={0}\n data-testid={'template-variable-' + spec.name}\n >\n <TemplateVariable key={spec.name + source ?? ''} name={spec.name} source={source} />\n </Box>\n );\n}\n"],"names":["Box","useTemplateExternalVariableDefinitions","useTemplateVariable","useTemplateVariableDefinitions","MAX_TEMPLATE_VARIABLE_WIDTH","MIN_TEMPLATE_VARIABLE_WIDTH","TemplateVariable","TemplateVariableList","variableDefinitions","externalVariableDefinitions","slice","reverse","map","def","definitions","v","TemplateVariableListItem","spec","source","name","ctx","display","state","overridden","hidden","undefined","minWidth","maxWidth","flexShrink","data-testid"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,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AAAA,OAAAA,KAAKE,IAAI,GAAGD,oBAAZD,kBAAAA,OAAsB;OAPxCA,CAAAA,QAAAA,KAAKE,IAAI,GAAGD,oBAAZD,mBAAAA,QAAsB;AAUjC"}
@@ -31,5 +31,5 @@ export interface DashboardProviderProps {
31
31
  }
32
32
  export declare const DashboardContext: import("react").Context<StoreApi<DashboardStoreState> | undefined>;
33
33
  export declare function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T;
34
- export declare function DashboardProvider(props: DashboardProviderProps): JSX.Element;
34
+ export declare function DashboardProvider(props: DashboardProviderProps): import("react/jsx-runtime").JSX.Element;
35
35
  //# sourceMappingURL=DashboardProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAiB,SAAS,EAAgD,MAAM,OAAO,CAAC;AAC/F,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,eAAe,EACf,cAAc,EAEd,cAAc,EACf,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAsD,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC1G,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAoB,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAA+B,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAA0B,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAmC,qCAAqC,EAAE,MAAM,gCAAgC,CAAC;AACxH,OAAO,EAAgC,kCAAkC,EAAE,MAAM,6BAA6B,CAAC;AAC/G,OAAO,EAA6B,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACzF,OAAO,EAA6B,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG1F,MAAM,WAAW,mBACf,SAAQ,eAAe,EACrB,UAAU,EACV,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,qCAAqC,EACrC,mBAAmB,EACnB,mBAAmB,EACnB,kCAAkC;IACpC,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,YAAY,EAAE,CAAC,SAAS,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,eAAe,CAAC;IAC1B,QAAQ,EAAE,cAAc,CAAC;IACzB,eAAe,EAAE,cAAc,CAAC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,mBAAmB;IAClC,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,oEAAsE,CAAC;AAEpG,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,CAAC,KAM/E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA0B9D"}
1
+ {"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAiB,SAAS,EAAgD,MAAM,OAAO,CAAC;AAC/F,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,eAAe,EACf,cAAc,EAEd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,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,oEAAsE,CAAC;AAEpG,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,CAAC,KAM/E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,2CA0B9D"}
@@ -42,10 +42,10 @@ export function DashboardProvider(props) {
42
42
  props
43
43
  ]);
44
44
  // load plugin to retrieve initial spec if default panel kind is defined
45
- const { defaultPluginKinds } = usePluginRegistry();
45
+ const { defaultPluginKinds } = usePluginRegistry();
46
46
  var _defaultPluginKinds_Panel;
47
47
  const defaultPanelKind = (_defaultPluginKinds_Panel = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds['Panel']) !== null && _defaultPluginKinds_Panel !== void 0 ? _defaultPluginKinds_Panel : '';
48
- const { data: plugin } = usePlugin('Panel', defaultPanelKind);
48
+ const { data: plugin } = usePlugin('Panel', defaultPanelKind);
49
49
  const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders
50
50
  useEffect(()=>{
51
51
  if (plugin === undefined) return;
@@ -67,9 +67,9 @@ export function DashboardProvider(props) {
67
67
  });
68
68
  }
69
69
  function initStore(props) {
70
- const { initialState: { dashboardResource , isEditMode } } = props;
71
- const { spec: { display , duration , refreshInterval =DEFAULT_REFRESH_INTERVAL , datasources } , metadata } = dashboardResource;
72
- let { spec: { layouts , panels } } = dashboardResource;
70
+ const { initialState: { dashboardResource, isEditMode } } = props;
71
+ const { spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources }, metadata } = dashboardResource;
72
+ let { spec: { layouts, panels } } = dashboardResource;
73
73
  // Set fallbacks in case the frontend is used with a non-Perses backend
74
74
  layouts = layouts !== null && layouts !== void 0 ? layouts : [];
75
75
  panels = panels !== null && panels !== void 0 ? panels : {};
@@ -95,12 +95,12 @@ function initStore(props) {
95
95
  setEditMode: (isEditMode)=>set({
96
96
  isEditMode
97
97
  }),
98
- setDashboard: ({ metadata , spec: { display , panels ={} , layouts =[] , duration , refreshInterval , datasources ={} } })=>{
98
+ setDashboard: ({ metadata, spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} } })=>{
99
99
  set((state)=>{
100
100
  state.metadata = metadata;
101
101
  state.display = display;
102
102
  state.panels = panels;
103
- const { panelGroups , panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
103
+ const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);
104
104
  state.panelGroups = panelGroups;
105
105
  state.panelGroupOrder = panelGroupOrder;
106
106
  state.duration = duration;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 2023 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 { createStore, useStore } from 'zustand';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { shallow } from 'zustand/shallow';\nimport { createContext, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport {\n DashboardResource,\n Display,\n ProjectMetadata,\n DurationString,\n DEFAULT_REFRESH_INTERVAL,\n DatasourceSpec,\n} from '@perses-dev/core';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\nimport { createSaveChangesDialogSlice, SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\nimport { createEditJsonDialogSlice, EditJsonDialogSlice } from './edit-json-dialog-slice';\nimport { createPanelDefinition } from './common';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice,\n EditJsonDialogSlice,\n SaveChangesConfirmationDialogSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n setDashboard: (dashboard: DashboardResource) => void;\n metadata: ProjectMetadata;\n duration: DurationString;\n refreshInterval: DurationString;\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T) {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStore(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps) {\n const createDashboardStore = useCallback(initStore, [props]);\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders\n\n useEffect(() => {\n if (plugin === undefined) return;\n const defaultPanelSpec = plugin.createInitialOptions();\n // set default panel kind, spec, and queries for add panel editor\n store.setState({\n initialValues: {\n panelDefinition: createPanelDefinition(defaultPanelKind, defaultPanelSpec),\n },\n });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps) {\n const {\n initialState: { dashboardResource, isEditMode },\n } = props;\n\n const {\n spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources },\n metadata,\n } = dashboardResource;\n\n let {\n spec: { layouts, panels },\n } = dashboardResource;\n\n // Set fallbacks in case the frontend is used with a non-Perses backend\n layouts = layouts ?? [];\n panels = panels ?? {};\n\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n /* Groups */\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n /* Panels */\n ...createPanelSlice(panels)(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDuplicatePanelSlice()(...args),\n /* General */\n ...createDiscardChangesDialogSlice(...args),\n ...createEditJsonDialogSlice(...args),\n ...createSaveChangesDialogSlice(...args),\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n setDashboard: ({\n metadata,\n spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} },\n }) => {\n set((state) => {\n state.metadata = metadata;\n state.display = display;\n state.panels = panels;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n state.duration = duration;\n state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n state.datasources = datasources;\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStore","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","DEFAULT_REFRESH_INTERVAL","usePlugin","usePluginRegistry","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createSaveChangesDialogSlice","createDuplicatePanelSlice","createEditJsonDialogSlice","createPanelDefinition","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","defaultPanelSpec","createInitialOptions","setState","initialValues","panelDefinition","Provider","value","children","initialState","dashboardResource","isEditMode","spec","display","duration","refreshInterval","datasources","metadata","layouts","panels","args","set","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"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,SAASA,WAAW,EAAEC,QAAQ,QAAQ,UAAU;AAEhD,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAAaC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC/F,SAKEC,wBAAwB,QAEnB,mBAAmB;AAC1B,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,4BAA4B;AACzE,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,2BAA2B,EAAEC,qBAAqB,QAAyB,sBAAsB;AA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;oBACf,MAAM,EAAEM,YAAW,EAAEC,gBAAe,EAAE,GAAGlD,4BAA4B0C;oBACrEM,MAAMC,cAAcA;oBACpBD,MAAME,kBAAkBA;oBACxBF,MAAMV,WAAWA;oBACjBU,MAAMT,kBAAkBA,4BAAAA,6BAAAA,kBAAmB3C;oBAC3CoD,MAAMR,cAAcA;gBACtB;YACF;QACF;IACF;IAIJ,OAAOzB;AACT"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 2023 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 { createStore, useStore } from 'zustand';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { shallow } from 'zustand/shallow';\nimport { createContext, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport {\n DashboardResource,\n Display,\n ProjectMetadata,\n DurationString,\n DEFAULT_REFRESH_INTERVAL,\n DatasourceSpec,\n} from '@perses-dev/core';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\nimport { createSaveChangesDialogSlice, SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\nimport { createEditJsonDialogSlice, EditJsonDialogSlice } from './edit-json-dialog-slice';\nimport { createPanelDefinition } from './common';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice,\n EditJsonDialogSlice,\n SaveChangesConfirmationDialogSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n setDashboard: (dashboard: DashboardResource) => void;\n metadata: ProjectMetadata;\n duration: DurationString;\n refreshInterval: DurationString;\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource;\n isEditMode?: boolean;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T) {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStore(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps) {\n const createDashboardStore = useCallback(initStore, [props]);\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders\n\n useEffect(() => {\n if (plugin === undefined) return;\n const defaultPanelSpec = plugin.createInitialOptions();\n // set default panel kind, spec, and queries for add panel editor\n store.setState({\n initialValues: {\n panelDefinition: createPanelDefinition(defaultPanelKind, defaultPanelSpec),\n },\n });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps) {\n const {\n initialState: { dashboardResource, isEditMode },\n } = props;\n\n const {\n spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources },\n metadata,\n } = dashboardResource;\n\n let {\n spec: { layouts, panels },\n } = dashboardResource;\n\n // Set fallbacks in case the frontend is used with a non-Perses backend\n layouts = layouts ?? [];\n panels = panels ?? {};\n\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n /* Groups */\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n /* Panels */\n ...createPanelSlice(panels)(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDuplicatePanelSlice()(...args),\n /* General */\n ...createDiscardChangesDialogSlice(...args),\n ...createEditJsonDialogSlice(...args),\n ...createSaveChangesDialogSlice(...args),\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean) => set({ isEditMode }),\n setDashboard: ({\n metadata,\n spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} },\n }) => {\n set((state) => {\n state.metadata = metadata;\n state.display = display;\n state.panels = panels;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n state.duration = duration;\n state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n state.datasources = datasources;\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStore","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","DEFAULT_REFRESH_INTERVAL","usePlugin","usePluginRegistry","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createSaveChangesDialogSlice","createDuplicatePanelSlice","createEditJsonDialogSlice","createPanelDefinition","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","defaultPanelSpec","createInitialOptions","setState","initialValues","panelDefinition","Provider","value","children","initialState","dashboardResource","isEditMode","spec","display","duration","refreshInterval","datasources","metadata","layouts","panels","args","set","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"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,SAASA,WAAW,EAAEC,QAAQ,QAAQ,UAAU;AAEhD,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAAaC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC/F,SAKEC,wBAAwB,QAEnB,mBAAmB;AAC1B,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,4BAA4B;AACzE,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,2BAA2B,EAAEC,qBAAqB,QAAyB,sBAAsB;AAC1G,SAASC,sBAAsB,QAA0B,uBAAuB;AAChF,SAASC,gBAAgB,QAAoB,gBAAgB;AAC7D,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,sBAAsB,QAA0B,uBAAuB;AAChF,SAASC,+BAA+B,QAA+C,iCAAiC;AACxH,SAASC,4BAA4B,QAA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BAAmB3C;oBAC3CoD,MAAMR,WAAW,GAAGA;gBACtB;YACF;QACF;IACF;IAIJ,OAAOzB;AACT"}
@@ -1,9 +1,9 @@
1
1
  import { DashboardResource, PanelDefinition, UnknownSpec } from '@perses-dev/core';
2
- export declare type OnSaveDashboard = (dashboard: DashboardResource) => Promise<unknown>;
2
+ export type OnSaveDashboard = (dashboard: DashboardResource) => Promise<unknown>;
3
3
  /**
4
4
  * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).
5
5
  */
6
- export declare type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];
6
+ export type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];
7
7
  declare global {
8
8
  var dashboardStoreId: number;
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnF,oBAAY,eAAe,GAAG,CAAC,SAAS,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEjF;;GAEG;AACH,oBAAY,UAAU,GAAG,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,UAAU,WAKzB;AAGD,wBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,WAAW,GAAG,eAAe,CAehH"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEnF,MAAM,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,iBAAiB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEjF;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,UAAU,WAKzB;AAGD,wBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,WAAW,GAAG,eAAe,CAehH"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/common.ts"],"sourcesContent":["// Copyright 2023 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 { DashboardResource, PanelDefinition, UnknownSpec } from '@perses-dev/core';\n\nexport type OnSaveDashboard = (dashboard: DashboardResource) => Promise<unknown>;\n\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number;\n}\n\n/**\n * Helper function to generate unique IDs for things in the dashboard store that don't have a \"natural\" ID.\n */\nexport function generateId() {\n if (globalThis.dashboardStoreId === undefined) {\n globalThis.dashboardStoreId = 0;\n }\n return globalThis.dashboardStoreId++;\n}\n\n// Helper function to create initial PanelDefinitions\nexport function createPanelDefinition(defaultPanelKind?: string, defaultPanelSpec?: UnknownSpec): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: '',\n description: undefined,\n },\n plugin: {\n kind: defaultPanelKind ?? '',\n spec: defaultPanelSpec ?? {},\n },\n queries: [],\n },\n };\n}\n"],"names":["generateId","globalThis","dashboardStoreId","undefined","createPanelDefinition","defaultPanelKind","defaultPanelSpec","kind","spec","display","name","description","plugin","queries"],"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;AAgBjC;;CAEC,GACD,OAAO,SAASA;IACd,IAAIC,WAAWC,qBAAqBC,WAAW;QAC7CF,WAAWC,mBAAmB;IAChC;IACA,OAAOD,WAAWC;AACpB;AAEA,qDAAqD;AACrD,OAAO,SAASE,sBAAsBC,gBAAyB,EAAEC,gBAA8B;IAC7F,OAAO;QACLC,MAAM;QACNC,MAAM;YACJC,SAAS;gBACPC,MAAM;gBACNC,aAAaR;YACf;YACAS,QAAQ;gBACNL,MAAMF,6BAAAA,8BAAAA,mBAAoB;gBAC1BG,MAAMF,6BAAAA,8BAAAA,mBAAoB,CAAC;YAC7B;YACAO,SAAS,EAAE;QACb;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/common.ts"],"sourcesContent":["// Copyright 2023 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 { DashboardResource, PanelDefinition, UnknownSpec } from '@perses-dev/core';\n\nexport type OnSaveDashboard = (dashboard: DashboardResource) => Promise<unknown>;\n\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number;\n}\n\n/**\n * Helper function to generate unique IDs for things in the dashboard store that don't have a \"natural\" ID.\n */\nexport function generateId() {\n if (globalThis.dashboardStoreId === undefined) {\n globalThis.dashboardStoreId = 0;\n }\n return globalThis.dashboardStoreId++;\n}\n\n// Helper function to create initial PanelDefinitions\nexport function createPanelDefinition(defaultPanelKind?: string, defaultPanelSpec?: UnknownSpec): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: '',\n description: undefined,\n },\n plugin: {\n kind: defaultPanelKind ?? '',\n spec: defaultPanelSpec ?? {},\n },\n queries: [],\n },\n };\n}\n"],"names":["generateId","globalThis","dashboardStoreId","undefined","createPanelDefinition","defaultPanelKind","defaultPanelSpec","kind","spec","display","name","description","plugin","queries"],"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;AAgBjC;;CAEC,GACD,OAAO,SAASA;IACd,IAAIC,WAAWC,gBAAgB,KAAKC,WAAW;QAC7CF,WAAWC,gBAAgB,GAAG;IAChC;IACA,OAAOD,WAAWC,gBAAgB;AACpC;AAEA,qDAAqD;AACrD,OAAO,SAASE,sBAAsBC,gBAAyB,EAAEC,gBAA8B;IAC7F,OAAO;QACLC,MAAM;QACNC,MAAM;YACJC,SAAS;gBACPC,MAAM;gBACNC,aAAaR;YACf;YACAS,QAAQ;gBACNL,MAAMF,6BAAAA,8BAAAA,mBAAoB;gBAC1BG,MAAMF,6BAAAA,8BAAAA,mBAAoB,CAAC;YAC7B;YACAO,SAAS,EAAE;QACb;IACF;AACF"}
@@ -12,14 +12,14 @@
12
12
  // limitations under the License.
13
13
  import { useCallback, useMemo } from 'react';
14
14
  import { useDashboardStore } from './DashboardProvider';
15
- const selectEditMode = ({ isEditMode , setEditMode })=>({
15
+ const selectEditMode = ({ isEditMode, setEditMode })=>({
16
16
  isEditMode,
17
17
  setEditMode
18
18
  });
19
19
  export function useEditMode() {
20
20
  return useDashboardStore(selectEditMode);
21
21
  }
22
- const selectDashboardActions = ({ setDashboard , openAddPanelGroup , openAddPanel })=>({
22
+ const selectDashboardActions = ({ setDashboard, openAddPanelGroup, openAddPanel })=>({
23
23
  setDashboard,
24
24
  openAddPanelGroup,
25
25
  openAddPanel
@@ -27,7 +27,7 @@ const selectDashboardActions = ({ setDashboard , openAddPanelGroup , openAddPane
27
27
  /**
28
28
  * Returns actions that can be performed on the current dashboard.
29
29
  */ export function useDashboardActions() {
30
- const { setDashboard , openAddPanelGroup , openAddPanel } = useDashboardStore(selectDashboardActions);
30
+ const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);
31
31
  return {
32
32
  setDashboard,
33
33
  openAddPanelGroup: ()=>openAddPanelGroup(),
@@ -70,7 +70,7 @@ const selectPanelGroups = (state)=>state.panelGroups;
70
70
  }
71
71
  return panelGroup;
72
72
  }
73
- const selectPanelGroupActions = ({ openEditPanelGroup , deletePanelGroup , openAddPanel , updatePanelGroupLayouts })=>({
73
+ const selectPanelGroupActions = ({ openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts })=>({
74
74
  openEditPanelGroup,
75
75
  deletePanelGroup,
76
76
  openAddPanel,
@@ -79,8 +79,8 @@ const selectPanelGroupActions = ({ openEditPanelGroup , deletePanelGroup , openA
79
79
  /**
80
80
  * Returns actions that can be performed on the given panel group.
81
81
  */ export function usePanelGroupActions(panelGroupId) {
82
- const { moveUp , moveDown } = useMovePanelGroup(panelGroupId);
83
- const { openEditPanelGroup , deletePanelGroup , openAddPanel , updatePanelGroupLayouts } = useDashboardStore(selectPanelGroupActions);
82
+ const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);
83
+ const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } = useDashboardStore(selectPanelGroupActions);
84
84
  return {
85
85
  openEditPanelGroup: ()=>openEditPanelGroup(panelGroupId),
86
86
  deletePanelGroup: ()=>deletePanelGroup(panelGroupId),
@@ -117,7 +117,7 @@ const selectPanelGroupEditor = (state)=>state.panelGroupEditor;
117
117
  */ export function usePanelGroupEditor() {
118
118
  return useDashboardStore(selectPanelGroupEditor);
119
119
  }
120
- const selectDeletePanelGroupDialog = ({ deletePanelGroupDialog , openDeletePanelGroupDialog , closeDeletePanelGroupDialog , deletePanelGroup })=>({
120
+ const selectDeletePanelGroupDialog = ({ deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup })=>({
121
121
  deletePanelGroupDialog,
122
122
  openDeletePanelGroupDialog,
123
123
  closeDeletePanelGroupDialog,
@@ -126,7 +126,7 @@ const selectDeletePanelGroupDialog = ({ deletePanelGroupDialog , openDeletePanel
126
126
  /**
127
127
  * Gets the Delete Panel Group dialog state.
128
128
  */ export function useDeletePanelGroupDialog() {
129
- const { deletePanelGroupDialog , openDeletePanelGroupDialog , closeDeletePanelGroupDialog , deletePanelGroup } = useDashboardStore(selectDeletePanelGroupDialog);
129
+ const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = useDashboardStore(selectDeletePanelGroupDialog);
130
130
  return {
131
131
  deletePanelGroupDialog,
132
132
  deletePanelGroup,
@@ -137,7 +137,7 @@ const selectDeletePanelGroupDialog = ({ deletePanelGroupDialog , openDeletePanel
137
137
  /**
138
138
  * Gets an individual panel in the store. Throws if the panel can't be found.
139
139
  */ export function usePanel(panelGroupItemId) {
140
- const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
140
+ const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
141
141
  const panel = useDashboardStore(useCallback((store)=>{
142
142
  var _store_panelGroups_panelGroupId;
143
143
  const panelKey = (_store_panelGroups_panelGroupId = store.panelGroups[panelGroupId]) === null || _store_panelGroups_panelGroupId === void 0 ? void 0 : _store_panelGroups_panelGroupId.itemPanelKeys[panelGroupLayoutId];
@@ -152,7 +152,7 @@ const selectDeletePanelGroupDialog = ({ deletePanelGroupDialog , openDeletePanel
152
152
  }
153
153
  return panel;
154
154
  }
155
- const selectPanelActions = ({ openEditPanel , openDeletePanelDialog , duplicatePanel })=>({
155
+ const selectPanelActions = ({ openEditPanel, openDeletePanelDialog, duplicatePanel })=>({
156
156
  openEditPanel,
157
157
  openDeletePanelDialog,
158
158
  duplicatePanel
@@ -160,7 +160,7 @@ const selectPanelActions = ({ openEditPanel , openDeletePanelDialog , duplicateP
160
160
  /**
161
161
  * Returns actions that can be performed on the given Panel.
162
162
  */ export function usePanelActions(panelGroupItemId) {
163
- const { openEditPanel , openDeletePanelDialog , duplicatePanel } = useDashboardStore(selectPanelActions);
163
+ const { openEditPanel, openDeletePanelDialog, duplicatePanel } = useDashboardStore(selectPanelActions);
164
164
  return {
165
165
  openEditPanel: ()=>openEditPanel(panelGroupItemId),
166
166
  openDeletePanelDialog: ()=>openDeletePanelDialog(panelGroupItemId),
@@ -173,7 +173,7 @@ const selectPanelEditor = (state)=>state.panelEditor;
173
173
  */ export function usePanelEditor() {
174
174
  return useDashboardStore(selectPanelEditor);
175
175
  }
176
- const selectDeletePanelDialog = ({ deletePanelDialog , deletePanel , closeDeletePanelDialog })=>({
176
+ const selectDeletePanelDialog = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog })=>({
177
177
  deletePanelDialog,
178
178
  deletePanel,
179
179
  closeDeletePanelDialog
@@ -188,7 +188,7 @@ const selectDashboardDuration = (state)=>state.duration;
188
188
  export function useDashboardDuration() {
189
189
  return useDashboardStore(selectDashboardDuration);
190
190
  }
191
- const selectSaveChangesConfirmationDialog = ({ saveChangesConfirmationDialog , openSaveChangesConfirmationDialog , closeSaveChangesConfirmationDialog })=>({
191
+ const selectSaveChangesConfirmationDialog = ({ saveChangesConfirmationDialog, openSaveChangesConfirmationDialog, closeSaveChangesConfirmationDialog })=>({
192
192
  saveChangesConfirmationDialog,
193
193
  openSaveChangesConfirmationDialog,
194
194
  closeSaveChangesConfirmationDialog
@@ -196,7 +196,7 @@ const selectSaveChangesConfirmationDialog = ({ saveChangesConfirmationDialog , o
196
196
  export function useSaveChangesConfirmationDialog() {
197
197
  return useDashboardStore(selectSaveChangesConfirmationDialog);
198
198
  }
199
- const selectDiscardChangesConfirmationDialog = ({ discardChangesConfirmationDialog , openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog })=>({
199
+ const selectDiscardChangesConfirmationDialog = ({ discardChangesConfirmationDialog, openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog })=>({
200
200
  discardChangesConfirmationDialog,
201
201
  openDiscardChangesConfirmationDialog,
202
202
  closeDiscardChangesConfirmationDialog
@@ -204,7 +204,7 @@ const selectDiscardChangesConfirmationDialog = ({ discardChangesConfirmationDial
204
204
  export function useDiscardChangesConfirmationDialog() {
205
205
  return useDashboardStore(selectDiscardChangesConfirmationDialog);
206
206
  }
207
- const selectEditJsonDialog = ({ editJsonDialog , openEditJsonDialog , closeEditJsonDialog })=>({
207
+ const selectEditJsonDialog = ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog })=>({
208
208
  editJsonDialog,
209
209
  openEditJsonDialog,
210
210
  closeEditJsonDialog
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"sourcesContent":["// Copyright 2023 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 { useCallback, useMemo } from 'react';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { PanelGroupItemId, PanelGroupId, PanelGroupItemLayout } from './panel-group-slice';\n\nconst selectEditMode = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode() {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions = ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => ({\n setDashboard,\n openAddPanelGroup,\n openAddPanel,\n});\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions() {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState) => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds() {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups = (state: DashboardStoreState) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups() {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore(selectPanelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId) {\n const panelGroup = useDashboardStore(useCallback((state) => state.panelGroups[panelGroupId], [panelGroupId]));\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\nconst selectPanelGroupActions = ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n}: DashboardStoreState) => ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n});\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId) {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } =\n useDashboardStore(selectPanelGroupActions);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) =>\n updatePanelGroupLayouts(panelGroupId, itemLayouts),\n };\n}\n\nconst selectSwapPanelGroups = (state: DashboardStoreState) => state.swapPanelGroups;\nconst selectPanelGroupsLength = (state: DashboardStoreState) => state.panelGroupOrder.length;\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId) {\n const currentIndex = useDashboardStore(\n useCallback((store) => store.panelGroupOrder.findIndex((id) => id === panelGroupId), [panelGroupId])\n );\n const panelGroupsLength = useDashboardStore(selectPanelGroupsLength);\n const swapPanelGroups = useDashboardStore(selectSwapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\nconst selectPanelGroupEditor = (state: DashboardStoreState) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor() {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog = ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n});\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog() {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panel = useDashboardStore(\n useCallback(\n (store) => {\n const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) return;\n return store.panels[panelKey];\n },\n [panelGroupId, panelGroupLayoutId]\n )\n );\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\nconst selectPanelActions = ({ openEditPanel, openDeletePanelDialog, duplicatePanel }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n});\n\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId) {\n const { openEditPanel, openDeletePanelDialog, duplicatePanel } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n duplicatePanel: () => duplicatePanel(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor = (state: DashboardStoreState) => state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor() {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => ({\n deletePanelDialog,\n deletePanel,\n closeDeletePanelDialog,\n});\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog() {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDashboardDuration = (state: DashboardStoreState) => state.duration;\nexport function useDashboardDuration() {\n return useDashboardStore(selectDashboardDuration);\n}\n\nconst selectSaveChangesConfirmationDialog = ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n});\nexport function useSaveChangesConfirmationDialog() {\n return useDashboardStore(selectSaveChangesConfirmationDialog);\n}\n\nconst selectDiscardChangesConfirmationDialog = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog() {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n\nconst selectEditJsonDialog = ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => ({\n editJsonDialog,\n openEditJsonDialog,\n closeEditJsonDialog,\n});\n/**\n * Gets the state for the edit JSON dialog.\n */\nexport function useEditJsonDialog() {\n return useDashboardStore(selectEditJsonDialog);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectPanelGroupOrder","state","panelGroupOrder","usePanelGroupIds","selectPanelGroups","panelGroups","useListPanelGroups","panelGroupIds","map","id","group","undefined","Error","usePanelGroup","panelGroupId","panelGroup","selectPanelGroupActions","openEditPanelGroup","deletePanelGroup","updatePanelGroupLayouts","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","itemLayouts","selectSwapPanelGroups","swapPanelGroups","selectPanelGroupsLength","length","currentIndex","store","findIndex","panelGroupsLength","selectPanelGroupEditor","panelGroupEditor","usePanelGroupEditor","selectDeletePanelGroupDialog","deletePanelGroupDialog","openDeletePanelGroupDialog","closeDeletePanelGroupDialog","useDeletePanelGroupDialog","usePanel","panelGroupItemId","panelGroupItemLayoutId","panelGroupLayoutId","panel","panelKey","itemPanelKeys","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","duplicatePanel","usePanelActions","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDashboardDuration","duration","useDashboardDuration","selectSaveChangesConfirmationDialog","saveChangesConfirmationDialog","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","useSaveChangesConfirmationDialog","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","selectEditJsonDialog","editJsonDialog","openEditJsonDialog","closeEditJsonDialog","useEditJsonDialog"],"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,SAASA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAC7C,SAA8BC,iBAAiB,QAAQ,sBAAsB;AAG7E,MAAMC,iBAAiB,CAAC,EAAEC,WAAU,EAAEC,YAAW,EAAuB,GA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MAAMG,0BAA0B,CAAC,EAAEC,kBAAiB,EAAEC,YAAW,EAAEC,uBAAsB,EAAuB,GAAM,CAAA;QACpHF;QACAC;QACAC;IACF,CAAA;AAEA;;CAEC,GACD,OAAO,SAASC;IACd,0FAA0F;IAC1F,OAAOvE,kBAAkBmE;AAC3B;AAEA,MAAMK,0BAA0B,CAAC7D,QAA+BA,MAAM8D;AACtE,OAAO,SAASC;IACd,OAAO1E,kBAAkBwE;AAC3B;AAEA,MAAMG,sCAAsC,CAAC,EAC3CC,8BAA6B,EAC7BC,kCAAiC,EACjCC,mCAAkC,EACd,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IACd,OAAO/E,kBAAkB2E;AAC3B;AAEA,MAAMK,yCAAyC,CAAC,EAC9CC,iCAAgC,EAChCC,qCAAoC,EACpCC,sCAAqC,EACjB,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IACd,OAAOpF,kBAAkBgF;AAC3B;AAEA,MAAMK,uBAAuB,CAAC,EAAEC,eAAc,EAAEC,mBAAkB,EAAEC,oBAAmB,EAAuB,GAAM,CAAA;QAClHF;QACAC;QACAC;IACF,CAAA;AACA;;CAEC,GACD,OAAO,SAASC;IACd,OAAOzF,kBAAkBqF;AAC3B"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/dashboard-provider-api.ts"],"sourcesContent":["// Copyright 2023 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 { useCallback, useMemo } from 'react';\nimport { DashboardStoreState, useDashboardStore } from './DashboardProvider';\nimport { PanelGroupItemId, PanelGroupId, PanelGroupItemLayout } from './panel-group-slice';\n\nconst selectEditMode = ({ isEditMode, setEditMode }: DashboardStoreState) => ({ isEditMode, setEditMode });\nexport function useEditMode() {\n return useDashboardStore(selectEditMode);\n}\n\nconst selectDashboardActions = ({ setDashboard, openAddPanelGroup, openAddPanel }: DashboardStoreState) => ({\n setDashboard,\n openAddPanelGroup,\n openAddPanel,\n});\n/**\n * Returns actions that can be performed on the current dashboard.\n */\nexport function useDashboardActions() {\n const { setDashboard, openAddPanelGroup, openAddPanel } = useDashboardStore(selectDashboardActions);\n return {\n setDashboard,\n openAddPanelGroup: () => openAddPanelGroup(),\n openAddPanel: () => openAddPanel(),\n };\n}\n\nconst selectPanelGroupOrder = (state: DashboardStoreState) => state.panelGroupOrder;\n/**\n * Returns an array of PanelGroupIds in the order they appear in the dashboard.\n */\nexport function usePanelGroupIds() {\n return useDashboardStore(selectPanelGroupOrder);\n}\n\nconst selectPanelGroups = (state: DashboardStoreState) => state.panelGroups;\n/**\n * Returns an array of PanelGroupDefinitions in the order they appear in the dashboard.\n */\nexport function useListPanelGroups() {\n const panelGroupIds = usePanelGroupIds();\n const panelGroups = useDashboardStore(selectPanelGroups);\n return useMemo(() => {\n return panelGroupIds.map((id) => {\n const group = panelGroups[id];\n if (group === undefined) {\n throw new Error(`Invalid panel group Id found ${id}`);\n }\n return group;\n });\n }, [panelGroupIds, panelGroups]);\n}\n\n/**\n * Gets a specific panel group by its id. Throws if the panel group does not exist.\n */\nexport function usePanelGroup(panelGroupId: PanelGroupId) {\n const panelGroup = useDashboardStore(useCallback((state) => state.panelGroups[panelGroupId], [panelGroupId]));\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} was not found`);\n }\n return panelGroup;\n}\n\nconst selectPanelGroupActions = ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n}: DashboardStoreState) => ({\n openEditPanelGroup,\n deletePanelGroup,\n openAddPanel,\n updatePanelGroupLayouts,\n});\n/**\n * Returns actions that can be performed on the given panel group.\n */\nexport function usePanelGroupActions(panelGroupId: PanelGroupId) {\n const { moveUp, moveDown } = useMovePanelGroup(panelGroupId);\n const { openEditPanelGroup, deletePanelGroup, openAddPanel, updatePanelGroupLayouts } =\n useDashboardStore(selectPanelGroupActions);\n\n return {\n openEditPanelGroup: () => openEditPanelGroup(panelGroupId),\n deletePanelGroup: () => deletePanelGroup(panelGroupId),\n openAddPanel: () => openAddPanel(panelGroupId),\n moveUp,\n moveDown,\n updatePanelGroupLayouts: (itemLayouts: PanelGroupItemLayout[]) =>\n updatePanelGroupLayouts(panelGroupId, itemLayouts),\n };\n}\n\nconst selectSwapPanelGroups = (state: DashboardStoreState) => state.swapPanelGroups;\nconst selectPanelGroupsLength = (state: DashboardStoreState) => state.panelGroupOrder.length;\n/**\n * Returns functions for moving a panel group up or down. A function will be undefined if the panel group can't be\n * moved in that direction.\n */\nfunction useMovePanelGroup(panelGroupId: PanelGroupId) {\n const currentIndex = useDashboardStore(\n useCallback((store) => store.panelGroupOrder.findIndex((id) => id === panelGroupId), [panelGroupId])\n );\n const panelGroupsLength = useDashboardStore(selectPanelGroupsLength);\n const swapPanelGroups = useDashboardStore(selectSwapPanelGroups);\n\n if (currentIndex < 0) {\n throw new Error(`Could not find panel group with Id ${panelGroupId} in order array`);\n }\n\n const moveUp = () => swapPanelGroups(currentIndex, currentIndex - 1);\n const moveDown = () => swapPanelGroups(currentIndex, currentIndex + 1);\n return {\n moveUp: currentIndex > 0 ? moveUp : undefined,\n moveDown: currentIndex < panelGroupsLength - 1 ? moveDown : undefined,\n };\n}\n\nconst selectPanelGroupEditor = (state: DashboardStoreState) => state.panelGroupEditor;\n/**\n * Gets the Panel Group editor state.\n */\nexport function usePanelGroupEditor() {\n return useDashboardStore(selectPanelGroupEditor);\n}\n\nconst selectDeletePanelGroupDialog = ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n}: DashboardStoreState) => ({\n deletePanelGroupDialog,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog,\n deletePanelGroup,\n});\n/**\n * Gets the Delete Panel Group dialog state.\n */\nexport function useDeletePanelGroupDialog() {\n const { deletePanelGroupDialog, openDeletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } =\n useDashboardStore(selectDeletePanelGroupDialog);\n return {\n deletePanelGroupDialog,\n deletePanelGroup,\n openDeletePanelGroupDialog,\n closeDeletePanelGroupDialog: () => closeDeletePanelGroupDialog(),\n };\n}\n\n/**\n * Gets an individual panel in the store. Throws if the panel can't be found.\n */\nexport function usePanel(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panel = useDashboardStore(\n useCallback(\n (store) => {\n const panelKey = store.panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) return;\n return store.panels[panelKey];\n },\n [panelGroupId, panelGroupLayoutId]\n )\n );\n\n if (panel === undefined) {\n throw new Error(`Could not find panel for Id ${panelGroupItemId}`);\n }\n return panel;\n}\n\nconst selectPanelActions = ({ openEditPanel, openDeletePanelDialog, duplicatePanel }: DashboardStoreState) => ({\n openEditPanel,\n openDeletePanelDialog,\n duplicatePanel,\n});\n\n/**\n * Returns actions that can be performed on the given Panel.\n */\nexport function usePanelActions(panelGroupItemId: PanelGroupItemId) {\n const { openEditPanel, openDeletePanelDialog, duplicatePanel } = useDashboardStore(selectPanelActions);\n return {\n openEditPanel: () => openEditPanel(panelGroupItemId),\n openDeletePanelDialog: () => openDeletePanelDialog(panelGroupItemId),\n duplicatePanel: () => duplicatePanel(panelGroupItemId),\n };\n}\n\nconst selectPanelEditor = (state: DashboardStoreState) => state.panelEditor;\n/**\n * Gets the state for the Panel Editor.\n */\nexport function usePanelEditor() {\n return useDashboardStore(selectPanelEditor);\n}\n\nconst selectDeletePanelDialog = ({ deletePanelDialog, deletePanel, closeDeletePanelDialog }: DashboardStoreState) => ({\n deletePanelDialog,\n deletePanel,\n closeDeletePanelDialog,\n});\n\n/**\n * Gets the state for the Delete Panel dialog.\n */\nexport function useDeletePanelDialog() {\n // TODO: Refactor similar to other dialogs/editors so these are on the editor state itself\n return useDashboardStore(selectDeletePanelDialog);\n}\n\nconst selectDashboardDuration = (state: DashboardStoreState) => state.duration;\nexport function useDashboardDuration() {\n return useDashboardStore(selectDashboardDuration);\n}\n\nconst selectSaveChangesConfirmationDialog = ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n saveChangesConfirmationDialog,\n openSaveChangesConfirmationDialog,\n closeSaveChangesConfirmationDialog,\n});\nexport function useSaveChangesConfirmationDialog() {\n return useDashboardStore(selectSaveChangesConfirmationDialog);\n}\n\nconst selectDiscardChangesConfirmationDialog = ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n}: DashboardStoreState) => ({\n discardChangesConfirmationDialog,\n openDiscardChangesConfirmationDialog,\n closeDiscardChangesConfirmationDialog,\n});\nexport function useDiscardChangesConfirmationDialog() {\n return useDashboardStore(selectDiscardChangesConfirmationDialog);\n}\n\nconst selectEditJsonDialog = ({ editJsonDialog, openEditJsonDialog, closeEditJsonDialog }: DashboardStoreState) => ({\n editJsonDialog,\n openEditJsonDialog,\n closeEditJsonDialog,\n});\n/**\n * Gets the state for the edit JSON dialog.\n */\nexport function useEditJsonDialog() {\n return useDashboardStore(selectEditJsonDialog);\n}\n"],"names":["useCallback","useMemo","useDashboardStore","selectEditMode","isEditMode","setEditMode","useEditMode","selectDashboardActions","setDashboard","openAddPanelGroup","openAddPanel","useDashboardActions","selectPanelGroupOrder","state","panelGroupOrder","usePanelGroupIds","selectPanelGroups","panelGroups","useListPanelGroups","panelGroupIds","map","id","group","undefined","Error","usePanelGroup","panelGroupId","panelGroup","selectPanelGroupActions","openEditPanelGroup","deletePanelGroup","updatePanelGroupLayouts","usePanelGroupActions","moveUp","moveDown","useMovePanelGroup","itemLayouts","selectSwapPanelGroups","swapPanelGroups","selectPanelGroupsLength","length","currentIndex","store","findIndex","panelGroupsLength","selectPanelGroupEditor","panelGroupEditor","usePanelGroupEditor","selectDeletePanelGroupDialog","deletePanelGroupDialog","openDeletePanelGroupDialog","closeDeletePanelGroupDialog","useDeletePanelGroupDialog","usePanel","panelGroupItemId","panelGroupItemLayoutId","panelGroupLayoutId","panel","panelKey","itemPanelKeys","panels","selectPanelActions","openEditPanel","openDeletePanelDialog","duplicatePanel","usePanelActions","selectPanelEditor","panelEditor","usePanelEditor","selectDeletePanelDialog","deletePanelDialog","deletePanel","closeDeletePanelDialog","useDeletePanelDialog","selectDashboardDuration","duration","useDashboardDuration","selectSaveChangesConfirmationDialog","saveChangesConfirmationDialog","openSaveChangesConfirmationDialog","closeSaveChangesConfirmationDialog","useSaveChangesConfirmationDialog","selectDiscardChangesConfirmationDialog","discardChangesConfirmationDialog","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","useDiscardChangesConfirmationDialog","selectEditJsonDialog","editJsonDialog","openEditJsonDialog","closeEditJsonDialog","useEditJsonDialog"],"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,SAASA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAC7C,SAA8BC,iBAAiB,QAAQ,sBAAsB;AAG7E,MAAMC,iBAAiB,CAAC,EAAEC,UAAU,EAAEC,WAAW,EAAuB,GAAM,CAAA;QAAED;QAAYC;IAAY,CAAA;AACxG,OAAO,SAASC;IACd,OAAOJ,kBAAkBC;AAC3B;AAEA,MAAMI,yBAAyB,CAAC,EAAEC,YAAY,EAAEC,iBAAiB,EAAEC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ACF,CAAA;AAEA;;CAEC,GACD,OAAO,SAASC;IACd,0FAA0F;IAC1F,OAAOvE,kBAAkBmE;AAC3B;AAEA,MAAMK,0BAA0B,CAAC7D,QAA+BA,MAAM8D,QAAQ;AAC9E,OAAO,SAASC;IACd,OAAO1E,kBAAkBwE;AAC3B;AAEA,MAAMG,sCAAsC,CAAC,EAC3CC,6BAA6B,EAC7BC,iCAAiC,EACjCC,kCAAkC,EACd,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IACd,OAAO/E,kBAAkB2E;AAC3B;AAEA,MAAMK,yCAAyC,CAAC,EAC9CC,gCAAgC,EAChCC,oCAAoC,EACpCC,qCAAqC,EACjB,GAAM,CAAA;QAC1BF;QACAC;QACAC;IACF,CAAA;AACA,OAAO,SAASC;IACd,OAAOpF,kBAAkBgF;AAC3B;AAEA,MAAMK,uBAAuB,CAAC,EAAEC,cAAc,EAAEC,kBAAkB,EAAEC,mBAAmB,EAAuB,GAAM,CAAA;QAClHF;QACAC;QACAC;IACF,CAAA;AACA;;CAEC,GACD,OAAO,SAASC;IACd,OAAOzF,kBAAkBqF;AAC3B"}
@@ -12,7 +12,7 @@
12
12
  // limitations under the License.
13
13
  export const createDeletePanelGroupSlice = (set, get)=>({
14
14
  deletePanelGroup (panelGroupId) {
15
- const { panelGroups , panelGroupOrder } = get();
15
+ const { panelGroups, panelGroupOrder } = get();
16
16
  const group = panelGroups[panelGroupId];
17
17
  const idIndex = panelGroupOrder.findIndex((id)=>id === panelGroupId);
18
18
  if (group === undefined || idIndex === -1) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-group-slice.ts"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupId, PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and related actions for deleting a Panel Group.\n */\nexport interface DeletePanelGroupSlice {\n deletePanelGroupDialog?: DeletePanelGroupDialogState;\n\n /**\n * Delete panel group and all the panels within the group\n */\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n closeDeletePanelGroupDialog: () => void;\n}\n\nexport interface DeletePanelGroupDialogState {\n panelGroupId: PanelGroupId;\n panelGroupName?: string;\n}\n\nexport const createDeletePanelGroupSlice: StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelGroupSlice & PanelGroupSlice & PanelSlice,\n Middleware,\n [],\n DeletePanelGroupSlice\n> = (set, get) => ({\n deletePanelGroup(panelGroupId) {\n const { panelGroups, panelGroupOrder } = get();\n const group = panelGroups[panelGroupId];\n const idIndex = panelGroupOrder.findIndex((id) => id === panelGroupId);\n if (group === undefined || idIndex === -1) {\n throw new Error(`Panel group ${panelGroupId} not found`);\n }\n\n // Get the panel keys for all the panel items in the group we're going to delete\n const panelKeys = Object.values(group.itemPanelKeys);\n\n set((draft) => {\n // Delete the panel group which also deletes all its items\n delete draft.panelGroups[panelGroupId];\n draft.panelGroupOrder.splice(idIndex, 1);\n\n // Get all remaining panel keys in use\n const usedPanelKeys = getUsedPanelKeys(draft.panelGroups);\n\n // For the panel keys of the items that were just deleted, see if they're still used and if not, also delete the\n // panel definition\n for (const panelKey of panelKeys) {\n if (usedPanelKeys.has(panelKey)) continue;\n\n delete draft.panels[panelKey];\n }\n });\n },\n\n openDeletePanelGroupDialog: (panelGroupId) => {\n const panelGroup = get().panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} not found`);\n }\n set((state) => {\n state.deletePanelGroupDialog = { panelGroupId, panelGroupName: panelGroup.title };\n });\n },\n\n closeDeletePanelGroupDialog: () =>\n set((state) => {\n state.deletePanelGroupDialog = undefined;\n }),\n});\n\n// Helper to get the panel keys of all groups, returning a set to eliminate duplicates\nfunction getUsedPanelKeys(panelGroups: PanelGroupSlice['panelGroups']): Set<string> {\n const usedPanelKeys = new Set<string>();\n for (const group of Object.values(panelGroups)) {\n for (const panelKey of Object.values(group.itemPanelKeys)) {\n usedPanelKeys.add(panelKey);\n }\n }\n return usedPanelKeys;\n}\n"],"names":["createDeletePanelGroupSlice","set","get","deletePanelGroup","panelGroupId","panelGroups","panelGroupOrder","group","idIndex","findIndex","id","undefined","Error","panelKeys","Object","values","itemPanelKeys","draft","splice","usedPanelKeys","getUsedPanelKeys","panelKey","has","panels","openDeletePanelGroupDialog","panelGroup","state","deletePanelGroupDialog","panelGroupName","title","closeDeletePanelGroupDialog","Set","add"],"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;AA2BjC,OAAO,MAAMA,8BAMT,CAACC,KAAKC,MAAS,CAAA;QACjBC,kBAAiBC,YAAY;YAC3B,MAAM,EAAEC,YAAW,EAAEC,gBAAe,EAAE,GAAGJ;YACzC,MAAMK,QAAQF,WAAW,CAACD,aAAa;YACvC,MAAMI,UAAUF,gBAAgBG,UAAU,CAACC,KAAOA,OAAON;YACzD,IAAIG,UAAUI,aAAaH,YAAY,CAAC,GAAG;gBACzC,MAAM,IAAII,MAAM,CAAC,YAAY,EAAER,aAAa,UAAU,CAAC;YACzD;YAEA,gFAAgF;YAChF,MAAMS,YAAYC,OAAOC,OAAOR,MAAMS;YAEtCf,IAAI,CAACgB;gBACH,0DAA0D;gBAC1D,OAAOA,MAAMZ,WAAW,CAACD,aAAa;gBACtCa,MAAMX,gBAAgBY,OAAOV,SAAS;gBAEtC,sCAAsC;gBACtC,MAAMW,gBAAgBC,iBAAiBH,MAAMZ;gBAE7C,gHAAgH;gBAChH,mBAAmB;gBACnB,KAAK,MAAMgB,YAAYR,UAAW;oBAChC,IAAIM,cAAcG,IAAID,WAAW;oBAEjC,OAAOJ,MAAMM,MAAM,CAACF,SAAS;gBAC/B;YACF;QACF;QAEAG,4BAA4B,CAACpB;YAC3B,MAAMqB,aAAavB,MAAMG,WAAW,CAACD,aAAa;YAClD,IAAIqB,eAAed,WAAW;gBAC5B,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAER,aAAa,UAAU,CAAC;YACjE;YACAH,IAAI,CAACyB;gBACHA,MAAMC,yBAAyB;oBAAEvB;oBAAcwB,gBAAgBH,WAAWI;gBAAM;YAClF;QACF;QAEAC,6BAA6B,IAC3B7B,IAAI,CAACyB;gBACHA,MAAMC,yBAAyBhB;YACjC;IACJ,CAAA,EAAG;AAEH,sFAAsF;AACtF,SAASS,iBAAiBf,WAA2C;IACnE,MAAMc,gBAAgB,IAAIY;IAC1B,KAAK,MAAMxB,SAASO,OAAOC,OAAOV,aAAc;QAC9C,KAAK,MAAMgB,YAAYP,OAAOC,OAAOR,MAAMS,eAAgB;YACzDG,cAAca,IAAIX;QACpB;IACF;IACA,OAAOF;AACT"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-group-slice.ts"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupId, PanelGroupSlice } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and related actions for deleting a Panel Group.\n */\nexport interface DeletePanelGroupSlice {\n deletePanelGroupDialog?: DeletePanelGroupDialogState;\n\n /**\n * Delete panel group and all the panels within the group\n */\n deletePanelGroup: (panelGroupId: PanelGroupId) => void;\n\n openDeletePanelGroupDialog: (panelGroupId: PanelGroupId) => void;\n closeDeletePanelGroupDialog: () => void;\n}\n\nexport interface DeletePanelGroupDialogState {\n panelGroupId: PanelGroupId;\n panelGroupName?: string;\n}\n\nexport const createDeletePanelGroupSlice: StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelGroupSlice & PanelGroupSlice & PanelSlice,\n Middleware,\n [],\n DeletePanelGroupSlice\n> = (set, get) => ({\n deletePanelGroup(panelGroupId) {\n const { panelGroups, panelGroupOrder } = get();\n const group = panelGroups[panelGroupId];\n const idIndex = panelGroupOrder.findIndex((id) => id === panelGroupId);\n if (group === undefined || idIndex === -1) {\n throw new Error(`Panel group ${panelGroupId} not found`);\n }\n\n // Get the panel keys for all the panel items in the group we're going to delete\n const panelKeys = Object.values(group.itemPanelKeys);\n\n set((draft) => {\n // Delete the panel group which also deletes all its items\n delete draft.panelGroups[panelGroupId];\n draft.panelGroupOrder.splice(idIndex, 1);\n\n // Get all remaining panel keys in use\n const usedPanelKeys = getUsedPanelKeys(draft.panelGroups);\n\n // For the panel keys of the items that were just deleted, see if they're still used and if not, also delete the\n // panel definition\n for (const panelKey of panelKeys) {\n if (usedPanelKeys.has(panelKey)) continue;\n\n delete draft.panels[panelKey];\n }\n });\n },\n\n openDeletePanelGroupDialog: (panelGroupId) => {\n const panelGroup = get().panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group with Id ${panelGroupId} not found`);\n }\n set((state) => {\n state.deletePanelGroupDialog = { panelGroupId, panelGroupName: panelGroup.title };\n });\n },\n\n closeDeletePanelGroupDialog: () =>\n set((state) => {\n state.deletePanelGroupDialog = undefined;\n }),\n});\n\n// Helper to get the panel keys of all groups, returning a set to eliminate duplicates\nfunction getUsedPanelKeys(panelGroups: PanelGroupSlice['panelGroups']): Set<string> {\n const usedPanelKeys = new Set<string>();\n for (const group of Object.values(panelGroups)) {\n for (const panelKey of Object.values(group.itemPanelKeys)) {\n usedPanelKeys.add(panelKey);\n }\n }\n return usedPanelKeys;\n}\n"],"names":["createDeletePanelGroupSlice","set","get","deletePanelGroup","panelGroupId","panelGroups","panelGroupOrder","group","idIndex","findIndex","id","undefined","Error","panelKeys","Object","values","itemPanelKeys","draft","splice","usedPanelKeys","getUsedPanelKeys","panelKey","has","panels","openDeletePanelGroupDialog","panelGroup","state","deletePanelGroupDialog","panelGroupName","title","closeDeletePanelGroupDialog","Set","add"],"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;AA2BjC,OAAO,MAAMA,8BAMT,CAACC,KAAKC,MAAS,CAAA;QACjBC,kBAAiBC,YAAY;YAC3B,MAAM,EAAEC,WAAW,EAAEC,eAAe,EAAE,GAAGJ;YACzC,MAAMK,QAAQF,WAAW,CAACD,aAAa;YACvC,MAAMI,UAAUF,gBAAgBG,SAAS,CAAC,CAACC,KAAOA,OAAON;YACzD,IAAIG,UAAUI,aAAaH,YAAY,CAAC,GAAG;gBACzC,MAAM,IAAII,MAAM,CAAC,YAAY,EAAER,aAAa,UAAU,CAAC;YACzD;YAEA,gFAAgF;YAChF,MAAMS,YAAYC,OAAOC,MAAM,CAACR,MAAMS,aAAa;YAEnDf,IAAI,CAACgB;gBACH,0DAA0D;gBAC1D,OAAOA,MAAMZ,WAAW,CAACD,aAAa;gBACtCa,MAAMX,eAAe,CAACY,MAAM,CAACV,SAAS;gBAEtC,sCAAsC;gBACtC,MAAMW,gBAAgBC,iBAAiBH,MAAMZ,WAAW;gBAExD,gHAAgH;gBAChH,mBAAmB;gBACnB,KAAK,MAAMgB,YAAYR,UAAW;oBAChC,IAAIM,cAAcG,GAAG,CAACD,WAAW;oBAEjC,OAAOJ,MAAMM,MAAM,CAACF,SAAS;gBAC/B;YACF;QACF;QAEAG,4BAA4B,CAACpB;YAC3B,MAAMqB,aAAavB,MAAMG,WAAW,CAACD,aAAa;YAClD,IAAIqB,eAAed,WAAW;gBAC5B,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAER,aAAa,UAAU,CAAC;YACjE;YACAH,IAAI,CAACyB;gBACHA,MAAMC,sBAAsB,GAAG;oBAAEvB;oBAAcwB,gBAAgBH,WAAWI,KAAK;gBAAC;YAClF;QACF;QAEAC,6BAA6B,IAC3B7B,IAAI,CAACyB;gBACHA,MAAMC,sBAAsB,GAAGhB;YACjC;IACJ,CAAA,EAAG;AAEH,sFAAsF;AACtF,SAASS,iBAAiBf,WAA2C;IACnE,MAAMc,gBAAgB,IAAIY;IAC1B,KAAK,MAAMxB,SAASO,OAAOC,MAAM,CAACV,aAAc;QAC9C,KAAK,MAAMgB,YAAYP,OAAOC,MAAM,CAACR,MAAMS,aAAa,EAAG;YACzDG,cAAca,GAAG,CAACX;QACpB;IACF;IACA,OAAOF;AACT"}
@@ -17,7 +17,7 @@
17
17
  return (set, get)=>({
18
18
  deletePanel (panelGroupItemId) {
19
19
  set((draft)=>{
20
- const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
20
+ const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
21
21
  const existingGroup = draft.panelGroups[panelGroupId];
22
22
  if (existingGroup === undefined) {
23
23
  throw new Error(`Missing panel group ${panelGroupId}`);
@@ -37,8 +37,8 @@
37
37
  });
38
38
  },
39
39
  openDeletePanelDialog (panelGroupItemId) {
40
- const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
41
- const { panels , panelGroups } = get();
40
+ const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
41
+ const { panels, panelGroups } = get();
42
42
  const panelGroup = panelGroups[panelGroupId];
43
43
  if (panelGroup === undefined) {
44
44
  throw new Error(`Panel group not found ${panelGroupId}`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-slice.ts"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for deleting Panels.\n */\nexport interface DeletePanelSlice {\n /**\n * Delete panels\n */\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * State for the delete panel dialog when it's open, otherwise undefined when it's closed.\n */\n deletePanelDialog?: DeletePanelDialogState;\n\n /**\n * Open delete panel dialog\n */\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Close delete panel dialog\n */\n closeDeletePanelDialog: () => void;\n}\n\nexport interface DeletePanelDialogState {\n panelGroupItemId: PanelGroupItemId;\n panelName: string;\n panelGroupName: string;\n}\n\n/**\n * Curried function for creating the PanelDeleteSlice.\n */\nexport function createDeletePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DeletePanelSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n deletePanel(panelGroupItemId: PanelGroupItemId) {\n set((draft) => {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const existingGroup = draft.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // remove panel from panel group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // See if panel key is still used and if not, delete it\n if (isPanelKeyStillUsed(draft.panelGroups, existingPanelKey) === false) {\n delete draft.panels[existingPanelKey];\n }\n });\n },\n\n openDeletePanelDialog(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n\n const { panels, panelGroups } = get();\n const panelGroup = panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group not found ${panelGroupId}`);\n }\n\n const panelKey = panelGroup.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupLayoutId}`);\n }\n\n const panel = panels[panelKey];\n if (panel === undefined) {\n throw new Error(`Could not find panel ${panelKey}`);\n }\n\n set((state) => {\n state.deletePanelDialog = {\n panelGroupItemId: panelGroupItemId,\n panelName: panel.spec.display.name,\n panelGroupName: panelGroup.title ?? '',\n };\n });\n },\n\n closeDeletePanelDialog() {\n set((state) => {\n state.deletePanelDialog = undefined;\n });\n },\n });\n}\n\n// Helper function to determine if a panel key is still being used somewhere in Panel Groups\nfunction isPanelKeyStillUsed(panelGroups: PanelGroupSlice['panelGroups'], panelKey: string) {\n for (const group of Object.values(panelGroups)) {\n const found = Object.values(group.itemPanelKeys).find((key) => key === panelKey);\n if (found !== undefined) {\n return true;\n }\n }\n return false;\n}\n"],"names":["createDeletePanelSlice","set","get","deletePanel","panelGroupItemId","draft","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","existingGroup","panelGroups","undefined","Error","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingPanelKey","itemPanelKeys","splice","isPanelKeyStillUsed","panels","openDeletePanelDialog","panelGroup","panelKey","panel","state","deletePanelDialog","panelName","spec","display","name","panelGroupName","title","closeDeletePanelDialog","group","Object","values","found","find","key"],"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;AAsCjC;;CAEC,GACD,OAAO,SAASA;IAOd,gGAAgG;IAChG,OAAO,CAACC,KAAKC,MAAS,CAAA;YACpBC,aAAYC,gBAAkC;gBAC5CH,IAAI,CAACI;oBACH,MAAM,EAAEC,aAAY,EAAEC,wBAAwBC,mBAAkB,EAAE,GAAGJ;oBACrE,MAAMK,gBAAgBJ,MAAMK,WAAW,CAACJ,aAAa;oBACrD,IAAIG,kBAAkBE,WAAW;wBAC/B,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEN,aAAa,CAAC;oBACvD;oBACA,MAAMO,oBAAoBJ,cAAcK,YAAYC,UAAU,CAACC,SAAWA,OAAOC,MAAMT;oBACvF,MAAMU,mBAAmBT,cAAcU,aAAa,CAACX,mBAAmB;oBACxE,IAAIK,sBAAsB,CAAC,KAAKK,qBAAqBP,WAAW;wBAC9D,MAAM,IAAIC,MAAM,CAAC,yBAAyB,EAAEJ,mBAAmB,CAAC;oBAClE;oBAEA,gCAAgC;oBAChCC,cAAcK,Y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MAAQA,QAAQhB;QACvE,IAAIc,UAAU5B,WAAW;YACvB,OAAO;QACT;IACF;IACA,OAAO;AACT"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/delete-panel-slice.ts"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\nimport { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for deleting Panels.\n */\nexport interface DeletePanelSlice {\n /**\n * Delete panels\n */\n deletePanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * State for the delete panel dialog when it's open, otherwise undefined when it's closed.\n */\n deletePanelDialog?: DeletePanelDialogState;\n\n /**\n * Open delete panel dialog\n */\n openDeletePanelDialog: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Close delete panel dialog\n */\n closeDeletePanelDialog: () => void;\n}\n\nexport interface DeletePanelDialogState {\n panelGroupItemId: PanelGroupItemId;\n panelName: string;\n panelGroupName: string;\n}\n\n/**\n * Curried function for creating the PanelDeleteSlice.\n */\nexport function createDeletePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DeletePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DeletePanelSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n deletePanel(panelGroupItemId: PanelGroupItemId) {\n set((draft) => {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const existingGroup = draft.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // remove panel from panel group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // See if panel key is still used and if not, delete it\n if (isPanelKeyStillUsed(draft.panelGroups, existingPanelKey) === false) {\n delete draft.panels[existingPanelKey];\n }\n });\n },\n\n openDeletePanelDialog(panelGroupItemId: PanelGroupItemId) {\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n\n const { panels, panelGroups } = get();\n const panelGroup = panelGroups[panelGroupId];\n if (panelGroup === undefined) {\n throw new Error(`Panel group not found ${panelGroupId}`);\n }\n\n const panelKey = panelGroup.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupLayoutId}`);\n }\n\n const panel = panels[panelKey];\n if (panel === undefined) {\n throw new Error(`Could not find panel ${panelKey}`);\n }\n\n set((state) => {\n state.deletePanelDialog = {\n panelGroupItemId: panelGroupItemId,\n panelName: panel.spec.display.name,\n panelGroupName: panelGroup.title ?? '',\n };\n });\n },\n\n closeDeletePanelDialog() {\n set((state) => {\n state.deletePanelDialog = undefined;\n });\n },\n });\n}\n\n// Helper function to determine if a panel key is still being used somewhere in Panel Groups\nfunction isPanelKeyStillUsed(panelGroups: PanelGroupSlice['panelGroups'], panelKey: string) {\n for (const group of Object.values(panelGroups)) {\n const found = Object.values(group.itemPanelKeys).find((key) => key === panelKey);\n if (found !== undefined) {\n return true;\n }\n }\n return false;\n}\n"],"names":["createDeletePanelSlice","set","get","deletePanel","panelGroupItemId","draft","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","existingGroup","panelGroups","undefined","Error","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingPanelKey","itemPanelKeys","splice","isPanelKeyStillUsed","panels","openDeletePanelDialog","panelGroup","panelKey","panel","state","deletePanelDialog","panelName","spec","display","name","panelGroupName","title","closeDeletePanelDialog","group","Object","values","found","find","key"],"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;AAsCjC;;CAEC,GACD,OAAO,SAASA;IAOd,gGAAgG;IAChG,OAAO,CAACC,KAAKC,MAAS,CAAA;YACpBC,aAAYC,gBAAkC;gBAC5CH,IAAI,CAACI;oBACH,MAAM,EAAEC,YAAY,EAAEC,wBAAwBC,kBAAkB,EAAE,GAAGJ;oBACrE,MAAMK,gBAAgBJ,MAAMK,WAAW,CAACJ,aAAa;oBACrD,IAAIG,kBAAkBE,WAAW;wBAC/B,MAAM,IAAIC,MAAM,CAAC,oBAAoB,EAAEN,aAAa,CAAC;oBACvD;oBACA,MAAMO,oBAAoBJ,cAAcK,WAAW,CAACC,SAAS,CAAC,CAACC,SAAWA,OAAOC,CAAC,KAAKT;oBACvF,MAAMU,mBAAmBT,cAAcU,aAAa,CAACX,mBAAmB;oBACxE,IAAIK,sBAAsB,CAAC,KAAKK,qBAAqBP,WAAW;wBAC9D,MAAM,IAAIC,MAAM,CAAC,yBAAyB,EAAEJ,mBAAmB,CAAC;oBAClE;oBAEA,gCAAgC;oBAChCC,cAAcK,WAAW,CAACM,MAAM,CAACP,mBAAmB;oBACpD,OAAOJ,cAAcU,aAAa,CAACX,mBAAmB;oBAEtD,uDAAuD;oBACvD,IAAIa,oBAAoBhB,MAAMK,WAAW,EAAEQ,sBAAsB,OAAO;wBACtE,OAAOb,MAAMiB,MAAM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sources":["../../../src/context/DashboardProvider/discard-changes-dialog-slice.tsx"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\nexport interface DiscardChangesConfirmationDialogSlice {\n discardChangesConfirmationDialog?: DiscardChangesConfirmationDialogState;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n closeDiscardChangesConfirmationDialog: () => void;\n}\n\nexport interface DiscardChangesConfirmationDialogState {\n onDiscardChanges: () => void;\n onCancel: () => void;\n description?: string;\n}\n\nexport const createDiscardChangesDialogSlice: StateCreator<\n DiscardChangesConfirmationDialogSlice,\n Middleware,\n [],\n DiscardChangesConfirmationDialogSlice\n> = (set) => ({\n isOpen: false,\n\n openDiscardChangesConfirmationDialog(dialog) {\n set((state) => {\n state.discardChangesConfirmationDialog = dialog;\n });\n },\n\n closeDiscardChangesConfirmationDialog() {\n set((state) => {\n state.discardChangesConfirmationDialog = undefined;\n });\n },\n});\n"],"names":["createDiscardChangesDialogSlice","set","isOpen","openDiscardChangesConfirmationDialog","dialog","state","discardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","undefined"],"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;AAmBjC,OAAO,MAAMA,kCAKT,CAACC,MAAS,CAAA;QACZC,QAAQ;QAERC,sCAAqCC,MAAM;YACzCH,IAAI,CAACI;gBACHA,MAAMC,mCAAmCF;YAC3C;QACF;QAEAG;YACEN,IAAI,CAACI;gBACHA,MAAMC,mCAAmCE;YAC3C;QACF;IACF,CAAA,EAAG"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/discard-changes-dialog-slice.tsx"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\nexport interface DiscardChangesConfirmationDialogSlice {\n discardChangesConfirmationDialog?: DiscardChangesConfirmationDialogState;\n openDiscardChangesConfirmationDialog: (\n discardChangesConfirmationDialog: DiscardChangesConfirmationDialogState\n ) => void;\n closeDiscardChangesConfirmationDialog: () => void;\n}\n\nexport interface DiscardChangesConfirmationDialogState {\n onDiscardChanges: () => void;\n onCancel: () => void;\n description?: string;\n}\n\nexport const createDiscardChangesDialogSlice: StateCreator<\n DiscardChangesConfirmationDialogSlice,\n Middleware,\n [],\n DiscardChangesConfirmationDialogSlice\n> = (set) => ({\n isOpen: false,\n\n openDiscardChangesConfirmationDialog(dialog) {\n set((state) => {\n state.discardChangesConfirmationDialog = dialog;\n });\n },\n\n closeDiscardChangesConfirmationDialog() {\n set((state) => {\n state.discardChangesConfirmationDialog = undefined;\n });\n },\n});\n"],"names":["createDiscardChangesDialogSlice","set","isOpen","openDiscardChangesConfirmationDialog","dialog","state","discardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","undefined"],"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;AAmBjC,OAAO,MAAMA,kCAKT,CAACC,MAAS,CAAA;QACZC,QAAQ;QAERC,sCAAqCC,MAAM;YACzCH,IAAI,CAACI;gBACHA,MAAMC,gCAAgC,GAAGF;YAC3C;QACF;QAEAG;YACEN,IAAI,CAACI;gBACHA,MAAMC,gCAAgC,GAAGE;YAC3C;QACF;IACF,CAAA,EAAG"}
@@ -20,7 +20,7 @@ import { generateId } from './common';
20
20
  set((state)=>{
21
21
  const panels = state.panels;
22
22
  // Figure out the panel key at that location
23
- const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
23
+ const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
24
24
  const group = state.panelGroups[panelGroupId];
25
25
  if (group === undefined) {
26
26
  throw new Error(`Missing panel group ${panelGroupId}`);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/duplicate-panel-slice.ts"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { getValidPanelKey, insertPanelInLayout, UnpositionedPanelGroupItemLayout } from '../../utils/panelUtils';\nimport { generateId, Middleware } from './common';\nimport { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles duplicating Panels.\n */\nexport interface DuplicatePanelSlice {\n /**\n * Duplicate panel.\n */\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n}\n\n/**\n * Curried function for duplicating a panel.\n */\nexport function createDuplicatePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DuplicatePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DuplicatePanelSlice\n> {\n return (set) => ({\n duplicatePanel(panelGroupItemId: PanelGroupItemId) {\n set((state) => {\n const panels = state.panels;\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const panelKey = group.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToDupe = panels[panelKey];\n if (panelToDupe === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n // Find the layout for the item being duped\n const matchingLayout = group.itemLayouts.find((itemLayout) => {\n return itemLayout.i === panelGroupLayoutId;\n });\n\n if (matchingLayout === undefined) {\n throw new Error(`Cannot find layout for Panel with key '${panelKey}'`);\n }\n\n const dupePanelKey = getValidPanelKey(panelKey, panels);\n\n state.panels[dupePanelKey] = panelToDupe;\n\n const duplicateLayout: UnpositionedPanelGroupItemLayout = {\n i: generateId().toString(),\n w: matchingLayout.w,\n h: matchingLayout.h,\n };\n\n group.itemLayouts = insertPanelInLayout(duplicateLayout, matchingLayout, group.itemLayouts);\n\n group.itemPanelKeys[duplicateLayout.i] = dupePanelKey;\n });\n },\n });\n}\n"],"names":["getValidPanelKey","insertPanelInLayout","generateId","createDuplicatePanelSlice","set","duplicatePanel","panelGroupItemId","state","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","group","panelGroups","undefined","Error","panelKey","itemPanelKeys","panelToDupe","matchingLayout","itemLayouts","find","itemLayout","i","dupePanelKey","duplicateLayout","toString","w","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AE7B,MAAMO,kBAAoD;wBACxDF,GAAGrB,aAAawB;wBAChBC,GAAGR,eAAeQ;wBAClBC,GAAGT,eAAeS;oBACpB;oBAEAhB,MAAMQ,cAAcnB,oBAAoBwB,iBAAiBN,gBAAgBP,MAAMQ;oBAE/ER,MAAMK,aAAa,CAACQ,gBAAgBF,EAAE,GAAGC;gBAC3C;YACF;QACF,CAAA;AACF"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/duplicate-panel-slice.ts"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { getValidPanelKey, insertPanelInLayout, UnpositionedPanelGroupItemLayout } from '../../utils/panelUtils';\nimport { generateId, Middleware } from './common';\nimport { PanelGroupSlice, PanelGroupItemId } from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles duplicating Panels.\n */\nexport interface DuplicatePanelSlice {\n /**\n * Duplicate panel.\n */\n duplicatePanel: (panelGroupItemId: PanelGroupItemId) => void;\n}\n\n/**\n * Curried function for duplicating a panel.\n */\nexport function createDuplicatePanelSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n DuplicatePanelSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n DuplicatePanelSlice\n> {\n return (set) => ({\n duplicatePanel(panelGroupItemId: PanelGroupItemId) {\n set((state) => {\n const panels = state.panels;\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const group = state.panelGroups[panelGroupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n const panelKey = group.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToDupe = panels[panelKey];\n if (panelToDupe === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n // Find the layout for the item being duped\n const matchingLayout = group.itemLayouts.find((itemLayout) => {\n return itemLayout.i === panelGroupLayoutId;\n });\n\n if (matchingLayout === undefined) {\n throw new Error(`Cannot find layout for Panel with key '${panelKey}'`);\n }\n\n const dupePanelKey = getValidPanelKey(panelKey, panels);\n\n state.panels[dupePanelKey] = panelToDupe;\n\n const duplicateLayout: UnpositionedPanelGroupItemLayout = {\n i: generateId().toString(),\n w: matchingLayout.w,\n h: matchingLayout.h,\n };\n\n group.itemLayouts = insertPanelInLayout(duplicateLayout, matchingLayout, group.itemLayouts);\n\n group.itemPanelKeys[duplicateLayout.i] = dupePanelKey;\n });\n },\n });\n}\n"],"names":["getValidPanelKey","insertPanelInLayout","generateId","createDuplicatePanelSlice","set","duplicatePanel","panelGroupItemId","state","panels","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","group","panelGroups","undefined","Error","panelKey","itemPanelKeys","panelToDupe","matchingLayout","itemLayouts","find","itemLayout","i","dupePanelKey","duplicateLayout","toString","w","h"],"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;AAGjC,SAASA,gBAAgB,EAAEC,mBAAmB,QAA0C,yBAAyB;AACjH,SAASC,UAAU,QAAoB,WAAW;AAclD;;CAEC,GACD,OAAO,SAASC;IAOd,OAAO,CAACC,MAAS,CAAA;YACfC,gBAAeC,gBAAkC;gBAC/CF,IAAI,CAACG;oBACH,MAAMC,SAASD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ent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\nexport interface EditJsonDialogSlice {\n editJsonDialog?: EditJsonDialogState;\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n}\n\nexport interface EditJsonDialogState {\n isOpen: boolean;\n}\n\nexport const createEditJsonDialogSlice: StateCreator<EditJsonDialogSlice, Middleware, [], EditJsonDialogSlice> = (\n set\n) => ({\n openEditJsonDialog() {\n set((state) => {\n state.editJsonDialog = {\n isOpen: true,\n };\n });\n },\n\n closeEditJsonDialog() {\n set((state) => {\n state.editJsonDialog = {\n isOpen: false,\n };\n });\n },\n});\n"],"names":["createEditJsonDialogSlice","set","openEditJsonDialog","state","editJsonDialog","isOpen","closeEditJsonDialog"],"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,OAAO,MAAMA,4BAAoG,CAC/GC,MACI,CAAA;QACJC;YACED,IAAI,CAACE;gBACHA,MAAMC,iBAAiB;oBACrBC,QAAQ;gBACV;YACF;QACF;QAEAC;YACEL,IAAI,CAACE;gBACHA,MAAMC,iBAAiB;oBACrBC,QAAQ;gBACV;YACF;QACF;IACF,CAAA,EAAG"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/edit-json-dialog-slice.tsx"],"sourcesContent":["// Copyright 2023 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 { StateCreator } from 'zustand';\nimport { Middleware } from './common';\n\nexport interface EditJsonDialogSlice {\n editJsonDialog?: EditJsonDialogState;\n openEditJsonDialog: () => void;\n closeEditJsonDialog: () => void;\n}\n\nexport interface EditJsonDialogState {\n isOpen: boolean;\n}\n\nexport const createEditJsonDialogSlice: StateCreator<EditJsonDialogSlice, Middleware, [], EditJsonDialogSlice> = (\n set\n) => ({\n openEditJsonDialog() {\n set((state) => {\n state.editJsonDialog = {\n isOpen: true,\n };\n });\n },\n\n closeEditJsonDialog() {\n set((state) => {\n state.editJsonDialog = {\n isOpen: false,\n };\n });\n },\n});\n"],"names":["createEditJsonDialogSlice","set","openEditJsonDialog","state","editJsonDialog","isOpen","closeEditJsonDialog"],"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,OAAO,MAAMA,4BAAoG,CAC/GC,MACI,CAAA;QACJC;YACED,IAAI,CAACE;gBACHA,MAAMC,cAAc,GAAG;oBACrBC,QAAQ;gBACV;YACF;QACF;QAEAC;YACEL,IAAI,CAACE;gBACHA,MAAMC,cAAc,GAAG;oBACrBC,QAAQ;gBACV;YACF;QACF;IACF,CAAA,EAAG"}
@@ -17,14 +17,13 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
17
17
  * Curried function for creating the PanelEditorSlice.
18
18
  */ export function createPanelEditorSlice() {
19
19
  // Return the state creator function for Zustand that uses the panels provided as intitial state
20
- return (set, get)=>{
21
- return {
20
+ return (set, get)=>({
22
21
  panelEditor: undefined,
23
22
  openEditPanel (panelGroupItemId) {
24
23
  var _panelGroups_panelGroupId;
25
- const { panels , panelGroups } = get();
24
+ const { panels, panelGroups } = get();
26
25
  // Figure out the panel key at that location
27
- const { panelGroupId , panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
26
+ const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;
28
27
  const panelKey = (_panelGroups_panelGroupId = panelGroups[panelGroupId]) === null || _panelGroups_panelGroupId === void 0 ? void 0 : _panelGroups_panelGroupId.itemPanelKeys[panelGroupLayoutId];
29
28
  if (panelKey === undefined) {
30
29
  throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);
@@ -141,8 +140,7 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
141
140
  state.panelEditor = editorState;
142
141
  });
143
142
  }
144
- };
145
- };
143
+ });
146
144
  }
147
145
 
148
146
  //# sourceMappingURL=panel-editor-slice.js.map