mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-5601] Add badges to custom name column (#3450)
* [ACS-5601] Add badges to name column component * [ACS-5601] Add on click handler to column badges * [ACS-5601] Fix badge hover color * [ACS-5601] Restore modal configuration, prettier fixes * [ACS-5601] Add missing tooltip translation * [ACS-5601] Add process content services to extension service * [ACS-5601] Add adf dynamic component to custom name column * [ACS-5601] Add missing dosc and unit tests * [ACS-5601] Post rebase package lock update * [ACS-5601] CR fixes * [ACS-5601] Unit test fix * [ACS-5601] CR fix * [ACS-5601] Fix unit test, add contrast gray to badges * [ACS-5601] fix fail test and exclude one test * [ACS-5601] fix fail test and exclude one test --------- Co-authored-by: akash.rathod@hyland.com <akash.rathod@hyland.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ContentActionRef } from '@alfresco/adf-extensions';
|
||||
import { Route } from '@angular/router';
|
||||
|
||||
export interface SettingsGroupRef {
|
||||
@@ -45,3 +46,7 @@ export interface SettingsParameterRef {
|
||||
export interface ExtensionRoute extends Route {
|
||||
parentRoute?: string;
|
||||
}
|
||||
|
||||
export interface Badge extends ContentActionRef {
|
||||
tooltip: string;
|
||||
}
|
||||
|
@@ -43,6 +43,7 @@ import { provideMockStore } from '@ngrx/store/testing';
|
||||
import { hasQuickShareEnabled } from '@alfresco/aca-shared/rules';
|
||||
import { MatIconRegistry } from '@angular/material/icon';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
|
||||
describe('AppExtensionService', () => {
|
||||
let service: AppExtensionService;
|
||||
@@ -1677,4 +1678,62 @@ describe('AppExtensionService', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should get badges from config', (done) => {
|
||||
extensions.setEvaluators({
|
||||
'action.enabled': () => true
|
||||
});
|
||||
|
||||
applyConfig({
|
||||
$id: 'test',
|
||||
$name: 'test',
|
||||
$version: '1.0.0',
|
||||
$license: 'MIT',
|
||||
$vendor: 'Good company',
|
||||
$runtime: '1.5.0',
|
||||
features: {
|
||||
badges: [
|
||||
{
|
||||
id: 'action1-id',
|
||||
icon: 'warning',
|
||||
tooltip: 'test tooltip',
|
||||
type: 'custom',
|
||||
rules: {
|
||||
visible: 'action.enabled'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'action2-id',
|
||||
icon: 'settings',
|
||||
tooltip: 'test tooltip2',
|
||||
type: 'custom',
|
||||
rules: {
|
||||
visible: 'action.enabled'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
const node: NodeEntry = {
|
||||
entry: {
|
||||
id: 'testId',
|
||||
name: 'testName',
|
||||
nodeType: 'test',
|
||||
isFile: true,
|
||||
isFolder: false,
|
||||
modifiedAt: undefined,
|
||||
createdAt: undefined,
|
||||
modifiedByUser: undefined,
|
||||
createdByUser: undefined
|
||||
}
|
||||
};
|
||||
|
||||
service.getBadges(node).subscribe((badges) => {
|
||||
expect(badges.length).toBe(2);
|
||||
expect(badges[0].id).toEqual('action1-id');
|
||||
expect(badges[1].id).toEqual('action2-id');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -53,10 +53,9 @@ import { AppConfigService, AuthenticationService, LogService } from '@alfresco/a
|
||||
import { BehaviorSubject, Observable } from 'rxjs';
|
||||
import { RepositoryInfo, NodeEntry } from '@alfresco/js-api';
|
||||
import { ViewerRules } from '../models/viewer.rules';
|
||||
import { SettingsGroupRef } from '../models/types';
|
||||
import { Badge, SettingsGroupRef } from '../models/types';
|
||||
import { NodePermissionService } from '../services/node-permission.service';
|
||||
import { filter, map } from 'rxjs/operators';
|
||||
import { ModalConfiguration } from '../models/modal-configuration';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -80,6 +79,7 @@ export class AppExtensionService implements RuleContext {
|
||||
private _createActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
||||
private _mainActions = new BehaviorSubject<ContentActionRef>(null);
|
||||
private _sidebarActions = new BehaviorSubject<Array<ContentActionRef>>([]);
|
||||
private _badges = new BehaviorSubject<Array<Badge>>([]);
|
||||
private _filesDocumentListPreset = new BehaviorSubject<Array<DocumentListPresetRef>>([]);
|
||||
|
||||
documentListPresets: {
|
||||
@@ -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._badges.next(this.loader.getElements<Badge>(config, 'features.badges'));
|
||||
this._filesDocumentListPreset.next(this.getDocumentListPreset(config, 'files'));
|
||||
|
||||
this.navbar = this.loadNavBar(config);
|
||||
@@ -370,6 +371,10 @@ export class AppExtensionService implements RuleContext {
|
||||
);
|
||||
}
|
||||
|
||||
getBadges(node: NodeEntry): Observable<Array<Badge>> {
|
||||
return this._badges.pipe(map((badges) => badges.filter((badge) => this.evaluateRule(badge.rules.visible, node))));
|
||||
}
|
||||
|
||||
private buildMenu(actionRef: ContentActionRef): ContentActionRef {
|
||||
if (actionRef.type === ContentActionType.menu && actionRef.children && actionRef.children.length > 0) {
|
||||
const children = actionRef.children.filter((action) => this.filterVisible(action)).map((action) => this.buildMenu(action));
|
||||
@@ -492,7 +497,7 @@ export class AppExtensionService implements RuleContext {
|
||||
return false;
|
||||
}
|
||||
|
||||
runActionById(id: string, additionalPayload?: ModalConfiguration) {
|
||||
runActionById(id: string, additionalPayload?: any) {
|
||||
const action = this.extensions.getActionById(id);
|
||||
if (action) {
|
||||
const { type, payload } = action;
|
||||
|
Reference in New Issue
Block a user