Skip to content

core: move links under components/core #94600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion static/app/components/assistant/getGuidesContent.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {GuidesContent} from 'sentry/components/assistant/types';
import {Link} from 'sentry/components/core/link';
import ExternalLink from 'sentry/components/links/externalLink';
import Link from 'sentry/components/links/link';
import {t, tct} from 'sentry/locale';
import type {Organization} from 'sentry/types/organization';
import {isDemoModeActive} from 'sentry/utils/demoMode';
Expand Down
4 changes: 2 additions & 2 deletions static/app/components/breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {css} from '@emotion/react';
import styled from '@emotion/styled';

import {Chevron} from 'sentry/components/chevron';
import type {LinkProps} from 'sentry/components/core/link';
import {Link} from 'sentry/components/core/link';
import GlobalSelectionLink from 'sentry/components/globalSelectionLink';
import type {LinkProps} from 'sentry/components/links/link';
import Link from 'sentry/components/links/link';
import {space} from 'sentry/styles/space';
import type {BreadcrumbDropdownProps} from 'sentry/views/settings/components/settingsBreadcrumb/breadcrumbDropdown';
import BreadcrumbDropdown from 'sentry/views/settings/components/settingsBreadcrumb/breadcrumbDropdown';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {Button} from 'sentry/components/core/button';
import type {SelectOption} from 'sentry/components/core/compactSelect';
import {CompactSelect} from 'sentry/components/core/compactSelect';
import {Flex} from 'sentry/components/core/layout';
import {Link} from 'sentry/components/core/link';
import DropdownButton from 'sentry/components/dropdownButton';
import Link from 'sentry/components/links/link';
import {IconInfo, IconSync} from 'sentry/icons';
import {t, tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/codecov/summary.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {css} from '@emotion/react';
import styled from '@emotion/styled';

import {Link} from 'sentry/components/core/link';
import {Hovercard} from 'sentry/components/hovercard';
import Link from 'sentry/components/links/link';
import {IconFilter} from 'sentry/icons';
import {space} from 'sentry/styles/space';
import {useLocation} from 'sentry/utils/useLocation';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/commitRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {openInviteMembersModal} from 'sentry/actionCreators/modal';
import CommitLink from 'sentry/components/commitLink';
import {UserAvatar} from 'sentry/components/core/avatar/userAvatar';
import {LinkButton} from 'sentry/components/core/button/linkButton';
import {Link} from 'sentry/components/core/link';
import {Tooltip} from 'sentry/components/core/tooltip';
import {Hovercard} from 'sentry/components/hovercard';
import ExternalLink from 'sentry/components/links/externalLink';
import Link from 'sentry/components/links/link';
import PanelItem from 'sentry/components/panels/panelItem';
import TextOverflow from 'sentry/components/textOverflow';
import TimeSince from 'sentry/components/timeSince';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/confirm.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from '@emotion/styled';

import Confirm, {openConfirmModal} from 'sentry/components/confirm';
import {Button} from 'sentry/components/core/button';
import Link from 'sentry/components/links/link';
import {Link} from 'sentry/components/core/link';
import * as Storybook from 'sentry/stories';
import {space} from 'sentry/styles/space';

Expand Down
2 changes: 1 addition & 1 deletion static/app/components/contextPickerModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import styled from '@emotion/styled';
import type {Query} from 'history';

import type {ModalRenderProps} from 'sentry/actionCreators/modal';
import {Link} from 'sentry/components/core/link';
import type {StylesConfig} from 'sentry/components/core/select';
import {Select} from 'sentry/components/core/select';
import {components} from 'sentry/components/forms/controls/reactSelectWrapper';
import IdBadge from 'sentry/components/idBadge';
import Link from 'sentry/components/links/link';
import LoadingError from 'sentry/components/loadingError';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import {t, tct} from 'sentry/locale';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/core/alert/alertLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {css, type Theme} from '@emotion/react';
import styled from '@emotion/styled';

import {Alert, type AlertProps} from 'sentry/components/core/alert';
import {Link} from 'sentry/components/core/link';
import ExternalLink from 'sentry/components/links/externalLink';
import Link from 'sentry/components/links/link';
import {IconChevron} from 'sentry/icons';
import {space} from 'sentry/styles/space';

Expand Down
2 changes: 1 addition & 1 deletion static/app/components/core/badge/deployBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import styled from '@emotion/styled';

import {Tag} from 'sentry/components/core/badge/tag';
import {Link} from 'sentry/components/core/link';
import {Tooltip} from 'sentry/components/core/tooltip';
import Link from 'sentry/components/links/link';
import {t} from 'sentry/locale';
import type {Deploy} from 'sentry/types/release';
import {MutableSearch} from 'sentry/utils/tokenizeSearch';
Expand Down
3 changes: 1 addition & 2 deletions static/app/components/core/button/linkButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import isPropValid from '@emotion/is-prop-valid';
import styled from '@emotion/styled';

import InteractionStateLayer from 'sentry/components/core/interactionStateLayer';
import {Link} from 'sentry/components/core/link';
import {Tooltip} from 'sentry/components/core/tooltip';
// eslint-disable-next-line boundaries/element-types
import Link from 'sentry/components/links/link';
// eslint-disable-next-line boundaries/element-types
import {IconDefaultsProvider} from 'sentry/icons/useIconDefaults';
// eslint-disable-next-line boundaries/element-types
import {space} from 'sentry/styles/space';
Expand Down
1 change: 1 addition & 0 deletions static/app/components/core/link/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {Link, type LinkProps, Anchor} from './link';
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@ import {locationDescriptorToTo} from 'sentry/utils/reactRouter6Compat/location';
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
import {useLocation} from 'sentry/utils/useLocation';

export const linkStyles = ({disabled, theme}: {theme: Theme; disabled?: boolean}) => css`
/* @TODO(jonasbadalic) This was defined on theme and only used here */
border-radius: 2px;

&:focus-visible {
box-shadow: ${theme.linkFocus} 0 0 0 2px;
text-decoration: none;
outline: none;
}

${disabled &&
css`
color: ${theme.disabled};
pointer-events: none;
:hover {
color: ${theme.disabled};
}
`}
`;

export interface LinkProps
extends Omit<
React.DetailedHTMLProps<React.HTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>,
Expand Down Expand Up @@ -59,11 +39,31 @@ export interface LinkProps
state?: ReactRouterLinkProps['state'];
}

