@perses-dev/dashboards 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/cjs/components/Dashboard.js +4 -5
  2. package/dist/cjs/components/DashboardToolbar.js +11 -5
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +3 -11
  4. package/dist/cjs/components/GridLayout/GridLayout.js +8 -6
  5. package/dist/cjs/components/GridLayout/GridTitle.js +9 -11
  6. package/dist/cjs/components/Panel/DeletePanelDialog.js +12 -8
  7. package/dist/cjs/components/Panel/Panel.js +4 -13
  8. package/dist/cjs/components/Panel/Panel.test.js +4 -3
  9. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -1
  10. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +3 -3
  11. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +21 -15
  12. package/dist/cjs/components/PanelDrawer/PanelPreview.js +9 -3
  13. package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
  14. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -111
  15. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +22 -16
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
  17. package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
  18. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
  19. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
  20. package/dist/cjs/components/Variables/Variable.js +1 -0
  21. package/dist/cjs/components/Variables/VariableEditor.js +33 -0
  22. package/dist/cjs/components/Variables/VariableList.js +0 -1
  23. package/dist/cjs/components/index.js +1 -0
  24. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +20 -8
  25. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +122 -29
  26. package/dist/cjs/context/DashboardProvider/{panel-editing-slice.js → panel-editor-slice.js} +32 -13
  27. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +102 -0
  28. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +187 -17
  29. package/dist/cjs/context/TimeRangeProvider.js +20 -44
  30. package/dist/cjs/context/index.js +1 -1
  31. package/dist/cjs/context/useDashboardSpec.js +61 -0
  32. package/dist/cjs/index.js +1 -0
  33. package/dist/cjs/test/render.js +25 -5
  34. package/dist/cjs/test/setup-tests.js +4 -1
  35. package/dist/cjs/test/testDashboard.js +11 -10
  36. package/dist/cjs/utils/index.js +28 -0
  37. package/dist/cjs/utils/time-range-params.js +145 -0
  38. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -4
  39. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
  40. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +42 -93
  41. package/dist/components/Dashboard.js +5 -6
  42. package/dist/components/Dashboard.js.map +1 -1
  43. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  44. package/dist/components/DashboardToolbar.js +13 -7
  45. package/dist/components/DashboardToolbar.js.map +1 -1
  46. package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
  47. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  48. package/dist/components/GridLayout/GridItemContent.js +4 -12
  49. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  50. package/dist/components/GridLayout/GridLayout.d.ts +2 -3
  51. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  52. package/dist/components/GridLayout/GridLayout.js +9 -7
  53. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  54. package/dist/components/GridLayout/GridTitle.d.ts +2 -1
  55. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  56. package/dist/components/GridLayout/GridTitle.js +10 -12
  57. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  58. package/dist/components/Panel/DeletePanelDialog.d.ts +1 -1
  59. package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -1
  60. package/dist/components/Panel/DeletePanelDialog.js +13 -9
  61. package/dist/components/Panel/DeletePanelDialog.js.map +1 -1
  62. package/dist/components/Panel/Panel.d.ts +2 -2
  63. package/dist/components/Panel/Panel.d.ts.map +1 -1
  64. package/dist/components/Panel/Panel.js +5 -14
  65. package/dist/components/Panel/Panel.js.map +1 -1
  66. package/dist/components/Panel/Panel.test.d.ts +1 -1
  67. package/dist/components/Panel/Panel.test.d.ts.map +1 -1
  68. package/dist/components/Panel/Panel.test.js +4 -3
  69. package/dist/components/Panel/Panel.test.js.map +1 -1
  70. package/dist/components/PanelDrawer/PanelDrawer.js +2 -2
  71. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  72. package/dist/components/PanelDrawer/PanelDrawer.test.js +3 -3
  73. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  74. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
  75. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  76. package/dist/components/PanelDrawer/PanelEditorForm.js +22 -16
  77. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  78. package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
  79. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  80. package/dist/components/PanelDrawer/PanelPreview.js +9 -3
  81. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  82. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
  83. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  84. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
  85. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  86. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
  87. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  88. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -112
  89. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  90. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -15
  91. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
  92. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
  93. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
  94. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
  95. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
  96. package/dist/components/PanelGroupDialog/index.d.ts +3 -0
  97. package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
  98. package/dist/components/PanelGroupDialog/index.js +16 -0
  99. package/dist/components/PanelGroupDialog/index.js.map +1 -0
  100. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  101. package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
  102. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  103. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
  104. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  105. package/dist/components/Variables/Variable.js +1 -0
  106. package/dist/components/Variables/Variable.js.map +1 -1
  107. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  108. package/dist/components/Variables/VariableEditor.js +33 -0
  109. package/dist/components/Variables/VariableEditor.js.map +1 -1
  110. package/dist/components/Variables/VariableList.js +0 -1
  111. package/dist/components/Variables/VariableList.js.map +1 -1
  112. package/dist/components/index.d.ts +1 -0
  113. package/dist/components/index.d.ts.map +1 -1
  114. package/dist/components/index.js +1 -0
  115. package/dist/components/index.js.map +1 -1
  116. package/dist/context/DashboardProvider/DashboardProvider.d.ts +7 -5
  117. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  118. package/dist/context/DashboardProvider/DashboardProvider.js +19 -7
  119. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  120. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +64 -22
  121. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  122. package/dist/context/DashboardProvider/dashboard-provider-api.js +133 -26
  123. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  124. package/dist/context/DashboardProvider/index.d.ts +2 -0
  125. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  126. package/dist/context/DashboardProvider/index.js.map +1 -1
  127. package/dist/context/DashboardProvider/{panel-editing-slice.d.ts → panel-editor-slice.d.ts} +28 -13
  128. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
  129. package/dist/context/DashboardProvider/{panel-editing-slice.js → panel-editor-slice.js} +33 -14
  130. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
  131. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +40 -0
  132. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
  133. package/dist/context/DashboardProvider/panel-group-editor-slice.js +96 -0
  134. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
  135. package/dist/context/DashboardProvider/panel-group-slice.d.ts +75 -10
  136. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  137. package/dist/context/DashboardProvider/panel-group-slice.js +189 -17
  138. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  139. package/dist/context/TimeRangeProvider.d.ts +9 -2
  140. package/dist/context/TimeRangeProvider.d.ts.map +1 -1
  141. package/dist/context/TimeRangeProvider.js +15 -43
  142. package/dist/context/TimeRangeProvider.js.map +1 -1
  143. package/dist/context/index.d.ts +1 -1
  144. package/dist/context/index.d.ts.map +1 -1
  145. package/dist/context/index.js +1 -1
  146. package/dist/context/index.js.map +1 -1
  147. package/dist/context/useDashboardSpec.d.ts +3 -0
  148. package/dist/context/useDashboardSpec.d.ts.map +1 -0
  149. package/dist/context/useDashboardSpec.js +55 -0
  150. package/dist/context/useDashboardSpec.js.map +1 -0
  151. package/dist/index.d.ts +1 -0
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +1 -0
  154. package/dist/index.js.map +1 -1
  155. package/dist/test/render.d.ts +2 -1
  156. package/dist/test/render.d.ts.map +1 -1
  157. package/dist/test/render.js +25 -5
  158. package/dist/test/render.js.map +1 -1
  159. package/dist/test/setup-tests.d.ts.map +1 -1
  160. package/dist/test/setup-tests.js +4 -0
  161. package/dist/test/setup-tests.js.map +1 -1
  162. package/dist/test/testDashboard.d.ts.map +1 -1
  163. package/dist/test/testDashboard.js +11 -10
  164. package/dist/test/testDashboard.js.map +1 -1
  165. package/dist/utils/index.d.ts +2 -0
  166. package/dist/utils/index.d.ts.map +1 -0
  167. package/dist/utils/index.js +15 -0
  168. package/dist/utils/index.js.map +1 -0
  169. package/dist/utils/time-range-params.d.ts +25 -0
  170. package/dist/utils/time-range-params.d.ts.map +1 -0
  171. package/dist/utils/time-range-params.js +137 -0
  172. package/dist/utils/time-range-params.js.map +1 -0
  173. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  174. package/dist/views/ViewDashboard/DashboardApp.js +1 -3
  175. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  176. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  177. package/dist/views/ViewDashboard/ViewDashboard.js +5 -22
  178. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  179. package/dist/views/ViewDashboard/tests/panelGroups.test.js +45 -96
  180. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  181. package/package.json +5 -4
  182. package/dist/cjs/context/DashboardProvider/layout-slice.js +0 -200
  183. package/dist/cjs/context/QueryStringProvider.js +0 -89
  184. package/dist/context/DashboardProvider/layout-slice.d.ts +0 -57
  185. package/dist/context/DashboardProvider/layout-slice.d.ts.map +0 -1
  186. package/dist/context/DashboardProvider/layout-slice.js +0 -196
  187. package/dist/context/DashboardProvider/layout-slice.js.map +0 -1
  188. package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +0 -1
  189. package/dist/context/DashboardProvider/panel-editing-slice.js.map +0 -1
  190. package/dist/context/QueryStringProvider.d.ts +0 -13
  191. package/dist/context/QueryStringProvider.d.ts.map +0 -1
  192. package/dist/context/QueryStringProvider.js +0 -40
  193. package/dist/context/QueryStringProvider.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/Panel.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState, useMemo } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { useInView } from 'react-intersection-observer';\nimport { ErrorBoundary, ErrorAlert, InfoTooltip, TooltipPlacement } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport {\n Box,\n Card,\n CardProps,\n CardHeader,\n CardContent,\n Typography,\n IconButton as MuiIconButton,\n Stack,\n styled,\n} from '@mui/material';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\nimport { usePanels, useEditMode } from '../../context';\nimport { PanelContent } from './PanelContent';\n\nexport interface PanelProps extends CardProps {\n definition: PanelDefinition;\n groupIndex: number;\n itemIndex: number;\n}\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n */\nexport function Panel(props: PanelProps) {\n const { definition, groupIndex, itemIndex, ...others } = props;\n\n const [contentElement, setContentElement] = useState<HTMLDivElement | null>(null);\n const [isHovered, setIsHovered] = useState(false);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const { ref, inView } = useInView({\n threshold: 0.3,\n initialInView: false,\n triggerOnce: true,\n });\n\n // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart\n const panelPadding = 1.5;\n\n const { isEditMode } = useEditMode();\n\n const { editPanel, openDeletePanelDialog } = usePanels();\n\n const handleEditButtonClick = () => {\n editPanel({ groupIndex, itemIndex });\n };\n\n return (\n <Card\n ref={ref}\n sx={{\n ...others.sx,\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n }}\n variant=\"outlined\"\n {...others}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n <CardHeader\n title={\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n minHeight: '24px',\n }}\n >\n <Typography\n component=\"h2\"\n variant=\"body2\"\n fontWeight={(theme) => theme.typography.fontWeightMedium}\n whiteSpace=\"nowrap\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n >\n {definition.spec.display.name}\n </Typography>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n marginLeft: 'auto',\n }}\n >\n {!isEditMode && isHovered && definition.spec.display.description && (\n <InfoTooltip\n id=\"info-tooltip\"\n description={definition.spec.display.description}\n placement={TooltipPlacement.Bottom}\n >\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"small\"\n sx={{ cursor: 'pointer' }}\n />\n </InfoTooltip>\n )}\n {isEditMode && isHovered && (\n <Stack direction=\"row\" alignItems=\"center\" spacing={0.5}>\n <IconButton aria-label=\"edit panel\" size=\"small\" onClick={handleEditButtonClick}>\n <PencilIcon />\n </IconButton>\n <IconButton\n aria-label=\"delete panel\"\n size=\"small\"\n onClick={() => openDeletePanelDialog({ groupIndex, itemIndex })}\n >\n <DeleteIcon />\n </IconButton>\n <IconButton aria-label=\"drag handle\" size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </IconButton>\n </Stack>\n )}\n </Box>\n </Box>\n }\n sx={{\n display: 'block',\n padding: (theme) => theme.spacing(1, panelPadding),\n borderBottom: (theme) => `solid 1px ${theme.palette.divider}`,\n }}\n />\n <CardContent\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n padding: (theme) => theme.spacing(panelPadding),\n // Override MUI default style for last-child\n ':last-child': {\n padding: (theme) => theme.spacing(panelPadding),\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {inView === true && (\n <PanelContent\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n />\n )}\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n}\n\nconst IconButton = styled(MuiIconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["useState","useMemo","useResizeObserver","useInView","ErrorBoundary","ErrorAlert","InfoTooltip","TooltipPlacement","Box","Card","CardHeader","CardContent","Typography","IconButton","MuiIconButton","Stack","styled","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","usePanels","useEditMode","PanelContent","Panel","props","definition","groupIndex","itemIndex","others","contentElement","setContentElement","isHovered","setIsHovered","width","height","ref","contentDimensions","undefined","inView","threshold","initialInView","triggerOnce","panelPadding","isEditMode","editPanel","openDeletePanelDialog","handleEditButtonClick","sx","display","flexFlow","variant","onMouseEnter","onMouseLeave","title","alignItems","minHeight","component","fontWeight","theme","typography","fontWeightMedium","whiteSpace","overflow","textOverflow","spec","name","marginLeft","description","id","placement","Bottom","aria-describedby","aria-hidden","fontSize","cursor","direction","spacing","aria-label","size","onClick","className","padding","borderBottom","palette","divider","position","flexGrow","FallbackComponent","panelPluginKind","plugin","kind","borderRadius","shape"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0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BACa;cACJ;;MACT,CACP;AACJ,CAAC;AAED,MAAMxB,UAAU,GAAGG,MAAM,CAACF,aAAa,CAAC,CAAC,CAAC,EAAE6C,KAAK,CAAA,EAAE,GAAM,CAAA;QACvDiC,YAAY,EAAEjC,KAAK,CAACkC,KAAK,CAACD,YAAY;QACtCV,OAAO,EAAE,KAAK;KACf,CAAA,AAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../../src/components/Panel/Panel.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState, useMemo } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { useInView } from 'react-intersection-observer';\nimport { ErrorBoundary, ErrorAlert, InfoTooltip, TooltipPlacement } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport {\n Box,\n Card,\n CardProps,\n CardHeader,\n CardContent,\n Typography,\n IconButton as MuiIconButton,\n Stack,\n styled,\n} from '@mui/material';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/Pencil';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\nimport { useEditMode, LayoutItem, usePanelActions } from '../../context';\nimport { PanelContent } from './PanelContent';\n\nexport interface PanelProps extends CardProps {\n definition: PanelDefinition;\n panelGroupItemId: LayoutItem;\n}\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n */\nexport function Panel(props: PanelProps) {\n const { definition, panelGroupItemId, ...others } = props;\n\n const [contentElement, setContentElement] = useState<HTMLDivElement | null>(null);\n const [isHovered, setIsHovered] = useState(false);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const { ref, inView } = useInView({\n threshold: 0.3,\n initialInView: false,\n triggerOnce: true,\n });\n\n // TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart\n const panelPadding = 1.5;\n\n const { isEditMode } = useEditMode();\n\n const { openEditPanel, openDeletePanelDialog } = usePanelActions(panelGroupItemId);\n\n return (\n <Card\n ref={ref}\n sx={{\n ...others.sx,\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n }}\n variant=\"outlined\"\n {...others}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n <CardHeader\n title={\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n minHeight: '24px',\n }}\n >\n <Typography\n component=\"h2\"\n variant=\"body2\"\n fontWeight={(theme) => theme.typography.fontWeightMedium}\n whiteSpace=\"nowrap\"\n overflow=\"hidden\"\n textOverflow=\"ellipsis\"\n >\n {definition.spec.display.name}\n </Typography>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n marginLeft: 'auto',\n }}\n >\n {!isEditMode && isHovered && definition.spec.display.description && (\n <InfoTooltip\n id=\"info-tooltip\"\n description={definition.spec.display.description}\n placement={TooltipPlacement.Bottom}\n >\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"small\"\n sx={{ cursor: 'pointer' }}\n />\n </InfoTooltip>\n )}\n {isEditMode && isHovered && (\n <Stack direction=\"row\" alignItems=\"center\" spacing={0.5}>\n <IconButton aria-label=\"edit panel\" size=\"small\" onClick={openEditPanel}>\n <PencilIcon />\n </IconButton>\n <IconButton aria-label=\"delete panel\" size=\"small\" onClick={openDeletePanelDialog}>\n <DeleteIcon />\n </IconButton>\n <IconButton aria-label=\"drag handle\" size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </IconButton>\n </Stack>\n )}\n </Box>\n </Box>\n }\n sx={{\n display: 'block',\n padding: (theme) => theme.spacing(1, panelPadding),\n borderBottom: (theme) => `solid 1px ${theme.palette.divider}`,\n }}\n />\n <CardContent\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n padding: (theme) => theme.spacing(panelPadding),\n // Override MUI default style for last-child\n ':last-child': {\n padding: (theme) => theme.spacing(panelPadding),\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n {inView === true && (\n <PanelContent\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n />\n )}\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n}\n\nconst IconButton = styled(MuiIconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["useState","useMemo","useResizeObserver","useInView","ErrorBoundary","ErrorAlert","InfoTooltip","TooltipPlacement","Box","Card","CardHeader","CardContent","Typography","IconButton","MuiIconButton","Stack","styled","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","useEditMode","usePanelActions","PanelContent","Panel","props","definition","panelGroupItemId","others","contentElement","setContentElement","isHovered","setIsHovered","width","height","ref","contentDimensions","undefined","inView","threshold","initialInView","triggerOnce","panelPadding","isEditMode","openEditPanel","openDeletePanelDialog","sx","display","flexFlow","variant","onMouseEnter","onMouseLeave","title","alignItems","minHeight","component","fontWeight","theme","typography","fontWeightMedium","whiteSpace","overflow","textOverflow","spec","name","marginLeft","description","id","placement","Bottom","aria-describedby","aria-hidden","fontSize","cursor","direction","spacing","aria-label","size","onClick","className","padding","borderBottom","palette","divider","position","flexGrow","FallbackComponent","panelPluginKind","plugin","kind","borderRadius","shape"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,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E,KAAK;KACf,CAAA,AAAC,CAAC,AAAC"}
@@ -1,2 +1,2 @@
1
- import 'intersection-observer';
1
+ export {};
2
2
  //# sourceMappingURL=Panel.test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Panel.test.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.test.tsx"],"names":[],"mappings":"AAcA,OAAO,uBAAuB,CAAC"}
1
+ {"version":3,"file":"Panel.test.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.test.tsx"],"names":[],"mappings":""}
@@ -12,7 +12,6 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { PluginRegistry } from '@perses-dev/plugin-system';
15
- import 'intersection-observer'; // TODO: Why do we need this side-effect? Should it be in test setup somewhere?
16
15
  import { screen } from '@testing-library/react';
