Merge pull request #8230 from nixocio/ui_issue_7751

Add username to tooltip

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-10-19 17:20:01 +00:00 committed by GitHub
commit 5c751f3f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

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