mirror of
https://github.com/ansible/awx.git
synced 2026-03-24 04:15:02 -02:30
Update AddDropDownButton to show down caret
Update AddDropDownButton to show down caret See: https://github.com/ansible/awx/issues/7721
This commit is contained in:
@@ -48,7 +48,12 @@ function AddDropDownButton({ dropdownItems, i18n }) {
|
|||||||
isPlain
|
isPlain
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
position={DropdownPosition.right}
|
position={DropdownPosition.right}
|
||||||
toggle={<ToolbarAddButton onClick={() => setIsOpen(!isOpen)} />}
|
toggle={
|
||||||
|
<ToolbarAddButton
|
||||||
|
showToggleIndicator
|
||||||
|
onClick={() => setIsOpen(!isOpen)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
dropdownItems={dropdownItems.map(item => (
|
dropdownItems={dropdownItems.map(item => (
|
||||||
<Link
|
<Link
|
||||||
className="pf-c-dropdown__menu-item"
|
className="pf-c-dropdown__menu-item"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import { string, func } from 'prop-types';
|
import { string, func } from 'prop-types';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { Button, DropdownItem, Tooltip } from '@patternfly/react-core';
|
import { Button, DropdownItem, Tooltip } from '@patternfly/react-core';
|
||||||
|
import CaretDownIcon from '@patternfly/react-icons/dist/js/icons/caret-down-icon';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { useKebabifiedMenu } from '../../contexts/Kebabified';
|
import { useKebabifiedMenu } from '../../contexts/Kebabified';
|
||||||
@@ -12,6 +13,7 @@ function ToolbarAddButton({
|
|||||||
i18n,
|
i18n,
|
||||||
isDisabled,
|
isDisabled,
|
||||||
defaultLabel = i18n._(t`Add`),
|
defaultLabel = i18n._(t`Add`),
|
||||||
|
showToggleIndicator,
|
||||||
}) {
|
}) {
|
||||||
const { isKebabified } = useKebabifiedMenu();
|
const { isKebabified } = useKebabifiedMenu();
|
||||||
|
|
||||||
@@ -50,7 +52,13 @@ function ToolbarAddButton({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Button variant="primary" aria-label={defaultLabel} onClick={onClick}>
|
<Button
|
||||||
|
icon={showToggleIndicator ? <CaretDownIcon /> : null}
|
||||||
|
iconPosition={showToggleIndicator ? 'right' : null}
|
||||||
|
variant="primary"
|
||||||
|
aria-label={defaultLabel}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
{defaultLabel}
|
{defaultLabel}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,4 +18,13 @@ describe('<ToolbarAddButton />', () => {
|
|||||||
expect(link).toHaveLength(1);
|
expect(link).toHaveLength(1);
|
||||||
expect(link.prop('to')).toBe('/foo');
|
expect(link.prop('to')).toBe('/foo');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should render link with toggle icon', () => {
|
||||||
|
const wrapper = mountWithContexts(
|
||||||
|
<ToolbarAddButton showToggleIndicator linkTo="/foo" />
|
||||||
|
);
|
||||||
|
const link = wrapper.find('Link');
|
||||||
|
expect(link).toHaveLength(1);
|
||||||
|
expect(link.prop('to')).toBe('/foo');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user