mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-11204] Fix: Duplicated site name is displayed instead of id when there are two libraries with the same name (#11682)
This commit is contained in:
@@ -285,5 +285,26 @@ describe('NodeTooltipUtils', () => {
|
||||
const result = NodeTooltipUtils.getLibraryTitle(library, allEntries);
|
||||
expect(result).toBe('Library Title');
|
||||
});
|
||||
|
||||
it('should append id as suffix when name is present and equals title', () => {
|
||||
const library = { id: 'lib1', name: 'Duplicate Title', title: 'Duplicate Title' };
|
||||
const allEntries = [{ id: 'lib2', title: 'Duplicate Title' }];
|
||||
const result = NodeTooltipUtils.getLibraryTitle(library, allEntries);
|
||||
expect(result).toBe('Duplicate Title (lib1)');
|
||||
});
|
||||
|
||||
it('should append id as suffix when name is missing', () => {
|
||||
const library = { id: 'lib1', title: 'Duplicate Title' };
|
||||
const allEntries = [{ id: 'lib2', title: 'Duplicate Title' }];
|
||||
const result = NodeTooltipUtils.getLibraryTitle(library, allEntries);
|
||||
expect(result).toBe('Duplicate Title (lib1)');
|
||||
});
|
||||
|
||||
it('should fallback to id when both name and title are missing', () => {
|
||||
const library = { id: 'lib1' };
|
||||
const allEntries = [];
|
||||
const result = NodeTooltipUtils.getLibraryTitle(library, allEntries);
|
||||
expect(result).toBe('lib1');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -120,7 +120,10 @@ export class NodeTooltipUtils {
|
||||
}
|
||||
|
||||
// If duplicate, append the ID or name in parentheses
|
||||
const suffix = libraryName || libraryId;
|
||||
let suffix = libraryId;
|
||||
if (libraryName && libraryName !== libraryTitle) {
|
||||
suffix = libraryName;
|
||||
}
|
||||
return isDuplicate && suffix ? `${libraryTitle} (${suffix})` : libraryTitle;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user