mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-6445] Address #PT20471_7 Missing Access Control (#3627)
This commit is contained in:
committed by
GitHub
parent
4393f337c5
commit
bcb7e634d9
@@ -30,7 +30,7 @@ import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { Site, SiteBodyCreate, SitePaging } from '@alfresco/js-api';
|
||||
import { Actions } from '@ngrx/effects';
|
||||
import { Subject } from 'rxjs';
|
||||
import { of, Subject } from 'rxjs';
|
||||
|
||||
describe('LibraryMetadataFormComponent', () => {
|
||||
let fixture: ComponentFixture<LibraryMetadataFormComponent>;
|
||||
@@ -51,7 +51,8 @@ describe('LibraryMetadataFormComponent', () => {
|
||||
{
|
||||
provide: Store,
|
||||
useValue: {
|
||||
dispatch: jasmine.createSpy('dispatch')
|
||||
dispatch: jasmine.createSpy('dispatch'),
|
||||
select: () => of()
|
||||
}
|
||||
}
|
||||
],
|
||||
@@ -210,6 +211,18 @@ describe('LibraryMetadataFormComponent', () => {
|
||||
expect(store.dispatch).not.toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel));
|
||||
});
|
||||
|
||||
it('should update library node when the user is an admin but has consumer rights', () => {
|
||||
component.node.entry.role = Site.RoleEnum.SiteConsumer;
|
||||
component.isAdmin = true;
|
||||
|
||||
fixture.detectChanges();
|
||||
component.toggleEdit();
|
||||
|
||||
component.update();
|
||||
|
||||
expect(store.dispatch).toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel));
|
||||
});
|
||||
|
||||
it('should not call markAsPristine on form when updating valid form but has not permission to update', () => {
|
||||
component.node.entry.role = Site.RoleEnum.SiteConsumer;
|
||||
spyOn(component.form, 'markAsPristine');
|
||||
|
@@ -42,7 +42,8 @@ import {
|
||||
SnackbarActionTypes,
|
||||
SnackbarErrorAction,
|
||||
SnackbarInfoAction,
|
||||
UpdateLibraryAction
|
||||
UpdateLibraryAction,
|
||||
isAdmin
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { debounceTime, filter, mergeMap, takeUntil } from 'rxjs/operators';
|
||||
import { AlfrescoApiService } from '@alfresco/adf-core';
|
||||
@@ -118,6 +119,7 @@ export class LibraryMetadataFormComponent implements OnInit, OnChanges, OnDestro
|
||||
|
||||
matcher = new InstantErrorStateMatcher();
|
||||
canUpdateLibrary = false;
|
||||
isAdmin = false;
|
||||
|
||||
onDestroy$: Subject<boolean> = new Subject<boolean>();
|
||||
|
||||
@@ -172,7 +174,13 @@ export class LibraryMetadataFormComponent implements OnInit, OnChanges, OnDestro
|
||||
this.libraryTitleExists = false;
|
||||
}
|
||||
});
|
||||
this.canUpdateLibrary = this.node?.entry?.role === 'SiteManager';
|
||||
this.store
|
||||
.select(isAdmin)
|
||||
.pipe(takeUntil(this.onDestroy$))
|
||||
.subscribe((value) => {
|
||||
this.isAdmin = value;
|
||||
});
|
||||
this.canUpdateLibrary = this.node?.entry?.role === 'SiteManager' || this.isAdmin;
|
||||
this.handleUpdatingEvent<SnackbarInfoAction>(SnackbarActionTypes.Info, 'LIBRARY.SUCCESS.LIBRARY_UPDATED', () =>
|
||||
Object.assign(this.node.entry, this.form.value)
|
||||
);
|
||||
@@ -186,7 +194,7 @@ export class LibraryMetadataFormComponent implements OnInit, OnChanges, OnDestro
|
||||
|
||||
ngOnChanges() {
|
||||
this.updateForm(this.node);
|
||||
this.canUpdateLibrary = this.node?.entry?.role === 'SiteManager';
|
||||
this.canUpdateLibrary = this.node?.entry?.role === 'SiteManager' || this.isAdmin;
|
||||
}
|
||||
|
||||
update() {
|
||||
|
Reference in New Issue
Block a user