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