diff --git a/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx b/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx index 3a9ff8696..fa977ed94 100644 --- a/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx +++ b/frontend/app/components/Dashboard/components/DashboardList/DashboardList.tsx @@ -7,56 +7,64 @@ import { sliceListPerPage } from 'App/utils'; import DashboardListItem from './DashboardListItem'; function DashboardList() { - const { dashboardStore } = useStore(); - const [shownDashboards, setDashboards] = React.useState([]); - const dashboards = dashboardStore.dashboards; - const dashboardsSearch = dashboardStore.dashboardsSearch; + const { dashboardStore } = useStore(); + const [shownDashboards, setDashboards] = React.useState([]); + const dashboards = dashboardStore.dashboards; + const dashboardsSearch = dashboardStore.dashboardsSearch; - React.useEffect(() => { - setDashboards(filterList(dashboards, dashboardsSearch, ['name', 'owner', 'description'])) - }, [dashboardsSearch]) - - const list = dashboardsSearch !== '' ? shownDashboards : dashboards; - const lenth = list.length; + React.useEffect(() => { + setDashboards(filterList(dashboards, dashboardsSearch, ['name', 'owner', 'description'])); + }, [dashboardsSearch]); - return ( - - -
You haven't created any dashboards yet
- - } - > -
-
-
Title
-
Visibility
-
Created
-
+ const list = dashboardsSearch !== '' ? shownDashboards : dashboards; + const lenth = list.length; - {sliceListPerPage(list, dashboardStore.page - 1, dashboardStore.pageSize).map((dashboard: any) => ( - - - - ))} -
+ return ( + + +
+ {dashboardsSearch !== '' + ? 'No matching results' + : "You haven't created any dashboards yet"} +
+ + } + > +
+
+
Title
+
Visibility
+
Created
+
-
-
- Showing {Math.min(list.length, dashboardStore.pageSize)} out of {list.length} Dashboards -
- dashboardStore.updateKey('page', page)} - limit={dashboardStore.pageSize} - debounceRequest={100} - /> -
- - ); + {sliceListPerPage(list, dashboardStore.page - 1, dashboardStore.pageSize).map( + (dashboard: any) => ( + + + + ) + )} +
+ +
+
+ Showing{' '} + {Math.min(list.length, dashboardStore.pageSize)}{' '} + out of {list.length} Dashboards +
+ dashboardStore.updateKey('page', page)} + limit={dashboardStore.pageSize} + debounceRequest={100} + /> +
+
+ ); } export default observer(DashboardList); diff --git a/frontend/app/components/Dashboard/components/MetricsList/MetricsList.tsx b/frontend/app/components/Dashboard/components/MetricsList/MetricsList.tsx index 0833c3557..ef6f8320f 100644 --- a/frontend/app/components/Dashboard/components/MetricsList/MetricsList.tsx +++ b/frontend/app/components/Dashboard/components/MetricsList/MetricsList.tsx @@ -8,62 +8,67 @@ import { sliceListPerPage } from 'App/utils'; import { IWidget } from 'App/mstore/types/widget'; function MetricsList({ siteId }: { siteId: string }) { - const { metricStore } = useStore(); - const metrics = useObserver(() => metricStore.metrics); - const metricsSearch = useObserver(() => metricStore.metricsSearch); + const { metricStore } = useStore(); + const metrics = useObserver(() => metricStore.metrics); + const metricsSearch = useObserver(() => metricStore.metricsSearch); - const filterByDashboard = (item: IWidget, searchRE: RegExp) => { - const dashboardsStr = item.dashboards.map((d: any) => d.name).join(' ') - return searchRE.test(dashboardsStr) - } - const list = metricsSearch !== '' - ? filterList(metrics, metricsSearch, ['name', 'metricType', 'owner'], filterByDashboard) - : metrics; - const lenth = list.length; + const filterByDashboard = (item: IWidget, searchRE: RegExp) => { + const dashboardsStr = item.dashboards.map((d: any) => d.name).join(' '); + return searchRE.test(dashboardsStr); + }; + const list = + metricsSearch !== '' + ? filterList(metrics, metricsSearch, ['name', 'metricType', 'owner'], filterByDashboard) + : metrics; + const lenth = list.length; - useEffect(() => { - metricStore.updateKey('sessionsPage', 1); - }, []) + useEffect(() => { + metricStore.updateKey('sessionsPage', 1); + }, []); - return useObserver(() => ( - - -
You haven't created any metrics yet
- - } - > -
-
-
Title
-
Owner
-
Visibility
-
Last Modified
-
+ return useObserver(() => ( + + +
+ {metricsSearch !== '' ? 'No matching results' : "You haven't created any metrics yet"} +
+
+ } + > +
+
+
Title
+
Owner
+
Visibility
+
Last Modified
+
- {sliceListPerPage(list, metricStore.page - 1, metricStore.pageSize).map((metric: any) => ( - - - - ))} -
+ {sliceListPerPage(list, metricStore.page - 1, metricStore.pageSize).map((metric: any) => ( + + + + ))} + -
-
- Showing {Math.min(list.length, metricStore.pageSize)} out of {list.length} metrics -
- metricStore.updateKey('page', page)} - limit={metricStore.pageSize} - debounceRequest={100} - /> -
-
- )); +
+
+ Showing{' '} + {Math.min(list.length, metricStore.pageSize)} out + of {list.length} metrics +
+ metricStore.updateKey('page', page)} + limit={metricStore.pageSize} + debounceRequest={100} + /> +
+
+ )); } export default MetricsList;