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:
nixocio 2020-09-24 15:51:58 -04:00
parent d6f0e16b4d
commit 98b9d4358d
2 changed files with 16 additions and 1 deletions

View File

@ -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 (

View File

@ -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'
);
});
});