Skip to content

Commit

Permalink
chore: upgrade ngrx #30255 (#30256)
Browse files Browse the repository at this point in the history
### Proposed Changes

This pull request primarily focuses on refactoring imports across
multiple files to improve code organization and maintainability. The
most significant changes involve moving `tapResponse` from
`@ngrx/component-store` to `@ngrx/operators` and reordering some imports
for consistency.

Refactoring imports:

*
[`core-web/apps/dotcdn/src/app/dotcdn.component.store.ts`](diffhunk://#diff-b202dfd3e850f6f8d29a81e0f698f305309a1d524fcb089138c0eed4f0b0e2d0L1-R2):
Moved `tapResponse` to `@ngrx/operators`.
*
[`core-web/apps/dotcms-ui/src/app/portlets/dot-pages/dot-pages-store/dot-pages.store.ts`](diffhunk://#diff-1145b6e61f8f24833b827ae5f3fe939586964551b15aab913ba530cd44808f0eL1-R2):
Moved `tapResponse` to `@ngrx/operators`.
*
[`core-web/apps/dotcms-ui/src/app/portlets/dot-templates/dot-template-create-edit/store/dot-template.store.ts`](diffhunk://#diff-7cdbc60fb309458c9c97919670ee9f2700e6f97077360d7b2c60be5d8915f1eaL1-R2):
Moved `tapResponse` to `@ngrx/operators`.
*
[`core-web/libs/block-editor/src/lib/extensions/ai-content-prompt/store/ai-content-prompt.store.ts`](diffhunk://#diff-8f6f04bd9db2042134fa2de4e51c610392f77e63c5a38920836f43046d721329L1-R2):
Moved `tapResponse` to `@ngrx/operators`.
*
[`core-web/libs/edit-content/src/lib/feature/edit-content/store/edit-content.store.ts`](diffhunk://#diff-ed3e9ecca632a2f217989f35608b4eedd1576950bda10c74f8598e83a4703016L1-L44):
Reorganized imports and moved `tapResponse` to `@ngrx/operators`.

Additional changes:

*
[`core-web/libs/edit-content/src/lib/feature/edit-content/store/edit-content.store.ts`](diffhunk://#diff-ed3e9ecca632a2f217989f35608b4eedd1576950bda10c74f8598e83a4703016L68-R62):
Added type annotation to `initialState` and updated computed property
logic.
[[1]](diffhunk://#diff-ed3e9ecca632a2f217989f35608b4eedd1576950bda10c74f8598e83a4703016L68-R62)
[[2]](diffhunk://#diff-ed3e9ecca632a2f217989f35608b4eedd1576950bda10c74f8598e83a4703016L80-R79)
*
[`core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts`](diffhunk://#diff-c7ed916450978a3e5c2f603d2569e0b817eacf6ad6abaf91c8a116fde84f14beR58):
Added temporary protected state for unit tests.
*
[`core-web/libs/portlets/edit-ema/portlet/src/lib/store/dot-uve.store.ts`](diffhunk://#diff-42fdc01a4da73b6ecede38045c03fd631badeb73e299fbb4ed6442eb1f3ad963R31):
Added temporary protected state for unit tests.

### Checklist
- [ ] Tests
- [ ] Translations
- [ ] Security Implications Contemplated (add notes if applicable)
  • Loading branch information
oidacra authored Nov 15, 2024
1 parent 52a1ac9 commit 0dfb0a3
Show file tree
Hide file tree
Showing 32 changed files with 291 additions and 74 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
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 @@ -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
@@ -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, inject } 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 { EMPTY, Observable, forkJoin } from 'rxjs';

import { Injectable, inject } from '@angular/core';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const initialState: UVEState = {
};

export const UVEStore = signalStore(
{ protectedState: false }, // TODO: remove when the unit tests are fixed
withState<UVEState>(initialState),
withComputed(
({
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, type, withMethods } from '@ngrx/signals';
import { rxMethod } from '@ngrx/signals/rxjs-interop';
import { EMPTY, pipe } from 'rxjs';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect } from '@jest/globals';
import { SpyObject } from '@ngneat/spectator';
import { createServiceFactory, mockProvider, SpectatorService } from '@ngneat/spectator/jest';
import { signalStore, withState, patchState } from '@ngrx/signals';
import { patchState, signalStore, withState } from '@ngrx/signals';
import { of } from 'rxjs';

import { ActivatedRoute, Router } from '@angular/router';
Expand Down Expand Up @@ -68,7 +68,11 @@ const initialState: UVEState = {
pageIsLocked: true
};

export const uveStoreMock = signalStore(withState<UVEState>(initialState), withEditor());
export const uveStoreMock = signalStore(
{ protectedState: false },
withState<UVEState>(initialState),
withEditor()
);

describe('withEditor', () => {
let spectator: SpectatorService<InstanceType<typeof uveStoreMock>>;
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, type, withMethods } from '@ngrx/signals';
import { rxMethod } from '@ngrx/signals/rxjs-interop';
import { EMPTY, forkJoin, of, 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, 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 } from 'rxjs';

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

0 comments on commit 0dfb0a3

Please sign in to comment.