mirror of
https://github.com/ansible/awx.git
synced 2026-01-23 07:28:02 -03:30
Merge pull request #9406 from nixocio/ui_issue_9323
Do not show tooltip with empty content Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
fe605596b5
@ -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