mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
user options extension and rules
This commit is contained in:
@@ -27,6 +27,11 @@ import { RuleContext } from '@alfresco/adf-extensions';
|
||||
import * as navigation from './navigation.rules';
|
||||
import * as repository from './repository.rules';
|
||||
|
||||
export interface AcaRuleContext extends RuleContext {
|
||||
languagePicker: boolean;
|
||||
withCredentials: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can copy selected node.
|
||||
* JSON ref: `app.canCopyNode`
|
||||
@@ -526,3 +531,21 @@ export function canToggleFavorite(context: RuleContext): boolean {
|
||||
].some(Boolean)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if application should render language picker menu.
|
||||
* JSON ref: `canShowLanguagePicker`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canShowLanguagePicker(context: AcaRuleContext): boolean {
|
||||
return context.languagePicker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if application should render logout option.
|
||||
* JSON ref: `canShowLogout`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canShowLogout(context: AcaRuleContext): boolean {
|
||||
return !context.withCredentials;
|
||||
}
|
||||
|
@@ -170,7 +170,9 @@ export class CoreExtensionsModule {
|
||||
'app.navigation.isSharedFileViewer': rules.isSharedFileViewer,
|
||||
|
||||
'repository.isQuickShareEnabled': rules.hasQuickShareEnabled,
|
||||
'user.isAdmin': rules.isAdmin
|
||||
'user.isAdmin': rules.isAdmin,
|
||||
'app.canShowLanguagePicker': rules.canShowLanguagePicker,
|
||||
'app.canShowLogout': rules.canShowLogout
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,11 @@ import { Store } from '@ngrx/store';
|
||||
import { Route } from '@angular/router';
|
||||
import { MatIconRegistry } from '@angular/material/icon';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { AppStore, getRuleContext } from '@alfresco/aca-shared/store';
|
||||
import {
|
||||
AppStore,
|
||||
getRuleContext,
|
||||
getLanguagePickerState
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { NodePermissionService } from '@alfresco/aca-shared';
|
||||
import {
|
||||
SelectionState,
|
||||
@@ -78,6 +82,7 @@ export class AppExtensionService implements RuleContext {
|
||||
sidebar: Array<SidebarTabRef> = [];
|
||||
contentMetadata: any;
|
||||
viewerRules: ViewerRules = {};
|
||||
userActions: Array<ContentActionRef> = [];
|
||||
|
||||
documentListPresets: {
|
||||
files: Array<DocumentListPresetRef>;
|
||||
@@ -103,6 +108,8 @@ export class AppExtensionService implements RuleContext {
|
||||
navigation: NavigationState;
|
||||
profile: ProfileState;
|
||||
repository: RepositoryInfo;
|
||||
withCredentials: boolean;
|
||||
languagePicker: boolean;
|
||||
|
||||
references$: Observable<ExtensionRef[]>;
|
||||
|
||||
@@ -124,6 +131,10 @@ export class AppExtensionService implements RuleContext {
|
||||
this.profile = result.profile;
|
||||
this.repository = result.repository;
|
||||
});
|
||||
|
||||
this.store.select(getLanguagePickerState).subscribe(result => {
|
||||
this.languagePicker = result;
|
||||
});
|
||||
}
|
||||
|
||||
async load() {
|
||||
@@ -170,6 +181,10 @@ export class AppExtensionService implements RuleContext {
|
||||
config,
|
||||
'features.sidebar'
|
||||
);
|
||||
this.userActions = this.loader.getContentActions(
|
||||
config,
|
||||
'features.userActions'
|
||||
);
|
||||
this.contentMetadata = this.loadContentMetadata(config);
|
||||
|
||||
this.documentListPresets = {
|
||||
@@ -186,6 +201,11 @@ export class AppExtensionService implements RuleContext {
|
||||
searchLibraries: this.getDocumentListPreset(config, 'search-libraries')
|
||||
};
|
||||
|
||||
this.withCredentials = this.appConfig.get<boolean>(
|
||||
'auth.withCredentials',
|
||||
false
|
||||
);
|
||||
|
||||
if (config.features && config.features.viewer) {
|
||||
this.viewerRules = <ViewerRules>(config.features.viewer['rules'] || {});
|
||||
}
|
||||
@@ -473,6 +493,12 @@ export class AppExtensionService implements RuleContext {
|
||||
return this.getAllowedActions(this.contextMenuActions);
|
||||
}
|
||||
|
||||
getUserActions(): Array<ContentActionRef> {
|
||||
return this.userActions
|
||||
.filter(action => this.filterVisible(action))
|
||||
.sort(sortByOrder);
|
||||
}
|
||||
|
||||
copyAction(action: ContentActionRef): ContentActionRef {
|
||||
return {
|
||||
...action,
|
||||
|
Reference in New Issue
Block a user