@perses-dev/dashboards 0.15.0 → 0.17.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 (86) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +8 -12
  2. package/dist/cjs/components/DownloadButton/DownloadButton.js +109 -0
  3. package/dist/cjs/{utils/component-ids.js → components/DownloadButton/index.js} +11 -14
  4. package/dist/cjs/components/GridLayout/GridLayout.js +13 -2
  5. package/dist/cjs/components/GridLayout/GridTitle.js +11 -17
  6. package/dist/cjs/components/Panel/Panel.js +4 -2
  7. package/dist/cjs/components/Panel/PanelHeader.js +54 -50
  8. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -3
  9. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +23 -0
  10. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +3 -1
  11. package/dist/cjs/components/Variables/Variable.js +7 -46
  12. package/dist/cjs/components/Variables/VariableEditor.js +157 -126
  13. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +353 -161
  14. package/dist/cjs/components/Variables/VariableList.js +15 -8
  15. package/dist/cjs/components/Variables/variable-model.js +74 -0
  16. package/dist/cjs/components/index.js +1 -0
  17. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +40 -15
  18. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +5 -9
  19. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +16 -1
  20. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +15 -21
  21. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  22. package/dist/components/DashboardToolbar/DashboardToolbar.js +8 -12
  23. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  24. package/dist/components/DownloadButton/DownloadButton.d.ts +3 -0
  25. package/dist/components/DownloadButton/DownloadButton.d.ts.map +1 -0
  26. package/dist/components/DownloadButton/DownloadButton.js +60 -0
  27. package/dist/components/DownloadButton/DownloadButton.js.map +1 -0
  28. package/dist/components/DownloadButton/index.d.ts +2 -0
  29. package/dist/components/DownloadButton/index.d.ts.map +1 -0
  30. package/dist/{utils/component-ids.js → components/DownloadButton/index.js} +2 -14
  31. package/dist/components/DownloadButton/index.js.map +1 -0
  32. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  33. package/dist/components/GridLayout/GridLayout.js +13 -2
  34. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  35. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  36. package/dist/components/GridLayout/GridTitle.js +11 -17
  37. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  38. package/dist/components/Panel/Panel.d.ts.map +1 -1
  39. package/dist/components/Panel/Panel.js +4 -2
  40. package/dist/components/Panel/Panel.js.map +1 -1
  41. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  42. package/dist/components/Panel/PanelHeader.js +54 -50
  43. package/dist/components/Panel/PanelHeader.js.map +1 -1
  44. package/dist/components/PanelDrawer/PanelDrawer.js +1 -3
  45. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  46. package/dist/components/PanelDrawer/PanelDrawer.test.js +23 -0
  47. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  48. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +4 -2
  49. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  50. package/dist/components/Variables/Variable.d.ts.map +1 -1
  51. package/dist/components/Variables/Variable.js +8 -47
  52. package/dist/components/Variables/Variable.js.map +1 -1
  53. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  54. package/dist/components/Variables/VariableEditor.js +159 -128
  55. package/dist/components/Variables/VariableEditor.js.map +1 -1
  56. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  57. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +315 -162
  58. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  59. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  60. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  61. package/dist/components/Variables/VariableList.js +15 -8
  62. package/dist/components/Variables/VariableList.js.map +1 -1
  63. package/dist/components/Variables/variable-model.d.ts +8 -0
  64. package/dist/components/Variables/variable-model.d.ts.map +1 -0
  65. package/dist/components/Variables/variable-model.js +64 -0
  66. package/dist/components/Variables/variable-model.js.map +1 -0
  67. package/dist/components/index.d.ts +1 -0
  68. package/dist/components/index.d.ts.map +1 -1
  69. package/dist/components/index.js +1 -0
  70. package/dist/components/index.js.map +1 -1
  71. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  72. package/dist/context/DashboardProvider/panel-editor-slice.js +40 -15
  73. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  74. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  75. package/dist/context/DashboardProvider/panel-group-editor-slice.js +5 -9
  76. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  77. package/dist/context/DashboardProvider/panel-group-slice.d.ts +9 -0
  78. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  79. package/dist/context/DashboardProvider/panel-group-slice.js +17 -0
  80. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  81. package/dist/views/ViewDashboard/tests/panelGroups.test.js +15 -21
  82. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  83. package/package.json +4 -4
  84. package/dist/utils/component-ids.d.ts +0 -8
  85. package/dist/utils/component-ids.d.ts.map +0 -1
  86. package/dist/utils/component-ids.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridLayout.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.\nimport { useState } from 'react';\nimport { Responsive, WidthProvider } from 'react-grid-layout';\nimport { Collapse, useTheme } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { useEditMode, usePanelGroup, usePanelGroupActions, PanelGroupId } from '../../context';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\nimport { GridContainer } from './GridContainer';\n\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps {\n panelGroupId: PanelGroupId;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { panelGroupId /*...others */ } = props;\n const theme = useTheme();\n const groupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n return (\n <GridContainer>\n {groupDefinition.title !== undefined && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false}>\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ sm: theme.breakpoints.values.sm, xxs: 0 }}\n cols={{ sm: 24, xxs: 2 }}\n rowHeight={30}\n draggableHandle={'.drag-handle'}\n resizeHandles={['se']}\n isDraggable={isEditMode}\n isResizable={isEditMode}\n containerPadding={[0, 10]}\n layouts={{ sm: groupDefinition.itemLayouts }}\n onLayoutChange={updatePanelGroupLayouts}\n >\n {groupDefinition.itemLayouts.map(({ i }) => (\n <div key={i}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i }} />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n"],"names":["useState","Responsive","WidthProvider","Collapse","useTheme","ErrorAlert","ErrorBoundary","useEditMode","usePanelGroup","usePanelGroupActions","GridTitle","GridItemContent","GridContainer","ResponsiveGridLayout","GridLayout","props","panelGroupId","theme","groupDefinition","updatePanelGroupLayouts","isOpen","setIsOpen","isCollapsed","isEditMode","title","undefined","collapse","onToggleOpen","current","in","unmountOnExit","appear","className","breakpoints","sm","values","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","containerPadding","layouts","itemLayouts","onLayoutChange","map","i","div","FallbackComponent","panelGroupItemId","panelGroupItemLayoutId"],"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;AACjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,UAAU,EAAEC,aAAa,QAAQ,mBAAmB,CAAC;AAC9D,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,eAAe,CAAC;AACnD,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,WAAW,EAAEC,aAAa,EAAEC,oBAAoB,QAAsB,eAAe,CAAC;AAC/F,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,eAAe,QAAQ,mBAAmB,CAAC;AACpD,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAEhD,MAAMC,oBAAoB,GAAGX,aAAa,CAACD,UAAU,CAAC,AAAC;AAMvD;;CAEC,GACD,OAAO,SAASa,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC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AAC,IAAI;qBAAC;oBACrBC,WAAW,EAAElB,UAAU;oBACvBmB,WAAW,EAAEnB,UAAU;oBACvBoB,gBAAgB,EAAE;AAAC,yBAAC;AAAE,0BAAE;qBAAC;oBACzBC,OAAO,EAAE;wBAAEV,EAAE,EAAEhB,eAAe,CAAC2B,WAAW;qBAAE;oBAC5CC,cAAc,EAAE3B,uBAAuB;8BAEtCD,eAAe,CAAC2B,WAAW,CAACE,GAAG,CAAC,CAAC,EAAEC,CAAC,CAAA,EAAE,iBACrC,KAACC,KAAG;sCACF,cAAA,KAAC3C,aAAa;gCAAC4C,iBAAiB,EAAE7C,UAAU;0CAC1C,cAAA,KAACM,eAAe;oCAACwC,gBAAgB,EAAE;wCAAEnC,YAAY;wCAAEoC,sBAAsB,EAAEJ,CAAC;qCAAE;kCAAI;8BACpE;2BAHRA,CAAC,CAIL,AACP,CAAC;kBACmB;cACd;;MACG,CAChB;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridLayout.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.\nimport { useState } from 'react';\nimport { Responsive, WidthProvider, Layouts, Layout } from 'react-grid-layout';\nimport { Collapse, useTheme } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { useEditMode, usePanelGroup, usePanelGroupActions, PanelGroupId } from '../../context';\nimport { GridTitle } from './GridTitle';\nimport { GridItemContent } from './GridItemContent';\nimport { GridContainer } from './GridContainer';\n\nconst ResponsiveGridLayout = WidthProvider(Responsive);\n\nexport interface GridLayoutProps {\n panelGroupId: PanelGroupId;\n}\n\nconst SMALL_LAYOUT_BREAKPOINT = 'sm' as const;\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps) {\n const { panelGroupId /*...others */ } = props;\n const theme = useTheme();\n const groupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed ?? true);\n const { isEditMode } = useEditMode();\n\n const handleLayoutChange = (currentLayout: Layout[], allLayouts: Layouts) => {\n // Using the value from `allLayouts` instead of `currentLayout` because of\n // a bug in react-layout-grid where `currentLayout` does not adjust properly\n // when going to a smaller breakpoint and then back to a larger breakpoint.\n // https://github.com/react-grid-layout/react-grid-layout/issues/1663\n const smallLayout = allLayouts[SMALL_LAYOUT_BREAKPOINT];\n if (smallLayout) {\n updatePanelGroupLayouts(smallLayout);\n }\n };\n\n return (\n <GridContainer>\n {groupDefinition.title !== undefined && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false}>\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ sm: theme.breakpoints.values.sm, xxs: 0 }}\n cols={{ sm: 24, xxs: 2 }}\n rowHeight={30}\n draggableHandle={'.drag-handle'}\n resizeHandles={['se']}\n isDraggable={isEditMode}\n isResizable={isEditMode}\n containerPadding={[0, 10]}\n layouts={{ [SMALL_LAYOUT_BREAKPOINT]: groupDefinition.itemLayouts }}\n onLayoutChange={handleLayoutChange}\n >\n {groupDefinition.itemLayouts.map(({ i }) => (\n <div key={i}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i }} />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n"],"names":["useState","Responsive","WidthProvider","Collapse","useTheme","ErrorAlert","ErrorBoundary","useEditMode","usePanelGroup","usePanelGroupActions","GridTitle","GridItemContent","GridContainer","ResponsiveGridLayout","SMALL_LAYOUT_BREAKPOINT","GridLayout","props","panelGroupId","theme","groupDefinition","updatePanelGroupLayouts","isOpen","setIsOpen","isCollapsed","isEditMode","handleLayoutChange","currentLayout","allLayouts","smallLayout","title","undefined","collapse","onToggleOpen","current","in","unmountOnExit","appear","className","breakpoints","sm","values","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","containerPadding","layouts","itemLayouts","onLayoutChange","map","i","div","FallbackComponent","panelGroupItemId","panelGroupItemLayoutId"],"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;AACjC;AAAA,SAASA,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,UAAU,EAAEC,aAAa,QAAyB,mBAAmB,CAAC;AAC/E,SAASC,QAAQ,EAAEC,QAAQ,QAAQ,eAAe,CAAC;AACnD,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AACnE,SAASC,WAAW,EAAEC,aAAa,EAAEC,oBAAoB,QAAsB,eAAe,CAAC;AAC/F,SAASC,SAAS,QAAQ,aAAa,CAAC;AACxC,SAASC,eAAe,QAAQ,mBAAmB,CAAC;AACpD,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAEhD,MAAMC,oBAAoB,GAAGX,aAAa,CAACD,UAAU,CAAC,AAAC;AAMvD,MAAMa,uBAAuB,GAAG,IAAI,AAAS,AAAC;AAE9C;;CAEC,GACD,OAAO,SAASC,UAAU,CAACC,KAAsB,EAAE;IACjD,MAAM,EAAEC,YAAY,CAAA,AAAC,YA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AE;wBAAEC,EAAE,EAAErB,KAAK,CAACoB,WAAW,CAACE,MAAM,CAACD,EAAE;wBAAEE,GAAG,EAAE,CAAC;qBAAE;oBACxDC,IAAI,EAAE;wBAAEH,EAAE,EAAE,EAAE;wBAAEE,GAAG,EAAE,CAAC;qBAAE;oBACxBE,SAAS,EAAE,EAAE;oBACbC,eAAe,EAAE,cAAc;oBAC/BC,aAAa,EAAE;wBAAC,IAAI;qBAAC;oBACrBC,WAAW,EAAEtB,UAAU;oBACvBuB,WAAW,EAAEvB,UAAU;oBACvBwB,gBAAgB,EAAE;AAAC,yBAAC;AAAE,0BAAE;qBAAC;oBACzBC,OAAO,EAAE;wBAAE,CAACnC,uBAAuB,CAAC,EAAEK,eAAe,CAAC+B,WAAW;qBAAE;oBACnEC,cAAc,EAAE1B,kBAAkB;8BAEjCN,eAAe,CAAC+B,WAAW,CAACE,GAAG,CAAC,CAAC,EAAEC,CAAC,CAAA,EAAE,iBACrC,KAACC,KAAG;sCACF,cAAA,KAAChD,aAAa;gCAACiD,iBAAiB,EAAElD,UAAU;0CAC1C,cAAA,KAACM,eAAe;oCAAC6C,gBAAgB,EAAE;wCAAEvC,YAAY;wCAAEwC,sBAAsB,EAAEJ,CAAC;qCAAE;kCAAI;8BACpE;2BAHRA,CAAC,CAIL,AACP,CAAC;kBACmB;cACd;;MACG,CAChB;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GridTitle.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridTitle.tsx"],"names":[],"mappings":";AAsBA,OAAO,EAAqC,YAAY,EAA6B,MAAM,eAAe,CAAC;AAE3G,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,OAAO,CAAC;QAChB,YAAY,EAAE,MAAM,IAAI,CAAC;KAC1B,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eA0D9C"}
1
+ {"version":3,"file":"GridTitle.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridTitle.tsx"],"names":[],"mappings":";AAqBA,OAAO,EAAqC,YAAY,EAA6B,MAAM,eAAe,CAAC;AAE3G,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,OAAO,CAAC;QAChB,YAAY,EAAE,MAAM,IAAI,CAAC;KAC1B,CAAC;CACH;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,eAuD9C"}
@@ -11,11 +11,10 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
- import { useState } from 'react';
15
14
  import { Box, IconButton, Stack, Typography } from '@mui/material';
