@perses-dev/dashboards 0.52.0-beta.5 → 0.52.0-rc.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 (108) hide show
  1. package/dist/cjs/components/GridLayout/GridLayout.js +78 -126
  2. package/dist/cjs/components/GridLayout/Row.js +150 -0
  3. package/dist/cjs/components/GridLayout/index.js +1 -0
  4. package/dist/cjs/components/LeaveDialog/LeaveDialog.js +44 -0
  5. package/dist/cjs/components/LeaveDialog/index.js +30 -0
  6. package/dist/cjs/components/Panel/Panel.js +5 -1
  7. package/dist/cjs/components/Panel/PanelActions.js +3 -3
  8. package/dist/cjs/components/Panel/PanelHeader.js +32 -15
  9. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +58 -21
  10. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +3 -0
  11. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +35 -15
  12. package/dist/cjs/components/index.js +1 -0
  13. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +7 -8
  14. package/dist/cjs/context/DashboardProvider/DashboardProviderWithQueryParams.js +3 -3
  15. package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -0
  16. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +6 -2
  17. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -0
  18. package/dist/cjs/context/DashboardProvider/view-panel-slice.js +10 -3
  19. package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
  20. package/dist/cjs/context/useDashboard.js +5 -4
  21. package/dist/cjs/views/ViewDashboard/DashboardApp.js +7 -3
  22. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +9 -8
  23. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts +2 -2
  24. package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
  25. package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
  26. package/dist/components/GridLayout/GridLayout.d.ts +8 -0
  27. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  28. package/dist/components/GridLayout/GridLayout.js +72 -126
  29. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  30. package/dist/components/GridLayout/Row.d.ts +17 -0
  31. package/dist/components/GridLayout/Row.d.ts.map +1 -0
  32. package/dist/components/GridLayout/Row.js +142 -0
  33. package/dist/components/GridLayout/Row.js.map +1 -0
  34. package/dist/components/GridLayout/index.d.ts +1 -0
  35. package/dist/components/GridLayout/index.d.ts.map +1 -1
  36. package/dist/components/GridLayout/index.js +1 -0
  37. package/dist/components/GridLayout/index.js.map +1 -1
  38. package/dist/components/LeaveDialog/LeaveDialog.d.ts +7 -0
  39. package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -0
  40. package/dist/components/LeaveDialog/LeaveDialog.js +36 -0
  41. package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -0
  42. package/dist/components/LeaveDialog/index.d.ts +2 -0
  43. package/dist/components/LeaveDialog/index.d.ts.map +1 -0
  44. package/dist/components/LeaveDialog/index.js +15 -0
  45. package/dist/components/LeaveDialog/index.js.map +1 -0
  46. package/dist/components/Panel/Panel.d.ts +5 -0
  47. package/dist/components/Panel/Panel.d.ts.map +1 -1
  48. package/dist/components/Panel/Panel.js +5 -1
  49. package/dist/components/Panel/Panel.js.map +1 -1
  50. package/dist/components/Panel/PanelActions.d.ts +2 -0
  51. package/dist/components/Panel/PanelActions.d.ts.map +1 -1
  52. package/dist/components/Panel/PanelActions.js +3 -3
  53. package/dist/components/Panel/PanelActions.js.map +1 -1
  54. package/dist/components/Panel/PanelHeader.d.ts +6 -1
  55. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  56. package/dist/components/Panel/PanelHeader.js +33 -16
  57. package/dist/components/Panel/PanelHeader.js.map +1 -1
  58. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  59. package/dist/components/PanelDrawer/PanelDrawer.js +59 -22
  60. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  61. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  62. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +3 -0
  63. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  64. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +1 -0
  65. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -1
  66. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +36 -16
  67. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -1
  68. package/dist/components/index.d.ts +1 -0
  69. package/dist/components/index.d.ts.map +1 -1
  70. package/dist/components/index.js +1 -0
  71. package/dist/components/index.js.map +1 -1
  72. package/dist/context/DashboardProvider/DashboardProvider.d.ts +5 -5
  73. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  74. package/dist/context/DashboardProvider/DashboardProvider.js +7 -8
  75. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  76. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js +4 -4
  77. package/dist/context/DashboardProvider/DashboardProviderWithQueryParams.js.map +1 -1
  78. package/dist/context/DashboardProvider/common.d.ts +1 -1
  79. package/dist/context/DashboardProvider/common.d.ts.map +1 -1
  80. package/dist/context/DashboardProvider/common.js.map +1 -1
  81. package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -0
  82. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
  83. package/dist/context/DashboardProvider/panel-editor-slice.js +1 -0
  84. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
  85. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +1 -0
  86. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -1
  87. package/dist/context/DashboardProvider/panel-group-editor-slice.js +6 -2
  88. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -1
  89. package/dist/context/DashboardProvider/panel-group-slice.d.ts +3 -0
  90. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  91. package/dist/context/DashboardProvider/panel-group-slice.js +1 -0
  92. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  93. package/dist/context/DashboardProvider/view-panel-slice.d.ts +6 -2
  94. package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
  95. package/dist/context/DashboardProvider/view-panel-slice.js +10 -3
  96. package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
  97. package/dist/context/VariableProvider/VariableProvider.js +1 -1
  98. package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
  99. package/dist/context/useDashboard.js +5 -4
  100. package/dist/context/useDashboard.js.map +1 -1
  101. package/dist/views/ViewDashboard/DashboardApp.d.ts +7 -6
  102. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  103. package/dist/views/ViewDashboard/DashboardApp.js +8 -4
  104. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  105. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  106. package/dist/views/ViewDashboard/ViewDashboard.js +9 -8
  107. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  108. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { ReactElement, useState } from 'react';\nimport { usePanelGroupEditor } from '../../context';\nimport { PanelGroupEditorForm, panelGroupEditorFormId, PanelGroupEditorFormProps } from './PanelGroupEditorForm';\n\n/**\n * A dialog for adding or editing a Panel Group. Open and initial state is controlled by the DashboardStore.\n */\nexport function PanelGroupDialog(): ReactElement {\n const panelGroupEditor = usePanelGroupEditor();\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 = (): void => setIsClosing(true);\n\n // Don't call close on the store until the Dialog has completely transitioned out\n const handleExited = (): void => {\n panelGroupEditor?.close();\n setIsClosing(false);\n };\n\n // Dialog is open if we have a model and we're not transitioning out\n const isOpen = panelGroupEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelGroupEditorFormProps['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 (panelGroupEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelGroupEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Dialog open={isOpen} TransitionProps={{ onExited: handleExited }}>\n {panelGroupEditor !== undefined && (\n <>\n <DialogTitle>{panelGroupEditor.mode} Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={panelGroupEditor.close}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent dividers sx={{ width: '500px' }}>\n <PanelGroupEditorForm initialValues={panelGroupEditor.initialValues} onSubmit={handleSubmit} />\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\" form={panelGroupEditorFormId}>\n {panelGroupEditor.mode === 'Edit' ? 'Apply' : 'Add'}\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={panelGroupEditor.close}>\n Cancel\n </Button>\n </DialogActions>\n </>\n )}\n </Dialog>\n );\n}\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useState","usePanelGroupEditor","PanelGroupEditorForm","panelGroupEditorFormId","PanelGroupDialog","panelGroupEditor","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","open","TransitionProps","onExited","mode","aria-label","onClick","sx","theme","position","top","spacing","right","dividers","width","initialValues","onSubmit","variant","type","form","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,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,gBAAgB;AACtG,OAAOC,eAAe,wBAAwB;AAC9C,SAAuBC,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAmC,yBAAyB;AAEjH;;CAEC,GACD,OAAO,SAASC;IACd,MAAMC,mBAAmBJ;IAEzB,iHAAiH;IACjH,MAAM,CAACK,WAAWC,aAAa,GAAGP,SAAS;IAC3C,MAAMQ,cAAc,IAAYD,aAAa;IAE7C,iFAAiF;IACjF,MAAME,eAAe;QACnBJ,kBAAkBK;QAClBH,aAAa;IACf;IAEA,oEAAoE;IACpE,MAAMI,SAASN,qBAAqBO,aAAaN,cAAc;IAE/D,MAAMO,eAAsD,CAACC;QAC3D,kHAAkH;QAClH,IAAIT,qBAAqBO,WAAW;YAClC,MAAM,IAAIG,MAAM;QAClB;QACAV,iBAAiBW,YAAY,CAACF;QAC9BN;IACF;IAEA,qBACE,KAACd;QAAOuB,MAAMN;QAAQO,iBAAiB;YAAEC,UAAUV;QAAa;kBAC7DJ,qBAAqBO,2BACpB;;8BACE,MAACjB;;wBAAaU,iBAAiBe,IAAI;wBAAC;;;8BACpC,KAAC3B;oBACC4B,cAAW;oBACXC,SAASjB,iBAAiBK,KAAK;oBAC/Ba,IAAI,CAACC,QAAW,CAAA;4BACdC,UAAU;4BACVC,KAAKF,MAAMG,OAAO,CAAC;4BACnBC,OAAOJ,MAAMG,OAAO,CAAC;wBACvB,CAAA;8BAEA,cAAA,KAAC5B;;8BAEH,KAACH;oBAAciC,QAAQ;oBAACN,IAAI;wBAAEO,OAAO;oBAAQ;8BAC3C,cAAA,KAAC5B;wBAAqB6B,eAAe1B,iBAAiB0B,aAAa;wBAAEC,UAAUnB;;;8BAEjF,MAAChB;;sCACC,KAACC;4BAAOmC,SAAQ;4BAAYC,MAAK;4BAASC,MAAMhC;sCAC7CE,iBAAiBe,IAAI,KAAK,SAAS,UAAU;;sCAEhD,KAACtB;4BAAOmC,SAAQ;4BAAWG,OAAM;4BAAYd,SAASjB,iBAAiBK,KAAK;sCAAE;;;;;;;AAQ1F"}
1
+ {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupDialog.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { IconButton, Dialog, DialogTitle, DialogContent, DialogActions, Button } from '@mui/material';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { ReactElement, useState } from 'react';\nimport { useVariableValues } from '@perses-dev/plugin-system';\nimport { usePanelGroupEditor } from '../../context';\nimport { PanelGroupEditorForm, panelGroupEditorFormId, PanelGroupEditorFormProps } from './PanelGroupEditorForm';\n\n/**\n * A dialog for adding or editing a Panel Group. Open and initial state is controlled by the DashboardStore.\n */\nexport function PanelGroupDialog(): ReactElement {\n const panelGroupEditor = usePanelGroupEditor();\n const variables = useVariableValues();\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 = (): void => setIsClosing(true);\n\n // Don't call close on the store until the Dialog has completely transitioned out\n const handleExited = (): void => {\n panelGroupEditor?.close();\n setIsClosing(false);\n };\n\n // Dialog is open if we have a model and we're not transitioning out\n const isOpen = panelGroupEditor !== undefined && isClosing === false;\n\n const handleSubmit: PanelGroupEditorFormProps['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 (panelGroupEditor === undefined) {\n throw new Error('Cannot apply changes');\n }\n panelGroupEditor.applyChanges(values);\n handleClose();\n };\n\n return (\n <Dialog open={isOpen} TransitionProps={{ onExited: handleExited }}>\n {panelGroupEditor !== undefined && (\n <>\n <DialogTitle>{panelGroupEditor.mode} Panel Group</DialogTitle>\n <IconButton\n aria-label=\"Close\"\n onClick={panelGroupEditor.close}\n sx={(theme) => ({\n position: 'absolute',\n top: theme.spacing(0.5),\n right: theme.spacing(0.5),\n })}\n >\n <CloseIcon />\n </IconButton>\n <DialogContent dividers sx={{ width: '500px' }}>\n <PanelGroupEditorForm\n initialValues={panelGroupEditor.initialValues}\n variables={Object.keys(variables)}\n onSubmit={handleSubmit}\n />\n </DialogContent>\n <DialogActions>\n <Button variant=\"contained\" type=\"submit\" form={panelGroupEditorFormId}>\n {panelGroupEditor.mode === 'Edit' ? 'Apply' : 'Add'}\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={panelGroupEditor.close}>\n Cancel\n </Button>\n </DialogActions>\n </>\n )}\n </Dialog>\n );\n}\n"],"names":["IconButton","Dialog","DialogTitle","DialogContent","DialogActions","Button","CloseIcon","useState","useVariableValues","usePanelGroupEditor","PanelGroupEditorForm","panelGroupEditorFormId","PanelGroupDialog","panelGroupEditor","variables","isClosing","setIsClosing","handleClose","handleExited","close","isOpen","undefined","handleSubmit","values","Error","applyChanges","open","TransitionProps","onExited","mode","aria-label","onClick","sx","theme","position","top","spacing","right","dividers","width","initialValues","Object","keys","onSubmit","variant","type","form","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,SAASA,UAAU,EAAEC,MAAM,EAAEC,WAAW,EAAEC,aAAa,EAAEC,aAAa,EAAEC,MAAM,QAAQ,gBAAgB;AACtG,OAAOC,eAAe,wBAAwB;AAC9C,SAAuBC,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,mBAAmB,QAAQ,gBAAgB;AACpD,SAASC,oBAAoB,EAAEC,sBAAsB,QAAmC,yBAAyB;AAEjH;;CAEC,GACD,OAAO,SAASC;IACd,MAAMC,mBAAmBJ;IACzB,MAAMK,YAAYN;IAElB,iHAAiH;IACjH,MAAM,CAACO,WAAWC,aAAa,GAAGT,SAAS;IAC3C,MAAMU,cAAc,IAAYD,aAAa;IAE7C,iFAAiF;IACjF,MAAME,eAAe;QACnBL,kBAAkBM;QAClBH,aAAa;IACf;IAEA,oEAAoE;IACpE,MAAMI,SAASP,qBAAqBQ,aAAaN,cAAc;IAE/D,MAAMO,eAAsD,CAACC;QAC3D,kHAAkH;QAClH,IAAIV,qBAAqBQ,WAAW;YAClC,MAAM,IAAIG,MAAM;QAClB;QACAX,iBAAiBY,YAAY,CAACF;QAC9BN;IACF;IAEA,qBACE,KAAChB;QAAOyB,MAAMN;QAAQO,iBAAiB;YAAEC,UAAUV;QAAa;kBAC7DL,qBAAqBQ,2BACpB;;8BACE,MAACnB;;wBAAaW,iBAAiBgB,IAAI;wBAAC;;;8BACpC,KAAC7B;oBACC8B,cAAW;oBACXC,SAASlB,iBAAiBM,KAAK;oBAC/Ba,IAAI,CAACC,QAAW,CAAA;4BACdC,UAAU;4BACVC,KAAKF,MAAMG,OAAO,CAAC;4BACnBC,OAAOJ,MAAMG,OAAO,CAAC;wBACvB,CAAA;8BAEA,cAAA,KAAC9B;;8BAEH,KAACH;oBAAcmC,QAAQ;oBAACN,IAAI;wBAAEO,OAAO;oBAAQ;8BAC3C,cAAA,KAAC7B;wBACC8B,eAAe3B,iBAAiB2B,aAAa;wBAC7C1B,WAAW2B,OAAOC,IAAI,CAAC5B;wBACvB6B,UAAUrB;;;8BAGd,MAAClB;;sCACC,KAACC;4BAAOuC,SAAQ;4BAAYC,MAAK;4BAASC,MAAMnC;sCAC7CE,iBAAiBgB,IAAI,KAAK,SAAS,UAAU;;sCAEhD,KAACxB;4BAAOuC,SAAQ;4BAAWG,OAAM;4BAAYhB,SAASlB,iBAAiBM,KAAK;sCAAE;;;;;;;AAQ1F"}
@@ -2,6 +2,7 @@ import { ReactElement } from 'react';
2
2
  import { PanelGroupEditorValues } from '../../context';
3
3
  export interface PanelGroupEditorFormProps {
4
4
  initialValues: PanelGroupEditorValues;
5
+ variables?: string[];
5
6
  onSubmit: (next: PanelGroupEditorValues) => void;
6
7
  }
7
8
  export declare function PanelGroupEditorForm(props: PanelGroupEditorFormProps): ReactElement;
@@ -1 +1 @@
1
- {"version":3,"file":"PanelGroupEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/PanelGroupEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAoB,YAAY,EAAY,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAIvD,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,sBAAsB,CAAC;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,YAAY,CAsCnF;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,4BAA4B,CAAC"}
1
+ {"version":3,"file":"PanelGroupEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelGroupDialog/PanelGroupEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAoB,YAAY,EAAY,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,sBAAsB,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;CAClD;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,YAAY,CA2DnF;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,4BAA4B,CAAC"}
@@ -12,20 +12,18 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { useState } from 'react';
15
- import { FormControl, InputLabel, TextField, Select, MenuItem } from '@mui/material';
15
+ import { FormControl, TextField, MenuItem, Typography } from '@mui/material';
16
16
  export function PanelGroupEditorForm(props) {
17
- const { initialValues, onSubmit } = props;
17
+ const { initialValues, variables, onSubmit } = props;
18
18
  const [title, setTitle] = useState(initialValues.title);
19
19
  const [isCollapsed, setIsCollapsed] = useState(initialValues.isCollapsed);
20
- const handleCollapsedChange = (e)=>{
21
- const next = e.target.value;
22
- setIsCollapsed(next === 'Closed');
23
- };
20
+ const [repeatVariable, setRepeatVariable] = useState(initialValues.repeatVariable);
24
21
  const handleSubmit = (e)=>{
25
22
  e.preventDefault();
26
23
  onSubmit({
27
24
  title,
28
- isCollapsed
25
+ isCollapsed,
26
+ repeatVariable
29
27
  });
30
28
  };
31
29
  return /*#__PURE__*/ _jsxs("form", {
@@ -40,25 +38,21 @@ export function PanelGroupEditorForm(props) {
40
38
  label: "Name",
41
39
  variant: "outlined",
42
40
  value: title,
43
- onChange: (e)=>setTitle(e.target.value)
41
+ onChange: (e)=>setTitle(e.target.value),
42
+ "data-testid": "panel-group-editor-name"
44
43
  })
45
44
  }),
46
45
  /*#__PURE__*/ _jsxs(FormControl, {
47
46
  fullWidth: true,
48
47
  margin: "normal",
49
48
  children: [
50
- /*#__PURE__*/ _jsx(InputLabel, {
51
- id: "select-collapse-state",
52
- children: "Collapse State"
53
- }),
54
- /*#__PURE__*/ _jsxs(Select, {
49
+ /*#__PURE__*/ _jsxs(TextField, {
50
+ select: true,
55
51
  required: true,
56
- displayEmpty: true,
57
- labelId: "select-collapse-state",
58
52
  label: "Collapse State",
59
53
  size: "small",
60
54
  value: isCollapsed ? 'Closed' : 'Open',
61
- onChange: handleCollapsedChange,
55
+ onChange: (e)=>setIsCollapsed(e.target.value === 'Closed'),
62
56
  children: [
63
57
  /*#__PURE__*/ _jsx(MenuItem, {
64
58
  value: "Open",
@@ -69,6 +63,32 @@ export function PanelGroupEditorForm(props) {
69
63
  children: "Closed"
70
64
  })
71
65
  ]
66
+ }),
67
+ /*#__PURE__*/ _jsx(FormControl, {
68
+ fullWidth: true,
69
+ margin: "normal",
70
+ children: /*#__PURE__*/ _jsxs(TextField, {
71
+ select: true,
72
+ label: "Repeat Variable",
73
+ variant: "outlined",
74
+ value: repeatVariable ?? '',
75
+ onChange: (e)=>setRepeatVariable(e.target.value === '' ? undefined : e.target.value),
76
+ children: [
77
+ /*#__PURE__*/ _jsx(MenuItem, {
78
+ value: "",
79
+ children: /*#__PURE__*/ _jsx(Typography, {
80
+ sx: {
81
+ fontStyle: 'italic'
82
+ },
83
+ children: "None"
84
+ })
85
+ }),
86
+ variables?.sort((a, b)=>a.localeCompare(b)).map((variable)=>/*#__PURE__*/ _jsx(MenuItem, {
87
+ value: variable,
88
+ children: variable
89
+ }, variable))
90
+ ]
91
+ })
72
92
  })
73
93
  ]
74
94
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupEditorForm.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEventHandler, ReactElement, useState } from 'react';\nimport { FormControl, InputLabel, TextField, Select, SelectProps, MenuItem } from '@mui/material';\nimport { PanelGroupEditorValues } from '../../context';\n\ntype CollapsedState = 'Open' | 'Closed';\n\nexport interface PanelGroupEditorFormProps {\n initialValues: PanelGroupEditorValues;\n onSubmit: (next: PanelGroupEditorValues) => void;\n}\n\nexport function PanelGroupEditorForm(props: PanelGroupEditorFormProps): ReactElement {\n const { initialValues, onSubmit } = props;\n\n const [title, setTitle] = useState(initialValues.title);\n const [isCollapsed, setIsCollapsed] = useState(initialValues.isCollapsed);\n\n const handleCollapsedChange: SelectProps<CollapsedState>['onChange'] = (e) => {\n const next = e.target.value;\n setIsCollapsed(next === 'Closed');\n };\n\n const handleSubmit: FormEventHandler = (e) => {\n e.preventDefault();\n onSubmit({ title, isCollapsed });\n };\n\n return (\n <form id={panelGroupEditorFormId} onSubmit={handleSubmit}>\n <FormControl fullWidth margin=\"normal\">\n <TextField required label=\"Name\" variant=\"outlined\" value={title} onChange={(e) => setTitle(e.target.value)} />\n </FormControl>\n <FormControl fullWidth margin=\"normal\">\n <InputLabel id=\"select-collapse-state\">Collapse State</InputLabel>\n <Select<CollapsedState>\n required\n displayEmpty\n labelId=\"select-collapse-state\"\n label=\"Collapse State\"\n size=\"small\"\n value={isCollapsed ? 'Closed' : 'Open'}\n onChange={handleCollapsedChange}\n >\n <MenuItem value=\"Open\">Open</MenuItem>\n <MenuItem value=\"Closed\">Closed</MenuItem>\n </Select>\n </FormControl>\n </form>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelGroupEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelGroupEditorFormId = 'panel-group-editor-form';\n"],"names":["useState","FormControl","InputLabel","TextField","Select","MenuItem","PanelGroupEditorForm","props","initialValues","onSubmit","title","setTitle","isCollapsed","setIsCollapsed","handleCollapsedChange","e","next","target","value","handleSubmit","preventDefault","form","id","panelGroupEditorFormId","fullWidth","margin","required","label","variant","onChange","displayEmpty","labelId","size"],"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,SAAyCA,QAAQ,QAAQ,QAAQ;AACjE,SAASC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,MAAM,EAAeC,QAAQ,QAAQ,gBAAgB;AAUlG,OAAO,SAASC,qBAAqBC,KAAgC;IACnE,MAAM,EAAEC,aAAa,EAAEC,QAAQ,EAAE,GAAGF;IAEpC,MAAM,CAACG,OAAOC,SAAS,GAAGX,SAASQ,cAAcE,KAAK;IACtD,MAAM,CAACE,aAAaC,eAAe,GAAGb,SAASQ,cAAcI,WAAW;IAExE,MAAME,wBAAiE,CAACC;QACtE,MAAMC,OAAOD,EAAEE,MAAM,CAACC,KAAK;QAC3BL,eAAeG,SAAS;IAC1B;IAEA,MAAMG,eAAiC,CAACJ;QACtCA,EAAEK,cAAc;QAChBX,SAAS;YAAEC;YAAOE;QAAY;IAChC;IAEA,qBACE,MAACS;QAAKC,IAAIC;QAAwBd,UAAUU;;0BAC1C,KAAClB;gBAAYuB,SAAS;gBAACC,QAAO;0BAC5B,cAAA,KAACtB;oBAAUuB,QAAQ;oBAACC,OAAM;oBAAOC,SAAQ;oBAAWV,OAAOR;oBAAOmB,UAAU,CAACd,IAAMJ,SAASI,EAAEE,MAAM,CAACC,KAAK;;;0BAE5G,MAACjB;gBAAYuB,SAAS;gBAACC,QAAO;;kCAC5B,KAACvB;wBAAWoB,IAAG;kCAAwB;;kCACvC,MAAClB;wBACCsB,QAAQ;wBACRI,YAAY;wBACZC,SAAQ;wBACRJ,OAAM;wBACNK,MAAK;wBACLd,OAAON,cAAc,WAAW;wBAChCiB,UAAUf;;0CAEV,KAACT;gCAASa,OAAM;0CAAO;;0CACvB,KAACb;gCAASa,OAAM;0CAAS;;;;;;;;AAKnC;AAEA;;CAEC,GACD,OAAO,MAAMK,yBAAyB,0BAA0B"}
1
+ {"version":3,"sources":["../../../src/components/PanelGroupDialog/PanelGroupEditorForm.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { FormEventHandler, ReactElement, useState } from 'react';\nimport { FormControl, TextField, MenuItem, Typography } from '@mui/material';\nimport { PanelGroupEditorValues } from '../../context';\n\nexport interface PanelGroupEditorFormProps {\n initialValues: PanelGroupEditorValues;\n variables?: string[];\n onSubmit: (next: PanelGroupEditorValues) => void;\n}\n\nexport function PanelGroupEditorForm(props: PanelGroupEditorFormProps): ReactElement {\n const { initialValues, variables, onSubmit } = props;\n\n const [title, setTitle] = useState(initialValues.title);\n const [isCollapsed, setIsCollapsed] = useState(initialValues.isCollapsed);\n const [repeatVariable, setRepeatVariable] = useState<string | undefined>(initialValues.repeatVariable);\n\n const handleSubmit: FormEventHandler = (e) => {\n e.preventDefault();\n onSubmit({ title, isCollapsed, repeatVariable });\n };\n\n return (\n <form id={panelGroupEditorFormId} onSubmit={handleSubmit}>\n <FormControl fullWidth margin=\"normal\">\n <TextField\n required\n label=\"Name\"\n variant=\"outlined\"\n value={title}\n onChange={(e) => setTitle(e.target.value)}\n data-testid=\"panel-group-editor-name\"\n />\n </FormControl>\n <FormControl fullWidth margin=\"normal\">\n <TextField\n select\n required\n label=\"Collapse State\"\n size=\"small\"\n value={isCollapsed ? 'Closed' : 'Open'}\n onChange={(e) => setIsCollapsed(e.target.value === 'Closed')}\n >\n <MenuItem value=\"Open\">Open</MenuItem>\n <MenuItem value=\"Closed\">Closed</MenuItem>\n </TextField>\n <FormControl fullWidth margin=\"normal\">\n <TextField\n select\n label=\"Repeat Variable\"\n variant=\"outlined\"\n value={repeatVariable ?? ''}\n onChange={(e) => setRepeatVariable(e.target.value === '' ? undefined : e.target.value)}\n >\n <MenuItem value=\"\">\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </MenuItem>\n {variables\n ?.sort((a, b) => a.localeCompare(b))\n .map((variable) => (\n <MenuItem key={variable} value={variable}>\n {variable}\n </MenuItem>\n ))}\n </TextField>\n </FormControl>\n </FormControl>\n </form>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelGroupEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelGroupEditorFormId = 'panel-group-editor-form';\n"],"names":["useState","FormControl","TextField","MenuItem","Typography","PanelGroupEditorForm","props","initialValues","variables","onSubmit","title","setTitle","isCollapsed","setIsCollapsed","repeatVariable","setRepeatVariable","handleSubmit","e","preventDefault","form","id","panelGroupEditorFormId","fullWidth","margin","required","label","variant","value","onChange","target","data-testid","select","size","undefined","sx","fontStyle","sort","a","b","localeCompare","map","variable"],"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,SAAyCA,QAAQ,QAAQ,QAAQ;AACjE,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,EAAEC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;wCAAW8B,IAAI;4CAAEC,WAAW;wCAAS;kDAAG;;;gCAE1C3B,WACG4B,KAAK,CAACC,GAAGC,IAAMD,EAAEE,aAAa,CAACD,IAChCE,IAAI,CAACC,yBACJ,KAACtC;wCAAwBwB,OAAOc;kDAC7BA;uCADYA;;;;;;;;AAS/B;AAEA;;CAEC,GACD,OAAO,MAAMpB,yBAAyB,0BAA0B"}
@@ -12,6 +12,7 @@ export * from './EditJsonButton';
12
12
  export * from './EditJsonDialog';
13
13
  export * from './EmptyDashboard';
14
14
  export * from './GridLayout';
15
+ export * from './LeaveDialog';
15
16
  export * from './Panel';
16
17
  export * from './PanelDrawer';
17
18
  export * from './PanelGroupDialog';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oCAAoC,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
@@ -24,6 +24,7 @@ export * from './EditJsonButton';
24
24
  export * from './EditJsonDialog';
25
25
  export * from './EmptyDashboard';
26
26
  export * from './GridLayout';
27
+ export * from './LeaveDialog';
27
28
  export * from './Panel';
28
29
  export * from './PanelDrawer';
29
30
  export * from './PanelGroupDialog';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './AddGroupButton';\nexport * from './AddPanelButton';\nexport * from './Dashboard';\nexport * from './DashboardToolbar';\nexport * from './DashboardStickyToolbar';\nexport * from './Datasources';\nexport * from './DeletePanelDialog';\nexport * from './DeletePanelGroupDialog';\nexport * from './DiscardChangesConfirmationDialog';\nexport * from './DownloadButton';\nexport * from './EditJsonButton';\nexport * from './EditJsonDialog';\nexport * from './EmptyDashboard';\nexport * from './GridLayout';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './QuerySummaryTable';\nexport * from './SaveChangesConfirmationDialog';\nexport * from './SaveDashboardButton';\nexport * from './Variables';\n"],"names":[],"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,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,cAAc;AAC5B,cAAc,qBAAqB;AACnC,cAAc,2BAA2B;AACzC,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,2BAA2B;AACzC,cAAc,qCAAqC;AACnD,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,kCAAkC;AAChD,cAAc,wBAAwB;AACtC,cAAc,cAAc"}
1
+ {"version":3,"sources":["../../src/components/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './AddGroupButton';\nexport * from './AddPanelButton';\nexport * from './Dashboard';\nexport * from './DashboardToolbar';\nexport * from './DashboardStickyToolbar';\nexport * from './Datasources';\nexport * from './DeletePanelDialog';\nexport * from './DeletePanelGroupDialog';\nexport * from './DiscardChangesConfirmationDialog';\nexport * from './DownloadButton';\nexport * from './EditJsonButton';\nexport * from './EditJsonDialog';\nexport * from './EmptyDashboard';\nexport * from './GridLayout';\nexport * from './LeaveDialog';\nexport * from './Panel';\nexport * from './PanelDrawer';\nexport * from './PanelGroupDialog';\nexport * from './QuerySummaryTable';\nexport * from './SaveChangesConfirmationDialog';\nexport * from './SaveDashboardButton';\nexport * from './Variables';\n"],"names":[],"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,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,cAAc;AAC5B,cAAc,qBAAqB;AACnC,cAAc,2BAA2B;AACzC,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,2BAA2B;AACzC,cAAc,qCAAqC;AACnD,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,mBAAmB;AACjC,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,qBAAqB;AACnC,cAAc,sBAAsB;AACpC,cAAc,kCAAkC;AAChD,cAAc,wBAAwB;AACtC,cAAc,cAAc"}
@@ -11,7 +11,7 @@ import { DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-
11
11
  import { SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';
12
12
  import { DuplicatePanelSlice } from './duplicate-panel-slice';
13
13
  import { EditJsonDialogSlice } from './edit-json-dialog-slice';
14
- import { ViewPanelSlice } from './view-panel-slice';
14
+ import { ViewPanelSlice, VirtualPanelRef } from './view-panel-slice';
15
15
  export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelGroupEditorSlice, DeletePanelGroupSlice, PanelEditorSlice, DeletePanelSlice, DiscardChangesConfirmationDialogSlice, DuplicatePanelSlice, EditJsonDialogSlice, SaveChangesConfirmationDialogSlice, ViewPanelSlice {
16
16
  isEditMode: boolean;
17
17
  setEditMode: (isEditMode: boolean) => void;
@@ -24,17 +24,17 @@ export interface DashboardStoreState extends PanelGroupSlice, PanelSlice, PanelG
24
24
  datasources?: Record<string, DatasourceSpec>;
25
25
  ttl?: DurationString;
26
26
  }
27
+ export declare const DashboardContext: import("react").Context<StoreApi<DashboardStoreState> | undefined>;
28
+ export declare function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T;
27
29
  export interface DashboardStoreProps {
28
30
  dashboardResource: DashboardResource | EphemeralDashboardResource;
29
31
  isEditMode?: boolean;
30
- viewPanelRef?: string;
31
- setViewPanelRef?: (viewPanelRef: string | undefined) => void;
32
+ viewPanelRef?: VirtualPanelRef;
33
+ setViewPanelRef?: (viewPanelRef: VirtualPanelRef | undefined) => void;
32
34
  }
33
35
  export interface DashboardProviderProps {
34
36
  initialState: DashboardStoreProps;
35
37
  children?: ReactNode;
36
38
  }
37
- export declare const DashboardContext: import("react").Context<StoreApi<DashboardStoreState> | undefined>;
38
- export declare function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T;
39
39
  export declare function DashboardProvider(props: DashboardProviderProps): ReactElement;
40
40
  //# sourceMappingURL=DashboardProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardProvider.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIxC,OAAO,EAAiB,YAAY,EAAE,SAAS,EAAgD,MAAM,OAAO,CAAC;AAC7G,OAAO,EACL,iBAAiB,EACjB,OAAO,EACP,eAAe,EACf,cAAc,EAEd,cAAc,EACd,0BAA0B,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,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CAAC;IAC/B,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,GAAG,SAAS,KAAK,IAAI,CAAC;CACvE;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,mBAAmB,CAAC;IAClC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,GAAG,YAAY,CA0B7E"}
@@ -40,14 +40,15 @@ export function useDashboardStore(selector) {
40
40
  return useStoreWithEqualityFn(store, selector, shallow);
41
41
  }
42
42
  export function DashboardProvider(props) {
43
+ // Prevent calling createDashboardStore every time it rerenders
43
44
  const createDashboardStore = useCallback(initStore, [
44
45
  props
45
46
  ]);
47
+ const [store] = useState(createDashboardStore(props));
46
48
  // load plugin to retrieve initial spec if default panel kind is defined
47
49
  const { defaultPluginKinds } = usePluginRegistry();
48
50
  const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';
49
51
  const { data: plugin } = usePlugin('Panel', defaultPanelKind);
50
- const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders
51
52
  useEffect(()=>{
52
53
  if (plugin === undefined) return;
53
54
  const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};
@@ -69,12 +70,8 @@ export function DashboardProvider(props) {
69
70
  }
70
71
  function initStore(props) {
71
72
  const { initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef } } = props;
72
- const { kind, metadata, spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources } } = dashboardResource;
73
+ const { kind, metadata, spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} } } = dashboardResource;
73
74
  const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;
74
- let { spec: { layouts, panels } } = dashboardResource;
75
- // Set fallbacks in case the frontend is used with a non-Perses backend
76
- layouts = layouts ?? [];
77
- panels = panels ?? {};
78
75
  const store = createStore()(immer(devtools((...args)=>{
79
76
  const [set] = args;
80
77
  return {
@@ -97,9 +94,11 @@ function initStore(props) {
97
94
  datasources,
98
95
  ttl,
99
96
  isEditMode: !!isEditMode,
100
- setEditMode: (isEditMode)=>set({
97
+ setEditMode: (isEditMode)=>{
98
+ set({
101
99
  isEditMode
102
- }),
100
+ });
101
+ },
103
102
  setDashboard: ({ kind, metadata, spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} } })=>{
104
103
  set((state)=>{
105
104
  state.kind = kind;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createStore } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { shallow } from 'zustand/shallow';\nimport { createContext, ReactElement, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport {\n DashboardResource,\n Display,\n ProjectMetadata,\n DurationString,\n DEFAULT_REFRESH_INTERVAL,\n DatasourceSpec,\n EphemeralDashboardResource,\n} from '@perses-dev/core';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\nimport { createSaveChangesDialogSlice, SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\nimport { createEditJsonDialogSlice, EditJsonDialogSlice } from './edit-json-dialog-slice';\nimport { createPanelDefinition } from './common';\nimport { createViewPanelSlice, ViewPanelSlice } from './view-panel-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice,\n EditJsonDialogSlice,\n SaveChangesConfirmationDialogSlice,\n ViewPanelSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n kind: DashboardResource['kind'] | EphemeralDashboardResource['kind'];\n metadata: ProjectMetadata;\n duration: DurationString;\n refreshInterval: DurationString;\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n ttl?: DurationString;\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource | EphemeralDashboardResource;\n isEditMode?: boolean;\n viewPanelRef?: string;\n setViewPanelRef?: (viewPanelRef: string | undefined) => void;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStoreWithEqualityFn(store, selector, shallow);\n}\n\nexport function DashboardProvider(props: DashboardProviderProps): ReactElement {\n const createDashboardStore = useCallback(initStore, [props]);\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n const [store] = useState(createDashboardStore(props)); // prevent calling createDashboardStore every time it rerenders\n\n useEffect(() => {\n if (plugin === undefined) return;\n const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};\n // set default panel kind, spec, and queries for add panel editor\n store.setState({\n initialValues: {\n panelDefinition: createPanelDefinition(defaultPanelKind, defaultPanelSpec),\n },\n });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps): StoreApi<DashboardStoreState> {\n const {\n initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef },\n } = props;\n\n const {\n kind,\n metadata,\n spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources },\n } = dashboardResource;\n\n const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;\n\n let {\n spec: { layouts, panels },\n } = dashboardResource;\n\n // Set fallbacks in case the frontend is used with a non-Perses backend\n layouts = layouts ?? [];\n panels = panels ?? {};\n\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n /* Groups */\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n /* Panels */\n ...createPanelSlice(panels)(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDuplicatePanelSlice()(...args),\n ...createViewPanelSlice(viewPanelRef, setViewPanelRef)(...args),\n /* General */\n ...createDiscardChangesDialogSlice(...args),\n ...createEditJsonDialogSlice(...args),\n ...createSaveChangesDialogSlice(...args),\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean): void => set({ isEditMode }),\n setDashboard: ({\n kind,\n metadata,\n spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} },\n }): void => {\n set((state) => {\n state.kind = kind;\n state.metadata = metadata;\n state.display = display;\n state.panels = panels;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n state.duration = duration;\n state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n state.datasources = datasources;\n // TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStoreWithEqualityFn","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","DEFAULT_REFRESH_INTERVAL","usePlugin","usePluginRegistry","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createSaveChangesDialogSlice","createDuplicatePanelSlice","createEditJsonDialogSlice","createPanelDefinition","createViewPanelSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","defaultPanelSpec","createInitialOptions","setState","initialValues","panelDefinition","Provider","value","children","initialState","dashboardResource","isEditMode","viewPanelRef","setViewPanelRef","kind","metadata","spec","display","duration","refreshInterval","datasources","ttl","layouts","panels","args","set","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iC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C,4BAA4B+C,KAAK;YACpC,GAAG5C,4BAA4B4C,KAAK;YACpC,GAAGzC,+BAA+ByC,KAAK;YACvC,GAAGtC,qBAAqB0B,cAAcC,oBAAoBW,KAAK;YAC/D,WAAW,GACX,GAAG3C,mCAAmC2C,KAAK;YAC3C,GAAGxC,6BAA6BwC,KAAK;YACrC,GAAG1C,gCAAgC0C,KAAK;YACxCV;YACAC;YACAE;YACAC;YACAC;YACAC;YACAC;YACAV,YAAY,CAAC,CAACA;YACde,aAAa,CAACf,aAA8Bc,IAAI;oBAAEd;gBAAW;YAC7DgB,cAAc,CAAC,EACbb,IAAI,EACJC,QAAQ,EACRC,MAAM,EAAEC,OAAO,EAAEM,SAAS,CAAC,CAAC,EAAED,UAAU,EAAE,EAAEJ,QAAQ,EAAEC,eAAe,EAAEC,cAAc,CAAC,CAAC,EAAE,EAC1F;gBACCK,IAAI,CAACG;oBACHA,MAAMd,IAAI,GAAGA;oBACbc,MAAMb,QAAQ,GAAGA;oBACjBa,MAAMX,OAAO,GAAGA;oBAChBW,MAAML,MAAM,GAAGA;oBACf,MAAM,EAAEM,WAAW,EAAEC,eAAe,EAAE,GAAGvD,4BAA4B+C;oBACrEM,MAAMC,WAAW,GAAGA;oBACpBD,MAAME,eAAe,GAAGA;oBACxBF,MAAMV,QAAQ,GAAGA;oBACjBU,MAAMT,eAAe,GAAGA,mBAAmBhD;oBAC3CyD,MAAMR,WAAW,GAAGA;gBACpB,uGAAuG;gBACzG;YACF;QACF;IACF;IAIJ,OAAO7B;AACT"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProvider.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { createStore } from 'zustand';\nimport { useStoreWithEqualityFn } from 'zustand/traditional';\nimport type { StoreApi } from 'zustand';\nimport { devtools } from 'zustand/middleware';\nimport { immer } from 'zustand/middleware/immer';\nimport { shallow } from 'zustand/shallow';\nimport { createContext, ReactElement, ReactNode, useCallback, useContext, useEffect, useState } from 'react';\nimport {\n DashboardResource,\n Display,\n ProjectMetadata,\n DurationString,\n DEFAULT_REFRESH_INTERVAL,\n DatasourceSpec,\n EphemeralDashboardResource,\n} from '@perses-dev/core';\nimport { usePlugin, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { createPanelGroupEditorSlice, PanelGroupEditorSlice } from './panel-group-editor-slice';\nimport { convertLayoutsToPanelGroups, createPanelGroupSlice, PanelGroupSlice } from './panel-group-slice';\nimport { createPanelEditorSlice, PanelEditorSlice } from './panel-editor-slice';\nimport { createPanelSlice, PanelSlice } from './panel-slice';\nimport { createDeletePanelGroupSlice, DeletePanelGroupSlice } from './delete-panel-group-slice';\nimport { createDeletePanelSlice, DeletePanelSlice } from './delete-panel-slice';\nimport { createDiscardChangesDialogSlice, DiscardChangesConfirmationDialogSlice } from './discard-changes-dialog-slice';\nimport { createSaveChangesDialogSlice, SaveChangesConfirmationDialogSlice } from './save-changes-dialog-slice';\nimport { createDuplicatePanelSlice, DuplicatePanelSlice } from './duplicate-panel-slice';\nimport { createEditJsonDialogSlice, EditJsonDialogSlice } from './edit-json-dialog-slice';\nimport { createPanelDefinition } from './common';\nimport { createViewPanelSlice, ViewPanelSlice, VirtualPanelRef } from './view-panel-slice';\n\nexport interface DashboardStoreState\n extends PanelGroupSlice,\n PanelSlice,\n PanelGroupEditorSlice,\n DeletePanelGroupSlice,\n PanelEditorSlice,\n DeletePanelSlice,\n DiscardChangesConfirmationDialogSlice,\n DuplicatePanelSlice,\n EditJsonDialogSlice,\n SaveChangesConfirmationDialogSlice,\n ViewPanelSlice {\n isEditMode: boolean;\n setEditMode: (isEditMode: boolean) => void;\n setDashboard: (dashboard: DashboardResource | EphemeralDashboardResource) => void;\n kind: DashboardResource['kind'] | EphemeralDashboardResource['kind'];\n metadata: ProjectMetadata;\n duration: DurationString;\n refreshInterval: DurationString;\n display?: Display;\n datasources?: Record<string, DatasourceSpec>;\n ttl?: DurationString;\n}\n\nexport const DashboardContext = createContext<StoreApi<DashboardStoreState> | undefined>(undefined);\n\nexport function useDashboardStore<T>(selector: (state: DashboardStoreState) => T): T {\n const store = useContext(DashboardContext);\n if (store === undefined) {\n throw new Error('No DashboardContext found. Did you forget a Provider?');\n }\n return useStoreWithEqualityFn(store, selector, shallow);\n}\n\nexport interface DashboardStoreProps {\n dashboardResource: DashboardResource | EphemeralDashboardResource;\n isEditMode?: boolean;\n viewPanelRef?: VirtualPanelRef;\n setViewPanelRef?: (viewPanelRef: VirtualPanelRef | undefined) => void;\n}\n\nexport interface DashboardProviderProps {\n initialState: DashboardStoreProps;\n children?: ReactNode;\n}\n\nexport function DashboardProvider(props: DashboardProviderProps): ReactElement {\n // Prevent calling createDashboardStore every time it rerenders\n const createDashboardStore = useCallback(initStore, [props]);\n const [store] = useState(createDashboardStore(props));\n\n // load plugin to retrieve initial spec if default panel kind is defined\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPanelKind = defaultPluginKinds?.['Panel'] ?? '';\n const { data: plugin } = usePlugin('Panel', defaultPanelKind);\n\n useEffect(() => {\n if (plugin === undefined) return;\n const defaultPanelSpec = plugin.createInitialOptions ? plugin.createInitialOptions() : {};\n // set default panel kind, spec, and queries for add panel editor\n store.setState({\n initialValues: {\n panelDefinition: createPanelDefinition(defaultPanelKind, defaultPanelSpec),\n },\n });\n }, [plugin, store, defaultPanelKind]);\n\n return (\n <DashboardContext.Provider value={store as StoreApi<DashboardStoreState>}>\n {props.children}\n </DashboardContext.Provider>\n );\n}\n\nfunction initStore(props: DashboardProviderProps): StoreApi<DashboardStoreState> {\n const {\n initialState: { dashboardResource, isEditMode, viewPanelRef, setViewPanelRef },\n } = props;\n\n const {\n kind,\n metadata,\n spec: { display, duration, refreshInterval = DEFAULT_REFRESH_INTERVAL, datasources, layouts = [], panels = {} },\n } = dashboardResource;\n\n const ttl = 'ttl' in dashboardResource.spec ? dashboardResource.spec.ttl : undefined;\n\n const store = createStore<DashboardStoreState>()(\n immer(\n devtools((...args) => {\n const [set] = args;\n return {\n /* Groups */\n ...createPanelGroupSlice(layouts)(...args),\n ...createPanelGroupEditorSlice(...args),\n ...createDeletePanelGroupSlice(...args),\n /* Panels */\n ...createPanelSlice(panels)(...args),\n ...createPanelEditorSlice()(...args),\n ...createDeletePanelSlice()(...args),\n ...createDuplicatePanelSlice()(...args),\n ...createViewPanelSlice(viewPanelRef, setViewPanelRef)(...args),\n /* General */\n ...createDiscardChangesDialogSlice(...args),\n ...createEditJsonDialogSlice(...args),\n ...createSaveChangesDialogSlice(...args),\n kind,\n metadata,\n display,\n duration,\n refreshInterval,\n datasources,\n ttl,\n isEditMode: !!isEditMode,\n setEditMode: (isEditMode: boolean): void => {\n set({ isEditMode });\n },\n setDashboard: ({\n kind,\n metadata,\n spec: { display, panels = {}, layouts = [], duration, refreshInterval, datasources = {} },\n }): void => {\n set((state) => {\n state.kind = kind;\n state.metadata = metadata;\n state.display = display;\n state.panels = panels;\n const { panelGroups, panelGroupOrder } = convertLayoutsToPanelGroups(layouts);\n state.panelGroups = panelGroups;\n state.panelGroupOrder = panelGroupOrder;\n state.duration = duration;\n state.refreshInterval = refreshInterval ?? DEFAULT_REFRESH_INTERVAL;\n state.datasources = datasources;\n // TODO: add ttl here to e.g allow edition from JSON view, but probably requires quite some refactoring\n });\n },\n };\n })\n )\n );\n\n return store;\n}\n"],"names":["createStore","useStoreWithEqualityFn","devtools","immer","shallow","createContext","useCallback","useContext","useEffect","useState","DEFAULT_REFRESH_INTERVAL","usePlugin","usePluginRegistry","createPanelGroupEditorSlice","convertLayoutsToPanelGroups","createPanelGroupSlice","createPanelEditorSlice","createPanelSlice","createDeletePanelGroupSlice","createDeletePanelSlice","createDiscardChangesDialogSlice","createSaveChangesDialogSlice","createDuplicatePanelSlice","createEditJsonDialogSlice","createPanelDefinition","createViewPanelSlice","DashboardContext","undefined","useDashboardStore","selector","store","Error","DashboardProvider","props","createDashboardStore","initStore","defaultPluginKinds","defaultPanelKind","data","plugin","defaultPanelSpec","createInitialOptions","setState","initialValues","panelDefinition","Provider","value","children","initialState","dashboardResource","isEditMode","viewPanelRef","setViewPanelRef","kind","metadata","spec","display","duration","refreshInterval","datasources","layouts","panels","ttl","args","set","setEditMode","setDashboard","state","panelGroups","panelGroupOrder"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,sBAAsB,QAAQ,sBAAsB;AAE7D,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,OAAO,QAAQ,kBAAkB;AAC1C,SAASC,aAAa,EAA2BC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAC7G,SAKEC,wBAAwB,QAGnB,mBAAmB;AAC1B,SAASC,SAAS,EAAEC,iBAAiB,QAAQ,4BAA4B;AACzE,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,2BAA2B,EAAEC,qBAAqB,QAAyB,sBAAsB;AAC1G,SAASC,sBAAsB,QAA0B,uBAAuB;AAChF,SAASC,gBAAgB,QAAoB,gBAAgB;AAC7D,SAASC,2BAA2B,QAA+B,6BAA6B;AAChG,SAASC,sBAAsB,QAA0B,uBAAuB;AAChF,SAASC,+BAA+B,QAA+C,iCAAiC;AACxH,SAASC,4BAA4B,QAA4C,8BAA8B;AA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oBACpBD,MAAME,eAAe,GAAGA;oBACxBF,MAAMV,QAAQ,GAAGA;oBACjBU,MAAMT,eAAe,GAAGA,mBAAmBhD;oBAC3CyD,MAAMR,WAAW,GAAGA;gBACpB,uGAAuG;gBACzG;YACF;QACF;IACF;IAIJ,OAAO7B;AACT"}
@@ -11,15 +11,15 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
- import { StringParam, useQueryParam } from 'use-query-params';
14
+ import { JsonParam, useQueryParam } from 'use-query-params';
15
15
  import { DashboardProvider } from './DashboardProvider';
16
16
  export function DashboardProviderWithQueryParams({ children, initialState }) {
17
- const [viewPanelRef, setViewPanelRef] = useQueryParam('viewPanelRef', StringParam);
17
+ const [viewPanelRef, setViewPanelRef] = useQueryParam('viewPanelRef', JsonParam);
18
18
  return /*#__PURE__*/ _jsx(DashboardProvider, {
19
19
  initialState: {
20
+ ...initialState,
20
21
  viewPanelRef: viewPanelRef ?? undefined,
21
- setViewPanelRef: setViewPanelRef,
22
- ...initialState
22
+ setViewPanelRef: setViewPanelRef
23
23
  },
24
24
  children: children
25
25
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProviderWithQueryParams.tsx"],"sourcesContent":["// Copyright 2024 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 { StringParam, useQueryParam } from 'use-query-params';\nimport { ReactElement } from 'react';\nimport { DashboardProvider, DashboardProviderProps } from './DashboardProvider';\n\nexport function DashboardProviderWithQueryParams({ children, initialState }: DashboardProviderProps): ReactElement {\n const [viewPanelRef, setViewPanelRef] = useQueryParam('viewPanelRef', StringParam);\n\n return (\n <DashboardProvider\n initialState={{\n viewPanelRef: viewPanelRef ?? undefined, // viewPanelRef can be null, forcing to undefined\n setViewPanelRef: setViewPanelRef,\n ...initialState,\n }}\n >\n {children}\n </DashboardProvider>\n );\n}\n"],"names":["StringParam","useQueryParam","DashboardProvider","DashboardProviderWithQueryParams","children","initialState","viewPanelRef","setViewPanelRef","undefined"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,WAAW,EAAEC,aAAa,QAAQ,mBAAmB;AAE9D,SAASC,iBAAiB,QAAgC,sBAAsB;AAEhF,OAAO,SAASC,iCAAiC,EAAEC,QAAQ,EAAEC,YAAY,EAA0B;IACjG,MAAM,CAACC,cAAcC,gBAAgB,GAAGN,cAAc,gBAAgBD;IAEtE,qBACE,KAACE;QACCG,cAAc;YACZC,cAAcA,gBAAgBE;YAC9BD,iBAAiBA;YACjB,GAAGF,YAAY;QACjB;kBAECD;;AAGP"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/DashboardProviderWithQueryParams.tsx"],"sourcesContent":["// Copyright 2024 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 { JsonParam, useQueryParam } from 'use-query-params';\nimport { ReactElement } from 'react';\nimport { DashboardProvider, DashboardProviderProps } from './DashboardProvider';\n\nexport function DashboardProviderWithQueryParams({ children, initialState }: DashboardProviderProps): ReactElement {\n const [viewPanelRef, setViewPanelRef] = useQueryParam('viewPanelRef', JsonParam);\n\n return (\n <DashboardProvider\n initialState={{\n ...initialState,\n viewPanelRef: viewPanelRef ?? undefined, // viewPanelRef can be null, forcing to undefined\n setViewPanelRef: setViewPanelRef,\n }}\n >\n {children}\n </DashboardProvider>\n );\n}\n"],"names":["JsonParam","useQueryParam","DashboardProvider","DashboardProviderWithQueryParams","children","initialState","viewPanelRef","setViewPanelRef","undefined"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,SAAS,EAAEC,aAAa,QAAQ,mBAAmB;AAE5D,SAASC,iBAAiB,QAAgC,sBAAsB;AAEhF,OAAO,SAASC,iCAAiC,EAAEC,QAAQ,EAAEC,YAAY,EAA0B;IACjG,MAAM,CAACC,cAAcC,gBAAgB,GAAGN,cAAc,gBAAgBD;IAEtE,qBACE,KAACE;QACCG,cAAc;YACZ,GAAGA,YAAY;YACfC,cAAcA,gBAAgBE;YAC9BD,iBAAiBA;QACnB;kBAECH;;AAGP"}
@@ -5,7 +5,7 @@ export type OnSaveDashboard = (dashboard: DashboardResource | EphemeralDashboard
5
5
  */
6
6
  export type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];
7
7
  declare global {
8
- var dashboardStoreId: number;
8
+ var dashboardStoreId: number | undefined;
9
9
  }
10
10
  /**
11
11
  * Helper function to generate unique IDs for things in the dashboard store that don't have a "natural" ID.
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/G,MAAM,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,iBAAiB,GAAG,0BAA0B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9G;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAKnC;AAGD,wBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,WAAW,GAAG,eAAe,CAehH"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/common.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/G,MAAM,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,iBAAiB,GAAG,0BAA0B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAE9G;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC;AAEjF,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAKnC;AAGD,wBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,WAAW,GAAG,eAAe,CAehH"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/common.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource, EphemeralDashboardResource, PanelDefinition, UnknownSpec } from '@perses-dev/core';\n\nexport type OnSaveDashboard = (dashboard: DashboardResource | EphemeralDashboardResource) => Promise<unknown>;\n\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number;\n}\n\n/**\n * Helper function to generate unique IDs for things in the dashboard store that don't have a \"natural\" ID.\n */\nexport function generateId(): number {\n if (globalThis.dashboardStoreId === undefined) {\n globalThis.dashboardStoreId = 0;\n }\n return globalThis.dashboardStoreId++;\n}\n\n// Helper function to create initial PanelDefinitions\nexport function createPanelDefinition(defaultPanelKind?: string, defaultPanelSpec?: UnknownSpec): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: '',\n description: undefined,\n },\n plugin: {\n kind: defaultPanelKind ?? '',\n spec: defaultPanelSpec ?? {},\n },\n queries: [],\n },\n };\n}\n"],"names":["generateId","globalThis","dashboardStoreId","undefined","createPanelDefinition","defaultPanelKind","defaultPanelSpec","kind","spec","display","name","description","plugin","queries"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAgBjC;;CAEC,GACD,OAAO,SAASA;IACd,IAAIC,WAAWC,gBAAgB,KAAKC,WAAW;QAC7CF,WAAWC,gBAAgB,GAAG;IAChC;IACA,OAAOD,WAAWC,gBAAgB;AACpC;AAEA,qDAAqD;AACrD,OAAO,SAASE,sBAAsBC,gBAAyB,EAAEC,gBAA8B;IAC7F,OAAO;QACLC,MAAM;QACNC,MAAM;YACJC,SAAS;gBACPC,MAAM;gBACNC,aAAaR;YACf;YACAS,QAAQ;gBACNL,MAAMF,oBAAoB;gBAC1BG,MAAMF,oBAAoB,CAAC;YAC7B;YACAO,SAAS,EAAE;QACb;IACF;AACF"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/common.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DashboardResource, EphemeralDashboardResource, PanelDefinition, UnknownSpec } from '@perses-dev/core';\n\nexport type OnSaveDashboard = (dashboard: DashboardResource | EphemeralDashboardResource) => Promise<unknown>;\n\n/**\n * The middleware applied to the DashboardStore (can be used as generic argument in StateCreator).\n */\nexport type Middleware = [['zustand/immer', never], ['zustand/devtools', never]];\n\ndeclare global {\n // eslint-disable-next-line no-var\n var dashboardStoreId: number | undefined;\n}\n\n/**\n * Helper function to generate unique IDs for things in the dashboard store that don't have a \"natural\" ID.\n */\nexport function generateId(): number {\n if (globalThis.dashboardStoreId === undefined) {\n globalThis.dashboardStoreId = 0;\n }\n return globalThis.dashboardStoreId++;\n}\n\n// Helper function to create initial PanelDefinitions\nexport function createPanelDefinition(defaultPanelKind?: string, defaultPanelSpec?: UnknownSpec): PanelDefinition {\n return {\n kind: 'Panel',\n spec: {\n display: {\n name: '',\n description: undefined,\n },\n plugin: {\n kind: defaultPanelKind ?? '',\n spec: defaultPanelSpec ?? {},\n },\n queries: [],\n },\n };\n}\n"],"names":["generateId","globalThis","dashboardStoreId","undefined","createPanelDefinition","defaultPanelKind","defaultPanelSpec","kind","spec","display","name","description","plugin","queries"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAgBjC;;CAEC,GACD,OAAO,SAASA;IACd,IAAIC,WAAWC,gBAAgB,KAAKC,WAAW;QAC7CF,WAAWC,gBAAgB,GAAG;IAChC;IACA,OAAOD,WAAWC,gBAAgB;AACpC;AAEA,qDAAqD;AACrD,OAAO,SAASE,sBAAsBC,gBAAyB,EAAEC,gBAA8B;IAC7F,OAAO;QACLC,MAAM;QACNC,MAAM;YACJC,SAAS;gBACPC,MAAM;gBACNC,aAAaR;YACf;YACAS,QAAQ;gBACNL,MAAMF,oBAAoB;gBAC1BG,MAAMF,oBAAoB,CAAC;YAC7B;YACAO,SAAS,EAAE;QACb;IACF;AACF"}
@@ -29,6 +29,7 @@ export interface PanelEditorState {
29
29
  * Whether we're adding a new panel, or editing an existing panel.
30
30
  */
31
31
  mode: Action;
32
+ panelGroupItemId?: PanelGroupItemId;
32
33
  /**
33
34
  * Initial values for the things that can be edited about a panel.
34
35
  */
@@ -1 +1 @@
1
- {"version":3,"file":"panel-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAc,UAAU,EAAyB,MAAM,UAAU,CAAC;AACzE,OAAO,EACL,eAAe,EACf,gBAAgB,EAKjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAE3D;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE5D;;OAEG;IACH,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IAEjC;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAEpD,gBAAgB,GAAG,UAAU,GAAG,eAAe,EAC/C,UAAU,EACV;CAAE,EACF,gBAAgB,CACjB,CA4IA"}
1
+ {"version":3,"file":"panel-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAc,UAAU,EAAyB,MAAM,UAAU,CAAC;AACzE,OAAO,EACL,eAAe,EACf,gBAAgB,EAKjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAC;IAE3D;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,CAAC;IAE/B;;OAEG;IACH,aAAa,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAE5D;;OAEG;IACH,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAKb,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IAEjC;;OAEG;IACH,YAAY,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAEhD;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,YAAY,CAEpD,gBAAgB,GAAG,UAAU,GAAG,eAAe,EAC/C,UAAU,EACV;CAAE,EACF,gBAAgB,CACjB,CA6IA"}
@@ -34,6 +34,7 @@ import { addPanelGroup, createEmptyPanelGroup } from './panel-group-slice';
34
34
  }
35
35
  const editorState = {
36
36
  mode: 'update',
37
+ panelGroupItemId: panelGroupItemId,
37
38
  initialValues: {
38
39
  groupId: panelGroupItemId.panelGroupId,
39
40
  panelDefinition: panelToEdit
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Action, PanelEditorValues, PanelGroupId } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { getYForNewRow, getValidPanelKey } from '../../utils';\nimport { generateId, Middleware, createPanelDefinition } from './common';\nimport {\n PanelGroupSlice,\n PanelGroupItemId,\n PanelGroupDefinition,\n PanelGroupItemLayout,\n addPanelGroup,\n createEmptyPanelGroup,\n} from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for adding or editing Panels.\n */\nexport interface PanelEditorSlice {\n /**\n * Initial values for add panel if default panel kind is defined\n */\n initialValues?: Pick<PanelEditorValues, 'panelDefinition'>;\n\n /**\n * State for the panel editor when its open, otherwise undefined when it's closed.\n */\n panelEditor?: PanelEditorState;\n\n /**\n * Opens the editor for editing an existing panel by providing its layout coordinates.\n */\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Opens the editor for adding a new Panel to a panel group.\n */\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n}\n\nexport interface PanelEditorState {\n /**\n * Whether we're adding a new panel, or editing an existing panel.\n */\n mode: Action;\n\n /**\n * Initial values for the things that can be edited about a panel.\n */\n initialValues: PanelEditorValues;\n\n /**\n * Applies changes, but doesn't close the editor.\n */\n applyChanges: (next: PanelEditorValues) => void;\n\n /**\n * Close the editor.\n */\n close: () => void;\n}\n\n/**\n * Curried function for creating the PanelEditorSlice.\n */\nexport function createPanelEditorSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n PanelEditorSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelEditorSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n panelEditor: undefined,\n\n openEditPanel(panelGroupItemId): void {\n const { panels, panelGroups } = get();\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToEdit = panels[panelKey];\n if (panelToEdit === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n const editorState: PanelEditorState = {\n mode: 'update',\n initialValues: {\n groupId: panelGroupItemId.panelGroupId,\n panelDefinition: panelToEdit,\n },\n applyChanges: (next) => {\n set((state) => {\n state.panels[panelKey] = next.panelDefinition;\n\n // If the panel didn't change groups, nothing else to do\n if (next.groupId === panelGroupId) {\n return;\n }\n\n // Move panel to the new group\n const existingGroup = state.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // Remove item from the old group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // Add item to the end of the new group\n const newGroup = state.panelGroups[next.groupId];\n if (newGroup === undefined) {\n throw new Error(`Could not find new group ${next.groupId}`);\n }\n\n newGroup.itemLayouts.push({\n i: existingLayout.i,\n x: 0,\n y: getYForNewRow(newGroup),\n w: existingLayout.w,\n h: existingLayout.h,\n });\n newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n\n openAddPanel(panelGroupId): void {\n // If a panel group isn't supplied, add to the first group or create a group if there aren't any\n let newGroup: PanelGroupDefinition | undefined = undefined;\n panelGroupId ??= get().panelGroupOrder[0];\n if (panelGroupId === undefined) {\n newGroup = createEmptyPanelGroup();\n newGroup.title = 'Panel Group';\n panelGroupId = newGroup.id;\n }\n\n const editorState: PanelEditorState = {\n mode: 'create',\n initialValues: {\n groupId: panelGroupId,\n panelDefinition: get().initialValues?.panelDefinition ?? createPanelDefinition(),\n },\n applyChanges: (next) => {\n const name = next.panelDefinition.spec.display.name;\n const panelKey = getValidPanelKey(name, get().panels);\n\n set((state) => {\n // Add a panel\n state.panels[panelKey] = next.panelDefinition;\n\n // Also add a panel group item referencing the panel\n const group = state.panelGroups[next.groupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${next.groupId}`);\n }\n const layout: PanelGroupItemLayout = {\n i: generateId().toString(),\n x: 0,\n y: getYForNewRow(group),\n w: 12,\n h: 6,\n };\n group.itemLayouts.push(layout);\n group.itemPanelKeys[layout.i] = panelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n set((state) => {\n // Add the new panel group if one was created for the panel\n if (newGroup !== undefined) {\n addPanelGroup(state, newGroup);\n }\n\n // Open the editor with the new state\n state.panelEditor = editorState;\n });\n },\n });\n}\n"],"names":["getYForNewRow","getValidPanelKey","generateId","createPanelDefinition","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panels","panelGroups","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","groupId","panelDefinition","applyChanges","next","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","w","h","close","openAddPanel","panelGroupOrder","title","id","name","spec","display","group","toString"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,s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;oBACNC,eAAe;wBACbC,SAASV;wBACTW,iBAAiBlB,MAAMgB,aAAa,EAAEE,mBAAmBvB;oBAC3D;oBACAwB,cAAc,CAACC;wBACb,MAAMsB,OAAOtB,KAAKF,eAAe,CAACyB,IAAI,CAACC,OAAO,CAACF,IAAI;wBACnD,MAAMhC,WAAWjB,iBAAiBiD,MAAM1C,MAAMK,MAAM;wBAEpDN,IAAI,CAACsB;4BACH,cAAc;4BACdA,MAAMhB,MAAM,CAACK,SAAS,GAAGU,KAAKF,eAAe;4BAE7C,oDAAoD;4BACpD,MAAM2B,QAAQxB,MAAMf,WAAW,CAACc,KAAKH,OAAO,CAAC;4BAC7C,IAAI4B,UAAU3C,WAAW;gCACvB,MAAM,IAAIU,MAAM,CAAC,oBAAoB,EAAEQ,KAAKH,OAAO,EAAE;4BACvD;4BACA,MAAMS,SAA+B;gCACnCC,GAAGjC,aAAaoD,QAAQ;gCACxBb,GAAG;gCACHC,GAAG1C,cAAcqD;gCACjBV,GAAG;gCACHC,GAAG;4BACL;4BACAS,MAAMrB,WAAW,CAACQ,IAAI,CAACN;4BACvBmB,MAAMlC,aAAa,CAACe,OAAOC,CAAC,CAAC,GAAGjB;wBAClC;oBACF;oBACA2B,OAAO;wBACLtC,IAAI,CAACsB;4BACHA,MAAMpB,WAAW,GAAGC;wBACtB;oBACF;gBACF;gBAEAH,IAAI,CAACsB;oBACH,2DAA2D;oBAC3D,IAAIU,aAAa7B,WAAW;wBAC1BN,cAAcyB,OAAOU;oBACvB;oBAEA,qCAAqC;oBACrCV,MAAMpB,WAAW,GAAGa;gBACtB;YACF;QACF,CAAA;AACF"}
1
+ {"version":3,"sources":["../../../src/context/DashboardProvider/panel-editor-slice.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Action, PanelEditorValues, PanelGroupId } from '@perses-dev/core';\nimport { StateCreator } from 'zustand';\nimport { getYForNewRow, getValidPanelKey } from '../../utils';\nimport { generateId, Middleware, createPanelDefinition } from './common';\nimport {\n PanelGroupSlice,\n PanelGroupItemId,\n PanelGroupDefinition,\n PanelGroupItemLayout,\n addPanelGroup,\n createEmptyPanelGroup,\n} from './panel-group-slice';\nimport { PanelSlice } from './panel-slice';\n\n/**\n * Slice that handles the visual editor state and actions for adding or editing Panels.\n */\nexport interface PanelEditorSlice {\n /**\n * Initial values for add panel if default panel kind is defined\n */\n initialValues?: Pick<PanelEditorValues, 'panelDefinition'>;\n\n /**\n * State for the panel editor when its open, otherwise undefined when it's closed.\n */\n panelEditor?: PanelEditorState;\n\n /**\n * Opens the editor for editing an existing panel by providing its layout coordinates.\n */\n openEditPanel: (panelGroupItemId: PanelGroupItemId) => void;\n\n /**\n * Opens the editor for adding a new Panel to a panel group.\n */\n openAddPanel: (panelGroupId?: PanelGroupId) => void;\n}\n\nexport interface PanelEditorState {\n /**\n * Whether we're adding a new panel, or editing an existing panel.\n */\n mode: Action;\n\n /*\n * Original item in a PanelGroup edited\n */\n panelGroupItemId?: PanelGroupItemId;\n\n /**\n * Initial values for the things that can be edited about a panel.\n */\n initialValues: PanelEditorValues;\n\n /**\n * Applies changes, but doesn't close the editor.\n */\n applyChanges: (next: PanelEditorValues) => void;\n\n /**\n * Close the editor.\n */\n close: () => void;\n}\n\n/**\n * Curried function for creating the PanelEditorSlice.\n */\nexport function createPanelEditorSlice(): StateCreator<\n // Actions in here need to modify both Panels and Panel Groups state\n PanelEditorSlice & PanelSlice & PanelGroupSlice,\n Middleware,\n [],\n PanelEditorSlice\n> {\n // Return the state creator function for Zustand that uses the panels provided as intitial state\n return (set, get) => ({\n panelEditor: undefined,\n\n openEditPanel(panelGroupItemId): void {\n const { panels, panelGroups } = get();\n\n // Figure out the panel key at that location\n const { panelGroupId, panelGroupItemLayoutId: panelGroupLayoutId } = panelGroupItemId;\n const panelKey = panelGroups[panelGroupId]?.itemPanelKeys[panelGroupLayoutId];\n if (panelKey === undefined) {\n throw new Error(`Could not find Panel Group item ${panelGroupItemId}`);\n }\n\n // Find the panel to edit\n const panelToEdit = panels[panelKey];\n if (panelToEdit === undefined) {\n throw new Error(`Cannot find Panel with key '${panelKey}'`);\n }\n\n const editorState: PanelEditorState = {\n mode: 'update',\n panelGroupItemId: panelGroupItemId,\n initialValues: {\n groupId: panelGroupItemId.panelGroupId,\n panelDefinition: panelToEdit,\n },\n applyChanges: (next) => {\n set((state) => {\n state.panels[panelKey] = next.panelDefinition;\n\n // If the panel didn't change groups, nothing else to do\n if (next.groupId === panelGroupId) {\n return;\n }\n\n // Move panel to the new group\n const existingGroup = state.panelGroups[panelGroupId];\n if (existingGroup === undefined) {\n throw new Error(`Missing panel group ${panelGroupId}`);\n }\n\n const existingLayoutIdx = existingGroup.itemLayouts.findIndex((layout) => layout.i === panelGroupLayoutId);\n const existingLayout = existingGroup.itemLayouts[existingLayoutIdx];\n const existingPanelKey = existingGroup.itemPanelKeys[panelGroupLayoutId];\n if (existingLayoutIdx === -1 || existingLayout === undefined || existingPanelKey === undefined) {\n throw new Error(`Missing panel group item ${panelGroupLayoutId}`);\n }\n\n // Remove item from the old group\n existingGroup.itemLayouts.splice(existingLayoutIdx, 1);\n delete existingGroup.itemPanelKeys[panelGroupLayoutId];\n\n // Add item to the end of the new group\n const newGroup = state.panelGroups[next.groupId];\n if (newGroup === undefined) {\n throw new Error(`Could not find new group ${next.groupId}`);\n }\n\n newGroup.itemLayouts.push({\n i: existingLayout.i,\n x: 0,\n y: getYForNewRow(newGroup),\n w: existingLayout.w,\n h: existingLayout.h,\n });\n newGroup.itemPanelKeys[existingLayout.i] = existingPanelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n // Open the editor with the new state\n set((state) => {\n state.panelEditor = editorState;\n });\n },\n\n openAddPanel(panelGroupId): void {\n // If a panel group isn't supplied, add to the first group or create a group if there aren't any\n let newGroup: PanelGroupDefinition | undefined = undefined;\n panelGroupId ??= get().panelGroupOrder[0];\n if (panelGroupId === undefined) {\n newGroup = createEmptyPanelGroup();\n newGroup.title = 'Panel Group';\n panelGroupId = newGroup.id;\n }\n\n const editorState: PanelEditorState = {\n mode: 'create',\n initialValues: {\n groupId: panelGroupId,\n panelDefinition: get().initialValues?.panelDefinition ?? createPanelDefinition(),\n },\n applyChanges: (next) => {\n const name = next.panelDefinition.spec.display.name;\n const panelKey = getValidPanelKey(name, get().panels);\n\n set((state) => {\n // Add a panel\n state.panels[panelKey] = next.panelDefinition;\n\n // Also add a panel group item referencing the panel\n const group = state.panelGroups[next.groupId];\n if (group === undefined) {\n throw new Error(`Missing panel group ${next.groupId}`);\n }\n const layout: PanelGroupItemLayout = {\n i: generateId().toString(),\n x: 0,\n y: getYForNewRow(group),\n w: 12,\n h: 6,\n };\n group.itemLayouts.push(layout);\n group.itemPanelKeys[layout.i] = panelKey;\n });\n },\n close: () => {\n set((state) => {\n state.panelEditor = undefined;\n });\n },\n };\n\n set((state) => {\n // Add the new panel group if one was created for the panel\n if (newGroup !== undefined) {\n addPanelGroup(state, newGroup);\n }\n\n // Open the editor with the new state\n state.panelEditor = editorState;\n });\n },\n });\n}\n"],"names":["getYForNewRow","getValidPanelKey","generateId","createPanelDefinition","addPanelGroup","createEmptyPanelGroup","createPanelEditorSlice","set","get","panelEditor","undefined","openEditPanel","panelGroupItemId","panels","panelGroups","panelGroupId","panelGroupItemLayoutId","panelGroupLayoutId","panelKey","itemPanelKeys","Error","panelToEdit","editorState","mode","initialValues","groupId","panelDefinition","applyChanges","next","state","existingGroup","existingLayoutIdx","itemLayouts","findIndex","layout","i","existingLayout","existingPanelKey","splice","newGroup","push","x","y","w","h","close","openAddPanel","pan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interface PanelGroupEditor {
11
11
  export interface PanelGroupEditorValues {
12
12
  title: string;
13
13
  isCollapsed: boolean;
14
+ repeatVariable: string | undefined;
14
15
  }
15
16
  /**
16
17
  * Slice that handles the visual editor state and related actions for adding or editing Panel Groups.
@@ -1 +1 @@
1
- {"version":3,"file":"panel-group-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAwC,MAAM,qBAAqB,CAAC;AAE5F,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,aAAa,EAAE,sBAAsB,CAAC;IACtC,YAAY,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACrD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAE9B;;OAEG;IACH,kBAAkB,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAEpD,qBAAqB,GAAG,eAAe,EACvC,UAAU,EACV;CAAE,EACF,qBAAqB,CAoErB,CAAC"}
1
+ {"version":3,"file":"panel-group-editor-slice.d.ts","sourceRoot":"","sources":["../../../src/context/DashboardProvider/panel-group-editor-slice.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,eAAe,EAAwC,MAAM,qBAAqB,CAAC;AAE5F,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,aAAa,EAAE,sBAAsB,CAAC;IACtC,YAAY,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACrD,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAEpC;;OAEG;IACH,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAE9B;;OAEG;IACH,kBAAkB,EAAE,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAEpD,qBAAqB,GAAG,eAAe,EACvC,UAAU,EACV;CAAE,EACF,qBAAqB,CAwErB,CAAC"}
@@ -19,12 +19,14 @@ export const createPanelGroupEditorSlice = (set, get)=>({
19
19
  mode: 'Add',
20
20
  initialValues: {
21
21
  title: '',
22
- isCollapsed: false
22
+ isCollapsed: false,
23
+ repeatVariable: ''
23
24
  },
24
25
  applyChanges (next) {
25
26
  const newGroup = createEmptyPanelGroup();
26
27
  newGroup.title = next.title;
27
28
  newGroup.isCollapsed = next.isCollapsed;
29
+ newGroup.repeatVariable = next.repeatVariable;
28
30
  set((draft)=>{
29
31
  addPanelGroup(draft, newGroup);
30
32
  });
@@ -50,7 +52,8 @@ export const createPanelGroupEditorSlice = (set, get)=>({
50
52
  mode: 'Edit',
51
53
  initialValues: {
52
54
  title: existingGroup.title ?? '',
53
- isCollapsed: existingGroup.isCollapsed
55
+ isCollapsed: existingGroup.isCollapsed,
56
+ repeatVariable: existingGroup.repeatVariable ?? ''
54
57
  },
55
58
  applyChanges (next) {
56
59
  set((draft)=>{
@@ -60,6 +63,7 @@ export const createPanelGroupEditorSlice = (set, get)=>({
60
63
  }
61
64
  group.title = next.title;
62
65
  group.isCollapsed = next.isCollapsed;
66
+ group.repeatVariable = next.repeatVariable;
63
67
  });
64
68
  },
65
69
  close () {