Skip to content

Commit

Permalink
[ACS-5563] Fixed incorrect initial loading of security marks (#3405)
Browse files Browse the repository at this point in the history
* [ACS-5563] fixed incorrect initial loading of security marks

* [ACS-5563] added DoneFn
  • Loading branch information
nikita-web-ua committed Sep 1, 2023
1 parent e2ddd81 commit deba28c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -77,7 +78,8 @@ describe('FilesComponent', () => {
params: of({ folderId: 'someId' }),
queryParamMap: of({})
}
}
},
AppExtensionService
],
schemas: [NO_ERRORS_SCHEMA]
});
Expand All @@ -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');
});

Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
29 changes: 18 additions & 11 deletions projects/aca-shared/src/lib/services/app.extension.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('AppExtensionService', () => {
});
});

it('should support column orders', () => {
it('should support column orders', (done) => {
applyConfig({
$id: 'test',
$name: 'test',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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();
});
});
});

Expand Down
6 changes: 3 additions & 3 deletions projects/aca-shared/src/lib/services/app.extension.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand All @@ -91,7 +91,6 @@ export class AppExtensionService implements RuleContext {
trashcan: Array<DocumentListPresetRef>;
searchLibraries: Array<DocumentListPresetRef>;
} = {
files: [],
libraries: [],
favoriteLibraries: [],
shared: [],
Expand All @@ -108,6 +107,7 @@ export class AppExtensionService implements RuleContext {
withCredentials: boolean;

references$: Observable<ExtensionRef[]>;
filesDocumentListPreset$: Observable<DocumentListPresetRef[]> = this._filesDocumentListPreset.asObservable();

config: ExtensionConfig;

Expand Down Expand Up @@ -158,14 +158,14 @@ 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');
this.contentMetadata = this.loadContentMetadata(config);
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'),
Expand Down

0 comments on commit deba28c

Please sign in to comment.