diff --git a/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx b/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx
index 5cd30cbda..d3c231ffc 100644
--- a/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx
+++ b/frontend/app/components/Dashboard/components/AddCardSection/AddCardSection.tsx
@@ -207,72 +207,74 @@ function CategoryTab({ tab, inCards }: { tab: string; 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' },
- { label: 'Monitors', value: 'monitors' },
- { label: 'Web Analytics', value: 'web_analytics' },
- ];
+const AddCardSection = observer(
+ ({ inCards, fit }: { fit?: boolean; 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' },
+ { label: 'Monitors', value: 'monitors' },
+ { label: 'Web Analytics', value: 'web_analytics' },
+ ];
- const originStr = window.env.ORIGIN || window.location.origin;
- 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 ? (
-
- ) : null}
-
-
- setTab(value)}
- />
-
-
+ const originStr = window.env.ORIGIN || window.location.origin;
+ 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 existing card
+
+
Add a card to dashboard
+ {isSaas ? (
+
+ ) : null}
+
+
+ setTab(value)}
+ />
+
+
+
+
+
+ Add existing card
+
-
- );
-});
+ );
+ }
+);
export default AddCardSection;
diff --git a/frontend/app/components/Dashboard/components/CreateDashboardButton.tsx b/frontend/app/components/Dashboard/components/CreateDashboardButton.tsx
index d5731517d..d768449d9 100644
--- a/frontend/app/components/Dashboard/components/CreateDashboardButton.tsx
+++ b/frontend/app/components/Dashboard/components/CreateDashboardButton.tsx
@@ -1,25 +1,45 @@
-import React from "react";
-import {PlusOutlined} from "@ant-design/icons";
-import NewDashboardModal from "Components/Dashboard/components/DashboardList/NewDashModal";
-import {Button} from "antd";
+import React from 'react';
+import { PlusOutlined } from '@ant-design/icons';
+import { Button } from 'antd';
+import { useStore } from 'App/mstore';
+import { useHistory } from 'react-router-dom';
interface Props {
- disabled?: boolean;
+ disabled?: boolean;
}
-function CreateDashboardButton({disabled = false}: Props) {
- const [showModal, setShowModal] = React.useState(false);
+function CreateDashboardButton({ disabled }: Props) {
+ const [dashboardCreating, setDashboardCreating] = React.useState(false);
+ const { projectsStore, dashboardStore } = useStore();
+ const siteId = projectsStore.siteId;
+ const history = useHistory();
- return <>
-
-
setShowModal(false)} open={showModal}/>
- >;
+ const createNewDashboard = async () => {
+ setDashboardCreating(true);
+ dashboardStore.initDashboard();
+ await dashboardStore
+ .save(dashboardStore.dashboardInstance)
+ .then(async (syncedDashboard) => {
+ dashboardStore.selectDashboardById(syncedDashboard.dashboardId);
+ history.push(`/${siteId}/dashboard/${syncedDashboard.dashboardId}`);
+ })
+ .finally(() => {
+ setDashboardCreating(false);
+ });
+ };
+ return (
+ <>
+ }
+ disabled={disabled}
+ type="primary"
+ onClick={createNewDashboard}
+ >
+ Create Dashboard
+
+ >
+ );
}
export default CreateDashboardButton;
diff --git a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx
index 03b3b84fc..3e6a9f3d2 100644
--- a/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx
+++ b/frontend/app/components/Dashboard/components/DashboardList/NewDashModal/ExampleCards.tsx
@@ -107,7 +107,7 @@ export const CARD_LIST: CardType[] = [
example: ExamplePath
},
{
- title: 'Sessions Trend',
+ title: 'Trend',
key: TIMESERIES,
cardType: TIMESERIES,
metricOf: 'sessionCount',
diff --git a/frontend/app/components/Dashboard/components/MetricViewHeader/MetricViewHeader.tsx b/frontend/app/components/Dashboard/components/MetricViewHeader/MetricViewHeader.tsx
index a19cc8f91..3ab7b683f 100644
--- a/frontend/app/components/Dashboard/components/MetricViewHeader/MetricViewHeader.tsx
+++ b/frontend/app/components/Dashboard/components/MetricViewHeader/MetricViewHeader.tsx
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react';
import { PageTitle, Icon } from 'UI';
-import { Segmented, Button } from 'antd';
+import { Segmented, Button, Popover } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import AddCardSection from '../AddCardSection/AddCardSection';
import MetricsSearch from '../MetricsSearch';
@@ -8,7 +8,6 @@ import Select from 'Shared/Select';
import { useStore } from 'App/mstore';
import { observer, useObserver } from 'mobx-react-lite';
import { DROPDOWN_OPTIONS } from 'App/constants/card';
-import { INDEXES } from "App/constants/zindex";
function MetricViewHeader() {
const { metricStore } = useStore();
@@ -28,13 +27,15 @@ function MetricViewHeader() {
-
+
} trigger={'click'}>
+
+
@@ -78,23 +79,6 @@ function MetricViewHeader() {
}
/> */}
-
- {showAddCardModal ? (
- {
- if (modalBgRef.current === e.target) {
- setShowAddCardModal(false);
- }
- }}
- className={
- 'fixed top-0 left-0 w-screen h-screen flex items-center justify-center bg-gray-lightest'
- }
- style={{ background: 'rgba(0,0,0,0.5)', zIndex: INDEXES.POPUP_GUIDE_BG }}
- >
-
-
- ) : null}
);