-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat(errors): main body content sections #112139
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
838d6e3
add body elements to errors page content
nikkikapadia 6dd2079
add schema hints section to the filter content (so i don't forget) + …
nikkikapadia cc595b7
add tests for new page content
nikkikapadia 7360ea8
make general hook for expandable control section
nikkikapadia df461c1
add in errors schema hints options
nikkikapadia a1263cd
clean up code around new hook
nikkikapadia 4f5a81a
Merge branch 'master' into nikki/errors/visualize-sidebar
nikkikapadia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary'; | ||
|
|
||
| import {ErrorsContentSection, ErrorsControlSection} from './body'; | ||
|
|
||
| describe('ErrorsControlSection', () => { | ||
| beforeEach(() => { | ||
| localStorage.clear(); | ||
| }); | ||
|
|
||
| it('renders as an aside element', () => { | ||
| render(<ErrorsControlSection controlSectionExpanded />); | ||
| expect(screen.getByRole('complementary')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('ErrorsContentSection', () => { | ||
| it('renders collapse sidebar button when expanded', () => { | ||
| const setControlSectionExpanded = jest.fn(); | ||
| render( | ||
| <ErrorsContentSection | ||
| controlSectionExpanded | ||
| setControlSectionExpanded={setControlSectionExpanded} | ||
| /> | ||
| ); | ||
|
|
||
| const collapseButton = screen.getByRole('button', {name: 'Collapse sidebar'}); | ||
| expect(collapseButton).toBeInTheDocument(); | ||
| expect(collapseButton).not.toHaveTextContent('Advanced'); | ||
| }); | ||
|
|
||
| it('renders expand sidebar button when collapsed', () => { | ||
| const setControlSectionExpanded = jest.fn(); | ||
| render( | ||
| <ErrorsContentSection | ||
| controlSectionExpanded={false} | ||
| setControlSectionExpanded={setControlSectionExpanded} | ||
| /> | ||
| ); | ||
|
|
||
| const expandButton = screen.getByRole('button', {name: 'Expand sidebar'}); | ||
| expect(expandButton).toBeInTheDocument(); | ||
| expect(expandButton).toHaveTextContent('Advanced'); | ||
| }); | ||
|
|
||
| it('calls setControlSectionExpanded when clicking collapse button', async () => { | ||
| const setControlSectionExpanded = jest.fn(); | ||
| render( | ||
| <ErrorsContentSection | ||
| controlSectionExpanded | ||
| setControlSectionExpanded={setControlSectionExpanded} | ||
| /> | ||
| ); | ||
|
|
||
| await userEvent.click(screen.getByRole('button', {name: 'Collapse sidebar'})); | ||
| expect(setControlSectionExpanded).toHaveBeenCalledWith(false); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import {IconChevron} from 'sentry/icons/iconChevron'; | ||
| import {t} from 'sentry/locale'; | ||
| import {OverChartButtonGroup} from 'sentry/views/explore/components/overChartButtonGroup'; | ||
| import { | ||
| ExploreContentSection, | ||
| ExploreControlSection, | ||
| } from 'sentry/views/explore/components/styles'; | ||
| import {ChevronButton} from 'sentry/views/explore/spans/spansTab'; | ||
|
|
||
| interface ErrorsControlSectionProps { | ||
| controlSectionExpanded: boolean; | ||
| } | ||
|
|
||
| export function ErrorsControlSection({ | ||
| controlSectionExpanded, | ||
| }: ErrorsControlSectionProps) { | ||
| return <ExploreControlSection expanded={controlSectionExpanded} />; | ||
| } | ||
|
|
||
| interface ErrorsContentSectionProps { | ||
| controlSectionExpanded: boolean; | ||
| setControlSectionExpanded: (expanded: boolean) => void; | ||
| } | ||
|
|
||
| export function ErrorsContentSection({ | ||
| controlSectionExpanded, | ||
| setControlSectionExpanded, | ||
| }: ErrorsContentSectionProps) { | ||
| return ( | ||
| <ExploreContentSection> | ||
| <OverChartButtonGroup> | ||
| <ChevronButton | ||
| aria-label={ | ||
| controlSectionExpanded ? t('Collapse sidebar') : t('Expand sidebar') | ||
| } | ||
| expanded={controlSectionExpanded} | ||
| size="xs" | ||
| icon={ | ||
| <IconChevron | ||
| isDouble | ||
| direction={controlSectionExpanded ? 'left' : 'right'} | ||
| size="xs" | ||
| /> | ||
| } | ||
| onClick={() => setControlSectionExpanded(!controlSectionExpanded)} | ||
| > | ||
| {controlSectionExpanded ? null : t('Advanced')} | ||
| </ChevronButton> | ||
| </OverChartButtonGroup> | ||
| </ExploreContentSection> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
static/app/views/explore/hooks/useControlSectionExpanded.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import {useCallback} from 'react'; | ||
|
|
||
| import {useLocalStorageState} from 'sentry/utils/useLocalStorageState'; | ||
|
|
||
| export function useControlSectionExpanded(localStorageKey: string) { | ||
| const [controlSectionExpanded, _setControlSectionExpanded] = useLocalStorageState( | ||
| localStorageKey, | ||
| 'expanded' | ||
| ); | ||
|
|
||
| const setControlSectionExpanded = useCallback( | ||
| (expanded: boolean) => { | ||
| _setControlSectionExpanded(expanded ? 'expanded' : ''); | ||
| }, | ||
| [_setControlSectionExpanded] | ||
| ); | ||
|
|
||
| return [controlSectionExpanded === 'expanded', setControlSectionExpanded] as const; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.