mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACS-5279] improved plugin handling (#3332)
This commit is contained in:
@@ -88,7 +88,10 @@ export interface AcaRuleContext extends RuleContext {
|
||||
* Checks if the content plugin is enabled.
|
||||
* JSON ref: `app.isContentServiceEnabled`
|
||||
*/
|
||||
export const isContentServiceEnabled = (): boolean => localStorage && localStorage.getItem('contentService') !== 'false';
|
||||
export const isContentServiceEnabled = (context: AcaRuleContext): boolean => {
|
||||
const flag = context.appConfig.get<boolean | string>('plugins.contentService');
|
||||
return flag === true || flag === 'true';
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if Search is supported for active view
|
||||
@@ -101,10 +104,10 @@ export const isSearchSupported = (context: RuleContext): boolean =>
|
||||
* Checks if upload action is supported for the given context
|
||||
* JSON ref: `app.isUploadSupported`
|
||||
*
|
||||
* @param content Rule execution context
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export const isUploadSupported = (context: RuleContext): boolean =>
|
||||
[isContentServiceEnabled(), navigation.isPersonalFiles(context) || navigation.isLibraryContent(context), canUpload(context)].every(Boolean);
|
||||
export const isUploadSupported = (context: AcaRuleContext): boolean =>
|
||||
[isContentServiceEnabled(context), navigation.isPersonalFiles(context) || navigation.isLibraryContent(context), canUpload(context)].every(Boolean);
|
||||
/**
|
||||
* Checks if user can copy selected node.
|
||||
* JSON ref: `app.canCopyNode`
|
||||
@@ -240,8 +243,8 @@ export const hasSelection = (context: RuleContext): boolean => !context.selectio
|
||||
* Checks if user can create a new folder with current path.
|
||||
* JSON ref: `app.navigation.folder.canCreate`
|
||||
*/
|
||||
export function canCreateFolder(context: RuleContext): boolean {
|
||||
if (isContentServiceEnabled() && (navigation.isPersonalFiles(context) || navigation.isLibraryContent(context))) {
|
||||
export function canCreateFolder(context: AcaRuleContext): boolean {
|
||||
if (isContentServiceEnabled(context) && (navigation.isPersonalFiles(context) || navigation.isLibraryContent(context))) {
|
||||
const { currentFolder } = context.navigation;
|
||||
|
||||
if (currentFolder) {
|
||||
@@ -257,14 +260,15 @@ export function canCreateFolder(context: RuleContext): boolean {
|
||||
*
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export const canCreateLibrary = (context: RuleContext): boolean => [isContentServiceEnabled(), navigation.isLibraries(context)].every(Boolean);
|
||||
export const canCreateLibrary = (context: AcaRuleContext): boolean =>
|
||||
[isContentServiceEnabled(context), navigation.isLibraries(context)].every(Boolean);
|
||||
|
||||
/**
|
||||
* Checks if user can upload content to current folder.
|
||||
* JSON ref: `app.navigation.folder.canUpload`
|
||||
*/
|
||||
export function canUpload(context: RuleContext): boolean {
|
||||
if (isContentServiceEnabled() && (navigation.isPersonalFiles(context) || navigation.isLibraryContent(context))) {
|
||||
export function canUpload(context: AcaRuleContext): boolean {
|
||||
if (isContentServiceEnabled(context) && (navigation.isPersonalFiles(context) || navigation.isLibraryContent(context))) {
|
||||
const { currentFolder } = context.navigation;
|
||||
|
||||
if (currentFolder) {
|
||||
@@ -578,7 +582,13 @@ export const showInfoSelectionButton = (context: RuleContext): boolean => naviga
|
||||
*
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canOpenWithOffice(context: RuleContext): boolean {
|
||||
export function canOpenWithOffice(context: AcaRuleContext): boolean {
|
||||
const flag = `${context.appConfig.get<boolean | string>('plugins.aosPlugin', false)}`;
|
||||
|
||||
if (flag !== 'true') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context.navigation && context.navigation.url && context.navigation.url.startsWith('/trashcan')) {
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user