mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
Revert changes from dev-durse-ADF-5378-integration (#2112)
* revert changes from dev-durse-ADF-5378-integration * remove comma
This commit is contained in:
@@ -28,8 +28,7 @@ import { Action } from '@ngrx/store';
|
|||||||
export enum UploadActionTypes {
|
export enum UploadActionTypes {
|
||||||
UploadFiles = 'UPLOAD_FILES',
|
UploadFiles = 'UPLOAD_FILES',
|
||||||
UploadFolder = 'UPLOAD_FOLDER',
|
UploadFolder = 'UPLOAD_FOLDER',
|
||||||
UploadFileVersion = 'UPLOAD_FILE_VERSION',
|
UploadFileVersion = 'UPLOAD_FILE_VERSION'
|
||||||
UploadImage = 'UPLOAD_IMAGE'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UploadFilesAction implements Action {
|
export class UploadFilesAction implements Action {
|
||||||
@@ -44,12 +43,6 @@ export class UploadFolderAction implements Action {
|
|||||||
constructor(public payload: any) {}
|
constructor(public payload: any) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UploadNewImageAction implements Action {
|
|
||||||
readonly type = UploadActionTypes.UploadImage;
|
|
||||||
|
|
||||||
constructor(public payload: any) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class UploadFileVersionAction implements Action {
|
export class UploadFileVersionAction implements Action {
|
||||||
readonly type = UploadActionTypes.UploadFileVersion;
|
readonly type = UploadActionTypes.UploadFileVersion;
|
||||||
|
|
||||||
|
@@ -19,8 +19,6 @@
|
|||||||
adf-file-uploading-dialog {
|
adf-file-uploading-dialog {
|
||||||
z-index: 1100;
|
z-index: 1100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 599px) {
|
@media screen and (max-width: 599px) {
|
||||||
|
@@ -14,8 +14,6 @@
|
|||||||
[allowDownload]="false"
|
[allowDownload]="false"
|
||||||
[allowFullScreen]="false"
|
[allowFullScreen]="false"
|
||||||
[overlayMode]="true"
|
[overlayMode]="true"
|
||||||
[readOnly]="!canUpdateNode"
|
|
||||||
(fileSubmit)="onFileSubmit($event)"
|
|
||||||
(showViewerChange)="onViewerVisibilityChanged()"
|
(showViewerChange)="onViewerVisibilityChanged()"
|
||||||
[canNavigateBefore]="previousNodeId"
|
[canNavigateBefore]="previousNodeId"
|
||||||
[canNavigateNext]="nextNodeId"
|
[canNavigateNext]="nextNodeId"
|
||||||
|
@@ -33,7 +33,6 @@ import {
|
|||||||
ReloadDocumentListAction,
|
ReloadDocumentListAction,
|
||||||
SetCurrentNodeVersionAction,
|
SetCurrentNodeVersionAction,
|
||||||
SetSelectedNodesAction,
|
SetSelectedNodesAction,
|
||||||
UploadNewImageAction,
|
|
||||||
ViewerActionTypes,
|
ViewerActionTypes,
|
||||||
ViewNodeAction
|
ViewNodeAction
|
||||||
} from '@alfresco/aca-shared/store';
|
} from '@alfresco/aca-shared/store';
|
||||||
@@ -46,7 +45,6 @@ import { Store } from '@ngrx/store';
|
|||||||
import { from, Observable, Subject } from 'rxjs';
|
import { from, Observable, Subject } from 'rxjs';
|
||||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||||
import { Actions, ofType } from '@ngrx/effects';
|
import { Actions, ofType } from '@ngrx/effects';
|
||||||
import { ContentManagementService } from '../../services/content-management.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-viewer',
|
selector: 'app-viewer',
|
||||||
@@ -66,7 +64,6 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
|||||||
selection: SelectionState;
|
selection: SelectionState;
|
||||||
infoDrawerOpened$: Observable<boolean>;
|
infoDrawerOpened$: Observable<boolean>;
|
||||||
|
|
||||||
canUpdateNode = false;
|
|
||||||
showRightSide = false;
|
showRightSide = false;
|
||||||
openWith: ContentActionRef[] = [];
|
openWith: ContentActionRef[] = [];
|
||||||
toolbarActions: ContentActionRef[] = [];
|
toolbarActions: ContentActionRef[] = [];
|
||||||
@@ -115,8 +112,7 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
|||||||
private preferences: UserPreferencesService,
|
private preferences: UserPreferencesService,
|
||||||
private apiService: AlfrescoApiService,
|
private apiService: AlfrescoApiService,
|
||||||
private uploadService: UploadService,
|
private uploadService: UploadService,
|
||||||
private appHookService: AppHookService,
|
private appHookService: AppHookService
|
||||||
private content: ContentManagementService
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
@@ -212,7 +208,6 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
|||||||
if (nodeId) {
|
if (nodeId) {
|
||||||
try {
|
try {
|
||||||
this.node = await this.contentApi.getNodeInfo(nodeId).toPromise();
|
this.node = await this.contentApi.getNodeInfo(nodeId).toPromise();
|
||||||
this.canUpdateNode = this.content.canUpdateNode(this.node);
|
|
||||||
this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }]));
|
this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }]));
|
||||||
this.navigateMultiple = this.extensions.canShowViewerNavigation({ entry: this.node });
|
this.navigateMultiple = this.extensions.canShowViewerNavigation({ entry: this.node });
|
||||||
if (!this.navigateMultiple) {
|
if (!this.navigateMultiple) {
|
||||||
@@ -259,11 +254,6 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
|||||||
this.store.dispatch(new ViewNodeAction(this.nextNodeId, { location }));
|
this.store.dispatch(new ViewNodeAction(this.nextNodeId, { location }));
|
||||||
}
|
}
|
||||||
|
|
||||||
onFileSubmit(newBlob: Blob) {
|
|
||||||
const newImageFile: File = new File([newBlob], this?.node?.name, { type: this?.node?.content?.mimeType });
|
|
||||||
this.store.dispatch(new UploadNewImageAction(newImageFile));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves nearest node information for the given node and folder.
|
* Retrieves nearest node information for the given node and folder.
|
||||||
* @param nodeId Unique identifier of the document node
|
* @param nodeId Unique identifier of the document node
|
||||||
|
@@ -25,23 +25,13 @@
|
|||||||
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TestBed } from '@angular/core/testing';
|
import { TestBed } from '@angular/core/testing';
|
||||||
import { Actions, EffectsModule } from '@ngrx/effects';
|
import { EffectsModule } from '@ngrx/effects';
|
||||||
import { UploadEffects } from './upload.effects';
|
import { UploadEffects } from './upload.effects';
|
||||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
import { NgZone } from '@angular/core';
|
import { NgZone } from '@angular/core';
|
||||||
import { UploadService, FileUploadCompleteEvent, FileModel } from '@alfresco/adf-core';
|
import { UploadService, FileUploadCompleteEvent, FileModel } from '@alfresco/adf-core';
|
||||||
import {
|
import { UnlockWriteAction, UploadFileVersionAction } from '@alfresco/aca-shared/store';
|
||||||
SnackbarErrorAction,
|
|
||||||
SnackbarInfoAction,
|
|
||||||
UnlockWriteAction,
|
|
||||||
UploadFileVersionAction,
|
|
||||||
UploadNewImageAction
|
|
||||||
} from '@alfresco/aca-shared/store';
|
|
||||||
import { ContentManagementService } from '../../services/content-management.service';
|
import { ContentManagementService } from '../../services/content-management.service';
|
||||||
import { Observable, of, throwError } from 'rxjs';
|
|
||||||
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
|
|
||||||
import { cold, hot } from 'jasmine-marbles';
|
|
||||||
import { provideMockActions } from '@ngrx/effects/testing';
|
|
||||||
|
|
||||||
describe('UploadEffects', () => {
|
describe('UploadEffects', () => {
|
||||||
let store: Store<any>;
|
let store: Store<any>;
|
||||||
@@ -49,35 +39,10 @@ describe('UploadEffects', () => {
|
|||||||
let effects: UploadEffects;
|
let effects: UploadEffects;
|
||||||
let zone: NgZone;
|
let zone: NgZone;
|
||||||
let contentManagementService: ContentManagementService;
|
let contentManagementService: ContentManagementService;
|
||||||
let actions$: Observable<any> = of();
|
|
||||||
const fakeNode: MinimalNodeEntryEntity = {
|
|
||||||
createdAt: undefined,
|
|
||||||
modifiedAt: undefined,
|
|
||||||
modifiedByUser: undefined,
|
|
||||||
isFile: true,
|
|
||||||
createdByUser: {
|
|
||||||
id: 'admin.adf@alfresco.com',
|
|
||||||
displayName: 'Administrator'
|
|
||||||
},
|
|
||||||
nodeType: 'cm:content',
|
|
||||||
content: {
|
|
||||||
mimeType: 'image/jpeg',
|
|
||||||
mimeTypeName: 'JPEG Image',
|
|
||||||
sizeInBytes: 175540,
|
|
||||||
encoding: 'UTF-8'
|
|
||||||
},
|
|
||||||
parentId: 'dff2bc1e-d092-42ac-82d1-87c82f6e56cb',
|
|
||||||
isFolder: false,
|
|
||||||
name: 'GoqZhm.jpg',
|
|
||||||
id: '1bf8a8f7-18ac-4eef-919d-61d952eaa179',
|
|
||||||
allowableOperations: ['delete', 'update', 'updatePermissions'],
|
|
||||||
isFavorite: false
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [AppTestingModule, EffectsModule.forRoot([UploadEffects])],
|
imports: [AppTestingModule, EffectsModule.forRoot([UploadEffects])]
|
||||||
providers: [provideMockActions(() => actions$)]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
zone = TestBed.inject(NgZone);
|
zone = TestBed.inject(NgZone);
|
||||||
@@ -91,6 +56,11 @@ describe('UploadEffects', () => {
|
|||||||
effects = TestBed.inject(UploadEffects);
|
effects = TestBed.inject(UploadEffects);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(effects['fileVersionInput'], 'click');
|
||||||
|
spyOn(effects, 'uploadVersion').and.callThrough();
|
||||||
|
});
|
||||||
|
|
||||||
describe('uploadAndUnlock()', () => {
|
describe('uploadAndUnlock()', () => {
|
||||||
it('should not upload and unlock file if param not provided', () => {
|
it('should not upload and unlock file if param not provided', () => {
|
||||||
effects.uploadAndUnlock(null);
|
effects.uploadAndUnlock(null);
|
||||||
@@ -181,17 +151,8 @@ describe('UploadEffects', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('upload file version', () => {
|
describe('upload file version', () => {
|
||||||
beforeEach(() => {
|
|
||||||
actions$ = TestBed.inject(Actions);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should trigger upload file from context menu', () => {
|
it('should trigger upload file from context menu', () => {
|
||||||
spyOn(effects['fileVersionInput'], 'click');
|
store.dispatch({ type: 'UPLOAD_FILE_VERSION' });
|
||||||
actions$ = hot('a', {
|
|
||||||
a: new UploadFileVersionAction(undefined)
|
|
||||||
});
|
|
||||||
const expected = cold('b', {});
|
|
||||||
expect(effects.uploadVersion$).toBeObservable(expected);
|
|
||||||
expect(effects['fileVersionInput'].click).toHaveBeenCalled();
|
expect(effects['fileVersionInput'].click).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -245,50 +206,9 @@ describe('UploadEffects', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
actions$ = hot('a', {
|
store.dispatch(new UploadFileVersionAction(fakeEvent));
|
||||||
a: new UploadFileVersionAction(fakeEvent)
|
|
||||||
});
|
|
||||||
|
|
||||||
const expected = cold('b', {});
|
|
||||||
expect(effects.uploadVersion$).toBeObservable(expected);
|
|
||||||
|
|
||||||
expect(contentManagementService.versionUpdateDialog).toHaveBeenCalledWith(fakeEvent.detail.data.node.entry, fakeEvent.detail.files[0].file);
|
expect(contentManagementService.versionUpdateDialog).toHaveBeenCalledWith(fakeEvent.detail.data.node.entry, fakeEvent.detail.files[0].file);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('image versioning', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
actions$ = TestBed.inject(Actions);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should trigger upload file version from viewer', () => {
|
|
||||||
spyOn(contentManagementService, 'getNodeInfo').and.returnValue(of(fakeNode));
|
|
||||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
|
||||||
const fakeBlob = new Blob([data], { type: 'image/png' });
|
|
||||||
const newImageFile: File = new File([fakeBlob], 'GoqZhm.jpg');
|
|
||||||
actions$ = hot('a', {
|
|
||||||
a: new UploadNewImageAction(newImageFile)
|
|
||||||
});
|
|
||||||
|
|
||||||
const expected = cold('b', {
|
|
||||||
b: new SnackbarInfoAction('APP.MESSAGES.UPLOAD.SUCCESS.MEDIA_MANAGEMENT')
|
|
||||||
});
|
|
||||||
expect(effects.uploadNewImage$).toBeObservable(expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should display snackbar if can`t retrieve node details', () => {
|
|
||||||
spyOn(contentManagementService, 'getNodeInfo').and.returnValue(throwError(fakeNode));
|
|
||||||
const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==');
|
|
||||||
const fakeBlob = new Blob([data], { type: 'image/png' });
|
|
||||||
const newImageFile: File = new File([fakeBlob], 'GoqZhm.jpg');
|
|
||||||
actions$ = hot('a', {
|
|
||||||
a: new UploadNewImageAction(newImageFile)
|
|
||||||
});
|
|
||||||
|
|
||||||
const expected = cold('b', {
|
|
||||||
b: new SnackbarErrorAction('APP.MESSAGES.UPLOAD.ERROR.GENERIC')
|
|
||||||
});
|
|
||||||
expect(effects.uploadNewImage$).toBeObservable(expected);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@@ -31,16 +31,14 @@ import {
|
|||||||
UploadFilesAction,
|
UploadFilesAction,
|
||||||
UploadFileVersionAction,
|
UploadFileVersionAction,
|
||||||
UploadFolderAction,
|
UploadFolderAction,
|
||||||
getCurrentFolder,
|
getCurrentFolder
|
||||||
UploadNewImageAction,
|
|
||||||
SnackbarInfoAction
|
|
||||||
} from '@alfresco/aca-shared/store';
|
} from '@alfresco/aca-shared/store';
|
||||||
import { FileModel, FileUtils, UploadService } from '@alfresco/adf-core';
|
import { FileModel, FileUtils, UploadService } from '@alfresco/adf-core';
|
||||||
import { Injectable, NgZone, RendererFactory2 } from '@angular/core';
|
import { Injectable, NgZone, RendererFactory2 } from '@angular/core';
|
||||||
import { Actions, Effect, ofType } from '@ngrx/effects';
|
import { Actions, Effect, ofType } from '@ngrx/effects';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { catchError, map, mergeMap, switchMap, take } from 'rxjs/operators';
|
import { catchError, map, take } from 'rxjs/operators';
|
||||||
import { ContentManagementService } from '../../services/content-management.service';
|
import { ContentManagementService } from '../../services/content-management.service';
|
||||||
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
|
import { MinimalNodeEntryEntity } from '@alfresco/js-api';
|
||||||
|
|
||||||
@@ -103,47 +101,17 @@ export class UploadEffects {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
|
||||||
uploadNewImage$ = this.actions$.pipe(
|
|
||||||
ofType<UploadNewImageAction>(UploadActionTypes.UploadImage),
|
|
||||||
switchMap((action) => {
|
|
||||||
return this.contentService.getNodeInfo().pipe(
|
|
||||||
mergeMap((node) => {
|
|
||||||
if (node?.id) {
|
|
||||||
const newFile = new FileModel(
|
|
||||||
action?.payload,
|
|
||||||
{
|
|
||||||
majorVersion: false,
|
|
||||||
newVersion: true,
|
|
||||||
parentId: node?.parentId,
|
|
||||||
nodeType: node?.content?.mimeType
|
|
||||||
},
|
|
||||||
node?.id
|
|
||||||
);
|
|
||||||
this.uploadQueue([newFile]);
|
|
||||||
return of(new SnackbarInfoAction('APP.MESSAGES.UPLOAD.SUCCESS.MEDIA_MANAGEMENT'));
|
|
||||||
}
|
|
||||||
return of(null);
|
|
||||||
}),
|
|
||||||
catchError(() => {
|
|
||||||
return of(new SnackbarErrorAction('APP.MESSAGES.UPLOAD.ERROR.GENERIC'));
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
@Effect({ dispatch: false })
|
@Effect({ dispatch: false })
|
||||||
uploadVersion$ = this.actions$.pipe(
|
uploadVersion$ = this.actions$.pipe(
|
||||||
ofType<UploadFileVersionAction>(UploadActionTypes.UploadFileVersion),
|
ofType<UploadFileVersionAction>(UploadActionTypes.UploadFileVersion),
|
||||||
mergeMap((action) => {
|
map((action) => {
|
||||||
if (action?.payload) {
|
if (action?.payload) {
|
||||||
const node = action?.payload?.detail?.data?.node?.entry;
|
const node = action?.payload?.detail?.data?.node?.entry;
|
||||||
const file: any = action?.payload?.detail?.files[0]?.file;
|
const file: any = action?.payload?.detail?.files[0]?.file;
|
||||||
return of(this.contentService.versionUpdateDialog(node, file));
|
this.contentService.versionUpdateDialog(node, file);
|
||||||
} else if (!action.payload) {
|
} else if (!action?.payload) {
|
||||||
return of(this.fileVersionInput.click());
|
this.fileVersionInput.click();
|
||||||
}
|
}
|
||||||
return of(null);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -301,9 +301,6 @@
|
|||||||
"504": "The server timed out, try again or contact IT support [504]",
|
"504": "The server timed out, try again or contact IT support [504]",
|
||||||
"403": "Insufficient permissions to upload in this location [403]",
|
"403": "Insufficient permissions to upload in this location [403]",
|
||||||
"404": "Upload location no longer exists [404]"
|
"404": "Upload location no longer exists [404]"
|
||||||
},
|
|
||||||
"SUCCESS": {
|
|
||||||
"MEDIA_MANAGEMENT_SUCCESS": "Version updated successfully"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"INFO": {
|
"INFO": {
|
||||||
|
Reference in New Issue
Block a user