edit folder error notification (#296)

This commit is contained in:
Cilibiu Bogdan 2018-04-11 12:03:27 +03:00 committed by Denys Vuika
parent 4f48ed9361
commit b47fc2cb3f
6 changed files with 48 additions and 2 deletions

View File

@ -28,6 +28,7 @@
color="primary" color="primary"
*ngIf="showEditOption(documentList.selection)" *ngIf="showEditOption(documentList.selection)"
title="{{ 'APP.ACTIONS.EDIT' | translate }}" title="{{ 'APP.ACTIONS.EDIT' | translate }}"
(error)="openSnackMessage($event)"
[adf-edit-folder]="documentList.selection[0]?.entry"> [adf-edit-folder]="documentList.selection[0]?.entry">
<mat-icon>create</mat-icon> <mat-icon>create</mat-icon>
</button> </button>

View File

@ -57,6 +57,7 @@ describe('Favorites Routed Component', () => {
let alfrescoContentService: ContentService; let alfrescoContentService: ContentService;
let contentService: ContentManagementService; let contentService: ContentManagementService;
let preferenceService: UserPreferencesService; let preferenceService: UserPreferencesService;
let notificationService: NotificationService;
let router: Router; let router: Router;
let page; let page;
let node; let node;
@ -132,6 +133,7 @@ describe('Favorites Routed Component', () => {
component = fixture.componentInstance; component = fixture.componentInstance;
nodesApi = TestBed.get(NodesApiService); nodesApi = TestBed.get(NodesApiService);
notificationService = TestBed.get(NotificationService);
alfrescoApi = TestBed.get(AlfrescoApiService); alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoApi.reset(); alfrescoApi.reset();
alfrescoContentService = TestBed.get(ContentService); alfrescoContentService = TestBed.get(ContentService);
@ -325,4 +327,16 @@ describe('Favorites Routed Component', () => {
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc'); expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
}); });
}); });
describe('openSnackMessage', () => {
it('should call notification service', () => {
const message = 'notification message';
spyOn(notificationService, 'openSnackMessage');
component.openSnackMessage(message);
expect(notificationService.openSnackMessage).toHaveBeenCalledWith(message, 4000);
});
});
}); });

View File

@ -28,7 +28,7 @@ import { Router, ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs/Rx'; import { Subscription } from 'rxjs/Rx';
import { MinimalNodeEntryEntity, MinimalNodeEntity, PathElementEntity, PathInfo } from 'alfresco-js-api'; import { MinimalNodeEntryEntity, MinimalNodeEntity, PathElementEntity, PathInfo } from 'alfresco-js-api';
import { ContentService, NodesApiService, UserPreferencesService } from '@alfresco/adf-core'; import { ContentService, NodesApiService, UserPreferencesService, NotificationService } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services'; import { DocumentListComponent } from '@alfresco/adf-content-services';
import { ContentManagementService } from '../../common/services/content-management.service'; import { ContentManagementService } from '../../common/services/content-management.service';
@ -52,6 +52,7 @@ export class FavoritesComponent extends PageComponent implements OnInit, OnDestr
private nodesApi: NodesApiService, private nodesApi: NodesApiService,
private contentService: ContentService, private contentService: ContentService,
private content: ContentManagementService, private content: ContentManagementService,
private notificationService: NotificationService,
public permission: NodePermissionService, public permission: NodePermissionService,
preferences: UserPreferencesService) { preferences: UserPreferencesService) {
super(preferences); super(preferences);
@ -124,6 +125,13 @@ export class FavoritesComponent extends PageComponent implements OnInit, OnDestr
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc'); this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
} }
openSnackMessage(event: any) {
this.notificationService.openSnackMessage(
event,
4000
);
}
private get prefix() { private get prefix() {
return this.route.snapshot.data.preferencePrefix; return this.route.snapshot.data.preferencePrefix;
} }

View File

@ -30,6 +30,7 @@
mat-icon-button mat-icon-button
*ngIf="canEditFolder(documentList.selection)" *ngIf="canEditFolder(documentList.selection)"
title="{{ 'APP.ACTIONS.EDIT' | translate }}" title="{{ 'APP.ACTIONS.EDIT' | translate }}"
(error)="openSnackMessage($event)"
[adf-edit-folder]="documentList.selection[0]?.entry"> [adf-edit-folder]="documentList.selection[0]?.entry">
<mat-icon>create</mat-icon> <mat-icon>create</mat-icon>
</button> </button>

View File

@ -63,6 +63,7 @@ describe('FilesComponent', () => {
let browsingFilesService: BrowsingFilesService; let browsingFilesService: BrowsingFilesService;
let nodeActionsService: NodeActionsService; let nodeActionsService: NodeActionsService;
let preferenceService: UserPreferencesService; let preferenceService: UserPreferencesService;
let notificationService: NotificationService;
beforeEach(async(() => { beforeEach(async(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
@ -121,6 +122,7 @@ describe('FilesComponent', () => {
router = TestBed.get(Router); router = TestBed.get(Router);
alfrescoContentService = TestBed.get(ContentService); alfrescoContentService = TestBed.get(ContentService);
browsingFilesService = TestBed.get(BrowsingFilesService); browsingFilesService = TestBed.get(BrowsingFilesService);
notificationService = TestBed.get(NotificationService);
nodeActionsService = TestBed.get(NodeActionsService); nodeActionsService = TestBed.get(NodeActionsService);
preferenceService = TestBed.get(UserPreferencesService); preferenceService = TestBed.get(UserPreferencesService);
}); });
@ -531,4 +533,16 @@ describe('FilesComponent', () => {
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc'); expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
}); });
}); });
describe('openSnackMessage', () => {
it('should call notification service', () => {
const message = 'notification message';
spyOn(notificationService, 'openSnackMessage');
component.openSnackMessage(message);
expect(notificationService.openSnackMessage).toHaveBeenCalledWith(message, 4000);
});
});
}); });

View File

@ -29,7 +29,7 @@ import { Router, ActivatedRoute, Params } from '@angular/router';
import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging, PathElement } from 'alfresco-js-api'; import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging, PathElement } from 'alfresco-js-api';
import { import {
UploadService, FileUploadEvent, NodesApiService, UploadService, FileUploadEvent, NodesApiService,
ContentService, AlfrescoApiService, UserPreferencesService ContentService, AlfrescoApiService, UserPreferencesService, NotificationService
} from '@alfresco/adf-core'; } from '@alfresco/adf-core';
import { BrowsingFilesService } from '../../common/services/browsing-files.service'; import { BrowsingFilesService } from '../../common/services/browsing-files.service';
@ -62,6 +62,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
private browsingFilesService: BrowsingFilesService, private browsingFilesService: BrowsingFilesService,
private contentService: ContentService, private contentService: ContentService,
private apiService: AlfrescoApiService, private apiService: AlfrescoApiService,
private notificationService: NotificationService,
public permission: NodePermissionService, public permission: NodePermissionService,
preferences: UserPreferencesService) { preferences: UserPreferencesService) {
super(preferences); super(preferences);
@ -307,6 +308,13 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc'); this.preferences.set(`${this.prefix}.sorting.direction`, event.detail.direction || 'desc');
} }
openSnackMessage(event: any) {
this.notificationService.openSnackMessage(
event,
4000
);
}
private get prefix() { private get prefix() {
return this.route.snapshot.data.preferencePrefix; return this.route.snapshot.data.preferencePrefix;
} }