-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
ref(issue-views): Overhaul issue views state and logic to a new context #82429
Conversation
0ca20a8
to
71c94e0
Compare
import {NewTabContext, type NewView} from 'sentry/views/issueList/utils/newTabContext'; | ||
|
||
export interface Tab { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to IssueView
and moved to IssueViews.tsx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great to see all the state logic in one place! Good refactor!
); | ||
} | ||
|
||
export function IssueViews<T extends string | number>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extract this to a new file? We don't usually include components in util files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe rename this to issueViewsContext to be more descriptive? Might also be better to put everything together in an issueViews
folder or something so that this isn't floating off in the utils folder for the whole issue list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped this in /groupsearchviewtabs/ for now, but I do want to save bigger renamings and restructures for a separate PR since there are a bunch of other places where it could be improved.
} | ||
|
||
export const IssueViewsContext = createContext<IssueViewsContextType>({ | ||
rootProps: {orientation: 'horizontal'}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary to be in the context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of react-aria's tab context variables that I included since this context is essentially just a wrapper on that one. I copied the behavior from our base tabs component here.
Bundle ReportChanges will increase total bundle size by 39.07kB (0.12%) ⬆️. This is within the configured threshold ✅ Detailed changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work!
I deleted some of the analytics calls in [this refactoring change](#82429) and forgot to add them back. This PR adds them back. I found what the old analytics keys were [here](https://github.com/getsentry/sentry/blob/7cb3a89c7a0737ea5c53ab0a1e85b03c7d8dd4ee/static/app/views/issueList/groupSearchViewTabs/draggableTabBar.tsx)
) This PR refactors the issue views family of components by moving lots of the navigation logic into the IssueViews context created in [this PR](#82429). Many of the tab actions that were folded into the IssueViews context require changes to the query parameters, which is why it makes sense to combine these two actions in the reducer function. For example: * Duplicating a tab requires the newly created tab to be selected (change viewId parameter) * Discarding a tab's changes requires the query/sort to be reset to the original query/sort (change query/sort param
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
…xt (#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**
I deleted some of the analytics calls in [this refactoring change](#82429) and forgot to add them back. This PR adds them back. I found what the old analytics keys were [here](https://github.com/getsentry/sentry/blob/7cb3a89c7a0737ea5c53ab0a1e85b03c7d8dd4ee/static/app/views/issueList/groupSearchViewTabs/draggableTabBar.tsx)
) This PR refactors the issue views family of components by moving lots of the navigation logic into the IssueViews context created in [this PR](#82429). Many of the tab actions that were folded into the IssueViews context require changes to the query parameters, which is why it makes sense to combine these two actions in the reducer function. For example: * Duplicating a tab requires the newly created tab to be selected (change viewId parameter) * Discarding a tab's changes requires the query/sort to be reset to the original query/sort (change query/sort param
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:IssueViews
, that extends the oldTabs
context. This new context now contains the views and temporary tabs stateuseReducer
within theIssueViews
context