Skip to content

Commit f795149

Browse files
authored
chore(prevent): Rename codecov routes to prevent (#97485)
This PR aims to change all the routes that were /codecov/ to /prevent/ as well as updating a bunch of consts that mentioned codecov when they probably should have been named prevent. Wanted to do this sooner rather than later to avoid an ever increasing diff. Mostly just find and replace with cursor, had to be a little surgical with the existing codecov integration items just because that actually _was_ codecov stuff and not prevent Closes https://linear.app/getsentry/issue/CCMRG-1487/rename-codecov-routes-to-prevent <!-- 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 f02baf6 commit f795149

File tree

128 files changed

+441
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+441
-444
lines changed

knip.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const productionEntryPoints = [
1717
// this is imported with require.context
1818
'static/app/data/forms/*.tsx',
1919
// --- we should be able to get rid of those: ---
20-
// todo codecov has unused code from the migration
21-
'static/app/{components,views}/codecov/**/*.{js,mjs,ts,tsx}',
20+
// Prevent exception until we build out coverage
21+
'static/app/components/prevent/virtualRenderers/**/*.{js,ts,tsx}',
2222
// todo we currently keep all icons
2323
'static/app/icons/**/*.{js,mjs,ts,tsx}',
2424
// todo find out how chartcuterie works

static/app/components/codecov/context/codecovContext.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.

static/app/components/codecov/branchSelector/branchSelector.tsx renamed to static/app/components/prevent/branchSelector/branchSelector.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import {useCallback, useEffect, useMemo, useState} from 'react';
22
import styled from '@emotion/styled';
33
import debounce from 'lodash/debounce';
44

5-
import {useInfiniteRepositoryBranches} from 'sentry/components/codecov/branchSelector/useInfiniteRepositoryBranches';
6-
import {useCodecovContext} from 'sentry/components/codecov/context/codecovContext';
75
import {Button} from 'sentry/components/core/button';
86
import type {SelectOption} from 'sentry/components/core/compactSelect';
97
import {CompactSelect} from 'sentry/components/core/compactSelect';
108
import {Flex} from 'sentry/components/core/layout';
119
import DropdownButton from 'sentry/components/dropdownButton';
10+
import {useInfiniteRepositoryBranches} from 'sentry/components/prevent/branchSelector/useInfiniteRepositoryBranches';
11+
import {usePreventContext} from 'sentry/components/prevent/context/preventContext';
1212
import {t} from 'sentry/locale';
1313
import {space} from 'sentry/styles/space';
1414

@@ -17,8 +17,8 @@ import {IconBranch} from './iconBranch';
1717
export const ALL_BRANCHES = 'All Branches';
1818

1919
export function BranchSelector() {
20-
const {branch, integratedOrgId, repository, codecovPeriod, changeContextValue} =
21-
useCodecovContext();
20+
const {branch, integratedOrgId, repository, preventPeriod, changeContextValue} =
21+
usePreventContext();
2222
const [searchValue, setSearchValue] = useState<string | undefined>();
2323
const {data} = useInfiniteRepositoryBranches({term: searchValue});
2424
const branches = data.branches;
@@ -29,11 +29,11 @@ export function BranchSelector() {
2929
changeContextValue({
3030
integratedOrgId,
3131
repository,
32-
codecovPeriod,
32+
preventPeriod,
3333
branch: selectedOption.value,
3434
});
3535
},
36-
[changeContextValue, integratedOrgId, repository, codecovPeriod]
36+
[changeContextValue, integratedOrgId, repository, preventPeriod]
3737
);
3838

3939
const handleOnSearch = useMemo(

static/app/components/codecov/branchSelector/useInfiniteRepositoryBranches.tsx renamed to static/app/components/prevent/branchSelector/useInfiniteRepositoryBranches.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {useMemo} from 'react';
22

33
import type {ApiResult} from 'sentry/api';
4-
import {useCodecovContext} from 'sentry/components/codecov/context/codecovContext';
4+
import {usePreventContext} from 'sentry/components/prevent/context/preventContext';
55
import {
66
fetchDataQuery,
77
type InfiniteData,
@@ -33,7 +33,7 @@ type Props = {
3333
};
3434

3535
export function useInfiniteRepositoryBranches({term}: Props) {
36-
const {integratedOrgId, repository} = useCodecovContext();
36+
const {integratedOrgId, repository} = usePreventContext();
3737
const organization = useOrganization();
3838

3939
const {data, ...rest} = useInfiniteQuery<

static/app/components/codecov/container/codecovParamsProvider.tsx renamed to static/app/components/prevent/container/preventParamsProvider.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import {useCallback} from 'react';
22
import {useSearchParams} from 'react-router-dom';
33

4-
import {ALL_BRANCHES} from 'sentry/components/codecov/branchSelector/branchSelector';
4+
import {ALL_BRANCHES} from 'sentry/components/prevent/branchSelector/branchSelector';
55
import type {
6-
CodecovContextData,
7-
CodecovContextDataParams,
8-
} from 'sentry/components/codecov/context/codecovContext';
9-
import {CodecovContext} from 'sentry/components/codecov/context/codecovContext';
6+
PreventContextData,
7+
PreventContextDataParams,
8+
} from 'sentry/components/prevent/context/preventContext';
9+
import {PreventContext} from 'sentry/components/prevent/context/preventContext';
1010
import {useLocalStorageState} from 'sentry/utils/useLocalStorageState';
1111
import useOrganization from 'sentry/utils/useOrganization';
1212

13-
type CodecovQueryParamsProviderProps = {
13+
type PreventQueryParamsProviderProps = {
1414
children?: NonNullable<React.ReactNode>;
1515
};
1616

@@ -20,25 +20,25 @@ type Org = {
2020
};
2121

2222
type LocalStorageState = Record<string, Org> & {
23-
codecovPeriod?: string;
2423
lastVisitedOrgId?: string;
24+
preventPeriod?: string;
2525
};
2626

2727
const VALUES_TO_RESET = ['repository', 'branch', 'testSuites'];
2828

29-
export default function CodecovQueryParamsProvider({
29+
export default function PreventQueryParamsProvider({
3030
children,
31-
}: CodecovQueryParamsProviderProps) {
31+
}: PreventQueryParamsProviderProps) {
3232
const organization = useOrganization();
3333
const initialLocalStorageState: LocalStorageState = {};
3434
const [localStorageState, setLocalStorageState] = useLocalStorageState(
35-
`codecov-selection:${organization.slug}`,
35+
`prevent-selection:${organization.slug}`,
3636
initialLocalStorageState
3737
);
3838

3939
const [searchParams, setSearchParams] = useSearchParams();
4040

41-
function _defineParams(): CodecovContextDataParams {
41+
function _defineParams(): PreventContextDataParams {
4242
const currentParams = Object.fromEntries(searchParams.entries());
4343

4444
const localStorageLastVisitedOrgId = localStorageState?.lastVisitedOrgId;
@@ -52,19 +52,19 @@ export default function CodecovQueryParamsProvider({
5252
(integratedOrgId ? localStorageState?.[integratedOrgId]?.branch : null) ||
5353
currentParams?.branch ||
5454
'All Branches';
55-
const codecovPeriod =
56-
currentParams?.codecovPeriod || localStorageState.codecovPeriod || '24h';
55+
const preventPeriod =
56+
currentParams?.preventPeriod || localStorageState.preventPeriod || '24h';
5757

5858
return {
5959
integratedOrgId,
6060
repository,
6161
branch,
62-
codecovPeriod,
62+
preventPeriod,
6363
};
6464
}
6565

6666
const changeContextValue = useCallback(
67-
(input: Partial<CodecovContextDataParams>) => {
67+
(input: Partial<PreventContextDataParams>) => {
6868
const currentParams = Object.fromEntries(searchParams.entries());
6969
const integratedOrgId = input.integratedOrgId;
7070

@@ -87,7 +87,7 @@ export default function CodecovQueryParamsProvider({
8787
}
8888
}
8989

90-
newState.codecovPeriod = input.codecovPeriod ? input.codecovPeriod : '24h';
90+
newState.preventPeriod = input.preventPeriod ? input.preventPeriod : '24h';
9191

9292
return newState;
9393
});
@@ -102,15 +102,15 @@ export default function CodecovQueryParamsProvider({
102102
[searchParams, setLocalStorageState, setSearchParams]
103103
);
104104

105-
const {integratedOrgId, repository, branch, codecovPeriod} = _defineParams();
105+
const {integratedOrgId, repository, branch, preventPeriod} = _defineParams();
106106

107-
const params: CodecovContextData = {
107+
const params: PreventContextData = {
108108
...(repository ? {repository} : {}),
109109
...(integratedOrgId ? {integratedOrgId} : {}),
110110
...(branch ? {branch} : {}),
111-
codecovPeriod,
111+
preventPeriod,
112112
changeContextValue,
113113
};
114114

115-
return <CodecovContext.Provider value={params}>{children}</CodecovContext.Provider>;
115+
return <PreventContext.Provider value={params}>{children}</PreventContext.Provider>;
116116
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {createContext, useContext} from 'react';
2+
3+
export type PreventContextData = {
4+
changeContextValue: (value: Partial<PreventContextDataParams>) => void;
5+
preventPeriod: string;
6+
branch?: string;
7+
integratedOrgId?: string;
8+
lastVisitedOrgId?: string;
9+
repository?: string;
10+
};
11+
12+
export type PreventContextDataParams = Omit<
13+
PreventContextData,
14+
'changeContextValue' | 'lastVisitedOrgId'
15+
>;
16+
17+
export const PreventContext = createContext<PreventContextData | undefined>(undefined);
18+
19+
export function usePreventContext() {
20+
const context = useContext(PreventContext);
21+
if (context === undefined)
22+
throw new Error('usePreventContext was called outside of PreventProvider');
23+
return context;
24+
}

static/app/components/codecov/dateSelector/dateSelector.spec.tsx renamed to static/app/components/prevent/dateSelector/dateSelector.spec.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import {render, screen} from 'sentry-test/reactTestingLibrary';
22

3-
import CodecovQueryParamsProvider from 'sentry/components/codecov/container/codecovParamsProvider';
4-
import {DateSelector} from 'sentry/components/codecov/dateSelector/dateSelector';
3+
import PreventQueryParamsProvider from 'sentry/components/prevent/container/preventParamsProvider';
4+
import {DateSelector} from 'sentry/components/prevent/dateSelector/dateSelector';
55

66
describe('DateSelector', function () {
77
it('renders when given relative period', async function () {
88
render(
9-
<CodecovQueryParamsProvider>
9+
<PreventQueryParamsProvider>
1010
<DateSelector />
11-
</CodecovQueryParamsProvider>,
11+
</PreventQueryParamsProvider>,
1212
{
1313
initialRouterConfig: {
1414
location: {
15-
pathname: '/codecov/tests',
15+
pathname: '/prevent/tests',
1616
query: {
17-
codecovPeriod: '7d',
17+
preventPeriod: '7d',
1818
integratedOrgId: '123',
1919
repository: 'some-repository',
2020
},
@@ -27,15 +27,15 @@ describe('DateSelector', function () {
2727

2828
it('renders when given an invalid relative period', async function () {
2929
render(
30-
<CodecovQueryParamsProvider>
30+
<PreventQueryParamsProvider>
3131
<DateSelector />
32-
</CodecovQueryParamsProvider>,
32+
</PreventQueryParamsProvider>,
3333
{
3434
initialRouterConfig: {
3535
location: {
36-
pathname: '/codecov/tests',
36+
pathname: '/prevent/tests',
3737
query: {
38-
codecovPeriod: '1y',
38+
preventPeriod: '1y',
3939
integratedOrgId: '123',
4040
repository: 'some-repository',
4141
},

static/app/components/codecov/dateSelector/dateSelector.tsx renamed to static/app/components/prevent/dateSelector/dateSelector.tsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
11
import {useCallback, useMemo} from 'react';
22
import styled from '@emotion/styled';
33

4-
import {useCodecovContext} from 'sentry/components/codecov/context/codecovContext';
54
import type {SelectOption} from 'sentry/components/core/compactSelect';
65
import {CompactSelect} from 'sentry/components/core/compactSelect';
76
import {Flex} from 'sentry/components/core/layout';
87
import DropdownButton from 'sentry/components/dropdownButton';
8+
import {usePreventContext} from 'sentry/components/prevent/context/preventContext';
99
import {getArbitraryRelativePeriod} from 'sentry/components/timeRangeSelector/utils';
1010
import {IconCalendar} from 'sentry/icons/iconCalendar';
1111
import {t} from 'sentry/locale';
1212

13-
export const CODECOV_DEFAULT_RELATIVE_PERIODS = {
13+
const PREVENT_DEFAULT_RELATIVE_PERIODS = {
1414
'24h': t('Last 24 hours'),
1515
'7d': t('Last 7 days'),
1616
'30d': t('Last 30 days'),
1717
};
1818

19-
export type CodecovPeriodOptions = keyof typeof CODECOV_DEFAULT_RELATIVE_PERIODS;
20-
2119
export function DateSelector() {
22-
const {codecovPeriod, changeContextValue} = useCodecovContext();
20+
const {preventPeriod, changeContextValue} = usePreventContext();
2321

2422
const handleChange = useCallback(
2523
(selectedOption: SelectOption<string>) => {
26-
changeContextValue({codecovPeriod: selectedOption.value});
24+
changeContextValue({preventPeriod: selectedOption.value});
2725
},
2826
[changeContextValue]
2927
);
3028

3129
const options = useMemo((): Array<SelectOption<string>> => {
32-
const currentAndDefaultCodecovPeriods = {
33-
...getArbitraryRelativePeriod(codecovPeriod),
34-
...CODECOV_DEFAULT_RELATIVE_PERIODS,
30+
const currentAndDefaultPreventPeriods = {
31+
...getArbitraryRelativePeriod(preventPeriod),
32+
...PREVENT_DEFAULT_RELATIVE_PERIODS,
3533
};
3634

37-
return Object.entries(currentAndDefaultCodecovPeriods).map(
35+
return Object.entries(currentAndDefaultPreventPeriods).map(
3836
([key, value]): SelectOption<string> => {
3937
return {
4038
value: key,
@@ -43,24 +41,24 @@ export function DateSelector() {
4341
};
4442
}
4543
);
46-
}, [codecovPeriod]);
44+
}, [preventPeriod]);
4745

4846
return (
4947
<CompactSelect
5048
disableSearchFilter
5149
options={options}
52-
value={codecovPeriod ?? ''}
50+
value={preventPeriod ?? ''}
5351
onChange={handleChange}
5452
menuWidth={'16rem'}
5553
trigger={(triggerProps, isOpen) => {
56-
const defaultLabel = options.some(item => item.value === codecovPeriod)
57-
? codecovPeriod?.toUpperCase()
54+
const defaultLabel = options.some(item => item.value === preventPeriod)
55+
? preventPeriod?.toUpperCase()
5856
: t('Invalid Period');
5957

6058
return (
6159
<DropdownButton
6260
isOpen={isOpen}
63-
data-test-id="codecov-time-selector"
61+
data-test-id="prevent-time-selector"
6462
{...triggerProps}
6563
>
6664
<TriggerLabelWrap>

0 commit comments

Comments
 (0)