mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
add missing typings to code (#1050)
* remove unused parameters * add missing types * add missing typing information * fix tests * restore old code
This commit is contained in:
parent
04cdc1dadd
commit
3a4cff505f
@ -77,22 +77,24 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.alfrescoApiService.getInstance().on('error', error => {
|
this.alfrescoApiService
|
||||||
if (error.status === 401) {
|
.getInstance()
|
||||||
if (!this.authenticationService.isLoggedIn()) {
|
.on('error', (error: { status: number }) => {
|
||||||
this.store.dispatch(new CloseModalDialogsAction());
|
if (error.status === 401) {
|
||||||
|
if (!this.authenticationService.isLoggedIn()) {
|
||||||
|
this.store.dispatch(new CloseModalDialogsAction());
|
||||||
|
|
||||||
let redirectUrl = this.route.snapshot.queryParams['redirectUrl'];
|
let redirectUrl = this.route.snapshot.queryParams['redirectUrl'];
|
||||||
if (!redirectUrl) {
|
if (!redirectUrl) {
|
||||||
redirectUrl = this.router.url;
|
redirectUrl = this.router.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.router.navigate(['/login'], {
|
||||||
|
queryParams: { redirectUrl: redirectUrl }
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.router.navigate(['/login'], {
|
|
||||||
queryParams: { redirectUrl: redirectUrl }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
this.loadAppSettings();
|
this.loadAppSettings();
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ export class ContextMenuItemComponent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
trackById(index: number, obj: { id: string }) {
|
trackById(_: number, obj: { id: string }) {
|
||||||
return obj.id;
|
return obj.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ export class ContextMenuComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
setTimeout(() => this.trigger.openMenu(), 0);
|
setTimeout(() => this.trigger.openMenu(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
trackById(index: number, obj: { id: string }) {
|
trackById(_: number, obj: { id: string }) {
|
||||||
return obj.id;
|
return obj.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ export class ContextActionsDirective implements OnInit, OnDestroy {
|
|||||||
return this.findAncestor(<Element>event.target, 'adf-datatable-cell');
|
return this.findAncestor(<Element>event.target, 'adf-datatable-cell');
|
||||||
}
|
}
|
||||||
|
|
||||||
private isSelected(target): boolean {
|
private isSelected(target: Element): boolean {
|
||||||
if (!target) {
|
if (!target) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,9 @@ export class ContextMenuService {
|
|||||||
|
|
||||||
open(config: ContextmenuOverlayConfig) {
|
open(config: ContextmenuOverlayConfig) {
|
||||||
const overlay = this.createOverlay(config);
|
const overlay = this.createOverlay(config);
|
||||||
|
|
||||||
const overlayRef = new ContextMenuOverlayRef(overlay);
|
const overlayRef = new ContextMenuOverlayRef(overlay);
|
||||||
|
|
||||||
this.attachDialogContainer(overlay, config, overlayRef);
|
this.attachDialogContainer(overlay, overlayRef);
|
||||||
|
|
||||||
return overlayRef;
|
return overlayRef;
|
||||||
}
|
}
|
||||||
@ -28,10 +27,9 @@ export class ContextMenuService {
|
|||||||
|
|
||||||
private attachDialogContainer(
|
private attachDialogContainer(
|
||||||
overlay: OverlayRef,
|
overlay: OverlayRef,
|
||||||
config: ContextmenuOverlayConfig,
|
|
||||||
contextmenuOverlayRef: ContextMenuOverlayRef
|
contextmenuOverlayRef: ContextMenuOverlayRef
|
||||||
) {
|
) {
|
||||||
const injector = this.createInjector(config, contextmenuOverlayRef);
|
const injector = this.createInjector(contextmenuOverlayRef);
|
||||||
|
|
||||||
const containerPortal = new ComponentPortal(
|
const containerPortal = new ComponentPortal(
|
||||||
ContextMenuComponent,
|
ContextMenuComponent,
|
||||||
@ -46,7 +44,6 @@ export class ContextMenuService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private createInjector(
|
private createInjector(
|
||||||
config: ContextmenuOverlayConfig,
|
|
||||||
contextmenuOverlayRef: ContextMenuOverlayRef
|
contextmenuOverlayRef: ContextMenuOverlayRef
|
||||||
): PortalInjector {
|
): PortalInjector {
|
||||||
const injectionTokens = new WeakMap();
|
const injectionTokens = new WeakMap();
|
||||||
|
@ -74,7 +74,7 @@ export class CreateMenuComponent implements OnInit, OnDestroy {
|
|||||||
this.onDestroy$.complete();
|
this.onDestroy$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
trackById(index: number, obj: { id: string }) {
|
trackById(_: number, obj: { id: string }) {
|
||||||
return obj.id;
|
return obj.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import { PageComponent } from '../page.component';
|
|||||||
import { ContentApiService } from '../../services/content-api.service';
|
import { ContentApiService } from '../../services/content-api.service';
|
||||||
import { AppExtensionService } from '../../extensions/extension.service';
|
import { AppExtensionService } from '../../extensions/extension.service';
|
||||||
import { map, debounceTime } from 'rxjs/operators';
|
import { map, debounceTime } from 'rxjs/operators';
|
||||||
import { FileUploadEvent, UploadService } from '@alfresco/adf-core';
|
import { UploadService } from '@alfresco/adf-core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './favorites.component.html'
|
templateUrl: './favorites.component.html'
|
||||||
@ -67,10 +67,10 @@ export class FavoritesComponent extends PageComponent implements OnInit {
|
|||||||
this.subscriptions = this.subscriptions.concat([
|
this.subscriptions = this.subscriptions.concat([
|
||||||
this.uploadService.fileUploadComplete
|
this.uploadService.fileUploadComplete
|
||||||
.pipe(debounceTime(300))
|
.pipe(debounceTime(300))
|
||||||
.subscribe(file => this.onFileUploadedEvent(file)),
|
.subscribe(_ => this.reload()),
|
||||||
this.uploadService.fileUploadDeleted
|
this.uploadService.fileUploadDeleted
|
||||||
.pipe(debounceTime(300))
|
.pipe(debounceTime(300))
|
||||||
.subscribe(file => this.onFileUploadedEvent(file)),
|
.subscribe(_ => this.reload()),
|
||||||
|
|
||||||
this.breakpointObserver
|
this.breakpointObserver
|
||||||
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
||||||
@ -116,8 +116,4 @@ export class FavoritesComponent extends PageComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private onFileUploadedEvent(event: FileUploadEvent) {
|
|
||||||
this.reload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ import { SetCurrentFolderAction } from '../../store/actions';
|
|||||||
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
||||||
import { debounceTime, takeUntil } from 'rxjs/operators';
|
import { debounceTime, takeUntil } from 'rxjs/operators';
|
||||||
import { isAdmin } from '../../store/selectors/app.selectors';
|
import { isAdmin } from '../../store/selectors/app.selectors';
|
||||||
|
import { ShareDataRow } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './files.component.html'
|
templateUrl: './files.component.html'
|
||||||
@ -199,9 +200,10 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
displayFolderParent(filePath = '', index) {
|
displayFolderParent(filePath = '', index: number) {
|
||||||
const parentName = filePath.split('/')[index];
|
const parentName = filePath.split('/')[index];
|
||||||
const currentFoldersDisplayed: any = this.documentList.data.getRows() || [];
|
const currentFoldersDisplayed =
|
||||||
|
<ShareDataRow[]>this.documentList.data.getRows() || [];
|
||||||
|
|
||||||
const alreadyDisplayedParentFolder = currentFoldersDisplayed.find(
|
const alreadyDisplayedParentFolder = currentFoldersDisplayed.find(
|
||||||
row => row.node.entry.isFolder && row.node.entry.name === parentName
|
row => row.node.entry.isFolder && row.node.entry.name === parentName
|
||||||
|
@ -70,7 +70,7 @@ export class AppHeaderComponent implements OnInit {
|
|||||||
this.actions = this.appExtensions.getHeaderActions();
|
this.actions = this.appExtensions.getHeaderActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
trackByActionId(index: number, action: ContentActionRef) {
|
trackByActionId(_: number, action: ContentActionRef) {
|
||||||
return action.id;
|
return action.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ export class LibraryMetadataFormComponent
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getVisibilityLabel(value) {
|
getVisibilityLabel(value: string) {
|
||||||
return this.libraryType.find(type => type.value === value).label;
|
return this.libraryType.find(type => type.value === value).label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ export class AppLayoutComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onExpanded(state) {
|
onExpanded(state: boolean) {
|
||||||
if (
|
if (
|
||||||
!this.minimizeSidenav &&
|
!this.minimizeSidenav &&
|
||||||
this.appConfigService.get('sideNav.preserveState')
|
this.appConfigService.get('sideNav.preserveState')
|
||||||
|
@ -131,11 +131,11 @@ export abstract class PageComponent implements OnInit, OnDestroy {
|
|||||||
this.store.dispatch(new ReloadDocumentListAction());
|
this.store.dispatch(new ReloadDocumentListAction());
|
||||||
}
|
}
|
||||||
|
|
||||||
trackByActionId(index: number, action: ContentActionRef) {
|
trackByActionId(_: number, action: ContentActionRef) {
|
||||||
return action.id;
|
return action.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
trackById(index: number, obj: { id: string }) {
|
trackById(_: number, obj: { id: string }) {
|
||||||
return obj.id;
|
return obj.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
: 'PERMISSIONS.DIALOG.INHERIT_PERMISSIONS_BUTTON') | translate
|
: 'PERMISSIONS.DIALOG.INHERIT_PERMISSIONS_BUTTON') | translate
|
||||||
}}
|
}}
|
||||||
</button>
|
</button>
|
||||||
<button mat-button (click)="openAddPermissionDialog($event)">
|
<button mat-button (click)="openAddPermissionDialog()">
|
||||||
{{ 'PERMISSIONS.DIALOG.ADD_USER_OR_GROUP' | translate }}
|
{{ 'PERMISSIONS.DIALOG.ADD_USER_OR_GROUP' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,7 +77,7 @@ export class PermissionsManagerComponent implements OnInit {
|
|||||||
this.permissionList.reload();
|
this.permissionList.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
openAddPermissionDialog(event: Event) {
|
openAddPermissionDialog() {
|
||||||
this.nodePermissionDialogService
|
this.nodePermissionDialogService
|
||||||
.updateNodePermissionByDialog(this.nodeId)
|
.updateNodePermissionByDialog(this.nodeId)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
@ -50,12 +50,10 @@ import { Subject } from 'rxjs';
|
|||||||
import { SearchLibrariesQueryBuilderService } from '../search-libraries-results/search-libraries-query-builder.service';
|
import { SearchLibrariesQueryBuilderService } from '../search-libraries-results/search-libraries-query-builder.service';
|
||||||
import { MatMenuTrigger } from '@angular/material';
|
import { MatMenuTrigger } from '@angular/material';
|
||||||
import { AppConfigService } from '@alfresco/adf-core';
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
|
import {
|
||||||
export enum SearchOptionIds {
|
SearchOptionModel,
|
||||||
Files = 'content',
|
SearchOptionIds
|
||||||
Folders = 'folder',
|
} from '../../../store/models/searchOption.model';
|
||||||
Libraries = 'libraries'
|
|
||||||
}
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'aca-search-input',
|
selector: 'aca-search-input',
|
||||||
@ -69,10 +67,10 @@ export class SearchInputComponent implements OnInit, OnDestroy {
|
|||||||
hasNewChange = false;
|
hasNewChange = false;
|
||||||
navigationTimer: any;
|
navigationTimer: any;
|
||||||
has400LibraryError = false;
|
has400LibraryError = false;
|
||||||
searchOnChange;
|
searchOnChange: boolean;
|
||||||
|
|
||||||
searchedWord = null;
|
searchedWord: string = null;
|
||||||
searchOptions: Array<any> = [
|
searchOptions: Array<SearchOptionModel> = [
|
||||||
{
|
{
|
||||||
id: SearchOptionIds.Files,
|
id: SearchOptionIds.Files,
|
||||||
key: 'SEARCH.INPUT.FILES',
|
key: 'SEARCH.INPUT.FILES',
|
||||||
|
@ -28,6 +28,14 @@ import { Injectable } from '@angular/core';
|
|||||||
import { SitePaging } from '@alfresco/js-api';
|
import { SitePaging } from '@alfresco/js-api';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
|
|
||||||
|
export interface LibrarySearchQuery {
|
||||||
|
term: string;
|
||||||
|
opts: {
|
||||||
|
skipCount: number;
|
||||||
|
maxItems: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@ -65,7 +73,7 @@ export class SearchLibrariesQueryBuilderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildQuery(): any {
|
buildQuery(): LibrarySearchQuery {
|
||||||
const query = this.userQuery;
|
const query = this.userQuery;
|
||||||
if (query && query.length > 1) {
|
if (query && query.length > 1) {
|
||||||
const resultQuery = {
|
const resultQuery = {
|
||||||
@ -80,7 +88,7 @@ export class SearchLibrariesQueryBuilderService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private findLibraries(libraryQuery): Promise<SitePaging> {
|
private findLibraries(libraryQuery: LibrarySearchQuery): Promise<SitePaging> {
|
||||||
return this.alfrescoApiService
|
return this.alfrescoApiService
|
||||||
.getInstance()
|
.getInstance()
|
||||||
.core.queriesApi.findSites(libraryQuery.term, libraryQuery.opts)
|
.core.queriesApi.findSites(libraryQuery.term, libraryQuery.opts)
|
||||||
|
@ -108,7 +108,7 @@ export class SearchResultsRowComponent implements OnInit {
|
|||||||
this.store.dispatch(new NavigateToFolder(this.node));
|
this.store.dispatch(new NavigateToFolder(this.node));
|
||||||
}
|
}
|
||||||
|
|
||||||
private getValue(path) {
|
private getValue(path: string) {
|
||||||
return path
|
return path
|
||||||
.replace('["', '.')
|
.replace('["', '.')
|
||||||
.replace('"]', '')
|
.replace('"]', '')
|
||||||
|
@ -61,10 +61,10 @@ export class SharedFilesComponent extends PageComponent implements OnInit {
|
|||||||
|
|
||||||
this.uploadService.fileUploadComplete
|
this.uploadService.fileUploadComplete
|
||||||
.pipe(debounceTime(300))
|
.pipe(debounceTime(300))
|
||||||
.subscribe(file => this.reload()),
|
.subscribe(_ => this.reload()),
|
||||||
this.uploadService.fileUploadDeleted
|
this.uploadService.fileUploadDeleted
|
||||||
.pipe(debounceTime(300))
|
.pipe(debounceTime(300))
|
||||||
.subscribe(file => this.reload()),
|
.subscribe(_ => this.reload()),
|
||||||
|
|
||||||
this.breakpointObserver
|
this.breakpointObserver
|
||||||
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
||||||
|
@ -54,7 +54,7 @@ export class SharedLinkViewComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
trackByActionId(index: number, action: ContentActionRef) {
|
trackByActionId(_: number, action: ContentActionRef) {
|
||||||
return action.id;
|
return action.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ export class ShareDialogComponent implements OnInit, OnDestroy {
|
|||||||
properties['qshare:expiryDate'] = date ? date.toDate() : null;
|
properties['qshare:expiryDate'] = date ? date.toDate() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private showError(response) {
|
private showError(response: { message: any }) {
|
||||||
let message;
|
let message;
|
||||||
const statusCode = JSON.parse(response.message).error.statusCode;
|
const statusCode = JSON.parse(response.message).error.statusCode;
|
||||||
if (statusCode === 403) {
|
if (statusCode === 403) {
|
||||||
|
@ -44,12 +44,12 @@ export class ToggleSharedComponent implements OnInit {
|
|||||||
this.selection$ = this.store.select(appSelection);
|
this.selection$ = this.store.select(appSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
isShared(selection) {
|
isShared(selection: SelectionState) {
|
||||||
// workaround for shared files
|
// workaround for shared files
|
||||||
if (
|
if (
|
||||||
selection.first &&
|
selection.first &&
|
||||||
selection.first.entry &&
|
selection.first.entry &&
|
||||||
selection.first.entry.sharedByUser
|
(<any>selection.first.entry).sharedByUser
|
||||||
) {
|
) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ export class ToggleSharedComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
editSharedNode(selection) {
|
editSharedNode(selection: SelectionState) {
|
||||||
this.store.dispatch(new ShareNodeAction(selection.first));
|
this.store.dispatch(new ShareNodeAction(selection.first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ export class SidenavComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
trackById(index: number, obj: { id: string }) {
|
trackById(_: number, obj: { id: string }) {
|
||||||
return obj.id;
|
return obj.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,10 @@ import {
|
|||||||
SnackbarInfoAction
|
SnackbarInfoAction
|
||||||
} from '../../../store/actions/snackbar.actions';
|
} from '../../../store/actions/snackbar.actions';
|
||||||
import { SetSelectedNodesAction } from '../../../store/actions/node.actions';
|
import { SetSelectedNodesAction } from '../../../store/actions/node.actions';
|
||||||
|
import {
|
||||||
|
LibraryMembershipToggleEvent,
|
||||||
|
LibraryMembershipErrorEvent
|
||||||
|
} from '../../../directives/library-membership.directive';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-toggle-join-library-button',
|
selector: 'app-toggle-join-library-button',
|
||||||
@ -72,7 +76,7 @@ export class ToggleJoinLibraryButtonComponent {
|
|||||||
this.selection$ = this.store.select(appSelection);
|
this.selection$ = this.store.select(appSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
onToggleEvent(event) {
|
onToggleEvent(event: LibraryMembershipToggleEvent) {
|
||||||
this.store.dispatch(new SnackbarInfoAction(event.i18nKey));
|
this.store.dispatch(new SnackbarInfoAction(event.i18nKey));
|
||||||
|
|
||||||
if (event.shouldReload) {
|
if (event.shouldReload) {
|
||||||
@ -89,7 +93,7 @@ export class ToggleJoinLibraryButtonComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onErrorEvent(event) {
|
onErrorEvent(event: LibraryMembershipErrorEvent) {
|
||||||
this.store.dispatch(new SnackbarErrorAction(event.i18nKey));
|
this.store.dispatch(new SnackbarErrorAction(event.i18nKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ describe('ToggleJoinLibraryComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should dispatch `SnackbarErrorAction` action on error', () => {
|
it('should dispatch `SnackbarErrorAction` action on error', () => {
|
||||||
const event = { event: {}, i18nKey: 'ERROR_i18nKey' };
|
const event = { error: {}, i18nKey: 'ERROR_i18nKey' };
|
||||||
component.onErrorEvent(event);
|
component.onErrorEvent(event);
|
||||||
|
|
||||||
expect(storeMock.dispatch).toHaveBeenCalledWith(
|
expect(storeMock.dispatch).toHaveBeenCalledWith(
|
||||||
@ -115,7 +115,7 @@ describe('ToggleJoinLibraryComponent', () => {
|
|||||||
expect(contentManagementService.libraryJoined.next).toHaveBeenCalled();
|
expect(contentManagementService.libraryJoined.next).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
const event = { shouldReload: true };
|
const event = { shouldReload: true, i18nKey: null };
|
||||||
component.onToggleEvent(event);
|
component.onToggleEvent(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ describe('ToggleJoinLibraryComponent', () => {
|
|||||||
).toHaveBeenCalled();
|
).toHaveBeenCalled();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
const event = { shouldReload: false };
|
const event = { shouldReload: false, i18nKey: null };
|
||||||
component.onToggleEvent(event);
|
component.onToggleEvent(event);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -52,7 +52,7 @@ export class ToolbarMenuItemComponent {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
trackById(index: number, obj: { id: string }) {
|
trackById(_: number, obj: { id: string }) {
|
||||||
return obj.id;
|
return obj.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ export class ToolbarMenuComponent {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
trackById(index: number, obj: { id: string }) {
|
trackById(_: number, obj: { id: string }) {
|
||||||
return obj.id;
|
return obj.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,24 @@ import {
|
|||||||
HostListener,
|
HostListener,
|
||||||
Input,
|
Input,
|
||||||
OnChanges,
|
OnChanges,
|
||||||
Output
|
Output,
|
||||||
|
SimpleChanges
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { SiteEntry, SiteMembershipRequestBody } from '@alfresco/js-api';
|
import { SiteEntry, SiteMembershipRequestBody } from '@alfresco/js-api';
|
||||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||||
import { BehaviorSubject, from } from 'rxjs';
|
import { BehaviorSubject, from } from 'rxjs';
|
||||||
|
|
||||||
|
export interface LibraryMembershipToggleEvent {
|
||||||
|
updatedEntry?: any;
|
||||||
|
shouldReload: boolean;
|
||||||
|
i18nKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LibraryMembershipErrorEvent {
|
||||||
|
error: any;
|
||||||
|
i18nKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[acaLibraryMembership]',
|
selector: '[acaLibraryMembership]',
|
||||||
exportAs: 'libraryMembership'
|
exportAs: 'libraryMembership'
|
||||||
@ -50,8 +62,12 @@ export class LibraryMembershipDirective implements OnChanges {
|
|||||||
@Input('acaLibraryMembership')
|
@Input('acaLibraryMembership')
|
||||||
selection: SiteEntry = null;
|
selection: SiteEntry = null;
|
||||||
|
|
||||||
@Output() toggle: EventEmitter<any> = new EventEmitter();
|
@Output() toggle: EventEmitter<
|
||||||
@Output() error: EventEmitter<any> = new EventEmitter();
|
LibraryMembershipToggleEvent
|
||||||
|
> = new EventEmitter();
|
||||||
|
@Output() error: EventEmitter<
|
||||||
|
LibraryMembershipErrorEvent
|
||||||
|
> = new EventEmitter();
|
||||||
|
|
||||||
@HostListener('click')
|
@HostListener('click')
|
||||||
onClick() {
|
onClick() {
|
||||||
@ -60,7 +76,7 @@ export class LibraryMembershipDirective implements OnChanges {
|
|||||||
|
|
||||||
constructor(private alfrescoApiService: AlfrescoApiService) {}
|
constructor(private alfrescoApiService: AlfrescoApiService) {}
|
||||||
|
|
||||||
ngOnChanges(changes) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (
|
if (
|
||||||
!changes.selection.currentValue ||
|
!changes.selection.currentValue ||
|
||||||
!changes.selection.currentValue.entry
|
!changes.selection.currentValue.entry
|
||||||
|
@ -40,7 +40,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isWriteLocked(context, null)).toBe(true);
|
expect(app.isWriteLocked(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if lock type is not set', () => {
|
it('should return [false] if lock type is not set', () => {
|
||||||
@ -54,20 +54,20 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isWriteLocked(context, null)).toBe(false);
|
expect(app.isWriteLocked(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if selection not present', () => {
|
it('should return [false] if selection not present', () => {
|
||||||
const context: any = {};
|
const context: any = {};
|
||||||
|
|
||||||
expect(app.isWriteLocked(context, null)).toBe(false);
|
expect(app.isWriteLocked(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('hasLockedFiles', () => {
|
describe('hasLockedFiles', () => {
|
||||||
it('should return [false] if selection not present', () => {
|
it('should return [false] if selection not present', () => {
|
||||||
const context: any = {};
|
const context: any = {};
|
||||||
expect(app.hasLockedFiles(context, null)).toBe(false);
|
expect(app.hasLockedFiles(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if nodes not present', () => {
|
it('should return [false] if nodes not present', () => {
|
||||||
@ -77,7 +77,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.hasLockedFiles(context, null)).toBe(false);
|
expect(app.hasLockedFiles(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if no files selected', () => {
|
it('should return [false] if no files selected', () => {
|
||||||
@ -98,7 +98,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.hasLockedFiles(context, null)).toBe(false);
|
expect(app.hasLockedFiles(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [true] when one of files is locked', () => {
|
it('should return [true] when one of files is locked', () => {
|
||||||
@ -121,7 +121,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.hasLockedFiles(context, null)).toBe(true);
|
expect(app.hasLockedFiles(context)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -148,14 +148,14 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.hasLockedFiles(context, null)).toBe(true);
|
expect(app.hasLockedFiles(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('canUpdateSelectedNode', () => {
|
describe('canUpdateSelectedNode', () => {
|
||||||
it('should return [false] if selection not preset', () => {
|
it('should return [false] if selection not preset', () => {
|
||||||
const context: any = {};
|
const context: any = {};
|
||||||
|
|
||||||
expect(app.canUpdateSelectedNode(context, null)).toBe(false);
|
expect(app.canUpdateSelectedNode(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if selection is empty', () => {
|
it('should return [false] if selection is empty', () => {
|
||||||
@ -165,7 +165,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUpdateSelectedNode(context, null)).toBe(false);
|
expect(app.canUpdateSelectedNode(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if first selection is not a file', () => {
|
it('should return [false] if first selection is not a file', () => {
|
||||||
@ -183,7 +183,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUpdateSelectedNode(context, null)).toBe(false);
|
expect(app.canUpdateSelectedNode(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if the file is locked', () => {
|
it('should return [false] if the file is locked', () => {
|
||||||
@ -210,7 +210,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUpdateSelectedNode(context, null)).toBe(false);
|
expect(app.canUpdateSelectedNode(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should evaluate allowable operation for the file', () => {
|
it('should evaluate allowable operation for the file', () => {
|
||||||
@ -237,7 +237,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUpdateSelectedNode(context, null)).toBe(true);
|
expect(app.canUpdateSelectedNode(context)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -264,7 +264,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
expect(app.canUploadVersion(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if other user has locked it previously', () => {
|
it('should return [false] if other user has locked it previously', () => {
|
||||||
@ -289,7 +289,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUploadVersion(context, null)).toBe(false);
|
expect(app.canUploadVersion(context)).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should check the [update] operation when no write lock present', () => {
|
it('should check the [update] operation when no write lock present', () => {
|
||||||
@ -318,7 +318,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
expect(app.canUploadVersion(context)).toBe(true);
|
||||||
expect(checked).toBe(true);
|
expect(checked).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -329,7 +329,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
expect(app.canUploadVersion(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [true] if route is `/favorites`', () => {
|
it('should return [true] if route is `/favorites`', () => {
|
||||||
@ -339,7 +339,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
expect(app.canUploadVersion(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [true] if route is `/shared`', () => {
|
it('should return [true] if route is `/shared`', () => {
|
||||||
@ -349,7 +349,7 @@ describe('app.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.canUploadVersion(context, null)).toBe(true);
|
expect(app.canUploadVersion(context)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RuleContext, RuleParameter } from '@alfresco/adf-extensions';
|
import { RuleContext } from '@alfresco/adf-extensions';
|
||||||
import {
|
import {
|
||||||
isNotTrashcan,
|
isNotTrashcan,
|
||||||
isNotLibraries,
|
isNotLibraries,
|
||||||
@ -39,16 +39,9 @@ import {
|
|||||||
* Checks if user can mark selected nodes as **Favorite**.
|
* Checks if user can mark selected nodes as **Favorite**.
|
||||||
* JSON ref: `app.selection.canAddFavorite`
|
* JSON ref: `app.selection.canAddFavorite`
|
||||||
*/
|
*/
|
||||||
export function canAddFavorite(
|
export function canAddFavorite(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (!context.selection.isEmpty) {
|
if (!context.selection.isEmpty) {
|
||||||
if (
|
if (isFavorites(context) || isLibraries(context) || isTrashcan(context)) {
|
||||||
isFavorites(context, ...args) ||
|
|
||||||
isLibraries(context, ...args) ||
|
|
||||||
isTrashcan(context, ...args)
|
|
||||||
) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return context.selection.nodes.some(node => !node.entry.isFavorite);
|
return context.selection.nodes.some(node => !node.entry.isFavorite);
|
||||||
@ -60,12 +53,9 @@ export function canAddFavorite(
|
|||||||
* Checks if user can un-mark selected nodes as **Favorite**.
|
* Checks if user can un-mark selected nodes as **Favorite**.
|
||||||
* JSON ref: `app.selection.canRemoveFavorite`
|
* JSON ref: `app.selection.canRemoveFavorite`
|
||||||
*/
|
*/
|
||||||
export function canRemoveFavorite(
|
export function canRemoveFavorite(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
if (!context.selection.isEmpty && !isTrashcan(context)) {
|
||||||
...args: RuleParameter[]
|
if (isFavorites(context)) {
|
||||||
): boolean {
|
|
||||||
if (!context.selection.isEmpty && !isTrashcan(context, ...args)) {
|
|
||||||
if (isFavorites(context, ...args)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return context.selection.nodes.every(node => node.entry.isFavorite);
|
return context.selection.nodes.every(node => node.entry.isFavorite);
|
||||||
@ -77,11 +67,8 @@ export function canRemoveFavorite(
|
|||||||
* Checks if user can share selected file.
|
* Checks if user can share selected file.
|
||||||
* JSON ref: `app.selection.file.canShare`
|
* JSON ref: `app.selection.file.canShare`
|
||||||
*/
|
*/
|
||||||
export function canShareFile(
|
export function canShareFile(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
if (isNotTrashcan(context) && context.selection.file) {
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (isNotTrashcan(context, ...args) && context.selection.file) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -91,16 +78,13 @@ export function canShareFile(
|
|||||||
* Checks if the selected file is already shared.
|
* Checks if the selected file is already shared.
|
||||||
* JSON ref: `app.selection.file.isShared`
|
* JSON ref: `app.selection.file.isShared`
|
||||||
*/
|
*/
|
||||||
export function isShared(
|
export function isShared(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
if (isSharedFiles(context) && !context.selection.isEmpty) {
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (isSharedFiles(context, ...args) && !context.selection.isEmpty) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(isNotTrashcan(context, ...args),
|
(isNotTrashcan(context),
|
||||||
!context.selection.isEmpty && context.selection.file)
|
!context.selection.isEmpty && context.selection.file)
|
||||||
) {
|
) {
|
||||||
return !!(
|
return !!(
|
||||||
@ -117,31 +101,28 @@ export function isShared(
|
|||||||
* Checks if user can delete selected nodes.
|
* Checks if user can delete selected nodes.
|
||||||
* JSON ref: `app.selection.canDelete`
|
* JSON ref: `app.selection.canDelete`
|
||||||
*/
|
*/
|
||||||
export function canDeleteSelection(
|
export function canDeleteSelection(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (
|
if (
|
||||||
isNotTrashcan(context, ...args) &&
|
isNotTrashcan(context) &&
|
||||||
isNotLibraries(context, ...args) &&
|
isNotLibraries(context) &&
|
||||||
isNotSearchResults(context, ...args) &&
|
isNotSearchResults(context) &&
|
||||||
!context.selection.isEmpty
|
!context.selection.isEmpty
|
||||||
) {
|
) {
|
||||||
if (hasLockedFiles(context, ...args)) {
|
if (hasLockedFiles(context)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// temp workaround for Search api
|
// temp workaround for Search api
|
||||||
if (isFavorites(context, ...args)) {
|
if (isFavorites(context)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPreview(context, ...args)) {
|
if (isPreview(context)) {
|
||||||
return context.permissions.check(context.selection.nodes, ['delete']);
|
return context.permissions.check(context.selection.nodes, ['delete']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// workaround for Shared Files
|
// workaround for Shared Files
|
||||||
if (isSharedFiles(context, ...args)) {
|
if (isSharedFiles(context)) {
|
||||||
return context.permissions.check(context.selection.nodes, ['delete'], {
|
return context.permissions.check(context.selection.nodes, ['delete'], {
|
||||||
target: 'allowableOperationsOnTarget'
|
target: 'allowableOperationsOnTarget'
|
||||||
});
|
});
|
||||||
@ -156,10 +137,7 @@ export function canDeleteSelection(
|
|||||||
* Checks if user can un-share selected nodes.
|
* Checks if user can un-share selected nodes.
|
||||||
* JSON ref: `app.selection.canUnshare`
|
* JSON ref: `app.selection.canUnshare`
|
||||||
*/
|
*/
|
||||||
export function canUnshareNodes(
|
export function canUnshareNodes(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (!context.selection.isEmpty) {
|
if (!context.selection.isEmpty) {
|
||||||
return context.permissions.check(context.selection.nodes, ['delete'], {
|
return context.permissions.check(context.selection.nodes, ['delete'], {
|
||||||
target: 'allowableOperationsOnTarget'
|
target: 'allowableOperationsOnTarget'
|
||||||
@ -172,10 +150,7 @@ export function canUnshareNodes(
|
|||||||
* Checks if user selected anything.
|
* Checks if user selected anything.
|
||||||
* JSON ref: `app.selection.notEmpty`
|
* JSON ref: `app.selection.notEmpty`
|
||||||
*/
|
*/
|
||||||
export function hasSelection(
|
export function hasSelection(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !context.selection.isEmpty;
|
return !context.selection.isEmpty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,10 +158,7 @@ export function hasSelection(
|
|||||||
* Checks if user can create a new folder with current path.
|
* Checks if user can create a new folder with current path.
|
||||||
* JSON ref: `app.navigation.folder.canCreate`
|
* JSON ref: `app.navigation.folder.canCreate`
|
||||||
*/
|
*/
|
||||||
export function canCreateFolder(
|
export function canCreateFolder(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { currentFolder } = context.navigation;
|
const { currentFolder } = context.navigation;
|
||||||
if (currentFolder) {
|
if (currentFolder) {
|
||||||
return context.permissions.check(currentFolder, ['create']);
|
return context.permissions.check(currentFolder, ['create']);
|
||||||
@ -198,10 +170,7 @@ export function canCreateFolder(
|
|||||||
* 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(
|
export function canUpload(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { currentFolder } = context.navigation;
|
const { currentFolder } = context.navigation;
|
||||||
if (currentFolder) {
|
if (currentFolder) {
|
||||||
return context.permissions.check(currentFolder, ['create']);
|
return context.permissions.check(currentFolder, ['create']);
|
||||||
@ -213,10 +182,7 @@ export function canUpload(
|
|||||||
* Checks if user can download selected nodes (either files or folders).
|
* Checks if user can download selected nodes (either files or folders).
|
||||||
* JSON ref: `app.selection.canDownload`
|
* JSON ref: `app.selection.canDownload`
|
||||||
*/
|
*/
|
||||||
export function canDownloadSelection(
|
export function canDownloadSelection(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (!context.selection.isEmpty) {
|
if (!context.selection.isEmpty) {
|
||||||
return context.selection.nodes.every((node: any) => {
|
return context.selection.nodes.every((node: any) => {
|
||||||
return (
|
return (
|
||||||
@ -232,10 +198,7 @@ export function canDownloadSelection(
|
|||||||
* Checks if user has selected a folder.
|
* Checks if user has selected a folder.
|
||||||
* JSON ref: `app.selection.folder`
|
* JSON ref: `app.selection.folder`
|
||||||
*/
|
*/
|
||||||
export function hasFolderSelected(
|
export function hasFolderSelected(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const folder = context.selection.folder;
|
const folder = context.selection.folder;
|
||||||
return folder ? true : false;
|
return folder ? true : false;
|
||||||
}
|
}
|
||||||
@ -244,10 +207,7 @@ export function hasFolderSelected(
|
|||||||
* Checks if user has selected a library (site).
|
* Checks if user has selected a library (site).
|
||||||
* JSON ref: `app.selection.library`
|
* JSON ref: `app.selection.library`
|
||||||
*/
|
*/
|
||||||
export function hasLibrarySelected(
|
export function hasLibrarySelected(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const library = context.selection.library;
|
const library = context.selection.library;
|
||||||
return library ? true : false;
|
return library ? true : false;
|
||||||
}
|
}
|
||||||
@ -256,10 +216,7 @@ export function hasLibrarySelected(
|
|||||||
* Checks if user has selected a **private** library (site)
|
* Checks if user has selected a **private** library (site)
|
||||||
* JSON ref: `app.selection.isPrivateLibrary`
|
* JSON ref: `app.selection.isPrivateLibrary`
|
||||||
*/
|
*/
|
||||||
export function isPrivateLibrary(
|
export function isPrivateLibrary(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const library = context.selection.library;
|
const library = context.selection.library;
|
||||||
return library
|
return library
|
||||||
? !!(
|
? !!(
|
||||||
@ -274,10 +231,7 @@ export function isPrivateLibrary(
|
|||||||
* Checks if the selected library has a **role** property defined.
|
* Checks if the selected library has a **role** property defined.
|
||||||
* JSON ref: `app.selection.hasLibraryRole`
|
* JSON ref: `app.selection.hasLibraryRole`
|
||||||
*/
|
*/
|
||||||
export function hasLibraryRole(
|
export function hasLibraryRole(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const library = context.selection.library;
|
const library = context.selection.library;
|
||||||
return library ? !!(library.entry && library.entry.role) : false;
|
return library ? !!(library.entry && library.entry.role) : false;
|
||||||
}
|
}
|
||||||
@ -286,21 +240,15 @@ export function hasLibraryRole(
|
|||||||
* Checks if the selected library has no **role** property defined.
|
* Checks if the selected library has no **role** property defined.
|
||||||
* JSON ref: `app.selection.hasNoLibraryRole`
|
* JSON ref: `app.selection.hasNoLibraryRole`
|
||||||
*/
|
*/
|
||||||
export function hasNoLibraryRole(
|
export function hasNoLibraryRole(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
return !hasLibraryRole(context);
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !hasLibraryRole(context, ...args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if user has selected a file.
|
* Checks if user has selected a file.
|
||||||
* JSON ref: `app.selection.file`
|
* JSON ref: `app.selection.file`
|
||||||
*/
|
*/
|
||||||
export function hasFileSelected(
|
export function hasFileSelected(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const file = context.selection.file;
|
const file = context.selection.file;
|
||||||
return file ? true : false;
|
return file ? true : false;
|
||||||
}
|
}
|
||||||
@ -309,14 +257,11 @@ export function hasFileSelected(
|
|||||||
* Checks if user can update the first selected node.
|
* Checks if user can update the first selected node.
|
||||||
* JSON ref: `app.selection.first.canUpdate`
|
* JSON ref: `app.selection.first.canUpdate`
|
||||||
*/
|
*/
|
||||||
export function canUpdateSelectedNode(
|
export function canUpdateSelectedNode(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (context.selection && !context.selection.isEmpty) {
|
if (context.selection && !context.selection.isEmpty) {
|
||||||
const node = context.selection.first;
|
const node = context.selection.first;
|
||||||
|
|
||||||
if (node.entry.isFile && hasLockedFiles(context, ...args)) {
|
if (node.entry.isFile && hasLockedFiles(context)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,15 +274,12 @@ export function canUpdateSelectedNode(
|
|||||||
* Checks if user can update the first selected folder.
|
* Checks if user can update the first selected folder.
|
||||||
* JSON ref: `app.selection.folder.canUpdate`
|
* JSON ref: `app.selection.folder.canUpdate`
|
||||||
*/
|
*/
|
||||||
export function canUpdateSelectedFolder(
|
export function canUpdateSelectedFolder(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { folder } = context.selection;
|
const { folder } = context.selection;
|
||||||
if (folder) {
|
if (folder) {
|
||||||
return (
|
return (
|
||||||
// workaround for Favorites Api
|
// workaround for Favorites Api
|
||||||
isFavorites(context, ...args) ||
|
isFavorites(context) ||
|
||||||
context.permissions.check(folder.entry, ['update'])
|
context.permissions.check(folder.entry, ['update'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -348,10 +290,7 @@ export function canUpdateSelectedFolder(
|
|||||||
* Checks if user has selected a **locked** file node.
|
* Checks if user has selected a **locked** file node.
|
||||||
* JSON ref: `app.selection.file.isLocked`
|
* JSON ref: `app.selection.file.isLocked`
|
||||||
*/
|
*/
|
||||||
export function hasLockedFiles(
|
export function hasLockedFiles(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (context && context.selection && context.selection.nodes) {
|
if (context && context.selection && context.selection.nodes) {
|
||||||
return context.selection.nodes.some(node => {
|
return context.selection.nodes.some(node => {
|
||||||
if (!node.entry.isFile) {
|
if (!node.entry.isFile) {
|
||||||
@ -373,10 +312,7 @@ export function hasLockedFiles(
|
|||||||
* Checks if the selected file has **write** or **read-only** locks specified.
|
* Checks if the selected file has **write** or **read-only** locks specified.
|
||||||
* JSON ref: `app.selection.file.isLocked`
|
* JSON ref: `app.selection.file.isLocked`
|
||||||
*/
|
*/
|
||||||
export function isWriteLocked(
|
export function isWriteLocked(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !!(
|
return !!(
|
||||||
context &&
|
context &&
|
||||||
context.selection &&
|
context.selection &&
|
||||||
@ -394,12 +330,9 @@ export function isWriteLocked(
|
|||||||
* and that current user is the owner of the lock.
|
* and that current user is the owner of the lock.
|
||||||
* JSON ref: `app.selection.file.isLockOwner`
|
* JSON ref: `app.selection.file.isLockOwner`
|
||||||
*/
|
*/
|
||||||
export function isUserWriteLockOwner(
|
export function isUserWriteLockOwner(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return (
|
return (
|
||||||
isWriteLocked(context, ...args) &&
|
isWriteLocked(context) &&
|
||||||
(context.selection.file.entry.properties['cm:lockOwner'] &&
|
(context.selection.file.entry.properties['cm:lockOwner'] &&
|
||||||
context.selection.file.entry.properties['cm:lockOwner'].id ===
|
context.selection.file.entry.properties['cm:lockOwner'].id ===
|
||||||
context.profile.id)
|
context.profile.id)
|
||||||
@ -410,28 +343,20 @@ export function isUserWriteLockOwner(
|
|||||||
* Checks if user can lock selected file.
|
* Checks if user can lock selected file.
|
||||||
* JSON ref: `app.selection.file.canLock`
|
* JSON ref: `app.selection.file.canLock`
|
||||||
*/
|
*/
|
||||||
export function canLockFile(
|
export function canLockFile(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
return !isWriteLocked(context) && canUpdateSelectedNode(context);
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return (
|
|
||||||
!isWriteLocked(context, ...args) && canUpdateSelectedNode(context, ...args)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if user can unlock selected file.
|
* Checks if user can unlock selected file.
|
||||||
* JSON ref: `app.selection.file.canLock`
|
* JSON ref: `app.selection.file.canLock`
|
||||||
*/
|
*/
|
||||||
export function canUnlockFile(
|
export function canUnlockFile(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { file } = context.selection;
|
const { file } = context.selection;
|
||||||
return (
|
return (
|
||||||
isWriteLocked(context, ...args) &&
|
isWriteLocked(context) &&
|
||||||
(context.permissions.check(file.entry, ['delete']) ||
|
(context.permissions.check(file.entry, ['delete']) ||
|
||||||
isUserWriteLockOwner(context, ...args))
|
isUserWriteLockOwner(context))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,15 +364,12 @@ export function canUnlockFile(
|
|||||||
* Checks if user can upload a new version of the file.
|
* Checks if user can upload a new version of the file.
|
||||||
* JSON ref: `app.selection.file.canUploadVersion`
|
* JSON ref: `app.selection.file.canUploadVersion`
|
||||||
*/
|
*/
|
||||||
export function canUploadVersion(
|
export function canUploadVersion(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
if (isFavorites(context) || isSharedFiles(context)) {
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
if (isFavorites(context, ...args) || isSharedFiles(context, ...args)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isWriteLocked(context, ...args)
|
return isWriteLocked(context)
|
||||||
? isUserWriteLockOwner(context, ...args)
|
? isUserWriteLockOwner(context)
|
||||||
: canUpdateSelectedNode(context, ...args);
|
: canUpdateSelectedNode(context);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isPreview(context, null)).toBe(true);
|
expect(app.isPreview(context)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isFavorites(context, null)).toBe(true);
|
expect(app.isFavorites(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if `/favorites` url contains `/preview/`', () => {
|
it('should return [false] if `/favorites` url contains `/preview/`', () => {
|
||||||
@ -56,7 +56,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isFavorites(context, null)).toBe(false);
|
expect(app.isFavorites(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isNotFavorites(context, null)).toBe(true);
|
expect(app.isNotFavorites(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url starts with `/favorites`', () => {
|
it('should return [false] if url starts with `/favorites`', () => {
|
||||||
@ -78,7 +78,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isNotFavorites(context, null)).toBe(false);
|
expect(app.isNotFavorites(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isSharedFiles(context, null)).toBe(true);
|
expect(app.isSharedFiles(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if `/shared` url contains `/preview/`', () => {
|
it('should return [false] if `/shared` url contains `/preview/`', () => {
|
||||||
@ -100,7 +100,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isSharedFiles(context, null)).toBe(false);
|
expect(app.isSharedFiles(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isNotSharedFiles(context, null)).toBe(true);
|
expect(app.isNotSharedFiles(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if path contains `/shared`', () => {
|
it('should return [false] if path contains `/shared`', () => {
|
||||||
@ -122,7 +122,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isNotSharedFiles(context, null)).toBe(false);
|
expect(app.isNotSharedFiles(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isTrashcan(context, null)).toBe(true);
|
expect(app.isTrashcan(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url does not start with `/trashcan`', () => {
|
it('should return [false] if url does not start with `/trashcan`', () => {
|
||||||
@ -144,7 +144,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isTrashcan(context, null)).toBe(false);
|
expect(app.isTrashcan(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isNotTrashcan(context, null)).toBe(true);
|
expect(app.isNotTrashcan(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url does start with `/trashcan`', () => {
|
it('should return [false] if url does start with `/trashcan`', () => {
|
||||||
@ -166,7 +166,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isNotTrashcan(context, null)).toBe(false);
|
expect(app.isNotTrashcan(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isPersonalFiles(context, null)).toBe(true);
|
expect(app.isPersonalFiles(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url does not start with `/personal-files`', () => {
|
it('should return [false] if url does not start with `/personal-files`', () => {
|
||||||
@ -188,7 +188,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isPersonalFiles(context, null)).toBe(false);
|
expect(app.isPersonalFiles(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isLibraries(context, null)).toBe(true);
|
expect(app.isLibraries(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [true] if url starts with `/search-libraries`', () => {
|
it('should return [true] if url starts with `/search-libraries`', () => {
|
||||||
@ -210,7 +210,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isLibraries(context, null)).toBe(true);
|
expect(app.isLibraries(context)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isNotLibraries(context, null)).toBe(true);
|
expect(app.isNotLibraries(context)).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isRecentFiles(context, null)).toBe(true);
|
expect(app.isRecentFiles(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url does not start with `/recent-files`', () => {
|
it('should return [false] if url does not start with `/recent-files`', () => {
|
||||||
@ -244,7 +244,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isRecentFiles(context, null)).toBe(false);
|
expect(app.isRecentFiles(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isSearchResults(context, null)).toBe(true);
|
expect(app.isSearchResults(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url does not start with `/search`', () => {
|
it('should return [false] if url does not start with `/search`', () => {
|
||||||
@ -266,7 +266,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isSearchResults(context, null)).toBe(false);
|
expect(app.isSearchResults(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isSharedPreview(context, null)).toBe(true);
|
expect(app.isSharedPreview(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url does not start with `/shared/preview/`', () => {
|
it('should return [false] if url does not start with `/shared/preview/`', () => {
|
||||||
@ -288,7 +288,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isSharedPreview(context, null)).toBe(false);
|
expect(app.isSharedPreview(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isFavoritesPreview(context, null)).toBe(true);
|
expect(app.isFavoritesPreview(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url does not start with `/favorites/preview/`', () => {
|
it('should return [false] if url does not start with `/favorites/preview/`', () => {
|
||||||
@ -310,7 +310,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isFavoritesPreview(context, null)).toBe(false);
|
expect(app.isFavoritesPreview(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isSharedFileViewer(context, null)).toBe(true);
|
expect(app.isSharedFileViewer(context)).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return [false] if url does not start with `/preview/s/`', () => {
|
it('should return [false] if url does not start with `/preview/s/`', () => {
|
||||||
@ -332,7 +332,7 @@ describe('navigation.evaluators', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(app.isSharedFileViewer(context, null)).toBe(false);
|
expect(app.isSharedFileViewer(context)).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -23,16 +23,13 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RuleContext, RuleParameter } from '@alfresco/adf-extensions';
|
import { RuleContext } from '@alfresco/adf-extensions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a Preview route is activated.
|
* Checks if a Preview route is activated.
|
||||||
* JSON ref: `app.navigation.isPreview`
|
* JSON ref: `app.navigation.isPreview`
|
||||||
*/
|
*/
|
||||||
export function isPreview(
|
export function isPreview(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.includes('/preview/');
|
return url && url.includes('/preview/');
|
||||||
}
|
}
|
||||||
@ -41,56 +38,41 @@ export function isPreview(
|
|||||||
* Checks if a **Favorites** route is activated.
|
* Checks if a **Favorites** route is activated.
|
||||||
* JSON ref: `app.navigation.isFavorites`
|
* JSON ref: `app.navigation.isFavorites`
|
||||||
*/
|
*/
|
||||||
export function isFavorites(
|
export function isFavorites(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/favorites') && !isPreview(context, ...args);
|
return url && url.startsWith('/favorites') && !isPreview(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the activated route is not **Favorites**.
|
* Checks if the activated route is not **Favorites**.
|
||||||
* JSON ref: `app.navigation.isNotFavorites`
|
* JSON ref: `app.navigation.isNotFavorites`
|
||||||
*/
|
*/
|
||||||
export function isNotFavorites(
|
export function isNotFavorites(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
return !isFavorites(context);
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !isFavorites(context, ...args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a **Shared Files** route is activated.
|
* Checks if a **Shared Files** route is activated.
|
||||||
* JSON ref: `app.navigation.isSharedFiles`
|
* JSON ref: `app.navigation.isSharedFiles`
|
||||||
*/
|
*/
|
||||||
export function isSharedFiles(
|
export function isSharedFiles(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/shared') && !isPreview(context, ...args);
|
return url && url.startsWith('/shared') && !isPreview(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the activated route is not **Shared Files**.
|
* Checks if the activated route is not **Shared Files**.
|
||||||
* JSON ref: `app.navigation.isNotSharedFiles`
|
* JSON ref: `app.navigation.isNotSharedFiles`
|
||||||
*/
|
*/
|
||||||
export function isNotSharedFiles(
|
export function isNotSharedFiles(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
return !isSharedFiles(context);
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !isSharedFiles(context, ...args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a **Trashcan** route is activated.
|
* Checks if a **Trashcan** route is activated.
|
||||||
* JSON ref: `app.navigation.isTrashcan`
|
* JSON ref: `app.navigation.isTrashcan`
|
||||||
*/
|
*/
|
||||||
export function isTrashcan(
|
export function isTrashcan(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/trashcan');
|
return url && url.startsWith('/trashcan');
|
||||||
}
|
}
|
||||||
@ -99,21 +81,15 @@ export function isTrashcan(
|
|||||||
* Checks if the activated route is not **Trashcan**.
|
* Checks if the activated route is not **Trashcan**.
|
||||||
* JSON ref: `app.navigation.isNotTrashcan`
|
* JSON ref: `app.navigation.isNotTrashcan`
|
||||||
*/
|
*/
|
||||||
export function isNotTrashcan(
|
export function isNotTrashcan(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
return !isTrashcan(context);
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !isTrashcan(context, ...args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a **Personal Files** route is activated.
|
* Checks if a **Personal Files** route is activated.
|
||||||
* JSON ref: `app.navigation.isPersonalFiles`
|
* JSON ref: `app.navigation.isPersonalFiles`
|
||||||
*/
|
*/
|
||||||
export function isPersonalFiles(
|
export function isPersonalFiles(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/personal-files');
|
return url && url.startsWith('/personal-files');
|
||||||
}
|
}
|
||||||
@ -122,10 +98,7 @@ export function isPersonalFiles(
|
|||||||
* Checks if a **Library Files** route is activated.
|
* Checks if a **Library Files** route is activated.
|
||||||
* JSON ref: `app.navigation.isLibraryFiles`
|
* JSON ref: `app.navigation.isLibraryFiles`
|
||||||
*/
|
*/
|
||||||
export function isLibraryFiles(
|
export function isLibraryFiles(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/libraries');
|
return url && url.startsWith('/libraries');
|
||||||
}
|
}
|
||||||
@ -134,10 +107,7 @@ export function isLibraryFiles(
|
|||||||
* Checks if a **Library Files** or **Library Search Result** route is activated.
|
* Checks if a **Library Files** or **Library Search Result** route is activated.
|
||||||
* JSON ref: `app.navigation.isLibraryFiles`
|
* JSON ref: `app.navigation.isLibraryFiles`
|
||||||
*/
|
*/
|
||||||
export function isLibraries(
|
export function isLibraries(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return (
|
return (
|
||||||
url && (url.endsWith('/libraries') || url.startsWith('/search-libraries'))
|
url && (url.endsWith('/libraries') || url.startsWith('/search-libraries'))
|
||||||
@ -148,21 +118,15 @@ export function isLibraries(
|
|||||||
* 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`
|
||||||
*/
|
*/
|
||||||
export function isNotLibraries(
|
export function isNotLibraries(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
return !isLibraries(context);
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !isLibraries(context, ...args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a **Recent Files** route is activated.
|
* Checks if a **Recent Files** route is activated.
|
||||||
* JSON ref: `app.navigation.isRecentFiles`
|
* JSON ref: `app.navigation.isRecentFiles`
|
||||||
*/
|
*/
|
||||||
export function isRecentFiles(
|
export function isRecentFiles(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/recent-files');
|
return url && url.startsWith('/recent-files');
|
||||||
}
|
}
|
||||||
@ -171,11 +135,8 @@ export function isRecentFiles(
|
|||||||
* Checks if the activated route is not **Recent Files**.
|
* Checks if the activated route is not **Recent Files**.
|
||||||
* JSON ref: `app.navigation.isNotRecentFiles`
|
* JSON ref: `app.navigation.isNotRecentFiles`
|
||||||
*/
|
*/
|
||||||
export function isNotRecentFiles(
|
export function isNotRecentFiles(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
return !isRecentFiles(context);
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !isRecentFiles(context, ...args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,8 +144,8 @@ export function isNotRecentFiles(
|
|||||||
* JSON ref: `app.navigation.isSearchResults`
|
* JSON ref: `app.navigation.isSearchResults`
|
||||||
*/
|
*/
|
||||||
export function isSearchResults(
|
export function isSearchResults(
|
||||||
context: RuleContext,
|
context: RuleContext /*,
|
||||||
...args: RuleParameter[]
|
...args: RuleParameter[]*/
|
||||||
): boolean {
|
): boolean {
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/search');
|
return url && url.startsWith('/search');
|
||||||
@ -194,21 +155,15 @@ export function isSearchResults(
|
|||||||
* Checks if the activated route is not **Search Results**.
|
* Checks if the activated route is not **Search Results**.
|
||||||
* JSON ref: `app.navigation.isNotSearchResults`
|
* JSON ref: `app.navigation.isNotSearchResults`
|
||||||
*/
|
*/
|
||||||
export function isNotSearchResults(
|
export function isNotSearchResults(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
return !isSearchResults(context);
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return !isSearchResults(context, ...args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a **Shared Preview** route is activated.
|
* Checks if a **Shared Preview** route is activated.
|
||||||
* JSON ref: `app.navigation.isSharedPreview`
|
* JSON ref: `app.navigation.isSharedPreview`
|
||||||
*/
|
*/
|
||||||
export function isSharedPreview(
|
export function isSharedPreview(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/shared/preview/');
|
return url && url.startsWith('/shared/preview/');
|
||||||
}
|
}
|
||||||
@ -217,10 +172,7 @@ export function isSharedPreview(
|
|||||||
* Checks if a **Favorites Preview** route is activated.
|
* Checks if a **Favorites Preview** route is activated.
|
||||||
* JSON ref: `app.navigation.isFavoritesPreview`
|
* JSON ref: `app.navigation.isFavoritesPreview`
|
||||||
*/
|
*/
|
||||||
export function isFavoritesPreview(
|
export function isFavoritesPreview(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/favorites/preview/');
|
return url && url.startsWith('/favorites/preview/');
|
||||||
}
|
}
|
||||||
@ -229,10 +181,7 @@ export function isFavoritesPreview(
|
|||||||
* Checks if a **Shared File Preview** route is activated.
|
* Checks if a **Shared File Preview** route is activated.
|
||||||
* JSON ref: `app.navigation.isFavoritesPreview`
|
* JSON ref: `app.navigation.isFavoritesPreview`
|
||||||
*/
|
*/
|
||||||
export function isSharedFileViewer(
|
export function isSharedFileViewer(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
const { url } = context.navigation;
|
const { url } = context.navigation;
|
||||||
return url && url.startsWith('/preview/s/');
|
return url && url.startsWith('/preview/s/');
|
||||||
}
|
}
|
||||||
|
@ -23,15 +23,12 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { RuleParameter, RuleContext } from '@alfresco/adf-extensions';
|
import { RuleContext } from '@alfresco/adf-extensions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the quick share repository option is enabled or not.
|
* Checks if the quick share repository option is enabled or not.
|
||||||
* JSON ref: `repository.isQuickShareEnabled`
|
* JSON ref: `repository.isQuickShareEnabled`
|
||||||
*/
|
*/
|
||||||
export function hasQuickShareEnabled(
|
export function hasQuickShareEnabled(context: RuleContext): boolean {
|
||||||
context: RuleContext,
|
|
||||||
...args: RuleParameter[]
|
|
||||||
): boolean {
|
|
||||||
return context.repository.status.isQuickShareEnabled;
|
return context.repository.status.isQuickShareEnabled;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ export class AppSharedRuleGuard implements CanActivate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
canActivate(
|
canActivate(
|
||||||
route: ActivatedRouteSnapshot
|
_: ActivatedRouteSnapshot
|
||||||
): Observable<boolean> | Promise<boolean> | boolean {
|
): Observable<boolean> | Promise<boolean> | boolean {
|
||||||
return this.isQuickShareEnabled$;
|
return this.isQuickShareEnabled$;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,8 @@ import {
|
|||||||
ResultSetPaging,
|
ResultSetPaging,
|
||||||
SiteBody,
|
SiteBody,
|
||||||
SiteEntry,
|
SiteEntry,
|
||||||
FavoriteBody
|
FavoriteBody,
|
||||||
|
FavoriteEntry
|
||||||
} from '@alfresco/js-api';
|
} from '@alfresco/js-api';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -256,7 +257,7 @@ export class ContentApiService {
|
|||||||
return from(this.api.sitesApi.updateSite(siteId, siteBody));
|
return from(this.api.sitesApi.updateSite(siteId, siteBody));
|
||||||
}
|
}
|
||||||
|
|
||||||
addFavorite(nodes: Array<MinimalNodeEntity>): Observable<any> {
|
addFavorite(nodes: Array<MinimalNodeEntity>): Observable<FavoriteEntry> {
|
||||||
const payload: FavoriteBody[] = nodes.map(node => {
|
const payload: FavoriteBody[] = nodes.map(node => {
|
||||||
const { isFolder, nodeId, id } = <any>node.entry;
|
const { isFolder, nodeId, id } = <any>node.entry;
|
||||||
const siteId = node.entry['guid'];
|
const siteId = node.entry['guid'];
|
||||||
@ -286,7 +287,7 @@ export class ContentApiService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
unlockNode(nodeId: string, opts?) {
|
unlockNode(nodeId: string, opts?: any) {
|
||||||
return this.api.nodesApi.unlockNode(nodeId, opts);
|
return this.api.nodesApi.unlockNode(nodeId, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ export class ContentManagementService {
|
|||||||
width: '400px'
|
width: '400px'
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogInstance.componentInstance.error.subscribe(message => {
|
dialogInstance.componentInstance.error.subscribe((message: string) => {
|
||||||
this.store.dispatch(new SnackbarErrorAction(message));
|
this.store.dispatch(new SnackbarErrorAction(message));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ export class ContentManagementService {
|
|||||||
width: '400px'
|
width: '400px'
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.componentInstance.error.subscribe(message => {
|
dialog.componentInstance.error.subscribe((message: string) => {
|
||||||
this.store.dispatch(new SnackbarErrorAction(message));
|
this.store.dispatch(new SnackbarErrorAction(message));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ export class ContentManagementService {
|
|||||||
width: '400px'
|
width: '400px'
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogInstance.componentInstance.error.subscribe(message => {
|
dialogInstance.componentInstance.error.subscribe((message: string) => {
|
||||||
this.store.dispatch(new SnackbarErrorAction(message));
|
this.store.dispatch(new SnackbarErrorAction(message));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -565,7 +565,7 @@ export class ContentManagementService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private undoMoveNodes(moveResponse, selectionParentId) {
|
private undoMoveNodes(moveResponse, selectionParentId: string) {
|
||||||
const movedNodes =
|
const movedNodes =
|
||||||
moveResponse && moveResponse['succeeded']
|
moveResponse && moveResponse['succeeded']
|
||||||
? moveResponse['succeeded']
|
? moveResponse['succeeded']
|
||||||
@ -963,7 +963,7 @@ export class ContentManagementService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private diff(selection, list, fromList = true): any {
|
private diff(selection: any[], list: any[], fromList = true): any {
|
||||||
const ids = selection.map(item => item.entry.id);
|
const ids = selection.map(item => item.entry.id);
|
||||||
|
|
||||||
return list.filter(item => {
|
return list.filter(item => {
|
||||||
@ -1144,7 +1144,7 @@ export class ContentManagementService {
|
|||||||
.subscribe(() => this.undoMoveNodes(moveResponse, initialParentId));
|
.subscribe(() => this.undoMoveNodes(moveResponse, initialParentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
getErrorMessage(errorObject): string {
|
getErrorMessage(errorObject: { message: any }): string {
|
||||||
let i18nMessageString = 'APP.MESSAGES.ERRORS.GENERIC';
|
let i18nMessageString = 'APP.MESSAGES.ERRORS.GENERIC';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -45,11 +45,17 @@ import {
|
|||||||
MinimalNodeEntity,
|
MinimalNodeEntity,
|
||||||
MinimalNodeEntryEntity,
|
MinimalNodeEntryEntity,
|
||||||
SitePaging,
|
SitePaging,
|
||||||
Site
|
Site,
|
||||||
|
NodeChildAssociationPaging
|
||||||
} from '@alfresco/js-api';
|
} from '@alfresco/js-api';
|
||||||
import { ContentApiService } from '../services/content-api.service';
|
import { ContentApiService } from '../services/content-api.service';
|
||||||
import { catchError, map, mergeMap } from 'rxjs/operators';
|
import { catchError, map, mergeMap } from 'rxjs/operators';
|
||||||
|
|
||||||
|
export enum BatchOperationType {
|
||||||
|
copy = 'copy',
|
||||||
|
move = 'move'
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
@ -80,11 +86,12 @@ export class NodeActionsService {
|
|||||||
* @param contentEntities nodes to copy
|
* @param contentEntities nodes to copy
|
||||||
* @param permission permission which is needed to apply the action
|
* @param permission permission which is needed to apply the action
|
||||||
*/
|
*/
|
||||||
public copyNodes(
|
copyNodes(contentEntities: any[], permission?: string): Subject<string> {
|
||||||
contentEntities: any[],
|
return this.doBatchOperation(
|
||||||
permission?: string
|
BatchOperationType.copy,
|
||||||
): Subject<string> {
|
contentEntities,
|
||||||
return this.doBatchOperation('copy', contentEntities, permission);
|
permission
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -93,11 +100,12 @@ export class NodeActionsService {
|
|||||||
* @param contentEntities nodes to move
|
* @param contentEntities nodes to move
|
||||||
* @param permission permission which is needed to apply the action
|
* @param permission permission which is needed to apply the action
|
||||||
*/
|
*/
|
||||||
public moveNodes(
|
moveNodes(contentEntities: any[], permission?: string): Subject<string> {
|
||||||
contentEntities: any[],
|
return this.doBatchOperation(
|
||||||
permission?: string
|
BatchOperationType.move,
|
||||||
): Subject<string> {
|
contentEntities,
|
||||||
return this.doBatchOperation('move', contentEntities, permission);
|
permission
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +116,7 @@ export class NodeActionsService {
|
|||||||
* @param permission permission which is needed to apply the action
|
* @param permission permission which is needed to apply the action
|
||||||
*/
|
*/
|
||||||
doBatchOperation(
|
doBatchOperation(
|
||||||
action: string,
|
action: BatchOperationType,
|
||||||
contentEntities: any[],
|
contentEntities: any[],
|
||||||
permission?: string
|
permission?: string
|
||||||
): Subject<string> {
|
): Subject<string> {
|
||||||
@ -128,14 +136,14 @@ export class NodeActionsService {
|
|||||||
// Check if there's nodeId for Shared Files
|
// Check if there's nodeId for Shared Files
|
||||||
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
||||||
const type = contentEntry.isFolder ? 'folder' : 'content';
|
const type = contentEntry.isFolder ? 'folder' : 'content';
|
||||||
const batch = [];
|
const batch: any[] = [];
|
||||||
|
|
||||||
// consider only first item in the selection
|
// consider only first item in the selection
|
||||||
const selection = selections[0];
|
const selection = selections[0];
|
||||||
let action$: Observable<any>;
|
let action$: Observable<any>;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
action === 'move' &&
|
action === BatchOperationType.move &&
|
||||||
contentEntities.length === 1 &&
|
contentEntities.length === 1 &&
|
||||||
type === 'content'
|
type === 'content'
|
||||||
) {
|
) {
|
||||||
@ -145,6 +153,7 @@ export class NodeActionsService {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
contentEntities.forEach(node => {
|
contentEntities.forEach(node => {
|
||||||
|
// batch.push(this.copyNodeAction(node.entry, selection.id));
|
||||||
batch.push(this[`${action}NodeAction`](node.entry, selection.id));
|
batch.push(this[`${action}NodeAction`](node.entry, selection.id));
|
||||||
});
|
});
|
||||||
action$ = zip(...batch);
|
action$ = zip(...batch);
|
||||||
@ -156,9 +165,9 @@ export class NodeActionsService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const processedData = this.processResponse(newContent);
|
const processedData = this.processResponse(newContent);
|
||||||
if (action === 'copy') {
|
if (action === BatchOperationType.copy) {
|
||||||
this.contentCopied.next(processedData.succeeded);
|
this.contentCopied.next(processedData.succeeded);
|
||||||
} else if (action === 'move') {
|
} else if (action === BatchOperationType.move) {
|
||||||
this.contentMoved.next(processedData);
|
this.contentMoved.next(processedData);
|
||||||
}
|
}
|
||||||
}, observable.error.bind(observable));
|
}, observable.error.bind(observable));
|
||||||
@ -182,7 +191,11 @@ export class NodeActionsService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkPermission(action: string, contentEntities: any[], permission?: string) {
|
checkPermission(
|
||||||
|
action: BatchOperationType,
|
||||||
|
contentEntities: any[],
|
||||||
|
permission?: string
|
||||||
|
) {
|
||||||
const notAllowedNode = contentEntities.find(
|
const notAllowedNode = contentEntities.find(
|
||||||
node => !this.isActionAllowed(action, node.entry, permission)
|
node => !this.isActionAllowed(action, node.entry, permission)
|
||||||
);
|
);
|
||||||
@ -370,7 +383,7 @@ export class NodeActionsService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
copyNodeAction(nodeEntry, selectionId): Observable<any> {
|
copyNodeAction(nodeEntry: any, selectionId: string): Observable<any> {
|
||||||
if (nodeEntry.isFolder) {
|
if (nodeEntry.isFolder) {
|
||||||
return this.copyFolderAction(nodeEntry, selectionId);
|
return this.copyFolderAction(nodeEntry, selectionId);
|
||||||
} else {
|
} else {
|
||||||
@ -379,7 +392,11 @@ export class NodeActionsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copyContentAction(contentEntry, selectionId, oldName?): Observable<any> {
|
copyContentAction(
|
||||||
|
contentEntry: any,
|
||||||
|
selectionId: string,
|
||||||
|
oldName?: string
|
||||||
|
): Observable<any> {
|
||||||
const _oldName = oldName || contentEntry.name;
|
const _oldName = oldName || contentEntry.name;
|
||||||
// Check if there's nodeId for Shared Files
|
// Check if there's nodeId for Shared Files
|
||||||
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
||||||
@ -411,7 +428,7 @@ export class NodeActionsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyFolderAction(contentEntry, selectionId): Observable<any> {
|
copyFolderAction(contentEntry: any, selectionId: string): Observable<any> {
|
||||||
// Check if there's nodeId for Shared Files
|
// Check if there's nodeId for Shared Files
|
||||||
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
||||||
let $destinationFolder: Observable<any>;
|
let $destinationFolder: Observable<any>;
|
||||||
@ -474,7 +491,7 @@ export class NodeActionsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
moveNodeAction(nodeEntry, selectionId): Observable<any> {
|
moveNodeAction(nodeEntry, selectionId: string): Observable<any> {
|
||||||
this.moveDeletedEntries = [];
|
this.moveDeletedEntries = [];
|
||||||
|
|
||||||
if (nodeEntry.isFolder) {
|
if (nodeEntry.isFolder) {
|
||||||
@ -519,7 +536,7 @@ export class NodeActionsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
moveFolderAction(contentEntry, selectionId): Observable<any> {
|
moveFolderAction(contentEntry, selectionId: string): Observable<any> {
|
||||||
// Check if there's nodeId for Shared Files
|
// Check if there's nodeId for Shared Files
|
||||||
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
||||||
const initialParentId = this.getEntryParentId(contentEntry);
|
const initialParentId = this.getEntryParentId(contentEntry);
|
||||||
@ -555,7 +572,7 @@ export class NodeActionsService {
|
|||||||
return $childrenToMove;
|
return $childrenToMove;
|
||||||
}),
|
}),
|
||||||
mergeMap(childrenToMove => {
|
mergeMap(childrenToMove => {
|
||||||
const batch = [];
|
const batch: any[] = [];
|
||||||
childrenToMove.list.entries.forEach(node => {
|
childrenToMove.list.entries.forEach(node => {
|
||||||
if (node.entry.isFolder) {
|
if (node.entry.isFolder) {
|
||||||
batch.push(
|
batch.push(
|
||||||
@ -588,7 +605,7 @@ export class NodeActionsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
moveContentAction(contentEntry, selectionId) {
|
moveContentAction(contentEntry: any, selectionId: string) {
|
||||||
// Check if there's nodeId for Shared Files
|
// Check if there's nodeId for Shared Files
|
||||||
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
const contentEntryId = contentEntry.nodeId || contentEntry.id;
|
||||||
const initialParentId = this.getEntryParentId(contentEntry);
|
const initialParentId = this.getEntryParentId(contentEntry);
|
||||||
@ -604,8 +621,8 @@ export class NodeActionsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getChildByName(parentId, name) {
|
getChildByName(parentId: string, name: string) {
|
||||||
const matchedNodes: Subject<any> = new Subject<any>();
|
const matchedNodes = new Subject<any>();
|
||||||
|
|
||||||
this.getNodeChildren(parentId).subscribe(
|
this.getNodeChildren(parentId).subscribe(
|
||||||
(childrenNodes: any) => {
|
(childrenNodes: any) => {
|
||||||
@ -627,11 +644,11 @@ export class NodeActionsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private isActionAllowed(
|
private isActionAllowed(
|
||||||
action: string,
|
action: BatchOperationType,
|
||||||
node: MinimalNodeEntryEntity,
|
node: MinimalNodeEntryEntity,
|
||||||
permission?: string
|
permission?: string
|
||||||
): boolean {
|
): boolean {
|
||||||
if (action === 'copy') {
|
if (action === BatchOperationType.copy) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return this.contentService.hasAllowableOperations(node, permission);
|
return this.contentService.hasAllowableOperations(node, permission);
|
||||||
@ -695,7 +712,10 @@ export class NodeActionsService {
|
|||||||
* @param nodeId The id of the parent node
|
* @param nodeId The id of the parent node
|
||||||
* @param params optional parameters
|
* @param params optional parameters
|
||||||
*/
|
*/
|
||||||
getNodeChildren(nodeId: string, params?) {
|
getNodeChildren(
|
||||||
|
nodeId: string,
|
||||||
|
params?: any
|
||||||
|
): Observable<NodeChildAssociationPaging> {
|
||||||
return from(
|
return from(
|
||||||
this.apiService.getInstance().nodes.getNodeChildren(nodeId, params)
|
this.apiService.getInstance().nodes.getNodeChildren(nodeId, params)
|
||||||
);
|
);
|
||||||
@ -717,13 +737,13 @@ export class NodeActionsService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public flatten(nDimArray) {
|
public flatten(nDimArray: any[]) {
|
||||||
if (!Array.isArray(nDimArray)) {
|
if (!Array.isArray(nDimArray)) {
|
||||||
return nDimArray;
|
return nDimArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodeQueue = nDimArray.slice(0);
|
const nodeQueue = nDimArray.slice(0);
|
||||||
const resultingArray = [];
|
const resultingArray: any[] = [];
|
||||||
|
|
||||||
do {
|
do {
|
||||||
nodeQueue.forEach(node => {
|
nodeQueue.forEach(node => {
|
||||||
|
@ -64,17 +64,14 @@ export class SetUserProfileAction implements Action {
|
|||||||
|
|
||||||
export class ToggleInfoDrawerAction implements Action {
|
export class ToggleInfoDrawerAction implements Action {
|
||||||
readonly type = TOGGLE_INFO_DRAWER;
|
readonly type = TOGGLE_INFO_DRAWER;
|
||||||
constructor(public payload?: any) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ToggleDocumentDisplayMode implements Action {
|
export class ToggleDocumentDisplayMode implements Action {
|
||||||
readonly type = TOGGLE_DOCUMENT_DISPLAY_MODE;
|
readonly type = TOGGLE_DOCUMENT_DISPLAY_MODE;
|
||||||
constructor(public payload?: any) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class LogoutAction implements Action {
|
export class LogoutAction implements Action {
|
||||||
readonly type = LOGOUT;
|
readonly type = LOGOUT;
|
||||||
constructor(public payload?: any) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ReloadDocumentListAction implements Action {
|
export class ReloadDocumentListAction implements Action {
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Action } from '@ngrx/store';
|
import { Action } from '@ngrx/store';
|
||||||
|
import { SearchOptionModel } from '../models/searchOption.model';
|
||||||
|
|
||||||
export const SEARCH_BY_TERM = 'SEARCH_BY_TERM';
|
export const SEARCH_BY_TERM = 'SEARCH_BY_TERM';
|
||||||
export const TOGGLE_SEARCH_FILTER = 'TOGGLE_SEARCH_FILTER';
|
export const TOGGLE_SEARCH_FILTER = 'TOGGLE_SEARCH_FILTER';
|
||||||
@ -32,7 +33,10 @@ export const HIDE_SEARCH_FILTER = 'HIDE_SEARCH_FILTER';
|
|||||||
|
|
||||||
export class SearchByTermAction implements Action {
|
export class SearchByTermAction implements Action {
|
||||||
readonly type = SEARCH_BY_TERM;
|
readonly type = SEARCH_BY_TERM;
|
||||||
constructor(public payload: string, public searchOptions?: any) {}
|
constructor(
|
||||||
|
public payload: string,
|
||||||
|
public searchOptions?: SearchOptionModel[]
|
||||||
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ToggleSearchFilterAction implements Action {
|
export class ToggleSearchFilterAction implements Action {
|
||||||
|
@ -89,7 +89,7 @@ export class RouterEffects {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private navigateToFolder(node: MinimalNodeEntryEntity) {
|
private navigateToFolder(node: MinimalNodeEntryEntity) {
|
||||||
let link = null;
|
let link: any[] = null;
|
||||||
const { path, id } = node;
|
const { path, id } = node;
|
||||||
|
|
||||||
if (path && path.name && path.elements) {
|
if (path && path.name && path.elements) {
|
||||||
@ -114,7 +114,7 @@ export class RouterEffects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private navigateToParentFolder(node: MinimalNodeEntryEntity) {
|
private navigateToParentFolder(node: MinimalNodeEntryEntity) {
|
||||||
let link = null;
|
let link: any[] = null;
|
||||||
const { path } = node;
|
const { path } = node;
|
||||||
|
|
||||||
if (path && path.name && path.elements) {
|
if (path && path.name && path.elements) {
|
||||||
|
@ -30,6 +30,7 @@ import { EffectsModule } from '@ngrx/effects';
|
|||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { SearchByTermAction } from '../actions/search.actions';
|
import { SearchByTermAction } from '../actions/search.actions';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { SearchOptionIds } from '../models/searchOption.model';
|
||||||
|
|
||||||
describe('SearchEffects', () => {
|
describe('SearchEffects', () => {
|
||||||
let store: Store<any>;
|
let store: Store<any>;
|
||||||
@ -55,7 +56,14 @@ describe('SearchEffects', () => {
|
|||||||
|
|
||||||
it('should navigate to `search-libraries` when search options has library true', fakeAsync(() => {
|
it('should navigate to `search-libraries` when search options has library true', fakeAsync(() => {
|
||||||
store.dispatch(
|
store.dispatch(
|
||||||
new SearchByTermAction('test', [{ id: 'libraries', value: true }])
|
new SearchByTermAction('test', [
|
||||||
|
{
|
||||||
|
id: SearchOptionIds.Libraries,
|
||||||
|
value: true,
|
||||||
|
key: '',
|
||||||
|
shouldDisable: null
|
||||||
|
}
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
|
@ -28,7 +28,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
import { SEARCH_BY_TERM, SearchByTermAction } from '../actions/search.actions';
|
import { SEARCH_BY_TERM, SearchByTermAction } from '../actions/search.actions';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { SearchOptionIds } from '../../components/search/search-input/search-input.component';
|
import { SearchOptionIds } from '../models/searchOption.model';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SearchEffects {
|
export class SearchEffects {
|
||||||
|
@ -145,7 +145,7 @@ export class UploadEffects {
|
|||||||
this.fileVersionInput.value = '';
|
this.fileVersionInput.value = '';
|
||||||
this.uploadAndUnlock(fileModel);
|
this.uploadAndUnlock(fileModel);
|
||||||
}),
|
}),
|
||||||
catchError(error => {
|
catchError(_ => {
|
||||||
this.fileVersionInput.value = '';
|
this.fileVersionInput.value = '';
|
||||||
return of(new SnackbarErrorAction('VERSION.ERROR.GENERIC'));
|
return of(new SnackbarErrorAction('VERSION.ERROR.GENERIC'));
|
||||||
})
|
})
|
||||||
|
37
src/app/store/models/searchOption.model.ts
Normal file
37
src/app/store/models/searchOption.model.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*!
|
||||||
|
* @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 enum SearchOptionIds {
|
||||||
|
Files = 'content',
|
||||||
|
Folders = 'folder',
|
||||||
|
Libraries = 'libraries'
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SearchOptionModel {
|
||||||
|
id: SearchOptionIds;
|
||||||
|
key: string;
|
||||||
|
value: boolean;
|
||||||
|
shouldDisable(): boolean;
|
||||||
|
}
|
@ -39,21 +39,15 @@ import {
|
|||||||
SET_CURRENT_URL,
|
SET_CURRENT_URL,
|
||||||
SetCurrentUrlAction,
|
SetCurrentUrlAction,
|
||||||
SET_INFO_DRAWER_STATE,
|
SET_INFO_DRAWER_STATE,
|
||||||
SetInfoDrawerStateAction
|
SetInfoDrawerStateAction,
|
||||||
} from '../actions';
|
|
||||||
import {
|
|
||||||
TOGGLE_INFO_DRAWER,
|
TOGGLE_INFO_DRAWER,
|
||||||
ToggleInfoDrawerAction,
|
|
||||||
TOGGLE_DOCUMENT_DISPLAY_MODE,
|
TOGGLE_DOCUMENT_DISPLAY_MODE,
|
||||||
ToggleDocumentDisplayMode,
|
|
||||||
SET_INITIAL_STATE,
|
SET_INITIAL_STATE,
|
||||||
SetInitialStateAction
|
SetInitialStateAction,
|
||||||
} from '../actions/app.actions';
|
|
||||||
import {
|
|
||||||
TOGGLE_SEARCH_FILTER,
|
TOGGLE_SEARCH_FILTER,
|
||||||
SHOW_SEARCH_FILTER,
|
SHOW_SEARCH_FILTER,
|
||||||
HIDE_SEARCH_FILTER
|
HIDE_SEARCH_FILTER
|
||||||
} from '../actions/search.actions';
|
} from '../actions';
|
||||||
|
|
||||||
export function appReducer(
|
export function appReducer(
|
||||||
state: AppState = INITIAL_APP_STATE,
|
state: AppState = INITIAL_APP_STATE,
|
||||||
@ -81,15 +75,13 @@ export function appReducer(
|
|||||||
newState = updateCurrentUrl(state, <SetCurrentUrlAction>action);
|
newState = updateCurrentUrl(state, <SetCurrentUrlAction>action);
|
||||||
break;
|
break;
|
||||||
case TOGGLE_INFO_DRAWER:
|
case TOGGLE_INFO_DRAWER:
|
||||||
newState = updateInfoDrawer(state, <ToggleInfoDrawerAction>action);
|
newState = toggleInfoDrawer(state);
|
||||||
break;
|
break;
|
||||||
case SET_INFO_DRAWER_STATE:
|
case SET_INFO_DRAWER_STATE:
|
||||||
newState = setInfoDrawer(state, <SetInfoDrawerStateAction>action);
|
newState = setInfoDrawer(state, <SetInfoDrawerStateAction>action);
|
||||||
break;
|
break;
|
||||||
case TOGGLE_DOCUMENT_DISPLAY_MODE:
|
case TOGGLE_DOCUMENT_DISPLAY_MODE:
|
||||||
newState = updateDocumentDisplayMode(state, <ToggleDocumentDisplayMode>(
|
newState = toggleDocumentDisplayMode(state);
|
||||||
action
|
|
||||||
));
|
|
||||||
break;
|
break;
|
||||||
case SET_REPOSITORY_INFO:
|
case SET_REPOSITORY_INFO:
|
||||||
newState = updateRepositoryStatus(state, <SetRepositoryInfoAction>action);
|
newState = updateRepositoryStatus(state, <SetRepositoryInfoAction>action);
|
||||||
@ -174,7 +166,7 @@ function updateCurrentUrl(state: AppState, action: SetCurrentUrlAction) {
|
|||||||
return newState;
|
return newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInfoDrawer(state: AppState, action: ToggleInfoDrawerAction) {
|
function toggleInfoDrawer(state: AppState) {
|
||||||
const newState = Object.assign({}, state);
|
const newState = Object.assign({}, state);
|
||||||
|
|
||||||
let value = state.infoDrawerOpened;
|
let value = state.infoDrawerOpened;
|
||||||
@ -189,10 +181,7 @@ function updateInfoDrawer(state: AppState, action: ToggleInfoDrawerAction) {
|
|||||||
return newState;
|
return newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDocumentDisplayMode(
|
function toggleDocumentDisplayMode(state: AppState) {
|
||||||
state: AppState,
|
|
||||||
action: ToggleDocumentDisplayMode
|
|
||||||
) {
|
|
||||||
const newState = Object.assign({}, state);
|
const newState = Object.assign({}, state);
|
||||||
newState.documentDisplayMode =
|
newState.documentDisplayMode =
|
||||||
newState.documentDisplayMode === 'list' ? 'gallery' : 'list';
|
newState.documentDisplayMode === 'list' ? 'gallery' : 'list';
|
||||||
|
@ -27,7 +27,7 @@ import { Pipe, PipeTransform } from '@angular/core';
|
|||||||
|
|
||||||
@Pipe({ name: 'translate' })
|
@Pipe({ name: 'translate' })
|
||||||
export class TranslatePipeMock implements PipeTransform {
|
export class TranslatePipeMock implements PipeTransform {
|
||||||
transform(value: any, ...args: any[]) {
|
transform(value: any) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,15 +34,15 @@ export class TranslateServiceMock extends TranslateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get(
|
get(
|
||||||
key: string | Array<string>,
|
key: string | Array<string> /*,
|
||||||
interpolateParams?: Object
|
interpolateParams?: Object*/
|
||||||
): Observable<string | any> {
|
): Observable<string | any> {
|
||||||
return of(key);
|
return of(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
instant(
|
instant(
|
||||||
key: string | Array<string>,
|
key: string | Array<string> /*,
|
||||||
interpolateParams?: Object
|
interpolateParams?: Object*/
|
||||||
): string | any {
|
): string | any {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user