@perses-dev/dashboards 0.0.0-snapshot-time-range-height-80d08fc → 0.0.0-snapshot-embed-import-errors-8906900

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 (108) hide show
  1. package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +19 -5
  2. package/dist/cjs/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
  3. package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
  4. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +74 -0
  5. package/dist/cjs/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
  6. package/dist/cjs/components/DownloadButton/DownloadButton.js +2 -8
  7. package/dist/cjs/components/GridLayout/GridTitle.js +38 -22
  8. package/dist/cjs/components/Panel/PanelHeader.js +59 -26
  9. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +29 -8
  10. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +11 -6
  11. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +2 -8
  12. package/dist/cjs/components/ToolbarIconButton/ToolbarIconButton.js +35 -0
  13. package/dist/cjs/components/ToolbarIconButton/index.js +28 -0
  14. package/dist/cjs/components/Variables/VariableEditor.js +19 -3
  15. package/dist/cjs/components/Variables/VariableList.js +1 -1
  16. package/dist/cjs/components/index.js +2 -1
  17. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +2 -0
  18. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +10 -1
  19. package/dist/cjs/context/DashboardProvider/discard-changes-dialog-slice.js +33 -0
  20. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +7 -7
  21. package/dist/cjs/views/ViewDashboard/DashboardApp.js +14 -14
  22. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -1
  23. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -0
  24. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  25. package/dist/components/DashboardToolbar/DashboardToolbar.js +20 -6
  26. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  27. package/dist/components/DeletePanelDialog/DeletePanelDialog.js +2 -0
  28. package/dist/components/DeletePanelDialog/DeletePanelDialog.js.map +1 -1
  29. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  30. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +2 -0
  31. package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  32. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +3 -0
  33. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -0
  34. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +63 -0
  35. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -0
  36. package/dist/components/DiscardChangesConfirmationDialog/index.d.ts +2 -0
  37. package/dist/components/DiscardChangesConfirmationDialog/index.d.ts.map +1 -0
  38. package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js +1 -1
  39. package/dist/components/{UnsavedChangesConfirmationDialog → DiscardChangesConfirmationDialog}/index.js.map +1 -1
  40. package/dist/components/DownloadButton/DownloadButton.js +2 -8
  41. package/dist/components/DownloadButton/DownloadButton.js.map +1 -1
  42. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  43. package/dist/components/GridLayout/GridTitle.js +38 -22
  44. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  45. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  46. package/dist/components/Panel/PanelHeader.js +61 -28
  47. package/dist/components/Panel/PanelHeader.js.map +1 -1
  48. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  49. package/dist/components/PanelDrawer/PanelDrawer.js +32 -11
  50. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  51. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
  52. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  53. package/dist/components/PanelDrawer/PanelEditorForm.js +12 -7
  54. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  55. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  56. package/dist/components/TimeRangeControls/TimeRangeControls.js +2 -8
  57. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  58. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts +6 -0
  59. package/dist/components/ToolbarIconButton/ToolbarIconButton.d.ts.map +1 -0
  60. package/dist/components/ToolbarIconButton/ToolbarIconButton.js +29 -0
  61. package/dist/components/ToolbarIconButton/ToolbarIconButton.js.map +1 -0
  62. package/dist/components/ToolbarIconButton/index.d.ts +2 -0
  63. package/dist/components/ToolbarIconButton/index.d.ts.map +1 -0
  64. package/dist/components/ToolbarIconButton/index.js +15 -0
  65. package/dist/components/ToolbarIconButton/index.js.map +1 -0
  66. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  67. package/dist/components/Variables/VariableEditor.js +19 -3
  68. package/dist/components/Variables/VariableEditor.js.map +1 -1
  69. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  70. package/dist/components/Variables/VariableList.js +1 -1
  71. package/dist/components/Variables/VariableList.js.map +1 -1
  72. package/dist/components/index.d.ts +2 -1
  73. package/dist/components/index.d.ts.map +1 -1
  74. package/dist/components/index.js +2 -1
  75. package/dist/components/index.js.map +1 -1
  76. package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
  77. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  78. package/dist/context/DashboardProvider/DashboardProvider.js +2 -0
  79. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  80. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +5 -0
  81. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  82. package/dist/context/DashboardProvider/dashboard-provider-api.js +8 -0
  83. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  84. package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts +15 -0
  85. package/dist/context/DashboardProvider/discard-changes-dialog-slice.d.ts.map +1 -0
  86. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js +27 -0
  87. package/dist/context/DashboardProvider/discard-changes-dialog-slice.js.map +1 -0
  88. package/dist/context/DashboardProvider/index.d.ts +1 -0
  89. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  90. package/dist/context/DashboardProvider/index.js.map +1 -1
  91. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +7 -7
  92. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  93. package/dist/views/ViewDashboard/DashboardApp.d.ts +1 -0
  94. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  95. package/dist/views/ViewDashboard/DashboardApp.js +16 -16
  96. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  97. package/dist/views/ViewDashboard/ViewDashboard.d.ts +1 -0
  98. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  99. package/dist/views/ViewDashboard/ViewDashboard.js +2 -1
  100. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  101. package/package.json +4 -4
  102. package/dist/cjs/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -67
  103. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts +0 -8
  104. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.d.ts.map +0 -1
  105. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js +0 -56
  106. package/dist/components/UnsavedChangesConfirmationDialog/UnsavedChangesConfirmationDialog.js.map +0 -1
  107. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts +0 -2
  108. package/dist/components/UnsavedChangesConfirmationDialog/index.d.ts.map +0 -1
@@ -13,8 +13,8 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import React, { useRef } from 'react';
15
15
  import DownloadIcon from 'mdi-material-ui/DownloadOutline';
