From 4bfd147afaff41da0307a8d4784bfce6e3a185a2 Mon Sep 17 00:00:00 2001 From: Neeha2383 Date: Tue, 29 Oct 2024 18:40:08 -0500 Subject: [PATCH 1/6] issue-29621: Excluding Hidden content types from the Widgets displayed on the palette --- .../edit-ema-palette/store/edit-ema-palette.store.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts index 4d6232327cf6..4de6ea773201 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts @@ -237,10 +237,12 @@ export class DotPaletteStore extends ComponentStore { filter, page: 40, type: 'WIDGET' - }) + }), + this.dotConfigurationService + .getKeyAsList('CONTENT_PALETTE_HIDDEN_CONTENT_TYPES') ]).pipe( map((results) => { - const [filteredContentTypes, widgets] = results; + const [filteredContentTypes, widgets,hiddenContentTypes] = results; // Some pages bring widgets in the CONTENT_PALETTE_HIDDEN_CONTENT_TYPES, and others don't. // However, all pages allow widgets, so we make a request just to get them. @@ -249,9 +251,12 @@ export class DotPaletteStore extends ComponentStore { const contentLets = filteredContentTypes.filter( (item) => item.baseType !== 'WIDGET' ); + // Filter widgets based to exclude hidden content types + const relevantWidgets = widgets.filter(widget => !hiddenContentTypes.includes(widget.variable) + ); // Merge both array and order them by name - const contentTypes = [...contentLets, ...widgets] + const contentTypes = [...contentLets, ...relevantWidgets] .sort((a, b) => a.name.localeCompare(b.name)) .slice(0, 40); From 0a85a98698ec8c096e075c36ab7f1d1d4ae1ec40 Mon Sep 17 00:00:00 2001 From: Neeha2383 Date: Thu, 31 Oct 2024 12:07:50 -0500 Subject: [PATCH 2/6] formatting changes --- .../edit-ema-palette/store/edit-ema-palette.store.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts index 4de6ea773201..9c14abeeaf1e 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts @@ -238,11 +238,10 @@ export class DotPaletteStore extends ComponentStore { page: 40, type: 'WIDGET' }), - this.dotConfigurationService - .getKeyAsList('CONTENT_PALETTE_HIDDEN_CONTENT_TYPES') + this.dotConfigurationService.getKeyAsList('CONTENT_PALETTE_HIDDEN_CONTENT_TYPES') ]).pipe( map((results) => { - const [filteredContentTypes, widgets,hiddenContentTypes] = results; + const [filteredContentTypes, widgets, hiddenContentTypes] = results; // Some pages bring widgets in the CONTENT_PALETTE_HIDDEN_CONTENT_TYPES, and others don't. // However, all pages allow widgets, so we make a request just to get them. @@ -252,7 +251,8 @@ export class DotPaletteStore extends ComponentStore { (item) => item.baseType !== 'WIDGET' ); // Filter widgets based to exclude hidden content types - const relevantWidgets = widgets.filter(widget => !hiddenContentTypes.includes(widget.variable) + const relevantWidgets = widgets.filter( + (widget) => !hiddenContentTypes.includes(widget.variable) ); // Merge both array and order them by name From 6ecabcd89a2947cf734e6367409ccbfb2eb512a4 Mon Sep 17 00:00:00 2001 From: Rafael Velazco Date: Thu, 26 Dec 2024 11:36:45 -0400 Subject: [PATCH 3/6] chore: code cleanup --- .../store/edit-ema-palette.store.ts | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts index 1a4ea6e8eeae..a9ee031c9fb0 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts @@ -13,6 +13,7 @@ import { } from '@dotcms/data-access'; import { DEFAULT_VARIANT_ID, + DotCMSBaseTypesContentTypes, DotCMSContentlet, DotCMSContentType, DotContainerStructure, @@ -232,36 +233,34 @@ export class DotPaletteStore extends ComponentStore { * @returns An Observable that emits the filtered content types. */ private getFilteredContentTypes(filter: string, allowedContent: string[]) { - return forkJoin([ - this.dotContentTypeService.filterContentTypes(filter, allowedContent.join(',')), - this.dotContentTypeService.getContentTypes({ + return forkJoin({ + contentTypes: this.dotContentTypeService.filterContentTypes( + filter, + allowedContent.join(',') + ), + widgets: this.dotContentTypeService.getContentTypes({ filter, page: 40, type: 'WIDGET' }), - this.dotConfigurationService.getKeyAsList('CONTENT_PALETTE_HIDDEN_CONTENT_TYPES') - ]).pipe( - map((results) => { - const [filteredContentTypes, widgets, hiddenContentTypes] = results; - - // Some pages bring widgets in the CONTENT_PALETTE_HIDDEN_CONTENT_TYPES, and others don't. - // However, all pages allow widgets, so we make a request just to get them. - // Full comment here: https://github.com/dotCMS/core/pull/22573#discussion_r921263060 - // This filter is used to prevent widgets from being repeated. - const contentLets = filteredContentTypes.filter( - (item) => item.baseType !== 'WIDGET' - ); - // Filter widgets based to exclude hidden content types - const relevantWidgets = widgets.filter( - (widget) => !hiddenContentTypes.includes(widget.variable) + hiddenContentTypes: this.dotConfigurationService.getKeyAsList( + 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES' + ) + }).pipe( + map(({ contentTypes, widgets, hiddenContentTypes }) => { + /** + * This filter is used to prevent widgets from being repeated. + * More information here: https://github.com/dotCMS/core/pull/22573#discussion_r921263060 + */ + const filteredContentTypes = contentTypes.filter( + (item) => item.baseType !== DotCMSBaseTypesContentTypes.WIDGET ); + const mergedContentAndWidgets = [...filteredContentTypes, ...widgets]; - // Merge both array and order them by name - const contentTypes = [...contentLets, ...relevantWidgets] + return mergedContentAndWidgets + .filter((item) => !hiddenContentTypes.includes(item.variable)) .sort((a, b) => a.name.localeCompare(b.name)) .slice(0, 40); - - return contentTypes; }), catchError(() => EMPTY) ); From 6afb3ad39cdb3022bc0edd64bfc8c6886a530165 Mon Sep 17 00:00:00 2001 From: Rafael Velazco Date: Thu, 26 Dec 2024 12:08:42 -0400 Subject: [PATCH 4/6] test: add test to cover escenario --- .../store/edit-ema-palette.store.spec.ts | 80 ++++++++++++------- 1 file changed, 52 insertions(+), 28 deletions(-) diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.spec.ts index bfbb9a45e479..3c9a0dbe3c4c 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.spec.ts @@ -8,7 +8,6 @@ import { DotESContentService, DotPropertiesService } from '@dotcms/data-access'; -import { DotCMSContentType } from '@dotcms/dotcms-models'; import { DotPaletteStore, @@ -17,8 +16,23 @@ import { PALETTE_TYPES } from './edit-ema-palette.store'; +const WIDGET_MOCK = { + baseType: 'WIDGET', + id: 'widgetTest1', + name: 'widgetTest1', + variable: 'widgetTest1' +}; + +const VALID_CONTENT_TYPE_MOCK = { + baseType: 'someContent', + id: 'contentTypeTest1', + name: 'contentTypeTest1', + variable: 'contentTypeTest1' +}; + describe('EditEmaPaletteStore', () => { let spectator: SpectatorService; + let dotPropertiesService: DotPropertiesService; const createService = createServiceFactory({ service: DotPaletteStore, providers: [ @@ -43,25 +57,21 @@ describe('EditEmaPaletteStore', () => { useValue: { filterContentTypes: () => of([ - { - baseType: 'someContent', - id: 'contentTypeTest1', - name: 'contentTypeTest1' - }, + VALID_CONTENT_TYPE_MOCK, { baseType: 'WIDGET', id: 'contentTypeTest2', - name: 'contentTypeTest2' + name: 'contentTypeTest2', + variable: 'contentTypeTest2' } ]), - getContentTypes: () => - of([ - { - baseType: 'WIDGET', - id: 'widgetTest1', - name: 'widgetTest1' - } - ]) + getContentTypes: () => of([WIDGET_MOCK]) + } + }, + { + provide: DotPropertiesService, + useValue: { + getKeyAsList: () => of([]) } } ] @@ -69,6 +79,7 @@ describe('EditEmaPaletteStore', () => { beforeEach(() => { spectator = createService(); + dotPropertiesService = spectator.inject(DotPropertiesService); }); describe('updaters', () => { @@ -105,26 +116,19 @@ describe('EditEmaPaletteStore', () => { spectator.inject(DotContentTypeService), 'getContentTypes' ); + + const getKeyAsListSpy = jest.spyOn(dotPropertiesService, 'getKeyAsList'); spectator.service.loadContentTypes({ filter: '', allowedContent: ['contentTypeTest1'] }); - const expected = [ - { - baseType: 'someContent', - id: 'contentTypeTest1', - name: 'contentTypeTest1' - }, - { - baseType: 'WIDGET', - id: 'widgetTest1', - name: 'widgetTest1' - } - ]; spectator.service.vm$.subscribe((state) => { - expect(state.contenttypes.items).toEqual(expected as DotCMSContentType[]); + expect(state.contenttypes.items).toEqual([VALID_CONTENT_TYPE_MOCK, WIDGET_MOCK]); expect(patchStateSpy).toHaveBeenCalled(); expect(filterContentTypesSpy).toHaveBeenCalledWith('', 'contentTypeTest1'); + expect(getKeyAsListSpy).toHaveBeenCalledWith( + 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES' + ); expect(getContentTypesSpy).toHaveBeenCalledWith({ filter: '', page: 40, @@ -134,6 +138,26 @@ describe('EditEmaPaletteStore', () => { }); }); + it('should load content types with filter hidden content types', (done) => { + const getKeyAsListSpy = jest + .spyOn(dotPropertiesService, 'getKeyAsList') + .mockReturnValue(of(['contentTypeTest1'])); + + const payload = { + filter: '', + allowedContent: ['contentTypeTest1'] + }; + + spectator.service.loadContentTypes(payload); + spectator.service.vm$.subscribe((state) => { + expect(state.contenttypes.items).toEqual([WIDGET_MOCK]); + expect(getKeyAsListSpy).toHaveBeenCalledWith( + 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES' + ); + done(); + }); + }); + it('should load contentlets', (done) => { const contentServiceSpy = jest.spyOn(spectator.inject(DotESContentService), 'get'); const patchStateSpy = jest.spyOn(spectator.service, 'patchState'); From 9a743dc366df3c4d2e527fbe0329c71fbd067987 Mon Sep 17 00:00:00 2001 From: Rafael Velazco Date: Thu, 26 Dec 2024 12:47:53 -0400 Subject: [PATCH 5/6] fix: port fix from new UVE palette to old palette to support old clients --- .../store/dot-palette.store.spec.ts | 42 +++++++++-- .../dot-palette/store/dot-palette.store.ts | 73 ++++++++++--------- 2 files changed, 75 insertions(+), 40 deletions(-) diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.spec.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.spec.ts index 82d10925dd45..5ce65f84733d 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.spec.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.spec.ts @@ -6,6 +6,7 @@ import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { DotContentTypeService, DotESContentService, + DotPropertiesService, DotSessionStorageService, PaginatorService } from '@dotcms/data-access'; @@ -110,18 +111,29 @@ class MockContentTypeService { } } +const SORTED_CONTENT_TYPE_MOCK = contentTypeDataMock.sort((a, b) => + a.name.localeCompare(b.name) +) as DotCMSContentType[]; + describe('DotPaletteStore', () => { let dotPaletteStore: DotPaletteStore; let paginatorService: PaginatorService; let dotContentTypeService: DotContentTypeService; let dotESContentService: DotESContentService; let dotSessionStorageService: DotSessionStorageService; + let dotPropertiesService: DotPropertiesService; beforeEach(() => { TestBed.configureTestingModule({ providers: [ DotPaletteStore, DotSessionStorageService, + { + provide: DotPropertiesService, + useValue: { + getKeyAsList: () => of([]) + } + }, { provide: PaginatorService, useClass: MockPaginatorService }, { provide: DotContentTypeService, useClass: MockContentTypeService }, { provide: DotESContentService, useClass: MockESPaginatorService } @@ -132,6 +144,7 @@ describe('DotPaletteStore', () => { dotContentTypeService = TestBed.inject(DotContentTypeService); dotESContentService = TestBed.inject(DotESContentService); dotSessionStorageService = TestBed.inject(DotSessionStorageService); + dotPropertiesService = TestBed.inject(DotPropertiesService); }); // Updaters @@ -182,27 +195,42 @@ describe('DotPaletteStore', () => { // Effects it('should load contentTypes to store', (done) => { - const sortedDataMock = contentTypeDataMock.sort((a, b) => a.name.localeCompare(b.name)); spyOn(dotContentTypeService, 'filterContentTypes').and.returnValues( - of(sortedDataMock as DotCMSContentType[]) + of(SORTED_CONTENT_TYPE_MOCK) + ); + spyOn(dotContentTypeService, 'getContentTypes').and.returnValues(of([])); + + dotPaletteStore.loadContentTypes(['blog', 'banner']); + dotPaletteStore.vm$.subscribe((data) => { + expect(data.contentTypes).toEqual(SORTED_CONTENT_TYPE_MOCK); + done(); + }); + }); + + it("should load contentTypes and remove the hidden is the CONTENT_PALETTE_HIDDEN_CONTENT_TYPES is setted'", (done) => { + spyOn(dotContentTypeService, 'filterContentTypes').and.returnValues( + of(SORTED_CONTENT_TYPE_MOCK) ); spyOn(dotContentTypeService, 'getContentTypes').and.returnValues(of([])); + spyOn(dotPropertiesService, 'getKeyAsList').and.returnValue(of(['Form'])); + + const expectedData = SORTED_CONTENT_TYPE_MOCK.filter((item) => item.variable !== 'Form'); + dotPaletteStore.loadContentTypes(['blog', 'banner']); dotPaletteStore.vm$.subscribe((data) => { - expect(data.contentTypes).toEqual(sortedDataMock as DotCMSContentType[]); + expect(data.contentTypes).toEqual(expectedData); done(); }); }); - it('should load inly widgets to store if allowedContent is empty', (done) => { - const sortedDataMock = contentTypeDataMock.sort((a, b) => a.name.localeCompare(b.name)); + it('should load only widgets to store if allowedContent is empty', (done) => { spyOn(dotContentTypeService, 'filterContentTypes').and.returnValues(of([])); spyOn(dotContentTypeService, 'getContentTypes').and.returnValues( - of(sortedDataMock as DotCMSContentType[]) + of(SORTED_CONTENT_TYPE_MOCK) ); dotPaletteStore.loadContentTypes([]); dotPaletteStore.vm$.subscribe((data) => { - expect(data.contentTypes).toEqual(sortedDataMock as DotCMSContentType[]); + expect(data.contentTypes).toEqual(SORTED_CONTENT_TYPE_MOCK); done(); }); diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.ts index b1dcbb95ffcc..bcdb764c358d 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.ts @@ -1,5 +1,5 @@ import { ComponentStore } from '@ngrx/component-store'; -import { forkJoin, Observable } from 'rxjs'; +import { forkJoin, Observable, of } from 'rxjs'; import { Injectable } from '@angular/core'; @@ -10,12 +10,14 @@ import { debounceTime, map, take } from 'rxjs/operators'; import { DotContentTypeService, DotESContentService, + DotPropertiesService, DotSessionStorageService, PaginatorService } from '@dotcms/data-access'; import { ComponentStatus, DEFAULT_VARIANT_ID, + DotCMSBaseTypesContentTypes, DotCMSContentlet, DotCMSContentType, ESContent @@ -163,7 +165,8 @@ export class DotPaletteStore extends ComponentStore { private dotContentTypeService: DotContentTypeService, private paginatorESService: DotESContentService, private paginationService: PaginatorService, - private dotSessionStorageService: DotSessionStorageService + private dotSessionStorageService: DotSessionStorageService, + private dotConfigurationService: DotPropertiesService ) { super({ contentlets: null, @@ -249,37 +252,41 @@ export class DotPaletteStore extends ComponentStore { */ getContenttypesData(): void { this.setLoading(); - this.state$.pipe(take(1)).subscribe(({ filter, allowedContent }) => { - if (allowedContent && allowedContent.length) { - forkJoin([ - this.dotContentTypeService.filterContentTypes(filter, allowedContent.join(',')), - this.dotContentTypeService.getContentTypes({ filter, page: 40, type: 'WIDGET' }) - ]) - .pipe(take(1)) - .subscribe((results: DotCMSContentType[][]) => { - const [allowContent, widgets] = results; - - // Some pages bring widgets in the CONTENT_PALETTE_HIDDEN_CONTENT_TYPES, and others don't. - // However, all pages allow widgets, so we make a request just to get them. - // Full comment here: https://github.com/dotCMS/core/pull/22573#discussion_r921263060 - // This filter is used to prevent widgets from being repeated. - const contentLets = allowContent.filter( - (item) => item.baseType !== 'WIDGET' - ); - - // Merge both array and order them by name - const contentTypes = [...contentLets, ...widgets] - .sort((a, b) => a.name.localeCompare(b.name)) - .slice(0, 40); - - this.loadContentypes(contentTypes); - }); - } else { - this.dotContentTypeService - .getContentTypes({ filter, page: 40, type: 'WIDGET' }) - .pipe(take(1)) - .subscribe((data: DotCMSContentType[]) => this.loadContentypes(data)); - } + this.state$.pipe(take(1)).subscribe(({ filter, allowedContent = [] }) => { + // Note: This store needs to be refactored + const hasAllowedContent = allowedContent && allowedContent.length > 0; + const contentTypes$ = hasAllowedContent + ? this.dotContentTypeService.filterContentTypes(filter, allowedContent.join(',')) + : of([]); + + forkJoin({ + contentTypes: contentTypes$, + widgets: this.dotContentTypeService.getContentTypes({ + filter, + page: 40, + type: 'WIDGET' + }), + hiddenContentTypes: this.dotConfigurationService.getKeyAsList( + 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES' + ) + }) + .pipe(take(1)) + .subscribe(({ contentTypes, widgets, hiddenContentTypes }) => { + /** + * This filter is used to prevent widgets from being repeated. + * More information here: https://github.com/dotCMS/core/pull/22573#discussion_r921263060 + */ + const filteredContentTypes = contentTypes.filter( + (item) => item.baseType !== DotCMSBaseTypesContentTypes.WIDGET + ); + const mergedContentAndWidgets = [...filteredContentTypes, ...widgets]; + const data = mergedContentAndWidgets + .filter((item) => !hiddenContentTypes.includes(item.variable)) + .sort((a, b) => a.name.localeCompare(b.name)) + .slice(0, 40); + + this.loadContentypes(data); + }); }); } From d49266e6d7c56a9298a565c7c175ae5cf42e9f43 Mon Sep 17 00:00:00 2001 From: Rafael Velazco Date: Thu, 26 Dec 2024 12:59:40 -0400 Subject: [PATCH 6/6] dev: create DotConfigurationVariables enum --- .../components/dot-palette/store/dot-palette.store.ts | 3 ++- .../dot-edit-page/content/dot-edit-content.component.ts | 4 ++-- core-web/libs/dotcms-models/src/lib/shared-models.ts | 5 +++++ .../edit-ema-palette/store/edit-ema-palette.store.spec.ts | 5 +++-- .../edit-ema-palette/store/edit-ema-palette.store.ts | 3 ++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.ts index bcdb764c358d..a7db59398fac 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/components/dot-palette/store/dot-palette.store.ts @@ -20,6 +20,7 @@ import { DotCMSBaseTypesContentTypes, DotCMSContentlet, DotCMSContentType, + DotConfigurationVariables, ESContent } from '@dotcms/dotcms-models'; @@ -267,7 +268,7 @@ export class DotPaletteStore extends ComponentStore { type: 'WIDGET' }), hiddenContentTypes: this.dotConfigurationService.getKeyAsList( - 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES' + DotConfigurationVariables.CONTENT_PALETTE_HIDDEN_CONTENT_TYPES ) }) .pipe(take(1)) diff --git a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/dot-edit-content.component.ts b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/dot-edit-content.component.ts index 4484bebc6876..7da30585801d 100644 --- a/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/dot-edit-content.component.ts +++ b/core-web/apps/dotcms-ui/src/app/portlets/dot-edit-page/content/dot-edit-content.component.ts @@ -31,6 +31,7 @@ import { DEFAULT_VARIANT_NAME, DotCMSContentlet, DotCMSContentType, + DotConfigurationVariables, DotContainerStructure, DotContentletEventAddContentType, DotExperiment, @@ -377,9 +378,8 @@ browse from the page internal links } private setAllowedContent(pageState: DotPageRenderState): void { - const CONTENT_HIDDEN_KEY = 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES'; this.dotConfigurationService - .getKeyAsList(CONTENT_HIDDEN_KEY) + .getKeyAsList(DotConfigurationVariables.CONTENT_PALETTE_HIDDEN_CONTENT_TYPES) .pipe(take(1)) .subscribe((results) => { this.allowedContent = this.filterAllowedContentTypes(results, pageState) || []; diff --git a/core-web/libs/dotcms-models/src/lib/shared-models.ts b/core-web/libs/dotcms-models/src/lib/shared-models.ts index d085547b5bfd..845d253cf2f5 100644 --- a/core-web/libs/dotcms-models/src/lib/shared-models.ts +++ b/core-web/libs/dotcms-models/src/lib/shared-models.ts @@ -31,6 +31,11 @@ export const enum FeaturedFlags { FEATURE_FLAG_UVE_PREVIEW_MODE = 'FEATURE_FLAG_UVE_PREVIEW_MODE' } +export const enum DotConfigurationVariables { + CONTENT_PALETTE_HIDDEN_CONTENT_TYPES = 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES', + WYSIWYG_IMAGE_URL_PATTERN = 'WYSIWYG_IMAGE_URL_PATTERN' +} + export const FEATURE_FLAG_NOT_FOUND = 'NOT_FOUND'; export type DotDropdownGroupSelectOption = { diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.spec.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.spec.ts index 3c9a0dbe3c4c..0c14aa9516b2 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.spec.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.spec.ts @@ -8,6 +8,7 @@ import { DotESContentService, DotPropertiesService } from '@dotcms/data-access'; +import { DotConfigurationVariables } from '@dotcms/dotcms-models'; import { DotPaletteStore, @@ -127,7 +128,7 @@ describe('EditEmaPaletteStore', () => { expect(patchStateSpy).toHaveBeenCalled(); expect(filterContentTypesSpy).toHaveBeenCalledWith('', 'contentTypeTest1'); expect(getKeyAsListSpy).toHaveBeenCalledWith( - 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES' + DotConfigurationVariables.CONTENT_PALETTE_HIDDEN_CONTENT_TYPES ); expect(getContentTypesSpy).toHaveBeenCalledWith({ filter: '', @@ -152,7 +153,7 @@ describe('EditEmaPaletteStore', () => { spectator.service.vm$.subscribe((state) => { expect(state.contenttypes.items).toEqual([WIDGET_MOCK]); expect(getKeyAsListSpy).toHaveBeenCalledWith( - 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES' + DotConfigurationVariables.CONTENT_PALETTE_HIDDEN_CONTENT_TYPES ); done(); }); diff --git a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts index a9ee031c9fb0..eb77d25bd8e9 100644 --- a/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts +++ b/core-web/libs/portlets/edit-ema/portlet/src/lib/edit-ema-editor/components/edit-ema-palette/store/edit-ema-palette.store.ts @@ -16,6 +16,7 @@ import { DotCMSBaseTypesContentTypes, DotCMSContentlet, DotCMSContentType, + DotConfigurationVariables, DotContainerStructure, DotPageContainerStructure } from '@dotcms/dotcms-models'; @@ -244,7 +245,7 @@ export class DotPaletteStore extends ComponentStore { type: 'WIDGET' }), hiddenContentTypes: this.dotConfigurationService.getKeyAsList( - 'CONTENT_PALETTE_HIDDEN_CONTENT_TYPES' + DotConfigurationVariables.CONTENT_PALETTE_HIDDEN_CONTENT_TYPES ) }).pipe( map(({ contentTypes, widgets, hiddenContentTypes }) => {