mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-10-01 14:41:14 +00:00
improved upload and create actions
This commit is contained in:
committed by
Sheena Malhotra
parent
ddb1b264b0
commit
cdd95c17f8
@@ -143,8 +143,7 @@
|
||||
"click": "CREATE_FOLDER"
|
||||
},
|
||||
"rules": {
|
||||
"enabled": "app.navigation.folder.canCreate",
|
||||
"visible": "app.isContentServiceEnabled"
|
||||
"visible": "app.navigation.folder.canCreate"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -157,7 +156,7 @@
|
||||
"click": "CREATE_LIBRARY"
|
||||
},
|
||||
"rules": {
|
||||
"visible": "app.isContentServiceEnabled"
|
||||
"visible": "app.canCreateLibrary"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -171,8 +170,7 @@
|
||||
"click": "FILE_FROM_TEMPLATE"
|
||||
},
|
||||
"rules": {
|
||||
"enabled": "app.navigation.folder.canUpload",
|
||||
"visible": "app.isContentServiceEnabled"
|
||||
"visible": "app.navigation.folder.canUpload"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -186,8 +184,7 @@
|
||||
"click": "FOLDER_FROM_TEMPLATE"
|
||||
},
|
||||
"rules": {
|
||||
"enabled": "app.navigation.folder.canUpload",
|
||||
"visible": "app.isContentServiceEnabled"
|
||||
"visible": "app.navigation.folder.canUpload"
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -198,13 +195,11 @@
|
||||
"icon": "file_upload",
|
||||
"title": "APP.NEW_MENU.MENU_ITEMS.UPLOAD_FILE",
|
||||
"description": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES",
|
||||
"description-disabled": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES_NOT_ALLOWED",
|
||||
"actions": {
|
||||
"click": "UPLOAD_FILES"
|
||||
},
|
||||
"rules": {
|
||||
"enabled": "app.navigation.folder.canUpload",
|
||||
"visible": "app.isContentServiceEnabled"
|
||||
"visible": "app.isUploadSupported"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -213,13 +208,11 @@
|
||||
"icon": "file_upload",
|
||||
"title": "APP.NEW_MENU.MENU_ITEMS.UPLOAD_FOLDER",
|
||||
"description": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS",
|
||||
"description-disabled": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS_NOT_ALLOWED",
|
||||
"actions": {
|
||||
"click": "UPLOAD_FOLDER"
|
||||
},
|
||||
"rules": {
|
||||
"enabled": "app.navigation.folder.canUpload",
|
||||
"visible": "app.isContentServiceEnabled"
|
||||
"visible": "app.isUploadSupported"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@@ -24,7 +24,6 @@
|
||||
*/
|
||||
|
||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||
import { SetCurrentFolderAction, AppStore } from '@alfresco/aca-shared/store';
|
||||
@@ -44,7 +43,7 @@ export class HeaderActionsComponent implements OnInit, OnDestroy {
|
||||
createActions: Array<ContentActionRef> = [];
|
||||
uploadActions: Array<ContentActionRef> = [];
|
||||
|
||||
constructor(private router: Router, private store: Store<AppStore>, private extensions: AppExtensionService) {}
|
||||
constructor(private store: Store<AppStore>, private extensions: AppExtensionService) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.extensions
|
||||
@@ -72,24 +71,12 @@ export class HeaderActionsComponent implements OnInit, OnDestroy {
|
||||
return action.id;
|
||||
}
|
||||
|
||||
private isPersonalFilesRoute(): boolean {
|
||||
return this.router.url.includes('/personal-files');
|
||||
}
|
||||
|
||||
private isFavoriteLibrariesRoute(): boolean {
|
||||
return this.router.url.includes('/favorite/libraries');
|
||||
}
|
||||
|
||||
private isLibrariesRoute(): boolean {
|
||||
return this.router.url.includes('/libraries');
|
||||
}
|
||||
|
||||
canShowCreateButton(): boolean {
|
||||
return this.createActions.length > 0 && (this.isPersonalFilesRoute() || this.isFavoriteLibrariesRoute() || this.isLibrariesRoute());
|
||||
return this.createActions.length > 0;
|
||||
}
|
||||
|
||||
canShowUploadButton(): boolean {
|
||||
return this.uploadActions.length > 0 && this.isPersonalFilesRoute();
|
||||
return this.uploadActions.length > 0;
|
||||
}
|
||||
|
||||
canShowSearchSeparator(): boolean {
|
||||
|
@@ -91,6 +91,14 @@ export interface AcaRuleContext extends RuleContext {
|
||||
*/
|
||||
export const isContentServiceEnabled = (): boolean => localStorage && localStorage.getItem('contentService') !== 'false';
|
||||
|
||||
/**
|
||||
* Checks if upload action is supported for the given context
|
||||
* JSON ref: `app.isUploadSupported`
|
||||
*
|
||||
* @param content Rule execution context
|
||||
*/
|
||||
export const isUploadSupported = (context: RuleContext): boolean =>
|
||||
[isContentServiceEnabled(), navigation.isPersonalFiles(context) || navigation.isLibraryContent(context), canUpload(context)].every(Boolean);
|
||||
/**
|
||||
* Checks if user can copy selected node.
|
||||
* JSON ref: `app.canCopyNode`
|
||||
@@ -227,21 +235,35 @@ export const hasSelection = (context: RuleContext): boolean => !context.selectio
|
||||
* JSON ref: `app.navigation.folder.canCreate`
|
||||
*/
|
||||
export function canCreateFolder(context: RuleContext): boolean {
|
||||
const { currentFolder } = context.navigation;
|
||||
if (currentFolder) {
|
||||
return context.permissions.check(currentFolder, ['create']);
|
||||
if (isContentServiceEnabled() && (navigation.isPersonalFiles(context) || navigation.isLibraryContent(context))) {
|
||||
const { currentFolder } = context.navigation;
|
||||
|
||||
if (currentFolder) {
|
||||
return context.permissions.check(currentFolder, ['create']);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can create a Library
|
||||
* JSON ref: `app.canCreateLibrary`
|
||||
*
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export const canCreateLibrary = (context: RuleContext): boolean => [isContentServiceEnabled(), 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 {
|
||||
const { currentFolder } = context.navigation;
|
||||
if (currentFolder) {
|
||||
return context.permissions.check(currentFolder, ['create']);
|
||||
if (isContentServiceEnabled() && (navigation.isPersonalFiles(context) || navigation.isLibraryContent(context))) {
|
||||
const { currentFolder } = context.navigation;
|
||||
|
||||
if (currentFolder) {
|
||||
return context.permissions.check(currentFolder, ['create']);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@@ -106,6 +106,11 @@ export function isLibraries(context: RuleContext): boolean {
|
||||
return url && (url.endsWith('/libraries') || url.startsWith('/search-libraries'));
|
||||
}
|
||||
|
||||
export function isLibraryContent(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && (url.endsWith('/libraries') || url.includes('/libraries/') || url.startsWith('/search-libraries'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the activated route is neither **Libraries** nor **Library Search Results**.
|
||||
* JSON ref: `app.navigation.isNotLibraries`
|
||||
|
Reference in New Issue
Block a user