feat(ui) - cards - add selected to the dashboard
This commit is contained in:
parent
280d80b775
commit
9c86c8f4fc
2 changed files with 9 additions and 5 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import React, { useEffect } from 'react';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { useStore } from 'App/mstore';
|
||||
import { Loader, Tooltip, Popover } from 'UI';
|
||||
import { Loader } from 'UI';
|
||||
import { withSiteId } from 'App/routes';
|
||||
import withModal from 'App/components/Modal/withModal';
|
||||
import DashboardWidgetGrid from '../DashboardWidgetGrid';
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ function MetricsLibraryModal(props: Props) {
|
|||
const [selectedList, setSelectedList] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
metricStore.updateKey('listView', true)
|
||||
}, [])
|
||||
metricStore.updateKey('listView', true);
|
||||
}, []);
|
||||
|
||||
const onSelectionChange = (list: any) => {
|
||||
setSelectedList(list);
|
||||
|
|
@ -26,7 +26,7 @@ function MetricsLibraryModal(props: Props) {
|
|||
return (
|
||||
<>
|
||||
<Modal.Header title="Cards Library" />
|
||||
<Modal.Content className='p-4 pb-20'>
|
||||
<Modal.Content className="p-4 pb-20">
|
||||
<div className="border">
|
||||
<MetricsList siteId={siteId} onSelectionChange={onSelectionChange} />
|
||||
</div>
|
||||
|
|
@ -47,7 +47,11 @@ function SelectedContent({ dashboardId, selected }: any) {
|
|||
const dashboard = useMemo(() => dashboardStore.getDashboard(dashboardId), [dashboardId]);
|
||||
|
||||
const addSelectedToDashboard = () => {
|
||||
dashboardStore.addWidgetToDashboard(dashboard, selected).then(hideModal);
|
||||
if (!dashboard || !dashboard.dashboardId) return;
|
||||
dashboardStore.addWidgetToDashboard(dashboard, selected).then(() => {
|
||||
hideModal();
|
||||
dashboardStore.fetch(dashboard.dashboardId);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue