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 navigation from './navigation.rules';
|
||||||
import * as repository from './repository.rules';
|
import * as repository from './repository.rules';
|
||||||
|
|
||||||
|
export interface AcaRuleContext extends RuleContext {
|
||||||
|
languagePicker: boolean;
|
||||||
|
withCredentials: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if user can copy selected node.
|
* Checks if user can copy selected node.
|
||||||
* JSON ref: `app.canCopyNode`
|
* JSON ref: `app.canCopyNode`
|
||||||
@@ -526,3 +531,21 @@ export function canToggleFavorite(context: RuleContext): boolean {
|
|||||||
].some(Boolean)
|
].some(Boolean)
|
||||||
].every(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,
|
'app.navigation.isSharedFileViewer': rules.isSharedFileViewer,
|
||||||
|
|
||||||
'repository.isQuickShareEnabled': rules.hasQuickShareEnabled,
|
'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 { Route } from '@angular/router';
|
||||||
import { MatIconRegistry } from '@angular/material/icon';
|
import { MatIconRegistry } from '@angular/material/icon';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
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 { NodePermissionService } from '@alfresco/aca-shared';
|
||||||
import {
|
import {
|
||||||
SelectionState,
|
SelectionState,
|
||||||
@@ -78,6 +82,7 @@ export class AppExtensionService implements RuleContext {
|
|||||||
sidebar: Array<SidebarTabRef> = [];
|
sidebar: Array<SidebarTabRef> = [];
|
||||||
contentMetadata: any;
|
contentMetadata: any;
|
||||||
viewerRules: ViewerRules = {};
|
viewerRules: ViewerRules = {};
|
||||||
|
userActions: Array<ContentActionRef> = [];
|
||||||
|
|
||||||
documentListPresets: {
|
documentListPresets: {
|
||||||
files: Array<DocumentListPresetRef>;
|
files: Array<DocumentListPresetRef>;
|
||||||
@@ -103,6 +108,8 @@ export class AppExtensionService implements RuleContext {
|
|||||||
navigation: NavigationState;
|
navigation: NavigationState;
|
||||||
profile: ProfileState;
|
profile: ProfileState;
|
||||||
repository: RepositoryInfo;
|
repository: RepositoryInfo;
|
||||||
|
withCredentials: boolean;
|
||||||
|
languagePicker: boolean;
|
||||||
|
|
||||||
references$: Observable<ExtensionRef[]>;
|
references$: Observable<ExtensionRef[]>;
|
||||||
|
|
||||||
@@ -124,6 +131,10 @@ export class AppExtensionService implements RuleContext {
|
|||||||
this.profile = result.profile;
|
this.profile = result.profile;
|
||||||
this.repository = result.repository;
|
this.repository = result.repository;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.store.select(getLanguagePickerState).subscribe(result => {
|
||||||
|
this.languagePicker = result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
@@ -170,6 +181,10 @@ export class AppExtensionService implements RuleContext {
|
|||||||
config,
|
config,
|
||||||
'features.sidebar'
|
'features.sidebar'
|
||||||
);
|
);
|
||||||
|
this.userActions = this.loader.getContentActions(
|
||||||
|
config,
|
||||||
|
'features.userActions'
|
||||||
|
);
|
||||||
this.contentMetadata = this.loadContentMetadata(config);
|
this.contentMetadata = this.loadContentMetadata(config);
|
||||||
|
|
||||||
this.documentListPresets = {
|
this.documentListPresets = {
|
||||||
@@ -186,6 +201,11 @@ export class AppExtensionService implements RuleContext {
|
|||||||
searchLibraries: this.getDocumentListPreset(config, 'search-libraries')
|
searchLibraries: this.getDocumentListPreset(config, 'search-libraries')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.withCredentials = this.appConfig.get<boolean>(
|
||||||
|
'auth.withCredentials',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
if (config.features && config.features.viewer) {
|
if (config.features && config.features.viewer) {
|
||||||
this.viewerRules = <ViewerRules>(config.features.viewer['rules'] || {});
|
this.viewerRules = <ViewerRules>(config.features.viewer['rules'] || {});
|
||||||
}
|
}
|
||||||
@@ -473,6 +493,12 @@ export class AppExtensionService implements RuleContext {
|
|||||||
return this.getAllowedActions(this.contextMenuActions);
|
return this.getAllowedActions(this.contextMenuActions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUserActions(): Array<ContentActionRef> {
|
||||||
|
return this.userActions
|
||||||
|
.filter(action => this.filterVisible(action))
|
||||||
|
.sort(sortByOrder);
|
||||||
|
}
|
||||||
|
|
||||||
copyAction(action: ContentActionRef): ContentActionRef {
|
copyAction(action: ContentActionRef): ContentActionRef {
|
||||||
return {
|
return {
|
||||||
...action,
|
...action,
|
||||||
|
Reference in New Issue
Block a user