openreplay/frontend/app/components/Dashboard/components/WidgetPreview/WidgetPreview.tsx
Sudheer Salavadi 1b3a3dfc21
Product analytics refinements (#3002)
* Various UX, UI and Functional Improvements in  Dashboards & Cards

- Depth filter of Sankey chart data in frontend
- Dashboard & Cards empty state view updates
- Disabled save image feature on cards

* Fixed empty views and headers

* Various improvements across dashboards and cards.
2025-02-04 09:49:49 +01:00

55 lines
1.8 KiB
TypeScript

import cn from 'classnames';
import { observer } from 'mobx-react-lite';
import React from 'react';
import WidgetDateRange from "Components/Dashboard/components/WidgetDateRange/WidgetDateRange";
import { useStore } from 'App/mstore';
import { FUNNEL, TIMESERIES } from "App/constants/card";
import WidgetWrapper from '../WidgetWrapper';
import WidgetOptions from 'Components/Dashboard/components/WidgetOptions';
interface Props {
className?: string;
name: string;
isEditing?: boolean;
}
function WidgetPreview(props: Props) {
const { className = '' } = props;
const { metricStore } = useStore();
const metric: any = metricStore.instance;
const hasGranularSettings = [TIMESERIES, FUNNEL].includes(metric.metricType)
const hasGranularity = ['lineChart', 'barChart', 'areaChart'].includes(metric.viewType);
const hasComparison = metric.metricType === FUNNEL || ['lineChart', 'barChart', 'table', 'progressChart', 'metric'].includes(metric.viewType);
// [rangeStart, rangeEnd] or [period_name] -- have to check options
const presetComparison = metric.compareTo;
return (
<>
<div
className={cn(className, 'bg-white rounded-xl border shadow-sm mt-0')}
>
<div className="flex items-center gap-2 px-4 py-2 border-b justify-between flex-wrap">
<WidgetDateRange
label=""
hasGranularSettings={hasGranularSettings}
hasGranularity={hasGranularity}
hasComparison={hasComparison}
presetComparison={presetComparison}
/>
<WidgetOptions />
</div>
<div className="py-4">
<WidgetWrapper
widget={metric}
isPreview={true}
isWidget={false}
hideName
/>
</div>
</div>
</>
);
}
export default observer(WidgetPreview);