Skip to content

Commit af33e23

Browse files
authored
chore(prevent): Integrate prevent-ai flag and move around codecov-ui flag (#97719)
This PR updates the secondary nav for prevent to be flagged by the new prevent-ai flag, and then changes the coverage/tests/tokens pages to use the original flag. The UI button now appears with just the "prevent AI" stuff which directly links to the new onboarding page Closes https://linear.app/getsentry/issue/PREVENT-256/integrate-prevent-ai-feature-flag-in-sentry-ui https://github.com/user-attachments/assets/922a9673-ec17-4ee5-9937-038df2786458 <!-- Sentry employees and contractors can delete or ignore the following. --> ### Legal Boilerplate Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.
1 parent ef55497 commit af33e23

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

static/app/views/nav/primary/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {PrimaryNavigationWhatsNew} from 'sentry/views/nav/primary/whatsNew';
2828
import {NavTourElement, StackedNavigationTour} from 'sentry/views/nav/tour/tour';
2929
import {NavLayout, PrimaryNavGroup} from 'sentry/views/nav/types';
3030
import {UserDropdown} from 'sentry/views/nav/userDropdown';
31-
import {COVERAGE_BASE_URL, PREVENT_BASE_URL} from 'sentry/views/prevent/settings';
31+
import {PREVENT_AI_BASE_URL, PREVENT_BASE_URL} from 'sentry/views/prevent/settings';
3232

3333
function SidebarBody({children}: {children: React.ReactNode}) {
3434
const {layout} = useNavContext();
@@ -123,9 +123,9 @@ export function PrimaryNavigationItems() {
123123
</NavTourElement>
124124
</Feature>
125125

126-
<Feature features={['codecov-ui']}>
126+
<Feature features={['prevent-ai']}>
127127
<SidebarLink
128-
to={`/${prefix}/${PREVENT_BASE_URL}/${COVERAGE_BASE_URL}/commits/`}
128+
to={`/${prefix}/${PREVENT_BASE_URL}/${PREVENT_AI_BASE_URL}/new/`}
129129
activeTo={`/${prefix}/${PREVENT_BASE_URL}/`}
130130
analyticsKey="prevent"
131131
group={PrimaryNavGroup.PREVENT}

static/app/views/nav/secondary/sections/prevent/preventSecondaryNav.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {Fragment} from 'react';
22

3+
import Feature from 'sentry/components/acl/feature';
34
import {t} from 'sentry/locale';
45
import useOrganization from 'sentry/utils/useOrganization';
56
import {PRIMARY_NAV_GROUP_CONFIG} from 'sentry/views/nav/primary/config';
@@ -39,27 +40,33 @@ function PreventSecondaryNav() {
3940
</SecondaryNav.Header>
4041
<SecondaryNav.Body>
4142
<SecondaryNav.Section id="prevent-main">
42-
<SecondaryNav.Item
43-
to={`${coveragePathname}commits/`}
44-
activeTo={coveragePathname}
45-
>
46-
{t('Coverage')}
47-
</SecondaryNav.Item>
48-
<SecondaryNav.Item to={testsPathname} activeTo={testsPathname}>
49-
{t('Tests')}
50-
</SecondaryNav.Item>
43+
<Feature features={['codecov-ui']}>
44+
<SecondaryNav.Item
45+
to={`${coveragePathname}commits/`}
46+
activeTo={coveragePathname}
47+
>
48+
{t('Coverage')}
49+
</SecondaryNav.Item>
50+
</Feature>
51+
<Feature features={['codecov-ui']}>
52+
<SecondaryNav.Item to={testsPathname} activeTo={testsPathname}>
53+
{t('Tests')}
54+
</SecondaryNav.Item>
55+
</Feature>
5156
<SecondaryNav.Item
5257
to={`${preventAIPathName}new/`}
5358
activeTo={`${preventAIPathName}new/`}
5459
>
5560
{t('Prevent AI')}
5661
</SecondaryNav.Item>
5762
</SecondaryNav.Section>
58-
<SecondaryNav.Section id="prevent-configure" title={t('Configure')}>
59-
<SecondaryNav.Item to={`${tokensPathName}`} activeTo={tokensPathName}>
60-
{t('Tokens')}
61-
</SecondaryNav.Item>
62-
</SecondaryNav.Section>
63+
<Feature features={['codecov-ui']}>
64+
<SecondaryNav.Section id="prevent-configure" title={t('Configure')}>
65+
<SecondaryNav.Item to={`${tokensPathName}`} activeTo={tokensPathName}>
66+
{t('Tokens')}
67+
</SecondaryNav.Item>
68+
</SecondaryNav.Section>
69+
</Feature>
6370
</SecondaryNav.Body>
6471
</Fragment>
6572
);

static/app/views/prevent/index.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {render, screen} from 'sentry-test/reactTestingLibrary';
44

55
import PreventPage from 'sentry/views/prevent';
66

7-
const COVERAGE_FEATURE = 'codecov-ui';
7+
const PREVENT_FEATURE = 'prevent-ai';
88

99
describe('PreventPage', () => {
1010
describe('when the user has access to the feature', () => {
@@ -13,7 +13,7 @@ describe('PreventPage', () => {
1313
<PreventPage>
1414
<p>Test content</p>
1515
</PreventPage>,
16-
{organization: OrganizationFixture({features: [COVERAGE_FEATURE]})}
16+
{organization: OrganizationFixture({features: [PREVENT_FEATURE]})}
1717
);
1818

1919
const testContent = screen.getByText('Test content');

static/app/views/prevent/index.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@ export default function PreventPage({children}: Props) {
1414
const location = useLocation();
1515
const organization = useOrganization();
1616

17-
// Redirect to coverage page if the user lands on the codecov page
18-
if (
19-
location.pathname === `/${PREVENT_BASE_URL}/` ||
20-
location.pathname === `/${PREVENT_BASE_URL}/coverage`
21-
) {
22-
return <Redirect to={`/${PREVENT_BASE_URL}/coverage/commits/`} />;
17+
if (location.pathname === `/${PREVENT_BASE_URL}/`) {
18+
return <Redirect to={`/${PREVENT_BASE_URL}/prevent-ai/new/`} />;
2319
}
2420

2521
return (
2622
<Feature
27-
features={['codecov-ui']}
23+
features={['prevent-ai']}
2824
organization={organization}
2925
renderDisabled={NoAccess}
3026
>

0 commit comments

Comments
 (0)