Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into issue-30367-Implement…
Browse files Browse the repository at this point in the history
…-Abandoned-Job-Detection-and-Recovery
  • Loading branch information
jgambarios committed Nov 18, 2024
2 parents db8fcb6 + 3d77285 commit e2accd9
Show file tree
Hide file tree
Showing 76 changed files with 1,376 additions and 347 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,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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ComponentStore, OnStateInit, tapResponse } from '@ngrx/component-store';
import { ComponentStore, OnStateInit } from '@ngrx/component-store';
import { tapResponse } from '@ngrx/operators';
import { EMPTY, Observable, throwError } 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 { ChartData } from 'chart.js';
import { forkJoin, Observable, of } 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 { forkJoin } from 'rxjs';

import { HttpErrorResponse } from '@angular/common/http';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<dot-block-editor
[field]="contentlet.field"
[value]="contentlet.content"
[languageId]="contentlet.languageId"
[languageId]="contentlet.language"
(valueChange)="value.set($event)"
data-testId="dot-block-editor" />
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@ const messageServiceMock = new MockDotMessageService({
const EVENT_DATA = {
fieldName: 'testName',
contentType: 'Blog',
language: '2',
language: 2,
inode: 'testInode',
blockEditorContent: '{"field":"field value"}'
content: {
conent: [],
type: 'doc'
}
};

const contentTypeMock: DotCMSContentType = {
Expand Down Expand Up @@ -135,8 +138,8 @@ describe('DotBlockEditorSidebarComponent', () => {
const blockEditor = spectator.query(DotBlockEditorComponent);

expect(blockEditor.field).toEqual(BLOCK_EDITOR_FIELD);
expect(blockEditor.languageId).toBe(parseInt(EVENT_DATA.language));
expect(blockEditor.value).toEqual(JSON.parse(EVENT_DATA.blockEditorContent));
expect(blockEditor.languageId).toBe(EVENT_DATA.language);
expect(blockEditor.value).toEqual(EVENT_DATA.content);
expect(dotContentTypeService.getContentType).toHaveBeenCalledWith('Blog');
});

Expand Down
Loading

0 comments on commit e2accd9

Please sign in to comment.