16
- import { IconButton, styled } from '@mui/material';
17
16
  import { useDashboard } from '../../context';
17
+ import { ToolbarIconButton } from '../ToolbarIconButton';
18
18
  // Button to download the dashboard as a JSON file.
19
19
  export function DownloadButton() {
20
20
  const { dashboard } = useDashboard();
@@ -35,7 +35,7 @@ export function DownloadButton() {
35
35
  };
36
36
  return /*#__PURE__*/ _jsxs(_Fragment, {
37
37
  children: [
38
- /*#__PURE__*/ _jsx(DownloadIconButton, {
38
+ /*#__PURE__*/ _jsx(ToolbarIconButton, {
39
39
  title: "Download JSON",
40
40
  onClick: onDownloadButtonClick,
41
41
  children: /*#__PURE__*/ _jsx(DownloadIcon, {})
@@ -50,11 +50,5 @@ export function DownloadButton() {
50
50
  ]
51
51
  });
52
52
  }
53
- const DownloadIconButton = styled(IconButton)(({ theme })=>({
54
- border: `1px solid ${theme.palette.grey[300]}`,
55
- borderRadius: theme.shape.borderRadius,
56
- padding: '4px',
57
- color: theme.palette.grey[900]
58
- }));
59
53
 
60
54
  //# sourceMappingURL=DownloadButton.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DownloadButton/DownloadButton.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 React, { useRef } from 'react';\nimport DownloadIcon from 'mdi-material-ui/DownloadOutline';\nimport { IconButton, styled } from '@mui/material';\nimport { useDashboard } from '../../context';\n\n// Button to download the dashboard as a JSON file.\nexport function DownloadButton() {\n const { dashboard } = useDashboard();\n const hiddenLinkRef = useRef<HTMLAnchorElement>(null);\n\n const onDownloadButtonClick = () => {\n if (!hiddenLinkRef || !hiddenLinkRef.current) return;\n // Create blob URL\n const hiddenLinkUrl = URL.createObjectURL(\n new Blob([JSON.stringify(dashboard)], {\n type: 'application/json',\n })\n );\n // Simulate click\n hiddenLinkRef.current.href = hiddenLinkUrl;\n hiddenLinkRef.current.click();\n // Remove blob URL (for memory management)\n URL.revokeObjectURL(hiddenLinkUrl);\n };\n\n return (\n <>\n <DownloadIconButton title=\"Download JSON\" onClick={onDownloadButtonClick}>\n <DownloadIcon />\n </DownloadIconButton>\n {/* Hidden link to download the dashboard as a JSON file */}\n {/* eslint-disable jsx-a11y/anchor-has-content */}\n {/* eslint-disable jsx-a11y/anchor-is-valid */}\n <a ref={hiddenLinkRef} style={{ display: 'none' }} download={`${dashboard.metadata.name}.json`} />\n </>\n );\n}\n\nconst DownloadIconButton = styled(IconButton)(({ theme }) => ({\n border: `1px solid ${theme.palette.grey[300]}`,\n borderRadius: theme.shape.borderRadius,\n padding: '4px',\n color: theme.palette.grey[900],\n}));\n"],"names":["React","useRef","DownloadIcon","IconButton","styled","useDashboard","DownloadButton","dashboard","hiddenLinkRef","onDownloadButtonClick","current","hiddenLinkUrl","URL","createObjectURL","Blob","JSON","stringify","type","href","click","revokeObjectURL","DownloadIconButton","title","onClick","a","ref","style","display","download","metadata","name","theme","border","palette","grey","borderRadius","shape","padding","color"],"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,OA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C,CAAC,CAAC,EAAE4B,KAAK,CAAA,EAAE,GAAM,CAAA;QAC5DC,MAAM,EAAE,CAAC,UAAU,EAAED,KAAK,CAACE,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9CC,YAAY,EAAEJ,KAAK,CAACK,KAAK,CAACD,YAAY;QACtCE,OAAO,EAAE,KAAK;QACdC,KAAK,EAAEP,KAAK,CAACE,OAAO,CAACC,IAAI,CAAC,GAAG,CAAC;KAC/B,CAAA,AAAC,CAAC,AAAC"}
1
+ {"version":3,"sources":["../../../src/components/DownloadButton/DownloadButton.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 React, { useRef } from 'react';\nimport DownloadIcon from 'mdi-material-ui/DownloadOutline';\nimport { useDashboard } from '../../context';\nimport { ToolbarIconButton } from '../ToolbarIconButton';\n\n// Button to download the dashboard as a JSON file.\nexport function DownloadButton() {\n const { dashboard } = useDashboard();\n const hiddenLinkRef = useRef<HTMLAnchorElement>(null);\n\n const onDownloadButtonClick = () => {\n if (!hiddenLinkRef || !hiddenLinkRef.current) return;\n // Create blob URL\n const hiddenLinkUrl = URL.createObjectURL(\n new Blob([JSON.stringify(dashboard)], {\n type: 'application/json',\n })\n );\n // Simulate click\n hiddenLinkRef.current.href = hiddenLinkUrl;\n hiddenLinkRef.current.click();\n // Remove blob URL (for memory management)\n URL.revokeObjectURL(hiddenLinkUrl);\n };\n\n return (\n <>\n <ToolbarIconButton title=\"Download JSON\" onClick={onDownloadButtonClick}>\n <DownloadIcon />\n </ToolbarIconButton>\n {/* Hidden link to download the dashboard as a JSON file */}\n {/* eslint-disable jsx-a11y/anchor-has-content */}\n {/* eslint-disable jsx-a11y/anchor-is-valid */}\n <a ref={hiddenLinkRef} style={{ display: 'none' }} download={`${dashboard.metadata.name}.json`} />\n </>\n );\n}\n"],"names":["React","useRef","DownloadIcon","useDashboard","ToolbarIconButton","DownloadButton","dashboard","hiddenLinkRef","onDownloadButtonClick","current","hiddenLinkUrl","URL","createObjectURL","Blob","JSON","stringify","type","href","click","revokeObjectURL","title","onClick","a","ref","style","display","download","metadata","name"],"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,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO,CAAC;AACtC,OAAOC,YAAY,MAAM,iCAAiC,CAAC;AAC3D,SAASC,YAAY,QAAQ,eAAe,CAAC;AAC7C,SAASC,iBAAiB,QAAQ,sBAAsB,CAAC;AAEzD,mDAAmD;AACnD,OAAO,SAASC,cAAc,GAAG;IAC/B,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGH,YAAY,EAAE,AAAC;IACrC,MAAMI,aAAa,GAAGN,MAAM,CAAoB,IAAI,CAAC,AAAC;IAEtD,MAAMO,qBAAqB,GAAG,IAAM;QAClC,IAAI,CAACD,aAAa,IAAI,CAACA,aAAa,CAACE,OAAO,EAAE,OAAO;QACrD,kBAAkB;QAClB,MAAMC,aAAa,GAAGC,GAAG,CAACC,eAAe,CACvC,IAAIC,IAAI,CAAC;YAACC,IAAI,CAACC,SAAS,CAACT,SAAS,CAAC;SAAC,EAAE;YACpCU,IAAI,EAAE,kBAAkB;SACzB,CAAC,CACH,AAAC;QACF,iBAAiB;QACjBT,aAAa,CAACE,OAAO,CAACQ,IAAI,GAAGP,aAAa,CAAC;QAC3CH,aAAa,CAACE,OAAO,CAACS,KAAK,EAAE,CAAC;QAC9B,0CAA0C;QAC1CP,GAAG,CAACQ,eAAe,CAACT,aAAa,CAAC,CAAC;IACrC,CAAC,AAAC;IAEF,qBACE;;0BACE,KAACN,iBAAiB;gBAACgB,KAAK,EAAC,eAAe;gBAACC,OAAO,EAAEb,qBAAqB;0BACrE,cAAA,KAACN,YAAY,KAAG;cACE;0BAIpB,KAACoB,GAAC;gBAACC,GAAG,EAAEhB,aAAa;gBAAEiB,KAAK,EAAE;oBAAEC,OAAO,EAAE,MAAM;iBAAE;gBAAEC,QAAQ,EAAE,CAAC,EAAEpB,SAAS,CAACqB,QAAQ,CAACC,IAAI,CAAC,KAAK,CAAC;cAAI;;MACjG,CACH;AACJ,CAAC"}
@@ -1 +1 @@
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,eAwD9C"}
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,eAyE9C"}
@@ -19,6 +19,7 @@ import PencilIcon from 'mdi-material-ui/PencilOutline';
19
19
  import ArrowUpIcon from 'mdi-material-ui/ArrowUp';
20
20
  import ArrowDownIcon from 'mdi-material-ui/ArrowDown';
21
21
  import DeleteIcon from 'mdi-material-ui/DeleteOutline';
22
+ import { InfoTooltip } from '@perses-dev/components';
22
23
  import { usePanelGroupActions, useEditMode, useDeletePanelGroupDialog } from '../../context';
23
24
  /**
24
25
  * Renders the title for a Grid section, optionally also supporting expanding
@@ -54,32 +55,47 @@ import { usePanelGroupActions, useEditMode, useDeletePanelGroupDialog } from '..
54
55
  direction: "row",
55
56
  marginLeft: "auto",
56
57
  children: [
57
- /*#__PURE__*/ _jsx(IconButton, {
58
- "aria-label": `add panel to group ${title}`,
59
- onClick: openAddPanel,
60
- children: /*#__PURE__*/ _jsx(AddPanelIcon, {})
58
+ /*#__PURE__*/ _jsx(InfoTooltip, {
59
+ description: `Add a new panel to ${title}`,
60
+ children: /*#__PURE__*/ _jsx(IconButton, {
61
+ "aria-label": `add panel to group ${title}`,
62
+ onClick: openAddPanel,
63
+ children: /*#__PURE__*/ _jsx(AddPanelIcon, {})
64
+ })
61
65
  }),
62
- /*#__PURE__*/ _jsx(IconButton, {
63
- "aria-label": `edit group ${title}`,
64
- onClick: openEditPanelGroup,
65
- children: /*#__PURE__*/ _jsx(PencilIcon, {})
66
+ /*#__PURE__*/ _jsx(InfoTooltip, {
67
+ description: "Edit",
68
+ children: /*#__PURE__*/ _jsx(IconButton, {
69
+ "aria-label": `edit group ${title}`,
70
+ onClick: openEditPanelGroup,
71
+ children: /*#__PURE__*/ _jsx(PencilIcon, {})
72
+ })
66
73
  }),
67
- /*#__PURE__*/ _jsx(IconButton, {
68
- "aria-label": `delete group ${title}`,
69
- onClick: ()=>openDeletePanelGroupDialog(panelGroupId),
70
- children: /*#__PURE__*/ _jsx(DeleteIcon, {})
74
+ /*#__PURE__*/ _jsx(InfoTooltip, {
75
+ description: "Delete",
76
+ children: /*#__PURE__*/ _jsx(IconButton, {
77
+ "aria-label": `delete group ${title}`,
78
+ onClick: ()=>openDeletePanelGroupDialog(panelGroupId),
79
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {})
80
+ })
71
81
  }),
72
- /*#__PURE__*/ _jsx(IconButton, {
73
- "aria-label": `move group ${title} down`,
74
- disabled: moveDown === undefined,
75
- onClick: moveDown,
76
- children: /*#__PURE__*/ _jsx(ArrowDownIcon, {})
82
+ /*#__PURE__*/ _jsx(InfoTooltip, {
83
+ description: "Move panel group down",
84
+ children: /*#__PURE__*/ _jsx(IconButton, {
85
+ "aria-label": `move group ${title} down`,
86
+ disabled: moveDown === undefined,
87
+ onClick: moveDown,
88
+ children: /*#__PURE__*/ _jsx(ArrowDownIcon, {})
89
+ })
77
90
  }),
78
- /*#__PURE__*/ _jsx(IconButton, {
79
- "aria-label": `move group ${title} up`,
80
- disabled: moveUp === undefined,
81
- onClick: moveUp,
82
- children: /*#__PURE__*/ _jsx(ArrowUpIcon, {})
91
+ /*#__PURE__*/ _jsx(InfoTooltip, {
92
+ description: "Move panel group up",
93
+ children: /*#__PURE__*/ _jsx(IconButton, {
94
+ "aria-label": `move group ${title} up`,
95
+ disabled: moveUp === undefined,
96
+ onClick: moveUp,
97
+ children: /*#__PURE__*/ _jsx(ArrowUpIcon, {})
98
+ })
83
99
  })
84
100
  ]
85
101
  })
@@ -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 { 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: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.paper : 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","mode","background","paper","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;AAW3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AU,EAAC,MAAM;;sCACtC,KAAC3B,UAAU;4BAAC6C,YAAU,EAAE,CAAC,mBAAmB,EAAE7B,KAAK,CAAC,CAAC;4BAAEyB,OAAO,EAAEvB,YAAY;sCAC1E,cAAA,KAACb,YAAY,KAAG;0BACL;sCACb,KAACL,UAAU;4BAAC6C,YAAU,EAAE,CAAC,WAAW,EAAE7B,KAAK,CAAC,CAAC;4BAAEyB,OAAO,EAAEtB,kBAAkB;sCACxE,cAAA,KAACb,UAAU,KAAG;0BACH;sCACb,KAACN,UAAU;4BAAC6C,YAAU,EAAE,CAAC,aAAa,EAAE7B,KAAK,CAAC,CAAC;4BAAEyB,OAAO,EAAE,IAAMnB,0BAA0B,CAACP,YAAY,CAAC;sCACtG,cAAA,KAACN,UAAU,KAAG;0BACH;sCACb,KAACT,UAAU;4BAAC6C,YAAU,EAAE,CAAC,WAAW,EAAE7B,KAAK,CAAC,KAAK,CAAC;4BAAE8B,QAAQ,EAAEzB,QAAQ,KAAKO,SAAS;4BAAEa,OAAO,EAAEpB,QAAQ;sCACrG,cAAA,KAACb,aAAa,KAAG;0BACN;sCACb,KAACR,UAAU;4BAAC6C,YAAU,EAAE,CAAC,WAAW,EAAE7B,KAAK,CAAC,GAAG,CAAC;4BAAE8B,QAAQ,EAAE1B,MAAM,KAAKQ,SAAS;4BAAEa,OAAO,EAAErB,MAAM;sCAC/F,cAAA,KAACb,WAAW,KAAG;0BACJ;;kBACP,AACT;;UACA,GAEH,+DAA+D;QAC/DiB,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 { InfoTooltip } from '@perses-dev/components';\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: ({ palette }) =>\n palette.mode === 'dark' ? palette.background.paper : 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 <InfoTooltip description={`Add a new panel to ${title}`}>\n <IconButton aria-label={`add panel to group ${title}`} onClick={openAddPanel}>\n <AddPanelIcon />\n </IconButton>\n </InfoTooltip>\n <InfoTooltip description=\"Edit\">\n <IconButton aria-label={`edit group ${title}`} onClick={openEditPanelGroup}>\n <PencilIcon />\n </IconButton>\n </InfoTooltip>\n <InfoTooltip description=\"Delete\">\n <IconButton\n aria-label={`delete group ${title}`}\n onClick={() => openDeletePanelGroupDialog(panelGroupId)}\n >\n <DeleteIcon />\n </IconButton>\n </InfoTooltip>\n <InfoTooltip description=\"Move panel group down\">\n <IconButton\n aria-label={`move group ${title} down`}\n disabled={moveDown === undefined}\n onClick={moveDown}\n >\n <ArrowDownIcon />\n </IconButton>\n </InfoTooltip>\n <InfoTooltip description=\"Move panel group up\">\n <IconButton aria-label={`move group ${title} up`} disabled={moveUp === undefined} onClick={moveUp}>\n <ArrowUpIcon />\n </IconButton>\n </InfoTooltip>\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","InfoTooltip","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","mode","background","paper","default","onClick","onToggleOpen","isOpen","direction","description","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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AS;gCAChCa,OAAO,EAAEpB,QAAQ;0CAEjB,cAAA,KAACd,aAAa,KAAG;8BACN;0BACD;sCACd,KAACE,WAAW;4BAACoC,WAAW,EAAC,qBAAqB;sCAC5C,cAAA,KAAC9C,UAAU;gCAAC+C,YAAU,EAAE,CAAC,WAAW,EAAE9B,KAAK,CAAC,GAAG,CAAC;gCAAE+B,QAAQ,EAAE3B,MAAM,KAAKQ,SAAS;gCAAEa,OAAO,EAAErB,MAAM;0CAC/F,cAAA,KAACd,WAAW,KAAG;8BACJ;0BACD;;kBACR,AACT;;UACA,GAEH,+DAA+D;QAC/DkB,IAAI,AACL;MACG,CACN;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,eAyE7G"}
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,eA2F7G"}
@@ -10,9 +10,9 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
14
  import { CardHeader, Typography, Stack, IconButton, styled } from '@mui/material';
15
- import { InfoTooltip, TooltipPlacement, combineSx } from '@perses-dev/components';
15
+ import { InfoTooltip, combineSx } from '@perses-dev/components';
16
16
  import InformationOutlineIcon from 'mdi-material-ui/InformationOutline';
17
17
  import PencilIcon from 'mdi-material-ui/PencilOutline';
18
18
  import DeleteIcon from 'mdi-material-ui/DeleteOutline';
@@ -20,49 +20,62 @@ 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
- let action = undefined;
23
+ let actions = undefined;
24
24
  if (editHandlers !== undefined) {
25
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",
26
+ actions = /*#__PURE__*/ _jsxs(_Fragment, {
30
27
  children: [
31
- /*#__PURE__*/ _jsx(HeaderIconButton, {
32
- "aria-label": `edit panel ${title}`,
33
- size: "small",
34
- onClick: editHandlers.onEditPanelClick,
35
- children: /*#__PURE__*/ _jsx(PencilIcon, {})
28
+ /*#__PURE__*/ _jsx(InfoTooltip, {
29
+ description: "Edit",
30
+ children: /*#__PURE__*/ _jsx(HeaderIconButton, {
31
+ "aria-label": `edit panel ${title}`,
32
+ size: "small",
33
+ onClick: editHandlers.onEditPanelClick,
34
+ children: /*#__PURE__*/ _jsx(PencilIcon, {
35
+ fontSize: "inherit"
36
+ })
37
+ })
36
38
  }),
37
- /*#__PURE__*/ _jsx(HeaderIconButton, {
38
- "aria-label": `delete panel ${title}`,
39
- size: "small",
40
- onClick: editHandlers.onDeletePanelClick,
41
- children: /*#__PURE__*/ _jsx(DeleteIcon, {})
39
+ /*#__PURE__*/ _jsx(InfoTooltip, {
40
+ description: "Delete",
41
+ children: /*#__PURE__*/ _jsx(HeaderIconButton, {
42
+ "aria-label": `delete panel ${title}`,
43
+ size: "small",
44
+ onClick: editHandlers.onDeletePanelClick,
45
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {
46
+ fontSize: "inherit"
47
+ })
48
+ })
42
49
  }),
43
- /*#__PURE__*/ _jsx(HeaderIconButton, {
44
- "aria-label": `move panel ${title}`,
45
- size: "small",
46
- children: /*#__PURE__*/ _jsx(DragIcon, {
47
- className: "drag-handle",
48
- sx: {
49
- cursor: 'grab'
50
- }
50
+ /*#__PURE__*/ _jsx(InfoTooltip, {
51
+ description: "Drag and drop panel to reorganize",
52
+ children: /*#__PURE__*/ _jsx(HeaderIconButton, {
53
+ "aria-label": `move panel ${title}`,
54
+ size: "small",
55
+ children: /*#__PURE__*/ _jsx(DragIcon, {
56
+ className: "drag-handle",
57
+ sx: {
58
+ cursor: 'grab'
59
+ },
60
+ fontSize: "inherit"
61
+ })
51
62
  })
52
63
  })
53
64
  ]
54
65
  });
55
66
  } else if (description !== undefined && isHovered) {
56
67
  // 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, {
68
+ actions = /*#__PURE__*/ _jsx(InfoTooltip, {
58
69
  id: descriptionTooltipId,
59
70
  description: description,
60
- placement: TooltipPlacement.Bottom,
71
+ enterDelay: 100,
61
72
  children: /*#__PURE__*/ _jsx(HeaderIconButton, {
62
73
  "aria-label": "Panel Description",
74
+ size: "small",
63
75
  children: /*#__PURE__*/ _jsx(InformationOutlineIcon, {
64
76
  "aria-describedby": "info-tooltip",
65
77
  "aria-hidden": false,
78
+ fontSize: "inherit",
66
79
  sx: {
67
80
  color: (theme)=>theme.palette.grey[700]
68
81
  }
@@ -90,12 +103,24 @@ export function PanelHeader({ id , title , description , editHandlers , isHovere
90
103
  },
91
104
  children: title
92
105
  }),
93
- action: action,
106
+ action: /*#__PURE__*/ _jsx(HeaderActionWrapper, {
107
+ direction: "row",
108
+ spacing: 0.25,
109
+ alignItems: "center",
110
+ children: actions
111
+ }),
94
112
  sx: combineSx((theme)=>({
95
113
  padding: theme.spacing(1),
96
114
  borderBottom: `solid 1px ${theme.palette.divider}`,
97
115
  '.MuiCardHeader-content': {
98
116
  overflow: 'hidden'
117
+ },
118
+ '.MuiCardHeader-action': {
119
+ // Overriding the negative margins from MUI's defaults, so we
120
+ // can vertically center the icons. Moving these values to a wrapper
121
+ // inside the action in `HeaderActionWrapper` below.
122
+ // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CardHeader/CardHeader.js#L56-L58
123
+ margin: 'auto'
99
124
  }
100
125
  }), sx),
101
126
  ...rest
@@ -105,5 +130,13 @@ const HeaderIconButton = styled(IconButton)(({ theme })=>({
105
130
  borderRadius: theme.shape.borderRadius,
106
131
  padding: '4px'
107
132
  }));
133
+ const HeaderActionWrapper = styled(Stack)(()=>({
134
+ // Adding back the negative margins from MUI's defaults for actions, so we
135
+ // avoid increasing the header size when actions are present while also being
136
+ // able to vertically center the actions.
137
+ // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CardHeader/CardHeader.js#L56-L58
138
+ marginTop: -4,
139
+ marginBottom: -4
140
+ }));
108
141
 
109
142
  //# sourceMappingURL=PanelHeader.js.map
@@ -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 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;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,CAAA,EAAE,GAAGC,IAAI,EAAoB,EAAE;IAC9G,MAAMC,cAAc,GAAG,CAAC,EAAEP,EAAE,CAAC,MAAM,CAAC,AAAC;IACrC,MAAMQ,oBAAoB,GAAG,CAAC,EAAER,EAAE,CAAC,YAAY,CAAC,AAAC;IAEjD,IAAIS,MAAM,GAA8BC,SAAS,AAAC;IAClD,IAAIP,YAAY,KAAKO,SAAS,EAAE;QAC9B,gEAAgE;QAChED,MAAM,iBACJ,MAACpB,KAAK;YAACsB,SAAS,EAAC,KAAK;YAACC,OAAO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S,EAAC,QAAQ;QAClBC,iBAAe,EAAExB,cAAc;QAC/BiB,kBAAgB,EAAEhB,oBAAoB;QACtCwB,iBAAiB;QACjB/B,KAAK,gBACH,KAACb,UAAU;YACTY,EAAE,EAAEO,cAAc;YAClB0B,OAAO,EAAC,WAAW;YACnB5B,EAAE,EAAE;gBACF,gEAAgE;gBAChE,+CAA+C;gBAC/C6B,UAAU,EAAE,MAAM;gBAClBC,SAAS,EAAE,MAAM;gBACjBC,UAAU,EAAE,QAAQ;gBACpBC,QAAQ,EAAE,QAAQ;gBAClBC,YAAY,EAAE,UAAU;aACzB;sBAEArC,KAAK;UACK;QAEfQ,MAAM,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"}
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, 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 actions: CardHeaderProps['action'] = undefined;\n if (editHandlers !== undefined) {\n // If there are edit handlers, always just show the edit buttons\n actions = (\n <>\n <InfoTooltip description=\"Edit\">\n <HeaderIconButton aria-label={`edit panel ${title}`} size=\"small\" onClick={editHandlers.onEditPanelClick}>\n <PencilIcon fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n <InfoTooltip description=\"Delete\">\n <HeaderIconButton aria-label={`delete panel ${title}`} size=\"small\" onClick={editHandlers.onDeletePanelClick}>\n <DeleteIcon fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n <InfoTooltip description=\"Drag and drop panel to reorganize\">\n <HeaderIconButton aria-label={`move panel ${title}`} size=\"small\">\n <DragIcon className=\"drag-handle\" sx={{ cursor: 'grab' }} fontSize=\"inherit\" />\n </HeaderIconButton>\n </InfoTooltip>\n </>\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 actions = (\n <InfoTooltip id={descriptionTooltipId} description={description} enterDelay={100}>\n <HeaderIconButton aria-label=\"Panel Description\" size=\"small\">\n <InformationOutlineIcon\n aria-describedby=\"info-tooltip\"\n aria-hidden={false}\n fontSize=\"inherit\"\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={\n <HeaderActionWrapper direction=\"row\" spacing={0.25} alignItems=\"center\">\n {actions}\n </HeaderActionWrapper>\n }\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 '.MuiCardHeader-action': {\n // Overriding the negative margins from MUI's defaults, so we\n // can vertically center the icons. Moving these values to a wrapper\n // inside the action in `HeaderActionWrapper` below.\n // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CardHeader/CardHeader.js#L56-L58\n margin: 'auto',\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\nconst HeaderActionWrapper = styled(Stack)(() => ({\n // Adding back the negative margins from MUI's defaults for actions, so we\n // avoid increasing the header size when actions are present while also being\n // able to vertically center the actions.\n // https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CardHeader/CardHeader.js#L56-L58\n marginTop: -4,\n marginBottom: -4,\n}));\n"],"names":["CardHeader","Typography","Stack","IconButton","styled","InfoTooltip","combineSx","InformationOutlineIcon","PencilIcon","DeleteIcon","DragIcon","PanelHeader","id","title","description","editHandlers","isHovered","sx","rest","titleElementId","descriptionTooltipId","actions","undefined","HeaderIconButton","aria-label","size","onClick","onEditPanelClick","fontSize","onDeletePanelClick","className","cursor","enterDelay","aria-describedby","aria-hidden","color","theme","palette","grey","component","aria-labelledby","disableTypography","variant","lineHeight","minHeight","whiteSpace","overflow","textOverflow","action","HeaderActionWrapper","direction","spacing","alignItems","padding","borderBottom","divider","margin","borderRadius","shape","marginTop","marginBottom"],"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,SAAS,QAAQ,wBAAwB,CAAC;AAChE,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,CAAA,EAAE,GAAGC,IAAI,EAAoB,EAAE;IAC9G,MAAMC,cAAc,GAAG,CAAC,EAAEP,EAAE,CAAC,MAAM,CAAC,AAAC;IACrC,MAAMQ,oBAAoB,GAAG,CAAC,EAAER,EAAE,CAAC,YAAY,CAAC,AAAC;IAEjD,IAAIS,OAAO,GAA8BC,SAAS,AAAC;IACnD,IAAIP,YAAY,KAAKO,SAAS,EAAE;QAC9B,gEAAgE;QAChED,OAAO,iBACL;;8BACE,K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AgB,GAAGnB,MAAM,CAACD,UAAU,CAAC,CAAC,CAAC,EAAEiC,KAAK,CAAA,EAAE,GAAM,CAAA;QAC1DqB,YAAY,EAAErB,KAAK,CAACsB,KAAK,CAACD,YAAY;QACtCJ,OAAO,EAAE,KAAK;KACf,CAAA,AAAC,CAAC,AAAC;AAEJ,MAAMJ,mBAAmB,GAAG7C,MAAM,CAACF,KAAK,CAAC,CAAC,IAAO,CAAA;QAC/C,0EAA0E;QAC1E,6EAA6E;QAC7E,yCAAyC;QACzC,4GAA4G;QAC5GyD,SAAS,EAAE,CAAC,CAAC;QACbC,YAAY,EAAE,CAAC,CAAC;KACjB,CAAA,AAAC,CAAC,AAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PanelDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"names":[],"mappings":";AAmBA;;GAEG;AACH,eAAO,MAAM,WAAW,mBAsDvB,CAAC"}
1
+ {"version":3,"file":"PanelDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelDrawer.tsx"],"names":[],"mappings":";AAoBA;;GAEG;AACH,eAAO,MAAM,WAAW,mBA+EvB,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ /* eslint-disable @typescript-eslint/no-empty-function */ // Copyright 2022 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -11,18 +11,36 @@
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';
14
+ import { useCallback, useState } from 'react';
15
15
  import { Stack, Box, Button, Typography } from '@mui/material';
16
16
  import { Drawer } from '@perses-dev/components';
17
- import { usePanelEditor } from '../../context';
18
- import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
17
+ import { useDiscardChangesConfirmationDialog, usePanelEditor } from '../../context';
18
+ import { PanelEditorForm } from './PanelEditorForm';
19
19
  /**
20
20
  * The Add/Edit panel drawer for editing a panel's options.
21
21
  */ export const PanelDrawer = ()=>{
22
22
  const panelEditor = usePanelEditor();
23
+ const { openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog } = useDiscardChangesConfirmationDialog();
24
+ const [values, setValues] = useState(undefined);
23
25
  // When the user clicks close, start closing but don't call the store yet to keep values stable during animtation
24
26
  const [isClosing, setIsClosing] = useState(false);
25
- const handleClose = ()=>setIsClosing(true);
27
+ const handleClose = ()=>{
28
+ const isModified = JSON.stringify(panelEditor === null || panelEditor === void 0 ? void 0 : panelEditor.initialValues) !== JSON.stringify(values);
29
+ if (isModified) {
30
+ openDiscardChangesConfirmationDialog({
31
+ onDiscardChanges: ()=>{
32
+ closeDiscardChangesConfirmationDialog();
33
+ setIsClosing(true);
34
+ },
35
+ onCancel: ()=>{
36
+ closeDiscardChangesConfirmationDialog();
37
+ },
38
+ description: 'You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.'
39
+ });
40
+ } else {
41
+ setIsClosing(true);
42
+ }
43
+ };
26
44
  // Don't call closeDrawer on the store until the Drawer has completely transitioned out
27
45
  const handleExited = ()=>{
28
46
  panelEditor === null || panelEditor === void 0 ? void 0 : panelEditor.close();
@@ -30,14 +48,17 @@ import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
30
48
  };
31
49
  // Drawer is open if we have a model and we're not transitioning out
32
50
  const isOpen = panelEditor !== undefined && isClosing === false;
33
- const handleSubmit = (values)=>{
51
+ const handleSubmit = ()=>{
34
52
  // This shouldn't happen since we don't render the submit button until we have a model, but check to make TS happy
35
- if (panelEditor === undefined) {
53
+ if (panelEditor === undefined || values === undefined) {
36
54
  throw new Error('Cannot apply changes');
37
55
  }
38
56
  panelEditor.applyChanges(values);
39
- handleClose();
57
+ setIsClosing(true);
40
58
  };
59
+ const handleChange = useCallback((values)=>{
60
+ setValues(values);
61
+ }, []);
41
62
  return /*#__PURE__*/ _jsx(Drawer, {
42
63
  isOpen: isOpen,
43
64
  onClose: handleClose,
@@ -69,7 +90,7 @@ import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
69
90
  /*#__PURE__*/ _jsx(Button, {
70
91
  type: "submit",
71
92
  variant: "contained",
72
- form: panelEditorFormId,
93
+ onClick: handleSubmit,
73
94
  children: panelEditor.mode === 'Add' ? 'Add' : 'Apply'
74
95
  }),
75
96
  /*#__PURE__*/ _jsx(Button, {
@@ -83,8 +104,8 @@ import { PanelEditorForm, panelEditorFormId } from './PanelEditorForm';
83
104
  ]
84
105
  }),
85
106
  /*#__PURE__*/ _jsx(PanelEditorForm, {
86
- onSubmit: handleSubmit,
87
- initialValues: panelEditor.initialValues
107
+ initialValues: panelEditor.initialValues,
108
+ onChange: handleChange
88
109
  })
89
110
  ]
90
111
  })
@@ -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.divider}`,\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 color=\"secondary\" 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","divider","variant","mode","direction","marginLeft","type","form","color","onClick","onSubmit","initialValues"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CA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UAAU,EAAE;YAAEC,QAAQ,EAAEV,YAAY;SAAE;kBAEjFJ,WAAW,KAAKO,SAAS,kBACxB;;8BACE,MAACf,GAAG;oBACFuB,EAAE,EAAE;wBACFC,OAAO,EAAE,MAAM;wBACfC,UAAU,EAAE,QAAQ;wBACpBC,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;wBACvCC,YAAY,EAAE,CAACF,KAAK,GAAK,CAAC,UAAU,EAAEA,KAAK,CAACG,OAAO,CAACC,OAAO,CAAC,CAAC;qBAC9D;;sCAED,MAAC7B,UAAU;4BAAC8B,OAAO,EAAC,IAAI;;gCAAExB,WAAW,CAACyB,IAAI;gCAAC,QAAM;;0BAAa;sCAC9D,MAAClC,KAAK;4BAACmC,SAAS,EAAC,KAAK;4BAACN,OAAO,EAAE,CAAC;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;oCAACqC,KAAK,EAAC,WAAW;oCAACN,OAAO,EAAC,UAAU;oCAACO,OAAO,EAAE5B,WAAW;8CAAE,QAEnE;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":["/* eslint-disable @typescript-eslint/no-empty-function */\n// 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 { useCallback, useState } from 'react';\nimport { Stack, Box, Button, Typography } from '@mui/material';\nimport { Drawer } from '@perses-dev/components';\nimport { PanelEditorValues, useDiscardChangesConfirmationDialog, usePanelEditor } from '../../context';\nimport { PanelEditorForm, 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 const { openDiscardChangesConfirmationDialog, closeDiscardChangesConfirmationDialog } =\n useDiscardChangesConfirmationDialog();\n\n const [values, setValues] = useState<PanelEditorValues | undefined>(undefined);\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 = () => {\n const isModified = JSON.stringify(panelEditor?.initialValues) !== JSON.stringify(values);\n if (isModified) {\n openDiscardChangesConfirmationDialog({\n onDiscardChanges: () => {\n closeDiscardChangesConfirmationDialog();\n setIsClosing(true);\n },\n onCancel: () => {\n closeDiscardChangesConfirmationDialog();\n },\n description:\n 'You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.',\n });\n } else {\n setIsClosing(true);\n }\n };\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 = () => {\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 || values === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelEditor.applyChanges(values);\n setIsClosing(true);\n };\n\n const handleChange: PanelEditorFormProps['onChange'] = useCallback((values) => {\n setValues(values);\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.divider}`,\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\" onClick={handleSubmit}>\n {panelEditor.mode === 'Add' ? 'Add' : 'Apply'}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleClose}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <PanelEditorForm initialValues={panelEditor.initialValues} onChange={handleChange} />\n </>\n )}\n </Drawer>\n );\n};\n"],"names":["useCallback","useState","Stack","Box","Button","Typography","Drawer","useDiscardChangesConfirmationDialog","usePanelEditor","PanelEditorForm","PanelDrawer","panelEditor","openDiscardChangesConfirmationDialog","closeDiscardChangesConfirmationDialog","values","setValues","undefined","isClosing","setIsClosing","handleClose","isModified","JSON","stringify","initialValues","onDiscardChanges","onCancel","description","handleExited","close","isOpen","handleSubmit","Error","applyChanges","handleChange","onClose","SlideProps","onExited","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","mode","direction","marginLeft","type","onClick","color","onChange"],"mappings":"AAAA,uDAAuD,GACvD,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,WAAW,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC9C,SAASC,KAAK,EAAEC,GAAG,EAAEC,MAAM,EAAEC,UAAU,QA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AAM;oCAAC8C,IAAI,EAAC,QAAQ;oCAACJ,OAAO,EAAC,WAAW;oCAACK,OAAO,EAAErB,YAAY;8CAC5DnB,WAAW,CAACoC,IAAI,KAAK,KAAK,GAAG,KAAK,GAAG,OAAO;kCACtC;8CACT,KAAC3C,MAAM;oCAACgD,KAAK,EAAC,WAAW;oCAACN,OAAO,EAAC,UAAU;oCAACK,OAAO,EAAEhC,WAAW;8CAAE,QAEnE;kCAAS;;0BACH;;kBACJ;8BACN,KAACV,eAAe;oBAACc,aAAa,EAAEZ,WAAW,CAACY,aAAa;oBAAE8B,QAAQ,EAAEpB,YAAY;kBAAI;;UACpF,AACJ;MACM,CACT;AACJ,CAAC,CAAC"}
@@ -2,7 +2,7 @@
2
2
  import { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';
3
3
  export interface PanelEditorFormProps {
4
4
  initialValues: PanelEditorValues;
5
- onSubmit: (values: PanelEditorValues) => void;
5
+ onChange: (values: PanelEditorValues) => void;
6
6
  }
7
7
  export declare function PanelEditorForm(props: PanelEditorFormProps): JSX.Element;
8
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":";AA6BA,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,eA0G1D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
1
+ {"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":";AA6BA,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,eAwG1D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
@@ -11,7 +11,7 @@
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 } from "react/jsx-runtime";
14
- import { useState } from 'react';
14
+ import { useEffect, useState } from 'react';
15
15
  import { Box, 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';
@@ -19,7 +19,7 @@ import { useListPanelGroups } from '../../context';
19
19
  import { PanelPreview } from './PanelPreview';
20
20
  export function PanelEditorForm(props) {
21
21
  var ref;
22
- const { initialValues , onSubmit } = props;
22
+ const { initialValues , onChange } = props;
23
23
  const panelGroups = useListPanelGroups();
24
24
  const [name, setName] = useState(initialValues.name);
25
25
  const [description, setDescription] = useState(initialValues.description);
@@ -46,8 +46,7 @@ export function PanelEditorForm(props) {
46
46
  }
47
47
  setGroupId(value);
48
48
  };
49
- const handleSubmit = (e)=>{
50
- e.preventDefault();
49
+ useEffect(()=>{
51
50
  const values = {
52
51
  name,
53
52
  description,
@@ -55,14 +54,20 @@ export function PanelEditorForm(props) {
55
54
  kind,
56
55
  spec
57
56
  };
58
- onSubmit(values);
59
- };
57
+ onChange(values);
58
+ }, [
59
+ name,
60
+ description,
61
+ groupId,
62
+ kind,
63
+ spec,
64
+ onChange
65
+ ]);
60
66
  var _title, ref1;
61
67
  return(// Grid maxHeight allows user to scroll inside Drawer to see all content
62
68
  /*#__PURE__*/ _jsx(Box, {
63
69
  component: "form",
64
70
  id: panelEditorFormId,
65
- onSubmit: handleSubmit,
66
71
  sx: {
67
72
  flex: 1,
68
73
  overflowY: 'scroll',