@perses-dev/dashboards 0.52.0 → 0.53.0-beta.1
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.
- package/dist/cjs/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
- package/dist/cjs/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +9 -67
- package/dist/cjs/components/GridLayout/GridLayout.js +1 -1
- package/dist/cjs/components/LeaveDialog/LeaveDialog.js +10 -1
- package/dist/cjs/components/Panel/Panel.js +4 -3
- package/dist/cjs/components/Panel/PanelHeader.js +1 -9
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +186 -183
- package/dist/cjs/components/PanelDrawer/PanelPreview.js +3 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +6 -21
- package/dist/cjs/components/QueryViewerDialog/QueryViewerDialog.js +121 -0
- package/dist/cjs/components/QueryViewerDialog/index.js +30 -0
- package/dist/cjs/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +18 -6
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
- package/dist/cjs/components/Variables/ListVariableListBox.js +201 -0
- package/dist/cjs/components/Variables/Variable.js +164 -72
- package/dist/cjs/components/Variables/VariableList.js +2 -2
- package/dist/cjs/components/Variables/index.js +1 -0
- package/dist/cjs/components/index.js +2 -1
- package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +1 -1
- package/dist/cjs/context/DashboardProvider/delete-panel-slice.js +1 -1
- package/dist/cjs/context/DashboardProvider/duplicate-panel-slice.js +1 -1
- package/dist/cjs/context/DashboardProvider/index.js +1 -1
- package/dist/cjs/context/DashboardProvider/panel-editor-slice.js +1 -1
- package/dist/cjs/context/DashboardProvider/panel-group-slice.js +1 -7
- package/dist/cjs/context/DashboardProvider/view-panel-slice.js +1 -1
- package/dist/cjs/context/DatasourceStoreProvider.js +3 -4
- package/dist/cjs/context/PanelEditorProvider/PanelEditorProvider.js +49 -0
- package/dist/cjs/context/PanelEditorProvider/index.js +23 -0
- package/dist/cjs/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/cjs/context/VariableProvider/hydrationUtils.js +1 -1
- package/dist/cjs/context/VariableProvider/index.js +1 -1
- package/dist/cjs/context/VariableProvider/utils.js +1 -1
- package/dist/cjs/context/index.js +1 -0
- package/dist/cjs/context/useDashboard.js +1 -1
- package/dist/cjs/utils/panelUtils.js +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.d.ts.map +1 -1
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +0 -2
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js +5 -15
- package/dist/components/DeletePanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +10 -68
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +1 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/Row.d.ts +2 -2
- package/dist/components/GridLayout/Row.d.ts.map +1 -1
- package/dist/components/GridLayout/Row.js.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts +2 -1
- package/dist/components/LeaveDialog/LeaveDialog.d.ts.map +1 -1
- package/dist/components/LeaveDialog/LeaveDialog.js +10 -1
- package/dist/components/LeaveDialog/LeaveDialog.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +1 -2
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +5 -4
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +2 -10
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +186 -183
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelPreview.js +4 -1
- package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +5 -15
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
- package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts +9 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.d.ts.map +1 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js +72 -0
- package/dist/components/QueryViewerDialog/QueryViewerDialog.js.map +1 -0
- package/dist/components/QueryViewerDialog/index.d.ts +2 -0
- package/dist/components/QueryViewerDialog/index.d.ts.map +1 -0
- package/dist/components/QueryViewerDialog/index.js +15 -0
- package/dist/components/QueryViewerDialog/index.js.map +1 -0
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js +19 -7
- package/dist/components/SaveChangesConfirmationDialog/SaveChangesConfirmationDialog.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +11 -6
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/ListVariableListBox.d.ts +16 -0
- package/dist/components/Variables/ListVariableListBox.d.ts.map +1 -0
- package/dist/components/Variables/ListVariableListBox.js +141 -0
- package/dist/components/Variables/ListVariableListBox.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +168 -75
- package/dist/components/Variables/Variable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +1 -2
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +2 -2
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +1 -0
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +1 -0
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -1
- package/dist/components/index.js.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +1 -2
- package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js +1 -1
- package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/delete-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js +1 -1
- package/dist/context/DashboardProvider/delete-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js +1 -1
- package/dist/context/DashboardProvider/duplicate-panel-slice.js.map +1 -1
- package/dist/context/DashboardProvider/index.d.ts +0 -1
- package/dist/context/DashboardProvider/index.d.ts.map +1 -1
- package/dist/context/DashboardProvider/index.js +1 -1
- package/dist/context/DashboardProvider/index.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +2 -2
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.d.ts +1 -24
- package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-group-slice.js +1 -6
- package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts +2 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/save-changes-dialog-slice.js.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.d.ts +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js +1 -1
- package/dist/context/DashboardProvider/view-panel-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +1 -17
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +2 -3
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts +13 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.d.ts.map +1 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js +33 -0
- package/dist/context/PanelEditorProvider/PanelEditorProvider.js.map +1 -0
- package/dist/context/PanelEditorProvider/index.d.ts +3 -0
- package/dist/context/PanelEditorProvider/index.d.ts.map +1 -0
- package/dist/context/PanelEditorProvider/index.js +16 -0
- package/dist/context/PanelEditorProvider/index.js.map +1 -0
- package/dist/context/VariableProvider/VariableProvider.d.ts +1 -10
- package/dist/context/VariableProvider/VariableProvider.d.ts.map +1 -1
- package/dist/context/VariableProvider/VariableProvider.js +1 -1
- package/dist/context/VariableProvider/VariableProvider.js.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.d.ts +1 -2
- package/dist/context/VariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js +1 -1
- package/dist/context/VariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/VariableProvider/index.js +1 -1
- package/dist/context/VariableProvider/index.js.map +1 -1
- package/dist/context/VariableProvider/utils.d.ts +1 -2
- package/dist/context/VariableProvider/utils.d.ts.map +1 -1
- package/dist/context/VariableProvider/utils.js +1 -1
- package/dist/context/VariableProvider/utils.js.map +1 -1
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +1 -1
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/utils/panelUtils.d.ts +1 -2
- package/dist/utils/panelUtils.d.ts.map +1 -1
- package/dist/utils/panelUtils.js +1 -1
- package/dist/utils/panelUtils.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.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 { FormEvent, ReactElement } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DeletePanelGroupDialog/DeletePanelGroupDialog.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 { FormEvent, ReactElement } from 'react';\nimport { Dialog } from '@perses-dev/components';\nimport { Button } from '@mui/material';\nimport { useDeletePanelGroupDialog, useViewPanel } from '../../context';\n\nexport const DeletePanelGroupDialog = (): ReactElement => {\n const { deletePanelGroupDialog, closeDeletePanelGroupDialog, deletePanelGroup } = useDeletePanelGroupDialog();\n const { setViewPanel } = useViewPanel();\n const panelGroupId = deletePanelGroupDialog?.panelGroupId;\n\n const handleDelete = (e: FormEvent): void => {\n e.preventDefault();\n if (panelGroupId === undefined) {\n throw new Error('group index is undefined');\n }\n deletePanelGroup(panelGroupId);\n closeDeletePanelGroupDialog();\n setViewPanel(undefined);\n };\n\n return (\n <Dialog open={deletePanelGroupDialog !== undefined}>\n <Dialog.Header>Delete Panel Group</Dialog.Header>\n\n <form onSubmit={handleDelete}>\n <Dialog.Content dividers sx={{ width: '500px' }}>\n Are you sure you want to delete {deletePanelGroupDialog?.panelGroupName ?? 'panel group'}? This will delete\n all the panels within the group.\n </Dialog.Content>\n <Dialog.Actions>\n <Button variant=\"contained\" type=\"submit\">\n Delete\n </Button>\n <Button variant=\"outlined\" color=\"secondary\" onClick={() => closeDeletePanelGroupDialog()}>\n Cancel\n </Button>\n </Dialog.Actions>\n </form>\n </Dialog>\n );\n};\n"],"names":["Dialog","Button","useDeletePanelGroupDialog","useViewPanel","DeletePanelGroupDialog","deletePanelGroupDialog","closeDeletePanelGroupDialog","deletePanelGroup","setViewPanel","panelGroupId","handleDelete","e","preventDefault","undefined","Error","open","Header","form","onSubmit","Content","dividers","sx","width","panelGroupName","Actions","variant","type","color","onClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,MAAM,QAAQ,yBAAyB;AAChD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,yBAAyB,EAAEC,YAAY,QAAQ,gBAAgB;AAExE,OAAO,MAAMC,yBAAyB;IACpC,MAAM,EAAEC,sBAAsB,EAAEC,2BAA2B,EAAEC,gBAAgB,EAAE,GAAGL;IAClF,MAAM,EAAEM,YAAY,EAAE,GAAGL;IACzB,MAAMM,eAAeJ,wBAAwBI;IAE7C,MAAMC,eAAe,CAACC;QACpBA,EAAEC,cAAc;QAChB,IAAIH,iBAAiBI,WAAW;YAC9B,MAAM,IAAIC,MAAM;QAClB;QACAP,iBAAiBE;QACjBH;QACAE,aAAaK;IACf;IAEA,qBACE,MAACb;QAAOe,MAAMV,2BAA2BQ;;0BACvC,KAACb,OAAOgB,MAAM;0BAAC;;0BAEf,MAACC;gBAAKC,UAAUR;;kCACd,MAACV,OAAOmB,OAAO;wBAACC,QAAQ;wBAACC,IAAI;4BAAEC,OAAO;wBAAQ;;4BAAG;4BACdjB,wBAAwBkB,kBAAkB;4BAAc;;;kCAG3F,MAACvB,OAAOwB,OAAO;;0CACb,KAACvB;gCAAOwB,SAAQ;gCAAYC,MAAK;0CAAS;;0CAG1C,KAACzB;gCAAOwB,SAAQ;gCAAWE,OAAM;gCAAYC,SAAS,IAAMtB;0CAA+B;;;;;;;;AAOrG,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"GridItemContent.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"names":[],"mappings":"AAgBA,OAAc,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAC/D,OAAO,EAA2B,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE7E,OAAO,EAAqB,YAAY,EAAE,MAAM,UAAU,CAAC;AAG3D,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,CAmGzE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -11,13 +11,14 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { Box
|
|
14
|
+
import { Box } from '@mui/material';
|
|
15
15
|
import { useInView } from 'react-intersection-observer';
|
|
16
|
-
import { DataQueriesProvider,
|
|
16
|
+
import { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';
|
|
17
17
|
import React, { useMemo, useState } from 'react';
|
|
18
|
+
import { isPanelGroupItemIdEqual } from '@perses-dev/core';
|
|
18
19
|
import { useEditMode, usePanel, usePanelActions, useViewPanelGroup } from '../../context';
|
|
19
20
|
import { Panel } from '../Panel';
|
|
20
|
-
import {
|
|
21
|
+
import { QueryViewerDialog } from '../QueryViewerDialog';
|
|
21
22
|
/**
|
|
22
23
|
* Resolves the reference to panel content in a GridItemDefinition and renders the panel.
|
|
23
24
|
*/ export function GridItemContent(props) {
|
|
@@ -73,38 +74,6 @@ import { isPanelGroupItemIdEqual } from '../../context/DashboardProvider/panel-g
|
|
|
73
74
|
};
|
|
74
75
|
});
|
|
75
76
|
const pluginQueryOptions = typeof plugin?.queryOptions === 'function' ? plugin?.queryOptions(panelDefinition.spec.plugin.spec) : plugin?.queryOptions;
|
|
76
|
-
const queryRows = useMemo(()=>{
|
|
77
|
-
if (!queries?.length) return null;
|
|
78
|
-
const queryItems = [];
|
|
79
|
-
queries.forEach((query, index)=>{
|
|
80
|
-
if (query?.spec?.plugin?.kind && query?.kind) {
|
|
81
|
-
queryItems.push(/*#__PURE__*/ _jsxs(React.Fragment, {
|
|
82
|
-
children: [
|
|
83
|
-
/*#__PURE__*/ _jsx(PluginSpecEditor, {
|
|
84
|
-
value: query.spec.plugin.spec,
|
|
85
|
-
pluginSelection: {
|
|
86
|
-
kind: query.spec.plugin.kind,
|
|
87
|
-
type: query.kind
|
|
88
|
-
},
|
|
89
|
-
onChange: ()=>{},
|
|
90
|
-
isReadonly: true
|
|
91
|
-
}),
|
|
92
|
-
index < queries.length - 1 && /*#__PURE__*/ _jsx(Divider, {
|
|
93
|
-
sx: {
|
|
94
|
-
my: 2
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
]
|
|
98
|
-
}, `query-${index}`));
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
return queryItems;
|
|
102
|
-
}, [
|
|
103
|
-
queries
|
|
104
|
-
]);
|
|
105
|
-
const onCloseHandler = ()=>{
|
|
106
|
-
setOpenQueryViewer(false);
|
|
107
|
-
};
|
|
108
77
|
return /*#__PURE__*/ _jsxs(Box, {
|
|
109
78
|
ref: ref,
|
|
110
79
|
sx: {
|
|
@@ -112,38 +81,6 @@ import { isPanelGroupItemIdEqual } from '../../context/DashboardProvider/panel-g
|
|
|
112
81
|
height: '100%'
|
|
113
82
|
},
|
|
114
83
|
children: [
|
|
115
|
-
/*#__PURE__*/ _jsxs(Dialog, {
|
|
116
|
-
fullWidth: true,
|
|
117
|
-
PaperProps: {
|
|
118
|
-
sx: {
|
|
119
|
-
margin: '10px',
|
|
120
|
-
width: 'calc(100% - 20px)'
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
maxWidth: "lg",
|
|
124
|
-
open: openQueryViewer,
|
|
125
|
-
children: [
|
|
126
|
-
/*#__PURE__*/ _jsx(DialogTitle, {
|
|
127
|
-
children: "Query Viewer"
|
|
128
|
-
}),
|
|
129
|
-
/*#__PURE__*/ _jsx(DialogContent, {
|
|
130
|
-
children: /*#__PURE__*/ _jsx(Box, {
|
|
131
|
-
sx: {
|
|
132
|
-
padding: '5px'
|
|
133
|
-
},
|
|
134
|
-
children: queryRows
|
|
135
|
-
})
|
|
136
|
-
}),
|
|
137
|
-
/*#__PURE__*/ _jsx(DialogActions, {
|
|
138
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
139
|
-
variant: "outlined",
|
|
140
|
-
onClick: onCloseHandler,
|
|
141
|
-
color: "primary",
|
|
142
|
-
children: "Close"
|
|
143
|
-
})
|
|
144
|
-
})
|
|
145
|
-
]
|
|
146
|
-
}),
|
|
147
84
|
/*#__PURE__*/ _jsx(DataQueriesProvider, {
|
|
148
85
|
definitions: definitions,
|
|
149
86
|
options: {
|
|
@@ -161,6 +98,11 @@ import { isPanelGroupItemIdEqual } from '../../context/DashboardProvider/panel-g
|
|
|
161
98
|
panelOptions: props.panelOptions,
|
|
162
99
|
panelGroupItemId: panelGroupItemId
|
|
163
100
|
})
|
|
101
|
+
}),
|
|
102
|
+
/*#__PURE__*/ _jsx(QueryViewerDialog, {
|
|
103
|
+
open: openQueryViewer,
|
|
104
|
+
queryDefinitions: queryDefinitions,
|
|
105
|
+
onClose: ()=>setOpenQueryViewer(false)
|
|
164
106
|
})
|
|
165
107
|
]
|
|
166
108
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Divider } from '@mui/material';\nimport { useInView } from 'react-intersection-observer';\nimport { DataQueriesProvider, PluginSpecEditor, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport React, { ReactElement, useMemo, useState } from 'react';\nimport { PanelGroupItemId, useEditMode, usePanel, usePanelActions, useViewPanelGroup } from '../../context';\nimport { Panel, PanelProps, PanelOptions } from '../Panel';\nimport { isPanelGroupItemIdEqual } from '../../context/DashboardProvider/panel-group-slice';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n width: number; // necessary for determining the suggested step ms\n panelOptions?: PanelOptions;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps): ReactElement {\n const { panelGroupItemId, width } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n\n const {\n spec: { queries },\n } = panelDefinition;\n\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, viewPanel } = usePanelActions(panelGroupItemId);\n const viewPanelGroupItemId = useViewPanelGroup();\n const { ref, inView } = useInView({\n threshold: 0.2, // we have the flexibility to adjust this threshold to trigger queries slightly earlier or later based on performance\n initialInView: false,\n triggerOnce: true,\n });\n\n const [openQueryViewer, setOpenQueryViewer] = useState(false);\n\n const viewQueriesHandler = useMemo(() => {\n return isEditMode || !queries?.length\n ? undefined\n : {\n onClick: (): void => {\n setOpenQueryViewer(true);\n },\n };\n }, [isEditMode, queries]);\n\n const readHandlers = {\n isPanelViewed: isPanelGroupItemIdEqual(viewPanelGroupItemId, panelGroupItemId),\n onViewPanelClick: function (): void {\n if (viewPanelGroupItemId === undefined) {\n viewPanel(panelGroupItemId);\n } else {\n viewPanel(undefined);\n }\n },\n };\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDuplicatePanelClick: duplicatePanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const suggestedStepMs = useSuggestedStepMs(width);\n\n const { data: plugin } = usePlugin('Panel', panelDefinition.spec.plugin.kind);\n\n const queryDefinitions = queries ?? [];\n const definitions = queryDefinitions.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n });\n\n const pluginQueryOptions =\n typeof plugin?.queryOptions === 'function'\n ? plugin?.queryOptions(panelDefinition.spec.plugin.spec)\n : plugin?.queryOptions;\n\n const queryRows = useMemo(() => {\n if (!queries?.length) return null;\n\n const queryItems: ReactElement[] = [];\n queries.forEach((query, index) => {\n if (query?.spec?.plugin?.kind && query?.kind) {\n queryItems.push(\n <React.Fragment key={`query-${index}`}>\n <PluginSpecEditor\n value={query.spec.plugin.spec}\n pluginSelection={{ kind: query.spec.plugin.kind, type: query.kind }}\n onChange={(): void => {}}\n isReadonly\n />\n {index < queries.length - 1 && <Divider sx={{ my: 2 }} />}\n </React.Fragment>\n );\n }\n });\n\n return queryItems;\n }, [queries]);\n\n const onCloseHandler = (): void => {\n setOpenQueryViewer(false);\n };\n\n return (\n <Box\n ref={ref}\n sx={{\n width: '100%',\n height: '100%',\n }}\n >\n <Dialog\n fullWidth\n PaperProps={{\n sx: {\n margin: '10px',\n width: 'calc(100% - 20px)',\n },\n }}\n maxWidth=\"lg\"\n open={openQueryViewer}\n >\n <DialogTitle>Query Viewer</DialogTitle>\n <DialogContent>\n <Box sx={{ padding: '5px' }}>{queryRows}</Box>\n </DialogContent>\n <DialogActions>\n <Button variant=\"outlined\" onClick={onCloseHandler} color=\"primary\">\n Close\n </Button>\n </DialogActions>\n </Dialog>\n <DataQueriesProvider\n definitions={definitions}\n options={{ suggestedStepMs, ...pluginQueryOptions }}\n queryOptions={{ enabled: inView }}\n >\n {inView && (\n <Panel\n definition={panelDefinition}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n panelOptions={props.panelOptions}\n panelGroupItemId={panelGroupItemId}\n />\n )}\n </DataQueriesProvider>\n </Box>\n );\n}\n"],"names":["Box","Button","Dialog","DialogActions","DialogContent","DialogTitle","Divider","useInView","DataQueriesProvider","PluginSpecEditor","usePlugin","useSuggestedStepMs","React","useMemo","useState","useEditMode","usePanel","usePanelActions","useViewPanelGroup","Panel","isPanelGroupItemIdEqual","GridItemContent","props","panelGroupItemId","width","panelDefinition","spec","queries","isEditMode","openEditPanel","openDeletePanelDialog","duplicatePanel","viewPanel","viewPanelGroupItemId","ref","inView","threshold","initialInView","triggerOnce","openQueryViewer","setOpenQueryViewer","viewQueriesHandler","length","undefined","onClick","readHandlers","isPanelViewed","onViewPanelClick","editHandlers","onEditPanelClick","onDuplicatePanelClick","onDeletePanelClick","suggestedStepMs","data","plugin","kind","queryDefinitions","definitions","map","query","pluginQueryOptions","queryOptions","queryRows","queryItems","forEach","index","push","Fragment","value","pluginSelection","type","onChange","isReadonly","sx","my","onCloseHandler","height","fullWidth","PaperProps","margin","maxWidth","open","padding","variant","color","options","enabled","definition","panelOptions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,EAAEC,MAAM,EAAEC,MAAM,EAAEC,aAAa,E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C;KAAQ;IAEZ,MAAMgD,iBAAiB;QACrBnC,mBAAmB;IACrB;IAEA,qBACE,MAACxC;QACCkC,KAAKA;QACLuC,IAAI;YACFjD,OAAO;YACPoD,QAAQ;QACV;;0BAEA,MAAC1E;gBACC2E,SAAS;gBACTC,YAAY;oBACVL,IAAI;wBACFM,QAAQ;wBACRvD,OAAO;oBACT;gBACF;gBACAwD,UAAS;gBACTC,MAAM1C;;kCAEN,KAAClC;kCAAY;;kCACb,KAACD;kCACC,cAAA,KAACJ;4BAAIyE,IAAI;gCAAES,SAAS;4BAAM;sCAAIpB;;;kCAEhC,KAAC3D;kCACC,cAAA,KAACF;4BAAOkF,SAAQ;4BAAWvC,SAAS+B;4BAAgBS,OAAM;sCAAU;;;;;0BAKxE,KAAC5E;gBACCiD,aAAaA;gBACb4B,SAAS;oBAAEjC;oBAAiB,GAAGQ,kBAAkB;gBAAC;gBAClDC,cAAc;oBAAEyB,SAASnD;gBAAO;0BAE/BA,wBACC,KAAChB;oBACCoE,YAAY9D;oBACZoB,cAAcA;oBACdG,cAAcA;oBACdP,oBAAoBA;oBACpB+C,cAAclE,MAAMkE,YAAY;oBAChCjE,kBAAkBA;;;;;AAM9B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridItemContent.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { useInView } from 'react-intersection-observer';\nimport { DataQueriesProvider, usePlugin, useSuggestedStepMs } from '@perses-dev/plugin-system';\nimport React, { ReactElement, useMemo, useState } from 'react';\nimport { isPanelGroupItemIdEqual, PanelGroupItemId } from '@perses-dev/core';\nimport { useEditMode, usePanel, usePanelActions, useViewPanelGroup } from '../../context';\nimport { Panel, PanelProps, PanelOptions } from '../Panel';\nimport { QueryViewerDialog } from '../QueryViewerDialog';\n\nexport interface GridItemContentProps {\n panelGroupItemId: PanelGroupItemId;\n width: number; // necessary for determining the suggested step ms\n panelOptions?: PanelOptions;\n}\n\n/**\n * Resolves the reference to panel content in a GridItemDefinition and renders the panel.\n */\nexport function GridItemContent(props: GridItemContentProps): ReactElement {\n const { panelGroupItemId, width } = props;\n const panelDefinition = usePanel(panelGroupItemId);\n\n const {\n spec: { queries },\n } = panelDefinition;\n\n const { isEditMode } = useEditMode();\n const { openEditPanel, openDeletePanelDialog, duplicatePanel, viewPanel } = usePanelActions(panelGroupItemId);\n const viewPanelGroupItemId = useViewPanelGroup();\n const { ref, inView } = useInView({\n threshold: 0.2, // we have the flexibility to adjust this threshold to trigger queries slightly earlier or later based on performance\n initialInView: false,\n triggerOnce: true,\n });\n\n const [openQueryViewer, setOpenQueryViewer] = useState(false);\n\n const viewQueriesHandler = useMemo(() => {\n return isEditMode || !queries?.length\n ? undefined\n : {\n onClick: (): void => {\n setOpenQueryViewer(true);\n },\n };\n }, [isEditMode, queries]);\n\n const readHandlers = {\n isPanelViewed: isPanelGroupItemIdEqual(viewPanelGroupItemId, panelGroupItemId),\n onViewPanelClick: function (): void {\n if (viewPanelGroupItemId === undefined) {\n viewPanel(panelGroupItemId);\n } else {\n viewPanel(undefined);\n }\n },\n };\n\n // Provide actions to the panel when in edit mode\n let editHandlers: PanelProps['editHandlers'] = undefined;\n if (isEditMode) {\n editHandlers = {\n onEditPanelClick: openEditPanel,\n onDuplicatePanelClick: duplicatePanel,\n onDeletePanelClick: openDeletePanelDialog,\n };\n }\n\n // map TimeSeriesQueryDefinition to Definition<UnknownSpec>\n const suggestedStepMs = useSuggestedStepMs(width);\n\n const { data: plugin } = usePlugin('Panel', panelDefinition.spec.plugin.kind);\n\n const queryDefinitions = queries ?? [];\n const definitions = queryDefinitions.map((query) => {\n return {\n kind: query.spec.plugin.kind,\n spec: query.spec.plugin.spec,\n };\n });\n\n const pluginQueryOptions =\n typeof plugin?.queryOptions === 'function'\n ? plugin?.queryOptions(panelDefinition.spec.plugin.spec)\n : plugin?.queryOptions;\n\n return (\n <Box\n ref={ref}\n sx={{\n width: '100%',\n height: '100%',\n }}\n >\n <DataQueriesProvider\n definitions={definitions}\n options={{ suggestedStepMs, ...pluginQueryOptions }}\n queryOptions={{ enabled: inView }}\n >\n {inView && (\n <Panel\n definition={panelDefinition}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n panelOptions={props.panelOptions}\n panelGroupItemId={panelGroupItemId}\n />\n )}\n </DataQueriesProvider>\n <QueryViewerDialog\n open={openQueryViewer}\n queryDefinitions={queryDefinitions}\n onClose={() => setOpenQueryViewer(false)}\n />\n </Box>\n );\n}\n"],"names":["Box","useInView","DataQueriesProvider","usePlugin","useSuggestedStepMs","React","useMemo","useState","isPanelGroupItemIdEqual","useEditMode","usePanel","usePanelActions","useViewPanelGroup","Panel","QueryViewerDialog","GridItemContent","props","panelGroupItemId","width","panelDefinition","spec","queries","isEditMode","openEditPanel","openDeletePanelDialog","duplicatePanel","viewPanel","viewPanelGroupItemId","ref","inView","threshold","initialInView","triggerOnce","openQueryViewer","setOpenQueryViewer","viewQueriesHandler","length","undefined","onClick","readHandlers","isPanelViewed","onViewPanelClick","editHandlers","onEditPanelClick","onDuplicatePanelClick","onDeletePanelClick","suggestedStepMs","data","plugin","kind","queryDefinitions","definitions","map","query","pluginQueryOptions","queryOptions","sx","height","options","enabled","definition","panelOptions","open","onClose"],"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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AAIf,YAAY;QACdoB,eAAe;YACbC,kBAAkBpB;YAClBqB,uBAAuBnB;YACvBoB,oBAAoBrB;QACtB;IACF;IAEA,2DAA2D;IAC3D,MAAMsB,kBAAkB1C,mBAAmBc;IAE3C,MAAM,EAAE6B,MAAMC,MAAM,EAAE,GAAG7C,UAAU,SAASgB,gBAAgBC,IAAI,CAAC4B,MAAM,CAACC,IAAI;IAE5E,MAAMC,mBAAmB7B,WAAW,EAAE;IACtC,MAAM8B,cAAcD,iBAAiBE,GAAG,CAAC,CAACC;QACxC,OAAO;YACLJ,MAAMI,MAAMjC,IAAI,CAAC4B,MAAM,CAACC,IAAI;YAC5B7B,MAAMiC,MAAMjC,IAAI,CAAC4B,MAAM,CAAC5B,IAAI;QAC9B;IACF;IAEA,MAAMkC,qBACJ,OAAON,QAAQO,iBAAiB,aAC5BP,QAAQO,aAAapC,gBAAgBC,IAAI,CAAC4B,MAAM,CAAC5B,IAAI,IACrD4B,QAAQO;IAEd,qBACE,MAACvD;QACC4B,KAAKA;QACL4B,IAAI;YACFtC,OAAO;YACPuC,QAAQ;QACV;;0BAEA,KAACvD;gBACCiD,aAAaA;gBACbO,SAAS;oBAAEZ;oBAAiB,GAAGQ,kBAAkB;gBAAC;gBAClDC,cAAc;oBAAEI,SAAS9B;gBAAO;0BAE/BA,wBACC,KAAChB;oBACC+C,YAAYzC;oBACZoB,cAAcA;oBACdG,cAAcA;oBACdP,oBAAoBA;oBACpB0B,cAAc7C,MAAM6C,YAAY;oBAChC5C,kBAAkBA;;;0BAIxB,KAACH;gBACCgD,MAAM7B;gBACNiB,kBAAkBA;gBAClBa,SAAS,IAAM7B,mBAAmB;;;;AAI1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"GridLayout.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/GridLayout.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAwB,MAAM,kBAAkB,CAAC;AAItE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAO,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,CAmE/D;AAED,MAAM,WAAW,qBAAsB,SAAQ,QAAQ;IACrD,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAkB,EAClB,cAAc,EACd,aAAa,GACd,EAAE,qBAAqB,GAAG,YAAY,GAAG,IAAI,CA0C7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/GridLayout/GridLayout.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/GridLayout.tsx"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { ReactElement, useState } from 'react';\nimport { Layouts, Layout } from 'react-grid-layout';\nimport { PanelGroupId, PanelGroupDefinition } from '@perses-dev/core';\nimport { useVariableValues, VariableContext } from '@perses-dev/plugin-system';\nimport { useEditMode, usePanelGroup, usePanelGroupActions, useViewPanelGroup } from '../../context';\nimport { GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { PanelOptions } from '../Panel';\nimport { Row, RowProps } from './Row';\n\nexport interface GridLayoutProps {\n panelGroupId: PanelGroupId;\n panelOptions?: PanelOptions;\n panelFullHeight?: number;\n}\n\n/**\n * Layout component that arranges children in a Grid based on the definition.\n */\nexport function GridLayout(props: GridLayoutProps): ReactElement {\n const { panelGroupId, panelOptions, panelFullHeight } = props;\n const groupDefinition: PanelGroupDefinition = usePanelGroup(panelGroupId);\n const { updatePanelGroupLayouts } = usePanelGroupActions(panelGroupId);\n const viewPanelItemId = useViewPanelGroup();\n const { isEditMode } = useEditMode();\n\n const [gridColWidth, setGridColWidth] = useState(0);\n\n const hasViewPanel = viewPanelItemId?.panelGroupId === panelGroupId; // current panelGroup contains the panel extended?\n\n const handleLayoutChange = (currentLayout: Layout[], allLayouts: Layouts): void => {\n // Using the value from `allLayouts` instead of `currentLayout` because of\n // a bug in react-layout-grid where `currentLayout` does not adjust properly\n // when going to a smaller breakpoint and then back to a larger breakpoint.\n // https://github.com/react-grid-layout/react-grid-layout/issues/1663\n const smallLayout = allLayouts[GRID_LAYOUT_SMALL_BREAKPOINT];\n if (smallLayout && !hasViewPanel) {\n updatePanelGroupLayouts(smallLayout);\n }\n };\n\n /**\n * Calculate the column width so we can determine the width of each panel for suggested step ms\n * https://github.com/react-grid-layout/react-grid-layout/blob/master/lib/calculateUtils.js#L14-L35\n */\n const handleWidthChange = (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ): void => {\n const marginX = margin[0];\n const marginWidth = marginX * (cols - 1);\n const containerPaddingWidth = containerPadding[0] * 2;\n // exclude margin and padding from total width\n setGridColWidth((containerWidth - marginWidth - containerPaddingWidth) / cols);\n };\n\n return (\n <>\n {!groupDefinition.repeatVariable ? (\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={handleLayoutChange}\n onWidthChange={handleWidthChange}\n />\n ) : (\n <RepeatGridLayout\n repeatVariableName={groupDefinition.repeatVariable}\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={handleLayoutChange}\n onWidthChange={handleWidthChange}\n />\n )}\n </>\n );\n}\n\nexport interface RepeatGridLayoutProps extends RowProps {\n repeatVariableName: string;\n}\n\n/**\n * Renders a grid layout for a repeated variable, where each value of the variable will create a new row.\n */\nexport function RepeatGridLayout({\n repeatVariableName,\n panelGroupId,\n groupDefinition,\n gridColWidth,\n panelFullHeight,\n panelOptions,\n isEditMode = false,\n onLayoutChange,\n onWidthChange,\n}: RepeatGridLayoutProps): ReactElement | null {\n const variables = useVariableValues();\n const variable = variables[repeatVariableName];\n\n // If the variable is not defined, or if it is defined but has no values, render a standard row without repeating\n if (variable === undefined || !Array.isArray(variable.value) || variable.value.length === 0) {\n return (\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n />\n );\n }\n\n return (\n <>\n {variable.value.map((value) => (\n <VariableContext.Provider\n key={`${repeatVariableName}-${value}`}\n value={{ state: { ...variables, [repeatVariableName]: { value, loading: false } } }}\n >\n <Row\n panelGroupId={panelGroupId}\n groupDefinition={groupDefinition}\n gridColWidth={gridColWidth}\n panelFullHeight={panelFullHeight}\n panelOptions={panelOptions}\n isEditMode={isEditMode}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n repeatVariable={[repeatVariableName, value]}\n />\n </VariableContext.Provider>\n ))}\n </>\n );\n}\n"],"names":["useState","useVariableValues","VariableContext","useEditMode","usePanelGroup","usePanelGroupActions","useViewPanelGroup","GRID_LAYOUT_SMALL_BREAKPOINT","Row","GridLayout","props","panelGroupId","panelOptions","panelFullHeight","groupDefinition","updatePanelGroupLayouts","viewPanelItemId","isEditMode","gridColWidth","setGridColWidth","hasViewPanel","handleLayoutChange","currentLayout","allLayouts","smallLayout","handleWidthChange","containerWidth","margin","cols","containerPadding","marginX","marginWidth","containerPaddingWidth","repeatVariable","onLayoutChange","onWidthChange","RepeatGridLayout","repeatVariableName","variables","variable","undefined","Array","isArray","value","length","map","Provider","state","loading"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AACjC,SAAuBA,QAAQ,QAAQ,QAAQ;AAG/C,SAASC,iBAAiB,EAAEC,eAAe,QAAQ,4BAA4B;AAC/E,SAASC,WAAW,EAAEC,aAAa,EAAEC,oBAAoB,EAAEC,iBAAiB,QAAQ,gBAAgB;AACpG,SAASC,4BAA4B,QAAQ,kBAAkB;AAE/D,SAASC,GAAG,QAAkB,QAAQ;AAQtC;;CAEC,GACD,OAAO,SAASC,WAAWC,KAAsB;IAC/C,MAAM,EAAEC,YAAY,EAAEC,YAAY,EAAEC,eAAe,EAAE,GAAGH;IACxD,MAAMI,kBAAwCV,cAAcO;IAC5D,MAAM,EAAEI,uBAAuB,EAAE,GAAGV,qBAAqBM;IACzD,MAAMK,kBAAkBV;IACxB,MAAM,EAAEW,UAAU,EAAE,GAAGd;IAEvB,MAAM,CAACe,cAAcC,gBAAgB,GAAGnB,SAAS;IAEjD,MAAM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,GAAG;QAC3F,qBACE,KAACpC;YACCG,cAAcA;YACdG,iBAAiBA;YACjBI,cAAcA;YACdL,iBAAiBA;YACjBD,cAAcA;YACdK,YAAYA;YACZiB,gBAAgBA;YAChBC,eAAeA;;IAGrB;IAEA,qBACE;kBACGI,SAASI,KAAK,CAACE,GAAG,CAAC,CAACF,sBACnB,KAACzC,gBAAgB4C,QAAQ;gBAEvBH,OAAO;oBAAEI,OAAO;wBAAE,GAAGT,SAAS;wBAAE,CAACD,mBAAmB,EAAE;4BAAEM;4BAAOK,SAAS;wBAAM;oBAAE;gBAAE;0BAElF,cAAA,KAACxC;oBACCG,cAAcA;oBACdG,iBAAiBA;oBACjBI,cAAcA;oBACdL,iBAAiBA;oBACjBD,cAAcA;oBACdK,YAAYA;oBACZiB,gBAAgBA;oBAChBC,eAAeA;oBACfF,gBAAgB;wBAACI;wBAAoBM;qBAAM;;eAZxC,GAAGN,mBAAmB,CAAC,EAAEM,OAAO;;AAkB/C"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PanelGroupId } from '@perses-dev/core';
|
|
2
|
-
import {
|
|
1
|
+
import { PanelGroupId, PanelGroupDefinition } from '@perses-dev/core';
|
|
2
|
+
import { PanelOptions } from '@perses-dev/dashboards';
|
|
3
3
|
import { ReactElement } from 'react';
|
|
4
4
|
import { Layout, Layouts } from 'react-grid-layout';
|
|
5
5
|
export interface RowProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/Row.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../src/components/GridLayout/Row.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAwB,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAqB,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,YAAY,EAAgC,MAAM,OAAO,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,OAAO,EAA6B,MAAM,mBAAmB,CAAC;AAU/E,MAAM,WAAW,QAAQ;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,oBAAoB,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACxE,aAAa,CAAC,EAAE,CACd,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAC/B,IAAI,CAAC;IACV,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,wBAAgB,GAAG,CAAC,EAClB,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,UAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,GACf,EAAE,QAAQ,GAAG,YAAY,CAoGzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/GridLayout/Row.tsx"],"sourcesContent":["// Copyright 2025 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 { Collapse, useTheme } from '@mui/material';\nimport { PanelGroupId } from '@perses-dev/core';\nimport { PanelGroupDefinition, PanelGroupItemLayout, PanelOptions, useViewPanelGroup } from '@perses-dev/dashboards';\nimport { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { Layout, Layouts, Responsive, WidthProvider } from 'react-grid-layout';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { GRID_LAYOUT_COLS, GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { GridContainer } from './GridContainer';\nimport { GridItemContent } from './GridItemContent';\nimport { GridTitle } from './GridTitle';\n\nconst DEFAULT_MARGIN = 10;\nconst ROW_HEIGHT = 30;\n\nexport interface RowProps {\n panelGroupId: PanelGroupId;\n groupDefinition: PanelGroupDefinition;\n gridColWidth: number;\n panelFullHeight?: number;\n panelOptions?: PanelOptions;\n isEditMode?: boolean;\n onLayoutChange?: (currentLayout: Layout[], allLayouts: Layouts) => void;\n onWidthChange?: (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ) => void;\n repeatVariable?: [string, string];\n}\n\nexport function Row({\n panelGroupId,\n groupDefinition,\n gridColWidth,\n panelFullHeight,\n panelOptions,\n isEditMode = false,\n onLayoutChange,\n onWidthChange,\n repeatVariable,\n}: RowProps): ReactElement {\n const ResponsiveGridLayout = useMemo(() => WidthProvider(Responsive), []);\n const theme = useTheme();\n const viewPanelItemId = useViewPanelGroup();\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed);\n\n const hasViewPanel =\n viewPanelItemId?.panelGroupId === panelGroupId &&\n // Check for repeatVariable panels\n viewPanelItemId.repeatVariable?.[0] === repeatVariable?.[0] &&\n viewPanelItemId.repeatVariable?.[1] === repeatVariable?.[1];\n const itemLayoutViewed = viewPanelItemId?.panelGroupItemLayoutId;\n\n // If there is a panel in view mode, we should hide the grid if the panel is not in the current group.\n const isGridDisplayed = !viewPanelItemId || hasViewPanel;\n\n // TODO: handle it without useEffect\n useEffect(() => {\n if (hasViewPanel) {\n setIsOpen(true);\n }\n }, [hasViewPanel]);\n\n // Item layout is override if there is a panel in view mode\n const itemLayouts: PanelGroupItemLayout[] = useMemo(() => {\n if (itemLayoutViewed) {\n return groupDefinition.itemLayouts.map((itemLayout) => {\n if (itemLayout.i === itemLayoutViewed) {\n const rowTitleHeight = 40 + 8; // 40 is the height of the row title and 8 is the margin height\n return {\n h: Math.round(((panelFullHeight ?? window.innerHeight) - rowTitleHeight) / (ROW_HEIGHT + DEFAULT_MARGIN)), // Viewed panel should take the full height remaining\n i: itemLayoutViewed,\n w: 48,\n x: 0,\n y: 0,\n } as PanelGroupItemLayout;\n }\n return itemLayout;\n });\n }\n return groupDefinition.itemLayouts;\n }, [groupDefinition.itemLayouts, itemLayoutViewed, panelFullHeight]);\n\n return (\n <GridContainer\n sx={{\n display: isGridDisplayed ? 'block' : 'none',\n height: itemLayoutViewed ? `${panelFullHeight}px` : 'unset',\n overflow: itemLayoutViewed ? 'hidden' : 'unset',\n }}\n >\n {groupDefinition.title && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen: isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false} data-testid=\"panel-group-content\">\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ [GRID_LAYOUT_SMALL_BREAKPOINT]: theme.breakpoints.values.sm, xxs: 0 }}\n cols={GRID_LAYOUT_COLS}\n rowHeight={ROW_HEIGHT}\n draggableHandle=\".drag-handle\"\n resizeHandles={['se']}\n isDraggable={isEditMode && !hasViewPanel}\n isResizable={isEditMode && !hasViewPanel}\n margin={[DEFAULT_MARGIN, DEFAULT_MARGIN]}\n containerPadding={[0, 10]}\n layouts={{ sm: itemLayouts }}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n allowOverlap={hasViewPanel} // Enabling overlap when viewing a specific panel because panel in front of the viewed panel will add empty spaces (empty row height)\n >\n {itemLayouts.map(({ i, w }) => (\n <div\n key={i}\n style={{\n display: itemLayoutViewed ? (itemLayoutViewed === i ? 'unset' : 'none') : 'unset',\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent\n panelOptions={panelOptions}\n panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i, repeatVariable }}\n width={calculateGridItemWidth(w, gridColWidth)}\n />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n\nconst calculateGridItemWidth = (w: number, colWidth: number): number => {\n // 0 * Infinity === NaN, which causes problems with resize contraints\n if (!Number.isFinite(w)) return w;\n return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);\n};\n"],"names":["Collapse","useTheme","useViewPanelGroup","useEffect","useMemo","useState","Responsive","WidthProvider","ErrorAlert","ErrorBoundary","GRID_LAYOUT_COLS","GRID_LAYOUT_SMALL_BREAKPOINT","GridContainer","GridItemContent","GridTitle","DEFAULT_MARGIN","ROW_HEIGHT","Row","panelGroupId","groupDefinition","gridColWidth","panelFullHeight","panelOptions","isEditMode","onLayoutChange","onWidthChange","repeatVariable","ResponsiveGridLayout","theme","viewPanelItemId","isOpen","setIsOpen","isCollapsed","hasViewPanel","itemLayoutViewed","panelGroupItemLayoutId","isGridDisplayed","itemLayouts","map","itemLayout","i","rowTitleHeight","h","Math","round","window","innerHeight","w","x","y","sx","display","height","overflow","title","collapse","undefined","onToggleOpen","current","in","unmountOnExit","appear","data-testid","className","breakpoints","values","sm","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","margin","containerPadding","layouts","allowOverlap","div","style","FallbackComponent","panelGroupItemId","width","calculateGridItemWidth","colWidth","Number","isFinite","max"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;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;oBAC5BwC,aAAalD,cAAc,CAACU;oBAC5ByC,QAAQ;wBAAC3D;wBAAgBA;qBAAe;oBACxC4D,kBAAkB;wBAAC;wBAAG;qBAAG;oBACzBC,SAAS;wBAAEV,IAAI7B;oBAAY;oBAC3Bb,gBAAgBA;oBAChBC,eAAeA;oBACfoD,cAAc5C;8BAEbI,YAAYC,GAAG,CAAC,CAAC,EAAEE,CAAC,EAAEO,CAAC,EAAE,iBACxB,KAAC+B;4BAECC,OAAO;gCACL5B,SAASjB,mBAAoBA,qBAAqBM,IAAI,UAAU,SAAU;4BAC5E;sCAEA,cAAA,KAAC/B;gCAAcuE,mBAAmBxE;0CAChC,cAAA,KAACK;oCACCS,cAAcA;oCACd2D,kBAAkB;wCAAE/D;wCAAciB,wBAAwBK;wCAAGd;oCAAe;oCAC5EwD,OAAOC,uBAAuBpC,GAAG3B;;;2BAThCoB;;;;;AAkBnB;AAEA,MAAM2C,yBAAyB,CAACpC,GAAWqC;IACzC,qEAAqE;IACrE,IAAI,CAACC,OAAOC,QAAQ,CAACvC,IAAI,OAAOA;IAChC,OAAOJ,KAAKC,KAAK,CAACwC,WAAWrC,IAAIJ,KAAK4C,GAAG,CAAC,GAAGxC,IAAI,KAAKhC;AACxD"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/GridLayout/Row.tsx"],"sourcesContent":["// Copyright 2025 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 { Collapse, useTheme } from '@mui/material';\nimport { PanelGroupId, PanelGroupDefinition, PanelGroupItemLayout } from '@perses-dev/core';\nimport { PanelOptions, useViewPanelGroup } from '@perses-dev/dashboards';\nimport { ReactElement, useEffect, useMemo, useState } from 'react';\nimport { Layout, Layouts, Responsive, WidthProvider } from 'react-grid-layout';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { GRID_LAYOUT_COLS, GRID_LAYOUT_SMALL_BREAKPOINT } from '../../constants';\nimport { GridContainer } from './GridContainer';\nimport { GridItemContent } from './GridItemContent';\nimport { GridTitle } from './GridTitle';\n\nconst DEFAULT_MARGIN = 10;\nconst ROW_HEIGHT = 30;\n\nexport interface RowProps {\n panelGroupId: PanelGroupId;\n groupDefinition: PanelGroupDefinition;\n gridColWidth: number;\n panelFullHeight?: number;\n panelOptions?: PanelOptions;\n isEditMode?: boolean;\n onLayoutChange?: (currentLayout: Layout[], allLayouts: Layouts) => void;\n onWidthChange?: (\n containerWidth: number,\n margin: [number, number],\n cols: number,\n containerPadding: [number, number]\n ) => void;\n repeatVariable?: [string, string];\n}\n\nexport function Row({\n panelGroupId,\n groupDefinition,\n gridColWidth,\n panelFullHeight,\n panelOptions,\n isEditMode = false,\n onLayoutChange,\n onWidthChange,\n repeatVariable,\n}: RowProps): ReactElement {\n const ResponsiveGridLayout = useMemo(() => WidthProvider(Responsive), []);\n const theme = useTheme();\n const viewPanelItemId = useViewPanelGroup();\n\n const [isOpen, setIsOpen] = useState(!groupDefinition.isCollapsed);\n\n const hasViewPanel =\n viewPanelItemId?.panelGroupId === panelGroupId &&\n // Check for repeatVariable panels\n viewPanelItemId.repeatVariable?.[0] === repeatVariable?.[0] &&\n viewPanelItemId.repeatVariable?.[1] === repeatVariable?.[1];\n const itemLayoutViewed = viewPanelItemId?.panelGroupItemLayoutId;\n\n // If there is a panel in view mode, we should hide the grid if the panel is not in the current group.\n const isGridDisplayed = !viewPanelItemId || hasViewPanel;\n\n // TODO: handle it without useEffect\n useEffect(() => {\n if (hasViewPanel) {\n setIsOpen(true);\n }\n }, [hasViewPanel]);\n\n // Item layout is override if there is a panel in view mode\n const itemLayouts: PanelGroupItemLayout[] = useMemo(() => {\n if (itemLayoutViewed) {\n return groupDefinition.itemLayouts.map((itemLayout) => {\n if (itemLayout.i === itemLayoutViewed) {\n const rowTitleHeight = 40 + 8; // 40 is the height of the row title and 8 is the margin height\n return {\n h: Math.round(((panelFullHeight ?? window.innerHeight) - rowTitleHeight) / (ROW_HEIGHT + DEFAULT_MARGIN)), // Viewed panel should take the full height remaining\n i: itemLayoutViewed,\n w: 48,\n x: 0,\n y: 0,\n } as PanelGroupItemLayout;\n }\n return itemLayout;\n });\n }\n return groupDefinition.itemLayouts;\n }, [groupDefinition.itemLayouts, itemLayoutViewed, panelFullHeight]);\n\n return (\n <GridContainer\n sx={{\n display: isGridDisplayed ? 'block' : 'none',\n height: itemLayoutViewed ? `${panelFullHeight}px` : 'unset',\n overflow: itemLayoutViewed ? 'hidden' : 'unset',\n }}\n >\n {groupDefinition.title && (\n <GridTitle\n panelGroupId={panelGroupId}\n title={groupDefinition.title}\n collapse={\n groupDefinition.isCollapsed === undefined\n ? undefined\n : { isOpen: isOpen, onToggleOpen: () => setIsOpen((current) => !current) }\n }\n />\n )}\n <Collapse in={isOpen} unmountOnExit appear={false} data-testid=\"panel-group-content\">\n <ResponsiveGridLayout\n className=\"layout\"\n breakpoints={{ [GRID_LAYOUT_SMALL_BREAKPOINT]: theme.breakpoints.values.sm, xxs: 0 }}\n cols={GRID_LAYOUT_COLS}\n rowHeight={ROW_HEIGHT}\n draggableHandle=\".drag-handle\"\n resizeHandles={['se']}\n isDraggable={isEditMode && !hasViewPanel}\n isResizable={isEditMode && !hasViewPanel}\n margin={[DEFAULT_MARGIN, DEFAULT_MARGIN]}\n containerPadding={[0, 10]}\n layouts={{ sm: itemLayouts }}\n onLayoutChange={onLayoutChange}\n onWidthChange={onWidthChange}\n allowOverlap={hasViewPanel} // Enabling overlap when viewing a specific panel because panel in front of the viewed panel will add empty spaces (empty row height)\n >\n {itemLayouts.map(({ i, w }) => (\n <div\n key={i}\n style={{\n display: itemLayoutViewed ? (itemLayoutViewed === i ? 'unset' : 'none') : 'unset',\n }}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <GridItemContent\n panelOptions={panelOptions}\n panelGroupItemId={{ panelGroupId, panelGroupItemLayoutId: i, repeatVariable }}\n width={calculateGridItemWidth(w, gridColWidth)}\n />\n </ErrorBoundary>\n </div>\n ))}\n </ResponsiveGridLayout>\n </Collapse>\n </GridContainer>\n );\n}\n\nconst calculateGridItemWidth = (w: number, colWidth: number): number => {\n // 0 * Infinity === NaN, which causes problems with resize contraints\n if (!Number.isFinite(w)) return w;\n return Math.round(colWidth * w + Math.max(0, w - 1) * DEFAULT_MARGIN);\n};\n"],"names":["Collapse","useTheme","useViewPanelGroup","useEffect","useMemo","useState","Responsive","WidthProvider","ErrorAlert","ErrorBoundary","GRID_LAYOUT_COLS","GRID_LAYOUT_SMALL_BREAKPOINT","GridContainer","GridItemContent","GridTitle","DEFAULT_MARGIN","ROW_HEIGHT","Row","panelGroupId","groupDefinition","gridColWidth","panelFullHeight","panelOptions","isEditMode","onLayoutChange","onWidthChange","repeatVariable","ResponsiveGridLayout","theme","viewPanelItemId","isOpen","setIsOpen","isCollapsed","hasViewPanel","itemLayoutViewed","panelGroupItemLayoutId","isGridDisplayed","itemLayouts","map","itemLayout","i","rowTitleHeight","h","Math","round","window","innerHeight","w","x","y","sx","display","height","overflow","title","collapse","undefined","onToggleOpen","current","in","unmountOnExit","appear","data-testid","className","breakpoints","values","sm","xxs","cols","rowHeight","draggableHandle","resizeHandles","isDraggable","isResizable","margin","containerPadding","layouts","allowOverlap","div","style","FallbackComponent","panelGroupItemId","width","calculateGridItemWidth","colWidth","Number","isFinite","max"],"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,QAAQ,EAAEC,QAAQ,Q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,SAAS;wBAAEV,IAAI7B;oBAAY;oBAC3Bb,gBAAgBA;oBAChBC,eAAeA;oBACfoD,cAAc5C;8BAEbI,YAAYC,GAAG,CAAC,CAAC,EAAEE,CAAC,EAAEO,CAAC,EAAE,iBACxB,KAAC+B;4BAECC,OAAO;gCACL5B,SAASjB,mBAAoBA,qBAAqBM,IAAI,UAAU,SAAU;4BAC5E;sCAEA,cAAA,KAAC/B;gCAAcuE,mBAAmBxE;0CAChC,cAAA,KAACK;oCACCS,cAAcA;oCACd2D,kBAAkB;wCAAE/D;wCAAciB,wBAAwBK;wCAAGd;oCAAe;oCAC5EwD,OAAOC,uBAAuBpC,GAAG3B;;;2BAThCoB;;;;;AAkBnB;AAEA,MAAM2C,yBAAyB,CAACpC,GAAWqC;IACzC,qEAAqE;IACrE,IAAI,CAACC,OAAOC,QAAQ,CAACvC,IAAI,OAAOA;IAChC,OAAOJ,KAAKC,KAAK,CAACwC,WAAWrC,IAAIJ,KAAK4C,GAAG,CAAC,GAAGxC,IAAI,KAAKhC;AACxD"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { DashboardResource, EphemeralDashboardResource } from '@perses-dev/core';
|
|
2
2
|
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import type { BlockerFunction } from '@remix-run/router';
|
|
3
4
|
export interface LeaveDialogProps {
|
|
4
|
-
isBlocked: boolean;
|
|
5
|
+
isBlocked: BlockerFunction | boolean;
|
|
5
6
|
message: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function Prompt({ isBlocked, message }: LeaveDialogProps): ReactElement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeaveDialog.d.ts","sourceRoot":"","sources":["../../../src/components/LeaveDialog/LeaveDialog.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LeaveDialog.d.ts","sourceRoot":"","sources":["../../../src/components/LeaveDialog/LeaveDialog.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAQzD,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAMD,wBAAgB,MAAM,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,gBAAgB,GAAG,YAAY,CA4B7E;AAKD,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,iBAAiB,GAAG,0BAA0B,GAAG,SAAS,CAAC;IACrE,OAAO,EAAE,iBAAiB,GAAG,0BAA0B,CAAC;CACzD,GAAG,SAAS,CAYZ"}
|
|
@@ -52,8 +52,17 @@ const handleRouteChange = (event)=>{
|
|
|
52
52
|
/*
|
|
53
53
|
* LeaveDialog prompts the user with a confirmation dialog when they attempt to leave the page with unsaved changes.
|
|
54
54
|
*/ export function LeaveDialog({ original, current }) {
|
|
55
|
+
const handleIsBlocked = (ctx)=>{
|
|
56
|
+
if (JSON.stringify(original) !== JSON.stringify(current)) {
|
|
57
|
+
// Only block navigation if the pathname is changing (=> ignore search params changes)
|
|
58
|
+
if (ctx.currentLocation.pathname !== ctx.nextLocation.pathname) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
};
|
|
55
64
|
return /*#__PURE__*/ _jsx(Prompt, {
|
|
56
|
-
isBlocked:
|
|
65
|
+
isBlocked: handleIsBlocked,
|
|
57
66
|
message: "You have unsaved changes, are you sure you want to leave?"
|
|
58
67
|
});
|
|
59
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/LeaveDialog/LeaveDialog.tsx"],"sourcesContent":["// Copyright 2025 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 } from '@perses-dev/core';\nimport { ReactElement, ReactNode, useEffect } from 'react';\nimport { useBlocker } from 'react-router-dom';\nimport { DiscardChangesConfirmationDialog } from '@perses-dev/components';\n\nconst handleRouteChange = (event: BeforeUnloadEvent): string => {\n event.preventDefault();\n event.returnValue = ''; // Required for Chrome\n return ''; // Required for other browsers\n};\n\nexport interface LeaveDialogProps {\n isBlocked: boolean;\n message: string;\n}\n\n/*\n * Prompt component uses the useBlocker hook to block react-router navigation when there are unsaved changes.\n * It also listens to the beforeunload event to show a browser confirmation dialog when the user tries to close the tab, refresh the page or change url manually.\n */\nexport function Prompt({ isBlocked, message }: LeaveDialogProps): ReactElement {\n const blocker = useBlocker(isBlocked);\n const isBlockedState = blocker.state === 'blocked';\n const isProceedingState = blocker.state === 'proceeding';\n\n useEffect(() => {\n if (isBlocked) {\n window.addEventListener('beforeunload', handleRouteChange);\n } else {\n window.removeEventListener('beforeunload', handleRouteChange);\n }\n\n return (): void => {\n window.removeEventListener('beforeunload', handleRouteChange);\n };\n }, [blocker, isBlocked, isBlockedState]);\n\n const handleDiscardChanges = (): void => blocker.proceed?.();\n const handleCancel = (): void => blocker.reset?.();\n\n return (\n <DiscardChangesConfirmationDialog\n description={message}\n isOpen={isBlockedState || isProceedingState}\n onDiscardChanges={handleDiscardChanges}\n onCancel={handleCancel}\n />\n );\n}\n\n/*\n * LeaveDialog prompts the user with a confirmation dialog when they attempt to leave the page with unsaved changes.\n */\nexport function LeaveDialog({\n original,\n current,\n}: {\n original: DashboardResource | EphemeralDashboardResource | undefined;\n current: DashboardResource | EphemeralDashboardResource;\n}): ReactNode {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/LeaveDialog/LeaveDialog.tsx"],"sourcesContent":["// Copyright 2025 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 } from '@perses-dev/core';\nimport { ReactElement, ReactNode, useEffect } from 'react';\nimport { useBlocker } from 'react-router-dom';\nimport { DiscardChangesConfirmationDialog } from '@perses-dev/components';\nimport type { BlockerFunction } from '@remix-run/router';\n\nconst handleRouteChange = (event: BeforeUnloadEvent): string => {\n event.preventDefault();\n event.returnValue = ''; // Required for Chrome\n return ''; // Required for other browsers\n};\n\nexport interface LeaveDialogProps {\n isBlocked: BlockerFunction | boolean;\n message: string;\n}\n\n/*\n * Prompt component uses the useBlocker hook to block react-router navigation when there are unsaved changes.\n * It also listens to the beforeunload event to show a browser confirmation dialog when the user tries to close the tab, refresh the page or change url manually.\n */\nexport function Prompt({ isBlocked, message }: LeaveDialogProps): ReactElement {\n const blocker = useBlocker(isBlocked);\n const isBlockedState = blocker.state === 'blocked';\n const isProceedingState = blocker.state === 'proceeding';\n\n useEffect(() => {\n if (isBlocked) {\n window.addEventListener('beforeunload', handleRouteChange);\n } else {\n window.removeEventListener('beforeunload', handleRouteChange);\n }\n\n return (): void => {\n window.removeEventListener('beforeunload', handleRouteChange);\n };\n }, [blocker, isBlocked, isBlockedState]);\n\n const handleDiscardChanges = (): void => blocker.proceed?.();\n const handleCancel = (): void => blocker.reset?.();\n\n return (\n <DiscardChangesConfirmationDialog\n description={message}\n isOpen={isBlockedState || isProceedingState}\n onDiscardChanges={handleDiscardChanges}\n onCancel={handleCancel}\n />\n );\n}\n\n/*\n * LeaveDialog prompts the user with a confirmation dialog when they attempt to leave the page with unsaved changes.\n */\nexport function LeaveDialog({\n original,\n current,\n}: {\n original: DashboardResource | EphemeralDashboardResource | undefined;\n current: DashboardResource | EphemeralDashboardResource;\n}): ReactNode {\n const handleIsBlocked: BlockerFunction = (ctx) => {\n if (JSON.stringify(original) !== JSON.stringify(current)) {\n // Only block navigation if the pathname is changing (=> ignore search params changes)\n if (ctx.currentLocation.pathname !== ctx.nextLocation.pathname) {\n return true;\n }\n }\n return false;\n };\n\n return <Prompt isBlocked={handleIsBlocked} message=\"You have unsaved changes, are you sure you want to leave?\" />;\n}\n"],"names":["useEffect","useBlocker","DiscardChangesConfirmationDialog","handleRouteChange","event","preventDefault","returnValue","Prompt","isBlocked","message","blocker","isBlockedState","state","isProceedingState","window","addEventListener","removeEventListener","handleDiscardChanges","proceed","handleCancel","reset","description","isOpen","onDiscardChanges","onCancel","LeaveDialog","original","current","handleIsBlocked","ctx","JSON","stringify","currentLocation","pathname","nextLocation"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAAkCA,SAAS,QAAQ,QAAQ;AAC3D,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,gCAAgC,QAAQ,yBAAyB;AAG1E,MAAMC,oBAAoB,CAACC;IACzBA,MAAMC,cAAc;IACpBD,MAAME,WAAW,GAAG,IAAI,sBAAsB;IAC9C,OAAO,IAAI,8BAA8B;AAC3C;AAOA;;;CAGC,GACD,OAAO,SAASC,OAAO,EAAEC,SAAS,EAAEC,OAAO,EAAoB;IAC7D,MAAMC,UAAUT,WAAWO;IAC3B,MAAMG,iBAAiBD,QAAQE,KAAK,KAAK;IACzC,MAAMC,oBAAoBH,QAAQE,KAAK,KAAK;IAE5CZ,UAAU;QACR,IAAIQ,WAAW;YACbM,OAAOC,gBAAgB,CAAC,gBAAgBZ;QAC1C,OAAO;YACLW,OAAOE,mBAAmB,CAAC,gBAAgBb;QAC7C;QAEA,OAAO;YACLW,OAAOE,mBAAmB,CAAC,gBAAgBb;QAC7C;IACF,GAAG;QAACO;QAASF;QAAWG;KAAe;IAEvC,MAAMM,uBAAuB,IAAYP,QAAQQ,OAAO;IACxD,MAAMC,eAAe,IAAYT,QAAQU,KAAK;IAE9C,qBACE,KAAClB;QACCmB,aAAaZ;QACba,QAAQX,kBAAkBE;QAC1BU,kBAAkBN;QAClBO,UAAUL;;AAGhB;AAEA;;CAEC,GACD,OAAO,SAASM,YAAY,EAC1BC,QAAQ,EACRC,OAAO,EAIR;IACC,MAAMC,kBAAmC,CAACC;QACxC,IAAIC,KAAKC,SAAS,CAACL,cAAcI,KAAKC,SAAS,CAACJ,UAAU;YACxD,sFAAsF;YACtF,IAAIE,IAAIG,eAAe,CAACC,QAAQ,KAAKJ,IAAIK,YAAY,CAACD,QAAQ,EAAE;gBAC9D,OAAO;YACT;QACF;QACA,OAAO;IACT;IAEA,qBAAO,KAAC1B;QAAOC,WAAWoB;QAAiBnB,SAAQ;;AACrD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CardProps } from '@mui/material';
|
|
2
|
-
import { PanelDefinition } from '@perses-dev/core';
|
|
2
|
+
import { PanelDefinition, PanelGroupItemId } from '@perses-dev/core';
|
|
3
3
|
import { ReactNode } from 'react';
|
|
4
|
-
import { PanelGroupItemId } from '../../context';
|
|
5
4
|
import { PanelHeaderProps } from './PanelHeader';
|
|
6
5
|
export interface PanelProps extends CardProps<'section'> {
|
|
7
6
|
definition: PanelDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,SAAS,EAAsC,MAAM,OAAO,CAAC;AAGtE,OAAO,EAAe,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE9D,MAAM,WAAW,UAAW,SAAQ,SAAS,CAAC,SAAS,CAAC;IACtD,UAAU,EAAE,eAAe,CAAC;IAC5B,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,gBAAgB,CAAC,cAAc,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,kBAAkB,CAAC,EAAE,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;CAC7D;AAED,MAAM,MAAM,YAAY,GAAG;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,SAAS,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,kDAuMhB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2025 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Card, CardContent } from '@mui/material';
|
|
15
|
-
import { ErrorAlert, ErrorBoundary, combineSx,
|
|
15
|
+
import { ErrorAlert, ErrorBoundary, combineSx, useId } from '@perses-dev/components';
|
|
16
16
|
import { useDataQueriesContext, usePluginRegistry } from '@perses-dev/plugin-system';
|
|
17
17
|
import { memo, useMemo, useState, useEffect } from 'react';
|
|
18
18
|
import useResizeObserver from 'use-resize-observer';
|
|
@@ -44,7 +44,6 @@ import { PanelHeader } from './PanelHeader';
|
|
|
44
44
|
width,
|
|
45
45
|
height
|
|
46
46
|
]);
|
|
47
|
-
const chartsTheme = useChartsTheme();
|
|
48
47
|
const { queryResults } = useDataQueriesContext();
|
|
49
48
|
const { getPlugin } = usePluginRegistry();
|
|
50
49
|
const panelPropsForActions = useMemo(()=>{
|
|
@@ -171,7 +170,9 @@ import { PanelHeader } from './PanelHeader';
|
|
|
171
170
|
pluginActions: pluginActions,
|
|
172
171
|
showIcons: showIcons,
|
|
173
172
|
sx: {
|
|
174
|
-
|
|
173
|
+
py: '2px',
|
|
174
|
+
pl: '8px',
|
|
175
|
+
pr: '2px'
|
|
175
176
|
},
|
|
176
177
|
dimension: contentDimensions
|
|
177
178
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Panel/Panel.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 { Card, CardContent, CardProps } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary, combineSx, useChartsTheme, useId } from '@perses-dev/components';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { useDataQueriesContext, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { ReactNode, memo, useMemo, useState, useEffect } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { PanelGroupItemId } from '../../context';\nimport { PanelContent } from './PanelContent';\nimport { PanelHeader, PanelHeaderProps } from './PanelHeader';\n\nexport interface PanelProps extends CardProps<'section'> {\n definition: PanelDefinition;\n readHandlers?: PanelHeaderProps['readHandlers'];\n editHandlers?: PanelHeaderProps['editHandlers'];\n panelOptions?: PanelOptions;\n panelGroupItemId?: PanelGroupItemId;\n viewQueriesHandler?: PanelHeaderProps['viewQueriesHandler'];\n}\n\nexport type PanelOptions = {\n /**\n * Allow you to hide the panel header if desired.\n * This can be useful in embedded mode for example.\n */\n hideHeader?: boolean;\n /**\n * Whether to show panel icons always, or only when hovering over the panel.\n * Default: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'\n */\n showIcons?: 'always' | 'hover';\n /**\n * Content to render in right of the panel header. (top right of the panel)\n * It will only be rendered when the panel is in edit mode.\n */\n extra?: (props: PanelExtraProps) => ReactNode;\n};\n\nexport type PanelExtraProps = {\n /**\n * The PanelDefinition for the panel.\n */\n panelDefinition?: PanelDefinition;\n /**\n * The PanelGroupItemId for the panel.\n */\n panelGroupItemId?: PanelGroupItemId;\n};\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n *\n * Internal structure:\n * <Panel> // renders an entire panel, incl. header and action buttons\n * <PanelContent> // renders loading, error or panel based on the queries' status\n * <PanelPluginLoader> // loads a panel plugin from the plugin registry and renders the PanelComponent with data from props.queryResults\n */\nexport const Panel = memo(function Panel(props: PanelProps) {\n const {\n definition,\n readHandlers,\n editHandlers,\n onMouseEnter,\n onMouseLeave,\n sx,\n panelOptions,\n panelGroupItemId,\n viewQueriesHandler,\n ...others\n } = props;\n\n // Make sure we have an ID we can use for aria attributes\n const generatedPanelId = useId('Panel');\n const headerId = `${generatedPanelId}-header`;\n\n const [contentElement, setContentElement] = useState<HTMLElement | null>(null);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const chartsTheme = useChartsTheme();\n\n const { queryResults } = useDataQueriesContext();\n const { getPlugin } = usePluginRegistry();\n\n const panelPropsForActions = useMemo(() => {\n return {\n spec: definition.spec.plugin.spec,\n queryResults: queryResults.map((query) => ({\n definition: query.definition,\n data: query.data,\n })),\n contentDimensions,\n definition,\n };\n }, [definition, contentDimensions, queryResults]);\n\n // Load plugin actions from the plugin\n const [pluginActions, setPluginActions] = useState<ReactNode[]>([]);\n\n useEffect(() => {\n let cancelled = false;\n\n const loadPluginActions = async (): Promise<void> => {\n const panelPluginKind = definition.spec.plugin.kind;\n const panelProps = panelPropsForActions;\n\n if (!panelPluginKind || !panelProps) {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n try {\n // Add defensive check for getPlugin availability\n if (!getPlugin || typeof getPlugin !== 'function') {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n const plugin = await getPlugin('Panel', panelPluginKind);\n\n if (cancelled) return;\n\n // More defensive checking for plugin and actions\n if (\n !plugin ||\n typeof plugin !== 'object' ||\n !plugin.actions ||\n !Array.isArray(plugin.actions) ||\n plugin.actions.length === 0\n ) {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n // Render plugin actions in header location\n const headerActions = plugin.actions\n .filter((action) => !action.location || action.location === 'header')\n .map((action, index): ReactNode | null => {\n const ActionComponent = action.component;\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return <ActionComponent key={`plugin-action-${index}`} {...(panelProps as any)} />;\n } catch (error) {\n console.warn(`Failed to render plugin action ${index}:`, error);\n return null;\n }\n })\n .filter((item): item is ReactNode => Boolean(item));\n\n if (!cancelled) {\n setPluginActions(headerActions);\n }\n } catch (error) {\n if (!cancelled) {\n console.warn('Failed to load plugin actions:', error);\n setPluginActions([]);\n }\n }\n };\n\n // Use setTimeout to defer the async operation to the next tick\n const timeoutId = setTimeout(() => {\n loadPluginActions();\n }, 0);\n\n return (): void => {\n cancelled = true;\n clearTimeout(timeoutId);\n };\n }, [definition.spec.plugin.kind, panelPropsForActions, getPlugin]);\n\n const handleMouseEnter: CardProps['onMouseEnter'] = (e) => {\n onMouseEnter?.(e);\n };\n\n const handleMouseLeave: CardProps['onMouseLeave'] = (e) => {\n onMouseLeave?.(e);\n };\n\n // default value for showIcons: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'\n const showIcons = panelOptions?.showIcons ?? (editHandlers || readHandlers?.isPanelViewed ? 'always' : 'hover');\n\n return (\n <Card\n component=\"section\"\n sx={combineSx(\n {\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n ':hover': { '--panel-hover': 'block' },\n },\n sx\n )}\n variant=\"outlined\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-labelledby={headerId}\n aria-describedby={headerId}\n data-testid=\"panel\"\n {...others}\n >\n {!panelOptions?.hideHeader && (\n <PanelHeader\n extra={panelOptions?.extra?.({ panelDefinition: definition, panelGroupItemId })}\n id={headerId}\n title={definition.spec.display.name}\n description={definition.spec.display.description}\n queryResults={queryResults}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n links={definition.spec.links}\n pluginActions={pluginActions}\n showIcons={showIcons}\n sx={{ paddingX: `${chartsTheme.container.padding.default}px` }}\n dimension={contentDimensions}\n />\n )}\n <CardContent\n component=\"figure\"\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n margin: 0,\n padding: 0,\n // Override MUI default style for last-child\n ':last-child': {\n padding: 0,\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert} resetKeys={[definition.spec, queryResults]}>\n <PanelContent\n definition={definition}\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n queryResults={queryResults}\n />\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n});\n"],"names":["Card","CardContent","ErrorAlert","ErrorBoundary","combineSx","useChartsTheme","useId","useDataQueriesContext","usePluginRegistry","memo","useMemo","useState","useEffect","useResizeObserver","PanelContent","PanelHeader","Panel","props","definition","readHandlers","editHandlers","onMouseEnter","onMouseLeave","sx","panelOptions","panelGroupItemId","viewQueriesHandler","others","generatedPanelId","headerId","contentElement","setContentElement","width","height","ref","contentDimensions","undefined","chartsTheme","queryResults","getPlugin","panelPropsForActions","spec","plugin","map","query","data","pluginActions","setPluginActions","cancelled","loadPluginActions","panelPluginKind","kind","panelProps","actions","Array","isArray","length","headerActions","filter","action","location","index","ActionComponent","component","error","console","warn","item","Boolean","timeoutId","setTimeout","clearTimeout","handleMouseEnter","e","handleMouseLeave","showIcons","isPanelViewed","display","flexFlow","variant","aria-labelledby","aria-describedby","data-testid","hideHeader","extra","panelDefinition","id","title","name","description","links","paddingX","container","padding","default","dimension","position","overflow","flexGrow","margin","FallbackComponent","resetKeys"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC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BACdnB,cAAcA;gBACdC,cAAcA;gBACdM,oBAAoBA;gBACpBgE,OAAOxE,WAAWuB,IAAI,CAACiD,KAAK;gBAC5B5C,eAAeA;gBACf6B,WAAWA;gBACXpD,IAAI;oBAAEoE,UAAU,GAAGtD,YAAYuD,SAAS,CAACC,OAAO,CAACC,OAAO,CAAC,EAAE,CAAC;gBAAC;gBAC7DC,WAAW5D;;0BAGf,KAAClC;gBACC8D,WAAU;gBACVxC,IAAI;oBACFyE,UAAU;oBACVC,UAAU;oBACVC,UAAU;oBACVC,QAAQ;oBACRN,SAAS;oBACT,4CAA4C;oBAC5C,eAAe;wBACbA,SAAS;oBACX;gBACF;gBACA3D,KAAKH;0BAEL,cAAA,KAAC5B;oBAAciG,mBAAmBlG;oBAAYmG,WAAW;wBAACnF,WAAWuB,IAAI;wBAAEH;qBAAa;8BACtF,cAAA,KAACxB;wBACCI,YAAYA;wBACZgC,iBAAiBhC,WAAWuB,IAAI,CAACC,MAAM,CAACS,IAAI;wBAC5CV,MAAMvB,WAAWuB,IAAI,CAACC,MAAM,CAACD,IAAI;wBACjCN,mBAAmBA;wBACnBG,cAAcA;;;;;;AAM1B,GAAG"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Panel/Panel.tsx"],"sourcesContent":["// Copyright 2025 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 { Card, CardContent, CardProps } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary, combineSx, useId } from '@perses-dev/components';\nimport { PanelDefinition, PanelGroupItemId } from '@perses-dev/core';\nimport { useDataQueriesContext, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { ReactNode, memo, useMemo, useState, useEffect } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { PanelContent } from './PanelContent';\nimport { PanelHeader, PanelHeaderProps } from './PanelHeader';\n\nexport interface PanelProps extends CardProps<'section'> {\n definition: PanelDefinition;\n readHandlers?: PanelHeaderProps['readHandlers'];\n editHandlers?: PanelHeaderProps['editHandlers'];\n panelOptions?: PanelOptions;\n panelGroupItemId?: PanelGroupItemId;\n viewQueriesHandler?: PanelHeaderProps['viewQueriesHandler'];\n}\n\nexport type PanelOptions = {\n /**\n * Allow you to hide the panel header if desired.\n * This can be useful in embedded mode for example.\n */\n hideHeader?: boolean;\n /**\n * Whether to show panel icons always, or only when hovering over the panel.\n * Default: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'\n */\n showIcons?: 'always' | 'hover';\n /**\n * Content to render in right of the panel header. (top right of the panel)\n * It will only be rendered when the panel is in edit mode.\n */\n extra?: (props: PanelExtraProps) => ReactNode;\n};\n\nexport type PanelExtraProps = {\n /**\n * The PanelDefinition for the panel.\n */\n panelDefinition?: PanelDefinition;\n /**\n * The PanelGroupItemId for the panel.\n */\n panelGroupItemId?: PanelGroupItemId;\n};\n\n/**\n * Renders a PanelDefinition's content inside of a Card.\n *\n * Internal structure:\n * <Panel> // renders an entire panel, incl. header and action buttons\n * <PanelContent> // renders loading, error or panel based on the queries' status\n * <PanelPluginLoader> // loads a panel plugin from the plugin registry and renders the PanelComponent with data from props.queryResults\n */\nexport const Panel = memo(function Panel(props: PanelProps) {\n const {\n definition,\n readHandlers,\n editHandlers,\n onMouseEnter,\n onMouseLeave,\n sx,\n panelOptions,\n panelGroupItemId,\n viewQueriesHandler,\n ...others\n } = props;\n\n // Make sure we have an ID we can use for aria attributes\n const generatedPanelId = useId('Panel');\n const headerId = `${generatedPanelId}-header`;\n\n const [contentElement, setContentElement] = useState<HTMLElement | null>(null);\n\n const { width, height } = useResizeObserver({ ref: contentElement });\n\n const contentDimensions = useMemo(() => {\n if (width === undefined || height === undefined) return undefined;\n return { width, height };\n }, [width, height]);\n\n const { queryResults } = useDataQueriesContext();\n const { getPlugin } = usePluginRegistry();\n\n const panelPropsForActions = useMemo(() => {\n return {\n spec: definition.spec.plugin.spec,\n queryResults: queryResults.map((query) => ({\n definition: query.definition,\n data: query.data,\n })),\n contentDimensions,\n definition,\n };\n }, [definition, contentDimensions, queryResults]);\n\n // Load plugin actions from the plugin\n const [pluginActions, setPluginActions] = useState<ReactNode[]>([]);\n\n useEffect(() => {\n let cancelled = false;\n\n const loadPluginActions = async (): Promise<void> => {\n const panelPluginKind = definition.spec.plugin.kind;\n const panelProps = panelPropsForActions;\n\n if (!panelPluginKind || !panelProps) {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n try {\n // Add defensive check for getPlugin availability\n if (!getPlugin || typeof getPlugin !== 'function') {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n const plugin = await getPlugin('Panel', panelPluginKind);\n\n if (cancelled) return;\n\n // More defensive checking for plugin and actions\n if (\n !plugin ||\n typeof plugin !== 'object' ||\n !plugin.actions ||\n !Array.isArray(plugin.actions) ||\n plugin.actions.length === 0\n ) {\n if (!cancelled) {\n setPluginActions([]);\n }\n return;\n }\n\n // Render plugin actions in header location\n const headerActions = plugin.actions\n .filter((action) => !action.location || action.location === 'header')\n .map((action, index): ReactNode | null => {\n const ActionComponent = action.component;\n try {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return <ActionComponent key={`plugin-action-${index}`} {...(panelProps as any)} />;\n } catch (error) {\n console.warn(`Failed to render plugin action ${index}:`, error);\n return null;\n }\n })\n .filter((item): item is ReactNode => Boolean(item));\n\n if (!cancelled) {\n setPluginActions(headerActions);\n }\n } catch (error) {\n if (!cancelled) {\n console.warn('Failed to load plugin actions:', error);\n setPluginActions([]);\n }\n }\n };\n\n // Use setTimeout to defer the async operation to the next tick\n const timeoutId = setTimeout(() => {\n loadPluginActions();\n }, 0);\n\n return (): void => {\n cancelled = true;\n clearTimeout(timeoutId);\n };\n }, [definition.spec.plugin.kind, panelPropsForActions, getPlugin]);\n\n const handleMouseEnter: CardProps['onMouseEnter'] = (e) => {\n onMouseEnter?.(e);\n };\n\n const handleMouseLeave: CardProps['onMouseLeave'] = (e) => {\n onMouseLeave?.(e);\n };\n\n // default value for showIcons: if the dashboard is in editing mode or the panel is in fullscreen mode: 'always', otherwise 'hover'\n const showIcons = panelOptions?.showIcons ?? (editHandlers || readHandlers?.isPanelViewed ? 'always' : 'hover');\n\n return (\n <Card\n component=\"section\"\n sx={combineSx(\n {\n width: '100%',\n height: '100%',\n display: 'flex',\n flexFlow: 'column nowrap',\n ':hover': { '--panel-hover': 'block' },\n },\n sx\n )}\n variant=\"outlined\"\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n aria-labelledby={headerId}\n aria-describedby={headerId}\n data-testid=\"panel\"\n {...others}\n >\n {!panelOptions?.hideHeader && (\n <PanelHeader\n extra={panelOptions?.extra?.({ panelDefinition: definition, panelGroupItemId })}\n id={headerId}\n title={definition.spec.display.name}\n description={definition.spec.display.description}\n queryResults={queryResults}\n readHandlers={readHandlers}\n editHandlers={editHandlers}\n viewQueriesHandler={viewQueriesHandler}\n links={definition.spec.links}\n pluginActions={pluginActions}\n showIcons={showIcons}\n sx={{ py: '2px', pl: '8px', pr: '2px' }}\n dimension={contentDimensions}\n />\n )}\n <CardContent\n component=\"figure\"\n sx={{\n position: 'relative',\n overflow: 'hidden',\n flexGrow: 1,\n margin: 0,\n padding: 0,\n // Override MUI default style for last-child\n ':last-child': {\n padding: 0,\n },\n }}\n ref={setContentElement}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert} resetKeys={[definition.spec, queryResults]}>\n <PanelContent\n definition={definition}\n panelPluginKind={definition.spec.plugin.kind}\n spec={definition.spec.plugin.spec}\n contentDimensions={contentDimensions}\n queryResults={queryResults}\n />\n </ErrorBoundary>\n </CardContent>\n </Card>\n );\n});\n"],"names":["Card","CardContent","ErrorAlert","ErrorBoundary","combineSx","useId","useDataQueriesContext","usePluginRegistry","memo","useMemo","useState","useEffect","useResizeObserver","PanelContent","PanelHeader","Panel","props","definition","readHandlers","editHandlers","onMouseEnter","onMouseLeave","sx","panelOptions","panelGroupItemId","viewQueriesHandler","others","generatedPanelId","headerId","contentElement","setContentElement","width","height","ref","contentDimensions","undefined","queryResults","getPlugin","panelPropsForActions","spec","plugin","map","query","data","pluginActions","setPluginActions","cancelled","loadPluginActions","panelPluginKind","kind","panelProps","actions","Array","isArray","length","headerActions","filter","action","location","index","ActionComponent","component","error","console","warn","item","Boolean","timeoutId","setTimeout","clearTimeout","handleMouseEnter","e","handleMouseLeave","showIcons","isPanelViewed","display","flexFlow","variant","aria-labelledby","aria-describedby","data-testid","hideHeader","extra","panelDefinition","id","title","name","description","links","py","pl","pr","dimension","position","overflow","flexGrow","margin","padding","FallbackComponent","resetKeys"],"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,IAAI,EAAEC,WAAW,QAAmB,gBAAgB;AAC7D,SAASC,UAAU,EAAEC,aAAa,EAAEC,SAAS,EAAEC,KAAK,QAAQ,yBAAyB;AAErF,SAASC,qBAAqB,EAAEC,iBAAiB,QAAQ,4BAA4B;AACrF,SAAoBC,IAAI,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,SAAS,QAAQ,QAAQ;AACtE,OAAOC,uBAAuB,sBAAsB;AACpD,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,WAAW,QAA0B,gBAAgB;AAwC9D;;;;;;;CAOC,GACD,OAAO,MAAMC,sBAAQP,KAAK,SAASO,MAAMC,KAAiB;IACxD,MAAM,EACJC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,YAA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AI,CAACC,MAAM,CAACS,IAAI;wBAC5CV,MAAMtB,WAAWsB,IAAI,CAACC,MAAM,CAACD,IAAI;wBACjCL,mBAAmBA;wBACnBE,cAAcA;;;;;;AAM1B,GAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelHeader.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,eAAe,EAA8B,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAA+B,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"PanelHeader.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/PanelHeader.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,eAAe,EAA8B,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,SAAS,EAA+B,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,SAAS,EAAU,MAAM,OAAO,CAAC;AAExD,OAAO,EAAgB,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,KAAK,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAE1E,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC;IAC3E,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,YAAY,EAAE,SAAS,EAAE,CAAC;IAC1B,kBAAkB,CAAC,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IAC7D,YAAY,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACjD,YAAY,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;IACjD,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC;IAC5B,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CAC/B;AAED,wBAAgB,WAAW,CAAC,EAC1B,EAAE,EACF,KAAK,EAAE,QAAQ,EACf,WAAW,EAAE,cAAc,EAC3B,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,EAAE,EACF,KAAK,EACL,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,GAAG,IAAI,EACR,EAAE,gBAAgB,GAAG,YAAY,CAqEjC"}
|
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import { CardHeader, Stack, Typography, Tooltip } from '@mui/material';
|
|
15
15
|
import { combineSx } from '@perses-dev/components';
|
|
16
16
|
import { useReplaceVariablesInString } from '@perses-dev/plugin-system';
|
|
17
|
-
import {
|
|
17
|
+
import { useRef } from 'react';
|
|
18
18
|
import { HEADER_ACTIONS_CONTAINER_NAME } from '../../constants';
|
|
19
19
|
import { PanelActions } from './PanelActions';
|
|
20
20
|
export function PanelHeader({ id, title: rawTitle, description: rawDescription, links, queryResults, readHandlers, editHandlers, sx, extra, pluginActions, showIcons, viewQueriesHandler, dimension, ...rest }) {
|
|
@@ -23,15 +23,7 @@ export function PanelHeader({ id, title: rawTitle, description: rawDescription,
|
|
|
23
23
|
const title = useReplaceVariablesInString(rawTitle);
|
|
24
24
|
const description = useReplaceVariablesInString(rawDescription);
|
|
25
25
|
const textRef = useRef(null);
|
|
26
|
-
const
|
|
27
|
-
useEffect(()=>{
|
|
28
|
-
if (textRef.current && dimension?.width) {
|
|
29
|
-
setIsEllipsisActive(textRef.current.scrollWidth > textRef.current.clientWidth);
|
|
30
|
-
}
|
|
31
|
-
}, [
|
|
32
|
-
title,
|
|
33
|
-
dimension?.width
|
|
34
|
-
]);
|
|
26
|
+
const isEllipsisActive = textRef.current && dimension?.width ? textRef.current.scrollWidth > textRef.current.clientWidth : false;
|
|
35
27
|
return /*#__PURE__*/ _jsx(CardHeader, {
|
|
36
28
|
id: id,
|
|
37
29
|
component: "header",
|