Skip to content

Commit

Permalink
Reorder Edit Contentlet feature folders (#31053)
Browse files Browse the repository at this point in the history
### Proposed Changes
* Reorder Edit Content folders

This pull request focuses on refactoring the directory structure and
updating imports across various files in the
`core-web/libs/edit-content` module. The main goal is to move files from
the `feature/edit-content` directory to a more streamlined structure
under `components`, `store`, and `utils`. Here are the most important
changes:

### Directory Structure Refactoring:

* **Component Imports:**
- Updated imports in `dot-edit-content-form.component.ts` to reflect the
new location of `DotEditContentStore` and other components.
[[1]](diffhunk://#diff-52fdc67adc70be54cf6c07ee18c9340c26cbf50a4d8fe5ed14a21d33def30a23L32)
[[2]](diffhunk://#diff-52fdc67adc70be54cf6c07ee18c9340c26cbf50a4d8fe5ed14a21d33def30a23R40)
- Renamed and updated imports in
`dot-edit-content.layout.component.spec.ts` and
`dot-edit-content.layout.component.ts` to reflect the new component
structure.
[[1]](diffhunk://#diff-f3c46d454601be71a4128e613b5cd301a6e4465987025305fecedd47998a7b40L36-R49)
[[2]](diffhunk://#diff-4b222ec60172ab7698c9a0cd5849ece58e0c89123e2aa81769065349b5299e05L17-R22)

* **Store Imports:**
- Updated store-related imports in various feature files
(`content.feature.ts`, `form.feature.ts`, `information.feature.ts`,
`locales.feature.ts`, `sidebar.feature.ts`, `workflow.feature.ts`) to
reflect the new directory structure.
[[1]](diffhunk://#diff-b6072f3dc518e026533710923ea651bc5b7599b328a532e87ccaf3165e799b9cL39-R41)
[[2]](diffhunk://#diff-13fc57d49e7a279ca6a21406283394a09cb6f284d70315255ad974eccad1ea02L3-R3)
[[3]](diffhunk://#diff-9b8908e25adbe8580ab3b75a89a778fddd769e45609470483c6cd5cdb5598af1L20-R20)
[[4]](diffhunk://#diff-98c3ce9499537ab7088257d66c0227fcd12440cae10485c6ac53f9544d627839L30-R37)
[[5]](diffhunk://#diff-330bd1d3d95569cdb188700d865d60462480b16f8c33e4a6f038d68d204e65b6L15-R15)
[[6]](diffhunk://#diff-f0fcc051e3fcc31af6b92c498403b31849ebba4c0b02092e6c22049d74714d85L39-R39)

* **Test Files:**
- Updated imports in test files to reflect the new structure, ensuring
all references to `DotEditContentStore` and related services are
correct.
[[1]](diffhunk://#diff-c8c6cdfd93ac483cc08a7c63eab7b6a06cbcb21d7cbe2a3c65ac7190602f7e6eL2-R2)
[[2]](diffhunk://#diff-2f1a1d6b895a7f80141dc1acc3663ee94e65a59e505fe3268a56e06c3e2a8f2cL7-R11)
[[3]](diffhunk://#diff-0bc50a497494f30caacfe9313173befd0f6d40a118f96234555aa0c2c86406b4L28-R31)

* **Utils:**
- Updated utility imports in `workflows.utils.ts` to align with the new
structure.

These changes ensure a more organized and maintainable codebase by
clearly separating components, store logic, and utilities into their
respective directories.

### Checklist
- [ ] Tests
- [ ] Translations
- [ ] Security Implications Contemplated (add notes if applicable)

### Additional Info
** any additional useful context or info **

### Screenshots
Original             |  Updated
:-------------------------:|:-------------------------:
** original screenshot **  |  ** updated screenshot **
  • Loading branch information
oidacra authored Jan 3, 2025
1 parent fe71784 commit f4a6fd3
Show file tree
Hide file tree
Showing 23 changed files with 54 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { DotKeyValueComponent } from '@dotcms/ui';

import { DotEditContentFieldComponent } from './dot-edit-content-field.component';

import { DotEditContentStore } from '../../feature/edit-content/store/edit-content.store';
import { DotEditContentBinaryFieldComponent } from '../../fields/dot-edit-content-binary-field/dot-edit-content-binary-field.component';
import { DotEditContentCalendarFieldComponent } from '../../fields/dot-edit-content-calendar-field/dot-edit-content-calendar-field.component';
import { DotEditContentCategoryFieldComponent } from '../../fields/dot-edit-content-category-field/dot-edit-content-category-field.component';
Expand All @@ -43,6 +42,7 @@ import { DotEditContentTextFieldComponent } from '../../fields/dot-edit-content-
import { DotEditContentWYSIWYGFieldComponent } from '../../fields/dot-edit-content-wysiwyg-field/dot-edit-content-wysiwyg-field.component';
import { FIELD_TYPES } from '../../models/dot-edit-content-field.enum';
import { DotEditContentService } from '../../services/dot-edit-content.service';
import { DotEditContentStore } from '../../store/edit-content.store';
import {
BINARY_FIELD_CONTENTLET,
createFormGroupDirectiveMock,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import {

import { DotEditContentFormComponent } from './dot-edit-content-form.component';

import { DotEditContentStore } from '../../feature/edit-content/store/edit-content.store';
import { CONTENT_SEARCH_ROUTE } from '../../models/dot-edit-content-field.constant';
import { DotEditContentService } from '../../services/dot-edit-content.service';
import { DotEditContentStore } from '../../store/edit-content.store';
import {
MOCK_CONTENTLET_1_TAB as MOCK_CONTENTLET_1_OR_2_TABS,
MOCK_CONTENTTYPE_1_TAB,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { DotWorkflowActionsComponent } from '@dotcms/ui';
import { resolutionValue } from './utils';

import { TabViewInsertDirective } from '../../directives/tab-view-insert/tab-view-insert.directive';
import { DotEditContentStore } from '../../feature/edit-content/store/edit-content.store';
import {
CALENDAR_FIELD_TYPES,
CONTENT_SEARCH_ROUTE,
Expand All @@ -38,6 +37,7 @@ import {
import { FIELD_TYPES } from '../../models/dot-edit-content-field.enum';
import { FormValues } from '../../models/dot-edit-content-form.interface';
import { DotWorkflowActionParams } from '../../models/dot-edit-content.model';
import { DotEditContentStore } from '../../store/edit-content.store';
import { getFinalCastedValue, isFilteredType } from '../../utils/functions.util';
import { DotEditContentFieldComponent } from '../dot-edit-content-field/dot-edit-content-field.component';

Expand Down Expand Up @@ -88,7 +88,7 @@ import { DotEditContentFieldComponent } from '../dot-edit-content-field/dot-edit
]
})
export class DotEditContentFormComponent implements OnInit {
readonly $store = inject(DotEditContentStore);
readonly $store: InstanceType<typeof DotEditContentStore> = inject(DotEditContentStore);
readonly #router = inject(Router);
readonly #destroyRef = inject(DestroyRef);
readonly #fb = inject(FormBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ import {
MOCK_SINGLE_WORKFLOW_ACTIONS
} from '@dotcms/utils-testing';

import { EditContentLayoutComponent } from './edit-content.layout.component';
import { DotEditContentStore } from './store/edit-content.store';
import { DotEditContentLayoutComponent } from './dot-edit-content.layout.component';

import { DotEditContentFormComponent } from '../../components/dot-edit-content-form/dot-edit-content-form.component';
import { DotEditContentSidebarComponent } from '../../components/dot-edit-content-sidebar/dot-edit-content-sidebar.component';
import { DotEditContentService } from '../../services/dot-edit-content.service';
import { DotEditContentStore } from '../../store/edit-content.store';
import { MOCK_CONTENTLET_1_TAB } from '../../utils/edit-content.mock';
import * as utils from '../../utils/functions.util';
import { CONTENT_TYPE_MOCK } from '../../utils/mocks';
import { DotEditContentFormComponent } from '../dot-edit-content-form/dot-edit-content-form.component';
import { DotEditContentSidebarComponent } from '../dot-edit-content-sidebar/dot-edit-content-sidebar.component';

const MOCK_LANGUAGES = [{ id: 1, isoCode: 'en-us', defaultLanguage: false }] as DotLanguage[];

describe('EditContentLayoutComponent', () => {
let spectator: Spectator<EditContentLayoutComponent>;
let spectator: Spectator<DotEditContentLayoutComponent>;

let store: SpyObject<InstanceType<typeof DotEditContentStore>>;
let dotContentTypeService: SpyObject<DotContentTypeService>;
Expand All @@ -55,7 +55,7 @@ describe('EditContentLayoutComponent', () => {
let dotLanguagesService: SpyObject<DotLanguagesService>;

const createComponent = createComponentFactory({
component: EditContentLayoutComponent,
component: DotEditContentLayoutComponent,
imports: [
MockModule(MessagesModule),
MockComponent(DotEditContentFormComponent),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ import {
} from '@dotcms/data-access';
import { DotMessagePipe } from '@dotcms/ui';

import { DotEditContentStore } from './store/edit-content.store';

import { DotEditContentFormComponent } from '../../components/dot-edit-content-form/dot-edit-content-form.component';
import { DotEditContentSidebarComponent } from '../../components/dot-edit-content-sidebar/dot-edit-content-sidebar.component';
import { FormValues } from '../../models/dot-edit-content-form.interface';
import { DotEditContentService } from '../../services/dot-edit-content.service';
import { DotEditContentStore } from '../../store/edit-content.store';
import { DotEditContentFormComponent } from '../dot-edit-content-form/dot-edit-content-form.component';
import { DotEditContentSidebarComponent } from '../dot-edit-content-sidebar/dot-edit-content-sidebar.component';

/**
* Component that displays the edit content layout.
Expand Down Expand Up @@ -52,11 +51,11 @@ import { DotEditContentService } from '../../services/dot-edit-content.service';
host: {
'[class.edit-content--with-sidebar]': '$store.showSidebar()'
},
templateUrl: './edit-content.layout.component.html',
styleUrls: ['./edit-content.layout.component.scss'],
templateUrl: './dot-edit-content.layout.component.html',
styleUrls: ['./dot-edit-content.layout.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class EditContentLayoutComponent {
export class DotEditContentLayoutComponent {
/**
* The store instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import { DotEditContentSidebarInformationComponent } from './components/dot-edit
import { DotEditContentSidebarWorkflowComponent } from './components/dot-edit-content-sidebar-workflow/dot-edit-content-sidebar-workflow.component';
import { DotEditContentSidebarComponent } from './dot-edit-content-sidebar.component';

import { DotEditContentStore } from '../../feature/edit-content/store/edit-content.store';
import { DotEditContentService } from '../../services/dot-edit-content.service';
import { DotEditContentStore } from '../../store/edit-content.store';
import { MOCK_WORKFLOW_STATUS } from '../../utils/edit-content.mock';
import { MockResizeObserver } from '../../utils/mocks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { DotEditContentSidebarSectionComponent } from './components/dot-edit-con
import { DotEditContentSidebarWorkflowComponent } from './components/dot-edit-content-sidebar-workflow/dot-edit-content-sidebar-workflow.component';

import { TabViewInsertDirective } from '../../directives/tab-view-insert/tab-view-insert.directive';
import { DotEditContentStore } from '../../feature/edit-content/store/edit-content.store';
import { DotWorkflowState } from '../../models/dot-edit-content.model';
import { DotEditContentStore } from '../../store/edit-content.store';

/**
* The DotEditContentSidebarComponent is a component that displays the sidebar for the DotCMS content editing application.
Expand Down
6 changes: 3 additions & 3 deletions core-web/libs/edit-content/src/lib/edit-content.routes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Route } from '@angular/router';

import { DotEditContentLayoutComponent } from './components/dot-edit-content-layout/dot-edit-content.layout.component';
import { EditContentShellComponent } from './edit-content.shell.component';
import { EditContentLayoutComponent } from './feature/edit-content/edit-content.layout.component';

export const DotEditContentRoutes: Route[] = [
{
Expand All @@ -11,12 +11,12 @@ export const DotEditContentRoutes: Route[] = [
{
path: 'new/:contentType',
title: 'Create Content',
component: EditContentLayoutComponent
component: DotEditContentLayoutComponent
},
{
path: ':id',
title: 'Edit Content',
component: EditContentLayoutComponent
component: DotEditContentLayoutComponent
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { ComponentStatus } from '@dotcms/dotcms-models';

import { DotEditContentStore } from './edit-content.store';

import { DotEditContentService } from '../../../services/dot-edit-content.service';
import { DotEditContentService } from '../services/dot-edit-content.service';

describe('DotEditContentStore', () => {
let spectator: SpectatorService<InstanceType<typeof DotEditContentStore>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { inject } from '@angular/core';
import { ActivatedRoute } from '@angular/router';

import { ComponentStatus } from '@dotcms/dotcms-models';
import { withLocales } from '@dotcms/edit-content/feature/edit-content/store/features/locales.feature';

import { withContent } from './features/content.feature';
import { withForm } from './features/form.feature';
import { withInformation } from './features/information.feature';
import { withLocales } from './features/locales.feature';
import { withSidebar } from './features/sidebar.feature';
import { withWorkflow } from './features/workflow.feature';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import { MOCK_SINGLE_WORKFLOW_ACTIONS } from '@dotcms/utils-testing';
import { withContent } from './content.feature';
import { workflowInitialState } from './workflow.feature';

import { DotEditContentService } from '../../../../services/dot-edit-content.service';
import { MOCK_WORKFLOW_STATUS } from '../../../../utils/edit-content.mock';
import { CONTENT_TYPE_MOCK } from '../../../../utils/mocks';
import { parseCurrentActions, parseWorkflows } from '../../../../utils/workflows.utils';
import { DotEditContentService } from '../../services/dot-edit-content.service';
import { MOCK_WORKFLOW_STATUS } from '../../utils/edit-content.mock';
import { CONTENT_TYPE_MOCK } from '../../utils/mocks';
import { parseCurrentActions, parseWorkflows } from '../../utils/workflows.utils';
import { initialRootState } from '../edit-content.store';

describe('ContentFeature', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ import { DotContentletState } from '@dotcms/edit-content/models/dot-edit-content

import { WorkflowState } from './workflow.feature';

import { DotEditContentService } from '../../../../services/dot-edit-content.service';
import { transformFormDataFn } from '../../../../utils/functions.util';
import { parseCurrentActions, parseWorkflows } from '../../../../utils/workflows.utils';
import { DotEditContentService } from '../../services/dot-edit-content.service';
import { transformFormDataFn } from '../../utils/functions.util';
import { parseCurrentActions, parseWorkflows } from '../../utils/workflows.utils';
import { EditContentRootState } from '../edit-content.store';

export interface ContentState {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { patchState, signalStoreFeature, withMethods, withState } from '@ngrx/signals';

import { FormValues } from '../../../../models/dot-edit-content-form.interface';
import { FormValues } from '../../models/dot-edit-content-form.interface';

export interface FormState {
formValues: FormValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { switchMap, tap } from 'rxjs/operators';
import { DotHttpErrorManagerService } from '@dotcms/data-access';
import { ComponentStatus } from '@dotcms/dotcms-models';

import { DotEditContentService } from '../../../../services/dot-edit-content.service';
import { DotEditContentService } from '../../services/dot-edit-content.service';

export interface InformationState {
information: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { SpyObject, createServiceFactory, SpectatorService } from '@ngneat/spectator/jest';
import { createServiceFactory, SpectatorService, SpyObject } from '@ngneat/spectator/jest';
import { patchState, signalStore, signalStoreFeature, withMethods, withState } from '@ngrx/signals';
import { of } from 'rxjs';

Expand All @@ -16,11 +16,13 @@ import {
DotMessageService
} from '@dotcms/data-access';
import { ComponentStatus, DotLanguage } from '@dotcms/dotcms-models';
import { initialRootState } from '@dotcms/edit-content/feature/edit-content/store/edit-content.store';
import { contentInitialState } from '@dotcms/edit-content/feature/edit-content/store/features/content.feature';
import { withLocales } from '@dotcms/edit-content/feature/edit-content/store/features/locales.feature';
import { workflowInitialState } from '@dotcms/edit-content/feature/edit-content/store/features/workflow.feature';
import { DotEditContentService } from '@dotcms/edit-content/services/dot-edit-content.service';

import { contentInitialState } from './content.feature';
import { withLocales } from './locales.feature';
import { workflowInitialState } from './workflow.feature';

import { DotEditContentService } from '../../services/dot-edit-content.service';
import { initialRootState } from '../../store/edit-content.store';

const MOCK_LANGUAGES = [
{ id: 1, isoCode: 'en-us', translated: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import {
} from '@dotcms/data-access';
import { ComponentStatus, DotCMSContentlet, DotLanguage } from '@dotcms/dotcms-models';
import { DotEditContentSidebarUntranslatedLocaleComponent } from '@dotcms/edit-content/components/dot-edit-content-sidebar/components/dot-edit-content-sidebar-untranslated-locale/dot-edit-content-sidebar-untranslated-locale.component';
import { EditContentRootState } from '@dotcms/edit-content/feature/edit-content/store/edit-content.store';
import { ContentState } from '@dotcms/edit-content/feature/edit-content/store/features/content.feature';
import { FormState } from '@dotcms/edit-content/feature/edit-content/store/features/form.feature';
import { WorkflowState } from '@dotcms/edit-content/feature/edit-content/store/features/workflow.feature';
import { DotEditContentService } from '@dotcms/edit-content/services/dot-edit-content.service';
import { parseCurrentActions } from '@dotcms/edit-content/utils/workflows.utils';

import { ContentState } from './content.feature';
import { FormState } from './form.feature';
import { WorkflowState } from './workflow.feature';

import { DotEditContentService } from '../../services/dot-edit-content.service';
import { EditContentRootState } from '../../store/edit-content.store';
import { parseCurrentActions } from '../../utils/workflows.utils';

export interface LocalesState {
locales: DotLanguage[] | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { computed } from '@angular/core';

import { ContentState } from './content.feature';

import { getPersistSidebarState, setPersistSidebarState } from '../../../../utils/functions.util';
import { getPersistSidebarState, setPersistSidebarState } from '../../utils/functions.util';

export interface SidebarState {
showSidebar: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import {
MOCK_CONTENTLET_1_TAB,
MOCK_WORKFLOW_ACTIONS_NEW_ITEMNTTYPE_1_TAB,
MOCK_WORKFLOW_DATA
} from '../../../../utils/edit-content.mock';
import { CONTENT_TYPE_MOCK } from '../../../../utils/mocks';
import { parseCurrentActions, parseWorkflows } from '../../../../utils/workflows.utils';
} from '../../utils/edit-content.mock';
import { CONTENT_TYPE_MOCK } from '../../utils/mocks';
import { parseCurrentActions, parseWorkflows } from '../../utils/workflows.utils';
import { initialRootState } from '../edit-content.store';

const mockInitialStateWithContent: ContentState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {

import { ContentState } from './content.feature';

import { parseCurrentActions } from '../../../../utils/workflows.utils';
import { parseCurrentActions } from '../../utils/workflows.utils';
import { EditContentRootState } from '../edit-content.store';

export type CurrentContentActionsWithScheme = Record<string, DotCMSWorkflowAction[]>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DotCMSWorkflow, DotCMSWorkflowAction, WorkflowStep } from '@dotcms/dotcms-models';

import { CurrentContentActionsWithScheme } from '../feature/edit-content/store/features/workflow.feature';
import { CurrentContentActionsWithScheme } from '../store/features/workflow.feature';

/**
* Parses an array of workflow data and returns a new object with key-value pairs.
Expand Down

0 comments on commit f4a6fd3

Please sign in to comment.