Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {parseAsBoolean, useQueryState} from 'nuqs';

import {Alert} from '@sentry/scraps/alert';
import {Button} from '@sentry/scraps/button';

import {IconClose} from 'sentry/icons';
import {t} from 'sentry/locale';

export function InsightsRedirectNotice({children}: {children: React.ReactNode}) {
const [wasRedirectedFromInsights, setWasRedirectedFromInsights] = useQueryState(
'insightsRedirect',
parseAsBoolean.withOptions({history: 'replace'}).withDefault(false)
);
Comment on lines +10 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

damn nice


if (!wasRedirectedFromInsights) {
return null;
}

return (
<Alert
type="info"
trailingItems={
<Button
size="zero"
borderless
icon={<IconClose />}
aria-label={t('Dismiss')}
onClick={() => {
setWasRedirectedFromInsights(false);
}}
/>
}
>
{children}
</Alert>
);
}
4 changes: 4 additions & 0 deletions static/app/views/detectors/list/cron.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {HeaderCell} from 'sentry/views/detectors/components/detectorListTable';
import {DetectorListActions} from 'sentry/views/detectors/list/common/detectorListActions';
import {DetectorListContent} from 'sentry/views/detectors/list/common/detectorListContent';
import {DetectorListHeader} from 'sentry/views/detectors/list/common/detectorListHeader';
import {InsightsRedirectNotice} from 'sentry/views/detectors/list/common/insightsRedirectNotice';
import {useDetectorListQuery} from 'sentry/views/detectors/list/common/useDetectorListQuery';
import {
MonitorViewContext,
Expand Down Expand Up @@ -155,6 +156,9 @@ export default function CronDetectorsList() {
description={DESCRIPTION}
docsUrl={DOCS_URL}
>
<InsightsRedirectNotice>
{t('Cron monitors have been moved from Insights to Monitors.')}
</InsightsRedirectNotice>
<DetectorListHeader showTimeRangeSelector showTypeFilter={false} />
<DetectorListContent
{...detectorListQuery}
Expand Down
4 changes: 4 additions & 0 deletions static/app/views/detectors/list/uptime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {useDimensions} from 'sentry/utils/useDimensions';
import {DetectorListActions} from 'sentry/views/detectors/list/common/detectorListActions';
import {DetectorListContent} from 'sentry/views/detectors/list/common/detectorListContent';
import {DetectorListHeader} from 'sentry/views/detectors/list/common/detectorListHeader';
import {InsightsRedirectNotice} from 'sentry/views/detectors/list/common/insightsRedirectNotice';
import {useDetectorListQuery} from 'sentry/views/detectors/list/common/useDetectorListQuery';
import {
MonitorViewContext,
Expand Down Expand Up @@ -109,6 +110,9 @@ export default function UptimeDetectorsList() {
description={DESCRIPTION}
docsUrl={DOCS_URL}
>
<InsightsRedirectNotice>
{t('Uptime monitors have been moved from Insights to Monitors.')}
</InsightsRedirectNotice>
<DetectorListHeader showTimeRangeSelector showTypeFilter={false} />
<DetectorListContent {...detectorListQuery} />
</WorkflowEngineListLayout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {FeatureBadge} from 'sentry/components/core/badge/featureBadge';
import {t} from 'sentry/locale';
import useOrganization from 'sentry/utils/useOrganization';
import useProjects from 'sentry/utils/useProjects';
import {useUser} from 'sentry/utils/useUser';
import {makeMonitorBasePathname} from 'sentry/views/detectors/pathnames';
import {
AGENTS_LANDING_SUB_PATH,
AGENTS_SIDEBAR_LABEL,
Expand Down Expand Up @@ -33,6 +35,7 @@ import {SecondaryNav} from 'sentry/views/nav/secondary/secondary';
import {PrimaryNavGroup} from 'sentry/views/nav/types';

export function InsightsSecondaryNav() {
const user = useUser();
const organization = useOrganization();
const baseUrl = `/organizations/${organization.slug}/${DOMAIN_VIEW_BASE_URL}`;

Expand All @@ -47,6 +50,9 @@ export function InsightsSecondaryNav() {
? starredProjects.slice(0, 8)
: nonStarredProjects.filter(project => project.isMember).slice(0, 8);

const shouldRedirectToMonitors =
organization.features.includes('workflow-engine-ui') && !user?.isStaff;

return (
<Fragment>
<SecondaryNav.Header>
Expand Down Expand Up @@ -89,12 +95,23 @@ export function InsightsSecondaryNav() {
</SecondaryNav.Item>
</SecondaryNav.Section>
<SecondaryNav.Section id="insights-monitors">
<SecondaryNav.Item to={`${baseUrl}/crons/`} analyticsItemName="insights_crons">
<SecondaryNav.Item
to={
shouldRedirectToMonitors
? `${makeMonitorBasePathname(organization.slug)}crons/?insightsRedirect=true`
: `${baseUrl}/crons/`
}
analyticsItemName="insights_crons"
>
{t('Crons')}
</SecondaryNav.Item>
<Feature features={['uptime']}>
<SecondaryNav.Item
to={`${baseUrl}/uptime/`}
to={
shouldRedirectToMonitors
? `${makeMonitorBasePathname(organization.slug)}uptime/?insightsRedirect=true`
: `${baseUrl}/uptime/`
}
analyticsItemName="insights_uptime"
>
{t('Uptime')}
Expand Down
Loading