diff --git a/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx b/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx index ef71fccc0..5cd30cbda 100644 --- a/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx +++ b/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx @@ -14,8 +14,12 @@ import { Sparkles, } from 'lucide-react'; import { Icon } from 'UI'; -import FilterSeries from "App/mstore/types/filterSeries"; -import { CARD_LIST, CardType } from "../DashboardList/NewDashModal/ExampleCards"; +import FilterSeries from 'App/mstore/types/filterSeries'; +import { useModal } from 'App/components/Modal'; +import { + CARD_LIST, + CardType, +} from '../DashboardList/NewDashModal/ExampleCards'; import { useStore } from 'App/mstore'; import { HEATMAP, @@ -24,9 +28,11 @@ import { TIMESERIES, USER_PATH, } from 'App/constants/card'; -import { useHistory } from "react-router-dom"; -import { dashboardMetricCreate, withSiteId, metricCreate } from 'App/routes' +import { useHistory } from 'react-router-dom'; +import { dashboardMetricCreate, withSiteId, metricCreate } from 'App/routes'; import { FilterKey } from 'Types/filter/filterType'; +import MetricsLibraryModal from '../MetricsLibraryModal/MetricsLibraryModal'; +import { observer } from 'mobx-react-lite'; interface TabItem { icon: React.ReactNode; @@ -49,7 +55,9 @@ const tabItems: Record = { description: 'Visualize user progression through critical steps.', }, { - icon: , + icon: ( + + ), title: 'Journeys', type: USER_PATH, description: 'Understand the paths users take through your product.', @@ -69,7 +77,9 @@ const tabItems: Record = { ], monitors: [ { - icon: , + icon: ( + + ), title: 'JS Errors', type: FilterKey.ERRORS, description: 'Monitor JS errors affecting user experience.', @@ -127,7 +137,7 @@ const tabItems: Record = { ], }; -function CategoryTab({ tab, inCards }: { tab: string, inCards?: boolean }) { +function CategoryTab({ tab, inCards }: { tab: string; inCards?: boolean }) { const items = tabItems[tab]; const { metricStore, projectsStore, dashboardStore } = useStore(); const history = useHistory(); @@ -144,11 +154,11 @@ function CategoryTab({ tab, inCards }: { tab: string, inCards?: boolean }) { if (selectedCard.filters) { cardData.series = [ new FilterSeries().fromJson({ - name: "Series 1", + name: 'Series 1', filter: { filters: selectedCard.filters, - } - }) + }, + }), ]; } @@ -165,7 +175,12 @@ function CategoryTab({ tab, inCards }: { tab: string, inCards?: boolean }) { if (inCards) { history.push(withSiteId(metricCreate(), projectsStore.activeSiteId)); } else if (dashboardStore.selectedDashboard) { - history.push(withSiteId(dashboardMetricCreate(dashboardStore.selectedDashboard.dashboardId), projectsStore.activeSiteId)); + history.push( + withSiteId( + dashboardMetricCreate(dashboardStore.selectedDashboard.dashboardId), + projectsStore.activeSiteId + ) + ); } } }; @@ -192,7 +207,9 @@ function CategoryTab({ tab, inCards }: { tab: string, inCards?: boolean }) { ); } -function AddCardSection({ inCards }: { inCards?: boolean }) { +const AddCardSection = observer(({ inCards }: { inCards?: boolean }) => { + const { showModal } = useModal(); + const { metricStore, dashboardStore, projectsStore } = useStore(); const [tab, setTab] = React.useState('product_analytics'); const options = [ { label: 'Product Analytics', value: 'product_analytics' }, @@ -201,7 +218,21 @@ function AddCardSection({ inCards }: { inCards?: boolean }) { ]; const originStr = window.env.ORIGIN || window.location.origin; - const isSaas = /api\.openreplay\.com/.test(originStr) + const isSaas = /api\.openreplay\.com/.test(originStr); + const onExistingClick = () => { + const dashboardId = dashboardStore.selectedDashboard?.dashboardId; + const siteId = projectsStore.activeSiteId; + showModal( + , + { + right: true, + width: 800, + onClose: () => { + metricStore.updateKey('metricsSearch', ''); + }, + } + ); + }; return (
Add a card to dashboard
- {isSaas ? + {isSaas ? (
Ask AI
- : null} + ) : null}
-
Add existing card
+
+ Add existing card +
); -} +}); export default AddCardSection; diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx index 0645ab3ae..f7d31c573 100644 --- a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx +++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx @@ -75,13 +75,14 @@ function WidgetChart(props: Props) { }, []); useEffect(() => { + if (!data.chart) return; const series = data.chart[0] ? Object.keys(data.chart[0]).filter( (key) => key !== 'time' && key !== 'timestamp' ) : [] if (series.length) { setEnabledRows(series) } - }, [data.chart.length]) + }, [data.chart]) const onChartClick = (event: any) => { if (event) { diff --git a/frontend/app/components/Dashboard/components/WidgetDatatable/WidgetDatatable.tsx b/frontend/app/components/Dashboard/components/WidgetDatatable/WidgetDatatable.tsx index c90c75cd7..ac6b400fb 100644 --- a/frontend/app/components/Dashboard/components/WidgetDatatable/WidgetDatatable.tsx +++ b/frontend/app/components/Dashboard/components/WidgetDatatable/WidgetDatatable.tsx @@ -51,6 +51,7 @@ function WidgetDatatable(props: Props) { (key) => key !== 'time' && key !== 'timestamp' ); React.useEffect(() => { + if (!data.chart) return; setTableProps(initTableProps); columnNames.clear(); data.chart.forEach((p: any) => { @@ -93,7 +94,7 @@ function WidgetDatatable(props: Props) { setTableProps((prev) => [...prev, ...tableCols]); setTableData(items); - }, [data.chart.length]); + }, [data.chart]); const rowSelection: TableProps['rowSelection'] = { selectedRowKeys: props.enabledRows, diff --git a/frontend/app/components/hocs/withPermissions.js b/frontend/app/components/hocs/withPermissions.js index 3bec89d9a..672901bce 100644 --- a/frontend/app/components/hocs/withPermissions.js +++ b/frontend/app/components/hocs/withPermissions.js @@ -14,8 +14,6 @@ export default (requiredPermissions, className, isReplay = false, andEd = true) requiredPermissions.some((permission) => permissions.includes(permission) ); - console.log(isEnterprise, hasPermission, userStore.account, userStore.authStore) - return !isEnterprise || hasPermission ? ( ) : (