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"
|
"click": "CREATE_FOLDER"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"enabled": "app.navigation.folder.canCreate",
|
"visible": "app.navigation.folder.canCreate"
|
||||||
"visible": "app.isContentServiceEnabled"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -157,7 +156,7 @@
|
|||||||
"click": "CREATE_LIBRARY"
|
"click": "CREATE_LIBRARY"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"visible": "app.isContentServiceEnabled"
|
"visible": "app.canCreateLibrary"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -171,8 +170,7 @@
|
|||||||
"click": "FILE_FROM_TEMPLATE"
|
"click": "FILE_FROM_TEMPLATE"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"enabled": "app.navigation.folder.canUpload",
|
"visible": "app.navigation.folder.canUpload"
|
||||||
"visible": "app.isContentServiceEnabled"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -186,8 +184,7 @@
|
|||||||
"click": "FOLDER_FROM_TEMPLATE"
|
"click": "FOLDER_FROM_TEMPLATE"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"enabled": "app.navigation.folder.canUpload",
|
"visible": "app.navigation.folder.canUpload"
|
||||||
"visible": "app.isContentServiceEnabled"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -198,13 +195,11 @@
|
|||||||
"icon": "file_upload",
|
"icon": "file_upload",
|
||||||
"title": "APP.NEW_MENU.MENU_ITEMS.UPLOAD_FILE",
|
"title": "APP.NEW_MENU.MENU_ITEMS.UPLOAD_FILE",
|
||||||
"description": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES",
|
"description": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES",
|
||||||
"description-disabled": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES_NOT_ALLOWED",
|
|
||||||
"actions": {
|
"actions": {
|
||||||
"click": "UPLOAD_FILES"
|
"click": "UPLOAD_FILES"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"enabled": "app.navigation.folder.canUpload",
|
"visible": "app.isUploadSupported"
|
||||||
"visible": "app.isContentServiceEnabled"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -213,13 +208,11 @@
|
|||||||
"icon": "file_upload",
|
"icon": "file_upload",
|
||||||
"title": "APP.NEW_MENU.MENU_ITEMS.UPLOAD_FOLDER",
|
"title": "APP.NEW_MENU.MENU_ITEMS.UPLOAD_FOLDER",
|
||||||
"description": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS",
|
"description": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS",
|
||||||
"description-disabled": "APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS_NOT_ALLOWED",
|
|
||||||
"actions": {
|
"actions": {
|
||||||
"click": "UPLOAD_FOLDER"
|
"click": "UPLOAD_FOLDER"
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"enabled": "app.navigation.folder.canUpload",
|
"visible": "app.isUploadSupported"
|
||||||
"visible": "app.isContentServiceEnabled"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppExtensionService } from '@alfresco/aca-shared';
|
import { AppExtensionService } from '@alfresco/aca-shared';
|
||||||
import { SetCurrentFolderAction, AppStore } from '@alfresco/aca-shared/store';
|
import { SetCurrentFolderAction, AppStore } from '@alfresco/aca-shared/store';
|
||||||
@@ -44,7 +43,7 @@ export class HeaderActionsComponent implements OnInit, OnDestroy {
|
|||||||
createActions: Array<ContentActionRef> = [];
|
createActions: Array<ContentActionRef> = [];
|
||||||
uploadActions: 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 {
|
ngOnInit(): void {
|
||||||
this.extensions
|
this.extensions
|
||||||
@@ -72,24 +71,12 @@ export class HeaderActionsComponent implements OnInit, OnDestroy {
|
|||||||
return action.id;
|
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 {
|
canShowCreateButton(): boolean {
|
||||||
return this.createActions.length > 0 && (this.isPersonalFilesRoute() || this.isFavoriteLibrariesRoute() || this.isLibrariesRoute());
|
return this.createActions.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
canShowUploadButton(): boolean {
|
canShowUploadButton(): boolean {
|
||||||
return this.uploadActions.length > 0 && this.isPersonalFilesRoute();
|
return this.uploadActions.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
canShowSearchSeparator(): boolean {
|
canShowSearchSeparator(): boolean {
|
||||||
|
@@ -91,6 +91,14 @@ export interface AcaRuleContext extends RuleContext {
|
|||||||
*/
|
*/
|
||||||
export const isContentServiceEnabled = (): boolean => localStorage && localStorage.getItem('contentService') !== 'false';
|
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.
|
* Checks if user can copy selected node.
|
||||||
* JSON ref: `app.canCopyNode`
|
* JSON ref: `app.canCopyNode`
|
||||||
@@ -227,22 +235,36 @@ export const hasSelection = (context: RuleContext): boolean => !context.selectio
|
|||||||
* JSON ref: `app.navigation.folder.canCreate`
|
* JSON ref: `app.navigation.folder.canCreate`
|
||||||
*/
|
*/
|
||||||
export function canCreateFolder(context: RuleContext): boolean {
|
export function canCreateFolder(context: RuleContext): boolean {
|
||||||
|
if (isContentServiceEnabled() && (navigation.isPersonalFiles(context) || navigation.isLibraryContent(context))) {
|
||||||
const { currentFolder } = context.navigation;
|
const { currentFolder } = context.navigation;
|
||||||
|
|
||||||
if (currentFolder) {
|
if (currentFolder) {
|
||||||
return context.permissions.check(currentFolder, ['create']);
|
return context.permissions.check(currentFolder, ['create']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
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.
|
* Checks if user can upload content to current folder.
|
||||||
* JSON ref: `app.navigation.folder.canUpload`
|
* JSON ref: `app.navigation.folder.canUpload`
|
||||||
*/
|
*/
|
||||||
export function canUpload(context: RuleContext): boolean {
|
export function canUpload(context: RuleContext): boolean {
|
||||||
|
if (isContentServiceEnabled() && (navigation.isPersonalFiles(context) || navigation.isLibraryContent(context))) {
|
||||||
const { currentFolder } = context.navigation;
|
const { currentFolder } = context.navigation;
|
||||||
|
|
||||||
if (currentFolder) {
|
if (currentFolder) {
|
||||||
return context.permissions.check(currentFolder, ['create']);
|
return context.permissions.check(currentFolder, ['create']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -106,6 +106,11 @@ export function isLibraries(context: RuleContext): boolean {
|
|||||||
return url && (url.endsWith('/libraries') || url.startsWith('/search-libraries'));
|
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**.
|
* Checks if the activated route is neither **Libraries** nor **Library Search Results**.
|
||||||
* JSON ref: `app.navigation.isNotLibraries`
|
* JSON ref: `app.navigation.isNotLibraries`
|
||||||
|
Reference in New Issue
Block a user