Skip to content

Commit

Permalink
Merge branch 'develop-6.6.x' into epic/CXSPA-700
Browse files Browse the repository at this point in the history
  • Loading branch information
kimhw0630 authored Oct 6, 2023
2 parents a30d335 + 19d4559 commit 3ee1585
Show file tree
Hide file tree
Showing 8 changed files with 640 additions and 196 deletions.
31 changes: 28 additions & 3 deletions projects/core/src/cms/cms.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,32 @@
*/

import { ModuleWithProviders, NgModule } from '@angular/core';
import { provideDefaultConfig } from '../config/config-providers';
import { defaultCmsModuleConfig } from './config/default-cms-config';
import {
defaultCmsModuleConfig,
defaultUserCmsModuleConfig,
} from './config/default-cms-config';
import { CmsService } from './facade/cms.service';
import { PageMetaModule } from './page/page-meta.module';
import { CmsStoreModule } from './store/cms-store.module';
import { ConfigChunk, provideDefaultConfigFactory } from '../config';
import { USER_CMS_ENDPOINTS } from '../model';

function getDefaultCmsConfig(configChunk: any) {
let isUserCmsEndpoint = false;

configChunk.find((config: any) => {
const userCmsEndpoints = config.features?.[USER_CMS_ENDPOINTS];

if (Boolean(userCmsEndpoints)) {
isUserCmsEndpoint = userCmsEndpoints;
}
});

if (isUserCmsEndpoint) {
return defaultUserCmsModuleConfig;
}
return defaultCmsModuleConfig;
}

@NgModule({
imports: [CmsStoreModule, PageMetaModule.forRoot()],
Expand All @@ -18,7 +39,11 @@ export class CmsModule {
static forRoot(): ModuleWithProviders<CmsModule> {
return {
ngModule: CmsModule,
providers: [CmsService, provideDefaultConfig(defaultCmsModuleConfig)],
providers: [
CmsService,
// TODO: (CXSPA-4886) In the major change to provideDefaultConfig(defaultCmsModuleConfig)
provideDefaultConfigFactory(getDefaultCmsConfig, [ConfigChunk]),
],
};
}
}
15 changes: 15 additions & 0 deletions projects/core/src/cms/config/default-cms-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,18 @@ export const defaultCmsModuleConfig: CmsConfig = {
pageSize: 50,
},
};

// TODO: (CXSPA-4886) replace and remove this with defaultCmsModuleConfig in the major
export const defaultUserCmsModuleConfig: CmsConfig = {
...defaultCmsModuleConfig,
backend: {
occ: {
endpoints: {
component: 'users/${userId}/cms/components/${id}',
components: 'users/${userId}/cms/components',
pages: 'users/${userId}/cms/pages',
page: 'users/${userId}/cms/pages/${id}',
},
},
},
};
3 changes: 3 additions & 0 deletions projects/core/src/model/cms.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,6 @@ export interface CmsPickupItemDetails extends CmsComponent {
showEdit: boolean;
context: string;
}

// TODO: (CXSPA-4886) Remove this flag in the major
export const USER_CMS_ENDPOINTS = 'userCmsEndpoints';
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const pageContext: PageContext = {
type: PageType.PRODUCT_PAGE,
};

const spyOnPostEndpoint = `/cms/components?productCode=123`;
const spyOnPostEndpoint = `userId/anonymous/cms/components?productCode=123`;

describe('LegacyOccCmsComponentAdapter', () => {
let service: LegacyOccCmsComponentAdapter;
Expand Down Expand Up @@ -72,7 +72,7 @@ describe('LegacyOccCmsComponentAdapter', () => {

const testRequest = mockHttpRequest(
'POST',
'/cms/components?productCode=123'
'userId/anonymous/cms/components?productCode=123'
);

assertPostTestRequestBody(testRequest);
Expand Down
Loading

0 comments on commit 3ee1585

Please sign in to comment.