Skip to content

Commit 39d3c7e

Browse files
authored
35138 Defect content palette search bar disappears and system content types exposition (#35173)
### Proposed Changes This PR solves two small issues in the content palette: #### This PR fixes: #35138 Defect Search bar disappears * Restore $shouldHideControls() signal, modified in the modernization deploy. #### This PR fixes: #35140 Spike System Content Types exposition * Hide `system=true` Content Types (e.g., 'Dot Favorite Page') from being exposed when a request to the `api/v1/contenttype/page` resource is made. * Add integration tests This PR fixes: #35138 This PR fixes: #35140
1 parent 3747b39 commit 39d3c7e

File tree

5 files changed

+71
-14
lines changed

5 files changed

+71
-14
lines changed

core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-palette/components/dot-uve-palette-list/dot-uve-palette-list.component.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
effect,
1010
inject,
1111
input,
12-
linkedSignal,
1312
OnInit,
1413
signal,
1514
untracked,
@@ -132,6 +131,7 @@ export class DotUvePaletteListComponent implements OnInit {
132131
protected readonly $skipNextSearch = signal(false);
133132
protected readonly $contextMenuItems = signal<MenuItem[]>([]);
134133
protected readonly $isSearching = signal<boolean>(false);
134+
protected readonly $shouldHideControls = signal<boolean>(true);
135135
protected readonly $siteId = this.#globalStore.currentSiteId;
136136
protected readonly $contenttypes = this.#paletteListStore.contenttypes;
137137
protected readonly $contentlets = this.#paletteListStore.contentlets;
@@ -146,11 +146,6 @@ export class DotUvePaletteListComponent implements OnInit {
146146
protected readonly $isFavoritesList = this.#paletteListStore.$isFavoritesList;
147147
protected readonly status$ = toObservable(this.#paletteListStore.status);
148148

149-
protected readonly $shouldHideControls = linkedSignal({
150-
source: this.$contenttypes,
151-
computation: (contenttypes) => contenttypes.length === 0
152-
});
153-
154149
/**
155150
* Computed signal to determine the start index for the pagination.
156151
* @returns The start index for the pagination.
@@ -292,7 +287,7 @@ export class DotUvePaletteListComponent implements OnInit {
292287
* Handles the selection of a content type to view its contentlets.
293288
* Store handles query building, filter reset, and page reset automatically.
294289
*
295-
* @param contentTypeName - The name of the content type to drill into
290+
* @param selectedContentType - The name of the content type to drill into
296291
*/
297292
protected onSelectContentType(selectedContentType: string) {
298293
this.#paletteListStore.getContentlets({ ...EMPTY_SEARCH_PARAMS, selectedContentType });
@@ -421,6 +416,7 @@ export class DotUvePaletteListComponent implements OnInit {
421416
* @private
422417
*/
423418
#updateControlsVisibility() {
419+
this.$shouldHideControls.set(false);
424420
this.status$
425421
.pipe(
426422
filter(

core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/dot-uve-palette/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export const DEFAULT_PER_PAGE = 30;
153153

154154
/**
155155
* Base content types included in the Content tab.
156+
* Filter excludes DotCMSBaseTypesContentTypes FORMs and HTMLPAGEs to keep the Palette UI focused on standard content.
156157
*/
157158
export const BASETYPES_FOR_CONTENT = [
158159
DotCMSBaseTypesContentTypes.CONTENT,

dotCMS/src/main/java/com/dotcms/rest/api/v1/contenttype/ContentTypeResource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,8 @@ public final ResponseEntityPaginatedDataView getPagesContentTypes(@Context final
19111911
//Curated list of varNames ensures they belong into the passed BaseTypes
19121912
List<String> typeVarNames = contentTypes.stream()
19131913
.filter(contentType -> baseContentTypes.contains(contentType.baseType()))
1914+
// Excludes system contentTypes
1915+
.filter(contentType -> !contentType.system())
19141916
.map(ContentType::variable)
19151917
.collect(Collectors.toList());
19161918

dotCMS/src/main/webapp/ext/uve/dot-uve.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

dotcms-integration/src/test/java/com/dotcms/rest/api/v1/contenttype/ContentTypeResourceTest.java

Lines changed: 65 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@
1616
import com.dotcms.contenttype.model.type.ContentType;
1717
import com.dotcms.contenttype.model.type.PersonaContentType;
1818
import com.dotcms.contenttype.transform.contenttype.JsonContentTypeTransformer;
19+
import com.dotcms.datagen.ContainerDataGen;
20+
import com.dotcms.datagen.ContentTypeDataGen;
21+
import com.dotcms.datagen.FolderDataGen;
22+
import com.dotcms.datagen.HTMLPageDataGen;
1923
import com.dotcms.datagen.SiteDataGen;
24+
import com.dotcms.datagen.TemplateDataGen;
2025
import com.dotcms.datagen.TestUserUtils;
2126
import com.dotcms.mock.request.MockAttributeRequest;
2227
import com.dotcms.mock.request.MockHeaderRequest;
2328
import com.dotcms.mock.request.MockHttpRequestIntegrationTest;
2429
import com.dotcms.mock.request.MockSessionRequest;
2530
import com.dotcms.rest.EmptyHttpResponse;
2631
import com.dotcms.rest.InitDataObject;
32+
import com.dotcms.rest.ResponseEntityPaginatedDataView;
2733
import com.dotcms.rest.ResponseEntityView;
2834
import com.dotcms.rest.RestUtilTest;
2935
import com.dotcms.rest.WebResource;
@@ -37,6 +43,10 @@
3743
import com.dotmarketing.business.PermissionAPI;
3844
import com.dotmarketing.exception.DotDataException;
3945
import com.dotmarketing.exception.DotSecurityException;
46+
import com.dotmarketing.portlets.containers.model.Container;
47+
import com.dotmarketing.portlets.folders.model.Folder;
48+
import com.dotmarketing.portlets.htmlpageasset.model.HTMLPageAsset;
49+
import com.dotmarketing.portlets.templates.model.Template;
4050
import com.fasterxml.jackson.databind.ObjectMapper;
4151
import com.liferay.portal.model.User;
4252
import com.liferay.portal.util.WebKeys;
@@ -536,10 +546,61 @@ public void testGetRecentBaseTypes_whenCommunity_excludeTypes(final TestCase tes
536546
assertEquals(testCase.typesIncluded, types.stream().anyMatch(this::isEnterpriseBaseType));
537547
}
538548

539-
private boolean isEnterpriseBaseType(final BaseContentTypesView baseContentTypesView) {
540-
return baseContentTypesView.getName().equals(BaseContentType.FORM.name())
541-
|| baseContentTypesView.getName().equals(BaseContentType.PERSONA.name());
542-
}
549+
private boolean isEnterpriseBaseType(final BaseContentTypesView baseContentTypesView) {
550+
return baseContentTypesView.getName().equals(BaseContentType.FORM.name())
551+
|| baseContentTypesView.getName().equals(BaseContentType.PERSONA.name());
552+
}
553+
554+
/**
555+
* Method to test: {@link ContentTypeResource#getPagesContentTypes}
556+
* Given Scenario: A page whose container holds both a regular and a system content type
557+
* ExpectedResult: System content types are excluded from the response; regular ones are included
558+
*/
559+
@Test
560+
public void test_getPagesContentTypes_excludesSystemContentTypes() throws Exception {
561+
562+
final User adminUser = APILocator.getUserAPI().loadUserById("dotcms.org.1");
563+
564+
final ContentType regularContentType = new ContentTypeDataGen().nextPersisted();
565+
final ContentType systemContentType = new ContentTypeDataGen().system(true).nextPersisted();
566+
567+
try {
568+
final Container container = new ContainerDataGen()
569+
.withContentType(regularContentType, "")
570+
.withContentType(systemContentType, "")
571+
.nextPersisted();
572+
ContainerDataGen.publish(container);
573+
574+
final Template template = new TemplateDataGen()
575+
.withContainer(container.getIdentifier())
576+
.nextPersisted();
577+
APILocator.getVersionableAPI().setLive(template);
578+
579+
final Host systemHost = APILocator.getHostAPI()
580+
.findSystemHost(adminUser, false);
581+
final Folder folder = new FolderDataGen().site(systemHost).nextPersisted();
582+
final HTMLPageAsset page = new HTMLPageDataGen(folder, template).nextPersisted();
583+
APILocator.getContentletAPI().publish(page, adminUser, false);
584+
585+
final ContentTypeResource resource = new ContentTypeResource();
586+
final ResponseEntityPaginatedDataView response = resource.getPagesContentTypes(
587+
getHttpRequest(), new EmptyHttpResponse(),
588+
page.getIdentifier(), "-1", null, 1, 10, "name", "ASC", null, null);
589+
590+
@SuppressWarnings("unchecked") final List<Map<String, Object>> contentTypes = (List<Map<String, Object>>) response.getEntity();
591+
final List<String> variables = contentTypes.stream()
592+
.map(ct -> (String) ct.get(ContentTypesPaginator.VARIABLE))
593+
.collect(Collectors.toList());
594+
595+
assertTrue("Regular content type should be included in the palette",
596+
variables.contains(regularContentType.variable()));
597+
assertFalse("System content type should be excluded from the palette",
598+
variables.contains(systemContentType.variable()));
599+
} finally {
600+
ContentTypeDataGen.remove(regularContentType);
601+
ContentTypeDataGen.remove(systemContentType);
602+
}
603+
}
543604

544605
private static class TestHashMap<K, V> extends HashMap<K, V> {
545606
@Override

0 commit comments

Comments
 (0)