import styled from '@emotion/styled'; import GuideAnchor from 'sentry/components/assistant/guideAnchor'; import {DataSection} from 'sentry/components/events/styles'; import Anchor from 'sentry/components/links/anchor'; import QuestionTooltip from 'sentry/components/questionTooltip'; import {IconLink} from 'sentry/icons'; import {space} from 'sentry/styles/space'; export interface EventDataSectionProps { children: React.ReactNode; /** * The title of the section */ title: React.ReactNode; /** * Used as the `id` of the section. This powers the permalink */ type: string; /** * Actions that appear to the far right of the title */ actions?: React.ReactNode; className?: string; /** * If the section has a guide associated to it, you may specify the guide * target and it will wrap the title with a GuideAnchor */ guideTarget?: string; /** * A description shown in a QuestionTooltip */ help?: React.ReactNode; /** * If true, user is able to hover overlay without it disappearing. (nice if * you want the overlay to be interactive) */ isHelpHoverable?: boolean; /** * Should the permalink be enabled for this section? * * @default true */ showPermalink?: boolean; /** * Should the title be wrapped in a h3? */ wrapTitle?: boolean; } function scrollToSection(element: HTMLDivElement) { if (window.location.hash && element) { const [, hash] = window.location.hash.split('#'); try { const anchorElement = hash && element.querySelector('div#' + hash); if (anchorElement) { anchorElement.scrollIntoView(); } } catch { // Since we're blindly taking the hash from the url and shoving // it into a querySelector, it's possible that this may // raise an exception if the input is invalid. So let's just ignore // this instead of blowing up. // e.g. `document.querySelector('div#=')` // > Uncaught DOMException: Failed to execute 'querySelector' on 'Document': 'div#=' is not a valid selector. } } } export function EventDataSection({ children, className, type, title, help, actions, guideTarget, wrapTitle = true, showPermalink = true, isHelpHoverable = false, ...props }: EventDataSectionProps) { let titleNode = wrapTitle ?