Skip to content

Commit 5723864

Browse files
committed
feat(errors): create errors toolbar components
1 parent 091afea commit 5723864

File tree

10 files changed

+222
-7
lines changed

10 files changed

+222
-7
lines changed

static/app/views/explore/errors/body.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ExploreContentSection,
66
ExploreControlSection,
77
} from 'sentry/views/explore/components/styles';
8+
import {ErrorsToolbar} from 'sentry/views/explore/errors/toolbar';
89
import {ChevronButton} from 'sentry/views/explore/spans/spansTab';
910

1011
interface ErrorsControlSectionProps {
@@ -14,7 +15,11 @@ interface ErrorsControlSectionProps {
1415
export function ErrorsControlSection({
1516
controlSectionExpanded,
1617
}: ErrorsControlSectionProps) {
17-
return <ExploreControlSection expanded={controlSectionExpanded} />;
18+
return (
19+
<ExploreControlSection expanded={controlSectionExpanded}>
20+
<ErrorsToolbar />
21+
</ExploreControlSection>
22+
);
1823
}
1924

2025
interface ErrorsContentSectionProps {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {
2+
ToolbarFooter,
3+
ToolbarSection,
4+
} from 'sentry/views/explore/components/toolbar/styles';
5+
import {
6+
ToolbarGroupByAddGroupBy,
7+
ToolbarGroupByDropdown,
8+
ToolbarGroupByHeader,
9+
} from 'sentry/views/explore/components/toolbar/toolbarGroupBy';
10+
11+
export function ErrorsToolbarGroupBy() {
12+
return (
13+
<ToolbarSection data-test-id="section-group-by">
14+
<ToolbarGroupByHeader />
15+
<ToolbarGroupByItem />
16+
<ToolbarFooter>
17+
<ToolbarGroupByAddGroupBy add={() => {}} disabled={false} />
18+
</ToolbarFooter>
19+
</ToolbarSection>
20+
);
21+
}
22+
23+
function ToolbarGroupByItem() {
24+
return (
25+
<ToolbarGroupByDropdown
26+
column={{column: '', id: 0, uniqueId: '0'}}
27+
options={[{label: '-', value: '', textValue: '-'}]}
28+
loading={false}
29+
onClose={() => {}}
30+
onSearch={() => {}}
31+
canDelete={false}
32+
onColumnChange={() => {}}
33+
onColumnDelete={() => {}}
34+
/>
35+
);
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {Tooltip} from '@sentry/scraps/tooltip';
2+
3+
import {t} from 'sentry/locale';
4+
import {
5+
ToolbarHeader,
6+
ToolbarLabel,
7+
ToolbarRow,
8+
ToolbarSection,
9+
} from 'sentry/views/explore/components/toolbar/styles';
10+
import {
11+
ColumnCompactSelect,
12+
DirectionCompactSelect,
13+
} from 'sentry/views/explore/toolbar/toolbarSortBy';
14+
15+
export function ErrorsToolbarSortBy() {
16+
return (
17+
<ToolbarSection data-test-id="section-sort-by">
18+
<ToolbarHeader>
19+
<Tooltip
20+
position="right"
21+
title={t('Results you see first and last in your samples or aggregates.')}
22+
>
23+
<ToolbarLabel disabled={false}>{t('Sort By')}</ToolbarLabel>
24+
</Tooltip>
25+
</ToolbarHeader>
26+
<ToolbarRow>
27+
<ColumnCompactSelect options={[]} value="" onChange={() => {}} disabled={false} />
28+
<DirectionCompactSelect
29+
options={[
30+
{label: 'Desc', value: 'desc', textValue: 'desc'},
31+
{label: 'Asc', value: 'asc', textValue: 'asc'},
32+
]}
33+
value="desc"
34+
onChange={() => {}}
35+
disabled={false}
36+
/>
37+
</ToolbarRow>
38+
</ToolbarSection>
39+
);
40+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {Tooltip} from '@sentry/scraps/tooltip';
2+
3+
import {t} from 'sentry/locale';
4+
import {
5+
ToolbarFooter,
6+
ToolbarHeader,
7+
ToolbarLabel,
8+
ToolbarSection,
9+
} from 'sentry/views/explore/components/toolbar/styles';
10+
import {
11+
ToolbarVisualizeAddChart,
12+
ToolbarVisualizeAddEquation,
13+
} from 'sentry/views/explore/components/toolbar/toolbarVisualize';
14+
import {ErrorsToolbarVisualizeItem as ToolbarVisualizeItem} from 'sentry/views/explore/errors/toolbar/errorsToolbarVisualizeItem';
15+
16+
export function ErrorsToolbarVisualize() {
17+
return (
18+
<ToolbarSection data-test-id="section-visualizes">
19+
<ToolbarVisualizeHeader />
20+
<ToolbarVisualizeItem />
21+
<ToolbarFooter>
22+
<ToolbarVisualizeAddChart add={() => {}} disabled={false} />
23+
<ToolbarVisualizeAddEquation add={() => {}} disabled={false} />
24+
</ToolbarFooter>
25+
</ToolbarSection>
26+
);
27+
}
28+
29+
function ToolbarVisualizeHeader() {
30+
return (
31+
<ToolbarHeader>
32+
<Tooltip
33+
position="right"
34+
title={t(
35+
'Primary metric that appears in your chart. You can also overlay a series onto an existing chart or add an equation.'
36+
)}
37+
>
38+
<ToolbarLabel>{t('Visualize')}</ToolbarLabel>
39+
</Tooltip>
40+
</ToolbarHeader>
41+
);
42+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {ToolbarVisualizeDropdown} from 'sentry/views/explore/components/toolbar/toolbarVisualize';
2+
import {VisualizeFunction} from 'sentry/views/explore/queryParams/visualize';
3+
import {VisualizeLabel} from 'sentry/views/explore/toolbar/toolbarVisualize';
4+
5+
export function ErrorsToolbarVisualizeItem() {
6+
const sampleVisualize = new VisualizeFunction('count()', {visible: true});
7+
const label = (
8+
<VisualizeLabel index={0} visualize={sampleVisualize} onClick={() => {}} />
9+
);
10+
return (
11+
<ToolbarVisualizeDropdown
12+
aggregateOptions={[{label: 'Count', value: 'count', textValue: 'count'}]}
13+
fieldOptions={[]}
14+
onChangeAggregate={() => {}}
15+
onChangeArgument={() => {}}
16+
parsedFunction={sampleVisualize.parsedFunction}
17+
label={label}
18+
loading={false}
19+
onSearch={() => {}}
20+
onClose={() => {}}
21+
/>
22+
);
23+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import {render, screen, within} from 'sentry-test/reactTestingLibrary';
2+
3+
import {ErrorsToolbar} from 'sentry/views/explore/errors/toolbar';
4+
5+
describe('ErrorsToolbar', () => {
6+
it('renders the visualize section', async () => {
7+
render(<ErrorsToolbar />);
8+
9+
const section = await screen.findByTestId('section-visualizes');
10+
expect(within(section).getByText('Visualize')).toBeInTheDocument();
11+
expect(within(section).getByRole('button', {name: 'Count'})).toBeInTheDocument();
12+
expect(within(section).getByRole('button', {name: 'Add Chart'})).toBeInTheDocument();
13+
expect(
14+
within(section).getByRole('button', {name: 'Add Equation'})
15+
).toBeInTheDocument();
16+
});
17+
18+
it('renders the group by section', async () => {
19+
render(<ErrorsToolbar />);
20+
21+
const section = await screen.findByTestId('section-group-by');
22+
expect(within(section).getByTestId('editor-column')).toBeInTheDocument();
23+
expect(within(section).getByRole('button', {name: 'Add Group'})).toBeInTheDocument();
24+
});
25+
26+
it('renders the sort by section', async () => {
27+
render(<ErrorsToolbar />);
28+
29+
const section = await screen.findByTestId('section-sort-by');
30+
expect(within(section).getByText('Sort By')).toBeInTheDocument();
31+
expect(within(section).getByRole('button', {name: 'Desc'})).toBeInTheDocument();
32+
});
33+
34+
it('renders the save as section', async () => {
35+
render(<ErrorsToolbar />);
36+
37+
const section = await screen.findByTestId('section-save-as');
38+
expect(within(section).getByRole('button', {name: 'Save as'})).toBeInTheDocument();
39+
});
40+
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {Button} from '@sentry/scraps/button';
2+
import {Grid, Container} from '@sentry/scraps/layout';
3+
4+
import {t} from 'sentry/locale';
5+
import {ErrorsToolbarGroupBy} from 'sentry/views/explore/errors/toolbar/errorsToolbarGroupBy';
6+
import {ErrorsToolbarSortBy} from 'sentry/views/explore/errors/toolbar/errorsToolbarSortBy';
7+
import {ErrorsToolbarVisualize} from 'sentry/views/explore/errors/toolbar/errorsToolbarVisualize';
8+
import {SaveStyledToolbarSection} from 'sentry/views/explore/toolbar/toolbarSaveAs';
9+
10+
export function ErrorsToolbar() {
11+
return (
12+
<Container data-test-id="errors-toolbar">
13+
<ErrorsToolbarVisualize />
14+
<ErrorsToolbarGroupBy />
15+
<ErrorsToolbarSortBy />
16+
<ErrorsToolbarSaveAs />
17+
</Container>
18+
);
19+
}
20+
21+
function ErrorsToolbarSaveAs() {
22+
return (
23+
<SaveStyledToolbarSection data-test-id="section-save-as">
24+
<Grid flow="column" align="center" gap="md">
25+
<Button aria-label={t('Save as')}>{t('Save')}</Button>
26+
</Grid>
27+
</SaveStyledToolbarSection>
28+
);
29+
}

static/app/views/explore/toolbar/toolbarSaveAs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ export function ToolbarSaveAs() {
289289
const canCompareQueries = visualizeFunctions.length >= 2;
290290

291291
return (
292-
<StyledToolbarSection data-test-id="section-save-as">
292+
<SaveStyledToolbarSection data-test-id="section-save-as">
293293
<Grid flow="column" align="center" gap="md">
294294
<Tooltip
295295
disabled={!hasCrossEvents}
@@ -347,7 +347,7 @@ export function ToolbarSaveAs() {
347347
{t('Compare Queries')}
348348
</WideLinkButton>
349349
</Grid>
350-
</StyledToolbarSection>
350+
</SaveStyledToolbarSection>
351351
);
352352
}
353353

@@ -359,7 +359,7 @@ const DisabledText = styled('span')`
359359
color: ${p => p.theme.tokens.content.disabled};
360360
`;
361361

362-
const StyledToolbarSection = styled(ToolbarSection)`
362+
export const SaveStyledToolbarSection = styled(ToolbarSection)`
363363
border-top: 1px solid ${p => p.theme.tokens.border.primary};
364364
padding-top: ${p => p.theme.space['2xl']};
365365
`;

static/app/views/explore/toolbar/toolbarSortBy.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const FullWidthTooltip = styled(Tooltip)`
148148
width: 100%;
149149
`;
150150

151-
const ColumnCompactSelect = styled(CompactSelect)`
151+
export const ColumnCompactSelect = styled(CompactSelect)`
152152
flex: 1 1;
153153
min-width: 0;
154154
@@ -157,7 +157,7 @@ const ColumnCompactSelect = styled(CompactSelect)`
157157
}
158158
`;
159159

160-
const DirectionCompactSelect = styled(CompactSelect)`
160+
export const DirectionCompactSelect = styled(CompactSelect)`
161161
width: 90px;
162162
163163
> button {

static/app/views/explore/toolbar/toolbarVisualize.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ export function getVisualizeLabel(index: number) {
276276
return String.fromCharCode('A'.charCodeAt(0) + index);
277277
}
278278

279-
function VisualizeLabel({index, onClick, visualize}: VisualizeLabelProps) {
279+
export function VisualizeLabel({index, onClick, visualize}: VisualizeLabelProps) {
280280
const label = visualize.visible ? getVisualizeLabel(index) : <IconHide />;
281281

282282
return <Label onClick={onClick}>{label}</Label>;

0 commit comments

Comments
 (0)