|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
import {useTheme} from '@emotion/react';
|
|
import {useTheme} from '@emotion/react';
|
|
import styled from '@emotion/styled';
|
|
import styled from '@emotion/styled';
|
|
|
|
|
|
-import {openModal} from 'sentry/actionCreators/modal';
|
|
|
|
|
|
+import {openWidgetBuilderOverwriteModal} from 'sentry/actionCreators/modal';
|
|
import {OverwriteWidgetModalProps} from 'sentry/components/modals/widgetBuilder/overwriteWidgetModal';
|
|
import {OverwriteWidgetModalProps} from 'sentry/components/modals/widgetBuilder/overwriteWidgetModal';
|
|
import {t} from 'sentry/locale';
|
|
import {t} from 'sentry/locale';
|
|
import space from 'sentry/styles/space';
|
|
import space from 'sentry/styles/space';
|
|
@@ -14,23 +14,23 @@ import {
|
|
import {Card} from './card';
|
|
import {Card} from './card';
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
|
+ bypassOverwriteModal: boolean;
|
|
onWidgetSelect: (widget: WidgetTemplate) => void;
|
|
onWidgetSelect: (widget: WidgetTemplate) => void;
|
|
};
|
|
};
|
|
|
|
|
|
-export async function openWidgetBuilderOverwriteModal(
|
|
|
|
- options: OverwriteWidgetModalProps
|
|
|
|
-) {
|
|
|
|
- const mod = await import('sentry/components/modals/widgetBuilder/overwriteWidgetModal');
|
|
|
|
- const {default: Modal, modalCss} = mod;
|
|
|
|
-
|
|
|
|
- openModal(deps => <Modal {...deps} {...options} />, {backdrop: 'static', modalCss});
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-export function WidgetLibrary({onWidgetSelect}: Props) {
|
|
|
|
|
|
+export function WidgetLibrary({bypassOverwriteModal, onWidgetSelect}: Props) {
|
|
const theme = useTheme();
|
|
const theme = useTheme();
|
|
|
|
|
|
- function getLibrarySelectionHandler(widget, iconColor) {
|
|
|
|
|
|
+ function getLibrarySelectionHandler(
|
|
|
|
+ widget: OverwriteWidgetModalProps['widget'],
|
|
|
|
+ iconColor: OverwriteWidgetModalProps['iconColor']
|
|
|
|
+ ) {
|
|
return function handleWidgetSelect() {
|
|
return function handleWidgetSelect() {
|
|
|
|
+ if (bypassOverwriteModal) {
|
|
|
|
+ onWidgetSelect(widget);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
openWidgetBuilderOverwriteModal({
|
|
openWidgetBuilderOverwriteModal({
|
|
onConfirm: () => onWidgetSelect(widget),
|
|
onConfirm: () => onWidgetSelect(widget),
|
|
widget,
|
|
widget,
|