17
16
  import userEvent from '@testing-library/user-event';
18
17
  import { renderWithContext, mockPluginRegistryProps, FAKE_PANEL_PLUGIN, getTestDashboard } from '../../test';
@@ -35,8 +34,10 @@ describe('Panel', ()=>{
35
34
  }
36
35
  }
37
36
  },
38
- groupIndex: 0,
39
- itemIndex: 0
37
+ panelGroupItemId: {
38
+ panelGroupId: 0,
39
+ itemIndex: 0
40
+ }
40
41
  };
41
42
  };
42
43
  // Helper to render the panel with some context set
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/Panel.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginRegistry } from '@perses-dev/plugin-system';\nimport 'intersection-observer'; // TODO: Why do we need this side-effect? Should it be in test setup somewhere?\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { renderWithContext, mockPluginRegistryProps, FAKE_PANEL_PLUGIN, getTestDashboard } from '../../test';\nimport { DashboardProvider } from '../../context';\nimport { Panel, PanelProps } from './Panel';\n\ndescribe('Panel', () => {\n // Helper to create panel props for rendering tests\n const createPanelProps = (): PanelProps => {\n return {\n definition: {\n kind: 'Panel',\n spec: {\n display: {\n name: 'Fake Panel',\n description: 'This is a fake panel',\n },\n plugin: {\n kind: 'FakePanel',\n spec: {},\n },\n },\n },\n groupIndex: 0,\n itemIndex: 0,\n };\n };\n\n // Helper to render the panel with some context set\n const renderPanel = (isEditMode = false) => {\n const { addMockPlugin, pluginRegistryProps } = mockPluginRegistryProps();\n addMockPlugin('Panel', 'FakePanel', FAKE_PANEL_PLUGIN);\n\n renderWithContext(\n <PluginRegistry {...pluginRegistryProps}>\n <DashboardProvider initialState={{ dashboardSpec: getTestDashboard().spec, isEditMode }}>\n <Panel {...createPanelProps()} />\n </DashboardProvider>\n </PluginRegistry>\n );\n };\n\n it('should render name and info icon', async () => {\n renderPanel();\n await screen.findByText('Fake Panel');\n screen.queryByLabelText('info-tooltip');\n });\n\n it('should render edit icons when in edit mode', () => {\n renderPanel(true);\n const panelTitle = screen.getByText('Fake Panel');\n userEvent.hover(panelTitle);\n screen.getByLabelText('drag handle');\n screen.getByLabelText('edit panel');\n screen.getByLabelText('delete panel');\n });\n});\n"],"names":["PluginRegistry","screen","userEvent","renderWithContext","mockPluginRegistryProps","FAKE_PANEL_PLUGIN","getTestDashboard","DashboardProvider","Panel","describe","createPanelProps","definition","kind","spec","display","name","description","plugin","groupIndex","itemIndex","renderPanel","isEditMode","addMockPlugin","pluginRegistryProps","initialState","dashboardSpec","it","findByText","queryByLabelText","panelTitle","getByText","hover","getByLabelText"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAA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AA,KAACb,KAAK;oBAAE,GAAGE,gBAAgB,EAAE;kBAAI;cACf;UACL,CAClB,CAAC;IACJ,CAAC,AAAC;IAEFgB,EAAE,CAAC,kCAAkC,EAAE,UAAY;QACjDN,WAAW,EAAE,CAAC;QACd,MAAMnB,MAAM,CAAC0B,UAAU,CAAC,YAAY,CAAC,CAAC;QACtC1B,MAAM,CAAC2B,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEHF,EAAE,CAAC,4CAA4C,EAAE,IAAM;QACrDN,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,MAAMS,UAAU,GAAG5B,MAAM,CAAC6B,SAAS,CAAC,YAAY,CAAC,AAAC;QAClD5B,SAAS,CAAC6B,KAAK,CAACF,UAAU,CAAC,CAAC;QAC5B5B,MAAM,CAAC+B,cAAc,CAAC,aAAa,CAAC,CAAC;QACrC/B,MAAM,CAAC+B,cAAc,CAAC,YAAY,CAAC,CAAC;QACpC/B,MAAM,CAAC+B,cAAc,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/Panel/Panel.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginRegistry } from '@perses-dev/plugin-system';\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { renderWithContext, mockPluginRegistryProps, FAKE_PANEL_PLUGIN, getTestDashboard } from '../../test';\nimport { DashboardProvider } from '../../context';\nimport { Panel, PanelProps } from './Panel';\n\ndescribe('Panel', () => {\n // Helper to create panel props for rendering tests\n const createPanelProps = (): PanelProps => {\n return {\n definition: {\n kind: 'Panel',\n spec: {\n display: {\n name: 'Fake Panel',\n description: 'This is a fake panel',\n },\n plugin: {\n kind: 'FakePanel',\n spec: {},\n },\n },\n },\n panelGroupItemId: { panelGroupId: 0, itemIndex: 0 },\n };\n };\n\n // Helper to render the panel with some context set\n const renderPanel = (isEditMode = false) => {\n const { addMockPlugin, pluginRegistryProps } = mockPluginRegistryProps();\n addMockPlugin('Panel', 'FakePanel', FAKE_PANEL_PLUGIN);\n\n renderWithContext(\n <PluginRegistry {...pluginRegistryProps}>\n <DashboardProvider initialState={{ dashboardSpec: getTestDashboard().spec, isEditMode }}>\n <Panel {...createPanelProps()} />\n </DashboardProvider>\n </PluginRegistry>\n );\n };\n\n it('should render name and info icon', async () => {\n renderPanel();\n await screen.findByText('Fake Panel');\n screen.queryByLabelText('info-tooltip');\n });\n\n it('should render edit icons when in edit mode', () => {\n renderPanel(true);\n const panelTitle = screen.getByText('Fake Panel');\n userEvent.hover(panelTitle);\n screen.getByLabelText('drag handle');\n screen.getByLabelText('edit panel');\n screen.getByLabelText('delete panel');\n });\n});\n"],"names":["PluginRegistry","screen","userEvent","renderWithContext","mockPluginRegistryProps","FAKE_PANEL_PLUGIN","getTestDashboard","DashboardProvider","Panel","describe","createPanelProps","definition","kind","spec","display","name","description","plugin","panelGroupItemId","panelGroupId","itemIndex","renderPanel","isEditMode","addMockPlugin","pluginRegistryProps","initialState","dashboardSpec","it","findByText","queryByLabelText","panelTitle","getByText","hover","getByLabelText"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,cAAc,QAAQ,2BAA2B,CAAC;AAC3D,SAASC,MAAM,Q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C;QACd,MAAMpB,MAAM,CAAC2B,UAAU,CAAC,YAAY,CAAC,CAAC;QACtC3B,MAAM,CAAC4B,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IAEHF,EAAE,CAAC,4CAA4C,EAAE,IAAM;QACrDN,WAAW,CAAC,IAAI,CAAC,CAAC;QAClB,MAAMS,UAAU,GAAG7B,MAAM,CAAC8B,SAAS,CAAC,YAAY,CAAC,AAAC;QAClD7B,SAAS,CAAC8B,KAAK,CAACF,UAAU,CAAC,CAAC;QAC5B7B,MAAM,CAACgC,cAAc,CAAC,aAAa,CAAC,CAAC;QACrChC,MAAM,CAACgC,cAAc,CAAC,YAAY,CAAC,CAAC;QACpChC,MAAM,CAACgC,cAAc,CAAC,cAAc,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -14,12 +14,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
14
14
  import { useState } from 'react';