const linkStyles = ({disabled, theme}: {theme: Theme; disabled?: boolean}) => css`
/* @TODO(jonasbadalic) This was defined on theme and only used here */
border-radius: 2px;

&:focus-visible {
box-shadow: ${theme.linkFocus} 0 0 0 2px;
text-decoration: none;
outline: none;
}

${disabled &&
css`
color: ${theme.disabled};
pointer-events: none;
:hover {
color: ${theme.disabled};
}
`}
`;

/**
* A context-aware version of Link (from react-router) that falls
* back to <a> if there is no router present
*/
const Link = styled(({disabled, to, ...props}: LinkProps) => {
export const Link = styled(({disabled, to, ...props}: LinkProps) => {
const location = useLocation();
to = normalizeUrl(to, location);

Expand All @@ -82,5 +82,3 @@ export const Anchor = styled('a', {
})<{disabled?: boolean}>`
${linkStyles}
`;

export default Link;
2 changes: 1 addition & 1 deletion static/app/components/core/tabs/tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {TabListState} from '@react-stately/tabs';
import type {Node, Orientation} from '@react-types/shared';

import InteractionStateLayer from 'sentry/components/core/interactionStateLayer';
import Link from 'sentry/components/links/link';
import {Link} from 'sentry/components/core/link';
import {space} from 'sentry/styles/space';
import {isChonkTheme, withChonk} from 'sentry/utils/theme/withChonk';

Expand Down
2 changes: 1 addition & 1 deletion static/app/components/createAlertButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {hasEveryAccess} from 'sentry/components/acl/access';
import GuideAnchor from 'sentry/components/assistant/guideAnchor';
import type {LinkButtonProps} from 'sentry/components/core/button/linkButton';
import {LinkButton} from 'sentry/components/core/button/linkButton';
import Link from 'sentry/components/links/link';
import {Link} from 'sentry/components/core/link';
import {IconSiren} from 'sentry/icons';
import type {SVGIconProps} from 'sentry/icons/svgIcon';
import {t, tct} from 'sentry/locale';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/discover/performanceCardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from '@emotion/styled';
import type {Location} from 'history';

import {Alert} from 'sentry/components/core/alert';
import Link from 'sentry/components/links/link';
import {Link} from 'sentry/components/core/link';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import NotAvailable from 'sentry/components/notAvailable';
import PanelItem from 'sentry/components/panels/panelItem';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/discover/transactionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from '@emotion/styled';
import type {Location, LocationDescriptor} from 'history';

import {LinkButton} from 'sentry/components/core/button/linkButton';
import Link from 'sentry/components/links/link';
import {Link} from 'sentry/components/core/link';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import {PanelTable} from 'sentry/components/panels/panelTable';
import QuestionTooltip from 'sentry/components/questionTooltip';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/dropdownMenu/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import type {TreeState} from '@react-stately/tree';
import type {Node} from '@react-types/shared';
import type {LocationDescriptor} from 'history';

import {Link} from 'sentry/components/core/link';
import type {MenuListItemProps} from 'sentry/components/core/menuListItem';
import {MenuListItem} from 'sentry/components/core/menuListItem';
import ExternalLink from 'sentry/components/links/externalLink';
import Link from 'sentry/components/links/link';
import {IconChevron} from 'sentry/icons';
import usePrevious from 'sentry/utils/usePrevious';

Expand Down
2 changes: 1 addition & 1 deletion static/app/components/errors/notFound.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import styled from '@emotion/styled';

import {Alert} from 'sentry/components/core/alert';
import {Link} from 'sentry/components/core/link';
import ExternalLink from 'sentry/components/links/externalLink';
import Link from 'sentry/components/links/link';
import {t, tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';

Expand Down
2 changes: 1 addition & 1 deletion static/app/components/eventOrGroupExtraDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Fragment} from 'react';
import styled from '@emotion/styled';

import {Link} from 'sentry/components/core/link';
import {
getAutofixRunExists,
isIssueQuickFixable,
Expand All @@ -14,7 +15,6 @@ import IssueReplayCount from 'sentry/components/group/issueReplayCount';
import IssueSeerBadge from 'sentry/components/group/issueSeerBadge';
import ProjectBadge from 'sentry/components/idBadge/projectBadge';
import ExternalLink from 'sentry/components/links/externalLink';
import Link from 'sentry/components/links/link';
import Placeholder from 'sentry/components/placeholder';
import {IconChat} from 'sentry/icons';
import {tct} from 'sentry/locale';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/eventOrGroupHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {Fragment, useRef} from 'react';
import styled from '@emotion/styled';
import {useHover} from '@react-aria/interactions';

import {Link} from 'sentry/components/core/link';
import ErrorBoundary from 'sentry/components/errorBoundary';
import EventOrGroupTitle from 'sentry/components/eventOrGroupTitle';
import EventMessage from 'sentry/components/events/eventMessage';
import Link from 'sentry/components/links/link';
import {IconStar} from 'sentry/icons';
import {space} from 'sentry/styles/space';
import type {Event} from 'sentry/types/event';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/events/autofix/autofixSolution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {Alert} from 'sentry/components/core/alert';
import {Button} from 'sentry/components/core/button';
import {ButtonBar} from 'sentry/components/core/button/buttonBar';
import {Input} from 'sentry/components/core/input';
import {Link} from 'sentry/components/core/link';
import {Tooltip} from 'sentry/components/core/tooltip';
import {AutofixHighlightWrapper} from 'sentry/components/events/autofix/autofixHighlightWrapper';
import {SolutionEventItem} from 'sentry/components/events/autofix/autofixSolutionEventItem';
Expand All @@ -23,7 +24,6 @@ import {
makeAutofixQueryKey,
useAutofixRepos,
} from 'sentry/components/events/autofix/useAutofix';
import Link from 'sentry/components/links/link';
import {Timeline} from 'sentry/components/timeline';
import {IconAdd, IconChat, IconFix} from 'sentry/icons';
import {t, tct} from 'sentry/locale';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Alert} from 'sentry/components/core/alert';
import Link from 'sentry/components/links/link';
import {Link} from 'sentry/components/core/link';
import {tct} from 'sentry/locale';
import {useLocation} from 'sentry/utils/useLocation';
import {EventAttachmentFilter} from 'sentry/views/issueDetails/groupEventAttachments/groupEventAttachmentsFilter';
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/events/eventDataSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from '@emotion/styled';

import {Anchor} from 'sentry/components/core/link';
import {DataSection} from 'sentry/components/events/styles';
import {Anchor} from 'sentry/components/links/link';
import QuestionTooltip from 'sentry/components/questionTooltip';
import {IconLink} from 'sentry/icons';
import {space} from 'sentry/styles/space';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import styled from '@emotion/styled';
import {Button} from 'sentry/components/core/button';
import {LinkButton} from 'sentry/components/core/button/linkButton';
import {CompactSelect} from 'sentry/components/core/compactSelect';
import {Link} from 'sentry/components/core/link';
import {Tooltip} from 'sentry/components/core/tooltip';
import {DateTime} from 'sentry/components/dateTime';
import EmptyStateWarning from 'sentry/components/emptyStateWarning';
Expand All @@ -17,7 +18,6 @@ import {
} from 'sentry/components/events/interfaces/spans/header';
import WaterfallModel from 'sentry/components/events/interfaces/spans/waterfallModel';
import OpsBreakdown from 'sentry/components/events/opsBreakdown';
import Link from 'sentry/components/links/link';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import TextOverflow from 'sentry/components/textOverflow';
import {IconChevron, IconOpen} from 'sentry/icons';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {LocationDescriptor} from 'history';

import {Button} from 'sentry/components/core/button';
import {ButtonBar} from 'sentry/components/core/button/buttonBar';
import Link from 'sentry/components/links/link';
import {Link} from 'sentry/components/core/link';
import LoadingIndicator from 'sentry/components/loadingIndicator';
import Panel from 'sentry/components/panels/panel';
import Placeholder from 'sentry/components/placeholder';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {useMemo} from 'react';
import styled from '@emotion/styled';
import type {LocationDescriptor} from 'history';

import {Link} from 'sentry/components/core/link';
import Duration from 'sentry/components/duration';
import Link from 'sentry/components/links/link';
import type {GridColumnOrder} from 'sentry/components/tables/gridEditable';
import GridEditable from 'sentry/components/tables/gridEditable';
import SortLink from 'sentry/components/tables/gridEditable/sortLink';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import * as qs from 'query-string';

import {openNavigateToExternalLinkModal} from 'sentry/actionCreators/modal';
import {hasEveryAccess} from 'sentry/components/acl/access';
import {Link} from 'sentry/components/core/link';
import {DropdownMenu, type MenuItemProps} from 'sentry/components/dropdownMenu';
import type {TagTreeContent} from 'sentry/components/events/eventTags/eventTagsTree';
import EventTagsValue from 'sentry/components/events/eventTags/eventTagsValue';
import {AnnotatedTextErrors} from 'sentry/components/events/meta/annotatedText/annotatedTextErrors';
import ExternalLink from 'sentry/components/links/externalLink';
import Link from 'sentry/components/links/link';
import Version from 'sentry/components/version';
import VersionHoverCard from 'sentry/components/versionHoverCard';
import {IconEllipsis} from 'sentry/icons';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Link} from 'sentry/components/core/link';
import {DeviceName} from 'sentry/components/deviceName';
import {AnnotatedText} from 'sentry/components/events/meta/annotatedText';
import Link from 'sentry/components/links/link';
import type {EventTag} from 'sentry/types/event';
import type {Meta} from 'sentry/types/group';
import {defined} from 'sentry/utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
} from 'sentry/actionCreators/events';
import {openModal} from 'sentry/actionCreators/modal';
import {LinkButton} from 'sentry/components/core/button/linkButton';
import {Link} from 'sentry/components/core/link';
import Screenshot from 'sentry/components/events/eventTagsAndScreenshot/screenshot';
import ScreenshotModal, {
modalCss,
} from 'sentry/components/events/eventTagsAndScreenshot/screenshot/modal';
import Link from 'sentry/components/links/link';
import {t, tn} from 'sentry/locale';
import type {Event} from 'sentry/types/event';
import type {EventAttachment} from 'sentry/types/group';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Fragment} from 'react';

import Link from 'sentry/components/links/link';
import {Link} from 'sentry/components/core/link';
import {t, tct} from 'sentry/locale';
import type {Organization} from 'sentry/types/organization';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Link} from 'sentry/components/core/link';
import type {BreadcrumbTransactionEvent} from 'sentry/components/events/interfaces/breadcrumbs/types';
import {AnnotatedText} from 'sentry/components/events/meta/annotatedText';
import Highlight from 'sentry/components/highlight';
import Link from 'sentry/components/links/link';
import type {
BreadcrumbTypeDefault,
BreadcrumbTypeNavigation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {CopyToClipboardButton} from 'sentry/components/copyToClipboardButton';
import {Alert} from 'sentry/components/core/alert';
import {Button} from 'sentry/components/core/button';
import {ButtonBar} from 'sentry/components/core/button/buttonBar';
import {Link} from 'sentry/components/core/link';
import TextField from 'sentry/components/forms/fields/textField';
import ExternalLink from 'sentry/components/links/externalLink';
import Link from 'sentry/components/links/link';
import List from 'sentry/components/list';
import TextCopyInput from 'sentry/components/textCopyInput';
import {t, tct} from 'sentry/locale';
Expand Down
Loading
Loading