16
- import ExpandedIcon from 'mdi-material-ui/ChevronUp';
17
- import CollapsedIcon from 'mdi-material-ui/ChevronDown';
18
- import AddIcon from 'mdi-material-ui/Plus';
15
+ import ExpandedIcon from 'mdi-material-ui/ChevronDown';
16
+ import CollapsedIcon from 'mdi-material-ui/ChevronRight';
17
+ import AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';
19
18
  import PencilIcon from 'mdi-material-ui/PencilOutline';
20
19
  import ArrowUpIcon from 'mdi-material-ui/ArrowUp';
21
20
  import ArrowDownIcon from 'mdi-material-ui/ArrowDown';
@@ -26,7 +25,6 @@ import { usePanelGroupActions, useEditMode, useDeletePanelGroupDialog } from '..
26
25
  * and collapsing
27
26
  */ export function GridTitle(props) {
28
27
  const { panelGroupId , title , collapse } = props;
29
- const [isHovered, setIsHovered] = useState(false);
30
28
  const { openAddPanel , openEditPanelGroup , moveUp , moveDown } = usePanelGroupActions(panelGroupId);
31
29
  const { openDeletePanelGroupDialog } = useDeletePanelGroupDialog();
32
30
  const { isEditMode } = useEditMode();
@@ -45,8 +43,6 @@ import { usePanelGroupActions, useEditMode, useDeletePanelGroupDialog } from '..
45
43
  padding: (theme)=>theme.spacing(1),
46
44
  backgroundColor: (theme)=>theme.palette.background.default
47
45
  },
