Skip to content

Commit

Permalink
Containers and Categories migration to NG (#23291)
Browse files Browse the repository at this point in the history
* Create empty container portlet (#22783)

* copy container rest endpoint added with curl tests (#22944)

* copy container rest endpoint added with curl tests

* Addressed MR comments

* Addressed MR commentsby removing uuid validation as it is not needed

* fixed by importing required code

* Addressed PR comments by removing UUIDUtil import

* Added Tabs to Container Create Page and updated language strings (#22932)

* Added Tabs to Container Create Page and updated translation strings

* Removed unused comment

* Bulk delete container (#22973)

* bulk delete rest endpoint

* curl tests for bulk delete

* more ids added for bulk delete operation

* updated authorization user's password

* Container bulk operations (#23012)

* Container bulk publish/unpublish rest endpoints

* Container bulk archive/unarchive rest endpoints

* curl/postman tests for container bulk publish

* curl/postman tests for all bulk operations

* fixed failed test

* Container permission and history iframes (#23025)

* Added Container listing table and Filters (#22920)

* [WIP] Added Container listing and filters to Container list page

* [WIP] Refactor Container list to use already provided Container Interface

* [WIP] Container status is now displayed correctly

* [WIP] Updated unit tests and minor refactor

* Fixed unit test and listing data table

* Added template outlet before listing table search, Container list style and ui refactor

* Added strings to Language file and updated string keys in Container List component

* Added Component Store to Container Component

* Modified container list component to better use selectors

* moved activeRoue logic to store

* Refactored ContainerList functionality to ContainerListStore

* Method name refactor and State update minimisation

* Fixed state initialization

* Categories permissions iframe added (#23032)

* code adjustments as per error handling standard (#23031)

* Feature/container lisiting complete actions (#23030)

* [WIP] Added Container listing and filters to Container list page

* [WIP] Refactor Container list to use already provided Container Interface

* [WIP] Container status is now displayed correctly

* [WIP] Updated unit tests and minor refactor

* Fixed unit test and listing data table

* Added template outlet before listing table search, Container list style and ui refactor

* Added strings to Language file and updated string keys in Container List component

* [WIP] Added actions and Container service to handle actions

* Updated unit tests

* Added Component Store to Container Component

* Modified container list component to better use selectors

* moved activeRoue logic to store

* Refactored ContainerList functionality to ContainerListStore

* Method name refactor and State update minimisation

* Fixed state initialization

* [WIP] Added context menu actions and updated tests

* Fixed Unit tests

* Fixed Unit tests

* Update core-web/apps/dotcms-ui/src/app/api/services/dot-router/dot-router.service.ts

Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>

* Update core-web/apps/dotcms-ui/src/app/portlets/dot-containers/container-list/container-list.component.ts

Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>

* Context menu actions hooked up to container service, Updated unit tests

* Fixed store logic and fixed typos

* Refactored container list component methods to container list store, Fixed typos, Updated container routes

Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>

* Category rest endpoints for Add category, Update category and get children categories (#23029)

* Add category rest endpoint

* curl test fix

* rest endpoint added to get children categories by parent inode

* curl/postman tests

* addressed PR comments and also renamed API from children to _children

* reverted API name from _children to children

* Updated API documentation

* Code changes as per suggestions from code reviewing team

* removed unnecessary imports

* Update category rest endpoint added

* little changes

* fix for the curl test

* Delete category rest endpoint (#23080)

* Delete category rest endpoint

* addressed feedback from BE team

* Feature/container properties form (#23020)

* Added Tabs to Container Create Page and updated translation strings

* Added container properties component and added Inplace editor to it

* Removed unused comment

* [WIP] Properties form UI updated

* Added Monaco Editor to Properties Form

* add history and permission iframe

* refactoring

* create edit route for container and resolver

* Added controls to container form

* change component and folders name

* Added method docs, Added translations, Minor fixes

* Added missing translations

* Added MonacoEditor type model for reusability

* CSS refactor

* CSS refactor

* Renamed container create component as DotContainerCreateComponent

* Component and SCSS refactor

* Refactored Loop editor to new component

* Update core-web/apps/dotcms-ui/src/app/portlets/dot-containers/dot-container-create/dot-container-history/dot-container-history.component.ts

Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>

* Update core-web/apps/dotcms-ui/src/app/portlets/dot-containers/dot-container-create/dot-container-permissions/dot-container-permissions.component.ts

Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>

* Refactored Content Editor to new component

* Fixed Permissions and History componanets

* change css style and remove unnecessary ng deep

* change css style and remove unnecessary ng deep

* Update core-web/apps/dotcms-ui/src/app/portlets/dot-containers/dot-container-create/dot-container-create.component.scss

Co-authored-by: Freddy Montes <freddymontes@gmail.com>

* Update core-web/apps/dotcms-ui/src/app/portlets/dot-containers/dot-container-create/dot-content-editor/store/dot-content-editor.store.ts

Co-authored-by: Freddy Montes <freddymontes@gmail.com>

* Removed unnecessary monaco editor initializations

* fixed box height issue

Co-authored-by: Zulqarnain Huda <zulqarnain.huda@venturedive.com>
Co-authored-by: zulqarnainvd <113915849+zulqarnainvd@users.noreply.github.com>
Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>
Co-authored-by: Freddy Montes <freddymontes@gmail.com>

* Rest endpoint to update categories for sortOrder (#23091)

* Rest endpoint to update categories for sortOrder

* updated credentials

* Addressed PR feedback

* add permissions and history tab and load Iframe in Tabs (#23092)

* add permissions and history tab and load Iframe in Tabs

* write test cases using host component method and use variable in scss

* Export categories rest endpoint (#23108)

* Export categories rest endpoint

* addressed PR feedback

* Add/Get container details (#23126)

* improvements in old code

* add container rest endpoint added

* Container details endpoint added to fetch container + structures info combinely

* curl test + improvements

* addressed PR feedback for _add rest endpoint

* removed details endpoint and added support in the live and working endpoint to fetch contentTypes

* code cleanup

* Import categories rest endpoint (#23125)

* Import categories rest endpoint

* addressed PR feedback on categories import

* addressed further feedback on categories import

* Addressed PR feedback

* converted categoryDTO to immutable

* container rest endpoint modified to accept container code changes (#23157)

* container rest endpoint modified to accept container code changes

* curl/postman test added

* Curl test fix (#23161)

* changed admin user's password

* fixed curl test

* updated tests assertions

* removed obsolete code/classes for categories (#23168)

* removed obsolete code/classes for categories

* Removed useless entries

* removed servlet-mapping from web.xml

* Feature/categories permissions (#23047)

* categories initialization

* fix unit test of category component

* add Category Table and actions

* add sub category beadcrumb and update sub category in table

* modify subCategoryUrl and fix typo in table

* add permission component and create a store

* change folder name and css class convention

* add docs and refactor the code

* add doc

* disable home button

* changing code according to suggestions and write unit test of categorly listing component

* add action header and Table UI of categories

* add pagination and search filter

* feat: working on categories

* feat: working on categories

* add pagination and search filter

* refactoring and change doc

* otCMS/core#23253 Categories: Fix the sort order in the endpoint

* Revert "removed obsolete code/classes for categories (#23168)" (#23288)

This reverts commit 2762511.

* Container Form (#23110)

* Added Simple form to container properties

* add confirmation dialog on clear

* Container can now be added using the simple form

* fix create container route issue and get data in container properties

* Added inplace data variable and fixed inplace CSS

* Form is now editable

* add Variable popup model

* Added form validation and disabled button on zero max contentlets

* Load content type from different source

* add content type to menu state

* get contentStructure value from child component to parent

* Variable modal now works

* Fixes to container add code

* Addressed Feedback

* Addressed Feedback

* set variable in editor

* Added update logic, Fixed failing unit tests

* Fixed faorm initilisation issue

* Addressed Feedback

* changes according to PR

* Fixed notification issue in container list

* Fixed container list empty messages and linked butoon to create container

* changes according to new API and requested PR changes

* changes according to PR and working fedback UI 3 issues

* Container Add form CSS Fixes

* Added label and CSS fixes

* Fixed clear button

* Title field now enabled on container Add form

* disable save button when required fields is empty or on edit value is not changed

* #23144 Added API Link Component, Fixed button text

* fix UI issues

* fix UI issues and test cases

* refactor code

* Fixed CSS, Updated url to load system containers

* Disabled interaction in container list for System Container

* Updated tests

* fix contentType Variable issue and container listing scroll issue

* Removed optional identifier from container Request

* fix reported issues

* Removed  from container properties template

* refactoring and change name of resolver

* PR requested changes

* remove validation of description field

* Conatiner Properties Form UI Fixes

* Implemented Control Value Accessor for DotLoopEditor Component

* Code impovements and fixes

* #23146 Refactored Content Editor component into a angular form control

* #23146 [WIP] Adding data to form control

* Rename code component

Co-authored-by: Zulqarnain Huda <zulqarnain.huda@venturedive.com>
Co-authored-by: Freddy Montes <751424+fmontes@users.noreply.github.com>

* get categories childrens and add breadcrumb (#23260)

* get categories childrens and add breadcrumb

* refactor: changes according to PR

* refactor: add unit test case of category listing component

* #23252 working on categories feedbacks and write test cases

* #23252 working on categories feedbacks and write test cases

* Fix tests build for containers

* Clean up model

* Clean up renamed container

* #23252 fix category filter issue (#23308)

* Added children count in the top level categories list (#23263)

* Added children count in the top level categories list

* added categories paginator for additional information

* Addressed PR feedback

* added line space at line number 94

* added java doc on the CategoryResource API + added postman tests

* Fix import

Co-authored-by: Daniel Silva <daniel.silva@dotcms.com>
Co-authored-by: hassan-mustafa-baig <111717530+hassan-mustafa-baig@users.noreply.github.com>
Co-authored-by: motasimvd <62100713+motasimvd@users.noreply.github.com>
Co-authored-by: Rafael Velazco <rjvelazco21@gmail.com>
Co-authored-by: Zulqarnain Huda <zulqarnain.huda@venturedive.com>
Co-authored-by: zulqarnainvd <113915849+zulqarnainvd@users.noreply.github.com>
  • Loading branch information
7 people committed Nov 7, 2022
1 parent 0e63e1e commit deccd13
Show file tree
Hide file tree
Showing 138 changed files with 14,421 additions and 1,569 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';

import { CoreWebService } from '@dotcms/dotcms-js';

import { DotHttpErrorManagerService } from '@services/dot-http-error-manager/dot-http-error-manager.service';
import {
DotCategoriesService,
CATEGORY_API_URL,
CATEGORY_CHILDREN_API_URL
} from './dot-categories.service';
import { CoreWebServiceMock } from '@tests/core-web.service.mock';
import { of } from 'rxjs';
import {
CATEGORY_SOURCE,
DotCategory
} from '@dotcms/app/shared/models/dot-categories/dot-categories.model';

const mockCategory: DotCategory = {
categoryId: '1222',
categoryName: 'Test',
key: 'adsdsd',
sortOrder: 1,
deleted: false,
categoryVelocityVarName: 'sdsdsds',
friendlyName: 'asas',
identifier: '1222',
inode: '2121',
name: 'Test',
type: 'ggg',
source: CATEGORY_SOURCE.DB
};

describe('DotCategorysService', () => {
let service: DotCategoriesService;
let httpMock: HttpTestingController;

beforeEach(() => {
TestBed.configureTestingModule({
providers: [
DotCategoriesService,
{
provide: DotHttpErrorManagerService,
useValue: {
handle() {
return of({});
}
}
},
{
provide: CoreWebService,
useClass: CoreWebServiceMock
}
],
imports: [HttpClientTestingModule]
});
service = TestBed.inject(DotCategoriesService);

httpMock = TestBed.inject(HttpTestingController);
});

it('should get a categories list', () => {
service
.getCategories({
first: 0,
rows: 40,
sortOrder: 1,
filters: {},
globalFilter: null
})
.subscribe((categories: DotCategory[]) => {
expect(categories).toEqual([mockCategory]);
});

const req = httpMock.expectOne(`${CATEGORY_API_URL}?direction=ASC&per_page=40`);

expect(req.request.method).toBe('GET');

req.flush({
entity: [mockCategory]
});
});

it('should get a children categories list', () => {
service
.getChildrenCategories({
first: 0,
rows: 40,
sortOrder: 1,
filters: {
inode: { value: '123' }
},
globalFilter: null
})
.subscribe((categories: DotCategory[]) => {
expect(categories).toEqual([mockCategory]);
});

const req = httpMock.expectOne(
`${CATEGORY_CHILDREN_API_URL}?direction=ASC&per_page=40&inode=123`
);

expect(req.request.method).toBe('GET');

req.flush({
entity: [mockCategory]
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Injectable } from '@angular/core';
import { DotCategory } from '@dotcms/app/shared/models/dot-categories/dot-categories.model';
import { CoreWebService } from '@dotcms/dotcms-js';
import { LazyLoadEvent } from 'primeng/api';
import { Observable } from 'rxjs';
import { OrderDirection, PaginatorService } from '../paginator';

export const CATEGORY_API_URL = 'v1/categories';

export const CATEGORY_CHILDREN_API_URL = 'v1/categories/children';

@Injectable()
export class DotCategoriesService extends PaginatorService {
constructor(coreWebService: CoreWebService) {
super(coreWebService);
this.url = CATEGORY_API_URL;
}

updatePaginationService(event: LazyLoadEvent) {
const { sortField, sortOrder, filters } = event;
this.setExtraParams('inode', filters?.inode?.value || null);
this.filter = event?.filters?.global?.value || '';
this.sortField = sortField;
this.sortOrder = sortOrder === 1 ? OrderDirection.ASC : OrderDirection.DESC;
}

/**
* Get categories according to pagination and search
* @param {LazyLoadEvent} [event]
* @return {*} {Observable<DotCategory[]>}
* @memberof DotCategoriesService
*/
getCategories(event: LazyLoadEvent): Observable<DotCategory[]> {
this.url = CATEGORY_API_URL;
this.updatePaginationService(event);
const page = parseInt(String(event.first / this.paginationPerPage), 10) + 1;

return this.getPage(page);
}

/**
* Get children categories according to pagination and search
* @param {LazyLoadEvent} [event]
* @return {*} {Observable<DotCategory[]>}
* @memberof DotCategoriesService
*/
getChildrenCategories(event: LazyLoadEvent): Observable<DotCategory[]> {
this.url = CATEGORY_CHILDREN_API_URL;
this.updatePaginationService(event);
const page = parseInt(String(event.first / this.paginationPerPage), 10) + 1;

return this.getPage(page);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';

import { CoreWebService } from '@dotcms/dotcms-js';

import { DotHttpErrorManagerService } from '@services/dot-http-error-manager/dot-http-error-manager.service';
import { DotContainersService, CONTAINER_API_URL } from './dot-containers.service';
import { CoreWebServiceMock } from '@tests/core-web.service.mock';
import { DotActionBulkResult } from '@models/dot-action-bulk-result/dot-action-bulk-result.model';
import { of } from 'rxjs';
import {
CONTAINER_SOURCE,
DotContainerEntity,
DotContainerPayload
} from '@models/container/dot-container.model';

const mockBulkResponseSuccess: DotActionBulkResult = {
skippedCount: 0,
successCount: 1,
fails: []
};

const mockContainer: DotContainerEntity = {
container: {
archived: false,
categoryId: '6e07301c-e6d2-4c1f-9e8e-fcc4a31947d3',
deleted: false,
friendlyName: '',
identifier: '1234',
live: true,
name: 'movie',
parentPermissionable: {
hostname: 'default'
},
path: null,
source: CONTAINER_SOURCE.DB,
title: 'movie',
type: 'containers',
working: true
},
contentTypes: []
};

describe('DotContainersService', () => {
let service: DotContainersService;
let httpMock: HttpTestingController;

beforeEach(() => {
TestBed.configureTestingModule({
providers: [
DotContainersService,
{
provide: DotHttpErrorManagerService,
useValue: {
handle() {
return of({});
}
}
},
{
provide: CoreWebService,
useClass: CoreWebServiceMock
}
],
imports: [HttpClientTestingModule]
});
service = TestBed.inject(DotContainersService);

httpMock = TestBed.inject(HttpTestingController);
});

it('should get a list of containers', () => {
service.get().subscribe((container: DotContainerEntity[]) => {
expect(container).toEqual([mockContainer]);
});

const req = httpMock.expectOne(CONTAINER_API_URL);

expect(req.request.method).toBe('GET');

req.flush({
entity: [mockContainer]
});
});

it('should get a container by id', () => {
service.getById('123').subscribe((containerEntity: DotContainerEntity) => {
expect(containerEntity).toEqual(mockContainer);
});

const req = httpMock.expectOne(`${CONTAINER_API_URL}working?containerId=123`);

expect(req.request.method).toBe('GET');

req.flush({
entity: {
...mockContainer
}
});
});

it('should get a containers by filter', () => {
service.getFiltered('123').subscribe((container: DotContainerEntity[]) => {
expect(container).toEqual([mockContainer]);
});

const req = httpMock.expectOne(`${CONTAINER_API_URL}?filter=123`);

expect(req.request.method).toBe('GET');

req.flush({
entity: [mockContainer]
});
});

it('should post to create a container', () => {
service
.create({
title: '',
friendlyName: ''
} as DotContainerPayload)
.subscribe((container: DotContainerEntity) => {
expect(container).toEqual(mockContainer);
});

const req = httpMock.expectOne(`${CONTAINER_API_URL}`);

expect(req.request.method).toBe('POST');
expect(req.request.body.title).toEqual('');
expect(req.request.body.friendlyName).toEqual('');

req.flush({
entity: mockContainer
});
});

it('should put to update a container', () => {
service
.update({
title: '',
friendlyName: ''
} as DotContainerPayload)
.subscribe((container) => {
expect(container).toEqual(mockContainer);
});

const req = httpMock.expectOne(CONTAINER_API_URL);

expect(req.request.method).toBe('PUT');
expect(req.request.body.title).toEqual('');
expect(req.request.body.friendlyName).toEqual('');

req.flush({
entity: mockContainer
});
});
it('should put to save and publish a container', () => {
service
.saveAndPublish({
container: { name: '', friendlyName: '' },
contentTypes: []
} as DotContainerEntity)
.subscribe((container: DotContainerEntity) => {
expect(container).toEqual(mockContainer);
});

const req = httpMock.expectOne(`${CONTAINER_API_URL}_savepublish`);

expect(req.request.method).toBe('PUT');
expect(req.request.body.container.name).toEqual('');
expect(req.request.body.container.friendlyName).toEqual('');

req.flush({
entity: mockContainer
});
});
it('should delete a container', () => {
service.delete(['testId01']).subscribe();
const req = httpMock.expectOne(`${CONTAINER_API_URL}_bulkdelete`);

expect(req.request.method).toBe('DELETE');
expect(req.request.body).toEqual(['testId01']);
req.flush(mockBulkResponseSuccess);
});
it('should unArchive a container', () => {
service.unArchive(['testId01']).subscribe();
const req = httpMock.expectOne(`${CONTAINER_API_URL}_bulkunarchive`);

expect(req.request.method).toBe('PUT');
expect(req.request.body).toEqual(['testId01']);
req.flush(mockBulkResponseSuccess);
});
it('should archive a container', () => {
service.archive(['testId01']).subscribe();
const req = httpMock.expectOne(`${CONTAINER_API_URL}_bulkarchive`);

expect(req.request.method).toBe('PUT');
expect(req.request.body).toEqual(['testId01']);
req.flush(mockBulkResponseSuccess);
});
it('should unPublish a container', () => {
service.unPublish(['testId01']).subscribe();
const req = httpMock.expectOne(`${CONTAINER_API_URL}_bulkunpublish`);

expect(req.request.method).toBe('PUT');
expect(req.request.body).toEqual(['testId01']);
req.flush(mockBulkResponseSuccess);
});
it('should publish a container', () => {
const identifier = 'testId01';
service.publish([identifier]).subscribe();
const req = httpMock.expectOne(`${CONTAINER_API_URL}_bulkpublish`);

expect(req.request.method).toBe('PUT');
expect(req.request.body).toEqual([identifier]);
req.flush(mockBulkResponseSuccess);
});
it('should copy a container', () => {
service.copy('testId01').subscribe();
const req = httpMock.expectOne(`${CONTAINER_API_URL}testId01/_copy`);

expect(req.request.method).toBe('PUT');
req.flush(mockContainer);
});
});
Loading

0 comments on commit deccd13

Please sign in to comment.