Commit 39fddb6c authored by Fatih Acet's avatar Fatih Acet

Merge branch '13637-show-the-paths-for-groups-projects-in-productivity-analytics' into 'master'

Resolve "Show the paths for groups in productivity analytics"

Closes #13637

See merge request gitlab-org/gitlab-ee!15513
parents dd500aac 455ff45b
......@@ -73,11 +73,31 @@ export default {
<li>
<a href='#' class='dropdown-menu-link'>
${this.avatarTemplate(group)}
<div class="align-middle">${_.escape(group.name)}</div>
<div class="js-group-path align-middle">${this.formatGroupPath(
group.full_name,
)}</div>
</a>
</li>
`;
},
/**
* Formats the group's full name.
* It renders the last part (the part after the last backslash) of a group's full name as bold text.
* @returns String
*/
formatGroupPath(fullName) {
if (!fullName) {
return '';
}
const parts = fullName.split('/');
const lastPart = parts.length - 1;
return parts
.map((part, idx) =>
idx === lastPart ? `<strong>${_.escape(part.trim())}</strong>` : _.escape(part.trim()),
)
.join(' / ');
},
avatarTemplate(group) {
return group.avatar_url !== null
? renderAvatar(group, { sizeClass: 's16 rect-avatar' })
......
---
title: Show the paths for groups in groups dropdown
merge_request: 15513
author:
type: other
......@@ -14,11 +14,13 @@ const groups = [
{
id: 1,
name: 'foo',
full_name: 'foo',
avatar_url: `${TEST_HOST}/images/home/nasa.svg`,
},
{
id: 2,
name: 'foobar',
name: 'subgroup',
full_name: 'group / subgroup',
avatar_url: null,
},
];
......@@ -87,6 +89,15 @@ describe('GroupsDropdownFilter component', () => {
.contains('div.identicon'),
).toBe(true);
});
it('renders the full group name and highlights the last part', () => {
expect(
findDropdownItems()
.at(1)
.find('.js-group-path')
.html(),
).toContain('group / <strong>subgroup</strong>');
});
});
describe('on group click', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment