mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 12:20:45 -03:30
Add username to tooltip
Add username to tooltip when user cannot be deleted. See: https://github.com/ansible/awx/issues/7751
This commit is contained in:
parent
d6f0e16b4d
commit
98b9d4358d
@ -87,7 +87,7 @@ function ToolbarDeleteButton({
|
||||
const renderTooltip = () => {
|
||||
const itemsUnableToDelete = itemsToDelete
|
||||
.filter(cannotDelete)
|
||||
.map(item => item.name)
|
||||
.map(item => item.name || item.username)
|
||||
.join(', ');
|
||||
if (itemsToDelete.some(cannotDelete)) {
|
||||
return (
|
||||
|
||||
@ -12,6 +12,11 @@ const itemB = {
|
||||
name: 'Foo',
|
||||
summary_fields: { user_capabilities: { delete: false } },
|
||||
};
|
||||
const itemC = {
|
||||
id: 1,
|
||||
username: 'Foo',
|
||||
summary_fields: { user_capabilities: { delete: false } },
|
||||
};
|
||||
|
||||
describe('<ToolbarDeleteButton />', () => {
|
||||
test('should render button', () => {
|
||||
@ -61,4 +66,14 @@ describe('<ToolbarDeleteButton />', () => {
|
||||
expect(wrapper.find('Tooltip')).toHaveLength(1);
|
||||
expect(wrapper.find('Tooltip').prop('content')).toEqual('Delete');
|
||||
});
|
||||
|
||||
test('should render tooltip for username', () => {
|
||||
const wrapper = mountWithContexts(
|
||||
<ToolbarDeleteButton onDelete={() => {}} itemsToDelete={[itemC]} />
|
||||
);
|
||||
expect(wrapper.find('Tooltip')).toHaveLength(1);
|
||||
expect(wrapper.find('Tooltip').prop('content').props.children).toEqual(
|
||||
'You do not have permission to delete Items: Foo'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user