Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { UmbUfmElementBase } from '../ufm-element-base.js';
import { UMB_UFM_RENDER_CONTEXT } from '../ufm-render/ufm-render.context.js';
import { customElement, property } from '@umbraco-cms/backoffice/external/lit';
import { UmbDocumentItemRepository, UMB_DOCUMENT_ENTITY_TYPE } from '@umbraco-cms/backoffice/document';
import {
UmbDocumentItemDataResolver,
UmbDocumentItemRepository,
UMB_DOCUMENT_ENTITY_TYPE,
} from '@umbraco-cms/backoffice/document';
import { UmbId } from '@umbraco-cms/backoffice/id';
import { UmbMediaItemRepository, UMB_MEDIA_ENTITY_TYPE } from '@umbraco-cms/backoffice/media';
import { UmbMemberItemRepository, UMB_MEMBER_ENTITY_TYPE } from '@umbraco-cms/backoffice/member';
import type { UmbDocumentItemModel } from '@umbraco-cms/backoffice/document';

@customElement('ufm-content-name')
export class UmbUfmContentNameElement extends UmbUfmElementBase {
Expand Down Expand Up @@ -46,7 +51,7 @@
if (item.mediaKey) return UMB_MEDIA_ENTITY_TYPE;
}

return null;
return UMB_DOCUMENT_ENTITY_TYPE;
}

#getUniques(value: unknown) {
Expand All @@ -64,7 +69,17 @@
const { data } = await repository.requestItems(uniques);

if (Array.isArray(data) && data.length > 0) {
// TODO: [v17] Review usage of `item.variants[0].name` as this needs to be implemented properly! [LK]
if (entityType === UMB_DOCUMENT_ENTITY_TYPE) {
const namePromises = data.map(async (item) => {
const resolver = new UmbDocumentItemDataResolver(this);
resolver.setData(item as UmbDocumentItemModel);
return await resolver.getName();
});
const names = await Promise.all(namePromises);
return names.join(', ');
}

// TODO: Review usage of `item.variants[0].name` as this needs to be implemented properly for media/member items [LK]

Check warning on line 82 in src/Umbraco.Web.UI.Client/src/packages/ufm/components/content-name/content-name.element.ts

View check run for this annotation

CodeScene Delta Analysis / CodeScene Code Health Review (main)

❌ New issue: Deep, Nested Complexity

UmbUfmContentNameElement.getNames has a nested complexity depth of 4, threshold = 4. This function contains deeply nested logic such as if statements and/or loops. The deeper the nesting, the lower the code health.
return data.map((item) => item.variants[0].name).join(', ');
}
}
Expand Down
Loading