import {Fragment, PureComponent} from 'react';
import type {InjectedRouter} from 'react-router';
import {useTheme} from '@emotion/react';
import styled from '@emotion/styled';
import {FocusScope} from '@react-aria/focus';
import {AnimatePresence} from 'framer-motion';
import type {Location} from 'history';
import isEqual from 'lodash/isEqual';
import type {Client} from 'sentry/api';
import Feature from 'sentry/components/acl/feature';
import FeatureDisabled from 'sentry/components/acl/featureDisabled';
import GuideAnchor from 'sentry/components/assistant/guideAnchor';
import Banner from 'sentry/components/banner';
import {Button} from 'sentry/components/button';
import ButtonBar from 'sentry/components/buttonBar';
import {CreateAlertFromViewButton} from 'sentry/components/createAlertButton';
import type {MenuItemProps} from 'sentry/components/dropdownMenu';
import {DropdownMenu} from 'sentry/components/dropdownMenu';
import {Hovercard} from 'sentry/components/hovercard';
import InputControl from 'sentry/components/input';
import {Overlay, PositionWrapper} from 'sentry/components/overlay';
import {IconBookmark, IconDelete, IconEllipsis, IconStar} from 'sentry/icons';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {Organization, Project, SavedQuery} from 'sentry/types';
import {trackAnalytics} from 'sentry/utils/analytics';
import {browserHistory} from 'sentry/utils/browserHistory';
import EventView from 'sentry/utils/discover/eventView';
import {getDiscoverQueriesUrl} from 'sentry/utils/discover/urls';
import useOverlay from 'sentry/utils/useOverlay';
import withApi from 'sentry/utils/withApi';
import {normalizeUrl} from 'sentry/utils/withDomainRequired';
import withProjects from 'sentry/utils/withProjects';
import {handleAddQueryToDashboard} from 'sentry/views/discover/utils';
import {DEFAULT_EVENT_VIEW} from '../data';
import {
handleCreateQuery,
handleDeleteQuery,
handleResetHomepageQuery,
handleUpdateHomepageQuery,
handleUpdateQuery,
} from './utils';
const renderDisabled = p => (
}
>
{p.children(p)}
);
type SaveAsDropdownProps = {
disabled: boolean;
modifiedHandleCreateQuery: (e: React.MouseEvent) => void;
onChangeInput: (e: React.FormEvent) => void;
queryName: string;
};
function SaveAsDropdown({
queryName,
disabled,
onChangeInput,
modifiedHandleCreateQuery,
}: SaveAsDropdownProps) {
const {isOpen, triggerProps, overlayProps, arrowProps} = useOverlay();
const theme = useTheme();
return (