diff --git a/frontend/app/components/Dashboard/components/MetricTypeList/MetricTypeList.tsx b/frontend/app/components/Dashboard/components/MetricTypeList/MetricTypeList.tsx index 8e64d970d..e53d6e7a2 100644 --- a/frontend/app/components/Dashboard/components/MetricTypeList/MetricTypeList.tsx +++ b/frontend/app/components/Dashboard/components/MetricTypeList/MetricTypeList.tsx @@ -5,6 +5,7 @@ import MetricTypeItem, { MetricType } from '../MetricTypeItem/MetricTypeItem'; import { TYPES, LIBRARY } from 'App/constants/card'; import { withRouter, RouteComponentProps } from 'react-router-dom'; import { dashboardMetricCreate, metricCreate, withSiteId } from 'App/routes'; +import { useStore } from 'App/mstore'; interface Props extends RouteComponentProps { dashboardId: number; @@ -12,13 +13,16 @@ interface Props extends RouteComponentProps { } function MetricTypeList(props: Props) { const { dashboardId, siteId, history } = props; + const { metricStore } = useStore(); const { hideModal } = useModal(); const { showModal } = useModal(); const onClick = ({ slug }: MetricType) => { hideModal(); if (slug === LIBRARY) { - return showModal(, { right: true, width: 800 }); + return showModal(, { right: true, width: 800, onClose: () => { + metricStore.updateKey('metricsSearch', '') + } }); } // TODO redirect to card builder with metricType query param diff --git a/frontend/app/components/Dashboard/components/MetricsLibraryModal/MetricsLibraryModal.tsx b/frontend/app/components/Dashboard/components/MetricsLibraryModal/MetricsLibraryModal.tsx index 5755211c1..5227b7171 100644 --- a/frontend/app/components/Dashboard/components/MetricsLibraryModal/MetricsLibraryModal.tsx +++ b/frontend/app/components/Dashboard/components/MetricsLibraryModal/MetricsLibraryModal.tsx @@ -1,7 +1,7 @@ import Modal from 'App/components/Modal/Modal'; import React, { useEffect, useMemo, useState } from 'react'; import MetricsList from '../MetricsList'; -import { Button } from 'UI'; +import { Button, Icon } from 'UI'; import { useModal } from 'App/components/Modal'; import { useStore } from 'App/mstore'; import { observer, useObserver } from 'mobx-react-lite'; @@ -23,9 +23,22 @@ function MetricsLibraryModal(props: Props) { setSelectedList(list); }; + const onChange = ({ target: { value } }: any) => { + metricStore.updateKey('metricsSearch', value) + }; + return ( <> - + +
+
+
Cards Library
+
+
+ +
+
+
@@ -40,6 +53,20 @@ function MetricsLibraryModal(props: Props) { export default observer(MetricsLibraryModal); +function MetricSearch({ onChange }: any) { + return ( +
+ + +
+ ); +} + function SelectedContent({ dashboardId, selected }: any) { const { hideModal } = useModal(); const { metricStore, dashboardStore } = useStore(); diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx index 3b8779c2c..7cc3cee08 100644 --- a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx +++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx @@ -37,7 +37,7 @@ function WidgetChart(props: Props) { const drillDownFilter = dashboardStore.drillDownFilter; const colors = Styles.customMetricColors; const [loading, setLoading] = useState(true) - const isOverviewWidget = metric.metricType === 'predefined' && metric.viewType === 'overview'; + const isOverviewWidget = metric.metricType === WEB_VITALS; const params = { density: isOverviewWidget ? 7 : 70 } const metricParams = { ...params } const prevMetricRef = useRef(); diff --git a/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx b/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx index 494fc975b..35f4be01f 100644 --- a/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx +++ b/frontend/app/components/Dashboard/components/WidgetForm/WidgetForm.tsx @@ -10,7 +10,7 @@ import Select from 'Shared/Select'; import { withSiteId, dashboardMetricDetails, metricDetails } from 'App/routes'; import MetricTypeDropdown from './components/MetricTypeDropdown'; import MetricSubtypeDropdown from './components/MetricSubtypeDropdown'; -import { TIMESERIES, TABLE, CLICKMAP, FUNNEL, ERRORS } from 'App/constants/card'; +import { TIMESERIES, TABLE, CLICKMAP, FUNNEL, ERRORS, RESOURCE_MONITORING } from 'App/constants/card'; import { clickmapFilter } from 'App/types/filter/newFilter'; import { renderClickmapThumbnail } from './renderMap' @@ -41,7 +41,6 @@ function WidgetForm(props: Props) { const cannotSaveFunnel = isFunnel && (!metric.series[0] || eventsLength <= 1); const writeOption = ({ value, name }: any) => { - console.log(name, value) value = Array.isArray(value) ? value : value.value; const obj: any = { [name]: value }; @@ -69,9 +68,10 @@ function WidgetForm(props: Props) { obj['viewType'] = 'table'; } else if (value === FUNNEL) { obj['metricOf'] = 'sessionCount'; - } else if (value === ERRORS) { + } else if (value === ERRORS || value === RESOURCE_MONITORING) { obj['viewType'] = 'chart'; - } + } + if (metric.metricType === CLICKMAP && value !== CLICKMAP) { metric.series[0].filter.removeFilter(0) } diff --git a/frontend/app/components/Modal/Modal.tsx b/frontend/app/components/Modal/Modal.tsx index fb375333e..d2e8a838d 100644 --- a/frontend/app/components/Modal/Modal.tsx +++ b/frontend/app/components/Modal/Modal.tsx @@ -21,7 +21,9 @@ function Modal({ component, className = 'bg-white', props, hideModal }: Props) { document.querySelector('body').style.overflow = 'visible'; } }); - });return component ? ( + }); + + return component ? ( ReactDOM.createPortal(
{ - return ( +Modal.Header = ({ title, children }: { title?: string, children?: any }) => { + return !!children ? ( +
+ {children} +
+ ): (
{title}
@@ -47,11 +53,22 @@ Modal.Header = ({ title }: { title: string }) => { }; Modal.Content = ({ children, className = 'p-4' }: { children: any; className?: string }) => { - return
{children}
; + return ( +
+ {children} +
+ ); }; -Modal.Footer = ({ children, className = ''} : any) => { - return
{children}
; -} +Modal.Footer = ({ children, className = '' }: any) => { + return ( +
+ {children} +
+ ); +}; export default Modal; diff --git a/frontend/app/constants/card.ts b/frontend/app/constants/card.ts index 8ce72f8c8..24cddf9b3 100644 --- a/frontend/app/constants/card.ts +++ b/frontend/app/constants/card.ts @@ -146,12 +146,6 @@ export const TYPES: CardType[] = [ description: 'Find the adoption of your all features in your app.', slug: WEB_VITALS, subTypes: [ - { - title: 'Resources Count By Type', - slug: FilterKey.RESOURCES_COUNT_BY_TYPE, - description: '', - }, - { title: 'Resources Loading Time', slug: FilterKey.RESOURCES_LOADING_TIME, description: '' }, { title: 'CPU Load', slug: FilterKey.AVG_CPU, diff --git a/frontend/app/mstore/metricStore.ts b/frontend/app/mstore/metricStore.ts index 24d848d0c..df403bd5e 100644 --- a/frontend/app/mstore/metricStore.ts +++ b/frontend/app/mstore/metricStore.ts @@ -3,6 +3,7 @@ import Widget from './types/widget'; import { metricService, errorService } from 'App/services'; import { toast } from 'react-toastify'; import Error from './types/error'; +import { TIMESERIES, TABLE, CLICKMAP, FUNNEL, ERRORS, RESOURCE_MONITORING, PERFORMANCE, WEB_VITALS } from 'App/constants/card'; export default class MetricStore { isLoading: boolean = false; @@ -58,7 +59,11 @@ export default class MetricStore { } changeType(value: string) { - this.instance.update({ metricType: value}) + const obj: any = { metricType: value}; + if (value === ERRORS || value === RESOURCE_MONITORING || value === PERFORMANCE || value === WEB_VITALS) { + obj['viewType'] = 'chart'; + } + this.instance.update(obj) } reset(id: string) { diff --git a/frontend/app/mstore/types/widget.ts b/frontend/app/mstore/types/widget.ts index b7504c4c6..4f835266d 100644 --- a/frontend/app/mstore/types/widget.ts +++ b/frontend/app/mstore/types/widget.ts @@ -7,6 +7,7 @@ import { issueOptions } from 'App/constants/filterOptions'; import { FilterKey } from 'Types/filter/filterType'; import Period, { LAST_24_HOURS } from 'Types/app/period'; import { metricService } from "App/services"; +import { WEB_VITALS } from "App/constants/card"; export default class Widget { public static get ID_KEY():string { return "metricId" } @@ -134,7 +135,7 @@ export default class Widget { thumbnail: this.thumbnail, config: { ...this.config, - col: (this.metricType === 'funnel' || this.metricOf === FilterKey.ERRORS || this.metricOf === FilterKey.SESSIONS) ? 4 : 2 + col: (this.metricType === 'funnel' || this.metricOf === FilterKey.ERRORS || this.metricOf === FilterKey.SESSIONS) ? 4 : (this.metricType === WEB_VITALS ? 1 : 2) }, } } diff --git a/frontend/app/types/filter/filterType.ts b/frontend/app/types/filter/filterType.ts index 0f0f1bdc8..74dfb6e6d 100644 --- a/frontend/app/types/filter/filterType.ts +++ b/frontend/app/types/filter/filterType.ts @@ -269,7 +269,7 @@ export enum FilterKey { IMPACTED_SESSIONS_BY_SLOW_PAGES = 'impactedSessionsBySlowPages', // Resources - BREAKDOWN_OF_LOADED_RESOURCES = 'breakdownOfLoadedResources', + BREAKDOWN_OF_LOADED_RESOURCES = 'resourcesCountByType', MISSING_RESOURCES = 'missingResources', RESOURCE_TYPE_VS_RESPONSE_END = 'resourceTypeVsResponseEnd', RESOURCE_FETCH_TIME = 'resourceFetchTime',