Skip to content

Commit 08bda3d

Browse files
committed
fix lint
1 parent bf75681 commit 08bda3d

1 file changed

Lines changed: 26 additions & 16 deletions

File tree

web/src/components/dashboards/perses/useExternalPanelAddition.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from 'react';
1+
import { useEffect, useState, useCallback } from 'react';
22
import { useDispatch, useSelector } from 'react-redux';
33
import { useDashboardActions, useDashboardStore } from '@perses-dev/dashboards';
44
import { dashboardsOpened, dashboardsPersesPanelExternallyAdded } from '../../../store/actions';
@@ -20,20 +20,23 @@ export function useExternalPanelAddition({
2020
const dashboardStore = useDashboardStore();
2121
const [externallyAddedPanel, setExternallyAddedPanel] = useState(null);
2222

23-
const addPanelExternally = (panelDefinition: any): void => {
24-
// Simulate opening a panel to add the pane so that we can use it to programatically
25-
// add a panel to the dashboard from an external source (AI assistant).
26-
if (!isEditMode) {
27-
onEditButtonClick();
28-
}
29-
openAddPanel();
30-
// Wrap the panelDefinition with the groupId structure
31-
const change = {
32-
groupId: 0,
33-
panelDefinition,
34-
};
35-
setExternallyAddedPanel(change);
36-
};
23+
const addPanelExternally = useCallback(
24+
(panelDefinition: any): void => {
25+
// Simulate opening a panel to add the pane so that we can use it to programatically
26+
// add a panel to the dashboard from an external source (AI assistant).
27+
if (!isEditMode) {
28+
onEditButtonClick();
29+
}
30+
openAddPanel();
31+
// Wrap the panelDefinition with the groupId structure
32+
const change = {
33+
groupId: 0,
34+
panelDefinition,
35+
};
36+
setExternallyAddedPanel(change);
37+
},
38+
[isEditMode, onEditButtonClick, openAddPanel],
39+
);
3740

3841
useEffect(() => {
3942
// Listen for external panel addition requests
@@ -55,7 +58,14 @@ export function useExternalPanelAddition({
5558
// Clear the externally added panel after applying changes
5659
setExternallyAddedPanel(null);
5760
}
58-
}, [externallyAddedPanel, addPersesPanelExternally]);
61+
}, [
62+
dispatch,
63+
dashboardStore.panelGroupOrder,
64+
dashboardStore.panelEditor,
65+
externallyAddedPanel,
66+
addPanelExternally,
67+
addPersesPanelExternally,
68+
]);
5969

6070
// Advertise when custom dashboard is opened/closed
6171
useEffect(() => {

0 commit comments

Comments
 (0)