mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
shared library (#1080)
* shared project scaffold * rules package * move evaluators to shared lib * add rxjs peer dependency * use dedicated material namespaces * create store package, move actions * move selectors to shared library * move generic effects to shared lib * move routing extensions * minor code reorg * fix unit tests * move content-api service * move permission service * update tests * update plint config * move page layout * css variables * use dedicated css property * move generic error component to shared lib * fix test
This commit is contained in:
3
projects/aca-shared/rules/package.json
Normal file
3
projects/aca-shared/rules/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"ngPackage": {}
|
||||
}
|
365
projects/aca-shared/rules/src/app.rules.spec.ts
Normal file
365
projects/aca-shared/rules/src/app.rules.spec.ts
Normal file
@@ -0,0 +1,365 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import * as app from './app.rules';
|
||||
|
||||
describe('app.evaluators', () => {
|
||||
describe('isWriteLocked', () => {
|
||||
it('should return [true] if lock type is set', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
properties: {
|
||||
'cm:lockType': 'WRITE_LOCK'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isWriteLocked(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if lock type is not set', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
properties: {}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isWriteLocked(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return [false] if selection not present', () => {
|
||||
const context: any = {};
|
||||
|
||||
expect(app.isWriteLocked(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('hasLockedFiles', () => {
|
||||
it('should return [false] if selection not present', () => {
|
||||
const context: any = {};
|
||||
expect(app.hasLockedFiles(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return [false] if nodes not present', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
nodes: null
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.hasLockedFiles(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return [false] if no files selected', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
nodes: [
|
||||
{
|
||||
entry: {
|
||||
isFile: false
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isFile: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.hasLockedFiles(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return [true] when one of files is locked', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
nodes: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: true
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.hasLockedFiles(context)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should return [true] when one of files has readonly lock', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
nodes: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: false
|
||||
}
|
||||
},
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: false,
|
||||
properties: {
|
||||
'cm:lockType': 'READ_ONLY_LOCK'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.hasLockedFiles(context)).toBe(true);
|
||||
});
|
||||
|
||||
describe('canUpdateSelectedNode', () => {
|
||||
it('should return [false] if selection not preset', () => {
|
||||
const context: any = {};
|
||||
|
||||
expect(app.canUpdateSelectedNode(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return [false] if selection is empty', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
isEmpty: true
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUpdateSelectedNode(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return [false] if first selection is not a file', () => {
|
||||
const context: any = {
|
||||
permissions: {
|
||||
check: () => false
|
||||
},
|
||||
selection: {
|
||||
isEmpty: false,
|
||||
first: {
|
||||
entry: {
|
||||
isFile: false
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUpdateSelectedNode(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return [false] if the file is locked', () => {
|
||||
const context: any = {
|
||||
permissions: {
|
||||
check: () => true
|
||||
},
|
||||
selection: {
|
||||
isEmpty: false,
|
||||
nodes: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: true
|
||||
}
|
||||
}
|
||||
],
|
||||
first: {
|
||||
entry: {
|
||||
isFile: true,
|
||||
isLocked: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUpdateSelectedNode(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should evaluate allowable operation for the file', () => {
|
||||
const context: any = {
|
||||
permissions: {
|
||||
check: () => true
|
||||
},
|
||||
selection: {
|
||||
isEmpty: false,
|
||||
nodes: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true,
|
||||
allowableOperationsOnTarget: []
|
||||
}
|
||||
}
|
||||
],
|
||||
first: {
|
||||
entry: {
|
||||
isFile: true,
|
||||
allowableOperationsOnTarget: []
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUpdateSelectedNode(context)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('canUploadVersion', () => {
|
||||
it('should return [true] if user has locked it previously', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/personal-files'
|
||||
},
|
||||
profile: {
|
||||
id: 'user1'
|
||||
},
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
properties: {
|
||||
'cm:lockType': 'WRITE_LOCK',
|
||||
'cm:lockOwner': {
|
||||
id: 'user1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if other user has locked it previously', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/personal-files'
|
||||
},
|
||||
profile: {
|
||||
id: 'user2'
|
||||
},
|
||||
selection: {
|
||||
file: {
|
||||
entry: {
|
||||
properties: {
|
||||
'cm:lockType': 'WRITE_LOCK',
|
||||
'cm:lockOwner': {
|
||||
id: 'user1'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context)).toBe(false);
|
||||
});
|
||||
|
||||
it('should check the [update] operation when no write lock present', () => {
|
||||
let checked = false;
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/personal-files'
|
||||
},
|
||||
permissions: {
|
||||
check: () => (checked = true)
|
||||
},
|
||||
selection: {
|
||||
file: {},
|
||||
isEmpty: false,
|
||||
nodes: [
|
||||
{
|
||||
entry: {
|
||||
isFile: true
|
||||
}
|
||||
}
|
||||
],
|
||||
first: {
|
||||
entry: {
|
||||
isFile: true
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context)).toBe(true);
|
||||
expect(checked).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [true] if route is `/favorites`', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {}
|
||||
},
|
||||
navigation: {
|
||||
url: '/favorites'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [true] if route is `/favorites`', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {}
|
||||
},
|
||||
navigation: {
|
||||
url: '/favorites'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [true] if route is `/shared`', () => {
|
||||
const context: any = {
|
||||
selection: {
|
||||
file: {}
|
||||
},
|
||||
navigation: {
|
||||
url: '/shared'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.canUploadVersion(context)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
528
projects/aca-shared/rules/src/app.rules.ts
Normal file
528
projects/aca-shared/rules/src/app.rules.ts
Normal file
@@ -0,0 +1,528 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
import * as navigation from './navigation.rules';
|
||||
import * as repository from './repository.rules';
|
||||
|
||||
/**
|
||||
* Checks if user can copy selected node.
|
||||
* JSON ref: `app.canCopyNode`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canCopyNode(context: RuleContext): boolean {
|
||||
return [
|
||||
hasSelection(context),
|
||||
navigation.isNotTrashcan(context),
|
||||
navigation.isNotLibraries(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can mark selected nodes as **Favorite**.
|
||||
* JSON ref: `app.selection.canAddFavorite`
|
||||
*/
|
||||
export function canAddFavorite(context: RuleContext): boolean {
|
||||
if (!context.selection.isEmpty) {
|
||||
if (
|
||||
navigation.isFavorites(context) ||
|
||||
navigation.isLibraries(context) ||
|
||||
navigation.isTrashcan(context)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
return context.selection.nodes.some(node => !node.entry.isFavorite);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can un-mark selected nodes as **Favorite**.
|
||||
* JSON ref: `app.selection.canRemoveFavorite`
|
||||
*/
|
||||
export function canRemoveFavorite(context: RuleContext): boolean {
|
||||
if (!context.selection.isEmpty && !navigation.isTrashcan(context)) {
|
||||
if (navigation.isFavorites(context)) {
|
||||
return true;
|
||||
}
|
||||
return context.selection.nodes.every(node => node.entry.isFavorite);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can share selected file.
|
||||
* JSON ref: `app.selection.file.canShare`
|
||||
*/
|
||||
export function canShareFile(context: RuleContext): boolean {
|
||||
return [
|
||||
context.selection.file,
|
||||
navigation.isNotTrashcan(context),
|
||||
repository.hasQuickShareEnabled(context),
|
||||
!isShared(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can perform "Join" or "Cancel Join Request" on a library.
|
||||
* JSON ref: `canToggleJoinLibrary`
|
||||
*/
|
||||
export function canToggleJoinLibrary(context: RuleContext): boolean {
|
||||
return [
|
||||
hasLibrarySelected(context),
|
||||
!isPrivateLibrary(context),
|
||||
hasNoLibraryRole(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can edit the selected folder.
|
||||
* JSON ref: `canEditFolder`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canEditFolder(context: RuleContext): boolean {
|
||||
return [
|
||||
canUpdateSelectedFolder(context),
|
||||
navigation.isNotTrashcan(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected file is already shared.
|
||||
* JSON ref: `app.selection.file.isShared`
|
||||
*/
|
||||
export function isShared(context: RuleContext): boolean {
|
||||
if (navigation.isSharedFiles(context) && !context.selection.isEmpty) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
(navigation.isNotTrashcan(context),
|
||||
!context.selection.isEmpty && context.selection.file)
|
||||
) {
|
||||
return !!(
|
||||
context.selection.file.entry &&
|
||||
context.selection.file.entry.properties &&
|
||||
context.selection.file.entry.properties['qshare:sharedId']
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can delete selected nodes.
|
||||
* JSON ref: `app.selection.canDelete`
|
||||
*/
|
||||
export function canDeleteSelection(context: RuleContext): boolean {
|
||||
if (
|
||||
navigation.isNotTrashcan(context) &&
|
||||
navigation.isNotLibraries(context) &&
|
||||
navigation.isNotSearchResults(context) &&
|
||||
!context.selection.isEmpty
|
||||
) {
|
||||
if (hasLockedFiles(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// temp workaround for Search api
|
||||
if (navigation.isFavorites(context)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (navigation.isPreview(context)) {
|
||||
return context.permissions.check(context.selection.nodes, ['delete']);
|
||||
}
|
||||
|
||||
// workaround for Shared Files
|
||||
if (navigation.isSharedFiles(context)) {
|
||||
return context.permissions.check(context.selection.nodes, ['delete'], {
|
||||
target: 'allowableOperationsOnTarget'
|
||||
});
|
||||
}
|
||||
|
||||
return context.permissions.check(context.selection.nodes, ['delete']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can un-share selected nodes.
|
||||
* JSON ref: `app.selection.canUnshare`
|
||||
*/
|
||||
export function canUnshareNodes(context: RuleContext): boolean {
|
||||
if (!context.selection.isEmpty) {
|
||||
return context.permissions.check(context.selection.nodes, ['delete'], {
|
||||
target: 'allowableOperationsOnTarget'
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user selected anything.
|
||||
* JSON ref: `app.selection.notEmpty`
|
||||
*/
|
||||
export function hasSelection(context: RuleContext): boolean {
|
||||
return !context.selection.isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can create a new folder with current path.
|
||||
* JSON ref: `app.navigation.folder.canCreate`
|
||||
*/
|
||||
export function canCreateFolder(context: RuleContext): boolean {
|
||||
const { currentFolder } = context.navigation;
|
||||
if (currentFolder) {
|
||||
return context.permissions.check(currentFolder, ['create']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can download selected nodes (either files or folders).
|
||||
* JSON ref: `app.selection.canDownload`
|
||||
*/
|
||||
export function canDownloadSelection(context: RuleContext): boolean {
|
||||
if (!context.selection.isEmpty && navigation.isNotTrashcan(context)) {
|
||||
return context.selection.nodes.every((node: any) => {
|
||||
return (
|
||||
node.entry &&
|
||||
(node.entry.isFile || node.entry.isFolder || !!node.entry.nodeId)
|
||||
);
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user has selected a folder.
|
||||
* JSON ref: `app.selection.folder`
|
||||
*/
|
||||
export function hasFolderSelected(context: RuleContext): boolean {
|
||||
const folder = context.selection.folder;
|
||||
return folder ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user has selected a library (site).
|
||||
* JSON ref: `app.selection.library`
|
||||
*/
|
||||
export function hasLibrarySelected(context: RuleContext): boolean {
|
||||
const library = context.selection.library;
|
||||
return library ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user has selected a **private** library (site)
|
||||
* JSON ref: `app.selection.isPrivateLibrary`
|
||||
*/
|
||||
export function isPrivateLibrary(context: RuleContext): boolean {
|
||||
const library = context.selection.library;
|
||||
return library
|
||||
? !!(
|
||||
library.entry &&
|
||||
library.entry.visibility &&
|
||||
library.entry.visibility === 'PRIVATE'
|
||||
)
|
||||
: false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected library has a **role** property defined.
|
||||
* JSON ref: `app.selection.hasLibraryRole`
|
||||
*/
|
||||
export function hasLibraryRole(context: RuleContext): boolean {
|
||||
const library = context.selection.library;
|
||||
return library ? !!(library.entry && library.entry.role) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected library has no **role** property defined.
|
||||
* JSON ref: `app.selection.hasNoLibraryRole`
|
||||
*/
|
||||
export function hasNoLibraryRole(context: RuleContext): boolean {
|
||||
return !hasLibraryRole(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user has selected a file.
|
||||
* JSON ref: `app.selection.file`
|
||||
*/
|
||||
export function hasFileSelected(context: RuleContext): boolean {
|
||||
if (context && context.selection && context.selection.file) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can update the first selected node.
|
||||
* JSON ref: `app.selection.first.canUpdate`
|
||||
*/
|
||||
export function canUpdateSelectedNode(context: RuleContext): boolean {
|
||||
if (context.selection && !context.selection.isEmpty) {
|
||||
const node = context.selection.first;
|
||||
|
||||
if (node.entry.isFile && hasLockedFiles(context)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return context.permissions.check(node, ['update']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can update the first selected folder.
|
||||
* JSON ref: `app.selection.folder.canUpdate`
|
||||
*/
|
||||
export function canUpdateSelectedFolder(context: RuleContext): boolean {
|
||||
const { folder } = context.selection;
|
||||
if (folder) {
|
||||
return (
|
||||
// workaround for Favorites Api
|
||||
navigation.isFavorites(context) ||
|
||||
context.permissions.check(folder.entry, ['update'])
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user has selected a **locked** file node.
|
||||
* JSON ref: `app.selection.file.isLocked`
|
||||
*/
|
||||
export function hasLockedFiles(context: RuleContext): boolean {
|
||||
if (context && context.selection && context.selection.nodes) {
|
||||
return context.selection.nodes.some(node => {
|
||||
if (!node.entry.isFile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
node.entry.isLocked ||
|
||||
(node.entry.properties &&
|
||||
node.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK')
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected file has **write** or **read-only** locks specified.
|
||||
* JSON ref: `app.selection.file.isLocked`
|
||||
*/
|
||||
export function isWriteLocked(context: RuleContext): boolean {
|
||||
return !!(
|
||||
context &&
|
||||
context.selection &&
|
||||
context.selection.file &&
|
||||
context.selection.file.entry &&
|
||||
context.selection.file.entry.properties &&
|
||||
(context.selection.file.entry.properties['cm:lockType'] === 'WRITE_LOCK' ||
|
||||
context.selection.file.entry.properties['cm:lockType'] ===
|
||||
'READ_ONLY_LOCK')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the selected file has **write** or **read-only** locks specified,
|
||||
* and that current user is the owner of the lock.
|
||||
* JSON ref: `app.selection.file.isLockOwner`
|
||||
*/
|
||||
export function isUserWriteLockOwner(context: RuleContext): boolean {
|
||||
return (
|
||||
isWriteLocked(context) &&
|
||||
(context.selection.file.entry.properties['cm:lockOwner'] &&
|
||||
context.selection.file.entry.properties['cm:lockOwner'].id ===
|
||||
context.profile.id)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can lock selected file.
|
||||
* JSON ref: `app.selection.file.canLock`
|
||||
*/
|
||||
export function canLockFile(context: RuleContext): boolean {
|
||||
return !isWriteLocked(context) && canUpdateSelectedNode(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can unlock selected file.
|
||||
* JSON ref: `app.selection.file.canLock`
|
||||
*/
|
||||
export function canUnlockFile(context: RuleContext): boolean {
|
||||
const { file } = context.selection;
|
||||
return (
|
||||
isWriteLocked(context) &&
|
||||
(context.permissions.check(file.entry, ['delete']) ||
|
||||
isUserWriteLockOwner(context))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can upload a new version of the file.
|
||||
* JSON ref: `app.selection.file.canUploadVersion`
|
||||
*/
|
||||
export function canUploadVersion(context: RuleContext): boolean {
|
||||
if (navigation.isFavorites(context) || navigation.isSharedFiles(context)) {
|
||||
return hasFileSelected(context);
|
||||
}
|
||||
|
||||
return [
|
||||
hasFileSelected(context),
|
||||
navigation.isNotTrashcan(context),
|
||||
isWriteLocked(context)
|
||||
? isUserWriteLockOwner(context)
|
||||
: canUpdateSelectedNode(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user has trashcan item selected.
|
||||
* JSON ref: `isTrashcanItemSelected`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function isTrashcanItemSelected(context: RuleContext): boolean {
|
||||
return [navigation.isTrashcan(context), hasSelection(context)].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can view the file.
|
||||
* JSON ref: `canViewFile`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canViewFile(context: RuleContext): boolean {
|
||||
return [hasFileSelected(context), navigation.isNotTrashcan(context)].every(
|
||||
Boolean
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can **Leave** selected library.
|
||||
* JSON ref: `canLeaveLibrary`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canLeaveLibrary(context: RuleContext): boolean {
|
||||
return [hasLibrarySelected(context), hasLibraryRole(context)].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can toggle shared link mode.
|
||||
* JSON ref: `canToggleSharedLink`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canToggleSharedLink(context: RuleContext): boolean {
|
||||
return [
|
||||
hasFileSelected(context),
|
||||
[canShareFile(context), isShared(context)].some(Boolean)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can show **Info Drawer** for the selected node.
|
||||
* JSON ref: `canShowInfoDrawer`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canShowInfoDrawer(context: RuleContext): boolean {
|
||||
return [
|
||||
hasSelection(context),
|
||||
navigation.isNotLibraries(context),
|
||||
navigation.isNotTrashcan(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can manage file versions for the selected node.
|
||||
* JSON ref: `canManageFileVersions`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canManageFileVersions(context: RuleContext): boolean {
|
||||
return [
|
||||
hasFileSelected(context),
|
||||
navigation.isNotTrashcan(context),
|
||||
!hasLockedFiles(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can manage permissions for the selected node.
|
||||
* JSON ref: `canManagePermissions`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canManagePermissions(context: RuleContext): boolean {
|
||||
return [
|
||||
canUpdateSelectedNode(context),
|
||||
navigation.isNotTrashcan(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if user can toggle **Edit Offline** mode for selected node.
|
||||
* JSON ref: `canToggleEditOffline`
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canToggleEditOffline(context: RuleContext): boolean {
|
||||
return [
|
||||
hasFileSelected(context),
|
||||
navigation.isNotTrashcan(context),
|
||||
navigation.isNotFavorites(context) ||
|
||||
navigation.isFavoritesPreview(context),
|
||||
navigation.isNotSharedFiles(context) || navigation.isSharedPreview(context),
|
||||
canLockFile(context) || canUnlockFile(context)
|
||||
].every(Boolean);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Uses workarounds for for recent files and search api issues.
|
||||
* Checks if user can toggle **Favorite** state for a node.
|
||||
* @param context Rule execution context
|
||||
*/
|
||||
export function canToggleFavorite(context: RuleContext): boolean {
|
||||
return [
|
||||
[canAddFavorite(context), canRemoveFavorite(context)].some(Boolean),
|
||||
[
|
||||
navigation.isRecentFiles(context),
|
||||
navigation.isSharedFiles(context),
|
||||
navigation.isSearchResults(context),
|
||||
navigation.isFavorites(context)
|
||||
].some(Boolean)
|
||||
].every(Boolean);
|
||||
}
|
338
projects/aca-shared/rules/src/navigation.rules.spec.ts
Normal file
338
projects/aca-shared/rules/src/navigation.rules.spec.ts
Normal file
@@ -0,0 +1,338 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import * as app from './navigation.rules';
|
||||
|
||||
describe('navigation.evaluators', () => {
|
||||
describe('isPreview', () => {
|
||||
it('should return [true] if url contains `/preview/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: 'path/preview/id'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isPreview(context)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isFavorites', () => {
|
||||
it('should return [true] if url contains `/favorites`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/favorites/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isFavorites(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if `/favorites` url contains `/preview/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/favorites/preview/'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isFavorites(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isNotFavorites', () => {
|
||||
it('should return [true] if url is not `/favorites`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/some/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isNotFavorites(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url starts with `/favorites`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/favorites/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isNotFavorites(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSharedFiles', () => {
|
||||
it('should return [true] if path starts with `/shared`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/shared/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isSharedFiles(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if `/shared` url contains `/preview/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/shared/preview/'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isSharedFiles(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isNotSharedFiles', () => {
|
||||
it('should return [true] if path does not contain `/shared`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/some/path/'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isNotSharedFiles(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if path contains `/shared`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/shared/path/'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isNotSharedFiles(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isTrashcan', () => {
|
||||
it('should return [true] if url starts with `/trashcan`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/trashcan'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isTrashcan(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url does not start with `/trashcan`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/trashcan'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isTrashcan(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isNotTrashcan', () => {
|
||||
it('should return [true] if url does not start with `/trashcan`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/trashcan'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isNotTrashcan(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url does start with `/trashcan`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/trashcan'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isNotTrashcan(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isPersonalFiles', () => {
|
||||
it('should return [true] if url starts with `/personal-files`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/personal-files'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isPersonalFiles(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url does not start with `/personal-files`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/personal-files'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isPersonalFiles(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isLibraries', () => {
|
||||
it('should return [true] if url ends with `/libraries`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/libraries'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isLibraries(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [true] if url starts with `/search-libraries`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/search-libraries/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isLibraries(context)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isNotLibraries', () => {
|
||||
it('should return [true] if url does not end with `/libraries`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/libraries/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isNotLibraries(context)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isRecentFiles', () => {
|
||||
it('should return [true] if url starts with `/recent-files`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/recent-files'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isRecentFiles(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url does not start with `/recent-files`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/recent-files'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isRecentFiles(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSearchResults', () => {
|
||||
it('should return [true] if url starts with `/search`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/search'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isSearchResults(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url does not start with `/search`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/search'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isSearchResults(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSharedPreview', () => {
|
||||
it('should return [true] if url starts with `/shared/preview/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/shared/preview/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isSharedPreview(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url does not start with `/shared/preview/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/shared/preview/'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isSharedPreview(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isFavoritesPreview', () => {
|
||||
it('should return [true] if url starts with `/favorites/preview/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/favorites/preview/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isFavoritesPreview(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url does not start with `/favorites/preview/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/favorites/preview/'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isFavoritesPreview(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isSharedFileViewer', () => {
|
||||
it('should return [true] if url starts with `/preview/s/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/preview/s/path'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isSharedFileViewer(context)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return [false] if url does not start with `/preview/s/`', () => {
|
||||
const context: any = {
|
||||
navigation: {
|
||||
url: '/path/preview/s/'
|
||||
}
|
||||
};
|
||||
|
||||
expect(app.isSharedFileViewer(context)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
187
projects/aca-shared/rules/src/navigation.rules.ts
Normal file
187
projects/aca-shared/rules/src/navigation.rules.ts
Normal file
@@ -0,0 +1,187 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
|
||||
/**
|
||||
* Checks if a Preview route is activated.
|
||||
* JSON ref: `app.navigation.isPreview`
|
||||
*/
|
||||
export function isPreview(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && (url.includes('/preview/') || url.includes('/view/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Favorites** route is activated.
|
||||
* JSON ref: `app.navigation.isFavorites`
|
||||
*/
|
||||
export function isFavorites(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/favorites') && !isPreview(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the activated route is not **Favorites**.
|
||||
* JSON ref: `app.navigation.isNotFavorites`
|
||||
*/
|
||||
export function isNotFavorites(context: RuleContext): boolean {
|
||||
return !isFavorites(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Shared Files** route is activated.
|
||||
* JSON ref: `app.navigation.isSharedFiles`
|
||||
*/
|
||||
export function isSharedFiles(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/shared') && !isPreview(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the activated route is not **Shared Files**.
|
||||
* JSON ref: `app.navigation.isNotSharedFiles`
|
||||
*/
|
||||
export function isNotSharedFiles(context: RuleContext): boolean {
|
||||
return !isSharedFiles(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Trashcan** route is activated.
|
||||
* JSON ref: `app.navigation.isTrashcan`
|
||||
*/
|
||||
export function isTrashcan(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/trashcan');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the activated route is not **Trashcan**.
|
||||
* JSON ref: `app.navigation.isNotTrashcan`
|
||||
*/
|
||||
export function isNotTrashcan(context: RuleContext): boolean {
|
||||
return !isTrashcan(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Personal Files** route is activated.
|
||||
* JSON ref: `app.navigation.isPersonalFiles`
|
||||
*/
|
||||
export function isPersonalFiles(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/personal-files');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Library Files** route is activated.
|
||||
* JSON ref: `app.navigation.isLibraryFiles`
|
||||
*/
|
||||
export function isLibraryFiles(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/libraries');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Library Files** or **Library Search Result** route is activated.
|
||||
* JSON ref: `app.navigation.isLibraryFiles`
|
||||
*/
|
||||
export function isLibraries(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return (
|
||||
url && (url.endsWith('/libraries') || url.startsWith('/search-libraries'))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the activated route is neither **Libraries** nor **Library Search Results**.
|
||||
* JSON ref: `app.navigation.isNotLibraries`
|
||||
*/
|
||||
export function isNotLibraries(context: RuleContext): boolean {
|
||||
return !isLibraries(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Recent Files** route is activated.
|
||||
* JSON ref: `app.navigation.isRecentFiles`
|
||||
*/
|
||||
export function isRecentFiles(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/recent-files');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the activated route is not **Recent Files**.
|
||||
* JSON ref: `app.navigation.isNotRecentFiles`
|
||||
*/
|
||||
export function isNotRecentFiles(context: RuleContext): boolean {
|
||||
return !isRecentFiles(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Search Results** route is activated.
|
||||
* JSON ref: `app.navigation.isSearchResults`
|
||||
*/
|
||||
export function isSearchResults(
|
||||
context: RuleContext /*,
|
||||
...args: RuleParameter[]*/
|
||||
): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/search');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the activated route is not **Search Results**.
|
||||
* JSON ref: `app.navigation.isNotSearchResults`
|
||||
*/
|
||||
export function isNotSearchResults(context: RuleContext): boolean {
|
||||
return !isSearchResults(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Shared Preview** route is activated.
|
||||
* JSON ref: `app.navigation.isSharedPreview`
|
||||
*/
|
||||
export function isSharedPreview(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/shared/preview/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Favorites Preview** route is activated.
|
||||
* JSON ref: `app.navigation.isFavoritesPreview`
|
||||
*/
|
||||
export function isFavoritesPreview(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/favorites/preview/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a **Shared File Preview** route is activated.
|
||||
* JSON ref: `app.navigation.isFavoritesPreview`
|
||||
*/
|
||||
export function isSharedFileViewer(context: RuleContext): boolean {
|
||||
const { url } = context.navigation;
|
||||
return url && url.startsWith('/preview/s/');
|
||||
}
|
28
projects/aca-shared/rules/src/public_api.ts
Normal file
28
projects/aca-shared/rules/src/public_api.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export * from './app.rules';
|
||||
export * from './navigation.rules';
|
||||
export * from './repository.rules';
|
34
projects/aca-shared/rules/src/repository.rules.ts
Normal file
34
projects/aca-shared/rules/src/repository.rules.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
/*!
|
||||
* @license
|
||||
* Alfresco Example Content Application
|
||||
*
|
||||
* Copyright (C) 2005 - 2019 Alfresco Software Limited
|
||||
*
|
||||
* This file is part of the Alfresco Example Content Application.
|
||||
* If the software was purchased under a paid Alfresco license, the terms of
|
||||
* the paid license agreement will prevail. Otherwise, the software is
|
||||
* provided under the following open source license terms:
|
||||
*
|
||||
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { RuleContext } from '@alfresco/adf-extensions';
|
||||
|
||||
/**
|
||||
* Checks if the quick share repository option is enabled or not.
|
||||
* JSON ref: `repository.isQuickShareEnabled`
|
||||
*/
|
||||
export function hasQuickShareEnabled(context: RuleContext): boolean {
|
||||
return context.repository.status.isQuickShareEnabled;
|
||||
}
|
Reference in New Issue
Block a user