Skip to content

Commit d156eb4

Browse files
tlabajTitani
andauthored
refactor(ApplicationLauncher): Removed the deprecated prop dropdownItems (#3929)
* refactor(ApplicationLauncher): Removed the deprecated prop dropdownItems #2582 * rebase Co-authored-by: Titani <tlabaj@redaht.com>
1 parent ab06daf commit d156eb4

File tree

4 files changed

+809
-657
lines changed

4 files changed

+809
-657
lines changed

packages/react-core/src/components/ApplicationLauncher/ApplicationLauncher.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ export interface ApplicationLauncherProps extends React.HTMLProps<HTMLDivElement
1414
className?: string;
1515
/** Display menu above or below dropdown toggle */
1616
direction?: DropdownDirection | 'up' | 'down';
17-
/**
18-
* @deprecated
19-
* Use the items prop instead
20-
*
21-
* Array of DropdownItem nodes that will be rendered in the dropdown Menu list
22-
*/
23-
dropdownItems?: React.ReactNode[];
2417
/** Array of application launcher items */
2518
items?: React.ReactNode[];
2619
/** Render Application launcher toggle as disabled icon */
@@ -67,9 +60,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
6760
className: '',
6861
isDisabled: false,
6962
direction: DropdownDirection.down,
70-
dropdownItems: [] as React.ReactNode[],
7163
favorites: [] as string[],
72-
items: [] as React.ReactNode[],
7364
isOpen: false,
7465
position: DropdownPosition.left,
7566
/* eslint-disable @typescript-eslint/no-unused-vars */
@@ -154,7 +145,6 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
154145
isDisabled,
155146
className,
156147
isGrouped,
157-
dropdownItems,
158148
favorites,
159149
onFavorite,
160150
onSearch,
@@ -190,7 +180,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
190180
} else {
191181
renderableItems = items;
192182
}
193-
if (items.length === 0 && dropdownItems.length === 0) {
183+
if (items.length === 0) {
194184
renderableItems = [
195185
<ApplicationLauncherGroup key="no-results-group">
196186
<ApplicationLauncherItem key="no-results">{searchNoResultsText}</ApplicationLauncherItem>
@@ -221,7 +211,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
221211
>
222212
<DropdownWithContext
223213
{...props}
224-
dropdownItems={renderableItems.length ? renderableItems : dropdownItems}
214+
dropdownItems={renderableItems}
225215
isOpen={isOpen}
226216
className={className}
227217
aria-label={ariaLabel}

packages/react-core/src/components/ApplicationLauncher/__tests__/ApplicationLauncher.test.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,49 @@ import React from 'react';
22
import { mount } from 'enzyme';
33
import { HelpIcon } from '@patternfly/react-icons';
44
import { ApplicationLauncher } from '../ApplicationLauncher';
5-
import { DropdownItem } from '../../Dropdown/DropdownItem';
5+
import { ApplicationLauncherItem } from '../ApplicationLauncherItem';
66

77
import { DropdownPosition, DropdownDirection } from '../../Dropdown/dropdownConstants';
8-
import { DropdownSeparator } from '../../Dropdown/DropdownSeparator';
8+
import { ApplicationLauncherSeparator } from '../ApplicationLauncherSeparator';
99

1010
const dropdownItems = [
11-
<DropdownItem key="link">Link</DropdownItem>,
12-
<DropdownItem key="action" component="button">
11+
<ApplicationLauncherItem key="link">Link</ApplicationLauncherItem>,
12+
<ApplicationLauncherItem key="action" component="button">
1313
Action
14-
</DropdownItem>,
15-
<DropdownItem key="disabled link" isDisabled>
14+
</ApplicationLauncherItem>,
15+
<ApplicationLauncherItem key="disabled link" isDisabled>
1616
Disabled Link
17-
</DropdownItem>,
18-
<DropdownItem key="disabled action" isDisabled component="button">
17+
</ApplicationLauncherItem>,
18+
<ApplicationLauncherItem key="disabled action" isDisabled component="button">
1919
Disabled Action
20-
</DropdownItem>,
21-
<DropdownSeparator key="separator" />,
22-
<DropdownItem key="separated link">Separated Link</DropdownItem>,
23-
<DropdownItem key="separated action" component="button">
20+
</ApplicationLauncherItem>,
21+
<ApplicationLauncherSeparator key="separator" />,
22+
<ApplicationLauncherItem key="separated link">Separated Link</ApplicationLauncherItem>,
23+
<ApplicationLauncherItem key="separated action" component="button">
2424
Separated Action
25-
</DropdownItem>
25+
</ApplicationLauncherItem>
2626
];
2727

2828
describe('ApplicationLauncher', () => {
2929
test('regular', () => {
30-
const view = mount(<ApplicationLauncher dropdownItems={dropdownItems} />);
30+
const view = mount(<ApplicationLauncher items={dropdownItems} />);
3131
expect(view).toMatchSnapshot();
3232
});
3333

3434
test('right aligned', () => {
35-
const view = mount(<ApplicationLauncher dropdownItems={dropdownItems} position={DropdownPosition.right} />);
35+
const view = mount(<ApplicationLauncher items={dropdownItems} position={DropdownPosition.right} />);
3636
expect(view).toMatchSnapshot();
3737
});
3838

3939
test('dropup', () => {
40-
const view = mount(<ApplicationLauncher dropdownItems={dropdownItems} direction={DropdownDirection.up} />);
40+
const view = mount(<ApplicationLauncher items={dropdownItems} direction={DropdownDirection.up} />);
4141
expect(view).toMatchSnapshot();
4242
});
4343

4444
test('dropup + right aligned', () => {
4545
const view = mount(
4646
<ApplicationLauncher
47-
dropdownItems={dropdownItems}
47+
items={dropdownItems}
4848
direction={DropdownDirection.up}
4949
position={DropdownPosition.right}
5050
/>
@@ -53,13 +53,13 @@ describe('ApplicationLauncher', () => {
5353
});
5454

5555
test('expanded', () => {
56-
const view = mount(<ApplicationLauncher dropdownItems={dropdownItems} isOpen />);
56+
const view = mount(<ApplicationLauncher items={dropdownItems} isOpen />);
5757
expect(view).toMatchSnapshot();
5858
});
5959

6060
test('custom icon', () => {
6161
const view = mount(
62-
<ApplicationLauncher dropdownItems={dropdownItems} isOpen toggleIcon={<HelpIcon id="test-icon" />} />
62+
<ApplicationLauncher items={dropdownItems} isOpen toggleIcon={<HelpIcon id="test-icon" />} />
6363
);
6464
expect(view).toMatchSnapshot();
6565
});

0 commit comments

Comments
 (0)