mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-9980] Add the option to provide custom user profile sections (#4859)
* [ACS-9980] Add the option to provide custom user profile sections * [ACS-9980] Cr fixes * [ACS-9980] Formatting fix
This commit is contained in:
@@ -34,3 +34,7 @@ export interface Badge extends Partial<Pick<ContentActionRef, 'component' | 'act
|
||||
icon: string;
|
||||
tooltip: string;
|
||||
}
|
||||
|
||||
export interface UserProfileSection extends Partial<Pick<ContentActionRef, 'component' | 'rules'>> {
|
||||
id: string;
|
||||
}
|
||||
|
||||
@@ -1682,6 +1682,41 @@ describe('AppExtensionService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should get custom user profile sections from config', (done) => {
|
||||
extensions.setEvaluators({
|
||||
'action.enabled': () => true
|
||||
});
|
||||
|
||||
applyConfig({
|
||||
...defaultConfigMock,
|
||||
features: {
|
||||
userProfileSections: [
|
||||
{
|
||||
id: 'section1-id',
|
||||
component: 'testComponent1',
|
||||
rules: {
|
||||
visible: 'action.enabled'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'section2-id',
|
||||
component: 'testComponent2',
|
||||
rules: {
|
||||
visible: 'action.enabled'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
service.getUserProfileSections().subscribe((sections) => {
|
||||
expect(sections.length).toBe(2);
|
||||
expect(sections[0].id).toEqual('section1-id');
|
||||
expect(sections[1].id).toEqual('section2-id');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should update sidebar actions correctly', () => {
|
||||
spyOn(loader, 'getContentActions').and.callThrough();
|
||||
service.updateSidebarActions();
|
||||
|
||||
@@ -53,7 +53,7 @@ import { AppConfigService, AuthenticationService, LogService } from '@alfresco/a
|
||||
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
||||
import { NodeEntry, RepositoryInfo } from '@alfresco/js-api';
|
||||
import { ViewerRules } from '../models/viewer.rules';
|
||||
import { Badge } from '../models/types';
|
||||
import { Badge, UserProfileSection } from '../models/types';
|
||||
import { NodePermissionService } from '../services/node-permission.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { SearchCategory } from '@alfresco/adf-content-services';
|
||||
@@ -92,6 +92,7 @@ export class AppExtensionService implements RuleContext {
|
||||
private _filesDocumentListPreset = new BehaviorSubject<Array<DocumentListPresetRef>>([]);
|
||||
private _customMetadataPanels = new BehaviorSubject<Array<ContentActionRef>>([]);
|
||||
private _bulkActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
||||
private readonly _userProfileSections = new BehaviorSubject<Array<UserProfileSection>>([]);
|
||||
|
||||
documentListPresets: {
|
||||
libraries: Array<DocumentListPresetRef>;
|
||||
@@ -169,6 +170,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._badges.next(this.loader.getElements<Badge>(config, 'features.badges'));
|
||||
this._userProfileSections.next(this.loader.getElements<UserProfileSection>(config, 'features.userProfileSections'));
|
||||
this._filesDocumentListPreset.next(this.getDocumentListPreset(config, 'files'));
|
||||
this._customMetadataPanels.next(this.loader.getElements<ContentActionRef>(config, 'features.customMetadataPanels'));
|
||||
this._bulkActions.next(this.loader.getElements<ContentActionRef>(config, 'features.bulk-actions'));
|
||||
@@ -384,6 +386,10 @@ export class AppExtensionService implements RuleContext {
|
||||
return this._badges.pipe(map((badges) => badges.filter((badge) => this.evaluateRule(badge.rules.visible, node))));
|
||||
}
|
||||
|
||||
getUserProfileSections(): Observable<Array<UserProfileSection>> {
|
||||
return this._userProfileSections.pipe(map((sections) => sections.filter((section) => this.evaluateRule(section.rules.visible))));
|
||||
}
|
||||
|
||||
getCustomMetadataPanels(node: NodeEntry): Observable<Array<ContentActionRef>> {
|
||||
return this._customMetadataPanels.pipe(map((panels) => panels.filter((panel) => this.evaluateRule(panel.rules.visible, node))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user