Skip to content

Commit

Permalink
Merge branch 'main' into issue-30669-create-import-job-rest-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinogiardino authored Nov 19, 2024
2 parents a33f47c + d01e188 commit e3d982b
Show file tree
Hide file tree
Showing 81 changed files with 1,392 additions and 374 deletions.
3 changes: 2 additions & 1 deletion core-web/apps/dotcdn/src/app/dotcdn.component.store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ComponentStore } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { Observable, of } from 'rxjs';

import { Injectable } from '@angular/core';
Expand Down
2 changes: 2 additions & 0 deletions core-web/apps/dotcms-ui/proxy-dev.conf.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default [
pathRewrite: {
'^/assets/manifest.json': '/dotAdmin/assets/manifest.json',
'^/assets/monaco-editor/min': '/dotAdmin/assets/monaco-editor/min',
'^/assets/edit-ema': '/dotAdmin/assets/edit-ema',
'^/assets/seo': '/dotAdmin/assets/seo',
'^/assets': '/dotAdmin',
'^/tinymce': '/dotAdmin/tinymce'
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ComponentStore } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { forkJoin, Observable, of } from 'rxjs';

import { HttpErrorResponse } from '@angular/common/http';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ComponentStore } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { Observable, of, zip } from 'rxjs';

import { HttpErrorResponse } from '@angular/common/http';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ComponentStore } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { Observable } from 'rxjs';

