mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Do not show tooltip with empty content
Do not show tooltip with empty content. See: https://github.com/ansible/awx/issues/9323
This commit is contained in:
parent
615cc11d0d
commit
bf601fc988
@ -53,13 +53,21 @@ export default function StatusLabel({ status, tooltipContent = '' }) {
|
||||
const color = colors[status] || 'grey';
|
||||
const Icon = icons[status];
|
||||
|
||||
const renderLabel = () => (
|
||||
<Label variant="outline" color={color} icon={Icon ? <Icon /> : null}>
|
||||
{label}
|
||||
</Label>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Tooltip content={tooltipContent} position="top">
|
||||
<Label variant="outline" color={color} icon={Icon ? <Icon /> : null}>
|
||||
{label}
|
||||
</Label>
|
||||
</Tooltip>
|
||||
{tooltipContent ? (
|
||||
<Tooltip content={tooltipContent} position="top">
|
||||
{renderLabel()}
|
||||
</Tooltip>
|
||||
) : (
|
||||
renderLabel()
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ describe('StatusLabel', () => {
|
||||
expect(wrapper.find('CheckCircleIcon')).toHaveLength(1);
|
||||
expect(wrapper.find('Label').prop('color')).toEqual('green');
|
||||
expect(wrapper.text()).toEqual('Success');
|
||||
expect(wrapper.find('Tooltip')).toHaveLength(0);
|
||||
});
|
||||
|
||||
test('should render failed', () => {
|
||||
@ -58,4 +59,16 @@ describe('StatusLabel', () => {
|
||||
expect(wrapper.find('Label').prop('color')).toEqual('orange');
|
||||
expect(wrapper.text()).toEqual('Canceled');
|
||||
});
|
||||
|
||||
test('should render tooltip', () => {
|
||||
const wrapper = mount(
|
||||
<StatusLabel tooltipContent="Foo" status="success" />
|
||||
);
|
||||
expect(wrapper).toHaveLength(1);
|
||||
expect(wrapper.find('CheckCircleIcon')).toHaveLength(1);
|
||||
expect(wrapper.find('Label').prop('color')).toEqual('green');
|
||||
expect(wrapper.text()).toEqual('Success');
|
||||
expect(wrapper.find('Tooltip')).toHaveLength(1);
|
||||
expect(wrapper.find('Tooltip').prop('content')).toEqual('Foo');
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user