48
- onMouseEnter: ()=>setIsHovered(true),
49
- onMouseLeave: ()=>setIsHovered(false),
50
46
  children: collapse ? /*#__PURE__*/ _jsxs(_Fragment, {
51
47
  children: [
52
48
  /*#__PURE__*/ _jsx(IconButton, {
@@ -54,35 +50,33 @@ import { usePanelGroupActions, useEditMode, useDeletePanelGroupDialog } from '..
54
50
  children: collapse.isOpen ? /*#__PURE__*/ _jsx(ExpandedIcon, {}) : /*#__PURE__*/ _jsx(CollapsedIcon, {})
55
51
  }),
56
52
  text,
57
- isEditMode && isHovered && /*#__PURE__*/ _jsxs(Stack, {
53
+ isEditMode && /*#__PURE__*/ _jsxs(Stack, {
58
54
  direction: "row",
59
- sx: {
60
- marginLeft: 'auto'
61
- },
55
+ marginLeft: "auto",
62
56
  children: [
63
57
  /*#__PURE__*/ _jsx(IconButton, {
64
- "aria-label": "add panel to group",
58
+ "aria-label": `add panel to group ${title}`,
65
59
  onClick: openAddPanel,
66
- children: /*#__PURE__*/ _jsx(AddIcon, {})
60
+ children: /*#__PURE__*/ _jsx(AddPanelIcon, {})
67
61
  }),
68
62
  /*#__PURE__*/ _jsx(IconButton, {
69
- "aria-label": "edit group",
63
+ "aria-label": `edit group ${title}`,
70
64
  onClick: openEditPanelGroup,
71
65
  children: /*#__PURE__*/ _jsx(PencilIcon, {})
72
66
  }),
73
67
  /*#__PURE__*/ _jsx(IconButton, {
74
- "aria-label": "delete group",
68
+ "aria-label": `delete group ${title}`,
75
69
  onClick: ()=>openDeletePanelGroupDialog(panelGroupId),
76
70
  children: /*#__PURE__*/ _jsx(DeleteIcon, {})
77
71
  }),
78
72
  /*#__PURE__*/ _jsx(IconButton, {
79
- "aria-label": "move group down",
73
+ "aria-label": `move group ${title} down`,
80
74
  disabled: moveDown === undefined,
81
75
  onClick: moveDown,
82
76
  children: /*#__PURE__*/ _jsx(ArrowDownIcon, {})
83
77
  }),
84
78
  /*#__PURE__*/ _jsx(IconButton, {
85
- "aria-label": "move group up",
79
+ "aria-label": `move group ${title} up`,
86
80
  disabled: moveUp === undefined,
87
81
  onClick: moveUp,
88
82
  children: /*#__PURE__*/ _jsx(ArrowUpIcon, {})
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/GridLayout/GridTitle.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 { Box, IconButton, Stack, Typography } from '@mui/material';\nimport ExpandedIcon from 'mdi-material-ui/ChevronUp';\nimport CollapsedIcon from 'mdi-material-ui/ChevronDown';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport ArrowUpIcon from 'mdi-material-ui/ArrowUp';\nimport ArrowDownIcon from 'mdi-material-ui/ArrowDown';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { usePanelGroupActions, useEditMode, PanelGroupId, useDeletePanelGroupDialog } from '../../context';\n\nexport interface GridTitleProps {\n panelGroupId: PanelGroupId;\n title: string;\n collapse?: {\n isOpen: boolean;\n onToggleOpen: () => void;\n };\n}\n\n/**\n * Renders the title for a Grid section, optionally also supporting expanding\n * and collapsing\n */\nexport function GridTitle(props: GridTitleProps) {\n const { panelGroupId, title, collapse } = props;\n\n const [isHovered, setIsHovered] = useState(false);\n const { openAddPanel, openEditPanelGroup, moveUp, moveDown } = usePanelGroupActions(panelGroupId);\n const { openDeletePanelGroupDialog } = useDeletePanelGroupDialog();\n const { isEditMode } = useEditMode();\n\n const text = (\n <Typography variant=\"h2\" sx={{ marginLeft: collapse !== undefined ? 1 : undefined }}>\n {title}\n </Typography>\n );\n\n return (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'start',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1),\n backgroundColor: (theme) => theme.palette.background.default,\n }}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {collapse ? (\n <>\n <IconButton onClick={collapse.onToggleOpen}>\n {collapse.isOpen ? <ExpandedIcon /> : <CollapsedIcon />}\n </IconButton>\n {text}\n {isEditMode && isHovered && (\n <Stack direction=\"row\" sx={{ marginLeft: 'auto' }}>\n <IconButton aria-label=\"add panel to group\" onClick={openAddPanel}>\n <AddIcon />\n </IconButton>\n <IconButton aria-label=\"edit group\" onClick={openEditPanelGroup}>\n <PencilIcon />\n </IconButton>\n <IconButton aria-label=\"delete group\" onClick={() => openDeletePanelGroupDialog(panelGroupId)}>\n <DeleteIcon />\n </IconButton>\n <IconButton aria-label=\"move group down\" disabled={moveDown === undefined} onClick={moveDown}>\n <ArrowDownIcon />\n </IconButton>\n <IconButton aria-label=\"move group up\" disabled={moveUp === undefined} onClick={moveUp}>\n <ArrowUpIcon />\n </IconButton>\n </Stack>\n )}\n </>\n ) : (\n // If we don't need expand/collapse, just render the title text\n text\n )}\n </Box>\n );\n}\n"],"names":["useState","Box","IconButton","Stack","Typography","ExpandedIcon","CollapsedIcon","AddIcon","PencilIcon","ArrowUpIcon","ArrowDownIcon","DeleteIcon","usePanelGroupActions","useEditMode","useDeletePanelGroupDialog","GridTitle","props","panelGroupId","title","collapse","isHovered","setIsHovered","openAddPanel","openEditPanelGroup","moveUp","moveDown","openDeletePanelGroupDialog","isEditMode","text","variant","sx","marginLeft","undefined","display","justifyContent","alignItems","padding","theme","spacing","backgroundColor","palette","background","default","onMouseEnter","onM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G;0BACH;sCACb,KAACT,UAAU;4BAAC+C,YAAU,EAAC,iBAAiB;4BAACC,QAAQ,EAAEzB,QAAQ,KAAKO,SAAS;4BAAEa,OAAO,EAAEpB,QAAQ;sCAC1F,cAAA,KAACf,aAAa,KAAG;0BACN;sCACb,KAACR,UAAU;4BAAC+C,YAAU,EAAC,eAAe;4BAACC,QAAQ,EAAE1B,MAAM,KAAKQ,SAAS;4BAAEa,OAAO,EAAErB,MAAM;sCACpF,cAAA,KAACf,WAAW,KAAG;0BACJ;;kBACP,AACT;;UACA,GAEH,+DAA+D;QAC/DmB,IAAI,AACL;MACG,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/GridLayout/GridTitle.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, IconButton, Stack, Typography } from '@mui/material';\nimport ExpandedIcon from 'mdi-material-ui/ChevronDown';\nimport CollapsedIcon from 'mdi-material-ui/ChevronRight';\nimport AddPanelIcon from 'mdi-material-ui/ChartBoxPlusOutline';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport ArrowUpIcon from 'mdi-material-ui/ArrowUp';\nimport ArrowDownIcon from 'mdi-material-ui/ArrowDown';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { usePanelGroupActions, useEditMode, PanelGroupId, useDeletePanelGroupDialog } from '../../context';\n\nexport interface GridTitleProps {\n panelGroupId: PanelGroupId;\n title: string;\n collapse?: {\n isOpen: boolean;\n onToggleOpen: () => void;\n };\n}\n\n/**\n * Renders the title for a Grid section, optionally also supporting expanding\n * and collapsing\n */\nexport function GridTitle(props: GridTitleProps) {\n const { panelGroupId, title, collapse } = props;\n\n const { openAddPanel, openEditPanelGroup, moveUp, moveDown } = usePanelGroupActions(panelGroupId);\n const { openDeletePanelGroupDialog } = useDeletePanelGroupDialog();\n const { isEditMode } = useEditMode();\n\n const text = (\n <Typography variant=\"h2\" sx={{ marginLeft: collapse !== undefined ? 1 : undefined }}>\n {title}\n </Typography>\n );\n\n return (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'start',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1),\n backgroundColor: (theme) => theme.palette.background.default,\n }}\n >\n {collapse ? (\n <>\n <IconButton onClick={collapse.onToggleOpen}>\n {collapse.isOpen ? <ExpandedIcon /> : <CollapsedIcon />}\n </IconButton>\n {text}\n {isEditMode && (\n <Stack direction=\"row\" marginLeft=\"auto\">\n <IconButton aria-label={`add panel to group ${title}`} onClick={openAddPanel}>\n <AddPanelIcon />\n </IconButton>\n <IconButton aria-label={`edit group ${title}`} onClick={openEditPanelGroup}>\n <PencilIcon />\n </IconButton>\n <IconButton aria-label={`delete group ${title}`} onClick={() => openDeletePanelGroupDialog(panelGroupId)}>\n <DeleteIcon />\n </IconButton>\n <IconButton aria-label={`move group ${title} down`} disabled={moveDown === undefined} onClick={moveDown}>\n <ArrowDownIcon />\n </IconButton>\n <IconButton aria-label={`move group ${title} up`} disabled={moveUp === undefined} onClick={moveUp}>\n <ArrowUpIcon />\n </IconButton>\n </Stack>\n )}\n </>\n ) : (\n // If we don't need expand/collapse, just render the title text\n text\n )}\n </Box>\n );\n}\n"],"names":["Box","IconButton","Stack","Typography","ExpandedIcon","CollapsedIcon","AddPanelIcon","PencilIcon","ArrowUpIcon","ArrowDownIcon","DeleteIcon","usePanelGroupActions","useEditMode","useDeletePanelGroupDialog","GridTitle","props","panelGroupId","title","collapse","openAddPanel","openEditPanelGroup","moveUp","moveDown","openDeletePanelGroupDialog","isEditMode","text","variant","sx","marginLeft","undefined","display","justifyContent","alignItems","padding","theme","spacing","backgroundColor","palette","background","default","onClick","onToggleOpen","isOpen","direction","aria-label","disabled"],"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,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AACnE,OAAOC,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAOC,aAAa,MAAM,8BAA8B,CAAC;AACzD,OAAOC,YAAY,MAAM,qCAAqC,CAAC;AAC/D,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAOC,aAAa,MAAM,2BAA2B,CAAC;AACtD,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,SAASC,oBAAoB,EAAEC,WAAW,EAAgBC,yBAAyB,QAAQ,eAAe,CAAC;AAW3G;;;CAGC,GACD,OAAO,SAASC,SAAS,CAACC,KAAqB,EAAE;IAC/C,MAAM,EAAEC,YAAY,CAAA,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAEhD,MAAM,EAAEI,YAAY,CAAA,EAAEC,kBAAkB,CAAA,EAAEC,MAAM,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGX,oBAAoB,CAACK,YAAY,CAAC,AAAC;IAClG,MAAM,EAAEO,0BAA0B,CAAA,EAAE,GAAGV,yBAAyB,EAAE,AAAC;IACnE,MAAM,EAAEW,UAAU,CAAA,EAAE,GAAGZ,WAAW,EAAE,AAAC;IAErC,MAAMa,IAAI,iBACR,KAACtB,UAAU;QAACuB,OAAO,EAAC,IAAI;QAACC,EAAE,EAAE;YAAEC,UAAU,EAAEV,QAAQ,KAAKW,SAAS,GAAG,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AElB,QAAQ;sCACrG,cAAA,KAACb,aAAa,KAAG;0BACN;sCACb,KAACR,UAAU;4BAAC2C,YAAU,EAAE,CAAC,WAAW,EAAE3B,KAAK,CAAC,GAAG,CAAC;4BAAE4B,QAAQ,EAAExB,MAAM,KAAKQ,SAAS;4BAAEW,OAAO,EAAEnB,MAAM;sCAC/F,cAAA,KAACb,WAAW,KAAG;0BACJ;;kBACP,AACT;;UACA,GAEH,+DAA+D;QAC/DiB,IAAI,AACL;MACG,CACN;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAQ,SAAS,EAAe,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG9D,MAAM,WAAW,UAAW,SAAQ,SAAS,CAAC,SAAS,CAAC;IACtD,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,eA2FtC"}
1
+ {"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAQ,SAAS,EAAe,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG9D,MAAM,WAAW,UAAW,SAAQ,SAAS,CAAC,SAAS,CAAC;IACtD,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;CACjD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,eA2FtC"}
@@ -14,9 +14,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState, useMemo } from 'react';
15
15
  import useResizeObserver from 'use-resize-observer';
16
16
  import { useInView } from 'react-intersection-observer';
17
- import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
17
+ import { ErrorBoundary, ErrorAlert, combineSx, useId } from '@perses-dev/components';
18
18
  import { Card, CardContent } from '@mui/material';
19
- import { useId } from '../../utils/component-ids';
20
19
  import { PanelHeader } from './PanelHeader';
21
20
  import { PanelContent } from './PanelContent';
22
21
  /**
@@ -98,6 +97,9 @@ import { PanelContent } from './PanelContent';
98
97
  ref: setContentElement,
99
98
  children: /*#__PURE__*/ _jsx(ErrorBoundary, {
100
99
  FallbackComponent: ErrorAlert,
100
+ resetKeys: [
101
+ definition.spec.plugin.spec
102
+ ],
101
103
  children: inView === true && /*#__PURE__*/ _jsx(PanelContent, {
102
104
  panelPluginKind: definition.spec.plugin.kind,
103
105
  spec: definition.spec.plugin.spec,
@@ -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, combineSx } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { Card, CardProps, CardContent } from '@mui/material';\nimport { useId } from '../../utils/component-ids';\nimport { PanelHeader, PanelHeaderProps } from './PanelHeader';\nimport { PanelContent } from './PanelContent';\n\nexport interface PanelProps extends CardProps<'section'> {\n definition: PanelDefinition;\n editHandlers?: PanelHeaderProps['editHandlers'];\n}\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n */\nexport function Panel(props: PanelProps) {\n const { definition, editHandlers, onMouseEnter, onMouseLeave, sx, ...others } = props;\n\n // Make sure we have an ID we can use for aria attributes\n const generatedPanelId = useId('Panel');\n const headerId = `${generatedPanelId}-header`;\n\n const [contentElement, setContentElement] = useState<HTMLElement | 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 handleMouseEnter: CardProps['onMouseEnter'] = (e) => {\n setIsHovered(true);\n onMouseEnter?.(e);\n };\n\n const handleMouseLeave: CardProps['onMouseLeave'] = (e) => {\n setIsHovered(false);\n onMouseLeave?.(e);\n };\n\n return (\n <Card\n ref={ref}\n component=\"section\"\n sx={combineSx(\n {\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n },\n sx\n )}\n variant=\"outlined\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-labelledby={headerId}\n aria-describedby={headerId}\n {...others}\n >\n <PanelHeader\n id={headerId}\n title={definition.spec.display.name}\n description={definition.spec.display.description}\n editHandlers={editHandlers}\n isHovered={isHovered}\n sx={{ paddingX: (theme) => theme.spacing(panelPadding) }}\n />\n <CardContent\n component=\"figure\"\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n margin: 0,\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"],"names":["useState","useMemo","useResizeObserver","useInView","ErrorBoundary","ErrorAlert","combineSx","Card","CardContent","useId","PanelHeader","PanelContent","Panel","props","definition","editHandlers","onMouseEnter","onMouseLeave","sx","others","generatedPanelId","headerId","contentElement","setContentElement","isHovered","setIsHovered","width","height","ref","contentDimensions","undefined","inView","threshold","initialInView","triggerOnce","panelPadding","handleMouseEnter","e","handleMouseLeave","component","display","flexFlow","variant","aria-labelledby","aria-describedby","id","title","spec","name","description","paddingX","theme","spacing","position","overflow","flexGrow","margin","padding","FallbackComponent","panelPluginKind","plugin","kind"],"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,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAC1C,OAAOC,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,SAASC,SAAS,QAAQ,6BAA6B,CAAC;AACxD,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAE9E,SAASC,IAAI,EAAaC,WAAW,QAAQ,eAAe,CAAC;AAC7D,SAASC,KAAK,QAAQ,2BAA2B,CAAC;AAClD,SAASC,WAAW,QAA0B,eAAe,CAAC;AAC9D,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C;;CAEC,GACD,OAAO,SAASC,KAAK,CAACC,KAAiB,EAAE;IACvC,MAAM,EAAEC,UAAU,CAAA,EAAEC,YAAY,CAAA,EAAEC,YAAY,CAAA,EAAEC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E,CAACN,KAAK,GAAKA,KAAK,CAACC,OAAO,CAACjB,YAAY,CAAC;qBAChD;iBACF;gBACDP,GAAG,EAAEL,iBAAiB;0BAEtB,cAAA,KAACnB,aAAa;oBAACsD,iBAAiB,EAAErD,UAAU;8BACzC0B,MAAM,KAAK,IAAI,kBACd,KAACpB,YAAY;wBACXgD,eAAe,EAAE7C,UAAU,CAACiC,IAAI,CAACa,MAAM,CAACC,IAAI;wBAC5Cd,IAAI,EAAEjC,UAAU,CAACiC,IAAI,CAACa,MAAM,CAACb,IAAI;wBACjClB,iBAAiB,EAAEA,iBAAiB;sBACpC,AACH;kBACa;cACJ;;MACT,CACP;AACJ,CAAC"}
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, combineSx, useId } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { Card, CardProps, CardContent } from '@mui/material';\nimport { PanelHeader, PanelHeaderProps } from './PanelHeader';\nimport { PanelContent } from './PanelContent';\n\nexport interface PanelProps extends CardProps<'section'> {\n definition: PanelDefinition;\n editHandlers?: PanelHeaderProps['editHandlers'];\n}\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n */\nexport function Panel(props: PanelProps) {\n const { definition, editHandlers, onMouseEnter, onMouseLeave, sx, ...others } = props;\n\n // Make sure we have an ID we can use for aria attributes\n const generatedPanelId = useId('Panel');\n const headerId = `${generatedPanelId}-header`;\n\n const [contentElement, setContentElement] = useState<HTMLElement | 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 handleMouseEnter: CardProps['onMouseEnter'] = (e) => {\n setIsHovered(true);\n onMouseEnter?.(e);\n };\n\n const handleMouseLeave: CardProps['onMouseLeave'] = (e) => {\n setIsHovered(false);\n onMouseLeave?.(e);\n };\n\n return (\n <Card\n ref={ref}\n component=\"section\"\n sx={combineSx(\n {\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n },\n sx\n )}\n variant=\"outlined\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-labelledby={headerId}\n aria-describedby={headerId}\n {...others}\n >\n <PanelHeader\n id={headerId}\n title={definition.spec.display.name}\n description={definition.spec.display.description}\n editHandlers={editHandlers}\n isHovered={isHovered}\n sx={{ paddingX: (theme) => theme.spacing(panelPadding) }}\n />\n <CardContent\n component=\"figure\"\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n margin: 0,\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} resetKeys={[definition.spec.plugin.spec]}>\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"],"names":["useState","useMemo","useResizeObserver","useInView","ErrorBoundary","ErrorAlert","combineSx","useId","Card","CardContent","PanelHeader","PanelContent","Panel","props","definition","editHandlers","onMouseEnter","onMouseLeave","sx","others","generatedPanelId","headerId","contentElement","setContentElement","isHovered","setIsHovered","width","height","ref","contentDimensions","undefined","inView","threshold","initialInView","triggerOnce","panelPadding","handleMouseEnter","e","handleMouseLeave","component","display","flexFlow","variant","aria-labelledby","aria-describedby","id","title","spec","name","description","paddingX","theme","spacing","position","overflow","flexGrow","margin","padding","FallbackComponent","resetKeys","plugin","panelPluginKind","kind"],"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,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAC1C,OAAOC,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,SAASC,SAAS,QAAQ,6BAA6B,CAAC;AACxD,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,KAAK,QAAQ,wBAAwB,CAAC;AAErF,SAASC,IAAI,EAAaC,WAAW,QAAQ,eAAe,CAAC;AAC7D,SAASC,WAAW,QAA0B,eAAe,CAAC;AAC9D,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAO9C;;CAEC,GACD,OAAO,SAASC,KAAK,CAACC,KAAiB,EAAE;IACvC,MAAM,EAAEC,UAAU,CAAA,EAAEC,YAAY,CAAA,EAAEC,YAAY,CAAA,EAAEC,YAAY,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGN,KAAK,AAAC;IAEtF,yDAAyD;IACzD,MAAMO,gBAAgB,GAAGb,KAAK,CAAC,OAAO,CAAC,AAAC;IACxC,MAAMc,QAAQ,GAAG,CAAC,EAAED,gBAAgB,CAAC,OAAO,CAAC,AAAC;IAE9C,MAAM,CAACE,cAA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FhB,MAAM,KAAK,IAAI,kBACd,KAACpB,YAAY;wBACXkD,eAAe,EAAE/C,UAAU,CAACiC,IAAI,CAACa,MAAM,CAACE,IAAI;wBAC5Cf,IAAI,EAAEjC,UAAU,CAACiC,IAAI,CAACa,MAAM,CAACb,IAAI;wBACjClB,iBAAiB,EAAEA,iBAAiB;sBACpC,AACH;kBACa;cACJ;;MACT,CACP;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelHeader.tsx"],"names":[],"mappings":";AAaA,OAAO,EAA6C,eAAe,EAAU,MAAM,eAAe,CAAC;AAOnG,aAAK,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAE1E,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC;IAC3E,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE;QACb,gBAAgB,EAAE,MAAM,IAAI,CAAC;QAC7B,kBAAkB,EAAE,MAAM,IAAI,CAAC;KAChC,CAAC;IACF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,eAkE7G"}
1
+ {"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelHeader.tsx"],"names":[],"mappings":";AAaA,OAAO,EAA6C,eAAe,EAAU,MAAM,eAAe,CAAC;AAOnG,aAAK,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAE1E,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC;IAC3E,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE;QACb,gBAAgB,EAAE,MAAM,IAAI,CAAC;QAC7B,kBAAkB,EAAE,MAAM,IAAI,CAAC;KAChC,CAAC;IACF,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,gBAAgB,eAyE7G"}
@@ -20,58 +20,55 @@ import DragIcon from 'mdi-material-ui/DragVertical';
20
20
  export function PanelHeader({ id , title , description , editHandlers , isHovered , sx , ...rest }) {
21
21
  const titleElementId = `${id}-title`;
22
22
  const descriptionTooltipId = `${id}-description`;
23
- // Don't show any actions unless panel is hovered
24
23
  let action = undefined;
25
- if (isHovered) {
26
- if (editHandlers !== undefined) {
27
- // If there are edit handlers, always just show the edit buttons
28
- action = /*#__PURE__*/ _jsxs(Stack, {
29
- direction: "row",
30
- alignItems: "center",
31
- spacing: 0.5,
32
- children: [
33
- /*#__PURE__*/ _jsx(HeaderIconButton, {
34
- "aria-label": "edit panel",
35
- size: "small",
36
- onClick: editHandlers.onEditPanelClick,
37
- children: /*#__PURE__*/ _jsx(PencilIcon, {})
38
- }),
39
- /*#__PURE__*/ _jsx(HeaderIconButton, {
40
- "aria-label": "delete panel",
41
- size: "small",
42
- onClick: editHandlers.onDeletePanelClick,
43
- children: /*#__PURE__*/ _jsx(DeleteIcon, {})
44
- }),
45
- /*#__PURE__*/ _jsx(HeaderIconButton, {
46
- "aria-label": "drag handle",
47
- size: "small",
48
- children: /*#__PURE__*/ _jsx(DragIcon, {
49
- className: "drag-handle",
50
- sx: {
51
- cursor: 'grab'
52
- }
53
- })
54
- })
55
- ]
56
- });
57
- } else if (description !== undefined) {
58
- // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description
59
- action = /*#__PURE__*/ _jsx(InfoTooltip, {
60
- id: descriptionTooltipId,
61
- description: description,
62
- placement: TooltipPlacement.Bottom,
63
- children: /*#__PURE__*/ _jsx(HeaderIconButton, {
64
- "aria-label": "Panel Description",
65
- children: /*#__PURE__*/ _jsx(InformationOutlineIcon, {
66
- "aria-describedby": "info-tooltip",
67
- "aria-hidden": false,
24
+ if (editHandlers !== undefined) {
25
+ // If there are edit handlers, always just show the edit buttons
26
+ action = /*#__PURE__*/ _jsxs(Stack, {
27
+ direction: "row",
28
+ spacing: 0.5,
29
+ alignItems: "center",
30
+ children: [
31
+ /*#__PURE__*/ _jsx(HeaderIconButton, {
32
+ "aria-label": `edit panel ${title}`,
33
+ size: "small",
34
+ onClick: editHandlers.onEditPanelClick,
35
+ children: /*#__PURE__*/ _jsx(PencilIcon, {})
36
+ }),
37
+ /*#__PURE__*/ _jsx(HeaderIconButton, {
38
+ "aria-label": `delete panel ${title}`,
39
+ size: "small",
40
+ onClick: editHandlers.onDeletePanelClick,
41
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {})
42
+ }),
43
+ /*#__PURE__*/ _jsx(HeaderIconButton, {
44
+ "aria-label": `move panel ${title}`,
45
+ size: "small",
46
+ children: /*#__PURE__*/ _jsx(DragIcon, {
47
+ className: "drag-handle",
68
48
  sx: {
69
- color: (theme)=>theme.palette.grey[700]
49
+ cursor: 'grab'
70
50
  }
71
51
  })
72
52
  })
73
- });
74
- }
53
+ ]
54
+ });
55
+ } else if (description !== undefined && isHovered) {
56
+ // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description
57
+ action = /*#__PURE__*/ _jsx(InfoTooltip, {
58
+ id: descriptionTooltipId,
59
+ description: description,
60
+ placement: TooltipPlacement.Bottom,
61
+ children: /*#__PURE__*/ _jsx(HeaderIconButton, {
62
+ "aria-label": "Panel Description",
63
+ children: /*#__PURE__*/ _jsx(InformationOutlineIcon, {
64
+ "aria-describedby": "info-tooltip",
65
+ "aria-hidden": false,
66
+ sx: {
67
+ color: (theme)=>theme.palette.grey[700]
68
+ }
69
+ })
70
+ })
71
+ });
75
72
  }
76
73
  return /*#__PURE__*/ _jsx(CardHeader, {
77
74
  id: id,
@@ -82,6 +79,15 @@ export function PanelHeader({ id , title , description , editHandlers , isHovere
82
79
  title: /*#__PURE__*/ _jsx(Typography, {
83
80
  id: titleElementId,
84
81
  variant: "subtitle1",
82
+ sx: {
83
+ // `minHeight` guarantees that the header has the correct height
84
+ // when there is no title (i.e. in the preview)
85
+ lineHeight: '24px',
86
+ minHeight: '24px',
87
+ whiteSpace: 'nowrap',
88
+ overflow: 'hidden',
89
+ textOverflow: 'ellipsis'
90
+ },
85
91
  children: title
86
92
  }),
87
93
  action: action,
@@ -89,9 +95,7 @@ export function PanelHeader({ id , title , description , editHandlers , isHovere
89
95
  padding: theme.spacing(1),
90
96
  borderBottom: `solid 1px ${theme.palette.divider}`,
91
97
  '.MuiCardHeader-content': {
92
- whiteSpace: 'nowrap',
93
- overflow: 'hidden',
94
- textOverflow: 'ellipsis'
98
+ overflow: 'hidden'
95
99
  }
96
100
  }), sx),
97
101
  ...rest
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/Panel/PanelHeader.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 { CardHeader, Typography, Stack, IconButton, CardHeaderProps, styled } from '@mui/material';\nimport { InfoTooltip, TooltipPlacement, combineSx } from '@perses-dev/components';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title: string;\n description?: string;\n editHandlers?: {\n onEditPanelClick: () => void;\n onDeletePanelClick: () => void;\n };\n isHovered: boolean;\n}\n\nexport function PanelHeader({ id, title, description, editHandlers, isHovered, sx, ...rest }: PanelHeaderProps) {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n // Don't show any actions unless panel is hovered\n let action: CardHeaderProps['action'] = undefined;\n if (isHovered) {\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n action = (\n <Stack direction=\"row\" alignItems=\"center\" spacing={0.5}>\n <HeaderIconButton aria-label=\"edit panel\" size=\"small\" onClick={editHandlers.onEditPanelClick}>\n <PencilIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label=\"delete panel\" size=\"small\" onClick={editHandlers.onDeletePanelClick}>\n <DeleteIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label=\"drag handle\" size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </HeaderIconButton>\n </Stack>\n );\n } else if (description !== undefined) {\n // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description\n action = (\n <InfoTooltip id={descriptionTooltipId} description={description} placement={TooltipPlacement.Bottom}>\n <HeaderIconButton aria-label=\"Panel Description\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n }\n\n return (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Typography id={titleElementId} variant=\"subtitle1\">\n {title}\n </Typography>\n }\n action={action}\n sx={combineSx(\n (theme) => ({\n padding: theme.spacing(1),\n borderBottom: `solid 1px ${theme.palette.divider}`,\n '.MuiCardHeader-content': {\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n },\n }),\n sx\n )}\n {...rest}\n />\n );\n}\n\nconst HeaderIconButton = styled(IconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["CardHeader","Typography","Stack","IconButton","styled","InfoTooltip","TooltipPlacement","combineSx","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","PanelHeader","id","title","description","editHandlers","isHovered","sx","rest","titleElementId","descriptionTooltipId","action","undefined","direction","alignItems","spacing","HeaderIconButton","aria-label","size","onClick","onEditPanelClick","onDeletePanelClick","className","cursor","placement","Bottom","aria-describedby","aria-hidden","color","theme","palette","grey","component","aria-labelledby","disableTypography","variant","padding","borderBottom","divider","whiteSpace","overflow","textOverflow","borderRadius","shape"],"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,UAAU,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAmBC,MAAM,QAAQ,eAAe,CAAC;AACnG,SAASC,WAAW,EAAEC,gBAAgB,EAAEC,SAAS,QAAQ,wBAAwB,CAAC;AAClF,OAAOC,sBAAsB,MAAM,oCAAoC,CAAC;AACxE,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,UAAU,MAAM,+BAA+B,CAAC;AACvD,OAAOC,QAAQ,MAAM,8BAA8B,CAAC;AAepD,OAAO,SAASC,WAAW,CAAC,EAAEC,EAAE,CAAA,EAAEC,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,YAAY,CAAA,EAAEC,SAAS,CAAA,EAAEC,EAAE,C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ACrB6B,kBAAgB,EAAC,cAAc;wBAC/BC,aAAW,EAAE,KAAK;wBAClBpB,EAAE,EAAE;4BAAEqB,KAAK,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC;yBAAE;sBACjD;kBACe;cACP,AACf,CAAC;QACJ,CAAC;IACH,CAAC;IAED,qBACE,KAAC1C,UAAU;QACTa,EAAE,EAAEA,EAAE;QACN8B,SAAS,EAAC,QAAQ;QAClBC,iBAAe,EAAExB,cAAc;QAC/BiB,kBAAgB,EAAEhB,oBAAoB;QACtCwB,iBAAiB;QACjB/B,KAAK,gBACH,KAACb,UAAU;YAACY,EAAE,EAAEO,cAAc;YAAE0B,OAAO,EAAC,WAAW;sBAChDhC,KAAK;UACK;QAEfQ,MAAM,EAAEA,MAAM;QACdJ,EAAE,EAAEX,SAAS,CACX,CAACiC,KAAK,GAAM,CAAA;gBACVO,OAAO,EAAEP,KAAK,CAACd,OAAO,CAAC,CAAC,CAAC;gBACzBsB,YAAY,EAAE,CAAC,UAAU,EAAER,KAAK,CAACC,OAAO,CAACQ,OAAO,CAAC,CAAC;gBAClD,wBAAwB,EAAE;oBACxBC,UAAU,EAAE,QAAQ;oBACpBC,QAAQ,EAAE,QAAQ;oBAClBC,YAAY,EAAE,UAAU;iBACzB;aACF,CAAA,AAAC,EACFlC,EAAE,CACH;QACA,GAAGC,IAAI;MACR,CACF;AACJ,CAAC;AAED,MAAMQ,gBAAgB,GAAGvB,MAAM,CAACD,UAAU,CAAC,CAAC,CAAC,EAAEqC,KAAK,CAAA,EAAE,GAAM,CAAA;QAC1Da,YAAY,EAAEb,KAAK,CAACc,KAAK,CAACD,YAAY;QACtCN,OAAO,EAAE,KAAK;KACf,CAAA,AAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../../src/components/Panel/PanelHeader.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 { CardHeader, Typography, Stack, IconButton, CardHeaderProps, styled } from '@mui/material';\nimport { InfoTooltip, TooltipPlacement, combineSx } from '@perses-dev/components';\nimport InformationOutlineIcon from 'mdi-material-ui/InformationOutline';\nimport PencilIcon from 'mdi-material-ui/PencilOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport DragIcon from 'mdi-material-ui/DragVertical';\n\ntype OmittedProps = 'children' | 'action' | 'title' | 'disableTypography';\n\nexport interface PanelHeaderProps extends Omit<CardHeaderProps, OmittedProps> {\n id: string;\n title: string;\n description?: string;\n editHandlers?: {\n onEditPanelClick: () => void;\n onDeletePanelClick: () => void;\n };\n isHovered: boolean;\n}\n\nexport function PanelHeader({ id, title, description, editHandlers, isHovered, sx, ...rest }: PanelHeaderProps) {\n const titleElementId = `${id}-title`;\n const descriptionTooltipId = `${id}-description`;\n\n let action: CardHeaderProps['action'] = undefined;\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n action = (\n <Stack direction=\"row\" spacing={0.5} alignItems=\"center\">\n <HeaderIconButton aria-label={`edit panel ${title}`} size=\"small\" onClick={editHandlers.onEditPanelClick}>\n <PencilIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label={`delete panel ${title}`} size=\"small\" onClick={editHandlers.onDeletePanelClick}>\n <DeleteIcon />\n </HeaderIconButton>\n <HeaderIconButton aria-label={`move panel ${title}`} size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} />\n </HeaderIconButton>\n </Stack>\n );\n } else if (description !== undefined && isHovered) {\n // If there aren't edit handlers and we have a description, show a button with a tooltip for the panel description\n action = (\n <InfoTooltip id={descriptionTooltipId} description={description} placement={TooltipPlacement.Bottom}>\n <HeaderIconButton aria-label=\"Panel Description\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n sx={{ color: (theme) => theme.palette.grey[700] }}\n />\n </HeaderIconButton>\n </InfoTooltip>\n );\n }\n\n return (\n <CardHeader\n id={id}\n component=\"header\"\n aria-labelledby={titleElementId}\n aria-describedby={descriptionTooltipId}\n disableTypography\n title={\n <Typography\n id={titleElementId}\n variant=\"subtitle1\"\n sx={{\n // `minHeight` guarantees that the header has the correct height\n // when there is no title (i.e. in the preview)\n lineHeight: '24px',\n minHeight: '24px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {title}\n </Typography>\n }\n action={action}\n sx={combineSx(\n (theme) => ({\n padding: theme.spacing(1),\n borderBottom: `solid 1px ${theme.palette.divider}`,\n '.MuiCardHeader-content': {\n overflow: 'hidden',\n },\n }),\n sx\n )}\n {...rest}\n />\n );\n}\n\nconst HeaderIconButton = styled(IconButton)(({ theme }) => ({\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n}));\n"],"names":["CardHeader","Typography","Stack","IconButton","styled","InfoTooltip","TooltipPlacement","combineSx","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","PanelHeader","id","title","description","editHandlers","isHovered","sx","rest","titleElementId","descriptionTooltipId","action","undefined","direction","spacing","alignItems","HeaderIconButton","aria-label","size","onClick","onEditPanelClick","onDeletePanelClick","className","cursor","placement","Bottom","aria-describedby","aria-hidden","color","theme","palette","grey","component","aria-labelledby","disableTypography","variant","lineHeight","minHeight","whiteSpace","overflow","textOverflow","padding","borderBottom","divider","borderRadius","shape"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;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M,EAAEA,MAAM;QACdJ,EAAE,EAAEX,SAAS,CACX,CAACiC,KAAK,GAAM,CAAA;gBACVY,OAAO,EAAEZ,KAAK,CAACf,OAAO,CAAC,CAAC,CAAC;gBACzB4B,YAAY,EAAE,CAAC,UAAU,EAAEb,KAAK,CAACC,OAAO,CAACa,OAAO,CAAC,CAAC;gBAClD,wBAAwB,EAAE;oBACxBJ,QAAQ,EAAE,QAAQ;iBACnB;aACF,CAAA,AAAC,EACFhC,EAAE,CACH;QACA,GAAGC,IAAI;MACR,CACF;AACJ,CAAC;AAED,MAAMQ,gBAAgB,GAAGvB,MAAM,CAACD,UAAU,CAAC,CAAC,CAAC,EAAEqC,KAAK,CAAA,EAAE,GAAM,CAAA;QAC1De,YAAY,EAAEf,KAAK,CAACgB,KAAK,CAACD,YAAY;QACtCH,OAAO,EAAE,KAAK;KACf,CAAA,AAAC,CAAC,AAAC"}
@@ -64,9 +64,7 @@ import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
64
64
  /*#__PURE__*/ _jsxs(Stack, {
65
65
  direction: "row",
66
66
  spacing: 1,
67
- sx: {
68
- marginLeft: 'auto'
69
- },
67
+ marginLeft: "auto",
70
68
  children: [
71
69
  /*#__PURE__*/ _jsx(Button, {
72
70
  type: "submit",
@@ -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 { 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 padding: (theme) => theme.spacing(1, 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","padding","theme","spacing","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,cAAc,QAAQ,eAAe,CAAC;AAC/C,SAASC,eAAe,EAAEC,iBAAiB,QAA8B,mBAAmB,CAAC;AAE7F;;CAEC,GACD,OAAO,MAAMC,WAAW,GAAG,IAAM;IAC/B,MAAMC,WAAW,GAAGJ,cAAc,EAAE,AAAC;IAErC,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,EAAE,CAAC;QACrBH,YAAY,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC,AAAC;IAEF,oEAAoE;IACpE,MAAMI,MAAM,GAAGN,WAAW,KAAKO,SAAS,IAAIN,SAAS,KAAK,KAAK,AAAC;IAEhE,MAAMO,YAAY,GAAqC,CAACC,MAAM,GAAK;QACjE,kHAAkH;QAClH,IAAIT,WAAW,KAAKO,SAAS,EAAE;YAC7B,MAAM,IAAIG,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ACJ;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 padding: (theme) => theme.spacing(1, 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} 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","padding","theme","spacing","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,cAAc,QAAQ,eAAe,CAAC;AAC/C,SAASC,eAAe,EAAEC,iBAAiB,QAA8B,mBAAmB,CAAC;AAE7F;;CAEC,GACD,OAAO,MAAMC,WAAW,GAAG,IAAM;IAC/B,MAAMC,WAAW,GAAGJ,cAAc,EAAE,AAAC;IAErC,iHAAiH;IACjH,MAAM,CAACK,SAAS,EAAEC,YAAY,CAAC,GAAGZ,QAAQ,CAAC,KAAK,CAAC,AAAC;IAClD,MAAMa,W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AC;4BAAEO,UAAU,EAAC,MAAM;;8CAElD,KAAClC,MAAM;oCAACmC,IAAI,EAAC,QAAQ;oCAACJ,OAAO,EAAC,WAAW;oCAACK,IAAI,EAAE/B,iBAAiB;8CAC9DE,WAAW,CAACyB,IAAI,KAAK,KAAK,GAAG,KAAK,GAAG,OAAO;kCACtC;8CACT,KAAChC,MAAM;oCAAC+B,OAAO,EAAC,UAAU;oCAACM,OAAO,EAAE3B,WAAW;8CAAE,QAEjD;kCAAS;;0BACH;;kBACJ;8BACN,KAACN,eAAe;oBAACkC,QAAQ,EAAEvB,YAAY;oBAAEwB,aAAa,EAAEhC,WAAW,CAACgC,aAAa;kBAAI;;UACpF,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
@@ -61,6 +61,29 @@ describe('Panel Drawer', ()=>{
61
61
  }
62
62
  });
63
63
  });
64
+ it('should add panel with duplicate panel name', async ()=>{
65
+ const storeApi = renderPanelDrawer();
66
+ act(()=>storeApi.getState().openAddPanel());
67
+ const nameInput = await screen.findByLabelText(/Name/);
68
+ userEvent.type(nameInput, 'cpu');
69
+ userEvent.click(screen.getByText('Add'));
70
+ const panels = storeApi.getState().panels;
71
+ expect(panels).toMatchObject({
72
+ // make sure we don't have duplicate panel key by appending "-1"
73
+ 'cpu-1': {
74
+ kind: 'Panel',
75
+ spec: {
76
+ display: {
77
+ name: 'cpu'
78
+ },
79
+ plugin: {
80
+ kind: '',
81
+ spec: {}
82
+ }
83
+ }
84
+ }
85
+ });
86
+ });
64
87
  it('should edit an existing panel', async ()=>{
65
88
  const storeApi = renderPanelDrawer();
66
89
  // Open the drawer for an existing panel
@@ -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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';\nimport { DashboardProvider } from '../../context/DashboardProvider';\nimport { PanelDrawer } from './PanelDrawer';\n\ndescribe('Panel Drawer', () => {\n const renderPanelDrawer = () => {\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelDrawer />\n </DashboardProvider>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel', async () => {\n const storeApi = renderPanelDrawer();\n\n // Open the drawer for a new panel\n act(() => storeApi.getState().openAddPanel());\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 const group = Object.values(storeApi.getState().panelGroups).find((group) => group.title === 'CPU Stats');\n if (group === undefined) {\n throw new Error('Test group not found');\n }\n const layout = Object.entries(group.itemPanelKeys).find(([, panelKey]) => panelKey === 'cpu');\n if (layout === undefined) {\n throw new Error('Test panel not found');\n }\n act(() => storeApi.getState().openEditPanel({ panelGroupId: group.id, panelGroupItemLayoutId: layout[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":["screen","userEvent","act","createDashboardProviderSpy","getTestDashboard","renderWithContext","DashboardProvider","PanelDrawer","describe","renderPanelDrawer","store","DashboardProviderSpy","initialState","dashboardResource","isEditMode","value","storeApi","undefined","Error","it","getState","openAddPanel","nameInput","findByLabelText","type","click","getByText","panels","expect","toMatchObject","NewPanel","kind","spec","display","name","plugin","group","Object","values","panelGroups","find","title","layout","entries","itemPanelKeys","panelKey","openEditPanel","panelGroupId","id","panelGroupItemLayoutId","clear","cpu"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAQ,wBAAwB,CAAC;AAChD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AACpD,SAASC,GAAG,QAAQ,sBAAsB,CAAC;AAC3C,SAASC,0BAA0B,EAAEC,gBAAgB,EAAEC,iBAAiB,QAAQ,YAAY,CAAC;AAC7F,SAASC,iBAAiB,QAAQ,iCAAiC,CAAC;AACpE,SAASC,WAAW,QAAQ,eAAe,CAAC;AAE5CC,QAAQ,CAAC,cAAc,EAAE,IAAM;IAC7B,MAAMC,iBAAiB,GAAG,IAAM;QAC9B,MAAM,EAAEC,KAAK,CAAA,EAAEC,oBAAoB,CAAA,EAAE,GAAGR,0BAA0B,EAAE,AAAC;QAErEE,iBAAiB,eACf,MAACC,iBAAiB;YAACM,YAAY,EAAE;gBAAEC,iBAAiB,EAA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EAAE;wBAAEC,IAAI,EAAE,WAAW;qBAAE;oBAC9BC,MAAM,EAAE;wBACNJ,IAAI,EAAE,iBAAiB;wBACvBC,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 { screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { act } from 'react-dom/test-utils';\nimport { createDashboardProviderSpy, getTestDashboard, renderWithContext } from '../../test';\nimport { DashboardProvider } from '../../context/DashboardProvider';\nimport { PanelDrawer } from './PanelDrawer';\n\ndescribe('Panel Drawer', () => {\n const renderPanelDrawer = () => {\n const { store, DashboardProviderSpy } = createDashboardProviderSpy();\n\n renderWithContext(\n <DashboardProvider initialState={{ dashboardResource: getTestDashboard(), isEditMode: true }}>\n <DashboardProviderSpy />\n <PanelDrawer />\n </DashboardProvider>\n );\n\n const { value: storeApi } = store;\n if (storeApi === undefined) {\n throw new Error('Expected dashboard store to be set after initial render');\n }\n\n return storeApi;\n };\n\n it('should add new panel', async () => {\n const storeApi = renderPanelDrawer();\n\n // Open the drawer for a new panel\n act(() => storeApi.getState().openAddPanel());\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 add panel with duplicate panel name', async () => {\n const storeApi = renderPanelDrawer();\n\n act(() => storeApi.getState().openAddPanel());\n\n const nameInput = await screen.findByLabelText(/Name/);\n userEvent.type(nameInput, 'cpu');\n userEvent.click(screen.getByText('Add'));\n\n const panels = storeApi.getState().panels;\n expect(panels).toMatchObject({\n // make sure we don't have duplicate panel key by appending \"-1\"\n 'cpu-1': {\n kind: 'Panel',\n spec: {\n display: { name: 'cpu' },\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 const group = Object.values(storeApi.getState().panelGroups).find((group) => group.title === 'CPU Stats');\n if (group === undefined) {\n throw new Error('Test group not found');\n }\n const layout = Object.entries(group.itemPanelKeys).find(([, panelKey]) => panelKey === 'cpu');\n if (layout === undefined) {\n throw new Error('Test panel not found');\n }\n act(() => storeApi.getState().openEditPanel({ panelGroupId: group.id, panelGroupItemLayoutId: layout[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":["screen","userEvent","act","createDashboardProviderSpy","getTestDashboard","renderWithContext","DashboardProvider","PanelDrawer","describe","renderPanelDrawer","store","DashboardProviderSpy","initialState","dashboardResource","isEditMode","value","storeApi","undefined","Error","it","getState","openAddPanel","nameInput","findByLabelText","type","click","getByText","panels","expect","toMatchObject","NewPanel","kind","spec","display","name","plugin","group","Object","values","panelGroups","find","title","layout","entries","itemPanelKeys","panelKey","openE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AACwB,KAAK,CAACzB,MAAM,CAAC0B,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;YAC3BsB,GAAG,EAAE;gBACHpB,IAAI,EAAE,OAAO;gBACbC,IAAI,EAAE;oBACJC,OAAO,EAAE;wBAAEC,IAAI,EAAE,WAAW;qBAAE;oBAC9BC,MAAM,EAAE;wBACNJ,IAAI,EAAE,iBAAiB;wBACvBC,IAAI,EAAE,EAAE;qBACT;iBACF;aACF;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -14,7 +14,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { generatePath } from 'react-router';
15
15
  import { createMemoryHistory } from 'history';
16
16
  import userEvent from '@testing-library/user-event';
17
- import { screen } from '@testing-library/react';
17
+ import { screen, act } from '@testing-library/react';
18
18
  import { renderWithContext } from '../../test';
19
19
  import testDashboard from '../../test/testDashboard';
20
20
  import { DashboardProvider, TimeRangeProvider } from '../../context';
@@ -71,7 +71,9 @@ describe('TimeRangeControls', ()=>{
71
71
  userEvent.click(secondSelected);
72
72
  expect(history.location.search).toEqual('?start=12h');
73
73
  // back button should return to first option selected
74
- history.back();
74
+ act(()=>{
75
+ history.back();
76
+ });
75
77
  expect(history.location.search).toEqual('?start=5m');
76
78
  });
77
79
  // TODO: add additional tests for absolute time selection, other inputs, form validation, etc.