diff --git a/web/src/controllers/DashboardController/DashboardController.tsx b/web/src/controllers/DashboardController/DashboardController.tsx
index 92922ced2..334c35955 100644
--- a/web/src/controllers/DashboardController/DashboardController.tsx
+++ b/web/src/controllers/DashboardController/DashboardController.tsx
@@ -8,7 +8,6 @@ import { useGetDashboard } from '@/api/buster_rest/dashboards';
import { useDashboardContentStore } from '@/context/Dashboards';
import { AddToDashboardModal } from '@/components/features/modal/AddToDashboardModal';
import { canEdit } from '@/lib/share';
-import { useWhyDidYouUpdate } from '@/hooks';
export const DashboardController: React.FC<{ dashboardId: string }> = ({ dashboardId }) => {
const { isFetched: isFetchedDashboard, data: permission } = useGetDashboard(
@@ -16,7 +15,6 @@ export const DashboardController: React.FC<{ dashboardId: string }> = ({ dashboa
(x) => x.permission
);
const selectedFileView = useChatLayoutContextSelector((x) => x.selectedFileView) || 'dashboard';
- const { openAddContentModal, onCloseAddContentModal } = useDashboardContentStore();
const isEditor = canEdit(permission);
const Component =
@@ -29,13 +27,20 @@ export const DashboardController: React.FC<{ dashboardId: string }> = ({ dashboa
{!isFetchedDashboard && }
- {isEditor && (
-
- )}
+ {isEditor && }
>
);
};
+
+const MemoizedAddToDashboardModal = React.memo(({ dashboardId }: { dashboardId: string }) => {
+ const { openAddContentModal, onCloseAddContentModal } = useDashboardContentStore();
+ return (
+
+ );
+});
+
+MemoizedAddToDashboardModal.displayName = 'MemoizedAddToDashboardModal';
diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardContainerHeaderButtons.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardContainerHeaderButtons.tsx
index af7681b54..dff119fcf 100644
--- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardContainerHeaderButtons.tsx
+++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/DashboardContainerHeaderButtons/DashboardContainerHeaderButtons.tsx
@@ -13,6 +13,7 @@ import { DashboardThreeDotMenu } from './DashboardThreeDotMenu';
import { AppTooltip } from '@/components/ui/tooltip';
import { useGetDashboard } from '@/api/buster_rest/dashboards';
import { canEdit } from '@/lib/share';
+import { useDashboardContentStore } from '@/context/Dashboards';
export const DashboardContainerHeaderButtons: React.FC = React.memo(
() => {
@@ -44,6 +45,7 @@ SaveToCollectionButton.displayName = 'SaveToCollectionButton';
const AddContentToDashboardButton = React.memo(({ dashboardId }: { dashboardId: string }) => {
const { data: permission } = useGetDashboard(dashboardId, (x) => x.permission);
const isEditor = canEdit(permission);
+ const onOpenAddContentModal = useDashboardContentStore((x) => x.onOpenAddContentModal);
if (!isEditor) {
return null;
@@ -51,7 +53,7 @@ const AddContentToDashboardButton = React.memo(({ dashboardId }: { dashboardId:
return (
- } />
+ } onClick={onOpenAddContentModal} />
);
});
diff --git a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx
index 8ad6bfbf0..0dc49ea27 100644
--- a/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx
+++ b/web/src/layouts/ChatLayout/FileContainer/FileContainerHeader/MetricContainerHeaderButtons/MetricThreeDotMenu.tsx
@@ -164,7 +164,7 @@ const useDashboardSelectMenu = ({ metricId }: { metricId: string }) => {
const dashboardDropdownItem: DropdownItem = useMemo(
() => ({
- label: 'Add content',
+ label: 'Add to dashboard',
value: 'add-to-dashboard',
icon: ,
items: [{dashboardSubMenu}]