Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ export interface ApplicationLauncherProps extends React.HTMLProps<HTMLDivElement
className?: string;
/** Display menu above or below dropdown toggle */
direction?: DropdownDirection | 'up' | 'down';
/**
* @deprecated
* Use the items prop instead
*
* Array of DropdownItem nodes that will be rendered in the dropdown Menu list
*/
dropdownItems?: React.ReactNode[];
/** Array of application launcher items */
items?: React.ReactNode[];
/** Render Application launcher toggle as disabled icon */
Expand Down Expand Up @@ -67,9 +60,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
className: '',
isDisabled: false,
direction: DropdownDirection.down,
dropdownItems: [] as React.ReactNode[],
favorites: [] as string[],
items: [] as React.ReactNode[],
isOpen: false,
position: DropdownPosition.left,
/* eslint-disable @typescript-eslint/no-unused-vars */
Expand Down Expand Up @@ -154,7 +145,6 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
isDisabled,
className,
isGrouped,
dropdownItems,
favorites,
onFavorite,
onSearch,
Expand Down Expand Up @@ -190,7 +180,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
} else {
renderableItems = items;
}
if (items.length === 0 && dropdownItems.length === 0) {
if (items.length === 0) {
renderableItems = [
<ApplicationLauncherGroup key="no-results-group">
<ApplicationLauncherItem key="no-results">{searchNoResultsText}</ApplicationLauncherItem>
Expand Down Expand Up @@ -221,7 +211,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
>
<DropdownWithContext
{...props}
dropdownItems={renderableItems.length ? renderableItems : dropdownItems}
dropdownItems={renderableItems}
isOpen={isOpen}
className={className}
aria-label={ariaLabel}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,49 @@ import React from 'react';
import { mount } from 'enzyme';
import { HelpIcon } from '@patternfly/react-icons';
import { ApplicationLauncher } from '../ApplicationLauncher';
import { DropdownItem } from '../../Dropdown/DropdownItem';
import { ApplicationLauncherItem } from '../ApplicationLauncherItem';

import { DropdownPosition, DropdownDirection } from '../../Dropdown/dropdownConstants';
import { DropdownSeparator } from '../../Dropdown/DropdownSeparator';
import { ApplicationLauncherSeparator } from '../ApplicationLauncherSeparator';

const dropdownItems = [
<DropdownItem key="link">Link</DropdownItem>,
<DropdownItem key="action" component="button">
<ApplicationLauncherItem key="link">Link</ApplicationLauncherItem>,
<ApplicationLauncherItem key="action" component="button">
Action
</DropdownItem>,
<DropdownItem key="disabled link" isDisabled>
</ApplicationLauncherItem>,
<ApplicationLauncherItem key="disabled link" isDisabled>
Disabled Link
</DropdownItem>,
<DropdownItem key="disabled action" isDisabled component="button">
</ApplicationLauncherItem>,
<ApplicationLauncherItem key="disabled action" isDisabled component="button">
Disabled Action
</DropdownItem>,
<DropdownSeparator key="separator" />,
<DropdownItem key="separated link">Separated Link</DropdownItem>,
<DropdownItem key="separated action" component="button">
</ApplicationLauncherItem>,
<ApplicationLauncherSeparator key="separator" />,
<ApplicationLauncherItem key="separated link">Separated Link</ApplicationLauncherItem>,
<ApplicationLauncherItem key="separated action" component="button">
Separated Action
</DropdownItem>
</ApplicationLauncherItem>
];

describe('ApplicationLauncher', () => {
test('regular', () => {
const view = mount(<ApplicationLauncher dropdownItems={dropdownItems} />);
const view = mount(<ApplicationLauncher items={dropdownItems} />);
expect(view).toMatchSnapshot();
});

test('right aligned', () => {
const view = mount(<ApplicationLauncher dropdownItems={dropdownItems} position={DropdownPosition.right} />);
const view = mount(<ApplicationLauncher items={dropdownItems} position={DropdownPosition.right} />);
expect(view).toMatchSnapshot();
});

test('dropup', () => {
const view = mount(<ApplicationLauncher dropdownItems={dropdownItems} direction={DropdownDirection.up} />);
const view = mount(<ApplicationLauncher items={dropdownItems} direction={DropdownDirection.up} />);
expect(view).toMatchSnapshot();
});

test('dropup + right aligned', () => {
const view = mount(
<ApplicationLauncher
dropdownItems={dropdownItems}
items={dropdownItems}
direction={DropdownDirection.up}
position={DropdownPosition.right}
/>
Expand All @@ -53,13 +53,13 @@ describe('ApplicationLauncher', () => {
});

test('expanded', () => {
const view = mount(<ApplicationLauncher dropdownItems={dropdownItems} isOpen />);
const view = mount(<ApplicationLauncher items={dropdownItems} isOpen />);
expect(view).toMatchSnapshot();
});

test('custom icon', () => {
const view = mount(
<ApplicationLauncher dropdownItems={dropdownItems} isOpen toggleIcon={<HelpIcon id="test-icon" />} />
<ApplicationLauncher items={dropdownItems} isOpen toggleIcon={<HelpIcon id="test-icon" />} />
);
expect(view).toMatchSnapshot();
});
Expand Down
Loading