Skip to content

Commit 5e555e1

Browse files
ref(ui): Remove dropdown feature from breadcrumbs (#98074)
This is unused on our standard breadcrumb component. It was reusing a dropdown breadcrumb from the settings breadcrumbs, which use a different component implementation from our usual breadcrumbs.
1 parent fa12e6f commit 5e555e1

File tree

5 files changed

+5
-109
lines changed

5 files changed

+5
-109
lines changed

static/app/components/breadcrumbs.spec.tsx

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -61,42 +61,4 @@ describe('Breadcrumbs', () => {
6161
await userEvent.click(screen.getByText('Test 3'));
6262
expect(router.push).not.toHaveBeenCalled();
6363
});
64-
65-
it('renders a crumb dropdown', async () => {
66-
const onSelect = jest.fn();
67-
render(
68-
<Breadcrumbs
69-
crumbs={[
70-
{
71-
label: 'dropdown crumb',
72-
onSelect,
73-
items: [
74-
{index: 0, value: 'item1', label: 'item1'},
75-
{index: 1, value: 'item2', label: 'item2'},
76-
{index: 2, value: 'item3', label: 'item3'},
77-
],
78-
},
79-
{
80-
label: 'Test 2',
81-
to: '/test2',
82-
},
83-
{
84-
label: 'Test 3',
85-
to: null,
86-
},
87-
]}
88-
/>,
89-
{
90-
router,
91-
deprecatedRouterMocks: true,
92-
}
93-
);
94-
await userEvent.hover(screen.getByText('dropdown crumb'));
95-
96-
const item3 = await screen.findByText('item3');
97-
expect(item3).toBeInTheDocument();
98-
99-
await userEvent.click(item3);
100-
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({label: 'item3'}));
101-
});
10264
});

static/app/components/breadcrumbs.stories.tsx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,6 @@ export default Storybook.story('Breadcrumbs', story => {
4343
</Fragment>
4444
));
4545

46-
story('With Dropdown', () => (
47-
<Fragment>
48-
<p>
49-
Breadcrumbs can include dropdown menus for selecting between multiple options.
50-
</p>
51-
<Storybook.SizingWindow display="block" style={{minHeight: '250px'}}>
52-
<Breadcrumbs
53-
crumbs={[
54-
{label: 'Organization', to: '/organizations/sentry/'},
55-
{
56-
label: 'Select Project',
57-
items: [
58-
{index: 0, value: 'javascript', label: 'JavaScript Project'},
59-
{index: 1, value: 'python', label: 'Python Project'},
60-
{index: 2, value: 'react', label: 'React Project'},
61-
],
62-
onSelect: item => {
63-
// eslint-disable-next-line no-console
64-
console.log('Selected:', item);
65-
},
66-
},
67-
{label: 'Settings', to: null},
68-
]}
69-
/>
70-
</Storybook.SizingWindow>
71-
</Fragment>
72-
));
73-
7446
story('Page Filter Preservation', () => (
7547
<Fragment>
7648
<p>

static/app/components/breadcrumbs.tsx

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import type {LinkProps} from 'sentry/components/core/link';
88
import {Link} from 'sentry/components/core/link';
99
import GlobalSelectionLink from 'sentry/components/globalSelectionLink';
1010
import {space} from 'sentry/styles/space';
11-
import type {BreadcrumbDropdownProps} from 'sentry/views/settings/components/settingsBreadcrumb/breadcrumbDropdown';
12-
import BreadcrumbDropdown from 'sentry/views/settings/components/settingsBreadcrumb/breadcrumbDropdown';
1311

1412
const BreadcrumbList = styled('nav')`
1513
display: flex;
@@ -41,28 +39,11 @@ export interface Crumb {
4139
to?: LinkProps['to'] | null;
4240
}
4341

44-
export interface CrumbDropdown {
45-
/**
46-
* Items of the crumb dropdown
47-
*/
48-
items: BreadcrumbDropdownProps['items'];
49-
50-
/**
51-
* Name of the crumb
52-
*/
53-
label: React.ReactNode;
54-
55-
/**
56-
* Callback function for when an item is selected
57-
*/
58-
onSelect: BreadcrumbDropdownProps['onSelect'];
59-
}
60-
6142
interface Props extends React.HTMLAttributes<HTMLDivElement> {
6243
/**
6344
* Array of crumbs that will be rendered
6445
*/
65-
crumbs: Array<Crumb | CrumbDropdown>;
46+
crumbs: Crumb[];
6647

6748
/**
6849
* As a general rule of thumb we don't want the last item to be link as it most likely
@@ -73,10 +54,6 @@ interface Props extends React.HTMLAttributes<HTMLDivElement> {
7354
linkLastItem?: boolean;
7455
}
7556

76-
function isCrumbDropdown(crumb: Crumb | CrumbDropdown): crumb is CrumbDropdown {
77-
return (crumb as CrumbDropdown).items !== undefined;
78-
}
79-
8057
/**
8158
* Page breadcrumbs used for navigation, not to be confused with sentry's event breadcrumbs
8259
*/
@@ -86,27 +63,12 @@ export function Breadcrumbs({crumbs, linkLastItem = false, ...props}: Props) {
8663
}
8764

8865
if (!linkLastItem) {
89-
const lastCrumb = crumbs[crumbs.length - 1]!;
90-
if (!isCrumbDropdown(lastCrumb)) {
91-
lastCrumb.to = null;
92-
}
66+
crumbs[crumbs.length - 1]!.to = null;
9367
}
9468

9569
return (
9670
<BreadcrumbList {...props} data-test-id="breadcrumb-list">
9771
{crumbs.map((crumb, index) => {
98-
if (isCrumbDropdown(crumb)) {
99-
const {label, ...crumbProps} = crumb;
100-
return (
101-
<BreadcrumbDropdown
102-
key={index}
103-
isLast={index >= crumbs.length - 1}
104-
route={{}}
105-
name={label}
106-
{...crumbProps}
107-
/>
108-
);
109-
}
11072
const {label, to, preservePageFilters, key} = crumb;
11173
const labelKey = typeof label === 'string' ? label : '';
11274
const mapKey =

static/app/views/alerts/builder/builderBreadCrumbs.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {Crumb, CrumbDropdown} from 'sentry/components/breadcrumbs';
1+
import type {Crumb} from 'sentry/components/breadcrumbs';
22
import Breadcrumbs from 'sentry/components/breadcrumbs';
33
import {t} from 'sentry/locale';
44
import type {Organization} from 'sentry/types/organization';
@@ -12,7 +12,7 @@ interface Props {
1212
}
1313

1414
function BuilderBreadCrumbs({title, alertName, projectSlug, organization}: Props) {
15-
const crumbs: Array<Crumb | CrumbDropdown> = [
15+
const crumbs: Crumb[] = [
1616
{
1717
to: makeAlertsPathname({
1818
path: '/rules/',

static/app/views/settings/components/settingsBreadcrumb/breadcrumbDropdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface AdditionalDropdownProps
1313
'onChange' | 'busyItemsStillVisible'
1414
> {}
1515

16-
export interface BreadcrumbDropdownProps extends AdditionalDropdownProps {
16+
interface BreadcrumbDropdownProps extends AdditionalDropdownProps {
1717
items: Item[];
1818
name: React.ReactNode;
1919
onSelect: (item: Item) => void;

0 commit comments

Comments
 (0)