|
@@ -15,10 +15,7 @@ import zip from 'lodash/zip';
|
|
|
|
|
|
import {validateWidget} from 'sentry/actionCreators/dashboards';
|
|
|
import {addErrorMessage} from 'sentry/actionCreators/indicator';
|
|
|
-import {
|
|
|
- openAddDashboardWidgetModal,
|
|
|
- openDashboardWidgetLibraryModal,
|
|
|
-} from 'sentry/actionCreators/modal';
|
|
|
+import {openAddDashboardWidgetModal} from 'sentry/actionCreators/modal';
|
|
|
import {loadOrganizationTags} from 'sentry/actionCreators/tags';
|
|
|
import {Client} from 'sentry/api';
|
|
|
import space from 'sentry/styles/space';
|
|
@@ -69,6 +66,7 @@ type Props = {
|
|
|
onUpdate: (widgets: Widget[]) => void;
|
|
|
onSetWidgetToBeUpdated: (widget: Widget) => void;
|
|
|
handleAddLibraryWidgets: (widgets: Widget[]) => void;
|
|
|
+ handleAddCustomWidget: (widget: Widget) => void;
|
|
|
layout: Layout[];
|
|
|
onLayoutChange: (layout: Layout[]) => void;
|
|
|
paramDashboardId?: string;
|
|
@@ -132,11 +130,11 @@ class Dashboard extends Component<Props, State> {
|
|
|
}
|
|
|
|
|
|
async addNewWidget() {
|
|
|
- const {api, organization, newWidget} = this.props;
|
|
|
+ const {api, organization, newWidget, handleAddCustomWidget} = this.props;
|
|
|
if (newWidget) {
|
|
|
try {
|
|
|
await validateWidget(api, organization.slug, newWidget);
|
|
|
- this.handleAddComplete(newWidget);
|
|
|
+ handleAddCustomWidget(newWidget);
|
|
|
} catch (error) {
|
|
|
// Don't do anything, widget isn't valid
|
|
|
addErrorMessage(error);
|
|
@@ -150,7 +148,13 @@ class Dashboard extends Component<Props, State> {
|
|
|
}
|
|
|
|
|
|
handleStartAdd = () => {
|
|
|
- const {organization, dashboard, selection, handleAddLibraryWidgets} = this.props;
|
|
|
+ const {
|
|
|
+ organization,
|
|
|
+ dashboard,
|
|
|
+ selection,
|
|
|
+ handleAddLibraryWidgets,
|
|
|
+ handleAddCustomWidget,
|
|
|
+ } = this.props;
|
|
|
trackAdvancedAnalyticsEvent('dashboards_views.add_widget_modal.opened', {
|
|
|
organization,
|
|
|
});
|
|
@@ -159,10 +163,13 @@ class Dashboard extends Component<Props, State> {
|
|
|
trackAdvancedAnalyticsEvent('dashboards_views.widget_library.opened', {
|
|
|
organization,
|
|
|
});
|
|
|
- openDashboardWidgetLibraryModal({
|
|
|
+ openAddDashboardWidgetModal({
|
|
|
organization,
|
|
|
dashboard,
|
|
|
- onAddWidget: (widgets: Widget[]) => handleAddLibraryWidgets(widgets),
|
|
|
+ selection,
|
|
|
+ onAddWidget: handleAddCustomWidget,
|
|
|
+ onAddLibraryWidget: (widgets: Widget[]) => handleAddLibraryWidgets(widgets),
|
|
|
+ source: DashboardWidgetSource.LIBRARY,
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
@@ -170,7 +177,7 @@ class Dashboard extends Component<Props, State> {
|
|
|
organization,
|
|
|
dashboard,
|
|
|
selection,
|
|
|
- onAddWidget: this.handleAddComplete,
|
|
|
+ onAddWidget: handleAddCustomWidget,
|
|
|
source: DashboardWidgetSource.DASHBOARDS,
|
|
|
});
|
|
|
};
|
|
@@ -196,14 +203,6 @@ class Dashboard extends Component<Props, State> {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
- handleAddComplete = (widget: Widget) => {
|
|
|
- let newWidget = widget;
|
|
|
- if (this.props.organization.features.includes('dashboard-grid-layout')) {
|
|
|
- newWidget = assignTempId(widget);
|
|
|
- }
|
|
|
- this.props.onUpdate([...this.props.dashboard.widgets, newWidget]);
|
|
|
- };
|
|
|
-
|
|
|
handleUpdateComplete = (prevWidget: Widget) => (nextWidget: Widget) => {
|
|
|
const nextList = [...this.props.dashboard.widgets];
|
|
|
const updateIndex = nextList.indexOf(prevWidget);
|
|
@@ -248,6 +247,7 @@ class Dashboard extends Component<Props, State> {
|
|
|
location,
|
|
|
paramDashboardId,
|
|
|
onSetWidgetToBeUpdated,
|
|
|
+ handleAddCustomWidget,
|
|
|
} = this.props;
|
|
|
|
|
|
if (organization.features.includes('metrics')) {
|
|
@@ -279,7 +279,7 @@ class Dashboard extends Component<Props, State> {
|
|
|
organization,
|
|
|
widget,
|
|
|
selection,
|
|
|
- onAddWidget: this.handleAddComplete,
|
|
|
+ onAddWidget: handleAddCustomWidget,
|
|
|
onUpdateWidget: this.handleUpdateComplete(widget),
|
|
|
};
|
|
|
openAddDashboardWidgetModal({
|