Ng17 migration (#10295)

* Migrate to NG17

* [ci:force] - fixed deps

* [ci:force] - fixed build for testing 1

* Fixed build for all the packages

* [ci:force] - fixing lint

* [ci:force] - Fixed lint

* AAE-26163 Fix infinite loop when authentication error event occured (#10272)

* AAE-26163 Logout user after 3 login attempts failed, avoiding infinite loop when an authentication error occured, like when a user machine clock is significantly out of sync

* AAE-26163 Wait to discovery document to be loaded and user not authenticated to perform a ssoLogin, logout user if login fails after 3 attempts

* AAE-26163 Fix missed id_token_hint invoking logout when a login error occured due to a clock significantly out of sync

* AAE-26163 Add fake observable to unit test

* AAE-26163 Show oauth event logs if showDebugInformation is enabled, remove auth items if access token is not valid

* AAE-26163 Improve tryLogin error message

* AAE-26163 Check if token has expired to fix case when user access the application after the token is expired and with a clock significantly out of sync

* AAE-26163 Test logout when clock is out of sync

* AAE-26163 Create a service to check if local machine time is out of sync

* AAE-26163 Update oauthErrorEvent$ and combinedOAuthErrorsStream$ to return errors

* AAE-26163 Output error within combined oauth error event subscription

* AAE-26163 Fix lint problems

* AAE-26163 Logout user when token refresh error happens for the second time, if the token is not refreshed properly after first refresh error

* AAE-26163 Logout user once an oauth error event occur due to clock out of sync

* AAE-26163 Fix retry login error message if the OAuthErrorEvent doesn t return reason

* AAE-26163 Fix the issue where the logout API call is canceled by the authorize call when login fails due to clock synchronization problems, causing an infinite loop.

* remove console.log

* AAE-26163 Fix retry login error message if the OAuthErrorEvent reason is an empty object

* Cherry picked commit from oidc and run fix lint

* [MIGRATION] - fixed build and lint

* [MIGRATION] - Added injectionContext to avoid error NG0203 for unit tests

* [MIGRATION] - Moving mocha to jest

* [MIGRATION] - Fixing failing migrated tests

* [MIGRATION] - Migrating to Jest - working but some tests fails

* Trying to fix js-api unit tests

* Removing testing lib to sync with develop

* Fixed two excluded unit tests

* Removed unused project parts

* Removed unused project parts

* Reduced tserrors on building storybook

* Fixed sonarqube errors

* Removing temporarily eslint rule from publishing

* [MIGRATION] - Fixed lint

* [MIGRATION] - Fixed type

* [MIGRATION] - Rebased

* [MIGRATION] - Readded removed action

* [MIGRATION] - Checking deps

* [MIGRATION] - updated lock

* [ACS-9052] manage versions close button is too low (#10466)

* [ci:force] - Fixed lint

* [ACS-9052] Fixed close button in version manager position

* [ACS-9052] Reverted unwanted changes

---------

Co-authored-by: VitoAlbano <vito.albano.123@gmail.com>

* [MIGRATION] - fixed storybook builds

* [MIGRATION] - Checking if now eslint is releasable

* [MIGRATION] - Changing the building executor for eslint-rules

* Readded rule for peer deps

* Fixed wrong rule

* [ACS-9075] Fixed incorrect buttons labels color (#10489)

* Update package.json

* Fix ACA pipeline

* [ACS-9084] Fixed incorrect color for notification bell icon (#10513)

* Change dialog label padding

* [AAE-26767] - Fixed lint

* [AAE-26767] - Fixed lint

* updated dependencies

* AAE-30733 Fix incorrect alignment of icons in permission list header

* [MIGRATION] - sync package-lock

* [MIGRATION] - Fixed package on core lib

* [MIGRATION] - Removed unused lock

* Fixed licence

* [MIGRATION] - sync lock file

* [MIGRATION] - fixed lint issues

* [ACS-9271][ACA] Login page input labels are cut if the input is not empty (#10637)

* AAE-31453 Override card-view-textitem readonly color

---------

Co-authored-by: Amedeo Lepore <amedeo.lepore@hyland.com>
Co-authored-by: Ehsan Rezaei <ehsan.rezaei@hyland.com>
Co-authored-by: AleksanderSklorz <115619721+AleksanderSklorz@users.noreply.github.com>
Co-authored-by: DominikIwanek <dominik.iwanek@hyland.com>
Co-authored-by: swapnil-verma-gl <92505353+swapnil-verma-gl@users.noreply.github.com>
Co-authored-by: Wojciech Duda <69160975+wojd0@users.noreply.github.com>
Co-authored-by: dominikiwanekhyland <141320833+dominikiwanekhyland@users.noreply.github.com>
This commit is contained in:
Vito Albano 2025-02-12 11:58:57 +00:00 committed by GitHub
parent 2284ede0c7
commit 5d64c7f0ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
317 changed files with 16460 additions and 15654 deletions

View File

@ -10,3 +10,4 @@ scripts
docs/**/*.md
lib/js-api/docs/**/*.md
.storybook
webpack.config.js

View File

@ -234,7 +234,7 @@ jobs:
- uses: ./.github/actions/setup
- uses: ./.github/actions/download-node-modules-and-artifacts
- run: NX_REJECT_UNKNOWN_LOCAL_CACHE=0 npx nx affected:build $NX_CALCULATION_FLAGS --prod
- run: NX_REJECT_UNKNOWN_LOCAL_CACHE=0 npx nx affected --target=build-storybook $NX_CALCULATION_FLAGS --configuration=ci --parallel=1
- run: NX_REJECT_UNKNOWN_LOCAL_CACHE=0 npx nx affected --target=build-storybook $NX_CALCULATION_FLAGS --configuration=ci
- uses: ./.github/actions/upload-node-modules-and-artifacts
PR-forbidden-labels:

4
jest.preset.js Normal file
View File

@ -0,0 +1,4 @@
// eslint-disable
const nxPreset = require('@nx/jest/preset').default;
module.exports = {...nxPreset };

View File

@ -50,7 +50,7 @@
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": ["lib/cli/**/*.ts", "lib/cli/**/*.html"]
}

View File

@ -33,7 +33,7 @@
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": ["lib/content-services/**/*.ts", "lib/content-services/**/*.html"]
}
@ -45,10 +45,7 @@
"browserTarget": "content-services:storybook",
"configDir": "lib/content-services/.storybook",
"compodoc": false,
"styles": [
"node_modules/cropperjs/dist/cropper.min.css",
"node_modules/pdfjs-dist/web/pdf_viewer.css"
],
"styles": ["node_modules/cropperjs/dist/cropper.min.css", "node_modules/pdfjs-dist/web/pdf_viewer.css"],
"stylePreprocessorOptions": {
"includePaths": ["lib", "lib/core/src/lib"]
}
@ -66,10 +63,7 @@
"configDir": "lib/content-services/.storybook",
"outputDir": "dist/storybook/content-services",
"compodoc": false,
"styles": [
"node_modules/cropperjs/dist/cropper.min.css",
"node_modules/pdfjs-dist/web/pdf_viewer.css"
],
"styles": ["node_modules/cropperjs/dist/cropper.min.css", "node_modules/pdfjs-dist/web/pdf_viewer.css"],
"stylePreprocessorOptions": {
"includePaths": ["lib", "lib/core/src/lib"]
}

View File

@ -23,18 +23,17 @@ import { AlfrescoApiService } from '../services/alfresco-api.service';
@Injectable()
export class AlfrescoApiNoAuthService extends AlfrescoApiService {
constructor(
storage: StorageService,
appConfig: AppConfigService,
private readonly adfHttpClient: AdfHttpClient
) {
constructor(storage: StorageService, appConfig: AppConfigService, private readonly adfHttpClient: AdfHttpClient) {
super(appConfig, storage);
}
override createInstance(config: AlfrescoApiConfig) {
return new AlfrescoApi({
return new AlfrescoApi(
{
...config,
oauthInit: false
}, this.adfHttpClient);
},
this.adfHttpClient
);
}
}

View File

@ -34,10 +34,11 @@ export function createAlfrescoApiInstance(angularAlfrescoApiService: AlfrescoApi
providedIn: 'root'
})
export class AlfrescoApiLoaderService {
constructor(private readonly appConfig: AppConfigService,
constructor(
private readonly appConfig: AppConfigService,
private readonly apiService: AlfrescoApiService,
private storageService: StorageService) {
}
private storageService: StorageService
) {}
async init(): Promise<any> {
await this.appConfig.load();

View File

@ -25,12 +25,12 @@ import { TagService } from '../../tag/services/tag.service';
providedIn: 'root'
})
export class NodeAspectService {
constructor(private nodesApiService: NodesApiService,
constructor(
private nodesApiService: NodesApiService,
private dialogAspectListService: DialogAspectListService,
private cardViewContentUpdateService: CardViewContentUpdateService,
private tagService: TagService) {
}
private tagService: TagService
) {}
updateNodeAspects(nodeId: string, selectorAutoFocusedOnClose?: string) {
this.dialogAspectListService.openAspectListDialog(nodeId, selectorAutoFocusedOnClose).subscribe((aspectList) => {

View File

@ -54,7 +54,6 @@ describe('ContentAuthLoaderService', () => {
basicAlfrescoAuthService = TestBed.inject(BasicAlfrescoAuthService);
});
it('should require Alf ticket on login if OAuth and provider is ALL or ECM', fakeAsync(() => {
spyOn(authService, 'isOauth').and.returnValue(true);
spyOn(authService, 'isALLProvider').and.returnValue(true);

View File

@ -21,17 +21,10 @@ import { take } from 'rxjs/operators';
@Injectable()
export class ContentAuthLoaderService {
constructor(
private readonly basicAlfrescoAuthService: BasicAlfrescoAuthService,
private readonly authService: AuthenticationService
) {
}
constructor(private readonly basicAlfrescoAuthService: BasicAlfrescoAuthService, private readonly authService: AuthenticationService) {}
init(): void {
this.authService.onLogin
.pipe(take(1))
.subscribe({
this.authService.onLogin.pipe(take(1)).subscribe({
next: async () => {
if (this.authService.isOauth() && (this.authService.isALLProvider() || this.authService.isECMProvider())) {
await this.basicAlfrescoAuthService.requireAlfTicket();

View File

@ -33,8 +33,7 @@ describe('Breadcrumb', () => {
});
let documentListComponent: DocumentListComponent;
const getBreadcrumbActionText = (): string =>
fixture.debugElement.nativeElement.querySelector('.adf-breadcrumb-item-current').textContent.trim();
const getBreadcrumbActionText = (): string => fixture.debugElement.nativeElement.querySelector('.adf-breadcrumb-item-current').textContent.trim();
beforeEach(() => {
TestBed.configureTestingModule({

View File

@ -18,7 +18,10 @@
import { Injectable } from '@angular/core';
import {
CategoryEntry,
CategoryPaging, Pagination, PathInfo, ResultNode,
CategoryPaging,
Pagination,
PathInfo,
ResultNode,
ResultSetPaging,
ResultSetPagingList,
ResultSetRowEntry
@ -27,7 +30,6 @@ import { Observable, of } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class CategoryServiceMock {
public getSubcategories(parentNodeId: string, skipCount?: number, maxItems?: number): Observable<CategoryPaging> {
return parentNodeId ? of(this.getChildrenLevelResponse(skipCount, maxItems)) : of(this.getRootLevelResponse(skipCount, maxItems));
}
@ -66,12 +68,12 @@ export class CategoryServiceMock {
}
private getRootLevelResponse(skipCount?: number, maxItems?: number): CategoryPaging {
const rootCategoryEntry: CategoryEntry = {entry: {id: 'testId', name: 'testNode', parentId: '-root-', hasChildren: true}};
return {list: {pagination: {skipCount, maxItems, hasMoreItems: false}, entries: [rootCategoryEntry]}};
const rootCategoryEntry: CategoryEntry = { entry: { id: 'testId', name: 'testNode', parentId: '-root-', hasChildren: true } };
return { list: { pagination: { skipCount, maxItems, hasMoreItems: false }, entries: [rootCategoryEntry] } };
}
private getChildrenLevelResponse(skipCount?: number, maxItems?: number): CategoryPaging {
const childCategoryEntry: CategoryEntry = {entry: {id: 'childId', name: 'childNode', parentId: 'testId', hasChildren: false}};
return {list: {pagination: {skipCount, maxItems, hasMoreItems: true}, entries: [childCategoryEntry]}};
const childCategoryEntry: CategoryEntry = { entry: { id: 'childId', name: 'childNode', parentId: 'testId', hasChildren: false } };
return { list: { pagination: { skipCount, maxItems, hasMoreItems: true }, entries: [childCategoryEntry] } };
}
}

View File

@ -25,13 +25,14 @@ import { map, mergeMap, toArray } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class CategoryTreeDatasourceService extends TreeService<CategoryNode> {
constructor(private categoryService: CategoryService) {
super();
}
public getSubNodes(parentNodeId: string, skipCount?: number, maxItems?: number, name?: string): Observable<TreeResponse<CategoryNode>> {
return !name ? this.categoryService.getSubcategories(parentNodeId, skipCount, maxItems).pipe(map((response: CategoryPaging) => {
return !name
? this.categoryService.getSubcategories(parentNodeId, skipCount, maxItems).pipe(
map((response: CategoryPaging) => {
const parentNode: CategoryNode = this.getParentNode(parentNodeId);
const nodesList: CategoryNode[] = response.list.entries.map((entry: CategoryEntry) => ({
id: entry.entry.id,
@ -54,14 +55,17 @@ export class CategoryTreeDatasourceService extends TreeService<CategoryNode> {
};
nodesList.push(loadMoreNode);
}
const treeResponse: TreeResponse<CategoryNode> = {entries: nodesList, pagination: response.list.pagination};
const treeResponse: TreeResponse<CategoryNode> = { entries: nodesList, pagination: response.list.pagination };
return treeResponse;
})) : this.categoryService.searchCategories(name, skipCount, maxItems).pipe(mergeMap((pagingResult) => {
})
)
: this.categoryService.searchCategories(name, skipCount, maxItems).pipe(
mergeMap((pagingResult) => {
const nextAfterGeneralPathPartIndex = 3;
const pathSeparator = '/';
return from(pagingResult.list.entries).pipe(mergeMap((category) => {
const path = category.entry.path.name.split(pathSeparator).slice(nextAfterGeneralPathPartIndex)
.join(pathSeparator);
return from(pagingResult.list.entries).pipe(
mergeMap((category) => {
const path = category.entry.path.name.split(pathSeparator).slice(nextAfterGeneralPathPartIndex).join(pathSeparator);
return this.categoryService.getCategory(category.entry.id).pipe(
map((res) => ({
@ -76,7 +80,9 @@ export class CategoryTreeDatasourceService extends TreeService<CategoryNode> {
);
}),
toArray(),
map(res => ({entries: res, pagination: pagingResult.list.pagination})));
}));
map((res) => ({ entries: res, pagination: pagingResult.list.pagination }))
);
})
);
}
}

View File

@ -18,35 +18,27 @@
import { FileModel, FileUploadStatus } from '../models/file.model';
export class FileUploadEvent {
constructor(
public readonly file: FileModel,
public readonly status: FileUploadStatus = FileUploadStatus.Pending,
public readonly error: any = null) {
}
public readonly error: any = null
) {}
}
export class FileUploadCompleteEvent extends FileUploadEvent {
constructor(file: FileModel, public totalComplete: number = 0, public data?: any, public totalAborted: number = 0) {
super(file, FileUploadStatus.Complete);
}
}
export class FileUploadDeleteEvent extends FileUploadEvent {
constructor(file: FileModel, public totalComplete: number = 0) {
super(file, FileUploadStatus.Deleted);
}
}
export class FileUploadErrorEvent extends FileUploadEvent {
constructor(file: FileModel, public error: any, public totalError: number = 0) {
super(file, FileUploadStatus.Error);
}
}

View File

@ -18,9 +18,7 @@
import { FileModel } from './file.model';
describe('FileModel', () => {
describe('extension', () => {
it('should return the extension if file has it', () => {
const file = new FileModel({ name: 'tyrion-lannister.doc' } as File);
@ -33,7 +31,7 @@ describe('FileModel', () => {
expect(file.extension).toBe('');
});
it('should return the empty string if file is starting with . and doesn\'t have extension', () => {
it("should return the empty string if file is starting with . and doesn't have extension", () => {
const file = new FileModel({ name: '.white-walkers' } as File);
expect(file.extension).toBe('');

View File

@ -26,7 +26,6 @@ import { catchError } from 'rxjs/operators';
providedIn: 'root'
})
export class FavoritesApiService {
private _favoritesApi: FavoritesApi;
get favoritesApi(): FavoritesApi {
this._favoritesApi = this._favoritesApi ?? new FavoritesApi(this.apiService.getInstance());
@ -42,16 +41,11 @@ export class FavoritesApiService {
return { entry };
}
constructor(
private apiService: AlfrescoApiService,
private preferences: UserPreferencesService
) {
}
constructor(private apiService: AlfrescoApiService, private preferences: UserPreferencesService) {}
remapFavoritesData(data: FavoritePaging = {}): NodePaging {
const pagination = (data?.list?.pagination || {});
const entries: any[] = this
.remapFavoriteEntries(data?.list?.entries || []);
const pagination = data?.list?.pagination || {};
const entries: any[] = this.remapFavoriteEntries(data?.list?.entries || []);
return {
list: { entries, pagination }
@ -63,7 +57,7 @@ export class FavoritesApiService {
.map(({ entry: { target } }: any) => ({
entry: target.file || target.folder
}))
.filter(({ entry }) => (!!entry))
.filter(({ entry }) => !!entry)
.map(FavoritesApiService.remapEntry);
}
@ -82,12 +76,8 @@ export class FavoritesApiService {
include: ['properties', 'allowableOperations']
};
const queryOptions = Object.assign(defaultOptions, options);
const promise = this.favoritesApi
.listFavorites(personId, queryOptions)
.then(this.remapFavoritesData);
const promise = this.favoritesApi.listFavorites(personId, queryOptions).then(this.remapFavoritesData);
return from(promise).pipe(
catchError((err) => of(err))
);
return from(promise).pipe(catchError((err) => of(err)));
}
}

View File

@ -48,7 +48,7 @@ import { TranslateModule } from '@ngx-translate/core';
<ng-container>
<mat-icon>{{ expanded ? 'expand_more' : 'chevron_right' }}</mat-icon>
<mat-panel-title *ngIf="title" class="adf-metadata-properties-title" [title]="title | translate">{{ title | translate }}</mat-panel-title>
<ng-content></ng-content>
<ng-content />
</ng-container>
`
})

View File

@ -19,13 +19,11 @@ import { AspectOrientedConfigService } from './aspect-oriented-config.service';
import { AspectOrientedConfig, Property, OrganisedPropertyGroup, PropertyGroupContainer } from '../../interfaces/content-metadata.interfaces';
describe('AspectOrientedConfigService', () => {
let configService: AspectOrientedConfigService;
const createConfigService = (configObj: AspectOrientedConfig) => new AspectOrientedConfigService(configObj);
describe('reorganiseByConfig', () => {
interface TestCase {
name: string;
config: AspectOrientedConfig;
@ -51,54 +49,58 @@ describe('AspectOrientedConfigService', () => {
{
name: 'One property from One group',
config: {
berseria: [ 'property1' ]
},
expectations: [{
title: 'Berseria',
properties: [ property1 ]
}]
},
{
name: 'More properties from One group',
config: {
berseria: [ 'property1', 'property2' ]
},
expectations: [{
title: 'Berseria',
properties: [ property1, property2 ]
}]
},
{
name: 'One-one properties from More group',
config: {
berseria: [ 'property1' ],
zestiria: [ 'property3' ]
berseria: ['property1']
},
expectations: [
{
title: 'Berseria',
properties: [ property1 ]
properties: [property1]
}
]
},
{
name: 'More properties from One group',
config: {
berseria: ['property1', 'property2']
},
expectations: [
{
title: 'Berseria',
properties: [property1, property2]
}
]
},
{
name: 'One-one properties from More group',
config: {
berseria: ['property1'],
zestiria: ['property3']
},
expectations: [
{
title: 'Berseria',
properties: [property1]
},
{
title: 'Zestiria',
properties: [ property3 ]
properties: [property3]
}
]
},
{
name: 'More properties from More groups',
config: {
zestiria: [ 'property4', 'property3' ],
berseria: [ 'property2', 'property1' ]
zestiria: ['property4', 'property3'],
berseria: ['property2', 'property1']
},
expectations: [
{
title: 'Zestiria',
properties: [ property4, property3 ]
properties: [property4, property3]
},
{
title: 'Berseria',
properties: [ property2, property1 ]
properties: [property2, property1]
}
]
},
@ -106,16 +108,16 @@ describe('AspectOrientedConfigService', () => {
name: 'Wildcard',
config: {
berseria: '*',
zestiria: [ 'property4' ]
zestiria: ['property4']
},
expectations: [
{
title: 'Berseria',
properties: [ property1, property2 ]
properties: [property1, property2]
},
{
title: 'Zestiria',
properties: [ property4 ]
properties: [property4]
}
]
},
@ -124,29 +126,29 @@ describe('AspectOrientedConfigService', () => {
config: {
berseria: '*',
'not-existing-group': '*',
zestiria: [ 'property4' ]
zestiria: ['property4']
},
expectations: [
{
title: 'Berseria',
properties: [ property1, property2 ]
properties: [property1, property2]
},
{
title: 'Zestiria',
properties: [ property4 ]
properties: [property4]
}
]
},
{
name: 'Not existing property',
config: {
berseria: [ 'not-existing-property' ],
zestiria: [ 'property4' ]
berseria: ['not-existing-property'],
zestiria: ['property4']
},
expectations: [
{
title: 'Zestiria',
properties: [ property4 ]
properties: [property4]
}
]
}
@ -160,7 +162,7 @@ describe('AspectOrientedConfigService', () => {
expect(organisedPropertyGroups.length).toBe(testCase.expectations.length, 'Group count should match');
testCase.expectations.forEach((expectation, i) => {
expect(organisedPropertyGroups[i].title).toBe(expectation.title, 'Group\'s title should match' );
expect(organisedPropertyGroups[i].title).toBe(expectation.title, "Group's title should match");
expect(organisedPropertyGroups[i].properties.length).toBe(
expectation.properties.length,
`Property count for '${organisedPropertyGroups[i].title}' group should match.`
@ -194,11 +196,11 @@ describe('AspectOrientedConfigService', () => {
expectations: [
{
title: 'Berseria',
properties: [ property1, property2 ]
properties: [property1, property2]
},
{
title: 'Zestiria',
properties: [ property3, property4 ]
properties: [property3, property4]
}
]
};
@ -208,7 +210,7 @@ describe('AspectOrientedConfigService', () => {
expect(organisedPropertyGroups.length).toBe(testCase.expectations.length, 'Group count should match');
testCase.expectations.forEach((expectation, i) => {
expect(organisedPropertyGroups[i].title).toBe(expectation.title, 'Group\'s title should match' );
expect(organisedPropertyGroups[i].title).toBe(expectation.title, "Group's title should match");
expect(organisedPropertyGroups[i].properties.length).toBe(
expectation.properties.length,
`Property count for '${organisedPropertyGroups[i].title}' group should match.`
@ -231,11 +233,11 @@ describe('AspectOrientedConfigService', () => {
expectations: [
{
title: 'Berseria',
properties: [ property1, property2 ]
properties: [property1, property2]
},
{
title: 'Zestiria',
properties: [ property3, property4 ]
properties: [property3, property4]
}
]
};

View File

@ -19,8 +19,7 @@ import { ContentMetadataConfig, OrganisedPropertyGroup, PropertyGroupContainer,
import { getGroup, getProperty } from './property-group-reader';
export class AspectOrientedConfigService implements ContentMetadataConfig {
constructor(private config: any) { }
constructor(private config: any) {}
public isGroupAllowed(groupName: string): boolean {
if (this.isIncludeAllEnabled()) {
@ -43,8 +42,7 @@ export class AspectOrientedConfigService implements ContentMetadataConfig {
}
public appendAllPreset(propertyGroups: PropertyGroupContainer): OrganisedPropertyGroup[] {
const groups = Object.keys(propertyGroups)
.map((groupName) => {
const groups = Object.keys(propertyGroups).map((groupName) => {
const propertyGroup = propertyGroups[groupName];
const properties = propertyGroup.properties;
@ -87,7 +85,6 @@ export class AspectOrientedConfigService implements ContentMetadataConfig {
} else {
return readOnlyAspects === propertyGroupName;
}
}
public filterExcludedPreset(propertyGroups: OrganisedPropertyGroup[]): OrganisedPropertyGroup[] {

View File

@ -25,19 +25,17 @@ import { ContentMetadataConfig } from '../../interfaces/content-metadata.interfa
import { HttpClientModule } from '@angular/common/http';
describe('ContentMetadataConfigFactory', () => {
let factory: ContentMetadataConfigFactory;
let appConfig: AppConfigService;
let config: ContentMetadataConfig;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientModule
],
imports: [HttpClientModule],
providers: [
{
provide: LogService, useValue: {
provide: LogService,
useValue: {
error: () => {}
}
}
@ -48,7 +46,6 @@ describe('ContentMetadataConfigFactory', () => {
});
describe('get', () => {
let logService: LogService;
beforeEach(() => {
@ -57,7 +54,6 @@ describe('ContentMetadataConfigFactory', () => {
});
describe('get', () => {
it('should get back to default preset if no preset is provided as parameter', () => {
config = factory.get();
@ -85,7 +81,6 @@ describe('ContentMetadataConfigFactory', () => {
});
describe('set', () => {
const setConfig = (presetName: string, presetConfig: any) => {
appConfig.config['content-metadata'] = {
presets: {

View File

@ -15,19 +15,15 @@
* limitations under the License.
*/
import { ContentMetadataConfig, OrganisedPropertyGroup,
PropertyGroupContainer
} from '../../interfaces/content-metadata.interfaces';
import { ContentMetadataConfig, OrganisedPropertyGroup, PropertyGroupContainer } from '../../interfaces/content-metadata.interfaces';
export class IndifferentConfigService implements ContentMetadataConfig {
isGroupAllowed(): boolean {
return true;
}
reorganiseByConfig(propertyGroups: PropertyGroupContainer): OrganisedPropertyGroup[] {
return Object.keys(propertyGroups)
.map((groupName) => {
return Object.keys(propertyGroups).map((groupName) => {
const propertyGroup = propertyGroups[groupName];
const properties = propertyGroup.properties;
@ -42,7 +38,7 @@ export class IndifferentConfigService implements ContentMetadataConfig {
}
appendAllPreset(): OrganisedPropertyGroup[] {
return[];
return [];
}
isIncludeAllEnabled(): boolean {

View File

@ -25,8 +25,7 @@ import {
import { getProperty } from './property-group-reader';
export class LayoutOrientedConfigService implements ContentMetadataConfig {
constructor(private config: any) { }
constructor(private config: any) {}
public isGroupAllowed(groupName: string): boolean {
if (this.isIncludeAllEnabled()) {
@ -61,8 +60,7 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
}
public appendAllPreset(propertyGroups: PropertyGroupContainer): OrganisedPropertyGroup[] {
return Object.keys(propertyGroups)
.map((groupName) => {
return Object.keys(propertyGroups).map((groupName) => {
const propertyGroup = propertyGroups[groupName];
const properties = propertyGroup.properties;
@ -88,16 +86,14 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
}
public isIncludeAllEnabled() {
const includeAllProperty = this.config
.map((config) => config.includeAll)
.find((includeAll) => includeAll !== undefined);
const includeAllProperty = this.config.map((config) => config.includeAll).find((includeAll) => includeAll !== undefined);
return includeAllProperty !== undefined ? includeAllProperty : false;
}
private setEditableProperty(propertyGroup: Property | Property[], itemConfig): Property | Property[] {
if (Array.isArray(propertyGroup)) {
propertyGroup.map((property) => property.editable = itemConfig.editable !== undefined ? itemConfig.editable : true);
propertyGroup.forEach((property) => (property.editable = itemConfig.editable !== undefined ? itemConfig.editable : true));
} else {
propertyGroup.editable = itemConfig.editable !== undefined ? itemConfig.editable : true;
}
@ -107,7 +103,7 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
private setPropertyTitle(item: Property | Property[], property: Property): Property | Property[] {
if (!Array.isArray(item)) {
return { ...item, ...(item.name === property.name && !!property.title) && { title: property.title } };
return { ...item, ...(item.name === property.name && !!property.title && { title: property.title }) };
}
return item;
}

View File

@ -31,24 +31,24 @@ import { VersionCompatibilityService } from '../../version-compatibility/version
providedIn: 'root'
})
export class ContentTypePropertiesService {
constructor(private contentTypeService: ContentTypeService,
constructor(
private contentTypeService: ContentTypeService,
private dialog: MatDialog,
private versionCompatibilityService: VersionCompatibilityService,
private propertyGroupTranslatorService: PropertyGroupTranslatorService) {
}
private propertyGroupTranslatorService: PropertyGroupTranslatorService
) {}
getContentTypeCardItem(node: Node): Observable<CardViewItem[]> {
if (this.versionCompatibilityService.isVersionSupported('7')) {
return this.contentTypeService.getContentTypeByPrefix(node.nodeType).
pipe(
return this.contentTypeService.getContentTypeByPrefix(node.nodeType).pipe(
map((contentType) => {
const contentTypesOptions$ = this.getContentTypesAsSelectOption(contentType);
const contentTypeCard = this.buildContentTypeSelectCardModel(contentType.entry.id, contentTypesOptions$);
const filteredProperties = this.getContentTypeSpecificProperties(contentType);
const propertiesCard = this.buildCardItemsFromPropertyList(filteredProperties, node.properties);
return [contentTypeCard, ...propertiesCard];
}));
})
);
} else {
return of([this.buildContentTypeTextCardModel(node.nodeType)]);
}
@ -80,7 +80,10 @@ export class ContentTypePropertiesService {
return contentTypeCard;
}
private buildContentTypeSelectCardModel(currentValue: string, options$: Observable<CardViewSelectItemOption<string>[]>): CardViewSelectItemModel<string> {
private buildContentTypeSelectCardModel(
currentValue: string,
options$: Observable<CardViewSelectItemOption<string>[]>
): CardViewSelectItemModel<string> {
const contentTypeCard = new CardViewSelectItemModel({
label: 'CORE.METADATA.BASIC.CONTENT_TYPE',
value: currentValue,
@ -100,7 +103,8 @@ export class ContentTypePropertiesService {
map(([contentTypesEntries, currentContentType]) => {
const updatedTypes = this.appendCurrentType(currentContentType, contentTypesEntries);
return updatedTypes.map((contentType) => ({ key: contentType.entry.id, label: contentType.entry.title ?? contentType.entry.id }));
}));
})
);
}
private appendCurrentType(currentType: TypeEntry, contentTypesEntries: TypeEntry[]): TypeEntry[] {

View File

@ -36,8 +36,7 @@ describe('PropertyDescriptorLoaderService', () => {
it('should load the groups passed by paramter', (done) => {
spyOn(classesApi, 'getClass').and.returnValue(Promise.resolve({}));
service.load(['exif:exif', 'cm:content', 'custom:custom'])
.subscribe(() => {
service.load(['exif:exif', 'cm:content', 'custom:custom']).subscribe(() => {
expect(classesApi.getClass).toHaveBeenCalledTimes(3);
expect(classesApi.getClass).toHaveBeenCalledWith('exif_exif');
expect(classesApi.getClass).toHaveBeenCalledWith('cm_content');

View File

@ -26,29 +26,29 @@ import { ClassesApi } from '@alfresco/js-api';
providedIn: 'root'
})
export class PropertyDescriptorsService {
private _classesApi: ClassesApi;
get classesApi(): ClassesApi {
this._classesApi = this._classesApi ?? new ClassesApi(this.alfrescoApiService.getInstance());
return this._classesApi;
}
constructor(private alfrescoApiService: AlfrescoApiService) {
}
constructor(private alfrescoApiService: AlfrescoApiService) {}
load(groupNames: string[]): Observable<PropertyGroupContainer> {
const groupFetchStreams = groupNames
.map((groupName) => groupName.replace(':', '_'))
.map((groupName) => defer(() => this.classesApi.getClass(groupName)));
return forkJoin(groupFetchStreams).pipe(
map(this.convertToObject)
);
return forkJoin(groupFetchStreams).pipe(map(this.convertToObject));
}
private convertToObject(propertyGroupsArray: PropertyGroup[]): PropertyGroupContainer {
return propertyGroupsArray.reduce((propertyGroups, propertyGroup) => Object.assign({}, propertyGroups, {
return propertyGroupsArray.reduce(
(propertyGroups, propertyGroup) =>
Object.assign({}, propertyGroups, {
[propertyGroup.name]: propertyGroup
}), {});
}),
{}
);
}
}

View File

@ -26,7 +26,6 @@ import { AlfrescoApiService } from '../../services/alfresco-api.service';
providedIn: 'root'
})
export class SharedLinksApiService {
error = new Subject<{ statusCode: number; message: string }>();
private _sharedLinksApi: SharedlinksApi;
@ -35,9 +34,7 @@ export class SharedLinksApiService {
return this._sharedLinksApi;
}
constructor(private apiService: AlfrescoApiService,
private preferences: UserPreferencesService) {
}
constructor(private apiService: AlfrescoApiService, private preferences: UserPreferencesService) {}
/**
* Gets shared links available to the current user.
@ -54,9 +51,7 @@ export class SharedLinksApiService {
const queryOptions = Object.assign({}, defaultOptions, options);
const promise = this.sharedLinksApi.listSharedLinks(queryOptions);
return from(promise).pipe(
catchError((err) => of(err))
);
return from(promise).pipe(catchError((err) => of(err)));
}
/**
@ -68,11 +63,9 @@ export class SharedLinksApiService {
* @returns The shared link just created
*/
createSharedLinks(nodeId: string, sharedLinkWithExpirySettings?: SharedLinkBodyCreate, options: any = {}): Observable<SharedLinkEntry> {
const promise = this.sharedLinksApi.createSharedLink(sharedLinkWithExpirySettings? sharedLinkWithExpirySettings : { nodeId }, options);
const promise = this.sharedLinksApi.createSharedLink(sharedLinkWithExpirySettings ? sharedLinkWithExpirySettings : { nodeId }, options);
return from(promise).pipe(
catchError((err) => of(err))
);
return from(promise).pipe(catchError((err) => of(err)));
}
/**
@ -84,8 +77,6 @@ export class SharedLinksApiService {
deleteSharedLink(sharedId: string): Observable<any | Error> {
const promise = this.sharedLinksApi.deleteSharedLink(sharedId);
return from(promise).pipe(
catchError((err: Error) => of(err))
);
return from(promise).pipe(catchError((err: Error) => of(err)));
}
}

View File

@ -25,15 +25,13 @@ import { map } from 'rxjs/operators';
providedIn: 'root'
})
export class ContentTypeService {
private _typesApi: TypesApi;
get typesApi(): TypesApi {
this._typesApi = this._typesApi ?? new TypesApi(this.alfrescoApiService.getInstance());
return this._typesApi;
}
constructor(private alfrescoApiService: AlfrescoApiService) {
}
constructor(private alfrescoApiService: AlfrescoApiService) {}
getContentTypeByPrefix(prefixedType: string): Observable<TypeEntry> {
return from(this.typesApi.getType(prefixedType));
@ -45,8 +43,6 @@ export class ContentTypeService {
where,
include: ['properties']
};
return from(this.typesApi.listTypes(opts)).pipe(
map((result: TypePaging) => result.list.entries)
);
return from(this.typesApi.listTypes(opts)).pipe(map((result: TypePaging) => result.list.entries));
}
}

View File

@ -24,15 +24,13 @@ import { AlfrescoApiService } from '../../../services/alfresco-api.service';
providedIn: 'root'
})
export class DownloadZipService {
private _downloadsApi: DownloadsApi;
get downloadsApi(): DownloadsApi {
this._downloadsApi = this._downloadsApi ?? new DownloadsApi(this.apiService.getInstance());
return this._downloadsApi;
}
constructor(private apiService: AlfrescoApiService) {
}
constructor(private apiService: AlfrescoApiService) {}
/**
* Creates a new download.

View File

@ -11,7 +11,7 @@
#{$mat-form-field-hide-placeholder} {
#{$mat-floating-label} {
padding-top: 11px;
padding-top: 20px;
}
}

View File

@ -34,7 +34,7 @@
&#{$mat-form-field-hide-placeholder} {
#{$mat-floating-label} {
padding-top: 11px;
padding-top: 20px;
}
}

View File

@ -48,7 +48,7 @@
<img [alt]="'ADF-DATATABLE.EMPTY.DRAG-AND-DROP.TITLE' | translate" class="adf-empty-folder-image" [src]="emptyFolderImageUrl">
</div>
</adf-empty-list>
<ng-content select="adf-custom-empty-content-template, empty-folder-content"></ng-content>
<ng-content select="adf-custom-empty-content-template, empty-folder-content" />
</ng-template>
</adf-no-content-template>
@ -58,7 +58,7 @@
<mat-icon>error</mat-icon>
<p class="adf-no-permission__template--text">{{ 'ADF-DOCUMENT-LIST.NO_PERMISSION' | translate }}</p>
</div>
<ng-content select="adf-custom-no-permission-template, no-permission-content"></ng-content>
<ng-content select="adf-custom-no-permission-template, no-permission-content" />
</ng-template>
</adf-no-permission-template>
@ -72,7 +72,7 @@
[color]="'primary'"
[mode]="'indeterminate'" />
</div>
<ng-content select="adf-custom-loading-content-template"></ng-content>
<ng-content select="adf-custom-loading-content-template" />
</ng-template>
</adf-loading-content-template>

View File

@ -735,7 +735,7 @@ export class DocumentListComponent extends DataTableSchema implements OnInit, On
}
private isLinkFolder(node: Node) {
return node.nodeType === 'app:folderlink' && node.properties && node.properties['cm:destination'];
return node.nodeType === 'app:folderlink' && node.properties?.['cm:destination'];
}
private updateCustomSourceData(nodeId: string): void {

View File

@ -15,13 +15,7 @@
* limitations under the License.
*/
import {
DataColumn,
DataRow,
DataSorting,
DataTableAdapter,
ThumbnailService
} from '@alfresco/adf-core';
import { DataColumn, DataRow, DataSorting, DataTableAdapter, ThumbnailService } from '@alfresco/adf-core';
import { NodePaging, NodeEntry } from '@alfresco/js-api';
import { PermissionStyleModel } from './../models/permissions-style.model';
import { ShareDataRow } from './share-data-row.model';
@ -57,12 +51,14 @@ export class ShareDataTableAdapter implements DataTableAdapter {
return this._sortingMode;
}
constructor(private thumbnailService: ThumbnailService,
constructor(
private thumbnailService: ThumbnailService,
private contentService: ContentService,
schema: DataColumn[] = [],
sorting?: DataSorting,
sortingMode: string = 'client',
allowDropFiles: boolean = false) {
allowDropFiles: boolean = false
) {
this.rows = [];
this.columns = schema || [];
this.sorting = sorting;
@ -106,7 +102,6 @@ export class ShareDataTableAdapter implements DataTableAdapter {
}
if (col.key === '$thumbnail') {
if (this.imageResolver) {
const resolved = this.imageResolver(row, col);
if (resolved) {
@ -137,7 +132,6 @@ export class ShareDataTableAdapter implements DataTableAdapter {
}
if (col.type === 'image') {
if (this.imageResolver) {
const resolved = this.imageResolver(row, col);
if (resolved) {
@ -149,7 +143,6 @@ export class ShareDataTableAdapter implements DataTableAdapter {
return dataRow.cacheValue(col.key, value);
}
/**
* Gets a thumbnail URL for the given document node.
*
@ -217,14 +210,12 @@ export class ShareDataTableAdapter implements DataTableAdapter {
isSmartFolder(node: any) {
const nodeAspects = this.getNodeAspectNames(node);
return nodeAspects.indexOf('smf:customConfigSmartFolder') > -1 ||
(nodeAspects.indexOf('smf:systemConfigSmartFolder') > -1);
return nodeAspects.indexOf('smf:customConfigSmartFolder') > -1 || nodeAspects.indexOf('smf:systemConfigSmartFolder') > -1;
}
isRuleFolder(node: any) {
const nodeAspects = this.getNodeAspectNames(node);
return nodeAspects.indexOf('rule:rules') > -1 ||
(nodeAspects.indexOf('rule:rules') > -1);
return nodeAspects.indexOf('rule:rules') > -1;
}
isALinkFolder(node: any) {
@ -233,7 +224,7 @@ export class ShareDataTableAdapter implements DataTableAdapter {
}
private getNodeAspectNames(node: any): any[] {
return node.entry?.aspectNames ? node.entry.aspectNames : (node.aspectNames ? node.aspectNames : []);
return node.entry?.aspectNames ? node.entry.aspectNames : node.aspectNames ? node.aspectNames : [];
}
private sortRows(rows: DataRow[], sorting: DataSorting) {
@ -244,7 +235,6 @@ export class ShareDataTableAdapter implements DataTableAdapter {
const options: Intl.CollatorOptions = {};
if (sorting?.key && rows?.length) {
if (sorting.key.includes('sizeInBytes') || sorting.key === 'name') {
options.numeric = true;
}
@ -256,21 +246,19 @@ export class ShareDataTableAdapter implements DataTableAdapter {
let left = a.getValue(sorting.key);
if (left) {
left = (left instanceof Date) ? left.valueOf().toString() : left.toString();
left = left instanceof Date ? left.valueOf().toString() : left.toString();
} else {
left = '';
}
let right = b.getValue(sorting.key);
if (right) {
right = (right instanceof Date) ? right.valueOf().toString() : right.toString();
right = right instanceof Date ? right.valueOf().toString() : right.toString();
} else {
right = '';
}
return sorting.direction === 'asc'
? left.localeCompare(right, undefined, options)
: right.localeCompare(left, undefined, options);
return sorting.direction === 'asc' ? left.localeCompare(right, undefined, options) : right.localeCompare(left, undefined, options);
});
}
}
@ -283,7 +271,9 @@ export class ShareDataTableAdapter implements DataTableAdapter {
if (nodePaging?.list) {
const nodeEntries: NodeEntry[] = nodePaging.list.entries;
if (nodeEntries?.length) {
shareDataRows = nodeEntries.map((item) => new ShareDataRow(item, this.contentService, this.permissionsStyle, this.thumbnailService, this.allowDropFiles));
shareDataRows = nodeEntries.map(
(item) => new ShareDataRow(item, this.contentService, this.permissionsStyle, this.thumbnailService, this.allowDropFiles)
);
if (this.filter) {
shareDataRows = shareDataRows.filter(this.filter);

View File

@ -29,17 +29,18 @@ import { NodeActionsService } from './node-actions.service';
providedIn: 'root'
})
export class FolderActionsService {
permissionEvent = new Subject<PermissionModel>();
error = new Subject<Error>();
success = new Subject<string>();
private handlers: { [id: string]: ContentActionHandler } = {};
constructor(private nodeActionsService: NodeActionsService,
constructor(
private nodeActionsService: NodeActionsService,
private documentListService: DocumentListService,
private contentService: ContentService,
private translation: TranslationService) {
private translation: TranslationService
) {
this.setupActionHandlers();
}
@ -107,36 +108,36 @@ export class FolderActionsService {
}
private prepareHandlers(actionObservable: Observable<any>, target?: any): void {
actionObservable.subscribe(
(fileOperationMessage) => {
actionObservable.subscribe((fileOperationMessage) => {
if (target && typeof target.reload === 'function') {
target.reload();
}
this.success.next(fileOperationMessage);
},
this.error.next.bind(this.error)
);
}, this.error.next.bind(this.error));
}
private deleteNode(node: NodeEntry, target?: any, permission?: string): Observable<any> {
if (this.canExecuteAction(node)) {
if (this.contentService.hasAllowableOperations(node.entry, permission)) {
const handlerObservable = this.documentListService.deleteNode(node.entry.id);
handlerObservable.subscribe(() => {
handlerObservable.subscribe(
() => {
if (target && typeof target.reload === 'function') {
target.reload();
}
const message = this.translation.instant('CORE.DELETE_NODE.SINGULAR', { name: node.entry.name });
this.success.next(message);
}, () => {
},
() => {
const message = this.translation.instant('CORE.DELETE_NODE.ERROR_SINGULAR', { name: node.entry.name });
this.error.next(message);
});
}
);
return handlerObservable;
} else {
this.permissionEvent.next(new PermissionModel({type: 'folder', action: 'delete', permission}));
this.permissionEvent.next(new PermissionModel({ type: 'folder', action: 'delete', permission }));
return throwError(new Error('No permission to delete'));
}
}

View File

@ -24,9 +24,7 @@ import { isAfter } from 'date-fns';
providedIn: 'root'
})
export class LockService {
constructor(private authService: AuthenticationService) {
}
constructor(private authService: AuthenticationService) {}
isLocked(node: Node): boolean {
let isLocked = false;

View File

@ -25,27 +25,27 @@ import { map } from 'rxjs/operators';
providedIn: 'root'
})
export class GroupService {
private _groupsApi: GroupsApi;
get groupsApi(): GroupsApi {
this._groupsApi = this._groupsApi ?? new GroupsApi(this.alfrescoApiService.getInstance());
return this._groupsApi;
}
constructor(
private alfrescoApiService: AlfrescoApiService
) {
}
constructor(private alfrescoApiService: AlfrescoApiService) {}
async listAllGroupMembershipsForPerson(personId: string, opts?: any, accumulator = []): Promise<GroupEntry[]> {
const groupsPaginated = await this.groupsApi.listGroupMembershipsForPerson(personId, opts);
accumulator = [...accumulator, ...groupsPaginated.list.entries];
if (groupsPaginated.list.pagination.hasMoreItems) {
const skip = groupsPaginated.list.pagination.skipCount + groupsPaginated.list.pagination.count;
return this.listAllGroupMembershipsForPerson(personId, {
return this.listAllGroupMembershipsForPerson(
personId,
{
maxItems: opts.maxItems,
skipCount: skip
}, accumulator);
},
accumulator
);
} else {
return accumulator;
}
@ -59,10 +59,12 @@ export class GroupService {
* @returns Observable<GroupEntry> group for specified id.
*/
getGroup(id: string, opts?: ContentIncludeQuery): Observable<GroupEntry> {
return from(this.groupsApi.getGroup(id, opts)).pipe(map((group) => {
return from(this.groupsApi.getGroup(id, opts)).pipe(
map((group) => {
group.entry.description ||= '';
return group;
}));
})
);
}
/**
@ -73,12 +75,20 @@ export class GroupService {
* @returns Observable<GroupEntry> updated group.
*/
updateGroup(group: Group, opts?: ContentIncludeQuery): Observable<GroupEntry> {
return from(this.groupsApi.updateGroup(group.id, {
return from(
this.groupsApi.updateGroup(
group.id,
{
displayName: group.displayName,
description: group.description
}, opts)).pipe(map((updatedGroup) => {
},
opts
)
).pipe(
map((updatedGroup) => {
updatedGroup.entry.description ||= '';
return updatedGroup;
}));
})
);
}
}

View File

@ -17,13 +17,10 @@
/* spellchecker: disable */
export const fakeAuthorityResults: any[] = [{
export const fakeAuthorityResults: any[] = [
{
entry: {
aspectNames: [
'cm:personDisabled',
'cm:ownable',
'cm:preferences'
],
aspectNames: ['cm:personDisabled', 'cm:ownable', 'cm:preferences'],
isFolder: false,
search: {
score: 4.014668
@ -42,7 +39,8 @@ export const fakeAuthorityResults: any[] = [{
encoding: 'UTF-8',
locale: 'en_US',
id: 148,
infoUrl: 'contentUrl=store://2018/4/18/9/30/514bb261-bc61-4502-ad2f-dfafec9ae4eb.bin|mimetype=application/octet-stream|size=55|encoding=UTF-8|locale=en_US_'
infoUrl:
'contentUrl=store://2018/4/18/9/30/514bb261-bc61-4502-ad2f-dfafec9ae4eb.bin|mimetype=application/octet-stream|size=55|encoding=UTF-8|locale=en_US_'
},
'cm:owner': {
id: 'abeecher',
@ -59,7 +57,8 @@ export const fakeAuthorityResults: any[] = [{
encoding: 'UTF-8',
locale: 'en_US',
id: 147,
infoUrl: 'contentUrl=store://2018/4/18/9/30/afc39bc9-6bac-4f24-8730-9d9f617a322e.bin|mimetype=text/plain|size=709|encoding=UTF-8|locale=en_US_'
infoUrl:
'contentUrl=store://2018/4/18/9/30/afc39bc9-6bac-4f24-8730-9d9f617a322e.bin|mimetype=text/plain|size=709|encoding=UTF-8|locale=en_US_'
},
'cm:userName': 'abeecher',
'cm:companyaddress3': 'UK',
@ -81,13 +80,10 @@ export const fakeAuthorityResults: any[] = [{
},
parentId: '063f5d48-a0b3-4cbf-826c-88a4fbfa3336'
}
},
{
},
{
entry: {
aspectNames: [
'cm:ownable',
'cm:preferences'
],
aspectNames: ['cm:ownable', 'cm:preferences'],
isFolder: false,
search: {
score: 4.014668
@ -106,7 +102,8 @@ export const fakeAuthorityResults: any[] = [{
encoding: 'UTF-8',
locale: 'en',
id: 313,
infoUrl: 'contentUrl=store://2018/4/23/14/42/92bb4aa9-db27-41a4-9804-ddab3cc83d3e.bin|mimetype=text/plain|size=102|encoding=UTF-8|locale=en_'
infoUrl:
'contentUrl=store://2018/4/23/14/42/92bb4aa9-db27-41a4-9804-ddab3cc83d3e.bin|mimetype=text/plain|size=102|encoding=UTF-8|locale=en_'
},
'cm:authorizationStatus': 'AUTHORIZED',
'cm:homeFolder': 'a20cd541-4ada-4525-9807-9fa0a047d9f4',
@ -121,8 +118,8 @@ export const fakeAuthorityResults: any[] = [{
},
parentId: '063f5d48-a0b3-4cbf-826c-88a4fbfa3336'
}
},
{
},
{
entry: {
isFolder: false,
search: {
@ -138,7 +135,8 @@ export const fakeAuthorityResults: any[] = [{
},
parentId: '030d833e-da8e-4f5c-8ef9-d809638bd04b'
}
}];
}
];
export const fakeAuthorityListResult: any = {
list: {
@ -168,7 +166,8 @@ export const fakeNameListResult: any = {
lastTxId: 5496
}
},
entries: [{
entries: [
{
entry: {
aspectNames: ['cm:ownable'],
isFolder: false,
@ -197,7 +196,8 @@ export const fakeNameListResult: any = {
},
parentId: '3e9ce910-a4a0-4531-8f80-7734bece6342'
}
}, {
},
{
entry: {
aspectNames: ['cm:ownable'],
isFolder: false,
@ -226,6 +226,7 @@ export const fakeNameListResult: any = {
},
parentId: '3e9ce910-a4a0-4531-8f80-7734bece6342'
}
}]
}
]
}
};

View File

@ -21,9 +21,7 @@ import { AppConfigService, StorageService } from '@alfresco/adf-core';
@Injectable()
export class AlfrescoApiServiceMock extends AlfrescoApiService {
constructor(protected appConfig: AppConfigService,
protected storageService: StorageService) {
constructor(protected appConfig: AppConfigService, protected storageService: StorageService) {
super(appConfig, storageService);
if (!this.alfrescoApi) {
this.initAlfrescoApi();

View File

@ -18,7 +18,7 @@
import { SearchCategory } from '../search/models/search-category.interface';
export const mockSearchFilterWithoutDisplayedLabelsByField: SearchCategory = {
id : 'test',
id: 'test',
name: 'test',
expanded: false,
enabled: true,
@ -33,7 +33,7 @@ export const mockSearchFilterWithoutDisplayedLabelsByField: SearchCategory = {
};
export const mockSearchFilterWithWrongDisplayedLabelsByField: SearchCategory = {
id : 'test',
id: 'test',
name: 'test',
expanded: false,
enabled: true,
@ -51,7 +51,7 @@ export const mockSearchFilterWithWrongDisplayedLabelsByField: SearchCategory = {
};
export const mockSearchFilterWithDisplayedLabelsByField: SearchCategory = {
id : 'test',
id: 'test',
name: 'test',
expanded: false,
enabled: true,

View File

@ -27,10 +27,13 @@ export const fakeNodeWithCreatePermission = new Node({
path: {
name: '/Company Home/User Homes',
isComplete: true,
elements: [{
elements: [
{
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
name: 'Company Home'
}, { id: '55052317-7e59-4058-8e07-769f41e615e1', name: 'User Homes' }]
},
{ id: '55052317-7e59-4058-8e07-769f41e615e1', name: 'User Homes' }
]
},
isFolder: true,
modifiedByUser: { id: 'Test', displayName: 'Test' },
@ -51,10 +54,13 @@ export const fakeNodeWithNoPermission = new Node({
path: {
name: '/Company Home/User Homes',
isComplete: true,
elements: [{
elements: [
{
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
name: 'Company Home'
}, { id: '55052317-7e59-4058-8e07-769f41e615e1', name: 'User Homes' }]
},
{ id: '55052317-7e59-4058-8e07-769f41e615e1', name: 'User Homes' }
]
},
isFolder: true,
modifiedByUser: { id: 'Test', displayName: 'Test' },
@ -72,7 +78,8 @@ export const fakeNodeAnswerWithEntries = {
skipCount: 10,
maxItems: 10
},
entries: [{
entries: [
{
entry: {
isFile: true,
createdByUser: { id: 'admin', displayName: 'Administrator' },
@ -89,10 +96,13 @@ export const fakeNodeAnswerWithEntries = {
path: {
name: '/Company Home/Guest Home',
isComplete: true,
elements: [{
elements: [
{
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
name: 'Company Home'
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
},
{ id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }
]
},
isFolder: false,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
@ -101,7 +111,8 @@ export const fakeNodeAnswerWithEntries = {
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' },
allowableOperations: ['delete', 'update']
}
}]
}
]
}
};
@ -127,7 +138,8 @@ export const fakeGetSitesAnswer = {
skipCount: 0,
maxItems: 20
},
entries: [{
entries: [
{
entry: {
role: 'SiteManager',
visibility: 'PRIVATE',
@ -136,7 +148,8 @@ export const fakeGetSitesAnswer = {
preset: 'site-dashboard',
title: 'Admin Site'
}
}, {
},
{
entry: {
role: 'SiteManager',
visibility: 'PUBLIC',
@ -146,7 +159,8 @@ export const fakeGetSitesAnswer = {
preset: 'site-dashboard',
title: 'Sample: Web Site Design Project'
}
}, {
},
{
entry: {
visibility: 'PUBLIC',
guid: 'af36cf8f-d43c-4a4b-84e6-d1b03e3a2ce5',
@ -154,7 +168,8 @@ export const fakeGetSitesAnswer = {
preset: 'site-dashboard',
title: 'Test Site'
}
}]
}
]
}
};
@ -167,7 +182,8 @@ export const fakeGetSiteMembership = {
skipCount: 0,
maxItems: 20
},
entries: [{
entries: [
{
entry: {
site: {
role: 'SiteManager',
@ -176,9 +192,13 @@ export const fakeGetSiteMembership = {
id: 'admin-site',
preset: 'site-dashboard',
title: 'Admin Site'
}, role: 'SiteManager', guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', id: 'admin-site'
},
role: 'SiteManager',
guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b',
id: 'admin-site'
}
}, {
},
{
entry: {
site: {
role: 'SiteManager',
@ -188,9 +208,13 @@ export const fakeGetSiteMembership = {
id: 'swsdp',
preset: 'site-dashboard',
title: 'Sample: Web Site Design Project'
}, role: 'SiteManager', guid: 'b4cff62a-664d-4d45-9302-98723eac1319', id: 'swsdp'
},
role: 'SiteManager',
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
id: 'swsdp'
}
}]
}
]
}
};
@ -202,17 +226,24 @@ export const fakeNodePaging: NodePaging = {
totalItems: 5,
skipCount: 0,
maxItems: 100
}, entries: [{
},
entries: [
{
entry: fakeNodeWithNoPermission
}, {
},
{
entry: fakeNodeWithNoPermission
}, {
},
{
entry: fakeNodeWithNoPermission
}, {
},
{
entry: fakeNodeWithNoPermission
}, {
},
{
entry: fakeNodeWithNoPermission
}]
}
]
}
};
@ -232,10 +263,13 @@ export const mockNode1 = new Node({
path: {
name: '/Company Home/Guest Home',
isComplete: true,
elements: [{
elements: [
{
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
name: 'Company Home'
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
},
{ id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }
]
},
isFolder: false,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
@ -261,10 +295,13 @@ export const mockNode2 = new Node({
path: {
name: '/Company Home/Guest Home',
isComplete: true,
elements: [{
elements: [
{
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
name: 'Company Home'
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
},
{ id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }
]
},
isFolder: false,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
@ -290,10 +327,13 @@ export const mockNode3 = new Node({
path: {
name: '/Company Home/Guest Home',
isComplete: true,
elements: [{
elements: [
{
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
name: 'Company Home'
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
},
{ id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }
]
},
isFolder: false,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
@ -320,12 +360,17 @@ export const mockNodePagingWithPreselectedNodes: NodePaging = {
totalItems: 5,
skipCount: 0,
maxItems: 100
}, entries: [{
},
entries: [
{
entry: mockNode1
}, {
},
{
entry: mockNode2
}, {
},
{
entry: mockNode3
}]
}
]
}
};

View File

@ -24,15 +24,12 @@ import { Component } from '@angular/core';
<span id="update-notification" *ngIf="updatedNode"> NODE UPDATED </span>
`
})
export class SimpleInheritedPermissionTestComponent {
message: string = '';
nodeId: string = 'fake-node-id';
updatedNode: boolean = false;
constructor() {
}
constructor() {}
onUpdate(node: any) {
this.updatedNode = node.permissions?.isInheritanceEnabled ?? false;

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
export const mockNode: any = ({
export const mockNode: any = {
isFile: true,
createdByUser: { id: 'admin', displayName: 'Administrator' },
modifiedAt: '2017-05-24T15:08:55.640Z',
@ -31,10 +31,13 @@ export const mockNode: any = ({
path: {
name: '/Company Home/Guest Home',
isComplete: true,
elements: [{
elements: [
{
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
name: 'Company Home'
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
},
{ id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }
]
},
isFolder: false,
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
@ -42,7 +45,7 @@ export const mockNode: any = ({
id: '70e1cc6a-6918-468a-b84a-1048093b06fd',
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' },
allowableOperations: ['delete', 'update']
});
};
export const mockFile = new File(['fakefake'], 'file-fake.png', { type: 'image/png' });
@ -59,21 +62,13 @@ export const mockNewVersionUploaderData: any = {
modifiedAt: '2022-05-24T10:19:43.544Z',
nodeType: 'cm:content',
content: {
mimeType:
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
mimeTypeName: 'Microsoft Word 2007',
sizeInBytes: 11887,
encoding: 'UTF-8'
},
parentId: '422538ca-ea4b-4086-83f9-b36e4521ec7f',
aspectNames: [
'rn:renditioned',
'cm:versionable',
'cm:titled',
'cm:auditable',
'cm:author',
'cm:thumbnailModification'
],
aspectNames: ['rn:renditioned', 'cm:versionable', 'cm:titled', 'cm:auditable', 'cm:author', 'cm:thumbnailModification'],
createdAt: '2022-05-24T07:26:44.429Z',
isFolder: false,
modifiedByUser: {
@ -101,21 +96,13 @@ export const mockNewVersionUploaderData: any = {
modifiedAt: '2022-05-24T07:26:45.337Z',
nodeType: 'cm:content',
content: {
mimeType:
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
mimeTypeName: 'Microsoft Word 2007',
sizeInBytes: 11949,
encoding: 'UTF-8'
},
parentId: '422538ca-ea4b-4086-83f9-b36e4521ec7f',
aspectNames: [
'rn:renditioned',
'cm:versionable',
'cm:titled',
'cm:auditable',
'cm:author',
'cm:thumbnailModification'
],
aspectNames: ['rn:renditioned', 'cm:versionable', 'cm:titled', 'cm:auditable', 'cm:author', 'cm:thumbnailModification'],
createdAt: '2022-05-24T07:26:44.429Z',
path: {
name: '/Company Home/User Homes/hruser',
@ -155,13 +142,7 @@ export const mockNewVersionUploaderData: any = {
accessStatus: 'ALLOWED'
}
],
settable: [
'Contributor',
'Collaborator',
'Coordinator',
'Editor',
'Consumer'
],
settable: ['Contributor', 'Collaborator', 'Coordinator', 'Editor', 'Consumer'],
isInheritanceEnabled: true
},
modifiedByUser: {

View File

@ -100,16 +100,11 @@ export const simpleCategories: SearchCategory[] = [
}
}
}
];
export const searchFilter = {
'app:fields': [
'cm:name'
],
include: [
'allowableOperations'
],
'app:fields': ['cm:name'],
include: ['allowableOperations'],
sorting: {
options: [
{
@ -412,8 +407,10 @@ export const mockSearchResult = {
label: 'SEARCH.FACET_QUERIES.MIMETYPE',
filterQuery: 'content.mimetype:text/html',
metrics: [{ type: 'count', value: { count: 13 } }]
}]
}, {
}
]
},
{
type: 'query',
label: 'Size facet queries',
buckets: [
@ -421,60 +418,75 @@ export const mockSearchResult = {
label: 'my1',
filterQuery: 'content.size:[111111 TO MAX]',
metrics: [{ type: 'count', value: { count: 806 } }]
}, {
},
{
label: 'my3',
filterQuery: 'content.size:[333333 TO MAX]',
metrics: [{ type: 'count', value: { count: 669 } }]
}, {
},
{
label: 'my2',
filterQuery: 'content.size:[222222 TO MAX]',
metrics: [{ type: 'count', value: { count: 691 } }]
}, {
},
{
label: 'my5',
filterQuery: 'content.size:[5555 TO MAX]',
metrics: [{ type: 'count', value: { count: 1866 } }]
}, {
},
{
label: 'my4',
filterQuery: 'content.size:[444444 TO MAX]',
metrics: [{ type: 'count', value: { count: 665 } }]
}, {
},
{
label: 'my7',
filterQuery: 'content.size:[777777 TO MAX]',
metrics: [{ type: 'count', value: { count: 641 } }]
}, {
},
{
label: 'SEARCH.FACET_QUERIES.SMALL',
filterQuery: 'content.size:[10240 TO 102400]',
metrics: [{ type: 'count', value: { count: 526 } }]
}, {
},
{
label: 'my6',
filterQuery: 'content.size:[666666 TO MAX]',
metrics: [{ type: 'count', value: { count: 652 } }]
}, {
},
{
label: 'SEARCH.FACET_QUERIES.XTRALARGE',
filterQuery: 'content.size:[16777216 TO 134217728]',
metrics: [{ type: 'count', value: { count: 617 } }]
}, {
},
{
label: 'my8',
filterQuery: 'content.size:[888888 TO MAX]',
metrics: [{ type: 'count', value: { count: 641 } }]
}, {
},
{
label: 'SEARCH.FACET_QUERIES.XXTRALARGE',
filterQuery: 'content.size:[134217728 TO MAX]',
metrics: [{ type: 'count', value: { count: 0 } }]
}, {
},
{
label: 'SEARCH.FACET_QUERIES.MEDIUM',
filterQuery: 'content.size:[102400 TO 1048576]',
metrics: [{ type: 'count', value: { count: 630 } }]
}, {
},
{
label: 'SEARCH.FACET_QUERIES.LARGE',
filterQuery: 'content.size:[1048576 TO 16777216]',
metrics: [{ type: 'count', value: { count: 23 } }]
}, {
},
{
label: 'Extra Small',
filterQuery: 'content.size:[0 TO 10240]',
metrics: [{ type: 'count', value: { count: 10239 } }]
}]
}, {
}
]
},
{
type: 'query',
label: 'SEARCH.FACET_QUERIES.MY_FACET_QUERIES',
buckets: [
@ -482,37 +494,45 @@ export const mockSearchResult = {
label: 'SEARCH.FACET_QUERIES.CREATED_THIS_YEAR',
filterQuery: 'created:2019',
metrics: [{ type: 'count', value: { count: 0 } }]
}]
}
]
},
{
type: 'field',
label: 'SEARCH.FACET_FIELDS.SIZE',
buckets: []
}, {
},
{
type: 'field',
label: 'SEARCH.FACET_FIELDS.CREATED',
buckets: []
}, {
},
{
type: 'field',
label: 'SEARCH.FACET_FIELDS.TYPE',
buckets: []
}, {
},
{
type: 'field',
label: 'SEARCH.FACET_FIELDS.MODIFIER',
buckets: []
}, {
},
{
type: 'field',
label: 'SEARCH.FACET_FIELDS.CREATOR',
buckets: []
}, {
},
{
type: 'interval',
label: 'TheModified',
buckets: []
}, {
},
{
type: 'interval',
label: 'The Created',
buckets: []
}]
}
]
}
}
};
@ -609,13 +629,7 @@ export const sizeOptions = [
}
];
export const filteredResult = [
'my1 (806)',
'my2 (691)',
'my3 (669)',
'my4 (665)',
'my5 (1866)'
];
export const filteredResult = ['my1 (806)', 'my2 (691)', 'my3 (669)', 'my4 (665)', 'my5 (1866)'];
export const mockContentSizeResponseBucket = {
label: '5875',
@ -628,10 +642,10 @@ export const mockContentSizeResponseBucket = {
}
}
]
};
};
export const getMockSearchResultWithResponseBucket = () => {
const cloneResult = JSON.parse(JSON.stringify( mockSearchResult));
const cloneResult = JSON.parse(JSON.stringify(mockSearchResult));
cloneResult.list.context.facets[3].buckets.push(mockContentSizeResponseBucket);
return cloneResult;
};

View File

@ -1,4 +1,6 @@
.adf-new-version-uploader-dialog {
display: block;
&-list {
height: 400px;
}
@ -33,6 +35,7 @@
display: flex;
justify-content: flex-end;
color: var(--adf-theme-foreground-text-color-054);
-webkit-font-smoothing: antialiased;
button {
text-transform: uppercase;

View File

@ -40,7 +40,10 @@ import { VersionListComponent } from '../version-manager/version-list.component'
],
templateUrl: './new-version-uploader.dialog.html',
styleUrls: ['./new-version-uploader.dialog.scss'],
encapsulation: ViewEncapsulation.None
encapsulation: ViewEncapsulation.None,
host: {
class: 'adf-new-version-uploader-dialog'
}
})
export class NewVersionUploaderDialogComponent implements OnInit {
/**

View File

@ -46,7 +46,8 @@ export const fakeContentComments = {
skipCount: 0,
maxItems: 100
},
entries: [{
entries: [
{
entry: {
createdAt: '2018-03-27T10:55:45.725+0000',
createdBy: fakeUser1,
@ -58,7 +59,8 @@ export const fakeContentComments = {
id: '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7',
content: 'fake-message-1'
}
}, {
},
{
entry: {
createdAt: '2018-03-27T10:55:45.725+0000',
createdBy: fakeUser2,

View File

@ -63,6 +63,10 @@
margin-left: 12px;
margin-right: 24px;
}
.adf-toolbar--spacer {
flex: 1 1 auto;
}
}
&-permission-role-column-header {

View File

@ -43,7 +43,7 @@ export class PermissionListService {
error$: Subject<boolean> = new Subject();
nodeWithRoles$: Subject<{ node: Node; roles: RoleModel[] }> = new Subject();
data$: Observable<NodePermissionsModel> = this.nodeWithRoles$.pipe(
map(({ node, roles}) => {
map(({ node, roles }) => {
const nodeLocalPermissions = this.nodePermissionService.getLocalPermissions(node);
const localPermissions = this.updateReadOnlyPermission(node, nodeLocalPermissions);
return {
@ -68,7 +68,8 @@ export class PermissionListService {
fetchPermission(nodeId: string) {
this.loading$.next(true);
this.nodePermissionService.getNodeWithRoles(nodeId)
this.nodePermissionService
.getNodeWithRoles(nodeId)
.pipe(finalize(() => this.loading$.next(false)))
.subscribe(
({ node, roles }) => {
@ -91,17 +92,15 @@ export class PermissionListService {
const authorityId = this.getManagerAuthority(this.node);
if (authorityId) {
const permissions = [
...(this.node.permissions.locallySet || []),
{ authorityId, name: SITE_MANAGER_ROLE, accessStatus: 'ALLOWED' }
];
const permissions = [...(this.node.permissions.locallySet || []), { authorityId, name: SITE_MANAGER_ROLE, accessStatus: 'ALLOWED' }];
updateLocalPermission$ = this.nodePermissionService.updatePermissions(this.node, permissions);
}
updateLocalPermission$.pipe(switchMap(() => this.nodeService.updateNode(this.node.id, nodeBody, {include: ['permissions']})))
.subscribe(
updateLocalPermission$.pipe(switchMap(() => this.nodeService.updateNode(this.node.id, nodeBody, { include: ['permissions'] }))).subscribe(
(nodeUpdated: Node) => {
const message = nodeUpdated.permissions.isInheritanceEnabled ? 'PERMISSION_MANAGER.MESSAGE.INHERIT-ENABLE-SUCCESS' : 'PERMISSION_MANAGER.MESSAGE.INHERIT-DISABLE-SUCCESS';
const message = nodeUpdated.permissions.isInheritanceEnabled
? 'PERMISSION_MANAGER.MESSAGE.INHERIT-ENABLE-SUCCESS'
: 'PERMISSION_MANAGER.MESSAGE.INHERIT-DISABLE-SUCCESS';
this.notificationService.showInfo(message);
nodeUpdated.permissions.inherited = nodeUpdated.permissions?.inherited ?? [];
this.reloadNode(nodeUpdated);
@ -121,9 +120,9 @@ export class PermissionListService {
this.nodePermissionDialogService
.openAddPermissionDialog(this.node, this.roles, 'PERMISSION_MANAGER.ADD-PERMISSION.TITLE')
.pipe(
switchMap(selection => {
switchMap((selection) => {
const total = selection.length;
const group = selection.filter(({authorityId}) => this.isGroup(authorityId)).length;
const group = selection.filter(({ authorityId }) => this.isGroup(authorityId)).length;
return forkJoin({
user: of(total - group),
group: of(group),
@ -131,23 +130,24 @@ export class PermissionListService {
});
})
)
.subscribe(({ user, group, node}) => {
this.notificationService.showInfo( 'PERMISSION_MANAGER.MESSAGE.PERMISSION-ADD-SUCCESS', null, { user, group });
.subscribe(
({ user, group, node }) => {
this.notificationService.showInfo('PERMISSION_MANAGER.MESSAGE.PERMISSION-ADD-SUCCESS', null, { user, group });
this.reloadNode(node);
},
() => {
this.notificationService.showError( 'PERMISSION_MANAGER.MESSAGE.PERMISSION-ADD-FAIL');
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-ADD-FAIL');
this.reloadNode();
}
);
}
deletePermissions(permissions: PermissionElement[]) {
this.nodePermissionService.removePermissions(this.node, permissions)
.subscribe((node) => {
this.nodePermissionService.removePermissions(this.node, permissions).subscribe(
(node) => {
const total = permissions.length;
const group = permissions.filter(({authorityId}) => this.isGroup(authorityId)).length;
this.notificationService.showInfo('PERMISSION_MANAGER.MESSAGE.PERMISSION-BULK-DELETE-SUCCESS', null, {user: total - group, group});
const group = permissions.filter(({ authorityId }) => this.isGroup(authorityId)).length;
this.notificationService.showInfo('PERMISSION_MANAGER.MESSAGE.PERMISSION-BULK-DELETE-SUCCESS', null, { user: total - group, group });
this.reloadNode(node);
},
() => {
@ -159,8 +159,8 @@ export class PermissionListService {
updateRole(role: string, permission: PermissionDisplayModel) {
const updatedPermissionRole = this.buildUpdatedPermission(role, permission);
this.nodePermissionService.updatePermissionRole(this.node, updatedPermissionRole)
.subscribe((node) => {
this.nodePermissionService.updatePermissionRole(this.node, updatedPermissionRole).subscribe(
(node) => {
this.notificationService.showInfo('PERMISSION_MANAGER.MESSAGE.PERMISSION-UPDATE-SUCCESS');
this.reloadNode(node);
this.updated.emit(permission);
@ -175,11 +175,11 @@ export class PermissionListService {
bulkRoleUpdate(role: string) {
const permissions = [...this.node.permissions.locallySet].map((permission) => this.buildUpdatedPermission(role, permission));
this.nodePermissionService.updatePermissions(this.node, permissions)
.subscribe((node) => {
this.nodePermissionService.updatePermissions(this.node, permissions).subscribe(
(node) => {
const total = permissions.length;
const group = permissions.filter(({authorityId}) => this.isGroup(authorityId)).length;
this.notificationService.showInfo('PERMISSION_MANAGER.MESSAGE.PERMISSION-BULK-UPDATE-SUCCESS', null, {user: total - group, group});
const group = permissions.filter(({ authorityId }) => this.isGroup(authorityId)).length;
this.notificationService.showInfo('PERMISSION_MANAGER.MESSAGE.PERMISSION-BULK-UPDATE-SUCCESS', null, { user: total - group, group });
this.reloadNode(node);
},
() => {
@ -190,10 +190,9 @@ export class PermissionListService {
}
deletePermission(permission: PermissionDisplayModel) {
const cloneNode = { ...this.node, permissions: { ...this.node.permissions, locallySet: [ ...this.node.permissions.locallySet ] } };
this.nodePermissionService
.removePermission(cloneNode, permission)
.subscribe((node) => {
const cloneNode = { ...this.node, permissions: { ...this.node.permissions, locallySet: [...this.node.permissions.locallySet] } };
this.nodePermissionService.removePermission(cloneNode, permission).subscribe(
(node) => {
this.notificationService.showInfo('PERMISSION_MANAGER.MESSAGE.PERMISSION-DELETE-SUCCESS');
if (!node.permissions.locallySet) {
node.permissions.locallySet = [];
@ -228,7 +227,9 @@ export class PermissionListService {
let authorityId: string;
if (sitePath) {
authorityId = `GROUP_site_${sitePath.name}_${SITE_MANAGER_ROLE}`;
hasLocalManagerPermission = !!node.permissions.locallySet?.find((permission) => permission.authorityId === authorityId && permission.name === SITE_MANAGER_ROLE);
hasLocalManagerPermission = !!node.permissions.locallySet?.find(
(permission) => permission.authorityId === authorityId && permission.name === SITE_MANAGER_ROLE
);
}
if (!hasLocalManagerPermission && authorityId) {

View File

@ -31,11 +31,7 @@ import { AllowableOperationsEnum } from '../../common/models/allowable-operation
providedIn: 'root'
})
export class NodePermissionDialogService {
constructor(private dialog: MatDialog,
private nodePermissionService: NodePermissionService,
private contentService: ContentService) {
}
constructor(private dialog: MatDialog, private nodePermissionService: NodePermissionService, private contentService: ContentService) {}
/**
* Opens a dialog to add permissions to a node.
@ -88,12 +84,14 @@ export class NodePermissionDialogService {
* @returns Node with updated permissions
*/
updateNodePermissionByDialog(nodeId?: string, title?: string): Observable<Node> {
return this.nodePermissionService.getNodeWithRoles(nodeId)
.pipe(
switchMap(({node, roles}) => this.openAddPermissionDialog(node, roles, title)
return this.nodePermissionService
.getNodeWithRoles(nodeId)
.pipe(
switchMap(({ node, roles }) =>
this.openAddPermissionDialog(node, roles, title).pipe(
switchMap((selection) => this.nodePermissionService.updateNodePermissions(nodeId, selection))
))
)
)
);
}
}

View File

@ -19,7 +19,6 @@ import { NodeEntry } from '@alfresco/js-api';
import { NodeNameTooltipPipe } from './node-name-tooltip.pipe';
describe('NodeNameTooltipPipe', () => {
const nodeName = 'node-name';
const nodeTitle = 'node-title';
const nodeDescription = 'node-description';

View File

@ -39,10 +39,7 @@ export class SearchAiService {
toggleSearchAiInput$ = this.toggleSearchAiInput.asObservable();
constructor(
private apiService: AlfrescoApiService,
private translateService: TranslateService
) {}
constructor(private apiService: AlfrescoApiService, private translateService: TranslateService) {}
/**
* Update the state of the search AI input.

View File

@ -1,3 +1,3 @@
<div class="adf-empty-search-result">
<ng-content></ng-content>
<ng-content />
</div>

View File

@ -50,8 +50,7 @@
*ngIf="data?.list?.entries.length === 0">
<ng-content
selector="adf-empty-search-result"
*ngIf="isNoSearchTemplatePresent() else defaultNoResult">
</ng-content>
*ngIf="isNoSearchTemplatePresent() else defaultNoResult" />
<ng-template #defaultNoResult>
<p matListItemLine class="adf-search-fixed-text">{{ 'SEARCH.RESULTS.NONE' | translate:{searchTerm:
searchTerm} }}</p>

View File

@ -15,5 +15,5 @@
</ng-container>
</ng-container>
<ng-content></ng-content>
<ng-content />
</mat-chip-set>

View File

@ -1,6 +1,6 @@
<div class="adf-search-filter-menu-card">
<div class="adf-search-filter-title">
<ng-content select="filter-title"></ng-content>
<ng-content select="filter-title" />
<button mat-icon-button
class="adf-search-filter-title-action"
aria-hidden="false"
@ -13,12 +13,12 @@
<mat-divider />
<div class="adf-search-filter-content">
<ng-content select="filter-content"></ng-content>
<ng-content select="filter-content" />
</div>
<mat-divider />
<div class="adf-search-filter-actions">
<ng-content select="filter-actions"></ng-content>
<ng-content select="filter-actions" />
</div>
</div>

View File

@ -55,7 +55,7 @@ export class SearchTextComponent implements SearchWidget, OnInit {
private readonly destroyRef = inject(DestroyRef);
ngOnInit() {
if (this.context && this.settings && this.settings.pattern) {
if (this.context && this.settings?.pattern) {
const pattern = new RegExp(this.settings.pattern, 'g');
const match = pattern.exec(this.context.queryFragments[this.id] || '');
if (this.settings.allowUpdateOnChange !== undefined && this.settings.allowUpdateOnChange !== null) {

View File

@ -2,6 +2,5 @@
[ngClass]="_classList" #panel>
<ng-template
[ngTemplateOutlet]="template"
[ngTemplateOutletContext]="{ $implicit: results }">
</ng-template>
[ngTemplateOutletContext]="{ $implicit: results }" />
</div>

View File

@ -18,11 +18,12 @@
import { UntypedFormControl } from '@angular/forms';
export class SearchTermValidator {
static minAlphanumericChars(minChars: number) {
return (control: UntypedFormControl) => ('' + control.value).replace(/[^0-9a-zA-Z]+/g, '').length >= minChars ? null : {
return (control: UntypedFormControl) =>
('' + control.value).replace(/[^0-9a-zA-Z]+/g, '').length >= minChars
? null
: {
hasMinAlphanumericChars: false
};
}
}

View File

@ -26,14 +26,13 @@ export class Payload {
}
describe('SearchFilterList', () => {
const generateItems = (count: number): Payload[] => Array(count).fill(null).map((_, id) => new Payload(id));
const generateItems = (count: number): Payload[] =>
Array(count)
.fill(null)
.map((_, id) => new Payload(id));
it('should init with external items', () => {
const items = [
new Payload(1),
new Payload(2)
];
const items = [new Payload(1), new Payload(2)];
const list = new SearchFilterList<Payload>(items);
expect(list.length).toBe(2);

View File

@ -18,7 +18,6 @@
const DEFAULT_PAGE_SIZE = 5;
export class SearchFilterList<T> implements Iterable<T> {
private filteredItems: T[] = [];
private _filterText: string = '';
@ -41,7 +40,7 @@ export class SearchFilterList<T> implements Iterable<T> {
return this._filter;
}
set filter(value: (item: T) => boolean ) {
set filter(value: (item: T) => boolean) {
this._filter = value;
this.applyFilter();
}

View File

@ -31,7 +31,6 @@ import { SearchDateRangeTabbedComponent } from '../components/search-date-range-
providedIn: 'root'
})
export class SearchFilterService {
/**
* Contains string-to-type mappings for registered widgets.
*/
@ -47,5 +46,4 @@ export class SearchFilterService {
'autocomplete-chips': SearchFilterAutocompleteChipsComponent,
'date-range': SearchDateRangeTabbedComponent
};
}

View File

@ -35,22 +35,15 @@ describe('SearchHeaderQueryBuilderService', () => {
return config;
};
const createQueryBuilder = (searchSettings): SearchHeaderQueryBuilderService => {
let builder: SearchHeaderQueryBuilderService;
TestBed.runInInjectionContext(() => {
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
builder = new SearchHeaderQueryBuilderService(buildConfig(searchSettings), alfrescoApiService, null);
});
return builder;
};
it('should load the configuration from app config', () => {
TestBed.runInInjectionContext(() => {
const config: SearchConfiguration = {
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
};
const builder = createQueryBuilder(config);
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
const builder = new SearchHeaderQueryBuilderService(buildConfig(config), alfrescoApiService, null);
builder.categories = [];
builder.filterQueries = [];
@ -63,8 +56,10 @@ describe('SearchHeaderQueryBuilderService', () => {
expect(builder.categories.length).toBe(2);
expect(builder.filterQueries.length).toBe(2);
});
});
it('should return the category assigned to a column key', () => {
TestBed.runInInjectionContext(() => {
const config: SearchConfiguration = {
categories: [
{ id: 'cat1', columnKey: 'fake-key-1', enabled: true } as any,
@ -73,20 +68,26 @@ describe('SearchHeaderQueryBuilderService', () => {
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
};
const service = createQueryBuilder(config);
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
const service = new SearchHeaderQueryBuilderService(buildConfig(config), alfrescoApiService, null);
const category = service.getCategoryForColumn('fake-key-1');
expect(category).not.toBeNull();
expect(category).not.toBeUndefined();
expect(category.columnKey).toBe('fake-key-1');
});
});
it('should have empty user query by default', () => {
const builder = createQueryBuilder({});
TestBed.runInInjectionContext(() => {
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
const builder = new SearchHeaderQueryBuilderService(buildConfig({}), alfrescoApiService, null);
expect(builder.userQuery).toBe('');
});
});
it('should add the extra filter for the parent node', () => {
TestBed.runInInjectionContext(() => {
const config: SearchConfiguration = {
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
@ -94,14 +95,17 @@ describe('SearchHeaderQueryBuilderService', () => {
const expectedResult = [{ query: 'PARENT:"workspace://SpacesStore/fake-node-id"' }];
const searchHeaderService = createQueryBuilder(config);
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
const searchHeaderService = new SearchHeaderQueryBuilderService(buildConfig(config), alfrescoApiService, null);
searchHeaderService.setCurrentRootFolderId('fake-node-id');
expect(searchHeaderService.filterQueries).toEqual(expectedResult, 'Filters are not as expected');
});
});
it('should not add again the parent filter if that node is already added', () => {
TestBed.runInInjectionContext(() => {
const expectedResult = [{ query: 'PARENT:"workspace://SpacesStore/fake-node-id"' }];
const config: SearchConfiguration = {
@ -109,13 +113,17 @@ describe('SearchHeaderQueryBuilderService', () => {
filterQueries: expectedResult
};
const searchHeaderService = createQueryBuilder(config);
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
const searchHeaderService = new SearchHeaderQueryBuilderService(buildConfig(config), alfrescoApiService, null);
searchHeaderService.setCurrentRootFolderId('fake-node-id');
expect(searchHeaderService.filterQueries).toEqual(expectedResult, 'Filters are not as expected');
});
});
it('should not add duplicate column names in activeFilters', () => {
TestBed.runInInjectionContext(() => {
const activeFilter = 'FakeColumn';
const config: SearchConfiguration = {
@ -123,7 +131,8 @@ describe('SearchHeaderQueryBuilderService', () => {
filterQueries: [{ query: 'PARENT:"workspace://SpacesStore/fake-node-id' }]
};
const searchHeaderService = createQueryBuilder(config);
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
const searchHeaderService = new SearchHeaderQueryBuilderService(buildConfig(config), alfrescoApiService, null);
expect(searchHeaderService.activeFilters.length).toBe(0);
@ -132,4 +141,5 @@ describe('SearchHeaderQueryBuilderService', () => {
expect(searchHeaderService.activeFilters.length).toBe(1);
});
});
});

View File

@ -18,7 +18,6 @@
import { NodeEntry } from '@alfresco/js-api';
export class TreeBaseNode {
name: string;
nodeId: string;
level: number;
@ -31,6 +30,5 @@ export class TreeBaseNode {
this.level = level ? level : 0;
this.expandable = expandable ? expandable : true;
this.node = nodeEntry ? new NodeEntry(nodeEntry) : undefined;
}
}

View File

@ -99,8 +99,7 @@
<mat-menu #menu="matMenu">
<ng-template
[ngTemplateOutlet]="nodeActionsMenuTemplate"
[ngTemplateOutletContext]="{ node: node }">
</ng-template>
[ngTemplateOutletContext]="{ node: node }" />
</mat-menu>
</div>
</mat-tree-node>
@ -109,8 +108,7 @@
</ng-container>
<ng-template #emptyContent>
<ng-template [ngTemplateOutlet]="emptyContentTemplate">
</ng-template>
<ng-template [ngTemplateOutlet]="emptyContentTemplate" />
</ng-template>
<ng-template #loadingSpinner>

View File

@ -26,7 +26,7 @@ import { treeNodesMockExpanded } from './tree-node.mock';
export class TreeServiceMock extends TreeService<TreeNode> {
public getSubNodes(parentNodeId: string, skipCount?: number, maxItems?: number): Observable<TreeResponse<TreeNode>> {
if (parentNodeId) {
return of({pagination: {skipCount, maxItems}, entries: Array.from(treeNodesMockExpanded)});
return of({ pagination: { skipCount, maxItems }, entries: Array.from(treeNodesMockExpanded) });
}
return of();
}

View File

@ -27,7 +27,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
// eslint-disable-next-line @angular-eslint/directive-class-suffix
export abstract class UploadBase implements OnInit {
protected uploadService = inject(UploadService);
protected translationService = inject(TranslationService);
protected translationService: TranslationService = inject(TranslationService);
protected ngZone = inject(NgZone);
/**
@ -98,31 +98,26 @@ export abstract class UploadBase implements OnInit {
* @param files files to upload
*/
uploadFiles(files: File[]): void {
const filteredFiles: FileModel[] = files
.map<FileModel>((file: File) => this.createFileModel(file, this.rootFolderId, ((file as any).webkitRelativePath || '').replace(/\/[^/]*$/, '')));
const filteredFiles: FileModel[] = files.map<FileModel>((file: File) =>
this.createFileModel(file, this.rootFolderId, ((file).webkitRelativePath || '').replace(/\/[^/]*$/, ''))
);
this.uploadQueue(filteredFiles);
}
uploadFilesInfo(files: FileInfo[]): void {
const filteredFiles: FileModel[] = files
.map<FileModel>((fileInfo: FileInfo) => this.createFileModel(fileInfo.file, this.rootFolderId, fileInfo.relativeFolder));
const filteredFiles: FileModel[] = files.map<FileModel>((fileInfo: FileInfo) =>
this.createFileModel(fileInfo.file, this.rootFolderId, fileInfo.relativeFolder)
);
this.uploadQueue(filteredFiles);
}
private uploadQueue(files: FileModel[]) {
const filteredFiles = files
.filter(this.isFileAcceptable.bind(this))
.filter(this.isFileSizeAcceptable.bind(this));
const filteredFiles = files.filter(this.isFileAcceptable.bind(this)).filter(this.isFileSizeAcceptable.bind(this));
this.ngZone.run(() => {
const event = new UploadFilesEvent(
[...filteredFiles],
this.uploadService,
this.success,
this.error
);
const event = new UploadFilesEvent([...filteredFiles], this.uploadService, this.success, this.error);
this.beginUpload.emit(event);
if (!event.defaultPrevented) {
@ -145,9 +140,7 @@ export abstract class UploadBase implements OnInit {
return true;
}
const allowedExtensions = this.acceptedFilesType
.split(',')
.map((ext) => ext.trim().replace(/^\./, ''));
const allowedExtensions = this.acceptedFilesType.split(',').map((ext) => ext.trim().replace(/^\./, ''));
return allowedExtensions.indexOf(file.extension) !== -1;
}
@ -162,14 +155,18 @@ export abstract class UploadBase implements OnInit {
* @returns file model
*/
protected createFileModel(file: File, parentId: string, path: string, id?: string): FileModel {
return new FileModel(file, {
return new FileModel(
file,
{
comment: this.comment,
majorVersion: this.majorVersion,
newVersion: this.versioning,
parentId,
path,
nodeType: this.nodeType
}, id);
},
id
);
}
protected isFileSizeAllowed(file: FileModel) {
@ -201,15 +198,11 @@ export abstract class UploadBase implements OnInit {
if (!this.isFileSizeAllowed(file)) {
acceptableSize = false;
const message = this.translationService.instant(
'FILE_UPLOAD.MESSAGES.EXCEED_MAX_FILE_SIZE',
{ fileName: file.name }
);
const message = this.translationService.instant('FILE_UPLOAD.MESSAGES.EXCEED_MAX_FILE_SIZE', { fileName: file.name });
this.error.emit(message);
}
return acceptableSize;
}
}

View File

@ -2,6 +2,5 @@
<ng-template
ngFor
[ngForOf]="files"
[ngForTemplate]="template">
</ng-template>
[ngForTemplate]="template" />
</div>

View File

@ -3,5 +3,5 @@
(folderEntityDropped)="onFolderEntityDropped($event)"
(upload-files)="onUploadFiles($any($event))"
dropzone="" webkitdropzone="*" #droparea>
<ng-content></ng-content>
<ng-content />
</div>

View File

@ -31,7 +31,7 @@ export class VersionCompatibilityService {
constructor(private discoveryApiService: DiscoveryApiService) {
this.discoveryApiService.ecmProductInfo$
.pipe(filter(acsInfo => !!acsInfo))
.pipe(filter((acsInfo) => !!acsInfo))
.subscribe((acsInfo: RepositoryInfo) => this.initializeAcsVersion(acsInfo.version));
}
@ -53,12 +53,13 @@ export class VersionCompatibilityService {
if (currentVersion) {
if (+currentVersion.major > +parsedRequiredVersion.major) {
versionSupported = true;
} else if (currentVersion.major === parsedRequiredVersion.major &&
+currentVersion.minor > +parsedRequiredVersion.minor) {
} else if (currentVersion.major === parsedRequiredVersion.major && +currentVersion.minor > +parsedRequiredVersion.minor) {
versionSupported = true;
} else if (currentVersion.major === parsedRequiredVersion.major &&
} else if (
currentVersion.major === parsedRequiredVersion.major &&
currentVersion.minor === parsedRequiredVersion.minor &&
+currentVersion.patch >= +parsedRequiredVersion.patch) {
+currentVersion.patch >= +parsedRequiredVersion.patch
) {
versionSupported = true;
}
}

View File

@ -34,23 +34,23 @@
(submitFile)="onSubmitFile($event)">
<adf-viewer-toolbar *ngIf="toolbar">
<ng-content select="adf-viewer-toolbar"></ng-content>
<ng-content select="adf-viewer-toolbar" />
</adf-viewer-toolbar>
<adf-viewer-toolbar-actions *ngIf="toolbarActions">
<ng-content select="adf-viewer-toolbar-actions"></ng-content>
<ng-content select="adf-viewer-toolbar-actions" />
</adf-viewer-toolbar-actions>
<adf-viewer-more-actions *ngIf="moreActions">
<ng-content select="adf-viewer-more-actions"></ng-content>
<ng-content select="adf-viewer-more-actions" />
</adf-viewer-more-actions>
<adf-viewer-open-with *ngIf="openWith">
<ng-content select="adf-viewer-open-with"></ng-content>
<ng-content select="adf-viewer-open-with" />
</adf-viewer-open-with>
<adf-viewer-sidebar *ngIf="sidebar">
<ng-content select="adf-viewer-sidebar"></ng-content>
<ng-content select="adf-viewer-sidebar" />
</adf-viewer-sidebar>
<adf-viewer-toolbar-custom-actions>

View File

@ -69,6 +69,7 @@ class ViewerWithCustomToolbarComponent {}
selector: 'adf-viewer-container-toolbar-actions',
standalone: true,
imports: [MatIconModule, MatButtonModule, ViewerToolbarActionsComponent, AlfrescoViewerComponent],
// eslint-disable-next-line @alfresco/eslint-angular/no-angular-material-selectors
template: `<adf-alfresco-viewer>
<adf-viewer-toolbar-actions>
<button mat-icon-button id="custom-button">
@ -103,6 +104,7 @@ class DummyDialogComponent {}
selector: 'adf-viewer-container-open-with',
standalone: true,
imports: [MatIconModule, MatMenuModule, ViewerOpenWithComponent, AlfrescoViewerComponent],
// eslint-disable-next-line @alfresco/eslint-angular/no-angular-material-selectors
template: `
<adf-alfresco-viewer>
<adf-viewer-open-with>
@ -128,6 +130,7 @@ class ViewerWithCustomOpenWithComponent {}
selector: 'adf-viewer-container-more-actions',
standalone: true,
imports: [MatIconModule, MatMenuModule, ViewerMoreActionsComponent, AlfrescoViewerComponent],
// eslint-disable-next-line @alfresco/eslint-angular/no-angular-material-selectors
template: ` <adf-alfresco-viewer>
<adf-viewer-more-actions>
<button mat-menu-item>

View File

@ -14,5 +14,6 @@
},
"target": "ES2022",
"useDefineForClassFields": false
}
},
"include": ["src/**/*.ts", "index.ts"]
}

View File

@ -6,5 +6,5 @@
"useDefineForClassFields": false
},
"files": ["src/test.ts"],
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts"]
"include": ["**/*.spec.ts", "**/*.test.ts", "**/*.d.ts", "index.ts"]
}

View File

@ -21,7 +21,6 @@ import { HttpParameterCodec } from '@angular/common/http';
// does not encode some special characters like + with is causing issues with the alfresco js API and returns 500 error
export class AlfrescoApiParamEncoder implements HttpParameterCodec {
encodeKey(key: string): string {
return encodeURIComponent(key);
}

View File

@ -16,10 +16,9 @@
*/
export class AlfrescoApiResponseError extends Error {
public name = 'AlfrescoApiResponseError';
constructor(msg: string, public status: number, public response: Record<string, any> ) {
constructor(msg: string, public status: number, public response: Record<string, any>) {
super(msg);
}
}

View File

@ -18,7 +18,6 @@
import { isConstructor, getQueryParamsWithCustomEncoder, removeNilValues } from './alfresco-api.utils';
describe('AlfrescoApiUtils', () => {
describe('isConstructor', () => {
class MockClass {}
/**
@ -50,9 +49,7 @@ describe('AlfrescoApiUtils', () => {
});
});
describe('getQueryParamsWithCustomEncoder', () => {
it('should return queryParams with removed undefined values', () => {
const actual = getQueryParamsWithCustomEncoder({
key1: 'value1',
@ -73,9 +70,7 @@ describe('AlfrescoApiUtils', () => {
});
});
describe('removeUndefinedValues', () => {
it('should return queryParams with removed undefined values', () => {
const actual = removeNilValues({
key1: 'value1',
@ -98,5 +93,4 @@ describe('AlfrescoApiUtils', () => {
expect(actual?.getAll('key2')).toEqual(['value2', 'value3']);
});
});
});

View File

@ -15,18 +15,31 @@
* limitations under the License.
*/
import { HttpEvent, HttpUploadProgressEvent, HttpEventType, HttpResponse, HttpParams, HttpParameterCodec, HttpUrlEncodingCodec } from '@angular/common/http';
import {
HttpEvent,
HttpUploadProgressEvent,
HttpEventType,
HttpResponse,
HttpParams,
HttpParameterCodec,
HttpUrlEncodingCodec
} from '@angular/common/http';
import { Constructor } from '../types';
export const isHttpUploadProgressEvent = <T>(val: HttpEvent<T>): val is HttpUploadProgressEvent => val.type === HttpEventType.UploadProgress;
export const isHttpResponseEvent = <T>(val: HttpEvent<T>): val is HttpResponse<T> => val.type === HttpEventType.Response;
export const isDate = (value: unknown): value is Date => value instanceof Date;
export const isXML = (value: unknown): boolean => typeof value === 'string' && value.startsWith('<?xml');
export const isBlobResponse = (response: HttpResponse<any>, returnType: Constructor<unknown> | 'blob'): response is HttpResponse<Blob> => returnType === 'blob' || response.body instanceof Blob;
export const isConstructor = <T = unknown>(value: any): value is Constructor<T> => typeof value === 'function' && !!value?.prototype?.constructor.name;
export const isBlobResponse = (response: HttpResponse<any>, returnType: Constructor<unknown> | 'blob'): response is HttpResponse<Blob> =>
returnType === 'blob' || response.body instanceof Blob;
export const isConstructor = <T = unknown>(value: any): value is Constructor<T> =>
typeof value === 'function' && !!value?.prototype?.constructor.name;
const convertParamsToString = (value: any): any => isDate(value) ? value.toISOString() : value;
export const getQueryParamsWithCustomEncoder = (obj: Record<string | number, unknown>, encoder: HttpParameterCodec = new HttpUrlEncodingCodec()): HttpParams | undefined => {
const convertParamsToString = (value: any): any => (isDate(value) ? value.toISOString() : value);
export const getQueryParamsWithCustomEncoder = (
obj: Record<string | number, unknown>,
encoder: HttpParameterCodec = new HttpUrlEncodingCodec()
): HttpParams | undefined => {
if (!obj) {
return undefined;
}
@ -38,7 +51,6 @@ export const getQueryParamsWithCustomEncoder = (obj: Record<string | number, unk
const params = removeNilValues(obj);
for (const key in params) {
if (Object.prototype.hasOwnProperty.call(params, key)) {
const value = params[key];
if (value instanceof Array) {
@ -62,7 +74,6 @@ export const getQueryParamsWithCustomEncoder = (obj: Record<string | number, unk
* @returns object with updated values
*/
export const removeNilValues = (obj: Record<string | number, unknown>) => {
if (!obj) {
return {};
}
@ -74,9 +85,7 @@ export const removeNilValues = (obj: Record<string | number, unknown>) => {
}, {});
};
export const convertObjectToFormData = (formParams: Record<string | number, string | Blob>): FormData => {
const formData = new FormData();
for (const key in formParams) {

View File

@ -17,6 +17,6 @@
export interface Dictionary<T> {
[key: string]: T;
};
}
export type Constructor<T> = new (...args: any[]) => T;

View File

@ -28,7 +28,8 @@ class MockAuthentication extends Authentication {
}
const mockNext: HttpHandler = {
handle: () => new Observable(subscriber => {
handle: () =>
new Observable((subscriber) => {
subscriber.complete();
})
};
@ -41,7 +42,7 @@ describe('AuthenticationInterceptor', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [AuthenticationInterceptor, {provide: Authentication, useClass: MockAuthentication}]
providers: [AuthenticationInterceptor, { provide: Authentication, useClass: MockAuthentication }]
});
interceptor = TestBed.inject(AuthenticationInterceptor);
addTokenToHeaderSpy = spyOn(interceptor['authService'], 'addTokenToHeader');

View File

@ -36,21 +36,18 @@ export const SHOULD_ADD_AUTH_TOKEN = new HttpContextToken<boolean>(() => false);
@Injectable()
export class AuthenticationInterceptor implements HttpInterceptor {
constructor(private authService: Authentication) {}
constructor( private authService: Authentication) { }
intercept(req: HttpRequest<any>, next: HttpHandler):
Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
intercept(
req: HttpRequest<any>,
next: HttpHandler
): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
if (req.context.get(SHOULD_ADD_AUTH_TOKEN)) {
return this.authService.addTokenToHeader(req.url, req.headers).pipe(
mergeMap((headersWithBearer) => {
const headerWithContentType = this.appendJsonContentType(headersWithBearer);
const kcReq = req.clone({ headers: headerWithContentType});
return next.handle(kcReq)
.pipe(
catchError((error) => observableThrowError(error))
);
const kcReq = req.clone({ headers: headerWithContentType });
return next.handle(kcReq).pipe(catchError((error) => observableThrowError(error)));
})
);
}
@ -59,7 +56,6 @@ export class AuthenticationInterceptor implements HttpInterceptor {
}
private appendJsonContentType(headers: HttpHeaders): HttpHeaders {
// prevent adding any content type, to properly handle formData with boundary browser generated value,
// as adding any Content-Type its going to break the upload functionality
@ -73,5 +69,4 @@ export class AuthenticationInterceptor implements HttpInterceptor {
return headers;
}
}

View File

@ -47,13 +47,7 @@ const meta: Meta = {
component: DemoBreadcrumbComponent,
decorators: [
moduleMetadata({
imports: [
BreadcrumbComponent,
BreadcrumbItemComponent,
MatButtonModule,
MatMenuModule,
MatIconModule
]
imports: [BreadcrumbComponent, BreadcrumbItemComponent, MatButtonModule, MatMenuModule, MatIconModule]
}),
applicationConfig({
providers: [importProvidersFrom(CoreStoryModule)]

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import {Component} from '@angular/core';
import { Component } from '@angular/core';
@Component({
selector: 'adf-demo-breadcrumb',

View File

@ -22,7 +22,7 @@ import { Component, TemplateRef, ViewChild } from '@angular/core';
selector: 'adf-breadcrumb-item',
template: `
<ng-template #breadcrumbItemTemplate>
<ng-content></ng-content>
<ng-content />
</ng-template>
`
})

View File

@ -34,13 +34,8 @@ export class BreadcrumbFocusDirective {
private getFocusableElements(root: HTMLElement): HTMLElement[] {
const allFocusableElements = `button, a, input, select, textarea, [tabindex]:not([tabindex="-1"])`;
return Array.from(
root.querySelectorAll(
allFocusableElements
) as NodeListOf<HTMLElement>
).filter(
(element) =>
!element.hasAttribute('disabled') && element.tabIndex >= 0
return Array.from(root.querySelectorAll(allFocusableElements) as NodeListOf<HTMLElement>).filter(
(element) => !element.hasAttribute('disabled') && element.tabIndex >= 0
);
}
}

View File

@ -18,7 +18,6 @@
import { Inject, Injectable, Optional, inject } from '@angular/core';
import { FlagsOverrideToken } from '../interfaces/features.interface';
export const isFlagsOverrideOn = () => () => inject(FlagsOverrideToken) ?? false;
@Injectable({ providedIn: 'root' })

View File

@ -27,22 +27,22 @@
"rxjs": "7.8.1"
},
"peerDependencies": {
"@angular/animations": "16.2.9",
"@angular/cdk": "16.2.9",
"@angular/common": "16.2.9",
"@angular/core": "16.2.9",
"@angular/forms": "16.2.9",
"@angular/material": "16.2.9",
"@angular/material-date-fns-adapter": "16.2.9",
"@angular/platform-browser": "16.2.9",
"@angular/router": "16.2.9",
"@mat-datetimepicker/core": "12.0.1",
"@ngx-translate/core": "^14.0.0",
"@angular/animations": ">=16.0.0",
"@angular/cdk": ">=16.0.0",
"@angular/common": ">=16.0.0",
"@angular/core": ">=16.0.0",
"@angular/forms": ">=16.0.0",
"@angular/material": ">=16.0.0",
"@angular/material-date-fns-adapter": ">=16.0.0",
"@angular/platform-browser": ">=16.0.0",
"@angular/router": ">=16.0.0",
"@mat-datetimepicker/core": ">=12.0.1",
"@ngx-translate/core": ">=14.0.0",
"@alfresco/js-api": ">=8.0.0-alpha.8-0",
"@alfresco/adf-extensions": ">=7.0.0-alpha.8-0",
"minimatch": "^10.0.1",
"pdfjs-dist": "3.3.122",
"ts-morph": "^20.0.0"
"minimatch": ">=10.0.0",
"pdfjs-dist": ">=3.3.122",
"ts-morph": ">=20.0.0"
},
"keywords": [
"core",

View File

@ -24,7 +24,7 @@
"defaultConfiguration": "production"
},
"build-schematics": {
"executor": "@nrwl/js:tsc",
"executor": "@nx/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/core/schematics/migrations",
@ -48,7 +48,7 @@
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": [
"lib/core/**/*.ts",
@ -71,10 +71,7 @@
"browserTarget": "core:build",
"configDir": "lib/core/.storybook",
"compodoc": false,
"styles": [
"node_modules/cropperjs/dist/cropper.min.css",
"node_modules/pdfjs-dist/web/pdf_viewer.css"
],
"styles": ["node_modules/cropperjs/dist/cropper.min.css", "node_modules/pdfjs-dist/web/pdf_viewer.css"],
"stylePreprocessorOptions": {
"includePaths": ["lib", "lib/core/src/lib"]
}

View File

@ -69,10 +69,7 @@ describe('StoragePrefixFactory', () => {
}
};
const prefixFactory = new StoragePrefixFactory(
appConfigService as AppConfigService,
externalPrefixFactory
);
const prefixFactory = new StoragePrefixFactory(appConfigService as AppConfigService, externalPrefixFactory);
prefixFactory.getPrefix().subscribe((prefix) => {
expect(prefix).toBe('prefix-from-factory');
@ -95,10 +92,7 @@ describe('StoragePrefixFactory', () => {
}
};
const prefixFactory = new StoragePrefixFactory(
appConfigService as AppConfigService,
externalPrefixFactory
);
const prefixFactory = new StoragePrefixFactory(appConfigService as AppConfigService, externalPrefixFactory);
prefixFactory.getPrefix().subscribe((prefix) => {
expect(prefix).toBe(appConfigPrefix);

View File

@ -33,7 +33,8 @@ export class StoragePrefixFactory {
constructor(
private appConfigService: AppConfigService,
@Optional()
@Inject(STORAGE_PREFIX_FACTORY_SERVICE) private storagePrefixFactory?: StoragePrefixFactoryService
@Inject(STORAGE_PREFIX_FACTORY_SERVICE)
private storagePrefixFactory?: StoragePrefixFactoryService
) {}
getPrefix(): Observable<string | undefined> {
@ -43,9 +44,7 @@ export class StoragePrefixFactory {
return of(prefix);
}
return this.storagePrefixFactory ?
this.storagePrefixFactory.getPrefix() :
of(prefix);
return this.storagePrefixFactory ? this.storagePrefixFactory.getPrefix() : of(prefix);
})
);
}

View File

@ -34,8 +34,7 @@ export function loadAppConfig(
storageService: StorageService,
adfHttpClient: AdfHttpClient,
storagePrefixFactory: StoragePrefixFactory
) {
) {
const init = () => {
adfHttpClient.disableCsrf = appConfigService.get<boolean>(AppConfigValues.DISABLECSRF, true);
storageService.prefix = appConfigService.get<string>(AppConfigValues.STORAGE_PREFIX, '');
@ -45,4 +44,4 @@ export function loadAppConfig(
});
};
return () => appConfigService.load(init);
};
}

View File

@ -23,7 +23,8 @@ import { AuthenticationService } from '../services/authentication.service';
import { RedirectAuthService } from '../oidc/redirect-auth.service';
const mockNext: HttpHandler = {
handle: () => new Observable(subscriber => {
handle: () =>
new Observable((subscriber) => {
subscriber.complete();
})
};

View File

@ -18,8 +18,15 @@
import { throwError as observableThrowError, Observable } from 'rxjs';
import { Injectable } from '@angular/core';
import {
HttpHandler, HttpInterceptor, HttpRequest,
HttpSentEvent, HttpHeaderResponse, HttpProgressEvent, HttpResponse, HttpUserEvent, HttpHeaders
HttpHandler,
HttpInterceptor,
HttpRequest,
HttpSentEvent,
HttpHeaderResponse,
HttpProgressEvent,
HttpResponse,
HttpUserEvent,
HttpHeaders
} from '@angular/common/http';
import { catchError, mergeMap } from 'rxjs/operators';
import { AuthenticationService } from '../services/authentication.service';
@ -30,17 +37,17 @@ export class AuthBearerInterceptor implements HttpInterceptor {
private excludedUrlsRegex: RegExp[];
constructor(private authenticationService: AuthenticationService) { }
constructor(private authenticationService: AuthenticationService) {}
private loadExcludedUrlsRegex() {
const excludedUrls = this.bearerExcludedUrls;
this.excludedUrlsRegex = excludedUrls.map((urlPattern) => new RegExp(`^https?://[^/]+/${urlPattern}`, 'i')) || [];
}
intercept(req: HttpRequest<any>, next: HttpHandler):
Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
intercept(
req: HttpRequest<any>,
next: HttpHandler
): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
if (!this.excludedUrlsRegex) {
this.loadExcludedUrlsRegex();
}
@ -48,27 +55,19 @@ export class AuthBearerInterceptor implements HttpInterceptor {
const requestUrl = req.url;
const shallPass: boolean = this.excludedUrlsRegex.some((regex) => regex.test(requestUrl));
if (shallPass) {
return next.handle(req)
.pipe(
catchError((error) => observableThrowError(error))
);
return next.handle(req).pipe(catchError((error) => observableThrowError(error)));
}
return this.authenticationService.addTokenToHeader(requestUrl, req.headers)
.pipe(
return this.authenticationService.addTokenToHeader(requestUrl, req.headers).pipe(
mergeMap((headersWithBearer) => {
const headerWithContentType = this.appendJsonContentType(headersWithBearer, req.body);
const kcReq = req.clone({ headers: headerWithContentType});
return next.handle(kcReq)
.pipe(
catchError((error) => observableThrowError(error))
);
const kcReq = req.clone({ headers: headerWithContentType });
return next.handle(kcReq).pipe(catchError((error) => observableThrowError(error)));
})
);
}
private appendJsonContentType(headers: HttpHeaders, reqBody: any): HttpHeaders {
// prevent adding any content type, to properly handle formData with boundary browser generated value,
// as adding any Content-Type its going to break the upload functionality
@ -86,5 +85,4 @@ export class AuthBearerInterceptor implements HttpInterceptor {
protected get bearerExcludedUrls(): readonly string[] {
return this._bearerExcludedUrls;
}
}

View File

@ -38,7 +38,6 @@ export interface TicketEntry {
providedIn: 'root'
})
export class ContentAuth {
onLogin = new ReplaySubject<any>(1);
onLogout = new ReplaySubject<any>(1);
onError = new Subject<any>();
@ -60,9 +59,7 @@ export class ContentAuth {
return this.appConfigService.get<string>(AppConfigValues.ECMHOST) + '/' + contextRootEcm + '/api/-default-/public/authentication/versions/1';
}
constructor(private appConfigService: AppConfigService,
private adfHttpClient: AdfHttpClient,
private storageService: StorageService) {
constructor(private appConfigService: AppConfigService, private adfHttpClient: AdfHttpClient, private storageService: StorageService) {
this.appConfigService.onLoad.subscribe(() => {
this.setConfig();
});
@ -72,7 +69,6 @@ export class ContentAuth {
if (this.storageService.getItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL)) {
this.setTicket(this.storageService.getItem(AppConfigValues.CONTENT_TICKET_STORAGE_LABEL));
}
}
saveUsername(username: string) {
@ -148,7 +144,8 @@ export class ContentAuth {
this.adfHttpClient.emit('error');
this.onError.next('error');
reject(error);
});
}
);
});
}
@ -200,12 +197,12 @@ export class ContentAuth {
createTicket(ticketBodyCreate: TicketBody): Promise<TicketEntry> {
if (ticketBodyCreate === null || ticketBodyCreate === undefined) {
this.onError.next((`Missing param ticketBodyCreate`));
this.onError.next(`Missing param ticketBodyCreate`);
throw new Error(`Missing param ticketBodyCreate`);
}
return this.adfHttpClient.post(this.basePath + '/tickets', {bodyParam: ticketBodyCreate});
return this.adfHttpClient.post(this.basePath + '/tickets', { bodyParam: ticketBodyCreate });
}
async requireAlfTicket(): Promise<void> {
@ -216,5 +213,4 @@ export class ContentAuth {
deleteTicket(): Promise<any> {
return this.adfHttpClient.delete(this.basePath + '/tickets/-me-');
}
}

View File

@ -22,12 +22,10 @@ import { AppConfigService, AppConfigValues } from '../../app-config/app-config.s
import { StorageService } from '../../common/services/storage.service';
import { ReplaySubject, Subject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ProcessAuth {
onLogin = new ReplaySubject<any>(1);
onLogout = new ReplaySubject<any>(1);
onError = new Subject<any>();
@ -38,7 +36,8 @@ export class ProcessAuth {
};
authentications: Authentication = {
basicAuth: {ticket: ''}, type: 'activiti'
basicAuth: { ticket: '' },
type: 'activiti'
};
get basePath(): string {
@ -46,9 +45,7 @@ export class ProcessAuth {
return this.appConfigService.get<string>(AppConfigValues.BPMHOST) + '/' + contextRootBpm;
}
constructor(private appConfigService: AppConfigService,
private adfHttpClient: AdfHttpClient,
private storageService: StorageService) {
constructor(private appConfigService: AppConfigService, private adfHttpClient: AdfHttpClient, private storageService: StorageService) {
this.appConfigService.onLoad.subscribe(() => {
this.setConfig();
});
@ -118,7 +115,8 @@ export class ProcessAuth {
this.onError.next('error');
}
reject(error);
});
}
);
});
return promise;
@ -147,7 +145,8 @@ export class ProcessAuth {
this.adfHttpClient.emit('error');
this.onError.next('error');
reject(error);
});
}
);
});
}

View File

@ -48,7 +48,7 @@ export const AuthGuardSsoRoleService: CanActivateFn = (route: ActivatedRouteSnap
}
const hasRole = hasRealmRole && hasClientRole;
if (!hasRole && route?.data && route.data['redirectUrl']) {
if (!hasRole && route?.data?.['redirectUrl']) {
const router = inject(Router);
router.navigate(['/' + route.data['redirectUrl']]);
}

View File

@ -20,39 +20,53 @@ import { IdentityRoleModel } from '../models/identity-role.model';
import { IdentityJoinGroupRequestModel } from '../interfaces/identity-user.service.interface';
export const mockIdentityGroup1 = {
id: 'mock-group-id-1', name: 'Mock Group 1', path: '/mock', subGroups: []
id: 'mock-group-id-1',
name: 'Mock Group 1',
path: '/mock',
subGroups: []
} as IdentityGroupModel;
export const mockIdentityGroup2 = {
id: 'mock-group-id-2', name: 'Mock Group 2', path: '', subGroups: []
id: 'mock-group-id-2',
name: 'Mock Group 2',
path: '',
subGroups: []
} as IdentityGroupModel;
export const mockIdentityGroup3 = {
id: 'mock-group-id-3', name: 'Mock Group 3', path: '', subGroups: []
id: 'mock-group-id-3',
name: 'Mock Group 3',
path: '',
subGroups: []
} as IdentityGroupModel;
export const mockIdentityGroup4 = {
id: 'mock-group-id-4', name: 'Mock Group 4', path: '', subGroups: []
id: 'mock-group-id-4',
name: 'Mock Group 4',
path: '',
subGroups: []
} as IdentityGroupModel;
export const mockIdentityGroup5 = {
id: 'mock-group-id-5', name: 'Mock Group 5', path: '', subGroups: []
id: 'mock-group-id-5',
name: 'Mock Group 5',
path: '',
subGroups: []
} as IdentityGroupModel;
export const mockIdentityGroupsCount = { count: 10 } as IdentityGroupCountModel;
export const mockIdentityGroups = [
mockIdentityGroup1, mockIdentityGroup2, mockIdentityGroup3, mockIdentityGroup4, mockIdentityGroup5
];
export const mockIdentityGroups = [mockIdentityGroup1, mockIdentityGroup2, mockIdentityGroup3, mockIdentityGroup4, mockIdentityGroup5];
export const roleMappingMock = [
{ id: 'role-id-1', name: 'role-name-1' }, { id: 'role-id-2', name: 'role-name-2' }
{ id: 'role-id-1', name: 'role-name-1' },
{ id: 'role-id-2', name: 'role-name-2' }
];
export const mockIdentityRoles = [
new IdentityRoleModel({id: 'mock-role-id', name: 'MOCK-ADMIN-ROLE'}),
new IdentityRoleModel({id: 'mock-role-id', name: 'MOCK-USER-ROLE'}),
new IdentityRoleModel({id: 'mock-role-id', name: 'MOCK-ROLE-1'})
new IdentityRoleModel({ id: 'mock-role-id', name: 'MOCK-ADMIN-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id', name: 'MOCK-USER-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id', name: 'MOCK-ROLE-1' })
];
export const clientRoles: IdentityRoleModel[] = [
@ -60,14 +74,20 @@ export const clientRoles: IdentityRoleModel[] = [
new IdentityRoleModel({ name: 'MOCK-USER-ROLE' })
];
export const mockJoinGroupRequest: IdentityJoinGroupRequestModel = {userId: 'mock-hser-id', groupId: 'mock-group-id', realm: 'mock-realm-name'};
export const mockJoinGroupRequest: IdentityJoinGroupRequestModel = { userId: 'mock-hser-id', groupId: 'mock-group-id', realm: 'mock-realm-name' };
export const mockGroup1 = {
id: 'mock-group-id-1', name: 'Mock Group 1', path: '/mock', subGroups: []
id: 'mock-group-id-1',
name: 'Mock Group 1',
path: '/mock',
subGroups: []
} as IdentityGroupModel;
export const mockGroup2 = {
id: 'mock-group-id-2', name: 'Mock Group 2', path: '', subGroups: []
id: 'mock-group-id-2',
name: 'Mock Group 2',
path: '',
subGroups: []
} as IdentityGroupModel;
export const mockGroups = [

View File

@ -31,7 +31,6 @@ import { IdentityRoleModel } from '../models/identity-role.model';
Injectable({ providedIn: 'root' });
export class IdentityGroupServiceMock implements IdentityGroupServiceInterface {
getGroups(): Observable<IdentityGroupModel[]> {
return of(mockIdentityGroups);
}
@ -81,9 +80,7 @@ export class IdentityGroupServiceMock implements IdentityGroupServiceInterface {
return of([]);
}
return of(mockIdentityGroups.filter(group =>
group.name.toUpperCase().includes(searchParams.name.toUpperCase())
));
return of(mockIdentityGroups.filter((group) => group.name.toUpperCase().includes(searchParams.name.toUpperCase())));
}
getGroupRoles(_groupId: string): Observable<IdentityRoleModel[]> {
@ -91,7 +88,8 @@ export class IdentityGroupServiceMock implements IdentityGroupServiceInterface {
}
checkGroupHasRole(groupId: string, roleNames: string[]): Observable<boolean> {
return this.getGroupRoles(groupId).pipe(map((groupRoles) => {
return this.getGroupRoles(groupId).pipe(
map((groupRoles) => {
let hasRole = false;
if (groupRoles?.length > 0) {
roleNames.forEach((roleName: string) => {
@ -103,7 +101,8 @@ export class IdentityGroupServiceMock implements IdentityGroupServiceInterface {
});
}
return hasRole;
}));
})
);
}
getClientIdByApplicationName(_applicationName: string): Observable<string> {
@ -119,9 +118,7 @@ export class IdentityGroupServiceMock implements IdentityGroupServiceInterface {
}
checkGroupHasClientApp(groupId: string, clientId: string): Observable<boolean> {
return this.getClientRoles(groupId, clientId).pipe(
map((response) => response && response.length > 0)
);
return this.getClientRoles(groupId, clientId).pipe(map((response) => response && response.length > 0));
}
checkGroupHasAnyClientAppRole(groupId: string, clientId: string, roleNames: string[]): Observable<boolean> {

View File

@ -18,37 +18,61 @@
import { IdentityUserModel } from '../models/identity-user.model';
import { IdentityRoleModel } from '../models/identity-role.model';
export const mockIdentityUser1: IdentityUserModel = { id: 'mock-user-id-1', username: 'userName1', firstName: 'first-name-1', lastName: 'last-name-1', email: 'abc@xyz.com' };
export const mockIdentityUser2: IdentityUserModel = { id: 'mock-user-id-2', username: 'userName2', firstName: 'first-name-2', lastName: 'last-name-2', email: 'abcd@xyz.com'};
export const mockIdentityUser3: IdentityUserModel = { id: 'mock-user-id-3', username: 'userName3', firstName: 'first-name-3', lastName: 'last-name-3', email: 'abcde@xyz.com' };
export const mockIdentityUser4: IdentityUserModel = { id: 'mock-user-id-4', username: 'userName4', firstName: 'first-name-4', lastName: 'last-name-4', email: 'abcde@xyz.com' };
export const mockIdentityUser5: IdentityUserModel = { id: 'mock-user-id-5', username: 'userName5', firstName: 'first-name-5', lastName: 'last-name-5', email: 'abcde@xyz.com' };
export const mockIdentityUser1: IdentityUserModel = {
id: 'mock-user-id-1',
username: 'userName1',
firstName: 'first-name-1',
lastName: 'last-name-1',
email: 'abc@xyz.com'
};
export const mockIdentityUser2: IdentityUserModel = {
id: 'mock-user-id-2',
username: 'userName2',
firstName: 'first-name-2',
lastName: 'last-name-2',
email: 'abcd@xyz.com'
};
export const mockIdentityUser3: IdentityUserModel = {
id: 'mock-user-id-3',
username: 'userName3',
firstName: 'first-name-3',
lastName: 'last-name-3',
email: 'abcde@xyz.com'
};
export const mockIdentityUser4: IdentityUserModel = {
id: 'mock-user-id-4',
username: 'userName4',
firstName: 'first-name-4',
lastName: 'last-name-4',
email: 'abcde@xyz.com'
};
export const mockIdentityUser5: IdentityUserModel = {
id: 'mock-user-id-5',
username: 'userName5',
firstName: 'first-name-5',
lastName: 'last-name-5',
email: 'abcde@xyz.com'
};
export const mockIdentityUsers: IdentityUserModel[] = [
mockIdentityUser1,
mockIdentityUser2,
mockIdentityUser3,
mockIdentityUser4,
mockIdentityUser5
];
export const mockIdentityUsers: IdentityUserModel[] = [mockIdentityUser1, mockIdentityUser2, mockIdentityUser3, mockIdentityUser4, mockIdentityUser5];
export const mockIdentityRole = new IdentityRoleModel({ id: 'id-1', name: 'MOCK-ADMIN-ROLE'});
export const mockIdentityRole = new IdentityRoleModel({ id: 'id-1', name: 'MOCK-ADMIN-ROLE' });
export const mockAvailableRoles = [
new IdentityRoleModel({ id: 'mock-role-id-1', name: 'MOCK-ADMIN-ROLE'}),
new IdentityRoleModel({ id: 'mock-role-id-2', name: 'MOCK-USER-ROLE'}),
new IdentityRoleModel({ id: 'mock-role-id-1', name: 'MOCK-ADMIN-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id-2', name: 'MOCK-USER-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id-3', name: 'MOCK_MODELER-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id-5', name: 'MOCK-ROLE-2'})
new IdentityRoleModel({ id: 'mock-role-id-5', name: 'MOCK-ROLE-2' })
];
export const mockAssignedRoles = [
new IdentityRoleModel({ id: 'mock-role-id-1', name: 'MOCK-ADMIN-ROLE'}),
new IdentityRoleModel({ id: 'mock-role-id-1', name: 'MOCK-ADMIN-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id-2', name: 'MOCK_MODELER-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id-3', name: 'MOCK-ROLE-1' })
];
export const mockEffectiveRoles = [
new IdentityRoleModel({id: 'mock-role-id-1', name: 'MOCK-ACTIVE-ADMIN-ROLE'}),
new IdentityRoleModel({id: 'mock-role-id-2', name: 'MOCK-ACTIVE-USER-ROLE'}),
new IdentityRoleModel({id: 'mock-role-id-3', name: 'MOCK-ROLE-1'})
new IdentityRoleModel({ id: 'mock-role-id-1', name: 'MOCK-ACTIVE-ADMIN-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id-2', name: 'MOCK-ACTIVE-USER-ROLE' }),
new IdentityRoleModel({ id: 'mock-role-id-3', name: 'MOCK-ROLE-1' })
];

View File

@ -35,7 +35,6 @@ import { mockAssignedRoles, mockAvailableRoles, mockEffectiveRoles, mockIdentity
providedIn: 'root'
})
export class IdentityUserServiceMock implements IdentityUserServiceInterface {
getCurrentUserInfo(): IdentityUserModel {
return mockIdentityUser1;
}
@ -45,9 +44,7 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface {
return of([]);
}
return of(mockIdentityUsers.filter(user =>
user.username.toUpperCase().includes(search.toUpperCase())
));
return of(mockIdentityUsers.filter((user) => user.username.toUpperCase().includes(search.toUpperCase())));
}
findUserByUsername(username: string): Observable<IdentityUserModel[]> {
@ -55,7 +52,7 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface {
return of([]);
}
return of(mockIdentityUsers.filter(user => user.username === username));
return of(mockIdentityUsers.filter((user) => user.username === username));
}
findUserByEmail(email: string): Observable<IdentityUserModel[]> {
@ -63,7 +60,7 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface {
return of([]);
}
return of(mockIdentityUsers.filter(user => user.email === email));
return of(mockIdentityUsers.filter((user) => user.email === email));
}
findUserById(id: string): Observable<any> {
@ -71,7 +68,7 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface {
return of([]);
}
return of(mockIdentityUsers.find(user => user.id === id));
return of(mockIdentityUsers.find((user) => user.id === id));
}
getClientRoles(userId: string, _clientId: string): Observable<any[]> {
@ -83,9 +80,7 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface {
}
checkUserHasClientApp(userId: string, clientId: string): Observable<boolean> {
return this.getClientRoles(userId, clientId).pipe(
map((clientRoles) => clientRoles.length > 0)
);
return this.getClientRoles(userId, clientId).pipe(map((clientRoles) => clientRoles.length > 0));
}
checkUserHasAnyClientAppRole(userId: string, clientId: string, roleNames: string[]): Observable<boolean> {
@ -112,9 +107,7 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface {
}
checkUserHasApplicationAccess(userId: string, applicationName: string): Observable<boolean> {
return this.getClientIdByApplicationName(applicationName).pipe(
switchMap((clientId: string) => this.checkUserHasClientApp(userId, clientId))
);
return this.getClientIdByApplicationName(applicationName).pipe(switchMap((clientId: string) => this.checkUserHasClientApp(userId, clientId)));
}
checkUserHasAnyApplicationRole(userId: string, applicationName: string, roleNames: string[]): Observable<boolean> {
@ -178,7 +171,8 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface {
}
checkUserHasRole(userId: string, roleNames: string[]): Observable<boolean> {
return this.getUserRoles(userId).pipe(map((userRoles: IdentityRoleModel[]) => {
return this.getUserRoles(userId).pipe(
map((userRoles: IdentityRoleModel[]) => {
let hasRole = false;
if (userRoles && userRoles.length > 0) {
roleNames.forEach((roleName: string) => {
@ -190,7 +184,8 @@ export class IdentityUserServiceMock implements IdentityUserServiceInterface {
});
}
return hasRole;
}));
})
);
}
queryUsers(_requestQuery: IdentityUserQueryCloudRequestModel): Observable<IdentityUserQueryResponse> {

View File

@ -128,6 +128,6 @@ export const deleteGroupMappingApi: any = {
export const applicationDetailsMockApi: any = {
oauth2Auth: {
callCustomApi: () => Promise.resolve([{id: 'mock-app-id', name: 'mock-app-name'}])
callCustomApi: () => Promise.resolve([{ id: 'mock-app-id', name: 'mock-app-name' }])
}
};

Some files were not shown because too many files have changed in this diff Show More