diff --git a/frontend/app/components/Dashboard/components/AddToDashboardButton.tsx b/frontend/app/components/Dashboard/components/AddToDashboardButton.tsx index 054576024..509c66426 100644 --- a/frontend/app/components/Dashboard/components/AddToDashboardButton.tsx +++ b/frontend/app/components/Dashboard/components/AddToDashboardButton.tsx @@ -1,64 +1,67 @@ +// Components/Dashboard/components/AddToDashboardButton.tsx + import React from 'react'; -import {Grid2x2Check} from "lucide-react" -import {Button, Modal} from "antd"; -import Select from "Shared/Select/Select"; -import {Form} from "UI"; -import {useStore} from "App/mstore"; +import { Grid2x2Check } from 'lucide-react'; +import { Button, Modal } from 'antd'; +import Select from 'Shared/Select/Select'; +import { Form } from 'UI'; +import { useStore } from 'App/mstore'; interface Props { - metricId: string; + metricId: string; } -function AddToDashboardButton({metricId}: Props) { - const {dashboardStore} = useStore(); - const dashboardOptions = dashboardStore.dashboards.map((i: any) => ({ - key: i.id, - label: i.name, - value: i.dashboardId, - })); - const [selectedId, setSelectedId] = React.useState(dashboardOptions[0]?.value); +export const showAddToDashboardModal = (metricId: string, dashboardStore: any) => { + const dashboardOptions = dashboardStore.dashboards.map((i: any) => ({ + key: i.id, + label: i.name, + value: i.dashboardId, + })); + let selectedId = dashboardOptions[0]?.value; - const onSave = (close: any) => { - const dashboard = dashboardStore.getDashboard(selectedId) - if (dashboard) { - dashboardStore.addWidgetToDashboard(dashboard, [metricId]).then(close) - } + const onSave = (close: any) => { + const dashboard = dashboardStore.getDashboard(selectedId); + if (dashboard) { + dashboardStore.addWidgetToDashboard(dashboard, [metricId]).then(close); } + }; - const onClick = () => { - Modal.confirm({ - title: 'Add to selected dashboard', - icon: null, - content: ( -