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 {
|
||||
UploadFiles = 'UPLOAD_FILES',
|
||||
UploadFolder = 'UPLOAD_FOLDER',
|
||||
UploadFileVersion = 'UPLOAD_FILE_VERSION',
|
||||
UploadImage = 'UPLOAD_IMAGE'
|
||||
UploadFileVersion = 'UPLOAD_FILE_VERSION'
|
||||
}
|
||||
|
||||
export class UploadFilesAction implements Action {
|
||||
@@ -44,12 +43,6 @@ export class UploadFolderAction implements Action {
|
||||
constructor(public payload: any) {}
|
||||
}
|
||||
|
||||
export class UploadNewImageAction implements Action {
|
||||
readonly type = UploadActionTypes.UploadImage;
|
||||
|
||||
constructor(public payload: any) {}
|
||||
}
|
||||
|
||||
export class UploadFileVersionAction implements Action {
|
||||
readonly type = UploadActionTypes.UploadFileVersion;
|
||||
|
||||
|
@@ -19,8 +19,6 @@
|
||||
adf-file-uploading-dialog {
|
||||
z-index: 1100;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@media screen and (max-width: 599px) {
|
||||
|
@@ -14,8 +14,6 @@
|
||||
[allowDownload]="false"
|
||||
[allowFullScreen]="false"
|
||||
[overlayMode]="true"
|
||||
[readOnly]="!canUpdateNode"
|
||||
(fileSubmit)="onFileSubmit($event)"
|
||||
(showViewerChange)="onViewerVisibilityChanged()"
|
||||
[canNavigateBefore]="previousNodeId"
|
||||
[canNavigateNext]="nextNodeId"
|
||||
|
@@ -33,7 +33,6 @@ import {
|
||||
ReloadDocumentListAction,
|
||||
SetCurrentNodeVersionAction,
|
||||
SetSelectedNodesAction,
|
||||
UploadNewImageAction,
|
||||
ViewerActionTypes,
|
||||
ViewNodeAction
|
||||
} from '@alfresco/aca-shared/store';
|
||||
@@ -46,7 +45,6 @@ import { Store } from '@ngrx/store';
|
||||
import { from, Observable, Subject } from 'rxjs';
|
||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||
import { Actions, ofType } from '@ngrx/effects';
|
||||
import { ContentManagementService } from '../../services/content-management.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-viewer',
|
||||
@@ -66,7 +64,6 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
||||
selection: SelectionState;
|
||||
infoDrawerOpened$: Observable<boolean>;
|
||||
|
||||
canUpdateNode = false;
|
||||
showRightSide = false;
|
||||
openWith: ContentActionRef[] = [];
|
||||
toolbarActions: ContentActionRef[] = [];
|
||||
@@ -115,8 +112,7 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
||||
private preferences: UserPreferencesService,
|
||||
private apiService: AlfrescoApiService,
|
||||
private uploadService: UploadService,
|
||||
private appHookService: AppHookService,
|
||||
private content: ContentManagementService
|
||||
private appHookService: AppHookService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@@ -212,7 +208,6 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
||||
if (nodeId) {
|
||||
try {
|
||||
this.node = await this.contentApi.getNodeInfo(nodeId).toPromise();
|
||||
this.canUpdateNode = this.content.canUpdateNode(this.node);
|
||||
this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }]));
|
||||
this.navigateMultiple = this.extensions.canShowViewerNavigation({ entry: this.node });
|
||||
if (!this.navigateMultiple) {
|
||||
@@ -259,11 +254,6 @@ export class AppViewerComponent implements OnInit, OnDestroy {
|
||||
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.
|
||||
* @param nodeId Unique identifier of the document node
|
||||
|
@@ -25,23 +25,13 @@
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { Actions, EffectsModule } from '@ngrx/effects';
|
||||
import { EffectsModule } from '@ngrx/effects';
|
||||
import { UploadEffects } from './upload.effects';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
import { NgZone } from '@angular/core';
|
||||
import { UploadService, FileUploadCompleteEvent, FileModel } from '@alfresco/adf-core';
|
||||
import {
|
||||
SnackbarErrorAction,
|
||||
SnackbarInfoAction,
|
||||
UnlockWriteAction,
|
||||
UploadFileVersionAction,
|
||||
UploadNewImageAction
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { UnlockWriteAction, UploadFileVersionAction } from '@alfresco/aca-shared/store';
|
||||
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', () => {
|
||||
let store: Store<any>;
|
||||
@@ -49,35 +39,10 @@ describe('UploadEffects', () => {
|
||||
let effects: UploadEffects;
|
||||
let zone: NgZone;
|
||||
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(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [AppTestingModule, EffectsModule.forRoot([UploadEffects])],
|
||||
providers: [provideMockActions(() => actions$)]
|
||||
imports: [AppTestingModule, EffectsModule.forRoot([UploadEffects])]
|
||||
});
|
||||
|
||||
zone = TestBed.inject(NgZone);
|
||||
@@ -91,6 +56,11 @@ describe('UploadEffects', () => {
|
||||
effects = TestBed.inject(UploadEffects);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(effects['fileVersionInput'], 'click');
|
||||
spyOn(effects, 'uploadVersion').and.callThrough();
|
||||
});
|
||||
|
||||
describe('uploadAndUnlock()', () => {
|
||||
it('should not upload and unlock file if param not provided', () => {
|
||||
effects.uploadAndUnlock(null);
|
||||
@@ -181,17 +151,8 @@ describe('UploadEffects', () => {
|
||||
});
|
||||
|
||||
describe('upload file version', () => {
|
||||
beforeEach(() => {
|
||||
actions$ = TestBed.inject(Actions);
|
||||
});
|
||||
|
||||
it('should trigger upload file from context menu', () => {
|
||||
spyOn(effects['fileVersionInput'], 'click');
|
||||
actions$ = hot('a', {
|
||||
a: new UploadFileVersionAction(undefined)
|
||||
});
|
||||
const expected = cold('b', {});
|
||||
expect(effects.uploadVersion$).toBeObservable(expected);
|
||||
store.dispatch({ type: 'UPLOAD_FILE_VERSION' });
|
||||
expect(effects['fileVersionInput'].click).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -245,50 +206,9 @@ describe('UploadEffects', () => {
|
||||
}
|
||||
}
|
||||
});
|
||||
actions$ = hot('a', {
|
||||
a: new UploadFileVersionAction(fakeEvent)
|
||||
});
|
||||
|
||||
const expected = cold('b', {});
|
||||
expect(effects.uploadVersion$).toBeObservable(expected);
|
||||
store.dispatch(new UploadFileVersionAction(fakeEvent));
|
||||
|
||||
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,
|
||||
UploadFileVersionAction,
|
||||
UploadFolderAction,
|
||||
getCurrentFolder,
|
||||
UploadNewImageAction,
|
||||
SnackbarInfoAction
|
||||
getCurrentFolder
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { FileModel, FileUtils, UploadService } from '@alfresco/adf-core';
|
||||
import { Injectable, NgZone, RendererFactory2 } from '@angular/core';
|
||||
import { Actions, Effect, ofType } from '@ngrx/effects';
|
||||
import { Store } from '@ngrx/store';
|
||||
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 { 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 })
|
||||
uploadVersion$ = this.actions$.pipe(
|
||||
ofType<UploadFileVersionAction>(UploadActionTypes.UploadFileVersion),
|
||||
mergeMap((action) => {
|
||||
map((action) => {
|
||||
if (action?.payload) {
|
||||
const node = action?.payload?.detail?.data?.node?.entry;
|
||||
const file: any = action?.payload?.detail?.files[0]?.file;
|
||||
return of(this.contentService.versionUpdateDialog(node, file));
|
||||
} else if (!action.payload) {
|
||||
return of(this.fileVersionInput.click());
|
||||
this.contentService.versionUpdateDialog(node, file);
|
||||
} else if (!action?.payload) {
|
||||
this.fileVersionInput.click();
|
||||
}
|
||||
return of(null);
|
||||
})
|
||||
);
|
||||
|
||||
|
@@ -301,9 +301,6 @@
|
||||
"504": "The server timed out, try again or contact IT support [504]",
|
||||
"403": "Insufficient permissions to upload in this location [403]",
|
||||
"404": "Upload location no longer exists [404]"
|
||||
},
|
||||
"SUCCESS": {
|
||||
"MEDIA_MANAGEMENT_SUCCESS": "Version updated successfully"
|
||||
}
|
||||
},
|
||||
"INFO": {
|
||||
|
Reference in New Issue
Block a user