|
@@ -25,6 +25,7 @@ import type {PageFilters} from 'sentry/types/core';
|
|
|
import type {InjectedRouter} from 'sentry/types/legacyReactRouter';
|
|
|
import type {Organization} from 'sentry/types/organization';
|
|
|
import {trackAnalytics} from 'sentry/utils/analytics';
|
|
|
+import {DatasetSource} from 'sentry/utils/discover/types';
|
|
|
import {hasCustomMetrics} from 'sentry/utils/metrics/features';
|
|
|
import theme from 'sentry/utils/theme';
|
|
|
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
|
|
@@ -91,6 +92,7 @@ type Props = {
|
|
|
widgetLegendState: WidgetLegendSelectionState;
|
|
|
widgetLimitReached: boolean;
|
|
|
handleAddMetricWidget?: (layout?: Widget['layout']) => void;
|
|
|
+ handleChangeSplitDataset?: (widget: Widget, index: number) => void;
|
|
|
isPreview?: boolean;
|
|
|
newWidget?: Widget;
|
|
|
onSetNewWidget?: () => void;
|
|
@@ -335,6 +337,29 @@ class Dashboard extends Component<Props, State> {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ handleChangeSplitDataset = (widget: Widget, index: number) => {
|
|
|
+ const {dashboard, onUpdate, isEditingDashboard, handleUpdateWidgetList} = this.props;
|
|
|
+
|
|
|
+ const widgetCopy = cloneDeep({
|
|
|
+ ...widget,
|
|
|
+ id: undefined,
|
|
|
+ });
|
|
|
+
|
|
|
+ const nextList = [...dashboard.widgets];
|
|
|
+ const nextWidgetData = {
|
|
|
+ ...widgetCopy,
|
|
|
+ widgetType: WidgetType.TRANSACTIONS,
|
|
|
+ datasetSource: DatasetSource.USER,
|
|
|
+ id: widget.id,
|
|
|
+ };
|
|
|
+ nextList[index] = nextWidgetData;
|
|
|
+
|
|
|
+ onUpdate(nextList);
|
|
|
+ if (!isEditingDashboard) {
|
|
|
+ handleUpdateWidgetList(nextList);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
handleEditWidget = (index: number) => () => {
|
|
|
const {organization, router, location, paramDashboardId} = this.props;
|
|
|
const widget = this.props.dashboard.widgets[index];
|
|
@@ -396,6 +421,7 @@ class Dashboard extends Component<Props, State> {
|
|
|
onDelete: this.handleDeleteWidget(widget),
|
|
|
onEdit: this.handleEditWidget(index),
|
|
|
onDuplicate: this.handleDuplicateWidget(widget, index),
|
|
|
+ onSetTransactionsDataset: () => this.handleChangeSplitDataset(widget, index),
|
|
|
|
|
|
isPreview,
|
|
|
|