diff --git a/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx b/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx index de42e052b..e017d9615 100644 --- a/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx +++ b/frontend/app/components/Dashboard/components/DashboardWidgetGrid/DashboardWidgetGrid.tsx @@ -1,117 +1,70 @@ import React from 'react'; -import {useStore} from 'App/mstore'; +import { useStore } from 'App/mstore'; import WidgetWrapper from '../WidgetWrapper'; -import {NoContent, Loader, Icon} from 'UI'; -import {useObserver} from 'mobx-react-lite'; +import { NoContent, Loader, Icon } from 'UI'; +import { useObserver } from 'mobx-react-lite'; import Widget from 'App/mstore/types/widget'; import MetricTypeList from '../MetricTypeList'; -import WidgetWrapperNew from "Components/Dashboard/components/WidgetWrapper/WidgetWrapperNew"; -import {Empty} from "antd"; +import WidgetWrapperNew from 'Components/Dashboard/components/WidgetWrapper/WidgetWrapperNew'; +import { Empty } from 'antd'; interface Props { - siteId: string; - dashboardId: string; - onEditHandler: () => void; - id?: string; + siteId: string; + dashboardId: string; + onEditHandler: () => void; + id?: string; } function DashboardWidgetGrid(props: Props) { - const {dashboardId, siteId} = props; - const {dashboardStore} = useStore(); - const loading = useObserver(() => dashboardStore.isLoading); - const dashboard = dashboardStore.selectedDashboard; - const list = useObserver(() => dashboard?.widgets); - const smallWidgets: Widget[] = []; - const regularWidgets: Widget[] = []; + const { dashboardId, siteId } = props; + const { dashboardStore } = useStore(); + const loading = useObserver(() => dashboardStore.isLoading); + const dashboard = dashboardStore.selectedDashboard; + const list = useObserver(() => dashboard?.widgets); - list?.forEach((item) => { - if (item.config.col === 1) { - smallWidgets.push(item); - } else { - regularWidgets.push(item); - } - }); - - const smallWidgetsLen = smallWidgets.length; - - return useObserver(() => ( - // @ts-ignore - list?.length === 0 ? : ( - - -
-
- There are no cards in this dashboard -
-
- Create a card from any of the below types or pick an existing one from your library. -
-
- {/*
*/} - {/* */} - {/*
*/} - + return useObserver(() => ( + // @ts-ignore + list?.length === 0 ? : ( + + +
+
+ There are no cards in this dashboard +
+
+ Create a card from any of the below types or pick an existing one from your library. +
+
+ + } + > +
+ { + list?.map((item: any, index: any) => ( + + + dashboard?.swapWidgetPosition(dragIndex, hoverIndex) } - > -
{smallWidgets.length > 0 ? ( - <> -
- - Web Vitals -
- - {smallWidgets && - smallWidgets.map((item: any, index: any) => ( - - - dashboard?.swapWidgetPosition(dragIndex, hoverIndex) - - } dashboardId={dashboardId} - siteId={siteId} - isWidget={true} - grid="vitals" - /> - - ))} - - - ) : null} - - {smallWidgets.length > 0 && regularWidgets.length > 0 ? ( -
- - All Cards -
- ) : null} - - {regularWidgets && - regularWidgets.map((item: any, index: any) => ( - - - dashboard?.swapWidgetPosition(dragIndex, hoverIndex) - } - dashboardId={dashboardId} - siteId={siteId} - isWidget={true} - grid="other" - /> - - ))} -
- - - ) - )); + dashboardId={dashboardId} + siteId={siteId} + isWidget={true} + grid="other" + /> +
+ )) + } +
+
+
+ ) + )); } export default DashboardWidgetGrid;