diff --git a/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx b/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx index 4ff6f7910..0fc945bec 100644 --- a/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx +++ b/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx @@ -62,6 +62,7 @@ function DashboardWidgetGrid(props: Props) { dashboardId={dashboardId} siteId={siteId} isWidget={true} + grid="vitals" /> ))} @@ -81,6 +82,7 @@ function DashboardWidgetGrid(props: Props) { dashboardId={dashboardId} siteId={siteId} isWidget={true} + grid="other" /> ))} diff --git a/frontend/app/components/Dashboard/components/WidgetWrapper/WidgetWrapper.tsx b/frontend/app/components/Dashboard/components/WidgetWrapper/WidgetWrapper.tsx index 6354af350..1de86785c 100644 --- a/frontend/app/components/Dashboard/components/WidgetWrapper/WidgetWrapper.tsx +++ b/frontend/app/components/Dashboard/components/WidgetWrapper/WidgetWrapper.tsx @@ -26,10 +26,11 @@ interface Props { onClick?: () => void; isWidget?: boolean; hideName?: boolean; + grid?: string; } function WidgetWrapper(props: Props & RouteComponentProps) { const { dashboardStore } = useStore(); - const { isWidget = false, active = false, index = 0, moveListItem = null, isPreview = false, isTemplate = false, dashboardId, siteId } = props; + const { isWidget = false, active = false, index = 0, moveListItem = null, isPreview = false, isTemplate = false, siteId, grid = "" } = props; const widget: any = props.widget; const isTimeSeries = widget.metricType === 'timeseries'; const isPredefined = widget.metricType === 'predefined'; @@ -37,7 +38,7 @@ function WidgetWrapper(props: Props & RouteComponentProps) { const [{ isDragging }, dragRef] = useDrag({ type: 'item', - item: { index }, + item: { index, grid }, collect: (monitor) => ({ isDragging: monitor.isDragging(), opacity: monitor.isDragging() ? 0.5 : 1, @@ -47,9 +48,12 @@ function WidgetWrapper(props: Props & RouteComponentProps) { const [{ isOver, canDrop }, dropRef] = useDrop({ accept: 'item', drop: (item: any) => { - if (item.index === index) return; + if (item.index === index || (item.grid !== grid)) return; moveListItem(item.index, index); }, + canDrop(item) { + return item.grid === grid + }, collect: (monitor: any) => ({ isOver: monitor.isOver(), canDrop: monitor.canDrop(), diff --git a/frontend/app/mstore/dashboardStore.ts b/frontend/app/mstore/dashboardStore.ts index 6eebcb04e..2fc6f696c 100644 --- a/frontend/app/mstore/dashboardStore.ts +++ b/frontend/app/mstore/dashboardStore.ts @@ -185,7 +185,7 @@ export default class DashboardStore { new Dashboard().fromJson(_dashboard) ); } else { - toast.success("Dashboard updated successfully"); + toast.success("Dashboard successfully updated "); this.updateDashboard( new Dashboard().fromJson(_dashboard) ); diff --git a/frontend/app/mstore/types/dashboard.ts b/frontend/app/mstore/types/dashboard.ts index ef4ae173c..125aff468 100644 --- a/frontend/app/mstore/types/dashboard.ts +++ b/frontend/app/mstore/types/dashboard.ts @@ -123,7 +123,7 @@ export default class Dashboard { dashboardService.saveWidget(this.dashboardId, widgetA), dashboardService.saveWidget(this.dashboardId, widgetB) ]).then(() => { - toast.success("Dashboard updated successfully") + toast.success("Dashboard successfully updated") resolve() }).catch(() => { toast.error("Error updating widget position")