import { Injectable } from '@angular/core';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ export const BubbleAssetFormExtension = (viewContainerRef: ViewContainerRef) =>
({ chain }) => {
return chain()
.command(({ tr }) => {
preventClose = true;
tr.setMeta(BUBBLE_ASSET_FORM_PLUGIN_KEY, { open: true, type });
setTimeout(() => {
preventClose = false;
}, 0);

return true;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,22 @@ export class BubbleLinkFormComponent implements OnInit {
const { languageId } = contentlet;
contentlet.language = this.getContentletLanguage(languageId);

// The URLs for urlContentMaps have this format: /content.<contentlet inode>
// So we need to replace it with the actual URL which is stored in urlMap
const cleanedContentlet = {
...contentlet,
url: contentlet.URL_MAP_FOR_CONTENT ? contentlet.urlMap : contentlet.url
};

return {
label: contentlet.title,
icon: 'contentlet/image',
data: {
contentlet: contentlet
contentlet: cleanedContentlet
},
command: () => {
this.onSelection({
payload: contentlet,
payload: cleanedContentlet,
type: {
name: 'dotContent'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,11 @@ describe('DotExperimentsService', () => {

expect(req.request.body['trafficProportion']).toEqual(newValue);
});

it('should return an Observable of undefined when experimentId is undefined', (done) => {
spectator.service.getById(undefined).subscribe((result) => {
expect(result).toBeUndefined();
done();
});
});
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Observable } from 'rxjs';
import { Observable, of } from 'rxjs';

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

import { pluck } from 'rxjs/operators';
import { catchError, pluck } from 'rxjs/operators';

import { DotCMSResponse } from '@dotcms/dotcms-js';
import {
Expand Down Expand Up @@ -83,13 +83,18 @@ export class DotExperimentsService {
/**
* Get details of an experiment
* @param {string} experimentId
* @returns Observable<DotExperiment>
* @returns Observable<DotExperiment | undefined>
* @memberof DotExperimentsService
*/
getById(experimentId: string): Observable<DotExperiment> {
getById(experimentId: string | undefined): Observable<DotExperiment | undefined> {
if (!experimentId) {
return of(undefined);
}

return this.http
.get<DotCMSResponseExperiment<DotExperiment>>(`${API_ENDPOINT}/${experimentId}`)
.pipe(pluck('entity'));
.pipe(pluck('entity'))
.pipe(catchError(() => of(undefined)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
Spectator,
SpyObject
} from '@ngneat/spectator/jest';
import { patchState } from '@ngrx/signals';
import { of } from 'rxjs';

import { Validators } from '@angular/forms';
Expand All @@ -23,7 +22,6 @@ import {
DotWorkflowsActionsService,
DotWorkflowService
} from '@dotcms/data-access';
import { ComponentStatus } from '@dotcms/dotcms-models';
import { DotWorkflowActionsComponent } from '@dotcms/ui';
import { DotFormatDateServiceMock } from '@dotcms/utils-testing';

Expand Down Expand Up @@ -129,21 +127,6 @@ describe('DotFormComponent', () => {
expect(component.form.get('modUserName')).toBeFalsy();
expect(component.form.get('publishDate')).toBeFalsy();
});

it('should disable the form when loading and enable it when not loading', () => {
spectator.detectChanges();

// // Initially, the form should be enabled
expect(component.form.enabled).toBe(true);

patchState(store, {
state: ComponentStatus.SAVING
});

spectator.flushEffects();

expect(component.form.enabled).toBe(false);
});
});

describe('New Content', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';

import { EditContentShellComponent } from './edit-content.shell.component';
import { Toast } from 'primeng/toast';

describe('EditContentComponent', () => {
let component: EditContentShellComponent;
let fixture: ComponentFixture<EditContentShellComponent>;
import { EditContentShellComponent } from './edit-content.shell.component';

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [EditContentShellComponent]
}).compileComponents();
describe('EditContentShellComponent', () => {
let spectator: Spectator<EditContentShellComponent>;
const createComponent = createComponentFactory(EditContentShellComponent);

fixture = TestBed.createComponent(EditContentShellComponent);
component = fixture.componentInstance;
fixture.detectChanges();
beforeEach(() => {
spectator = createComponent();
});

it('should create', () => {
expect(component).toBeTruthy();
it('should have p-toast component', () => {
expect(spectator.query(Toast)).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterModule } from '@angular/router';

import { MessageService } from 'primeng/api';
import { ToastModule } from 'primeng/toast';

@Component({
selector: 'dot-edit-content',
standalone: true,
imports: [RouterModule],
template: '<router-outlet />',
imports: [RouterModule, ToastModule],
providers: [MessageService],
template: '<p-toast /> <router-outlet />',
styleUrls: ['./edit-content.shell.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,4 @@
}
}

<p-toast />
<p-confirmDialog />
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { ActivatedRoute, Router } from '@angular/router';
import { MessageService } from 'primeng/api';
import { ConfirmDialog } from 'primeng/confirmdialog';
import { MessagesModule } from 'primeng/messages';
import { Toast, ToastModule } from 'primeng/toast';

import {
DotContentTypeService,
Expand Down Expand Up @@ -46,8 +45,6 @@ describe('EditContentLayoutComponent', () => {
const createComponent = createComponentFactory({
component: EditContentLayoutComponent,
imports: [
MockModule(ToastModule),

MockModule(MessagesModule),
MockComponent(DotEditContentFormComponent),
MockComponent(DotEditContentSidebarComponent)
Expand Down Expand Up @@ -100,10 +97,6 @@ describe('EditContentLayoutComponent', () => {
jest.spyOn(utils, 'getPersistSidebarState').mockReturnValue(true);
});

it('should have p-toast component', () => {
expect(spectator.query(Toast)).toBeTruthy();
});

it('should have p-confirmDialog component', () => {
expect(spectator.query(ConfirmDialog)).toBeTruthy();
});
Expand All @@ -126,7 +119,6 @@ describe('EditContentLayoutComponent', () => {
expect(spectator.query(byTestId('edit-content-layout__body'))).toBeTruthy();
expect(spectator.query(byTestId('edit-content-layout__sidebar'))).toBeTruthy();

expect(spectator.query(Toast)).toBeTruthy();
expect(spectator.query(ConfirmDialog)).toBeTruthy();
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { RouterLink } from '@angular/router';

import { MessageService } from 'primeng/api';
import { ButtonModule } from 'primeng/button';
import { ConfirmDialogModule } from 'primeng/confirmdialog';
import { MessagesModule } from 'primeng/messages';
Expand Down Expand Up @@ -37,7 +36,6 @@ import { DotEditContentService } from '../../services/dot-edit-content.service';
DotWorkflowsActionsService,
DotWorkflowActionsFireService,
DotEditContentService,
MessageService,
DotWorkflowService,
DotEditContentStore
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tapResponse } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import {
patchState,
signalStore,
Expand All @@ -18,18 +18,18 @@ import { MessageService } from 'primeng/api';

import { switchMap, tap } from 'rxjs/operators';

import { DotCMSContentlet } from '@dotcms/angular';
import {
DotContentTypeService,
DotFireActionOptions,
DotHttpErrorManagerService,
DotMessageService,
DotRenderMode,
DotWorkflowActionsFireService,
DotWorkflowsActionsService,
DotMessageService
DotWorkflowsActionsService
} from '@dotcms/data-access';
import {
ComponentStatus,
DotCMSContentlet,
DotCMSContentType,
DotCMSWorkflowAction,
FeaturedFlags
Expand Down Expand Up @@ -65,7 +65,7 @@ const initialState: EditContentState = {
* related to content editing and workflow actions.
*/
export const DotEditContentStore = signalStore(
withState(initialState),
withState<EditContentState>(initialState),
withComputed((store) => ({
/**
* Computed property that determines if the new content editor feature is enabled.
Expand All @@ -77,9 +77,13 @@ export const DotEditContentStore = signalStore(
*/
isEnabledNewContentEditor: computed(() => {
const contentType = store.contentType();
const metadata = contentType?.metadata;
if (!contentType?.metadata) {
return false;
}

return metadata?.[FeaturedFlags.FEATURE_FLAG_CONTENT_EDITOR2_ENABLED] === true;
return (
contentType.metadata[FeaturedFlags.FEATURE_FLAG_CONTENT_EDITOR2_ENABLED] === true
);
}),

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tapResponse } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import {
patchState,
signalStoreFeature,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tapResponse } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import {
patchState,
signalStoreFeature,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ComponentStore } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { Observable, from } from 'rxjs';

import { Injectable } from '@angular/core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ComponentStore } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { from, Observable, of } from 'rxjs';

import { HttpClient } from '@angular/common/http';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tapResponse } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { patchState, signalStore, withComputed, withMethods, withState } from '@ngrx/signals';
import { rxMethod } from '@ngrx/signals/rxjs-interop';
import { pipe } from 'rxjs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { switchMap, tap } from 'rxjs/operators';

import { ComponentStatus, DotHttpErrorResponse } from '@dotcms/dotcms-models';

import { UploadedFile, UPLOAD_TYPE } from '../../../../../models/dot-edit-content-file.model';
import { UPLOAD_TYPE, UploadedFile } from '../../../../../models/dot-edit-content-file.model';
import { DotFileFieldUploadService } from '../../../services/upload-file/upload-file.service';

export interface FormImportUrlState {
Expand All @@ -29,6 +29,7 @@ const initialState: FormImportUrlState = {
};

export const FormImportUrlStore = signalStore(
{ protectedState: false }, // TODO: remove when the unit tests are fixed
withState(initialState),
withComputed((state) => ({
isLoading: computed(() => state.status() === ComponentStatus.LOADING),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { tapResponse } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { patchState, signalStore, withComputed, withMethods, withState } from '@ngrx/signals';
import { rxMethod } from '@ngrx/signals/rxjs-interop';
import { pipe } from 'rxjs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const initialState: FileFieldState = {
};

export const FileFieldStore = signalStore(
{ protectedState: false }, // TODO: remove when the unit tests are fixed
withState(initialState),
withComputed(({ fileStatus }) => ({
isInit: computed(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { JsonObject } from '@angular-devkit/core';
import { tapResponse } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { patchState, signalStore, withHooks, withMethods, withState } from '@ngrx/signals';
import { rxMethod } from '@ngrx/signals/rxjs-interop';
import { pipe } from 'rxjs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentStore, tapResponse } from '@ngrx/component-store';
import { ComponentStore } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { Observable, throwError } from 'rxjs';

import { HttpErrorResponse } from '@angular/common/http';
Expand Down
Loading

0 comments on commit e3d982b

Please sign in to comment.