Skip to content
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

feat(nav): Update alerts links to /issues/alerts/ #85005

Merged
merged 10 commits into from
Feb 13, 2025
11 changes: 9 additions & 2 deletions static/app/components/createAlertButton.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import CreateAlertButton, {
import GuideStore from 'sentry/stores/guideStore';
import EventView from 'sentry/utils/discover/eventView';
import useProjects from 'sentry/utils/useProjects';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
import {DEFAULT_EVENT_VIEW} from 'sentry/views/discover/data';

const onClickMock = jest.fn();
Expand Down Expand Up @@ -227,7 +228,10 @@ describe('CreateAlertFromViewButton', () => {
});
await userEvent.click(screen.getByRole('button'));
expect(navigateTo).toHaveBeenCalledWith(
`/organizations/org-slug/alerts/wizard/?`,
makeAlertsPathname({
path: `/wizard/`,
organization,
}),
expect.objectContaining({
params: expect.objectContaining({
orgId: 'org-slug',
Expand Down Expand Up @@ -285,7 +289,10 @@ describe('CreateAlertFromViewButton', () => {
);
await userEvent.click(screen.getByRole('button'));
expect(router.push).toHaveBeenCalledWith({
pathname: `/organizations/org-slug/alerts/new/metric/`,
pathname: makeAlertsPathname({
path: `/new/metric/`,
organization,
}),
query: expect.objectContaining({
query: 'event.type:error ',
project: 'project-slug',
Expand Down
13 changes: 11 additions & 2 deletions static/app/components/createAlertButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type EventView from 'sentry/utils/discover/eventView';
import useApi from 'sentry/utils/useApi';
import useProjects from 'sentry/utils/useProjects';
import useRouter from 'sentry/utils/useRouter';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
import type {AlertType, AlertWizardAlertNames} from 'sentry/views/alerts/wizard/options';
import {
AlertWizardRuleTemplates,
Expand Down Expand Up @@ -75,7 +76,10 @@ function CreateAlertFromViewButton({
: DEFAULT_WIZARD_TEMPLATE;

const to = {
pathname: `/organizations/${organization.slug}/alerts/new/metric/`,
pathname: makeAlertsPathname({
path: '/new/metric/',
organization,
}),
query: {
...queryParams,
createFromDiscover: true,
Expand Down Expand Up @@ -143,7 +147,12 @@ export default function CreateAlertButton({
if (alertOption) {
params.append('alert_option', alertOption);
}
return `/organizations/${organization.slug}/alerts/wizard/?${params.toString()}`;
return (
makeAlertsPathname({
path: '/wizard/',
organization,
}) + `?${params.toString()}`
);
};

function handleClickWithoutProject(event: React.MouseEvent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {Organization} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {useDimensions} from 'sentry/utils/useDimensions';
import {useLocation} from 'sentry/utils/useLocation';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
import {SectionKey} from 'sentry/views/issueDetails/streamline/context';
import {InterimSection} from 'sentry/views/issueDetails/streamline/interimSection';
import {ResolutionSelector} from 'sentry/views/monitors/components/overviewTimeline/resolutionSelector';
Expand Down Expand Up @@ -77,7 +78,10 @@ export function CronTimelineSection({event, organization, project}: Props) {
size="xs"
icon={<IconOpen />}
to={{
pathname: `/organizations/${organization.slug}/alerts/rules/crons/${project.slug}/${monitorSlug}/details/`,
pathname: makeAlertsPathname({
path: `/rules/crons/${project.slug}/${monitorSlug}/details/`,
organization,
}),
query: {environment},
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import type {Event} from 'sentry/types/event';
import {type Group, GroupActivityType, GroupStatus} from 'sentry/types/group';
import type {Project} from 'sentry/types/project';
import {defined} from 'sentry/utils';
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
import {useDebouncedValue} from 'sentry/utils/useDebouncedValue';
import {useDimensions} from 'sentry/utils/useDimensions';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
import {
checkStatusPrecedent,
statusToText,
Expand Down Expand Up @@ -133,9 +133,10 @@ export function UptimeDataSection({group, event, project}: Props) {
<LinkButton
icon={<IconSettings />}
size="xs"
to={normalizeUrl(
`/organizations/${organization.slug}/alerts/rules/uptime/${project.slug}/${alertRuleId}/details/`
)}
to={makeAlertsPathname({
path: `/rules/uptime/${project.slug}/${alertRuleId}/details/`,
organization,
})}
>
{t('Uptime Alert Rule')}
</LinkButton>
Expand Down
11 changes: 9 additions & 2 deletions static/app/components/onboardingWizard/taskConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {Organization} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {isDemoModeEnabled} from 'sentry/utils/demoMode';
import {getDemoWalkthroughTasks} from 'sentry/utils/demoMode/guides';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
import {getPerformanceBaseUrl} from 'sentry/views/performance/utils';
import {makeReplaysPathname} from 'sentry/views/replays/pathnames';

Expand All @@ -47,12 +48,18 @@ type Options = {

function getIssueAlertUrl({projects, organization}: Options) {
if (!projects || !projects.length) {
return `/organizations/${organization.slug}/alerts/rules/`;
return makeAlertsPathname({
path: '/rules/',
organization,
});
}
// pick the first project with events if we have that, otherwise just pick the first project
const firstProjectWithEvents = projects.find(project => !!project.firstEvent);
const project = firstProjectWithEvents ?? projects[0]!;
return `/organizations/${organization.slug}/alerts/${project.slug}/wizard/`;
return makeAlertsPathname({
path: `/${project.slug}/wizard/`,
organization,
});
}

function getOnboardingInstructionsUrl({projects, organization}: Options) {
Expand Down
6 changes: 5 additions & 1 deletion static/app/components/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import useMedia from 'sentry/utils/useMedia';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import useProjects from 'sentry/utils/useProjects';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
import {MODULE_BASE_URLS} from 'sentry/views/insights/common/utils/useModuleURL';
import {
AI_LANDING_SUB_PATH,
Expand Down Expand Up @@ -328,7 +329,10 @@ function Sidebar() {
{...sidebarItemProps}
icon={<IconSiren />}
label={t('Alerts')}
to={`/organizations/${organization.slug}/alerts/rules/`}
to={makeAlertsPathname({
path: '/rules/',
organization,
})}
id="alerts"
/>
);
Expand Down
11 changes: 9 additions & 2 deletions static/app/views/alerts/builder/builderBreadCrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {Crumb, CrumbDropdown} from 'sentry/components/breadcrumbs';
import Breadcrumbs from 'sentry/components/breadcrumbs';
import {t} from 'sentry/locale';
import type {Organization} from 'sentry/types/organization';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';

interface Props {
organization: Organization;
Expand All @@ -13,15 +14,21 @@ interface Props {
function BuilderBreadCrumbs({title, alertName, projectSlug, organization}: Props) {
const crumbs: Array<Crumb | CrumbDropdown> = [
{
to: `/organizations/${organization.slug}/alerts/rules/`,
to: makeAlertsPathname({
path: '/rules/',
organization,
}),
label: t('Alerts'),
preservePageFilters: true,
},
{
label: title,
...(alertName
? {
to: `/organizations/${organization.slug}/alerts/${projectSlug}/wizard`,
to: makeAlertsPathname({
path: `/${projectSlug}/wizard/`,
organization,
}),
preservePageFilters: true,
}
: {}),
Expand Down
6 changes: 5 additions & 1 deletion static/app/views/alerts/builder/projectProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import useApi from 'sentry/utils/useApi';
import {useIsMountedRef} from 'sentry/utils/useIsMountedRef';
import useProjects from 'sentry/utils/useProjects';
import useScrollToTop from 'sentry/utils/useScrollToTop';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';

type Props = RouteComponentProps<RouteParams, {}> & {
hasMetricAlerts: boolean;
Expand Down Expand Up @@ -57,7 +58,10 @@ function AlertBuilderProjectProvider(props: Props) {
// If there's no project show the project selector modal
if (!project && !fetchError) {
navigateTo(
`/organizations/${organization.slug}/alerts/wizard/?referrer=${props.location.query.referrer}&project=:projectId`,
makeAlertsPathname({
path: '/wizard/',
organization,
}) + `?referrer=${props.location.query.referrer}&project=:projectId`,
props.router
);
}
Expand Down
32 changes: 18 additions & 14 deletions static/app/views/alerts/create.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {metric, trackAnalytics} from 'sentry/utils/analytics';
import AlertsContainer from 'sentry/views/alerts';
import AlertBuilderProjectProvider from 'sentry/views/alerts/builder/projectProvider';
import ProjectAlertsCreate from 'sentry/views/alerts/create';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';

jest.unmock('sentry/utils/recreateRoute');
// updateOnboardingTask triggers an out of band state update
Expand Down Expand Up @@ -111,7 +112,10 @@ describe('ProjectAlertsCreate', function () {
organization={organization}
project={project}
location={LocationFixture({
pathname: `/organizations/org-slug/alerts/rules/${project.slug}/new/`,
pathname: makeAlertsPathname({
path: `/rules/${project.slug}/new/`,
organization: OrganizationFixture({slug: 'org-slug'}),
}),
query: {createFromWizard: 'true'},
...location,
})}
Expand All @@ -136,7 +140,7 @@ describe('ProjectAlertsCreate', function () {
await waitFor(() => {
expect(wrapper.router.replace).toHaveBeenCalledWith(
expect.objectContaining({
pathname: '/organizations/org-slug/alerts/new/metric',
pathname: '/organizations/org-slug/alerts/new/metric/',
query: {
aggregate: 'count()',
dataset: 'events',
Expand Down Expand Up @@ -360,9 +364,9 @@ describe('ProjectAlertsCreate', function () {
expect(metric.startSpan).toHaveBeenCalledWith({name: 'saveAlertRule'});

await waitFor(() => {
expect(wrapper.router.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/alerts/rules/project-slug/1/details/',
});
expect(wrapper.router.push).toHaveBeenCalledWith(
'/organizations/org-slug/alerts/rules/project-slug/1/details/'
);
});
});

Expand Down Expand Up @@ -415,9 +419,9 @@ describe('ProjectAlertsCreate', function () {
expect(metric.startSpan).toHaveBeenCalledWith({name: 'saveAlertRule'});

await waitFor(() => {
expect(wrapper.router.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/alerts/rules/project-slug/1/details/',
});
expect(wrapper.router.push).toHaveBeenCalledWith(
'/organizations/org-slug/alerts/rules/project-slug/1/details/'
);
});
});

Expand Down Expand Up @@ -464,9 +468,9 @@ describe('ProjectAlertsCreate', function () {
expect(metric.startSpan).toHaveBeenCalledWith({name: 'saveAlertRule'});

await waitFor(() => {
expect(wrapper.router.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/alerts/rules/project-slug/1/details/',
});
expect(wrapper.router.push).toHaveBeenCalledWith(
'/organizations/org-slug/alerts/rules/project-slug/1/details/'
);
});
});

Expand Down Expand Up @@ -510,9 +514,9 @@ describe('ProjectAlertsCreate', function () {
expect(metric.startSpan).toHaveBeenCalledWith({name: 'saveAlertRule'});

await waitFor(() => {
expect(wrapper.router.push).toHaveBeenCalledWith({
pathname: '/organizations/org-slug/alerts/rules/project-slug/1/details/',
});
expect(wrapper.router.push).toHaveBeenCalledWith(
'/organizations/org-slug/alerts/rules/project-slug/1/details/'
);
});
});
});
Expand Down
14 changes: 10 additions & 4 deletions static/app/views/alerts/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import normalizeUrl from 'sentry/utils/url/normalizeUrl';
import {useNavigate} from 'sentry/utils/useNavigate';
import {useUserTeams} from 'sentry/utils/useUserTeams';
import BuilderBreadCrumbs from 'sentry/views/alerts/builder/builderBreadCrumbs';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';
import IssueRuleEditor from 'sentry/views/alerts/rules/issue';
import MetricRulesCreate from 'sentry/views/alerts/rules/metric/create';
import MetricRuleDuplicate from 'sentry/views/alerts/rules/metric/duplicate';
Expand Down Expand Up @@ -74,7 +75,10 @@ function Create(props: Props) {
router.replace(
normalizeUrl({
...location,
pathname: `/organizations/${organization.slug}/alerts/new/${alertType}`,
pathname: makeAlertsPathname({
path: `/new/${alertType}/`,
organization,
}),
query: {
...location.query,
...DEFAULT_WIZARD_TEMPLATE,
Expand All @@ -93,6 +97,7 @@ function Create(props: Props) {
location,
organization.slug,
project.slug,
organization,
]);

const {teams, isLoading} = useUserTeams();
Expand Down Expand Up @@ -154,9 +159,10 @@ function Create(props: Props) {
apiEndpoint={`/organizations/${organization.slug}/monitors/`}
onSubmitSuccess={(data: Monitor) =>
navigate(
normalizeUrl(
`/organizations/${organization.slug}/alerts/rules/crons/${data.project.slug}/${data.slug}/details/`
)
makeAlertsPathname({
path: `/rules/crons/${data.project.slug}/${data.slug}/details/`,
organization,
})
)
}
submitLabel={t('Create')}
Expand Down
12 changes: 9 additions & 3 deletions static/app/views/alerts/list/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import {TabList} from 'sentry/components/tabs';
import {IconSettings} from 'sentry/icons';
import {t} from 'sentry/locale';
import ProjectsStore from 'sentry/stores/projectsStore';
import normalizeUrl from 'sentry/utils/url/normalizeUrl';
import useOrganization from 'sentry/utils/useOrganization';
import usePageFilters from 'sentry/utils/usePageFilters';
import useRouter from 'sentry/utils/useRouter';
import {makeAlertsPathname} from 'sentry/views/alerts/pathnames';

type Props = {
activeTab: 'stream' | 'rules';
Expand All @@ -34,7 +34,10 @@ function AlertHeader({activeTab}: Props) {
const alertRulesLink = (
<TabList.Item
key="rules"
to={normalizeUrl(`/organizations/${organization.slug}/alerts/rules/`)}
to={makeAlertsPathname({
path: '/rules/',
organization,
})}
>
{t('Alert Rules')}
</TabList.Item>
Expand Down Expand Up @@ -85,7 +88,10 @@ function AlertHeader({activeTab}: Props) {
{alertRulesLink}
<TabList.Item
key="stream"
to={normalizeUrl(`/organizations/${organization.slug}/alerts/`)}
to={makeAlertsPathname({
path: '/',
organization,
})}
>
{t('History')}
</TabList.Item>
Expand Down
2 changes: 1 addition & 1 deletion static/app/views/alerts/list/rules/alertRulesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ function AlertRulesList() {
projectsLoaded={initiallyLoaded}
projects={projects as Project[]}
rule={rule}
orgId={organization.slug}
organization={organization}
onOwnerChange={handleOwnerChange}
onDelete={handleDeleteRule}
hasEditAccess={hasEditAccess}
Expand Down
Loading
Loading