mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5563] Fixed incorrect initial loading of security marks (#3405)
* [ACS-5563] fixed incorrect initial loading of security marks * [ACS-5563] added DoneFn
This commit is contained in:
committed by
GitHub
parent
e2ddd81cbc
commit
deba28c8e0
@@ -29,7 +29,7 @@ import { DocumentListService, FilterSearch, PathElementEntity, UploadService } f
|
||||
import { NodeActionsService } from '../../services/node-actions.service';
|
||||
import { FilesComponent } from './files.component';
|
||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||
import { ContentApiService } from '@alfresco/aca-shared';
|
||||
import { AppExtensionService, ContentApiService } from '@alfresco/aca-shared';
|
||||
import { of, Subject, throwError } from 'rxjs';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NodeEntry, NodePaging, Node } from '@alfresco/js-api';
|
||||
@@ -39,6 +39,7 @@ describe('FilesComponent', () => {
|
||||
let fixture: ComponentFixture<FilesComponent>;
|
||||
let component: FilesComponent;
|
||||
let uploadService: UploadService;
|
||||
let extensions: AppExtensionService;
|
||||
let nodeActionsService: NodeActionsService;
|
||||
let contentApi: ContentApiService;
|
||||
let route: ActivatedRoute;
|
||||
@@ -77,7 +78,8 @@ describe('FilesComponent', () => {
|
||||
params: of({ folderId: 'someId' }),
|
||||
queryParamMap: of({})
|
||||
}
|
||||
}
|
||||
},
|
||||
AppExtensionService
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
});
|
||||
@@ -96,6 +98,7 @@ describe('FilesComponent', () => {
|
||||
route = TestBed.inject(ActivatedRoute);
|
||||
nodeActionsService = TestBed.inject(NodeActionsService);
|
||||
contentApi = TestBed.inject(ContentApiService);
|
||||
extensions = TestBed.inject(AppExtensionService);
|
||||
spyContent = spyOn(contentApi, 'getNode');
|
||||
});
|
||||
|
||||
@@ -148,6 +151,24 @@ describe('FilesComponent', () => {
|
||||
expect(component.node).toBe(node);
|
||||
});
|
||||
|
||||
it('should set columns', () => {
|
||||
const filesDocumentListPresetMock = [
|
||||
{
|
||||
id: 'app.files.modifiedOn',
|
||||
key: 'modifiedAt',
|
||||
type: 'date',
|
||||
sortable: true,
|
||||
desktopOnly: true,
|
||||
template: 'template',
|
||||
sortingKey: 'sorting-key'
|
||||
}
|
||||
];
|
||||
|
||||
extensions.filesDocumentListPreset$ = of(filesDocumentListPresetMock);
|
||||
fixture.detectChanges();
|
||||
expect(component.columns).toEqual(filesDocumentListPresetMock);
|
||||
});
|
||||
|
||||
it('should navigate to parent if node is not a folder', () => {
|
||||
const nodeEntry = { isFolder: false, parentId: 'parent-id' };
|
||||
spyContent.and.returnValue(of({ entry: nodeEntry } as any));
|
||||
|
@@ -127,7 +127,10 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
||||
this.isAdmin = value;
|
||||
});
|
||||
|
||||
this.columns = this.extensions.documentListPresets.files || [];
|
||||
this.extensions.filesDocumentListPreset$.pipe(takeUntil(this.onDestroy$)).subscribe((preset) => {
|
||||
this.columns = preset;
|
||||
});
|
||||
|
||||
if (this.queryParams && Object.keys(this.queryParams).length > 0) {
|
||||
this.isFilterHeaderActive = true;
|
||||
}
|
||||
|
@@ -174,7 +174,7 @@ describe('AppExtensionService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should support column orders', () => {
|
||||
it('should support column orders', (done) => {
|
||||
applyConfig({
|
||||
$id: 'test',
|
||||
$name: 'test',
|
||||
@@ -228,19 +228,23 @@ describe('AppExtensionService', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const { files, libraries } = service.documentListPresets;
|
||||
const { libraries } = service.documentListPresets;
|
||||
const files = service.filesDocumentListPreset$;
|
||||
|
||||
expect(files.length).toBe(3);
|
||||
expect(files[0].id).toBe('app.files.thumbnail');
|
||||
expect(files[1].id).toBe('app.files.name');
|
||||
expect(files[2].id).toBe('app.files.securityMarks');
|
||||
files.subscribe((columns) => {
|
||||
expect(columns.length).toBe(3);
|
||||
expect(columns[0].id).toBe('app.files.thumbnail');
|
||||
expect(columns[1].id).toBe('app.files.name');
|
||||
expect(columns[2].id).toBe('app.files.securityMarks');
|
||||
done();
|
||||
});
|
||||
|
||||
expect(libraries.length).toBe(2);
|
||||
expect(libraries[0].id).toBe('app.libraries.name');
|
||||
expect(libraries[1].id).toBe('app.libraries.thumbnail');
|
||||
});
|
||||
|
||||
it('should ignore column if visibility in rules is false', () => {
|
||||
it('should ignore column if visibility in rules is false', (done) => {
|
||||
applyConfig({
|
||||
$id: 'test',
|
||||
$name: 'test',
|
||||
@@ -279,11 +283,14 @@ describe('AppExtensionService', () => {
|
||||
}
|
||||
});
|
||||
|
||||
const { files } = service.documentListPresets;
|
||||
const files = service.filesDocumentListPreset$;
|
||||
|
||||
expect(files.length).toBe(2);
|
||||
expect(files[0].id).toBe('app.files.thumbnail');
|
||||
expect(files[1].id).toBe('app.files.name');
|
||||
files.subscribe((columns) => {
|
||||
expect(columns.length).toBe(2);
|
||||
expect(columns[0].id).toBe('app.files.thumbnail');
|
||||
expect(columns[1].id).toBe('app.files.name');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -80,9 +80,9 @@ export class AppExtensionService implements RuleContext {
|
||||
private _createActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
||||
private _mainActions = new BehaviorSubject<ContentActionRef>(null);
|
||||
private _sidebarActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
||||
private _filesDocumentListPreset = new BehaviorSubject<Array<DocumentListPresetRef>>([]);
|
||||
|
||||
documentListPresets: {
|
||||
files: Array<DocumentListPresetRef>;
|
||||
libraries: Array<DocumentListPresetRef>;
|
||||
favoriteLibraries: Array<DocumentListPresetRef>;
|
||||
shared: Array<DocumentListPresetRef>;
|
||||
@@ -91,7 +91,6 @@ export class AppExtensionService implements RuleContext {
|
||||
trashcan: Array<DocumentListPresetRef>;
|
||||
searchLibraries: Array<DocumentListPresetRef>;
|
||||
} = {
|
||||
files: [],
|
||||
libraries: [],
|
||||
favoriteLibraries: [],
|
||||
shared: [],
|
||||
@@ -108,6 +107,7 @@ export class AppExtensionService implements RuleContext {
|
||||
withCredentials: boolean;
|
||||
|
||||
references$: Observable<ExtensionRef[]>;
|
||||
filesDocumentListPreset$: Observable<DocumentListPresetRef[]> = this._filesDocumentListPreset.asObservable();
|
||||
|
||||
config: ExtensionConfig;
|
||||
|
||||
@@ -158,6 +158,7 @@ export class AppExtensionService implements RuleContext {
|
||||
this._openWithActions.next(this.loader.getContentActions(config, 'features.viewer.openWith'));
|
||||
this._createActions.next(this.loader.getElements<ContentActionRef>(config, 'features.create'));
|
||||
this._mainActions.next(this.loader.getFeatures(config).mainAction);
|
||||
this._filesDocumentListPreset.next(this.getDocumentListPreset(config, 'files'));
|
||||
|
||||
this.navbar = this.loadNavBar(config);
|
||||
this.sidebarTabs = this.loader.getElements<SidebarTabRef>(config, 'features.sidebar.tabs');
|
||||
@@ -165,7 +166,6 @@ export class AppExtensionService implements RuleContext {
|
||||
this.search = this.loadSearchForms(config);
|
||||
|
||||
this.documentListPresets = {
|
||||
files: this.getDocumentListPreset(config, 'files'),
|
||||
libraries: this.getDocumentListPreset(config, 'libraries'),
|
||||
favoriteLibraries: this.getDocumentListPreset(config, 'favoriteLibraries'),
|
||||
shared: this.getDocumentListPreset(config, 'shared'),
|
||||
|
Reference in New Issue
Block a user