15
15
  import { Stack, Box, Button, Typography } from '@mui/material';
16
16
  import { Drawer } from '@perses-dev/components';
17
- import { usePanels } from '../../context';
17
+ import { usePanelEditor } from '../../context';
18
18
  import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
19
19
  /**
20
20
  * The Add/Edit panel drawer for editing a panel's options.
21
21
  */ export const PanelDrawer = ()=>{
22
- const { panelEditor } = usePanels();
22
+ const panelEditor = usePanelEditor();
23
23
  // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
24
24
  const [isClosing, setIsClosing] = useState(false);
25
25
  const handleClose = ()=>setIsClosing(true);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Stack, Box, Button, Typography } from '@mui/material';\nimport { Drawer } from '@perses-dev/components';\nimport { usePanels } from '../../context';\nimport { PanelEditorForm, panelEditorFormId, PanelEditorFormProps } from './PanelEditorForm';\n\n/**\n * The Add/Edit panel drawer for editing a panel's options.\n */\nexport const PanelDrawer = () => {\n const { panelEditor } = usePanels();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n const handleClose = () => setIsClosing(true);\n\n // Don't call closeDrawer on the store until the Drawer has completely transitioned out\n const handleExited = () => {\n panelEditor?.close();\n setIsClosing(false);\n };\n\n // Drawer is open if we have a model and we're not transitioning out\n const isOpen = panelEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelEditorFormProps['onSubmit'] = (values) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Drawer isOpen={isOpen} onClose={handleClose} SlideProps={{ onExited: handleExited }}>\n {/* When the drawer is opened, we should have panel editor state (this also ensures the form state gets reset between opens) */}\n {panelEditor !== undefined && (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n marginBottom: (theme) => theme.spacing(2),\n paddingBottom: (theme) => theme.spacing(2),\n borderBottom: (theme) => `1px solid ${theme.palette.grey[100]}`,\n }}\n >\n <Typography variant=\"h2\">{panelEditor.mode} Panel</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {/* Using the 'form' attribute lets us have a submit button like this outside the form element */}\n <Button type=\"submit\" variant=\"contained\" form={panelEditorFormId}>\n {panelEditor.mode === 'Add' ? 'Add' : 'Apply'}\n </Button>\n <Button variant=\"outlined\" onClick={handleClose}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <PanelEditorForm onSubmit={handleSubmit} initialValues={panelEditor.initialValues} />\n </>\n )}\n </Drawer>\n );\n};\n"],"names":["useState","Stack","Box","Button","Typography","Drawer","usePanels","PanelEditorForm","panelEditorFormId","PanelDrawer","panelEditor","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","onClose","SlideProps","onExited","sx","display","alignItems","marginBottom","theme","spacing","paddingBottom","borderBottom","palette","grey","variant","mode","direction","marginLeft","type","form","onClick","onSubmit","initialValues"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC/D,SAASC,MAAM,QAAQ,wBAAwB,CAAC;AAChD,SAASC,SAAS,QAAQ,eAAe,CAAC;AAC1C,SAASC,eAAe,EAAEC,iBAAiB,QAA8B,mBAAmB,CAAC;AAE7F;;CAEC,GACD,OAAO,MAAMC,WAAW,GAAG,IAAM;IAC/B,MAAM,EAAEC,WAAW,CAAA,EAAE,GAAGJ,SAAS,EAAE,AAAC;IAEpC,iHAAiH;IACjH,MAAM,CAACK,SAAS,EAAEC,YAAY,CAAC,GAAGZ,QAAQ,CAAC,KAAK,CAAC,AAAC;IAClD,MAAMa,WAAW,GAAG,IAAMD,YAAY,CAAC,IAAI,CAAC,AAAC;IAE7C,uFAAuF;IACvF,MAAME,YAAY,GAAG,IAAM;QACzBJ,WAAW,aAAXA,WAAW,WAAO,GAAlBA,KAAAA,CAAkB,GAAlBA,WAAW,CAAEK,KAAK,EAA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,OAAO,EAAC,WAAW;oCAACK,IAAI,EAAEhC,iBAAiB;8CAC9DE,WAAW,CAAC0B,IAAI,KAAK,KAAK,GAAG,KAAK,GAAG,OAAO;kCACtC;8CACT,KAACjC,MAAM;oCAACgC,OAAO,EAAC,UAAU;oCAACM,OAAO,EAAE5B,WAAW;8CAAE,QAEjD;kCAAS;;0BACH;;kBACJ;8BACN,KAACN,eAAe;oBAACmC,QAAQ,EAAExB,YAAY;oBAAEyB,aAAa,EAAEjC,WAAW,CAACiC,aAAa;kBAAI;;UACpF,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { Stack, Box, Button, Typography } from '@mui/material';\nimport { Drawer } from '@perses-dev/components';\nimport { usePanelEditor } from '../../context';\nimport { PanelEditorForm, panelEditorFormId, PanelEditorFormProps } from './PanelEditorForm';\n\n/**\n * The Add/Edit panel drawer for editing a panel's options.\n */\nexport const PanelDrawer = () => {\n const panelEditor = usePanelEditor();\n\n // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation\n const [isClosing, setIsClosing] = useState(false);\n const handleClose = () => setIsClosing(true);\n\n // Don't call closeDrawer on the store until the Drawer has completely transitioned out\n const handleExited = () => {\n panelEditor?.close();\n setIsClosing(false);\n };\n\n // Drawer is open if we have a model and we're not transitioning out\n const isOpen = panelEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelEditorFormProps['onSubmit'] = (values) => {\n // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy\n if (panelEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Drawer isOpen={isOpen} onClose={handleClose} SlideProps={{ onExited: handleExited }}>\n {/* When the drawer is opened, we should have panel editor state (this also ensures the form state gets reset between opens) */}\n {panelEditor !== undefined && (\n <>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n marginBottom: (theme) => theme.spacing(2),\n paddingBottom: (theme) => theme.spacing(2),\n borderBottom: (theme) => `1px solid ${theme.palette.grey[100]}`,\n }}\n >\n <Typography variant=\"h2\">{panelEditor.mode} Panel</Typography>\n <Stack direction=\"row\" spacing={1} sx={{ marginLeft: 'auto' }}>\n {/* Using the 'form' attribute lets us have a submit button like this outside the form element */}\n <Button type=\"submit\" variant=\"contained\" form={panelEditorFormId}>\n {panelEditor.mode === 'Add' ? 'Add' : 'Apply'}\n </Button>\n <Button variant=\"outlined\" onClick={handleClose}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <PanelEditorForm onSubmit={handleSubmit} initialValues={panelEditor.initialValues} />\n </>\n )}\n </Drawer>\n );\n};\n"],"names":["useState","Stack","Box","Button","Typography","Drawer","usePanelEditor","PanelEditorForm","panelEditorFormId","PanelDrawer","panelEditor","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","onClose","SlideProps","onExited","sx","display","alignItems","marginBottom","theme","spacing","paddingBottom","borderBottom","palette","grey","variant","mode","direction","marginLeft","type","form","onClick","onSubmit","initialValues"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,KAAK,EAAEC,GAAG,E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AAQ;wBACpBC,YAAY,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;wBACzCC,aAAa,EAAE,CAACF,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;wBAC1CE,YAAY,EAAE,CAACH,KAAK,GAAK,CAAC,UAAU,EAAEA,KAAK,CAACI,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;qBAChE;;sCAED,MAAC9B,UAAU;4BAAC+B,OAAO,EAAC,IAAI;;gCAAEzB,WAAW,CAAC0B,IAAI;gCAAC,QAAM;;0BAAa;sCAC9D,MAACnC,KAAK;4BAACoC,SAAS,EAAC,KAAK;4BAACP,OAAO,EAAE,CAAC;4BAAEL,EAAE,EAAE;gCAAEa,UAAU,EAAE,MAAM;6BAAE;;8CAE3D,KAACnC,MAAM;oCAACoC,IAAI,EAAC,QAAQ;oCAACJ,OAAO,EAAC,WAAW;oCAACK,IAAI,EAAEhC,iBAAiB;8CAC9DE,WAAW,CAAC0B,IAAI,KAAK,KAAK,GAAG,KAAK,GAAG,OAAO;kCACtC;8CACT,KAACjC,MAAM;oCAACgC,OAAO,EAAC,UAAU;oCAACM,OAAO,EAAE5B,WAAW;8CAAE,QAEjD;kCAAS;;0BACH;;kBACJ;8BACN,KAACN,eAAe;oBAACmC,QAAQ,EAAExB,YAAY;oBAAEyB,aAAa,EAAEjC,WAAW,CAACiC,aAAa;kBAAI;;UACpF,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
@@ -45,7 +45,7 @@ describe('Panel Drawer', ()=>{
45
45
  it('should add new panel', async ()=>{
46
46
  const storeApi = renderPanelDrawer();
47
47
  // Open the drawer for a new panel (i.e. no panel key)
48
- act(()=>storeApi.getState().addPanel(0));
48
+ act(()=>storeApi.getState().openAddPanel(0));
49
49
  const nameInput = await screen.findByLabelText(/Name/);
50
50
  userEvent.type(nameInput, 'New Panel');
51
51
  userEvent.click(screen.getByText('Add'));
@@ -70,8 +70,8 @@ describe('Panel Drawer', ()=>{
70
70
  it('should edit an existing panel', async ()=>{
71
71
  const storeApi = renderPanelDrawer();
72
72
  // Open the drawer for an existing panel
73
- act(()=>storeApi.getState().editPanel({
74
- groupIndex: 0,
73
+ act(()=>storeApi.getState().openEditPanel({
74
+ panelGroupId: 0,
75
75
  itemIndex: 0
76
76
  }));
77
77
  const nameInput = await screen.findByLabelText(/Name/);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginRegistry } from '@perses-dev/plugin-system';\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport {\n createDashboardProviderSpy,\n FAKE_PANEL_PLUGIN,\n getTestDashboard,\n mockPluginRegistryProps,\n renderWithContext,\n} from '../../test';\nimport { DashboardProvider } from '../../context/DashboardProvider';\nimport { PanelDrawer } from './PanelDrawer';\n\ndescribe('Panel Drawer', () => {\n const renderPanelDrawer = () => {\n const { addMockPlugin, pluginRegistryProps } = mockPluginRegistryProps();\n addMockPlugin('Panel', 'TimeSeriesChart', FAKE_PANEL_PLUGIN);\n\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <PluginRegistry {...pluginRegistryProps}>\n <DashboardProvider initialState={{ dashboardSpec: getTestDashboard().spec, isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelDrawer />\n </DashboardProvider>\n </PluginRegistry>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel', async () => {\n const storeApi = renderPanelDrawer();\n\n // Open the drawer for a new panel (i.e. no panel key)\n act(() => storeApi.getState().addPanel(0));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'New Panel');\n userEvent.click(screen.getByText('Add'));\n\n // TODO: Assert drawer is closed?\n const panels = storeApi.getState().panels;\n expect(panels).toMatchObject({\n // Should have the new panel in the store\n NewPanel: {\n kind: 'Panel',\n spec: {\n display: { name: 'New Panel' },\n plugin: {\n kind: '',\n spec: {},\n },\n },\n },\n });\n });\n\n it('should edit an existing panel', async () => {\n const storeApi = renderPanelDrawer();\n\n // Open the drawer for an existing panel\n act(() => storeApi.getState().editPanel({ groupIndex: 0, itemIndex: 0 }));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.clear(nameInput);\n userEvent.type(nameInput, 'cpu usage');\n userEvent.click(screen.getByText('Apply'));\n\n const panels = storeApi.getState().panels;\n expect(panels).toMatchObject({\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'cpu usage' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {},\n },\n },\n },\n });\n });\n});\n"],"names":["PluginRegistry","screen","userEvent","act","createDashboardProviderSpy","FAKE_PANEL_PLUGIN","getTestDashboard","mockPluginRegistryProps","renderWithContext","DashboardProvider","PanelDrawer","describe","renderPanelDrawer","addMockPlugin","pluginRegistryProps","store","DashboardProviderSpy","initialState","dashboardSpec","spec","isEditMode","value","storeApi","undefined","Error","it","getState","addPanel","nameInput","findByLabelText","type","click","getByText","panels","expect","toMatchObject","NewPanel","kind","display","name","plugin","editPanel","groupIndex","itemIndex","clear","cpu"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,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AAK,CAAC9B,MAAM,CAAC+B,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAE3C,MAAMC,MAAM,GAAGX,QAAQ,CAACI,QAAQ,EAAE,CAACO,MAAM,AAAC;QAC1CC,MAAM,CAACD,MAAM,CAAC,CAACE,aAAa,CAAC;YAC3BU,GAAG,EAAE;gBACHR,IAAI,EAAE,OAAO;gBACblB,IAAI,EAAE;oBACJmB,OAAO,EAAE;wBAAEC,IAAI,EAAE,WAAW;qBAAE;oBAC9BC,MAAM,EAAE;wBACNH,IAAI,EAAE,iBAAiB;wBACvBlB,IAAI,EAAE,EAAE;qBACT;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelDrawer.test.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PluginRegistry } from '@perses-dev/plugin-system';\nimport { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport {\n createDashboardProviderSpy,\n FAKE_PANEL_PLUGIN,\n getTestDashboard,\n mockPluginRegistryProps,\n renderWithContext,\n} from '../../test';\nimport { DashboardProvider } from '../../context/DashboardProvider';\nimport { PanelDrawer } from './PanelDrawer';\n\ndescribe('Panel Drawer', () => {\n const renderPanelDrawer = () => {\n const { addMockPlugin, pluginRegistryProps } = mockPluginRegistryProps();\n addMockPlugin('Panel', 'TimeSeriesChart', FAKE_PANEL_PLUGIN);\n\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <PluginRegistry {...pluginRegistryProps}>\n <DashboardProvider initialState={{ dashboardSpec: getTestDashboard().spec, isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelDrawer />\n </DashboardProvider>\n </PluginRegistry>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel', async () => {\n const storeApi = renderPanelDrawer();\n\n // Open the drawer for a new panel (i.e. no panel key)\n act(() => storeApi.getState().openAddPanel(0));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'New Panel');\n userEvent.click(screen.getByText('Add'));\n\n // TODO: Assert drawer is closed?\n const panels = storeApi.getState().panels;\n expect(panels).toMatchObject({\n // Should have the new panel in the store\n NewPanel: {\n kind: 'Panel',\n spec: {\n display: { name: 'New Panel' },\n plugin: {\n kind: '',\n spec: {},\n },\n },\n },\n });\n });\n\n it('should edit an existing panel', async () => {\n const storeApi = renderPanelDrawer();\n\n // Open the drawer for an existing panel\n act(() => storeApi.getState().openEditPanel({ panelGroupId: 0, itemIndex: 0 }));\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.clear(nameInput);\n userEvent.type(nameInput, 'cpu usage');\n userEvent.click(screen.getByText('Apply'));\n\n const panels = storeApi.getState().panels;\n expect(panels).toMatchObject({\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'cpu usage' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {},\n },\n },\n },\n });\n });\n});\n"],"names":["PluginRegistry","screen","userEvent","act","createDashboardProviderSpy","FAKE_PANEL_PLUGIN","getTestDashboard","mockPluginRegistryProps","renderWithContext","DashboardProvider","PanelDrawer","describe","renderPanelDrawer","addMockPlugin","pluginRegistryProps","store","DashboardProviderSpy","initialState","dashboardSpec","spec","isEditMode","value","storeApi","undefined","Error","it","getState","openAddPanel","nameInput","findByLabelText","type","click","getByText","panels","expect","toMatchObject","NewP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AMf,SAAS,GAAG,MAAM3B,MAAM,CAAC4B,eAAe,QAAQ,AAAC;QACvD3B,SAAS,CAAC0C,KAAK,CAAChB,SAAS,CAAC,CAAC;QAC3B1B,SAAS,CAAC4B,IAAI,CAACF,SAAS,EAAE,WAAW,CAAC,CAAC;QACvC1B,SAAS,CAAC6B,KAAK,CAAC9B,MAAM,CAAC+B,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAE3C,MAAMC,MAAM,GAAGX,QAAQ,CAACI,QAAQ,EAAE,CAACO,MAAM,AAAC;QAC1CC,MAAM,CAACD,MAAM,CAAC,CAACE,aAAa,CAAC;YAC3BU,GAAG,EAAE;gBACHR,IAAI,EAAE,OAAO;gBACblB,IAAI,EAAE;oBACJmB,OAAO,EAAE;wBAAEC,IAAI,EAAE,WAAW;qBAAE;oBAC9BC,MAAM,EAAE;wBACNH,IAAI,EAAE,iBAAiB;wBACvBlB,IAAI,EAAE,EAAE;qBACT;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { PanelEditorValues } from '../../context/DashboardProvider/panel-editing-slice';
2
+ import { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';
3
3
  export interface PanelEditorFormProps {
4
4
  initialValues: PanelEditorValues;
5
5
  onSubmit: (values: PanelEditorValues) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":";AA4BA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAGxF,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eA+F1D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
1
+ {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":";AA4BA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAGvF,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,QAAQ,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAqG1D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
@@ -15,15 +15,15 @@ import { useState } from 'react';
15
15
  import { FormControl, FormHelperText, Grid, InputLabel, MenuItem, Select, TextField, Typography } from '@mui/material';
16
16
  import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
17
17
  import { PluginKindSelect, PluginSpecEditor, usePluginEditor } from '@perses-dev/plugin-system';
18
- import { useLayouts } from '../../context';
18
+ import { useListPanelGroups } from '../../context';
19
19
  import { PanelPreview } from './PanelPreview';
20
20
  export function PanelEditorForm(props) {
21
21
  var ref;
22
22
  const { initialValues , onSubmit } = props;
23
- const { layouts } = useLayouts();
23
+ const panelGroups = useListPanelGroups();
24
24
  const [name, setName] = useState(initialValues.name);
25
25
  const [description, setDescription] = useState(initialValues.description);
26
- const [groupIndex, setGroupIndex] = useState(initialValues.groupIndex);
26
+ const [groupId, setGroupId] = useState(initialValues.groupId);
27
27
  const [kind, setKind] = useState(initialValues.kind);
28
28
  const [spec, setSpec] = useState(initialValues.spec);
29
29
  // Use common plugin editor logic even though we've split the inputs up in this form
@@ -44,35 +44,38 @@ export function PanelEditorForm(props) {
44
44
  if (typeof value === 'string') {
45
45
  return;
46
46
  }
47
- setGroupIndex(value);
47
+ setGroupId(value);
48
48
  };
49
49
  const handleSubmit = (e)=>{
50
50
  e.preventDefault();
51
- if (spec === undefined) {
52
- throw new Error('Cannot submit without a plugin spec');
53
- }
54
51
  const values = {
55
52
  name,
56
53
  description,
57
- groupIndex,
54
+ groupId,
58
55
  kind,
59
56
  spec
60
57
  };
61
58
  onSubmit(values);
62
59
  };
63
60
  var _title, ref1;
64
- return /*#__PURE__*/ _jsx("form", {
61
+ return(// Grid maxHeight allows user to scroll inside Drawer to see all content
62
+ /*#__PURE__*/ _jsx("form", {
65
63
  id: panelEditorFormId,
66
64
  onSubmit: handleSubmit,
67
65
  children: /*#__PURE__*/ _jsxs(Grid, {
68
66
  container: true,
69
67
  spacing: 2,
68
+ sx: {
69
+ overflowY: 'scroll',
70
+ maxHeight: '90vh'
71
+ },
70
72
  children: [
71
73
  /*#__PURE__*/ _jsx(Grid, {
72
74
  item: true,
73
75
  xs: 8,
74
76
  children: /*#__PURE__*/ _jsx(TextField, {
75
77
  required: true,
78
+ fullWidth: true,
76
79
  label: "Name",
77
80
  value: name,
78
81
  variant: "outlined",
@@ -83,6 +86,7 @@ export function PanelEditorForm(props) {
83
86
  item: true,
84
87
  xs: 4,
85
88
  children: /*#__PURE__*/ _jsxs(FormControl, {
89
+ fullWidth: true,
86
90
  children: [
87
91
  /*#__PURE__*/ _jsx(InputLabel, {
88
92
  id: "select-group",
@@ -92,12 +96,12 @@ export function PanelEditorForm(props) {
92
96
  required: true,
93
97
  labelId: "select-group",
94
98
  label: "Group",
95
- value: groupIndex !== null && groupIndex !== void 0 ? groupIndex : 0,
99
+ value: groupId,
96
100
  onChange: handleGroupChange,
97
- children: layouts.map((layout, index)=>/*#__PURE__*/ _jsx(MenuItem, {
98
- value: index,
99
- children: (_title = layout.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
100
- }, index))
101
+ children: panelGroups.map((panelGroup, index)=>/*#__PURE__*/ _jsx(MenuItem, {
102
+ value: panelGroup.id,
103
+ children: (_title = panelGroup.title) !== null && _title !== void 0 ? _title : `Group ${index + 1}`
104
+ }, panelGroup.id))
101
105
  })
102
106
  ]
103
107
  })
@@ -106,6 +110,7 @@ export function PanelEditorForm(props) {
106
110
  item: true,
107
111
  xs: 8,
108
112
  children: /*#__PURE__*/ _jsx(TextField, {
113
+ fullWidth: true,
109
114
  label: "Description",
110
115
  value: description,
111
116
  variant: "outlined",
@@ -117,6 +122,7 @@ export function PanelEditorForm(props) {
117
122
  xs: 4,
118
123
  children: [
119
124
  /*#__PURE__*/ _jsxs(FormControl, {
125
+ fullWidth: true,
120
126
  disabled: pluginEditor.isLoading,
121
127
  error: pluginEditor.error !== null,
122
128
  children: [
@@ -155,7 +161,7 @@ export function PanelEditorForm(props) {
155
161
  name: name,
156
162
  description: description,
157
163
  spec: spec,
158
- groupIndex: groupIndex
164
+ groupId: groupId
159
165
  })
160
166
  })
161
167
  ]
@@ -175,7 +181,7 @@ export function PanelEditorForm(props) {
175
181
  })
176
182
  ]
177
183
  })
178
- });
184
+ }));
179
185
  }
180
186
  /**
181
187
  * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEventHandler, useState } from 'react';\nimport {\n FormControl,\n FormHelperText,\n Grid,\n InputLabel,\n MenuItem,\n Select,\n SelectProps,\n TextField,\n Typography,\n} from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PluginKindSelect, PluginSpecEditor, usePluginEditor } from '@perses-dev/plugin-system';\nimport { useLayouts } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editing-slice';\nimport { PanelPreview } from './PanelPreview';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n onSubmit: (values: PanelEditorValues) => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const { initialValues, onSubmit } = props;\n\n const { layouts } = useLayouts();\n\n const [name, setName] = useState(initialValues.name);\n const [description, setDescription] = useState(initialValues.description);\n const [groupIndex, setGroupIndex] = useState(initialValues.groupIndex);\n const [kind, setKind] = useState(initialValues.kind);\n const [spec, setSpec] = useState(initialValues.spec);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind, spec },\n onChange: (plugin) => {\n setKind(plugin.kind);\n setSpec(plugin.spec);\n },\n });\n\n // Ignore string values (which would be an \"empty\" value from the Select) since we don't allow them to unset it\n const handleGroupChange: SelectProps<number>['onChange'] = (e) => {\n const { value } = e.target;\n if (typeof value === 'string') {\n return;\n }\n setGroupIndex(value);\n };\n\n const handleSubmit: FormEventHandler = (e) => {\n e.preventDefault();\n if (spec === undefined) {\n throw new Error('Cannot submit without a plugin spec');\n }\n const values: PanelEditorValues = { name, description, groupIndex, kind, spec };\n onSubmit(values);\n };\n\n return (\n <form id={panelEditorFormId} onSubmit={handleSubmit}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <TextField required label=\"Name\" value={name} variant=\"outlined\" onChange={(e) => setName(e.target.value)} />\n </Grid>\n <Grid item xs={4}>\n <FormControl>\n <InputLabel id=\"select-group\">Group</InputLabel>\n <Select required labelId=\"select-group\" label=\"Group\" value={groupIndex ?? 0} onChange={handleGroupChange}>\n {layouts.map((layout, index) => (\n <MenuItem key={index} value={index}>\n {layout.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n <Grid item xs={8}>\n <TextField\n label=\"Description\"\n value={description}\n variant=\"outlined\"\n onChange={(e) => setDescription(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl disabled={pluginEditor.isLoading} error={pluginEditor.error !== null}>\n <InputLabel id=\"panel-type-label\">Type</InputLabel>\n <PluginKindSelect\n pluginType=\"Panel\"\n required\n labelId=\"panel-type-label\"\n label=\"Type\"\n value={pluginEditor.pendingKind ? pluginEditor.pendingKind : kind}\n onChange={pluginEditor.onKindChange}\n />\n </FormControl>\n <FormHelperText>{pluginEditor.error?.message ?? ''}</FormHelperText>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview kind={kind} name={name} description={description} spec={spec} groupIndex={groupIndex} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PluginSpecEditor pluginType=\"Panel\" pluginKind={kind} value={spec} onChange={pluginEditor.onSpecChange} />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </form>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useState","FormControl","FormHelperText","Grid","InputLabel","MenuItem","Select","TextField","Typography","ErrorAlert","ErrorBoundary","PluginKindSelect","PluginSpecEditor","usePluginEditor","useLayouts","PanelPreview","PanelEditorForm","props","pluginEditor","initialValues","onSubmit","layouts","name","setName","description","setDescription","groupIndex","setGroupIndex","kind","setKind","spec","setSpec","pluginType","value","onChange","plugin","handleGroupChange","e","target","handleSubmit","preventDefault","undefined","Error","values","layout","form","id","panelEditorFormId","container","spacing","item","xs","required","label","variant","labelId","map","index","title","disabled","isLoading","error","pendingKind","onKindChange","message","marginBottom","FallbackComponent","pluginKind","onSpecChange"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,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1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEventHandler, useState } from 'react';\nimport {\n FormControl,\n FormHelperText,\n Grid,\n InputLabel,\n MenuItem,\n Select,\n SelectProps,\n TextField,\n Typography,\n} from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { PluginKindSelect, PluginSpecEditor, usePluginEditor } from '@perses-dev/plugin-system';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { PanelPreview } from './PanelPreview';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n onSubmit: (values: PanelEditorValues) => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const { initialValues, onSubmit } = props;\n\n const panelGroups = useListPanelGroups();\n\n const [name, setName] = useState(initialValues.name);\n const [description, setDescription] = useState(initialValues.description);\n const [groupId, setGroupId] = useState(initialValues.groupId);\n const [kind, setKind] = useState(initialValues.kind);\n const [spec, setSpec] = useState(initialValues.spec);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind, spec },\n onChange: (plugin) => {\n setKind(plugin.kind);\n setSpec(plugin.spec);\n },\n });\n\n // Ignore string values (which would be an \"empty\" value from the Select) since we don't allow them to unset it\n const handleGroupChange: SelectProps<number>['onChange'] = (e) => {\n const { value } = e.target;\n if (typeof value === 'string') {\n return;\n }\n setGroupId(value);\n };\n\n const handleSubmit: FormEventHandler = (e) => {\n e.preventDefault();\n const values: PanelEditorValues = { name, description, groupId, kind, spec };\n onSubmit(values);\n };\n\n return (\n // Grid maxHeight allows user to scroll inside Drawer to see all content\n <form id={panelEditorFormId} onSubmit={handleSubmit}>\n <Grid container spacing={2} sx={{ overflowY: 'scroll', maxHeight: '90vh' }}>\n <Grid item xs={8}>\n <TextField\n required\n fullWidth\n label=\"Name\"\n value={name}\n variant=\"outlined\"\n onChange={(e) => setName(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl fullWidth>\n <InputLabel id=\"select-group\">Group</InputLabel>\n <Select required labelId=\"select-group\" label=\"Group\" value={groupId} onChange={handleGroupChange}>\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </Select>\n </FormControl>\n </Grid>\n <Grid item xs={8}>\n <TextField\n fullWidth\n label=\"Description\"\n value={description}\n variant=\"outlined\"\n onChange={(e) => setDescription(e.target.value)}\n />\n </Grid>\n <Grid item xs={4}>\n <FormControl fullWidth disabled={pluginEditor.isLoading} error={pluginEditor.error !== null}>\n <InputLabel id=\"panel-type-label\">Type</InputLabel>\n <PluginKindSelect\n pluginType=\"Panel\"\n required\n labelId=\"panel-type-label\"\n label=\"Type\"\n value={pluginEditor.pendingKind ? pluginEditor.pendingKind : kind}\n onChange={pluginEditor.onKindChange}\n />\n </FormControl>\n <FormHelperText>{pluginEditor.error?.message ?? ''}</FormHelperText>\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview kind={kind} name={name} description={description} spec={spec} groupId={groupId} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PluginSpecEditor pluginType=\"Panel\" pluginKind={kind} value={spec} onChange={pluginEditor.onSpecChange} />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </form>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useState","FormControl","FormHelperText","Grid","InputLabel","MenuItem","Select","TextField","Typography","ErrorAlert","ErrorBoundary","PluginKindSelect","PluginSpecEditor","usePluginEditor","useListPanelGroups","PanelPreview","PanelEditorForm","props","pluginEditor","initialValues","onSubmit","panelGroups","name","setName","description","setDescription","groupId","setGroupId","kind","setKind","spec","setSpec","pluginType","value","onChange","plugin","handleGroupChange","e","target","handleSubmit","preventDefault","values","panelGroup","form","id","panelEditorFormId","container","spacing","sx","overflowY","maxHeight","item","xs","required","fullWidth","label","variant","labelId","map","index","title","disabled","isLoading","error","pendingKind","onKindChange","message","marginBottom","FallbackComponent","pluginKind","onSpecChange"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAA2BA,QAAQ,QAAQ,OAAO,CAAC;AACnD,SACEC,WAAW,EACXC,cAAc,EACdC,IAAI,EACJC,UAAU,EACVC,QAAQ,EACRC,MAAM,EAENC,SAAS,EACTC,UAAU,QACL,eAAe,CAAC;AACvB,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,gBAAgB,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,2BAA2B,CAAC;AAChG,SAASC,kBAAkB,QAAQ,eAAe,CAAC;AAEnD,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;QAmFlCC,GAAkB;IAlF3C,MAAM,EAAEC,aAAa,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAG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,KAAC5C,UAAU;4BAACgD,OAAO,EAAC,IAAI;4BAACW,YAAY,EAAE,CAAC;sCAAE,SAE1C;0BAAa;sCACb,KAACzD,aAAa;4BAAC0D,iBAAiB,EAAE3D,UAAU;sCAC1C,cAAA,KAACM,YAAY;gCAACa,IAAI,EAAEA,IAAI;gCAAEN,IAAI,EAAEA,IAAI;gCAAEE,WAAW,EAAEA,WAAW;gCAAEM,IAAI,EAAEA,IAAI;gCAAEJ,OAAO,EAAEA,OAAO;8BAAI;0BAClF;;kBACX;8BACP,KAACvB,IAAI;oBAACgD,IAAI;oBAACC,EAAE,EAAE,EAAE;8BACf,cAAA,KAAC1C,aAAa;wBAAC0D,iBAAiB,EAAE3D,UAAU;kCAC1C,cAAA,KAACG,gBAAgB;4BAACoB,UAAU,EAAC,OAAO;4BAACqC,UAAU,EAAEzC,IAAI;4BAAEK,KAAK,EAAEH,IAAI;4BAAEI,QAAQ,EAAEhB,YAAY,CAACoD,YAAY;0BAAI;sBAC7F;kBACX;;UACF;MACF,EACP;AACJ,CAAC;AAED;;CAEC,GACD,OAAO,MAAMzB,iBAAiB,GAAG,mBAAmB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import { PanelEditorValues } from '../../context/DashboardProvider/panel-editing-slice';
3
- export declare function PanelPreview({ name, description, kind, spec, groupIndex }: PanelEditorValues): JSX.Element;
2
+ import { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';
3
+ export declare function PanelPreview({ name, description, kind, spec, groupId }: PanelEditorValues): JSX.Element | null;
4
4
  //# sourceMappingURL=PanelPreview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qDAAqD,CAAC;AAGxF,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,iBAAiB,eAwB5F"}
1
+ {"version":3,"file":"PanelPreview.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAGvF,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,iBAAiB,sBA4BzF"}
@@ -13,7 +13,7 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { Panel } from '../Panel';
16
- export function PanelPreview({ name , description , kind , spec , groupIndex }) {
16
+ export function PanelPreview({ name , description , kind , spec , groupId }) {
17
17
  const previewValues = {
18
18
  definition: {
19
19
  kind: 'Panel',
@@ -28,9 +28,15 @@ export function PanelPreview({ name , description , kind , spec , groupIndex })
28
28
  }
29
29
  }
30
30
  },
31
- groupIndex,
32
- itemIndex: 0
31
+ // TODO: what should itemIndex be?
32
+ panelGroupItemId: {
33
+ panelGroupId: groupId,
34
+ itemIndex: 0
35
+ }
33
36
  };
37
+ if (!kind) {
38
+ return null;
39
+ }
34
40
  return /*#__PURE__*/ _jsx(Box, {
35
41
  height: 300,
36
42
  children: /*#__PURE__*/ _jsx(Panel, {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editing-slice';\nimport { Panel, PanelProps } from '../Panel';\n\nexport function PanelPreview({ name, description, kind, spec, groupIndex }: PanelEditorValues) {\n const previewValues: PanelProps = {\n definition: {\n kind: 'Panel',\n spec: {\n display: {\n name,\n description,\n },\n plugin: {\n kind,\n spec,\n },\n },\n },\n groupIndex,\n itemIndex: 0, // TODO: what should itemIndex be?\n };\n\n return (\n <Box height={300}>\n <Panel {...previewValues} />\n </Box>\n );\n}\n"],"names":["Box","Panel","PanelPreview","name","description","kind","spec","groupIndex","previewValues","definition","display","plugin","itemIndex","height"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AAEpC,SAASC,KAAK,QAAoB,UAAU,CAAC;AAE7C,OAAO,SAASC,YAAY,CAAC,EAAEC,IAAI,CAAA,EAAEC,WAAW,CAAA,EAAEC,IAAI,CAAA,EAAEC,IAAI,CAAA,EAAEC,UAAU,CAAA,EAAqB,EAAE;IAC7F,MAAMC,aAAa,GAAe;QAChCC,UAAU,EAAE;YACVJ,IAAI,EAAE,OAAO;YACbC,IAAI,EAAE;gBACJI,OAAO,EAAE;oBACPP,IAAI;oBACJC,WAAW;iBACZ;gBACDO,MAAM,EAAE;oBACNN,IAAI;oBACJC,IAAI;iBACL;aACF;SACF;QACDC,UAAU;QACVK,SAAS,EAAE,CAAC;KACb,AAAC;IAEF,qBACE,KAACZ,GAAG;QAACa,MAAM,EAAE,GAAG;kBACd,cAAA,KAACZ,KAAK;YAAE,GAAGO,aAAa;UAAI;MACxB,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/PanelDrawer/PanelPreview.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { Panel, PanelProps } from '../Panel';\n\nexport function PanelPreview({ name, description, kind, spec, groupId }: PanelEditorValues) {\n const previewValues: PanelProps = {\n definition: {\n kind: 'Panel',\n spec: {\n display: {\n name,\n description,\n },\n plugin: {\n kind,\n spec,\n },\n },\n },\n // TODO: what should itemIndex be?\n panelGroupItemId: { panelGroupId: groupId, itemIndex: 0 },\n };\n\n if (!kind) {\n return null;\n }\n\n return (\n <Box height={300}>\n <Panel {...previewValues} />\n </Box>\n );\n}\n"],"names":["Box","Panel","PanelPreview","name","description","kind","spec","groupId","previewValues","definition","display","plugin","panelGroupItemId","panelGroupId","itemIndex","height"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AAEpC,SAASC,KAAK,QAAoB,UAAU,CAAC;AAE7C,OAAO,SAASC,YAAY,CAAC,EAAEC,IAAI,CAAA,EAAEC,WAAW,CAAA,EAAEC,IAAI,CAAA,EAAEC,IAAI,CAAA,EAAEC,OAAO,CAAA,EAAqB,EAAE;IAC1F,MAAMC,aAAa,GAAe;QAChCC,UAAU,EAAE;YACVJ,IAAI,EAAE,OAAO;YACbC,IAAI,EAAE;gBACJI,OAAO,EAAE;oBACPP,IAAI;oBACJC,WAAW;iBACZ;gBACDO,MAAM,EAAE;oBACNN,IAAI;oBACJC,IAAI;iBACL;aACF;SACF;QACD,kCAAkC;QAClCM,gBAAgB,EAAE;YAAEC,YAAY,EAAEN,OAAO;YAAEO,SAAS,EAAE,CAAC;SAAE;KAC1D,AAAC;IAEF,IAAI,CAACT,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,qBACE,KAACL,GAAG;QAACe,MAAM,EAAE,GAAG;kBACd,cAAA,KAACd,KAAK;YAAE,GAAGO,aAAa;UAAI;MACxB,CACN;AACJ,CAAC"}
@@ -1,4 +1,3 @@
1
1
  /// <reference types="react" />
2
- declare const DeletePanelGroupDialog: () => JSX.Element;
3
- export default DeletePanelGroupDialog;
2
+ export declare const DeletePanelGroupDialog: () => JSX.Element;
4
3
  //# sourceMappingURL=DeletePanelGroupDialog.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DeletePanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/DeletePanelGroupDialog.tsx"],"names":[],"mappings":";AAkBA,QAAA,MAAM,sBAAsB,mBA4C3B,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"DeletePanelGroupDialog.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/DeletePanelGroupDialog.tsx"],"names":[],"mappings":";AAkBA,eAAO,MAAM,sBAAsB,mBA0ClC,CAAC"}
@@ -13,20 +13,19 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';
15
15
  import CloseIcon from 'mdi-material-ui/Close';
16
- import { usePanelGroupDialog, useLayouts } from '../../context';
17
- const DeletePanelGroupDialog = ()=>{
18
- var ref;
19
- const { layouts , deletePanelGroup } = useLayouts();
20
- const { deletePanelGroupDialog , closeDeletePanelGroupDialog } = usePanelGroupDialog();
21
- const groupIndex = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.groupIndex;
16
+ import { useDeletePanelGroupDialog } from '../../context';
17
+ export const DeletePanelGroupDialog = ()=>{
18
+ const { deletePanelGroupDialog , closeDeletePanelGroupDialog , deletePanelGroup } = useDeletePanelGroupDialog();
19
+ const panelGroupId = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.panelGroupId;
22
20
  const handleDelete = (e)=>{
23
21
  e.preventDefault();
24
- if (groupIndex == undefined) {
22
+ if (panelGroupId == undefined) {
25
23
  throw new Error('group index is undefined');
26
24
  }
27
- deletePanelGroup(groupIndex);
25
+ deletePanelGroup(panelGroupId);
28
26
  closeDeletePanelGroupDialog();
29
27
  };
28
+ var ref;
30
29
  return /*#__PURE__*/ _jsxs(Dialog, {
31
30
  open: deletePanelGroupDialog !== undefined,
32
31
  children: [
@@ -46,11 +45,15 @@ const DeletePanelGroupDialog = ()=>{
46
45
  /*#__PURE__*/ _jsxs("form", {
47
46
  onSubmit: handleDelete,
48
47
  children: [
49
- /*#__PURE__*/ _jsx(DialogContent, {
48
+ /*#__PURE__*/ _jsxs(DialogContent, {
50
49
  sx: {
51
50
  width: '500px'
52
51
  },
53
- children: `Are you sure you want to delete ${groupIndex !== undefined && layouts[groupIndex] !== undefined ? (ref = layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.title : 'panel group'}? This will delete all the panels within the group.`
52
+ children: [
53
+ "Are you sure you want to delete ",
54
+ (ref = deletePanelGroupDialog === null || deletePanelGroupDialog === void 0 ? void 0 : deletePanelGroupDialog.panelGroupName) !== null && ref !== void 0 ? ref : 'panel group',
55
+ "? This will delete all the panels within the group."
56
+ ]
54
57
  }),
55
58
  /*#__PURE__*/ _jsxs(DialogActions, {
56
59
  children: [
@@ -70,6 +73,5 @@ const DeletePanelGroupDialog = ()=>{
70
73
  ]
71
74
  });
72
75
  };
73
- export default DeletePanelGroupDialog;
74
76
 
75
77
  //# sourceMappingURL=DeletePanelGroupDialog.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelGroupDialog/DeletePanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { usePanelGroupDialog, useLayouts } from '../../context';\n\nconst DeletePanelGroupDialog = () => {\n const { layouts, deletePanelGroup } = useLayouts();\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog } = usePanelGroupDialog();\n\n const groupIndex = deletePanelGroupDialog?.groupIndex;\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n if (groupIndex == undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(groupIndex);\n closeDeletePanelGroupDialog();\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <DialogTitle>Delete Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>\n {`Are you sure you want to delete ${\n groupIndex !== undefined && layouts[groupIndex] !== undefined ? layouts[groupIndex]?.title : 'panel group'\n }? This will delete all the panels within the group.`}\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelGroupDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n\nexport default DeletePanelGroupDialog;\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","usePanelGroupDialog","useLayouts","DeletePanelGroupDialog","layouts","deletePanelGroup","deletePanelGroupDialog","closeDeletePanelGroupDialog","groupIndex","handleDelete","e","preventDefault","undefined","Error","open","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","width","title","variant","type"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,mBAAmB,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAEhE,MAAMC,sBAAsB,GAAG,IAAM;QAgCuCC,GAAmB;IA/B7F,MAAM,EAAEA,OAAO,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGH,UAAU,EAAE,AAAC;IACnD,MAAM,EAAEI,sBAAsB,CAAA,EAAEC,2BAA2B,CAAA,EAAE,GAAGN,mBAAmB,EAAE,AAAC;IAEtF,MAAMO,UAAU,GAAGF,sBAAsB,aAAtBA,sBAAsB,WAAY,GAAlCA,KAAAA,CAAkC,GAAlCA,sBAAsB,CAAEE,UAAU,AAAC;IAEtD,MAAMC,YAAY,GAAG,CAACC,CAAY,GAAK;QACrCA,CAAC,CAACC,cAAc,EAAE,CAAC;QACnB,IAAIH,UAAU,IAAII,SAAS,EAAE;YAC3B,MAAM,IAAIC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QACDR,gBAAgB,CAACG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sx"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEvent } from 'react';\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useDeletePanelGroupDialog } from '../../context';\n\nexport const DeletePanelGroupDialog = () => {\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = useDeletePanelGroupDialog();\n\n const panelGroupId = deletePanelGroupDialog?.panelGroupId;\n\n const handleDelete = (e: FormEvent) => {\n e.preventDefault();\n if (panelGroupId == undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(panelGroupId);\n closeDeletePanelGroupDialog();\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <DialogTitle>Delete Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={() => closeDeletePanelGroupDialog()}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <form onSubmit={handleDelete}>\n <DialogContent sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelGroupDialog?.panelGroupName ?? 'panel group'}? This will delete\n all the panels within the group.\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button onClick={() => closeDeletePanelGroupDialog()}>Cancel</Button>\n </DialogActions>\n </form>\n </Dialog>\n );\n};\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useDeletePanelGroupDialog","DeletePanelGroupDialog","deletePanelGroupDialog","closeDeletePanelGroupDialog","deletePanelGroup","panelGroupId","handleDelete","e","preventDefault","undefined","Error","open","aria-label","onClick","sx","theme","position","top","spacing","right","form","onSubmit","width","panelGroupName","variant","type"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,eAAe,CAAC;AACtG,OAAOC,SAAS,MAAM,uBAAuB,CAAC;AAC9C,SAASC,yBAAyB,QAAQ,eAAe,CAAC;AAE1D,OAAO,MAAMC,sBAAsB,GAAG,IAAM;IAC1C,MAAM,EAAEC,sBAAsB,CAAA,EAAEC,2BAA2B,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGJ,yBAAyB,EAAE,AAAC;IAE9G,MAAMK,YAAY,GAAGH,sBAAsB,aAAtBA,sBAAsB,WAAc,GAApCA,KAAAA,CAAoC,GAApCA,sBAAsB,CAAEG,YAAY,AAAC;IAE1D,MAAMC,YAAY,GAAG,CAACC,CAAY,GAAK;QACrCA,CAAC,CAACC,cAAc,EAAE,CAAC;QACnB,IAAIH,YAAY,IAAII,SAAS,EAAE;YAC7B,MAAM,IAAIC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC9C,CAAC;QACDN,gBAAgB,CAACC,YAAY,CAAC,CAAC;QAC/BF,2BAA2B,EAAE,CAAC;IAChC,CAAC,AAAC;QAkBuCD,GAAsC;IAhB/E,qBACE,MAACR,MAAM;QAACiB,IAAI,EAAET,sBAAsB,KAAKO,SAAS;;0BAChD,KAACd,WAAW;0BAAC,oBAAkB;cAAc;0BAC7C,KAACF,UAAU;gBACTmB,YAAU,EAAC,OAAO;gBAClBC,OAAO,EAAE,IAAMV,2BAA2B,EAAE;gBAC5CW,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,QAAQ,EAAE,UAAU;wBACpBC,GAAG,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;wBACvBC,KAAK,EAAEJ,KAAK,CAACG,OAAO,CAAC,GAAG,CAAC;qBAC1B,CAAA,AAAC;0BAEF,cAAA,KAACnB,SAAS,KAAG;cACF;0BACb,MAACqB,MAAI;gBAACC,QAAQ,EAAEf,YAAY;;kCAC1B,MAACV,aAAa;wBAACkB,EAAE,EAAE;4BAAEQ,KAAK,EAAE,OAAO;yBAAE;;4BAAE,kCACL;4BAACpB,CAAAA,GAAsC,GAAtCA,sBAAsB,aAAtBA,sBAAsB,WAAgB,GAAtCA,KAAAA,CAAsC,GAAtCA,sBAAsB,CAAEqB,cAAc,cAAtCrB,GAAsC,cAAtCA,GAAsC,GAAI,aAAa;4BAAC,qDAE3F;;sBAAgB;kCAChB,MAACL,aAAa;;0CACZ,KAACC,MAAM;gCAAC0B,OAAO,EAAC,WAAW;gCAACC,IAAI,EAAC,QAAQ;0CAAC,QAE1C;8BAAS;0CACT,KAAC3B,MAAM;gCAACe,OAAO,EAAE,IAAMV,2BAA2B,EAAE;0CAAE,QAAM;8BAAS;;sBACvD;;cACX;;MACA,CACT;AACJ,CAAC,CAAC"}
@@ -1,4 +1,6 @@
1
1
  /// <reference types="react" />
2
- declare const PanelGroupDialog: () => JSX.Element;
3
- export default PanelGroupDialog;
2
+ /**
3
+ * A dialog for adding or editing a Panel Group. Open and initial state is controlled by the DashboardStore.
4
+ */
5
+ export declare function PanelGroupDialog(): JSX.Element;
4
6
  //# sourceMappingURL=PanelGroupDialog.d.ts.map