mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
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:
parent
2284ede0c7
commit
5d64c7f0ed
@ -10,3 +10,4 @@ scripts
|
||||
docs/**/*.md
|
||||
lib/js-api/docs/**/*.md
|
||||
.storybook
|
||||
webpack.config.js
|
||||
|
2
.github/workflows/pull-request.yml
vendored
2
.github/workflows/pull-request.yml
vendored
@ -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
4
jest.preset.js
Normal file
@ -0,0 +1,4 @@
|
||||
// eslint-disable
|
||||
const nxPreset = require('@nx/jest/preset').default;
|
||||
|
||||
module.exports = {...nxPreset };
|
@ -50,7 +50,7 @@
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nrwl/linter:eslint",
|
||||
"executor": "@nx/eslint:lint",
|
||||
"options": {
|
||||
"lintFilePatterns": ["lib/cli/**/*.ts", "lib/cli/**/*.html"]
|
||||
}
|
||||
|
@ -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"]
|
||||
}
|
||||
|
@ -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({
|
||||
...config,
|
||||
oauthInit: false
|
||||
}, this.adfHttpClient);
|
||||
return new AlfrescoApi(
|
||||
{
|
||||
...config,
|
||||
oauthInit: false
|
||||
},
|
||||
this.adfHttpClient
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
import { AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppConfigService, AppConfigValues, StorageService } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
|
||||
/**
|
||||
* Create a factory to resolve an api service instance
|
||||
@ -34,10 +34,11 @@ export function createAlfrescoApiInstance(angularAlfrescoApiService: AlfrescoApi
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AlfrescoApiLoaderService {
|
||||
constructor(private readonly appConfig: AppConfigService,
|
||||
private readonly apiService: AlfrescoApiService,
|
||||
private storageService: StorageService) {
|
||||
}
|
||||
constructor(
|
||||
private readonly appConfig: AppConfigService,
|
||||
private readonly apiService: AlfrescoApiService,
|
||||
private storageService: StorageService
|
||||
) {}
|
||||
|
||||
async init(): Promise<any> {
|
||||
await this.appConfig.load();
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
import { from, Observable, of, zip } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
@ -25,12 +25,12 @@ import { TagService } from '../../tag/services/tag.service';
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class NodeAspectService {
|
||||
|
||||
constructor(private nodesApiService: NodesApiService,
|
||||
private dialogAspectListService: DialogAspectListService,
|
||||
private cardViewContentUpdateService: CardViewContentUpdateService,
|
||||
private tagService: TagService) {
|
||||
}
|
||||
constructor(
|
||||
private nodesApiService: NodesApiService,
|
||||
private dialogAspectListService: DialogAspectListService,
|
||||
private cardViewContentUpdateService: CardViewContentUpdateService,
|
||||
private tagService: TagService
|
||||
) {}
|
||||
|
||||
updateNodeAspects(nodeId: string, selectorAutoFocusedOnClose?: string) {
|
||||
this.dialogAspectListService.openAspectListDialog(nodeId, selectorAutoFocusedOnClose).subscribe((aspectList) => {
|
||||
|
@ -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);
|
||||
|
@ -21,22 +21,15 @@ 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({
|
||||
next: async () => {
|
||||
if (this.authService.isOauth() && (this.authService.isALLProvider() || this.authService.isECMProvider())) {
|
||||
await this.basicAlfrescoAuthService.requireAlfTicket();
|
||||
}
|
||||
this.authService.onLogin.pipe(take(1)).subscribe({
|
||||
next: async () => {
|
||||
if (this.authService.isOauth() && (this.authService.isALLProvider() || this.authService.isECMProvider())) {
|
||||
await this.basicAlfrescoAuthService.requireAlfTicket();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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({
|
||||
|
@ -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] } };
|
||||
}
|
||||
}
|
||||
|
@ -24,59 +24,65 @@ import { from, Observable } from 'rxjs';
|
||||
import { map, mergeMap, toArray } from 'rxjs/operators';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class CategoryTreeDatasourceService extends TreeService<CategoryNode> {
|
||||
|
||||
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) => {
|
||||
const parentNode: CategoryNode = this.getParentNode(parentNodeId);
|
||||
const nodesList: CategoryNode[] = response.list.entries.map((entry: CategoryEntry) => ({
|
||||
id: entry.entry.id,
|
||||
nodeName: entry.entry.name,
|
||||
parentId: entry.entry.parentId,
|
||||
hasChildren: entry.entry.hasChildren,
|
||||
level: parentNode ? parentNode.level + 1 : 0,
|
||||
isLoading: false,
|
||||
nodeType: TreeNodeType.RegularNode
|
||||
}));
|
||||
if (response.list.pagination.hasMoreItems && parentNode) {
|
||||
const loadMoreNode: CategoryNode = {
|
||||
id: 'loadMore',
|
||||
nodeName: '',
|
||||
parentId: parentNode.id,
|
||||
hasChildren: false,
|
||||
level: parentNode.level + 1,
|
||||
isLoading: false,
|
||||
nodeType: TreeNodeType.LoadMoreNode
|
||||
};
|
||||
nodesList.push(loadMoreNode);
|
||||
}
|
||||
const treeResponse: TreeResponse<CategoryNode> = {entries: nodesList, pagination: response.list.pagination};
|
||||
return treeResponse;
|
||||
})) : 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 !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,
|
||||
nodeName: entry.entry.name,
|
||||
parentId: entry.entry.parentId,
|
||||
hasChildren: entry.entry.hasChildren,
|
||||
level: parentNode ? parentNode.level + 1 : 0,
|
||||
isLoading: false,
|
||||
nodeType: TreeNodeType.RegularNode
|
||||
}));
|
||||
if (response.list.pagination.hasMoreItems && parentNode) {
|
||||
const loadMoreNode: CategoryNode = {
|
||||
id: 'loadMore',
|
||||
nodeName: '',
|
||||
parentId: parentNode.id,
|
||||
hasChildren: false,
|
||||
level: parentNode.level + 1,
|
||||
isLoading: false,
|
||||
nodeType: TreeNodeType.LoadMoreNode
|
||||
};
|
||||
nodesList.push(loadMoreNode);
|
||||
}
|
||||
const treeResponse: TreeResponse<CategoryNode> = { entries: nodesList, pagination: response.list.pagination };
|
||||
return treeResponse;
|
||||
})
|
||||
)
|
||||
: 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 this.categoryService.getCategory(category.entry.id).pipe(
|
||||
map((res) => ({
|
||||
id: category.entry.id,
|
||||
nodeName: path ? `${path}/${category.entry.name}` : category.entry.name,
|
||||
parentId: category.entry.parentId,
|
||||
level: 0,
|
||||
nodeType: TreeNodeType.RegularNode,
|
||||
hasChildren: res.entry.hasChildren,
|
||||
isLoading: false
|
||||
}))
|
||||
);
|
||||
}),
|
||||
toArray(),
|
||||
map(res => ({entries: res, pagination: pagingResult.list.pagination})));
|
||||
}));
|
||||
return this.categoryService.getCategory(category.entry.id).pipe(
|
||||
map((res) => ({
|
||||
id: category.entry.id,
|
||||
nodeName: path ? `${path}/${category.entry.name}` : category.entry.name,
|
||||
parentId: category.entry.parentId,
|
||||
level: 0,
|
||||
nodeType: TreeNodeType.RegularNode,
|
||||
hasChildren: res.entry.hasChildren,
|
||||
isLoading: false
|
||||
}))
|
||||
);
|
||||
}),
|
||||
toArray(),
|
||||
map((res) => ({ entries: res, pagination: pagingResult.list.pagination }))
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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('');
|
||||
|
@ -21,7 +21,7 @@ import { Subject } from 'rxjs';
|
||||
import { AuthenticationService, ThumbnailService } from '@alfresco/adf-core';
|
||||
import { PermissionsEnum } from '../models/permissions.enum';
|
||||
import { AllowableOperationsEnum } from '../models/allowable-operations.enum';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
|
||||
export interface FolderCreatedEvent {
|
||||
name: string;
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
`
|
||||
})
|
||||
|
@ -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]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@ -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,24 +42,23 @@ export class AspectOrientedConfigService implements ContentMetadataConfig {
|
||||
}
|
||||
|
||||
public appendAllPreset(propertyGroups: PropertyGroupContainer): OrganisedPropertyGroup[] {
|
||||
const groups = Object.keys(propertyGroups)
|
||||
.map((groupName) => {
|
||||
const propertyGroup = propertyGroups[groupName];
|
||||
const properties = propertyGroup.properties;
|
||||
const groups = Object.keys(propertyGroups).map((groupName) => {
|
||||
const propertyGroup = propertyGroups[groupName];
|
||||
const properties = propertyGroup.properties;
|
||||
|
||||
if (this.isAspectReadOnly(groupName)) {
|
||||
Object.keys(properties).map((propertyName) => this.setReadOnlyProperty(properties[propertyName]));
|
||||
}
|
||||
if (this.isAspectReadOnly(groupName)) {
|
||||
Object.keys(properties).map((propertyName) => this.setReadOnlyProperty(properties[propertyName]));
|
||||
}
|
||||
|
||||
return Object.assign({}, propertyGroup, {
|
||||
properties: Object.keys(properties).map((propertyName) => {
|
||||
if (this.isPropertyReadOnly(propertyName)) {
|
||||
this.setReadOnlyProperty(properties[propertyName]);
|
||||
}
|
||||
return properties[propertyName];
|
||||
})
|
||||
});
|
||||
return Object.assign({}, propertyGroup, {
|
||||
properties: Object.keys(properties).map((propertyName) => {
|
||||
if (this.isPropertyReadOnly(propertyName)) {
|
||||
this.setReadOnlyProperty(properties[propertyName]);
|
||||
}
|
||||
return properties[propertyName];
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
return groups;
|
||||
}
|
||||
@ -87,7 +85,6 @@ export class AspectOrientedConfigService implements ContentMetadataConfig {
|
||||
} else {
|
||||
return readOnlyAspects === propertyGroupName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public filterExcludedPreset(propertyGroups: OrganisedPropertyGroup[]): OrganisedPropertyGroup[] {
|
||||
|
@ -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: {
|
||||
@ -118,5 +113,5 @@ describe('ContentMetadataConfigFactory', () => {
|
||||
expect(config).toEqual(jasmine.any(LayoutOrientedConfigService));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -15,26 +15,22 @@
|
||||
* 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) => {
|
||||
const propertyGroup = propertyGroups[groupName];
|
||||
const properties = propertyGroup.properties;
|
||||
return Object.keys(propertyGroups).map((groupName) => {
|
||||
const propertyGroup = propertyGroups[groupName];
|
||||
const properties = propertyGroup.properties;
|
||||
|
||||
return Object.assign({}, propertyGroup, {
|
||||
properties: Object.keys(properties).map((propertyName) => properties[propertyName])
|
||||
});
|
||||
return Object.assign({}, propertyGroup, {
|
||||
properties: Object.keys(properties).map((propertyName) => properties[propertyName])
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
filterExcludedPreset(propertyGroups: OrganisedPropertyGroup[]): OrganisedPropertyGroup[] {
|
||||
@ -42,7 +38,7 @@ export class IndifferentConfigService implements ContentMetadataConfig {
|
||||
}
|
||||
|
||||
appendAllPreset(): OrganisedPropertyGroup[] {
|
||||
return[];
|
||||
return [];
|
||||
}
|
||||
|
||||
isIncludeAllEnabled(): boolean {
|
||||
|
@ -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()) {
|
||||
@ -41,9 +40,9 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
|
||||
const organisedPropertyGroup = layoutBlocks.map((layoutBlock) => {
|
||||
const flattenedItems = this.flattenItems(layoutBlock.items);
|
||||
const properties = flattenedItems.reduce((props, explodedItem) => {
|
||||
const isProperty = typeof explodedItem.property === 'object';
|
||||
const isProperty = typeof explodedItem.property === 'object';
|
||||
const propertyName = isProperty ? explodedItem.property.name : explodedItem.property;
|
||||
let property = getProperty(propertyGroups, explodedItem.groupName, propertyName) || [];
|
||||
let property = getProperty(propertyGroups, explodedItem.groupName, propertyName) || [];
|
||||
if (isProperty) {
|
||||
property = this.setPropertyTitle(property, explodedItem.property);
|
||||
}
|
||||
@ -61,15 +60,14 @@ export class LayoutOrientedConfigService implements ContentMetadataConfig {
|
||||
}
|
||||
|
||||
public appendAllPreset(propertyGroups: PropertyGroupContainer): OrganisedPropertyGroup[] {
|
||||
return Object.keys(propertyGroups)
|
||||
.map((groupName) => {
|
||||
const propertyGroup = propertyGroups[groupName];
|
||||
const properties = propertyGroup.properties;
|
||||
return Object.keys(propertyGroups).map((groupName) => {
|
||||
const propertyGroup = propertyGroups[groupName];
|
||||
const properties = propertyGroup.properties;
|
||||
|
||||
return Object.assign({}, propertyGroup, {
|
||||
properties: Object.keys(properties).map((propertyName) => properties[propertyName])
|
||||
});
|
||||
return Object.assign({}, propertyGroup, {
|
||||
properties: Object.keys(properties).map((propertyName) => properties[propertyName])
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public filterExcludedPreset(propertyGroups: OrganisedPropertyGroup[]): OrganisedPropertyGroup[] {
|
||||
@ -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;
|
||||
}
|
||||
|
@ -31,24 +31,24 @@ import { VersionCompatibilityService } from '../../version-compatibility/version
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ContentTypePropertiesService {
|
||||
|
||||
constructor(private contentTypeService: ContentTypeService,
|
||||
private dialog: MatDialog,
|
||||
private versionCompatibilityService: VersionCompatibilityService,
|
||||
private propertyGroupTranslatorService: PropertyGroupTranslatorService) {
|
||||
}
|
||||
constructor(
|
||||
private contentTypeService: ContentTypeService,
|
||||
private dialog: MatDialog,
|
||||
private versionCompatibilityService: VersionCompatibilityService,
|
||||
private propertyGroupTranslatorService: PropertyGroupTranslatorService
|
||||
) {}
|
||||
|
||||
getContentTypeCardItem(node: Node): Observable<CardViewItem[]> {
|
||||
if (this.versionCompatibilityService.isVersionSupported('7')) {
|
||||
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];
|
||||
}));
|
||||
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[] {
|
||||
|
@ -36,14 +36,13 @@ 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(() => {
|
||||
expect(classesApi.getClass).toHaveBeenCalledTimes(3);
|
||||
expect(classesApi.getClass).toHaveBeenCalledWith('exif_exif');
|
||||
expect(classesApi.getClass).toHaveBeenCalledWith('cm_content');
|
||||
expect(classesApi.getClass).toHaveBeenCalledWith('custom_custom');
|
||||
done();
|
||||
});
|
||||
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');
|
||||
expect(classesApi.getClass).toHaveBeenCalledWith('custom_custom');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should merge the forked values', (done) => {
|
||||
|
@ -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, {
|
||||
[propertyGroup.name]: propertyGroup
|
||||
}), {});
|
||||
return propertyGroupsArray.reduce(
|
||||
(propertyGroups, propertyGroup) =>
|
||||
Object.assign({}, propertyGroups, {
|
||||
[propertyGroup.name]: propertyGroup
|
||||
}),
|
||||
{}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#{$mat-form-field-hide-placeholder} {
|
||||
#{$mat-floating-label} {
|
||||
padding-top: 11px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
&#{$mat-form-field-hide-placeholder} {
|
||||
#{$mat-floating-label} {
|
||||
padding-top: 11px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
private contentService: ContentService,
|
||||
schema: DataColumn[] = [],
|
||||
sorting?: DataSorting,
|
||||
sortingMode: string = 'client',
|
||||
allowDropFiles: boolean = false) {
|
||||
constructor(
|
||||
private thumbnailService: ThumbnailService,
|
||||
private contentService: ContentService,
|
||||
schema: DataColumn[] = [],
|
||||
sorting?: DataSorting,
|
||||
sortingMode: string = 'client',
|
||||
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);
|
||||
@ -326,6 +316,6 @@ export class ShareDataTableAdapter implements DataTableAdapter {
|
||||
}
|
||||
|
||||
getRowByNodeId(nodeId: string): DataRow {
|
||||
return this.rows.find((row: DataRow) => row.node.entry.id === nodeId);
|
||||
return this.rows.find((row: DataRow) => row.node.entry.id === nodeId);
|
||||
}
|
||||
}
|
||||
|
@ -59,14 +59,14 @@ export enum ContentActionTarget {
|
||||
export type ContentActionHandler = (obj: any, target?: any, permission?: string) => any;
|
||||
|
||||
export class DocumentActionModel extends ContentActionModel {
|
||||
constructor(json?: any) {
|
||||
constructor(json?: any) {
|
||||
super(json);
|
||||
this.target = 'document';
|
||||
}
|
||||
}
|
||||
|
||||
export class FolderActionModel extends ContentActionModel {
|
||||
constructor(json?: any) {
|
||||
export class FolderActionModel extends ContentActionModel {
|
||||
constructor(json?: any) {
|
||||
super(json);
|
||||
this.target = 'folder';
|
||||
}
|
||||
|
@ -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,
|
||||
private documentListService: DocumentListService,
|
||||
private contentService: ContentService,
|
||||
private translation: TranslationService) {
|
||||
constructor(
|
||||
private nodeActionsService: NodeActionsService,
|
||||
private documentListService: DocumentListService,
|
||||
private contentService: ContentService,
|
||||
private translation: TranslationService
|
||||
) {
|
||||
this.setupActionHandlers();
|
||||
}
|
||||
|
||||
@ -107,36 +108,36 @@ export class FolderActionsService {
|
||||
}
|
||||
|
||||
private prepareHandlers(actionObservable: Observable<any>, target?: any): void {
|
||||
actionObservable.subscribe(
|
||||
(fileOperationMessage) => {
|
||||
if (target && typeof target.reload === 'function') {
|
||||
target.reload();
|
||||
}
|
||||
this.success.next(fileOperationMessage);
|
||||
},
|
||||
this.error.next.bind(this.error)
|
||||
);
|
||||
actionObservable.subscribe((fileOperationMessage) => {
|
||||
if (target && typeof target.reload === 'function') {
|
||||
target.reload();
|
||||
}
|
||||
this.success.next(fileOperationMessage);
|
||||
}, 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(() => {
|
||||
if (target && typeof target.reload === 'function') {
|
||||
target.reload();
|
||||
}
|
||||
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);
|
||||
});
|
||||
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'));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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, {
|
||||
maxItems: opts.maxItems,
|
||||
skipCount: skip
|
||||
}, accumulator);
|
||||
return this.listAllGroupMembershipsForPerson(
|
||||
personId,
|
||||
{
|
||||
maxItems: opts.maxItems,
|
||||
skipCount: skip
|
||||
},
|
||||
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) => {
|
||||
group.entry.description ||= '';
|
||||
return 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, {
|
||||
displayName: group.displayName,
|
||||
description: group.description
|
||||
}, opts)).pipe(map((updatedGroup) => {
|
||||
updatedGroup.entry.description ||= '';
|
||||
return updatedGroup;
|
||||
}));
|
||||
return from(
|
||||
this.groupsApi.updateGroup(
|
||||
group.id,
|
||||
{
|
||||
displayName: group.displayName,
|
||||
description: group.description
|
||||
},
|
||||
opts
|
||||
)
|
||||
).pipe(
|
||||
map((updatedGroup) => {
|
||||
updatedGroup.entry.description ||= '';
|
||||
return updatedGroup;
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,128 +17,126 @@
|
||||
|
||||
/* spellchecker: disable */
|
||||
|
||||
export const fakeAuthorityResults: any[] = [{
|
||||
entry: {
|
||||
aspectNames: [
|
||||
'cm:personDisabled',
|
||||
'cm:ownable',
|
||||
'cm:preferences'
|
||||
],
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 4.014668
|
||||
},
|
||||
isFile: false,
|
||||
name: 'dc103838-645f-43c1-8a2a-bc187e13c343',
|
||||
location: 'nodes',
|
||||
id: 'dc103838-645f-43c1-8a2a-bc187e13c343',
|
||||
nodeType: 'cm:person',
|
||||
properties: {
|
||||
'cm:location': 'Tilbury, UK',
|
||||
'cm:persondescription': {
|
||||
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',
|
||||
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_'
|
||||
export const fakeAuthorityResults: any[] = [
|
||||
{
|
||||
entry: {
|
||||
aspectNames: ['cm:personDisabled', 'cm:ownable', 'cm:preferences'],
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 4.014668
|
||||
},
|
||||
'cm:owner': {
|
||||
id: 'abeecher',
|
||||
displayName: 'Alice Beecher'
|
||||
isFile: false,
|
||||
name: 'dc103838-645f-43c1-8a2a-bc187e13c343',
|
||||
location: 'nodes',
|
||||
id: 'dc103838-645f-43c1-8a2a-bc187e13c343',
|
||||
nodeType: 'cm:person',
|
||||
properties: {
|
||||
'cm:location': 'Tilbury, UK',
|
||||
'cm:persondescription': {
|
||||
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',
|
||||
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_'
|
||||
},
|
||||
'cm:owner': {
|
||||
id: 'abeecher',
|
||||
displayName: 'Alice Beecher'
|
||||
},
|
||||
'cm:companyaddress2': 'Tilbury',
|
||||
'cm:userStatus': 'Helping to design the look and feel of the new web site',
|
||||
'cm:companyaddress1': '200 Butterwick Street',
|
||||
'cm:telephone': '0112211001100',
|
||||
'cm:preferenceValues': {
|
||||
contentUrl: 'store://2018/4/18/9/30/afc39bc9-6bac-4f24-8730-9d9f617a322e.bin',
|
||||
mimetype: 'text/plain',
|
||||
size: 709,
|
||||
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_'
|
||||
},
|
||||
'cm:userName': 'abeecher',
|
||||
'cm:companyaddress3': 'UK',
|
||||
'cm:userStatusTime': '2011-02-15T20:20:13.432+0000',
|
||||
'cm:email': 'abeecher@example.com',
|
||||
'cm:skype': 'abeecher',
|
||||
'cm:jobtitle': 'Graphic Designer',
|
||||
'cm:homeFolderProvider': 'userHomesHomeFolderProvider',
|
||||
'cm:homeFolder': '242533d8-68e6-4811-bc3d-61ec63c614aa',
|
||||
'cm:lastName': 'Beecher',
|
||||
'cm:sizeCurrent': 8382006,
|
||||
'cm:sizeQuota': -1,
|
||||
'cm:firstName': 'Alice',
|
||||
'cm:emailFeedId': 440,
|
||||
'cm:authorizationStatus': 'NEVER_AUTHORIZED',
|
||||
'cm:mobile': '0112211001100',
|
||||
'cm:organization': 'Moresby, Garland and Wedge',
|
||||
'cm:companypostcode': 'ALF1 SAM1'
|
||||
},
|
||||
'cm:companyaddress2': 'Tilbury',
|
||||
'cm:userStatus': 'Helping to design the look and feel of the new web site',
|
||||
'cm:companyaddress1': '200 Butterwick Street',
|
||||
'cm:telephone': '0112211001100',
|
||||
'cm:preferenceValues': {
|
||||
contentUrl: 'store://2018/4/18/9/30/afc39bc9-6bac-4f24-8730-9d9f617a322e.bin',
|
||||
mimetype: 'text/plain',
|
||||
size: 709,
|
||||
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_'
|
||||
parentId: '063f5d48-a0b3-4cbf-826c-88a4fbfa3336'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
aspectNames: ['cm:ownable', 'cm:preferences'],
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 4.014668
|
||||
},
|
||||
'cm:userName': 'abeecher',
|
||||
'cm:companyaddress3': 'UK',
|
||||
'cm:userStatusTime': '2011-02-15T20:20:13.432+0000',
|
||||
'cm:email': 'abeecher@example.com',
|
||||
'cm:skype': 'abeecher',
|
||||
'cm:jobtitle': 'Graphic Designer',
|
||||
'cm:homeFolderProvider': 'userHomesHomeFolderProvider',
|
||||
'cm:homeFolder': '242533d8-68e6-4811-bc3d-61ec63c614aa',
|
||||
'cm:lastName': 'Beecher',
|
||||
'cm:sizeCurrent': 8382006,
|
||||
'cm:sizeQuota': -1,
|
||||
'cm:firstName': 'Alice',
|
||||
'cm:emailFeedId': 440,
|
||||
'cm:authorizationStatus': 'NEVER_AUTHORIZED',
|
||||
'cm:mobile': '0112211001100',
|
||||
'cm:organization': 'Moresby, Garland and Wedge',
|
||||
'cm:companypostcode': 'ALF1 SAM1'
|
||||
},
|
||||
parentId: '063f5d48-a0b3-4cbf-826c-88a4fbfa3336'
|
||||
isFile: false,
|
||||
name: 'e320c16b-a763-4a4e-9f22-286ff5d8dca2',
|
||||
location: 'nodes',
|
||||
id: 'e320c16b-a763-4a4e-9f22-286ff5d8dca2',
|
||||
nodeType: 'cm:person',
|
||||
properties: {
|
||||
'cm:homeFolderProvider': 'bootstrapHomeFolderProvider',
|
||||
'cm:preferenceValues': {
|
||||
contentUrl: 'store://2018/4/23/14/42/92bb4aa9-db27-41a4-9804-ddab3cc83d3e.bin',
|
||||
mimetype: 'text/plain',
|
||||
size: 102,
|
||||
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_'
|
||||
},
|
||||
'cm:authorizationStatus': 'AUTHORIZED',
|
||||
'cm:homeFolder': 'a20cd541-4ada-4525-9807-9fa0a047d9f4',
|
||||
'cm:userName': 'admin',
|
||||
'cm:sizeCurrent': 0,
|
||||
'cm:email': 'admin@alfresco.com',
|
||||
'cm:firstName': 'Administrator',
|
||||
'cm:owner': {
|
||||
id: 'admin',
|
||||
displayName: 'Administrator'
|
||||
}
|
||||
},
|
||||
parentId: '063f5d48-a0b3-4cbf-826c-88a4fbfa3336'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 0.3541112
|
||||
},
|
||||
isFile: false,
|
||||
name: 'GROUP_ALFRESCO_ADMINISTRATORS',
|
||||
location: 'nodes',
|
||||
id: 'GROUP_ALFRESCO_ADMINISTRATORS',
|
||||
nodeType: 'cm:authorityContainer',
|
||||
properties: {
|
||||
'cm:authorityName': 'GROUP_ALFRESCO_ADMINISTRATORS'
|
||||
},
|
||||
parentId: '030d833e-da8e-4f5c-8ef9-d809638bd04b'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
aspectNames: [
|
||||
'cm:ownable',
|
||||
'cm:preferences'
|
||||
],
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 4.014668
|
||||
},
|
||||
isFile: false,
|
||||
name: 'e320c16b-a763-4a4e-9f22-286ff5d8dca2',
|
||||
location: 'nodes',
|
||||
id: 'e320c16b-a763-4a4e-9f22-286ff5d8dca2',
|
||||
nodeType: 'cm:person',
|
||||
properties: {
|
||||
'cm:homeFolderProvider': 'bootstrapHomeFolderProvider',
|
||||
'cm:preferenceValues': {
|
||||
contentUrl: 'store://2018/4/23/14/42/92bb4aa9-db27-41a4-9804-ddab3cc83d3e.bin',
|
||||
mimetype: 'text/plain',
|
||||
size: 102,
|
||||
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_'
|
||||
},
|
||||
'cm:authorizationStatus': 'AUTHORIZED',
|
||||
'cm:homeFolder': 'a20cd541-4ada-4525-9807-9fa0a047d9f4',
|
||||
'cm:userName': 'admin',
|
||||
'cm:sizeCurrent': 0,
|
||||
'cm:email': 'admin@alfresco.com',
|
||||
'cm:firstName': 'Administrator',
|
||||
'cm:owner': {
|
||||
id: 'admin',
|
||||
displayName: 'Administrator'
|
||||
}
|
||||
},
|
||||
parentId: '063f5d48-a0b3-4cbf-826c-88a4fbfa3336'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 0.3541112
|
||||
},
|
||||
isFile: false,
|
||||
name: 'GROUP_ALFRESCO_ADMINISTRATORS',
|
||||
location: 'nodes',
|
||||
id: 'GROUP_ALFRESCO_ADMINISTRATORS',
|
||||
nodeType: 'cm:authorityContainer',
|
||||
properties: {
|
||||
'cm:authorityName': 'GROUP_ALFRESCO_ADMINISTRATORS'
|
||||
},
|
||||
parentId: '030d833e-da8e-4f5c-8ef9-d809638bd04b'
|
||||
}
|
||||
}];
|
||||
];
|
||||
|
||||
export const fakeAuthorityListResult: any = {
|
||||
list: {
|
||||
@ -168,64 +166,67 @@ export const fakeNameListResult: any = {
|
||||
lastTxId: 5496
|
||||
}
|
||||
},
|
||||
entries: [{
|
||||
entry: {
|
||||
aspectNames: ['cm:ownable'],
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 1.0
|
||||
},
|
||||
isFile: false,
|
||||
name: '730cd9b0-5617-4865-aee8-90de1d596997',
|
||||
location: 'nodes',
|
||||
id: '730cd9b0-5617-4865-aee8-90de1d596997',
|
||||
nodeType: 'cm:person',
|
||||
properties: {
|
||||
'cm:homeFolderProvider': 'userHomesHomeFolderProvider',
|
||||
'cm:authorizationStatus': 'NEVER_AUTHORIZED',
|
||||
'cm:homeFolder': '277f505d-6526-45b1-a7b3-c9bdd66f17f6',
|
||||
'cm:userName': 'test1',
|
||||
'cm:lastName': 'lastName1',
|
||||
'cm:sizeCurrent': 0,
|
||||
'cm:email': 'test1@gmail.com',
|
||||
'cm:sizeQuota': 1073741824,
|
||||
'cm:firstName': 'firstName',
|
||||
'cm:owner': {
|
||||
id: 'test1',
|
||||
displayName: 'firstName lastName1'
|
||||
}
|
||||
},
|
||||
parentId: '3e9ce910-a4a0-4531-8f80-7734bece6342'
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
aspectNames: ['cm:ownable'],
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 1.0
|
||||
},
|
||||
isFile: false,
|
||||
name: '730cd9b0-5617-4865-aee8-90de1d596997',
|
||||
location: 'nodes',
|
||||
id: '730cd9b0-5617-4865-aee8-90de1d596997',
|
||||
nodeType: 'cm:person',
|
||||
properties: {
|
||||
'cm:homeFolderProvider': 'userHomesHomeFolderProvider',
|
||||
'cm:authorizationStatus': 'NEVER_AUTHORIZED',
|
||||
'cm:homeFolder': '277f505d-6526-45b1-a7b3-c9bdd66f17f6',
|
||||
'cm:userName': 'test1',
|
||||
'cm:lastName': 'lastName1',
|
||||
'cm:sizeCurrent': 0,
|
||||
'cm:email': 'test1@gmail.com',
|
||||
'cm:sizeQuota': 1073741824,
|
||||
'cm:firstName': 'firstName',
|
||||
'cm:owner': {
|
||||
id: 'test1',
|
||||
displayName: 'firstName lastName1'
|
||||
}
|
||||
},
|
||||
parentId: '3e9ce910-a4a0-4531-8f80-7734bece6342'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
aspectNames: ['cm:ownable'],
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 1.0
|
||||
},
|
||||
isFile: false,
|
||||
name: '3d1e9e57-505f-431e-bb2b-38ad8d5d2d15',
|
||||
location: 'nodes',
|
||||
id: '3d1e9e57-505f-431e-bb2b-38ad8d5d2d15',
|
||||
nodeType: 'cm:person',
|
||||
properties: {
|
||||
'cm:homeFolderProvider': 'userHomesHomeFolderProvider',
|
||||
'cm:authorizationStatus': 'NEVER_AUTHORIZED',
|
||||
'cm:homeFolder': '81a07ff0-82fb-4bbb-b869-d5fd92e71e17',
|
||||
'cm:userName': 'test11',
|
||||
'cm:lastName': 'lastName2',
|
||||
'cm:sizeCurrent': 0,
|
||||
'cm:email': 'test2@gmail.com',
|
||||
'cm:sizeQuota': -1,
|
||||
'cm:firstName': 'firstName',
|
||||
'cm:owner': {
|
||||
id: 'test11',
|
||||
displayName: 'firstName lastName2'
|
||||
}
|
||||
},
|
||||
parentId: '3e9ce910-a4a0-4531-8f80-7734bece6342'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
entry: {
|
||||
aspectNames: ['cm:ownable'],
|
||||
isFolder: false,
|
||||
search: {
|
||||
score: 1.0
|
||||
},
|
||||
isFile: false,
|
||||
name: '3d1e9e57-505f-431e-bb2b-38ad8d5d2d15',
|
||||
location: 'nodes',
|
||||
id: '3d1e9e57-505f-431e-bb2b-38ad8d5d2d15',
|
||||
nodeType: 'cm:person',
|
||||
properties: {
|
||||
'cm:homeFolderProvider': 'userHomesHomeFolderProvider',
|
||||
'cm:authorizationStatus': 'NEVER_AUTHORIZED',
|
||||
'cm:homeFolder': '81a07ff0-82fb-4bbb-b869-d5fd92e71e17',
|
||||
'cm:userName': 'test11',
|
||||
'cm:lastName': 'lastName2',
|
||||
'cm:sizeCurrent': 0,
|
||||
'cm:email': 'test2@gmail.com',
|
||||
'cm:sizeQuota': -1,
|
||||
'cm:firstName': 'firstName',
|
||||
'cm:owner': {
|
||||
id: 'test11',
|
||||
displayName: 'firstName lastName2'
|
||||
}
|
||||
},
|
||||
parentId: '3e9ce910-a4a0-4531-8f80-7734bece6342'
|
||||
}
|
||||
}]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
@ -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();
|
||||
|
@ -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,
|
||||
|
@ -27,10 +27,13 @@ export const fakeNodeWithCreatePermission = new Node({
|
||||
path: {
|
||||
name: '/Company Home/User Homes',
|
||||
isComplete: true,
|
||||
elements: [{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
}, { id: '55052317-7e59-4058-8e07-769f41e615e1', name: 'User Homes' }]
|
||||
elements: [
|
||||
{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
},
|
||||
{ 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: [{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
}, { id: '55052317-7e59-4058-8e07-769f41e615e1', name: 'User Homes' }]
|
||||
elements: [
|
||||
{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
},
|
||||
{ id: '55052317-7e59-4058-8e07-769f41e615e1', name: 'User Homes' }
|
||||
]
|
||||
},
|
||||
isFolder: true,
|
||||
modifiedByUser: { id: 'Test', displayName: 'Test' },
|
||||
@ -72,36 +78,41 @@ export const fakeNodeAnswerWithEntries = {
|
||||
skipCount: 10,
|
||||
maxItems: 10
|
||||
},
|
||||
entries: [{
|
||||
entry: {
|
||||
isFile: true,
|
||||
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
modifiedAt: '2017-05-24T15:08:55.640Z',
|
||||
nodeType: 'cm:content',
|
||||
content: {
|
||||
mimeType: 'application/rtf',
|
||||
mimeTypeName: 'Rich Text Format',
|
||||
sizeInBytes: 14530,
|
||||
encoding: 'UTF-8'
|
||||
},
|
||||
parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a',
|
||||
createdAt: '2017-05-24T15:08:55.640Z',
|
||||
path: {
|
||||
name: '/Company Home/Guest Home',
|
||||
isComplete: true,
|
||||
elements: [{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
|
||||
},
|
||||
isFolder: false,
|
||||
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
name: 'b_txt_file.rtf',
|
||||
id: '67b80f77-dbca-4f58-be6c-71b9dd61ea53',
|
||||
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' },
|
||||
allowableOperations: ['delete', 'update']
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
createdByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
modifiedAt: '2017-05-24T15:08:55.640Z',
|
||||
nodeType: 'cm:content',
|
||||
content: {
|
||||
mimeType: 'application/rtf',
|
||||
mimeTypeName: 'Rich Text Format',
|
||||
sizeInBytes: 14530,
|
||||
encoding: 'UTF-8'
|
||||
},
|
||||
parentId: 'd124de26-6ba0-4f40-8d98-4907da2d337a',
|
||||
createdAt: '2017-05-24T15:08:55.640Z',
|
||||
path: {
|
||||
name: '/Company Home/Guest Home',
|
||||
isComplete: true,
|
||||
elements: [
|
||||
{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
},
|
||||
{ id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }
|
||||
]
|
||||
},
|
||||
isFolder: false,
|
||||
modifiedByUser: { id: 'admin', displayName: 'Administrator' },
|
||||
name: 'b_txt_file.rtf',
|
||||
id: '67b80f77-dbca-4f58-be6c-71b9dd61ea53',
|
||||
properties: { 'cm:versionLabel': '1.0', 'cm:versionType': 'MAJOR' },
|
||||
allowableOperations: ['delete', 'update']
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -127,34 +138,38 @@ export const fakeGetSitesAnswer = {
|
||||
skipCount: 0,
|
||||
maxItems: 20
|
||||
},
|
||||
entries: [{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PRIVATE',
|
||||
guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b',
|
||||
id: 'admin-site',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Admin Site'
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PRIVATE',
|
||||
guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b',
|
||||
id: 'admin-site',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Admin Site'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'swsdp',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Sample: Web Site Design Project'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'af36cf8f-d43c-4a4b-84e6-d1b03e3a2ce5',
|
||||
id: 'test-site',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Test Site'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
entry: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'swsdp',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Sample: Web Site Design Project'
|
||||
}
|
||||
}, {
|
||||
entry: {
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'af36cf8f-d43c-4a4b-84e6-d1b03e3a2ce5',
|
||||
id: 'test-site',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Test Site'
|
||||
}
|
||||
}]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -167,30 +182,39 @@ export const fakeGetSiteMembership = {
|
||||
skipCount: 0,
|
||||
maxItems: 20
|
||||
},
|
||||
entries: [{
|
||||
entry: {
|
||||
site: {
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
site: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PRIVATE',
|
||||
guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b',
|
||||
id: 'admin-site',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Admin Site'
|
||||
},
|
||||
role: 'SiteManager',
|
||||
visibility: 'PRIVATE',
|
||||
guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b',
|
||||
id: 'admin-site',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Admin Site'
|
||||
}, role: 'SiteManager', guid: 'ac65fdbe-0c79-4f67-bd6a-b89a2768561b', id: 'admin-site'
|
||||
}
|
||||
}, {
|
||||
entry: {
|
||||
site: {
|
||||
id: 'admin-site'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
site: {
|
||||
role: 'SiteManager',
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'swsdp',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Sample: Web Site Design Project'
|
||||
},
|
||||
role: 'SiteManager',
|
||||
visibility: 'PUBLIC',
|
||||
guid: 'b4cff62a-664d-4d45-9302-98723eac1319',
|
||||
description: 'This is a Sample Alfresco Team site.',
|
||||
id: 'swsdp',
|
||||
preset: 'site-dashboard',
|
||||
title: 'Sample: Web Site Design Project'
|
||||
}, role: 'SiteManager', guid: 'b4cff62a-664d-4d45-9302-98723eac1319', id: 'swsdp'
|
||||
id: 'swsdp'
|
||||
}
|
||||
}
|
||||
}]
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
@ -202,17 +226,24 @@ export const fakeNodePaging: NodePaging = {
|
||||
totalItems: 5,
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
}, entries: [{
|
||||
entry: fakeNodeWithNoPermission
|
||||
}, {
|
||||
entry: fakeNodeWithNoPermission
|
||||
}, {
|
||||
entry: fakeNodeWithNoPermission
|
||||
}, {
|
||||
entry: fakeNodeWithNoPermission
|
||||
}, {
|
||||
entry: fakeNodeWithNoPermission
|
||||
}]
|
||||
},
|
||||
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: [{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
|
||||
elements: [
|
||||
{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company 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: [{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
|
||||
elements: [
|
||||
{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company 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: [{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
|
||||
elements: [
|
||||
{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company 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: [{
|
||||
entry: mockNode1
|
||||
}, {
|
||||
entry: mockNode2
|
||||
}, {
|
||||
entry: mockNode3
|
||||
}]
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
entry: mockNode1
|
||||
},
|
||||
{
|
||||
entry: mockNode2
|
||||
},
|
||||
{
|
||||
entry: mockNode3
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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: [{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company Home'
|
||||
}, { id: 'd124de26-6ba0-4f40-8d98-4907da2d337a', name: 'Guest Home' }]
|
||||
elements: [
|
||||
{
|
||||
id: '94acfc73-7014-4475-9bd9-93a2162f0f8c',
|
||||
name: 'Company 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: {
|
||||
|
@ -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,29 +629,23 @@ 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',
|
||||
filterQuery: 'content.size:5875',
|
||||
metrics: [
|
||||
{
|
||||
type: 'count',
|
||||
value: {
|
||||
count: 364
|
||||
}
|
||||
label: '5875',
|
||||
filterQuery: 'content.size:5875',
|
||||
metrics: [
|
||||
{
|
||||
type: 'count',
|
||||
value: {
|
||||
count: 364
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
/**
|
||||
|
@ -46,31 +46,33 @@ export const fakeContentComments = {
|
||||
skipCount: 0,
|
||||
maxItems: 100
|
||||
},
|
||||
entries: [{
|
||||
entry: {
|
||||
createdAt: '2018-03-27T10:55:45.725+0000',
|
||||
createdBy: fakeUser1,
|
||||
edited: false,
|
||||
modifiedAt: '2018-03-27T10:55:45.725+0000',
|
||||
canEdit: true,
|
||||
modifiedBy: fakeUser1,
|
||||
canDelete: true,
|
||||
id: '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7',
|
||||
content: 'fake-message-1'
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
createdAt: '2018-03-27T10:55:45.725+0000',
|
||||
createdBy: fakeUser1,
|
||||
edited: false,
|
||||
modifiedAt: '2018-03-27T10:55:45.725+0000',
|
||||
canEdit: true,
|
||||
modifiedBy: fakeUser1,
|
||||
canDelete: true,
|
||||
id: '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7',
|
||||
content: 'fake-message-1'
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
createdAt: '2018-03-27T10:55:45.725+0000',
|
||||
createdBy: fakeUser2,
|
||||
edited: false,
|
||||
modifiedAt: '2018-03-27T10:55:45.725+0000',
|
||||
canEdit: true,
|
||||
modifiedBy: fakeUser2,
|
||||
canDelete: true,
|
||||
id: '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7',
|
||||
content: 'fake-message-2'
|
||||
}
|
||||
}
|
||||
}, {
|
||||
entry: {
|
||||
createdAt: '2018-03-27T10:55:45.725+0000',
|
||||
createdBy: fakeUser2,
|
||||
edited: false,
|
||||
modifiedAt: '2018-03-27T10:55:45.725+0000',
|
||||
canEdit: true,
|
||||
modifiedBy: fakeUser2,
|
||||
canDelete: true,
|
||||
id: '35a0cea7-b6d0-4abc-9030-f4e461dd1ac7',
|
||||
content: 'fake-message-2'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
@ -146,62 +148,62 @@ export const getDateXMinutesAgo = (minutes: number) => new Date(new Date().getTi
|
||||
|
||||
export const commentsNodeData: CommentModel[] = [
|
||||
new CommentModel({
|
||||
id: 1,
|
||||
message: `I've done this component, is it cool?`,
|
||||
created: getDateXMinutesAgo(30),
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
id: 1,
|
||||
message: `I've done this component, is it cool?`,
|
||||
created: getDateXMinutesAgo(30),
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 2,
|
||||
message: 'Yeah',
|
||||
created: getDateXMinutesAgo(15),
|
||||
createdBy: new User(janeEod),
|
||||
isSelected: false
|
||||
id: 2,
|
||||
message: 'Yeah',
|
||||
created: getDateXMinutesAgo(15),
|
||||
createdBy: new User(janeEod),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 3,
|
||||
message: '+1',
|
||||
created: getDateXMinutesAgo(12),
|
||||
createdBy: new User(robertSmith),
|
||||
isSelected: false
|
||||
id: 3,
|
||||
message: '+1',
|
||||
created: getDateXMinutesAgo(12),
|
||||
createdBy: new User(robertSmith),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 4,
|
||||
message: 'ty',
|
||||
created: new Date(),
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
id: 4,
|
||||
message: 'ty',
|
||||
created: new Date(),
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
})
|
||||
];
|
||||
|
||||
export const commentsTaskData: CommentModel[] = [
|
||||
new CommentModel({
|
||||
id: 1,
|
||||
message: `I've done this task, what's next?`,
|
||||
created: getDateXMinutesAgo(30),
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
id: 1,
|
||||
message: `I've done this task, what's next?`,
|
||||
created: getDateXMinutesAgo(30),
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 2,
|
||||
message: `I've assigned you another one 🤠`,
|
||||
created: getDateXMinutesAgo(15),
|
||||
createdBy: new User(janeEod),
|
||||
isSelected: false
|
||||
id: 2,
|
||||
message: `I've assigned you another one 🤠`,
|
||||
created: getDateXMinutesAgo(15),
|
||||
createdBy: new User(janeEod),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 3,
|
||||
message: '+1',
|
||||
created: getDateXMinutesAgo(12),
|
||||
createdBy: new User(robertSmith),
|
||||
isSelected: false
|
||||
id: 3,
|
||||
message: '+1',
|
||||
created: getDateXMinutesAgo(12),
|
||||
createdBy: new User(robertSmith),
|
||||
isSelected: false
|
||||
}),
|
||||
new CommentModel({
|
||||
id: 4,
|
||||
message: 'Cheers',
|
||||
created: new Date(),
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
id: 4,
|
||||
message: 'Cheers',
|
||||
created: new Date(),
|
||||
createdBy: new User(johnDoe),
|
||||
isSelected: false
|
||||
})
|
||||
];
|
||||
|
@ -63,6 +63,10 @@
|
||||
margin-left: 12px;
|
||||
margin-right: 24px;
|
||||
}
|
||||
|
||||
.adf-toolbar--spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
}
|
||||
|
||||
&-permission-role-column-header {
|
||||
|
@ -33,7 +33,7 @@ import { AllowableOperationsEnum } from '../../../common/models/allowable-operat
|
||||
const SITE_MANAGER_ROLE = 'SiteManager';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class PermissionListService {
|
||||
updated = new EventEmitter<PermissionDisplayModel>();
|
||||
@ -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,26 +92,24 @@ 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(
|
||||
(nodeUpdated: Node) => {
|
||||
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);
|
||||
},
|
||||
() => {
|
||||
change.source.checked = this.node.permissions.isInheritanceEnabled;
|
||||
this.notificationService.showWarning('PERMISSION_MANAGER.MESSAGE.TOGGLE-PERMISSION-FAILED');
|
||||
}
|
||||
);
|
||||
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';
|
||||
this.notificationService.showInfo(message);
|
||||
nodeUpdated.permissions.inherited = nodeUpdated.permissions?.inherited ?? [];
|
||||
this.reloadNode(nodeUpdated);
|
||||
},
|
||||
() => {
|
||||
change.source.checked = this.node.permissions.isInheritanceEnabled;
|
||||
this.notificationService.showWarning('PERMISSION_MANAGER.MESSAGE.TOGGLE-PERMISSION-FAILED');
|
||||
}
|
||||
);
|
||||
} else {
|
||||
change.source.checked = this.node.permissions.isInheritanceEnabled;
|
||||
this.notificationService.showError('PERMISSION_MANAGER.ERROR.NOT-ALLOWED');
|
||||
@ -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,86 +130,86 @@ 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) => {
|
||||
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});
|
||||
this.reloadNode(node);
|
||||
},
|
||||
() => {
|
||||
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-DELETE-FAIL');
|
||||
this.reloadNode();
|
||||
}
|
||||
);
|
||||
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 });
|
||||
this.reloadNode(node);
|
||||
},
|
||||
() => {
|
||||
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-DELETE-FAIL');
|
||||
this.reloadNode();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
},
|
||||
() => {
|
||||
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-UPDATE-FAIL');
|
||||
this.reloadNode();
|
||||
this.errored.emit(permission);
|
||||
}
|
||||
);
|
||||
},
|
||||
() => {
|
||||
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-UPDATE-FAIL');
|
||||
this.reloadNode();
|
||||
this.errored.emit(permission);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
bulkRoleUpdate(role: string) {
|
||||
const permissions = [...this.node.permissions.locallySet].map((permission) => this.buildUpdatedPermission(role, permission));
|
||||
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});
|
||||
this.reloadNode(node);
|
||||
},
|
||||
() => {
|
||||
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-UPDATE-FAIL');
|
||||
this.reloadNode();
|
||||
}
|
||||
);
|
||||
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 });
|
||||
this.reloadNode(node);
|
||||
},
|
||||
() => {
|
||||
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-UPDATE-FAIL');
|
||||
this.reloadNode();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
deletePermission(permission: PermissionDisplayModel) {
|
||||
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 = [];
|
||||
}
|
||||
this.reloadNode(node);
|
||||
},
|
||||
() => {
|
||||
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-DELETE-FAIL');
|
||||
this.reloadNode();
|
||||
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 = [];
|
||||
}
|
||||
);
|
||||
this.reloadNode(node);
|
||||
},
|
||||
() => {
|
||||
this.notificationService.showError('PERMISSION_MANAGER.MESSAGE.PERMISSION-DELETE-FAIL');
|
||||
this.reloadNode();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private buildUpdatedPermission(role: string, permission: PermissionElement): PermissionElement {
|
||||
return {
|
||||
accessStatus: permission.accessStatus,
|
||||
name: this.canUpdateThePermission(this.node, permission) ? role : permission.name,
|
||||
name: this.canUpdateThePermission(this.node, permission) ? role : permission.name,
|
||||
authorityId: permission.authorityId
|
||||
};
|
||||
}
|
||||
@ -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) {
|
||||
@ -249,8 +250,8 @@ export class PermissionListService {
|
||||
canUpdateThePermission(node: Node, permission: PermissionElement): boolean {
|
||||
const sitePath = node.path.elements.find((path) => path.nodeType === 'st:site');
|
||||
if (!node.permissions.isInheritanceEnabled && sitePath) {
|
||||
const authorityId = `GROUP_site_${sitePath.name}_${SITE_MANAGER_ROLE}`;
|
||||
return !(permission.authorityId === authorityId && permission.name === SITE_MANAGER_ROLE);
|
||||
const authorityId = `GROUP_site_${sitePath.name}_${SITE_MANAGER_ROLE}`;
|
||||
return !(permission.authorityId === authorityId && permission.name === SITE_MANAGER_ROLE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -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)
|
||||
return this.nodePermissionService
|
||||
.getNodeWithRoles(nodeId)
|
||||
.pipe(
|
||||
switchMap(({node, roles}) => this.openAddPermissionDialog(node, roles, title)
|
||||
.pipe(
|
||||
switchMap(({ node, roles }) =>
|
||||
this.openAddPermissionDialog(node, roles, title).pipe(
|
||||
switchMap((selection) => this.nodePermissionService.updateNodePermissions(nodeId, selection))
|
||||
))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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';
|
||||
|
@ -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.
|
||||
|
@ -1,3 +1,3 @@
|
||||
<div class="adf-empty-search-result">
|
||||
<ng-content></ng-content>
|
||||
<ng-content />
|
||||
</div>
|
||||
|
@ -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>
|
||||
|
@ -15,5 +15,5 @@
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
<ng-content></ng-content>
|
||||
<ng-content />
|
||||
</mat-chip-set>
|
||||
|
@ -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>
|
||||
|
@ -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) {
|
||||
|
@ -2,6 +2,5 @@
|
||||
[ngClass]="_classList" #panel>
|
||||
<ng-template
|
||||
[ngTemplateOutlet]="template"
|
||||
[ngTemplateOutletContext]="{ $implicit: results }">
|
||||
</ng-template>
|
||||
[ngTemplateOutletContext]="{ $implicit: results }" />
|
||||
</div>
|
||||
|
@ -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 : {
|
||||
hasMinAlphanumericChars: false
|
||||
};
|
||||
return (control: UntypedFormControl) =>
|
||||
('' + control.value).replace(/[^0-9a-zA-Z]+/g, '').length >= minChars
|
||||
? null
|
||||
: {
|
||||
hasMinAlphanumericChars: false
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -35,101 +35,111 @@ 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', () => {
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
|
||||
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
|
||||
};
|
||||
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 = [];
|
||||
builder.categories = [];
|
||||
builder.filterQueries = [];
|
||||
|
||||
expect(builder.categories.length).toBe(0);
|
||||
expect(builder.filterQueries.length).toBe(0);
|
||||
expect(builder.categories.length).toBe(0);
|
||||
expect(builder.filterQueries.length).toBe(0);
|
||||
|
||||
builder.resetToDefaults();
|
||||
builder.resetToDefaults();
|
||||
|
||||
expect(builder.categories.length).toBe(2);
|
||||
expect(builder.filterQueries.length).toBe(2);
|
||||
expect(builder.categories.length).toBe(2);
|
||||
expect(builder.filterQueries.length).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return the category assigned to a column key', () => {
|
||||
const config: SearchConfiguration = {
|
||||
categories: [
|
||||
{ id: 'cat1', columnKey: 'fake-key-1', enabled: true } as any,
|
||||
{ id: 'cat2', columnKey: 'fake-key-2', enabled: true } as any
|
||||
],
|
||||
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
|
||||
};
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const config: SearchConfiguration = {
|
||||
categories: [
|
||||
{ id: 'cat1', columnKey: 'fake-key-1', enabled: true } as any,
|
||||
{ id: 'cat2', columnKey: 'fake-key-2', enabled: true } as any
|
||||
],
|
||||
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');
|
||||
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({});
|
||||
expect(builder.userQuery).toBe('');
|
||||
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', () => {
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
|
||||
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
|
||||
};
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
|
||||
filterQueries: [{ query: 'query1' }, { query: 'query2' }]
|
||||
};
|
||||
|
||||
const expectedResult = [{ query: 'PARENT:"workspace://SpacesStore/fake-node-id"' }];
|
||||
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');
|
||||
searchHeaderService.setCurrentRootFolderId('fake-node-id');
|
||||
|
||||
expect(searchHeaderService.filterQueries).toEqual(expectedResult, 'Filters are not as expected');
|
||||
expect(searchHeaderService.filterQueries).toEqual(expectedResult, 'Filters are not as expected');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not add again the parent filter if that node is already added', () => {
|
||||
const expectedResult = [{ query: 'PARENT:"workspace://SpacesStore/fake-node-id"' }];
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const expectedResult = [{ query: 'PARENT:"workspace://SpacesStore/fake-node-id"' }];
|
||||
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
|
||||
filterQueries: expectedResult
|
||||
};
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any, { id: 'cat2', enabled: true } as any],
|
||||
filterQueries: expectedResult
|
||||
};
|
||||
|
||||
const searchHeaderService = createQueryBuilder(config);
|
||||
searchHeaderService.setCurrentRootFolderId('fake-node-id');
|
||||
const alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
const searchHeaderService = new SearchHeaderQueryBuilderService(buildConfig(config), alfrescoApiService, null);
|
||||
|
||||
expect(searchHeaderService.filterQueries).toEqual(expectedResult, 'Filters are not as expected');
|
||||
searchHeaderService.setCurrentRootFolderId('fake-node-id');
|
||||
|
||||
expect(searchHeaderService.filterQueries).toEqual(expectedResult, 'Filters are not as expected');
|
||||
});
|
||||
});
|
||||
|
||||
it('should not add duplicate column names in activeFilters', () => {
|
||||
const activeFilter = 'FakeColumn';
|
||||
TestBed.runInInjectionContext(() => {
|
||||
const activeFilter = 'FakeColumn';
|
||||
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any],
|
||||
filterQueries: [{ query: 'PARENT:"workspace://SpacesStore/fake-node-id' }]
|
||||
};
|
||||
const config: SearchConfiguration = {
|
||||
categories: [{ id: 'cat1', enabled: true } as any],
|
||||
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);
|
||||
expect(searchHeaderService.activeFilters.length).toBe(0);
|
||||
|
||||
searchHeaderService.setActiveFilter(activeFilter, 'fake-value');
|
||||
searchHeaderService.setActiveFilter(activeFilter, 'fake-value');
|
||||
searchHeaderService.setActiveFilter(activeFilter, 'fake-value');
|
||||
searchHeaderService.setActiveFilter(activeFilter, 'fake-value');
|
||||
|
||||
expect(searchHeaderService.activeFilters.length).toBe(1);
|
||||
expect(searchHeaderService.activeFilters.length).toBe(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -23,10 +23,10 @@ import { TreeService } from '../services/tree.service';
|
||||
import { treeNodesMockExpanded } from './tree-node.mock';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class TreeServiceMock extends TreeService<TreeNode> {
|
||||
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();
|
||||
}
|
||||
|
@ -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, {
|
||||
comment: this.comment,
|
||||
majorVersion: this.majorVersion,
|
||||
newVersion: this.versioning,
|
||||
parentId,
|
||||
path,
|
||||
nodeType: this.nodeType
|
||||
}, id);
|
||||
return new FileModel(
|
||||
file,
|
||||
{
|
||||
comment: this.comment,
|
||||
majorVersion: this.majorVersion,
|
||||
newVersion: this.versioning,
|
||||
parentId,
|
||||
path,
|
||||
nodeType: this.nodeType
|
||||
},
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,5 @@
|
||||
<ng-template
|
||||
ngFor
|
||||
[ngForOf]="files"
|
||||
[ngForTemplate]="template">
|
||||
</ng-template>
|
||||
[ngForTemplate]="template" />
|
||||
</div>
|
||||
|
@ -3,5 +3,5 @@
|
||||
(folderEntityDropped)="onFolderEntityDropped($event)"
|
||||
(upload-files)="onUploadFiles($any($event))"
|
||||
dropzone="" webkitdropzone="*" #droparea>
|
||||
<ng-content></ng-content>
|
||||
<ng-content />
|
||||
</div>
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -14,5 +14,6 @@
|
||||
},
|
||||
"target": "ES2022",
|
||||
"useDefineForClassFields": false
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.ts", "index.ts"]
|
||||
}
|
||||
|
@ -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"]
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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']);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -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) {
|
||||
|
@ -17,6 +17,6 @@
|
||||
|
||||
export interface Dictionary<T> {
|
||||
[key: string]: T;
|
||||
};
|
||||
}
|
||||
|
||||
export type Constructor<T> = new (...args: any[]) => T;
|
||||
|
@ -22,46 +22,47 @@ import { Authentication } from '../authentication';
|
||||
import { AuthenticationInterceptor, SHOULD_ADD_AUTH_TOKEN } from './authentication.interceptor';
|
||||
|
||||
class MockAuthentication extends Authentication {
|
||||
addTokenToHeader(_: string, httpHeaders: HttpHeaders): Observable<HttpHeaders> {
|
||||
return of(httpHeaders);
|
||||
}
|
||||
addTokenToHeader(_: string, httpHeaders: HttpHeaders): Observable<HttpHeaders> {
|
||||
return of(httpHeaders);
|
||||
}
|
||||
}
|
||||
|
||||
const mockNext: HttpHandler = {
|
||||
handle: () => new Observable(subscriber => {
|
||||
subscriber.complete();
|
||||
})
|
||||
handle: () =>
|
||||
new Observable((subscriber) => {
|
||||
subscriber.complete();
|
||||
})
|
||||
};
|
||||
|
||||
const request = new HttpRequest('GET', 'http://localhost:4200');
|
||||
|
||||
describe('AuthenticationInterceptor', () => {
|
||||
let interceptor: AuthenticationInterceptor;
|
||||
let addTokenToHeaderSpy: jasmine.Spy<any>;
|
||||
let interceptor: AuthenticationInterceptor;
|
||||
let addTokenToHeaderSpy: jasmine.Spy<any>;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AuthenticationInterceptor, {provide: Authentication, useClass: MockAuthentication}]
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [AuthenticationInterceptor, { provide: Authentication, useClass: MockAuthentication }]
|
||||
});
|
||||
interceptor = TestBed.inject(AuthenticationInterceptor);
|
||||
addTokenToHeaderSpy = spyOn(interceptor['authService'], 'addTokenToHeader');
|
||||
});
|
||||
interceptor = TestBed.inject(AuthenticationInterceptor);
|
||||
addTokenToHeaderSpy = spyOn(interceptor['authService'], 'addTokenToHeader');
|
||||
});
|
||||
|
||||
it('should call add auth token method when SHOULD_ADD_AUTH_TOKEN context is set to true', () => {
|
||||
addTokenToHeaderSpy.and.callThrough();
|
||||
request.context.set(SHOULD_ADD_AUTH_TOKEN, true);
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).toHaveBeenCalled();
|
||||
});
|
||||
it('should call add auth token method when SHOULD_ADD_AUTH_TOKEN context is set to true', () => {
|
||||
addTokenToHeaderSpy.and.callThrough();
|
||||
request.context.set(SHOULD_ADD_AUTH_TOKEN, true);
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call add auth token method when SHOULD_ADD_AUTH_TOKEN context is set to false', () => {
|
||||
request.context.set(SHOULD_ADD_AUTH_TOKEN, false);
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
it('should not call add auth token method when SHOULD_ADD_AUTH_TOKEN context is set to false', () => {
|
||||
request.context.set(SHOULD_ADD_AUTH_TOKEN, false);
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not call add auth token method when SHOULD_ADD_AUTH_TOKEN context is not provided', () => {
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
it('should not call add auth token method when SHOULD_ADD_AUTH_TOKEN context is not provided', () => {
|
||||
interceptor.intercept(request, mockNext);
|
||||
expect(addTokenToHeaderSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -36,42 +36,37 @@ 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>> {
|
||||
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)));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
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))
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return next.handle(req).pipe(catchError((error) => observableThrowError(error)));
|
||||
return next.handle(req).pipe(catchError((error) => observableThrowError(error)));
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
// 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
|
||||
if (headers.get('Content-Type') === 'multipart/form-data') {
|
||||
return headers.delete('Content-Type');
|
||||
}
|
||||
|
||||
if (headers.get('Content-Type') === 'multipart/form-data') {
|
||||
return headers.delete('Content-Type');
|
||||
}
|
||||
if (!headers.get('Content-Type')) {
|
||||
return headers.set('Content-Type', 'application/json;charset=UTF-8');
|
||||
}
|
||||
|
||||
if (!headers.get('Content-Type')) {
|
||||
return headers.set('Content-Type', 'application/json;charset=UTF-8');
|
||||
}
|
||||
|
||||
return headers;
|
||||
return headers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -15,11 +15,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {Component} from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-demo-breadcrumb',
|
||||
template: `
|
||||
selector: 'adf-demo-breadcrumb',
|
||||
template: `
|
||||
<adf-breadcrumb [compact]="compact">
|
||||
<adf-breadcrumb-item>
|
||||
<a href="/">Home</a>
|
||||
@ -58,6 +58,6 @@ import {Component} from '@angular/core';
|
||||
`
|
||||
})
|
||||
export class DemoBreadcrumbComponent {
|
||||
compact = false;
|
||||
showBreadcrumbItemWithMenu = false;
|
||||
compact = false;
|
||||
showBreadcrumbItemWithMenu = false;
|
||||
}
|
||||
|
@ -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>
|
||||
`
|
||||
})
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import { Observable } from 'rxjs';
|
||||
export const isFeatureOff = (flag: string) => () => inject(FeaturesServiceToken).isOff$(flag);
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class IsFeatureOff {
|
||||
export class IsFeatureOff {
|
||||
constructor(@Inject(FeaturesServiceToken) private featuresServiceToken: IFeaturesService) {}
|
||||
|
||||
canMatch(route: Route): Observable<boolean> {
|
||||
|
@ -23,7 +23,7 @@ import { Observable } from 'rxjs';
|
||||
export const isFeatureOn = (flag: string) => () => inject(FeaturesServiceToken).isOn$(flag);
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class IsFeatureOn {
|
||||
export class IsFeatureOn {
|
||||
constructor(@Inject(FeaturesServiceToken) private featuresServiceToken: IFeaturesService) {}
|
||||
|
||||
canMatch(route: Route): Observable<boolean> {
|
||||
|
@ -18,11 +18,10 @@
|
||||
import { Inject, Injectable, Optional, inject } from '@angular/core';
|
||||
import { FlagsOverrideToken } from '../interfaces/features.interface';
|
||||
|
||||
|
||||
export const isFlagsOverrideOn = () => () => inject(FlagsOverrideToken) ?? false;
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class IsFlagsOverrideOn {
|
||||
export class IsFlagsOverrideOn {
|
||||
constructor(@Optional() @Inject(FlagsOverrideToken) private devToolsToken: boolean) {}
|
||||
|
||||
canMatch(): boolean {
|
||||
|
@ -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",
|
||||
|
@ -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"]
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ import { ShellLayoutComponent } from './components/shell/shell.component';
|
||||
import { SHELL_AUTH_TOKEN } from './services/shell-app.service';
|
||||
|
||||
export const SHELL_LAYOUT_ROUTE: Route = {
|
||||
path: '',
|
||||
component: ShellLayoutComponent,
|
||||
canActivate: [SHELL_AUTH_TOKEN],
|
||||
children: []
|
||||
path: '',
|
||||
component: ShellLayoutComponent,
|
||||
canActivate: [SHELL_AUTH_TOKEN],
|
||||
children: []
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
@ -23,9 +23,10 @@ import { AuthenticationService } from '../services/authentication.service';
|
||||
import { RedirectAuthService } from '../oidc/redirect-auth.service';
|
||||
|
||||
const mockNext: HttpHandler = {
|
||||
handle: () => new Observable(subscriber => {
|
||||
subscriber.complete();
|
||||
})
|
||||
handle: () =>
|
||||
new Observable((subscriber) => {
|
||||
subscriber.complete();
|
||||
})
|
||||
};
|
||||
|
||||
const mockRequest = (url) => new HttpRequest('GET', url);
|
||||
|
@ -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,61 +37,52 @@ 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>> {
|
||||
|
||||
|
||||
if (!this.excludedUrlsRegex) {
|
||||
this.loadExcludedUrlsRegex();
|
||||
private loadExcludedUrlsRegex() {
|
||||
const excludedUrls = this.bearerExcludedUrls;
|
||||
this.excludedUrlsRegex = excludedUrls.map((urlPattern) => new RegExp(`^https?://[^/]+/${urlPattern}`, 'i')) || [];
|
||||
}
|
||||
|
||||
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))
|
||||
intercept(
|
||||
req: HttpRequest<any>,
|
||||
next: HttpHandler
|
||||
): Observable<HttpSentEvent | HttpHeaderResponse | HttpProgressEvent | HttpResponse<any> | HttpUserEvent<any>> {
|
||||
if (!this.excludedUrlsRegex) {
|
||||
this.loadExcludedUrlsRegex();
|
||||
}
|
||||
|
||||
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 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)));
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
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))
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
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
|
||||
|
||||
private appendJsonContentType(headers: HttpHeaders, reqBody: any): HttpHeaders {
|
||||
if (headers.get('Content-Type') === 'multipart/form-data' && !(reqBody instanceof FormData)) {
|
||||
return headers.delete('Content-Type');
|
||||
}
|
||||
|
||||
// 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
|
||||
if (!headers.get('Content-Type') && !(reqBody instanceof FormData)) {
|
||||
return headers.set('Content-Type', 'application/json;charset=UTF-8');
|
||||
}
|
||||
|
||||
if (headers.get('Content-Type') === 'multipart/form-data' && !(reqBody instanceof FormData)) {
|
||||
return headers.delete('Content-Type');
|
||||
return headers;
|
||||
}
|
||||
|
||||
if (!headers.get('Content-Type') && !(reqBody instanceof FormData)) {
|
||||
return headers.set('Content-Type', 'application/json;charset=UTF-8');
|
||||
}
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
protected get bearerExcludedUrls(): readonly string[] {
|
||||
return this._bearerExcludedUrls;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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-');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user