Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ const mockContainer: DotContainerEntity = {
identifier: '1234',
live: true,
name: 'movie',
parentPermissionable: {
hostname: 'default'
},
hostName: 'default',
path: null,
source: CONTAINER_SOURCE.DB,
title: 'movie',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@ describe('TemplateContainersCacheService', () => {
type: 'type',
source: CONTAINER_SOURCE.FILE,
path: '/containers/path',
parentPermissionable: {
hostname: 'demo.dotcms.com'
}
hostName: 'demo.dotcms.com'
},
'2': {
identifier: '2',
name: 'container 2',
type: 'type',
source: CONTAINER_SOURCE.DB,
parentPermissionable: {
hostname: 'demo.dotcms.com'
}
hostName: 'demo.dotcms.com'
}
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ const containersMock: DotContainer[] = [
identifier: '123Published',
live: true,
name: 'movie',
parentPermissionable: {
hostname: 'default'
},
hostName: 'default',
path: null,
source: CONTAINER_SOURCE.DB,
title: 'movie',
Expand All @@ -100,9 +98,7 @@ const containersMock: DotContainer[] = [
identifier: '123Unpublish',
live: false,
name: 'test',
parentPermissionable: {
hostname: 'default'
},
hostName: 'default',
path: null,
source: CONTAINER_SOURCE.DB,
title: 'test',
Expand All @@ -117,9 +113,7 @@ const containersMock: DotContainer[] = [
identifier: '123Archived',
live: false,
name: 'test',
parentPermissionable: {
hostname: 'default'
},
hostName: 'default',
path: null,
source: CONTAINER_SOURCE.DB,
title: 'test',
Expand All @@ -134,9 +128,7 @@ const containersMock: DotContainer[] = [
identifier: 'SYSTEM_CONTAINER',
live: false,
name: 'test',
parentPermissionable: {
hostname: 'default'
},
hostName: 'default',
path: null,
source: CONTAINER_SOURCE.DB,
title: 'test',
Expand All @@ -151,9 +143,7 @@ const containersMock: DotContainer[] = [
identifier: 'FILE_CONTAINER',
live: false,
name: 'test',
parentPermissionable: {
hostname: 'default'
},
hostName: 'default',
path: '//demo.dotcms.com/application/containers/default/',
pathName: '//demo.dotcms.com/application/containers/default/',
source: CONTAINER_SOURCE.FILE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ describe('ContainerCreateComponent', () => {
name: '',
type: '',
source: CONTAINER_SOURCE.DB,
parentPermissionable: {
hostname: 'dotcms.com'
}
hostName: 'dotcms.com'
},
containerStructures: []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('DotTemplateAdvancedComponent', () => {

container.triggerEventHandler('swap', {
identifier: '123',
parentPermissionable: { hostname: 'demo.com' }
hostName: 'demo.com'
});

expect(component.editor.executeEdits).toHaveBeenCalledWith('source', [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,10 @@ export class DotTemplateAdvancedComponent implements OnInit, OnDestroy, OnChange
this.editor.executeEdits('source', [operation]);
}

private setContainerId({ identifier, parentPermissionable }: DotContainer): string {
const regex = new RegExp('//' + parentPermissionable.hostname);
private setContainerId({ identifier, hostName }: DotContainer): string {
const regex = new RegExp('//' + hostName);

return identifier?.includes(parentPermissionable.hostname)
? identifier.replace(regex, '')
: identifier;
return identifier?.includes(hostName) ? identifier.replace(regex, '') : identifier;
}

private getActions(disabled = true): DotPortletToolbarActions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ describe('SearchableDropdownComponent', () => {
id: i,
label: `site-${i}`,
name: `site-${i}`,
parentPermissionable: {
hostname: 'demo.dotcms.com'
}
hostName: 'demo.dotcms.com'
};
}

Expand Down Expand Up @@ -252,7 +250,7 @@ describe('SearchableDropdownComponent', () => {

it('should render a string array of properties in p-dataview', () => {
hostComp.data = data;
hostComp.labelPropertyName = ['name', 'parentPermissionable.hostname'];
hostComp.labelPropertyName = ['name', 'hostName'];

hostFixture.detectChanges();

Expand Down Expand Up @@ -350,9 +348,7 @@ describe('SearchableDropdownComponent', () => {
id: 1,
label: `label`,
name: `label`,
parentPermissionable: {
hostname: 'demo.dotcms.com'
},
hostName: 'demo.dotcms.com',
default: true
}
];
Expand All @@ -372,9 +368,7 @@ describe('SearchableDropdownComponent', () => {
id: 1,
label: `label`,
name: `label`,
parentPermissionable: {
hostname: 'demo.dotcms.com'
},
hostName: 'demo.dotcms.com',
default: false
}
];
Expand Down Expand Up @@ -504,9 +498,7 @@ describe('SearchableDropdownComponent', () => {
id: i,
label: `site-${i}`,
name: `site-${i}`,
parentPermissionable: {
hostname: 'demo.dotcms.com'
}
hostName: 'demo.dotcms.com'
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[pageLinkSize]="5"
[rows]="paginationService.paginationPerPage"
[totalRecords]="paginationService.totalRecords"
[labelPropertyName]="['name', 'parentPermissionable.hostname']"
[labelPropertyName]="['name', 'hostName']"
[class]="innerClass"
[multiple]="true"
data-testId="searchableDropdown"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ describe('ContainerSelectorComponent', () => {
name: 'Container 1',
type: 'Container',
source: CONTAINER_SOURCE.DB,
parentPermissionable: {
hostname: 'demo.dotcms.com'
}
hostName: 'demo.dotcms.com'
},
{
categoryId: '40204d-c380-439f-a6d0-97d8sdeed57e',
Expand All @@ -83,9 +81,7 @@ describe('ContainerSelectorComponent', () => {
type: 'Container',
source: CONTAINER_SOURCE.FILE,
path: 'container/path',
parentPermissionable: {
hostname: 'demo.dotcms.com'
}
hostName: 'demo.dotcms.com'
}
];

Expand All @@ -108,10 +104,7 @@ describe('ContainerSelectorComponent', () => {
const searchableComponent = searchable.componentInstance as SearchableDropdownComponent;

// Verify component properties directly
expect(searchableComponent.labelPropertyName).toEqual([
'name',
'parentPermissionable.hostname'
]);
expect(searchableComponent.labelPropertyName).toEqual(['name', 'hostName']);
expect(searchableComponent.multiple).toBe(true);
expect(searchableComponent.pageLinkSize).toBe(5);
expect(searchableComponent.persistentPlaceholder).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ describe('DotContainersService', () => {
title: 'Test Container Title',
path: '/test-container',
archived: false,
categoryId: 'test-category',
parentPermissionable: {
hostname: 'test-host'
}
categoryId: 'test-category'
};

const mockSystemContainer: DotContainer = {
Expand Down
5 changes: 2 additions & 3 deletions core-web/libs/dotcms-models/src/lib/dot-container.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export interface DotContainerEntity {

export interface DotContainer {
archived?: boolean;
hostName?: string;
hostId?: string;
categoryId?: string;
deleted?: boolean;
live?: boolean;
Expand All @@ -28,9 +30,6 @@ export interface DotContainer {
preLoop?: string;
postLoop?: string;
code?: string;
parentPermissionable?: {
hostname: string;
};
disableInteraction?: boolean;
pathName?: string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ describe('DotEditContentBinaryFieldComponent', () => {
});

beforeEach(() => {
// This spec relies on async Angular stabilization (whenStable).
// In large Jest runs, other suites can leave fake timers enabled in the same worker,
// which can cause these async setups to hang/flap. Force real timers for isolation.
jest.useRealTimers();

spectator = createComponent({
detectChanges: false,
props: {
Expand Down Expand Up @@ -769,6 +774,8 @@ describe('DotEditContentBinaryFieldComponent', () => {
});

afterEach(() => {
jest.clearAllTimers();
jest.useRealTimers();
jest.resetAllMocks();
});
});
Expand Down
2 changes: 2 additions & 0 deletions core-web/libs/sdk/uve/src/lib/dom/dom.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ export const getContainersData = (
const acceptTypes =
containerStructures?.map((structure) => structure.contentTypeVar).join(',') ?? '';

// TODO: Check if the variantId is needed and we need to find another way to get it.
// Since the parentPermissionable is not available after: https://github.com/dotCMS/core/pull/32890
const variantId = container?.parentPermissionable?.variantId;
const maxContentlets = container?.maxContentlets ?? 0;
const path = container?.path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,7 @@ describe('DotTemplateBuilderStore', () => {
path: '/new/default/container/path',
archived: false,
categoryId: 'new-category',
parentPermissionable: {
hostname: 'new-host'
}
hostName: 'new-host'
};

service.updateDefaultContainer(newDefaultContainer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ export const mockDefaultContainerWithPath: DotContainer = {
title: 'Default Container Title',
path: '/default/container/path',
archived: false,
categoryId: 'default-category',
parentPermissionable: {
hostname: 'default-host'
}
categoryId: 'default-category'
};

export const mockDefaultContainerWithoutPath: DotContainer = {
Expand All @@ -88,10 +85,7 @@ export const mockDefaultContainerWithoutPath: DotContainer = {
locked: false,
title: 'Default Container Title',
archived: false,
categoryId: 'default-category',
parentPermissionable: {
hostname: 'default-host'
}
categoryId: 'default-category'
};

export const mockTempContainer: DotContainer = {
Expand All @@ -106,10 +100,7 @@ export const mockTempContainer: DotContainer = {
title: 'Temp Container Title',
path: '/temp/container/path',
archived: false,
categoryId: 'temp-category',
parentPermissionable: {
hostname: 'temp-host'
}
categoryId: 'temp-category'
};

export const CONTAINERS_DATA_MOCK = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const sortedContainersMock = containersMock

function getGroupByHostContainersMock() {
const containerobj = sortedContainersMock.reduce((acc, option) => {
const { hostname } = option.value.parentPermissionable;
const hostname = option.value.hostName || 'SYSTEM_HOST';

if (!acc[hostname]) {
acc[hostname] = { items: [] };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
const DEFAULT_LABEL_NAME_INDEX = 'label';
const DEFAULT_VALUE_NAME_INDEX = 'value';

const DEFAULT_HOST_NAME = 'SYSTEM_HOST';

/**
* Directive to set an element's options from dotCMS's containers
*
Expand Down Expand Up @@ -134,7 +136,7 @@ export class DotContainerOptionsDirective implements OnInit {
[key: string]: { items: DotDropdownSelectOption<DotContainer>[] };
} {
return options.reduce((acc, option) => {
const { hostname } = option.value.parentPermissionable;
const hostname = option.value.hostName || DEFAULT_HOST_NAME;

if (!acc[hostname]) {
acc[hostname] = { items: [] };
Expand Down
Loading