Skip to content

Commit e2ca54d

Browse files
authored
ref(issue-views): Overhaul issue views state and logic to a new context (#82429)
This PR makes a major code refactor to the Issue Views family of components. No functionality should be broken or otherwise altered. The purpose of this refactor was to move lots of reused code and duplicated state into one unified context, `IssueViews.tsx`. This allows the displayed components to be much much cleaner and easier to understand while making it easier to add new functionality in the future. The two primary things it does are: 1. **Creates a new context, `IssueViews`, that extends the old `Tabs` context. This new context now contains the views and temporary tabs state** 2. **Delegates almost all tab alteration logic to a `useReducer` within the `IssueViews` context**
1 parent 50688ca commit e2ca54d

File tree

5 files changed

+698
-501
lines changed

5 files changed

+698
-501
lines changed

Diff for: static/app/components/draggableTabs/draggableTabList.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {motion, Reorder} from 'framer-motion';
2323
import {Button} from 'sentry/components/button';
2424
import {CompactSelect} from 'sentry/components/compactSelect';
2525
import DropdownButton from 'sentry/components/dropdownButton';
26-
import {TabsContext} from 'sentry/components/tabs';
2726
import {type BaseTabProps, Tab} from 'sentry/components/tabs/tab';
2827
import {IconAdd, IconEllipsis} from 'sentry/icons';
2928
import {t} from 'sentry/locale';
@@ -34,6 +33,7 @@ import {useDimensions} from 'sentry/utils/useDimensions';
3433
import {useDimensionsMultiple} from 'sentry/utils/useDimensionsMultiple';
3534
import {useNavigate} from 'sentry/utils/useNavigate';
3635
import useOrganization from 'sentry/utils/useOrganization';
36+
import {IssueViewsContext} from 'sentry/views/issueList/groupSearchViewTabs/issueViews';
3737

3838
import type {DraggableTabListItemProps} from './item';
3939
import {Item} from './item';
@@ -273,7 +273,7 @@ function BaseDraggableTabList({
273273
}: BaseDraggableTabListProps) {
274274
const navigate = useNavigate();
275275
const [hoveringKey, setHoveringKey] = useState<Key | null>(null);
276-
const {rootProps, setTabListState} = useContext(TabsContext);
276+
const {rootProps, setTabListState} = useContext(IssueViewsContext);
277277
const organization = useOrganization();
278278
const {
279279
value,

Diff for: static/app/components/tabs/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export interface TabsProps<T>
4747
value?: T;
4848
}
4949

50-
interface TabContext {
50+
export interface TabContext {
5151
rootProps: Omit<TabsProps<any>, 'children' | 'className'>;
5252
setTabListState: (state: TabListState<any>) => void;
5353
tabListState?: TabListState<any>;

0 commit comments

Comments
 (0)