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, LinkButton} 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, SavedQuery} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {defined} from 'sentry/utils';
import {trackAnalytics} from 'sentry/utils/analytics';
import {browserHistory} from 'sentry/utils/browserHistory';
import EventView from 'sentry/utils/discover/eventView';
import {DiscoverDatasets} from 'sentry/utils/discover/types';
import {getDiscoverQueriesUrl} from 'sentry/utils/discover/urls';
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
import useOverlay from 'sentry/utils/useOverlay';
import withApi from 'sentry/utils/withApi';
import withProjects from 'sentry/utils/withProjects';
import {hasDatasetSelector} from 'sentry/views/dashboards/utils';
import {handleAddQueryToDashboard} from 'sentry/views/discover/utils';
import {DEFAULT_EVENT_VIEW} from '../data';
import {
getDatasetFromLocationOrSavedQueryDataset,
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 (