forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Migrate create-report sections to a new provider - Fix menu component test - Add dso option sections to com/col sub paths - Fix issue with breadcrumbs on the collection page
- Loading branch information
1 parent
c19af67
commit 0fec539
Showing
11 changed files
with
240 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/app/shared/menu/providers/create-report.menu.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
|
||
import { TestBed } from '@angular/core/testing'; | ||
import { of as observableOf } from 'rxjs'; | ||
|
||
import { ConfigurationDataService } from '../../../core/data/configuration-data.service'; | ||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service'; | ||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id'; | ||
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model'; | ||
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils'; | ||
import { AuthorizationDataServiceStub } from '../../testing/authorization-service.stub'; | ||
import { ConfigurationDataServiceStub } from '../../testing/configuration-data.service.stub'; | ||
import { LinkMenuItemModel } from '../menu-item/models/link.model'; | ||
import { TextMenuItemModel } from '../menu-item/models/text.model'; | ||
import { MenuItemType } from '../menu-item-type.model'; | ||
import { PartialMenuSection } from '../menu-provider.model'; | ||
import { CreateReportMenuProvider } from './create-report.menu'; | ||
|
||
describe('CreateReportMenuProvider', () => { | ||
const expectedTopSection: PartialMenuSection = { | ||
visible: true, | ||
model: { | ||
type: MenuItemType.TEXT, | ||
text: 'menu.section.reports', | ||
} as TextMenuItemModel, | ||
icon: 'file-alt', | ||
}; | ||
|
||
const expectedSubSections: PartialMenuSection[] = [ | ||
{ | ||
visible: true, | ||
model: { | ||
type: MenuItemType.LINK, | ||
text: 'menu.section.reports.collections', | ||
link: '/admin/reports/collections', | ||
} as LinkMenuItemModel, | ||
icon: 'user-check', | ||
}, | ||
{ | ||
visible: true, | ||
model: { | ||
type: MenuItemType.LINK, | ||
text: 'menu.section.reports.queries', | ||
link: '/admin/reports/queries', | ||
} as LinkMenuItemModel, | ||
icon: 'user-check', | ||
}, | ||
]; | ||
|
||
let provider: CreateReportMenuProvider; | ||
let authorizationServiceStub = new AuthorizationDataServiceStub(); | ||
let configurationDataService = new ConfigurationDataServiceStub(); | ||
|
||
beforeEach(() => { | ||
spyOn(authorizationServiceStub, 'isAuthorized').and.callFake((id: FeatureID) => { | ||
if (id === FeatureID.CanManageGroups) { | ||
return observableOf(false); | ||
} else { | ||
return observableOf(true); | ||
} | ||
}); | ||
|
||
spyOn(configurationDataService, 'findByPropertyName').and.callFake((property: string) => { | ||
return createSuccessfulRemoteDataObject$(Object.assign({}, new ConfigurationProperty(), { values: ['true'] })); | ||
}); | ||
|
||
TestBed.configureTestingModule({ | ||
providers: [ | ||
CreateReportMenuProvider, | ||
{ provide: AuthorizationDataService, useValue: authorizationServiceStub }, | ||
{ provide: ConfigurationDataService, useValue: configurationDataService }, | ||
], | ||
}); | ||
provider = TestBed.inject(CreateReportMenuProvider); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(provider).toBeTruthy(); | ||
}); | ||
|
||
it('getTopSection should return expected menu section', (done) => { | ||
provider.getTopSection().subscribe((section) => { | ||
expect(section).toEqual(expectedTopSection); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('getSubSections should return expected menu sections', (done) => { | ||
provider.getSubSections().subscribe((sections) => { | ||
expect(sections).toEqual(expectedSubSections); | ||
done(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* The contents of this file are subject to the license and copyright | ||
* detailed in the LICENSE and NOTICE files at the root of the source | ||
* tree and available online at | ||
* | ||
* http://www.dspace.org/license/ | ||
*/ | ||
|
||
import { Injectable } from '@angular/core'; | ||
import { | ||
combineLatest as observableCombineLatest, | ||
Observable, | ||
} from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
import { ConfigurationDataService } from '../../../core/data/configuration-data.service'; | ||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service'; | ||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id'; | ||
import { RemoteData } from '../../../core/data/remote-data'; | ||
import { ConfigurationProperty } from '../../../core/shared/configuration-property.model'; | ||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; | ||
import { LinkMenuItemModel } from '../menu-item/models/link.model'; | ||
import { TextMenuItemModel } from '../menu-item/models/text.model'; | ||
import { MenuItemType } from '../menu-item-type.model'; | ||
import { PartialMenuSection } from '../menu-provider.model'; | ||
import { AbstractExpandableMenuProvider } from './helper-providers/expandable-menu-provider'; | ||
|
||
/** | ||
* Menu provider to create the report menu sections | ||
*/ | ||
@Injectable() | ||
export class CreateReportMenuProvider extends AbstractExpandableMenuProvider { | ||
constructor( | ||
protected authorizationService: AuthorizationDataService, | ||
protected configurationDataService: ConfigurationDataService, | ||
) { | ||
super(); | ||
} | ||
|
||
getSubSections(): Observable<PartialMenuSection[]> { | ||
return observableCombineLatest([ | ||
this.configurationDataService.findByPropertyName('contentreport.enable').pipe( | ||
getFirstCompletedRemoteData(), | ||
map((res: RemoteData<ConfigurationProperty>) => res.hasSucceeded && res.payload && res.payload.values[0] === 'true'), | ||
), | ||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf), | ||
]).pipe( | ||
map(([reportEnabled, isSiteAdmin]: [boolean, boolean]) => { | ||
return [ | ||
/* Collections Report */ | ||
{ | ||
visible: isSiteAdmin && reportEnabled, | ||
model: { | ||
type: MenuItemType.LINK, | ||
text: 'menu.section.reports.collections', | ||
link: '/admin/reports/collections', | ||
} as LinkMenuItemModel, | ||
icon: 'user-check', | ||
}, | ||
/* Queries Report */ | ||
{ | ||
visible: isSiteAdmin && reportEnabled, | ||
model: { | ||
type: MenuItemType.LINK, | ||
text: 'menu.section.reports.queries', | ||
link: '/admin/reports/queries', | ||
} as LinkMenuItemModel, | ||
icon: 'user-check', | ||
}, | ||
]; | ||
})); | ||
} | ||
|
||
getTopSection(): Observable<PartialMenuSection> { | ||
return observableCombineLatest([ | ||
this.configurationDataService.findByPropertyName('contentreport.enable').pipe( | ||
getFirstCompletedRemoteData(), | ||
map((res: RemoteData<ConfigurationProperty>) => res.hasSucceeded && res.payload && res.payload.values[0] === 'true'), | ||
), | ||
this.authorizationService.isAuthorized(FeatureID.AdministratorOf), | ||
]).pipe( | ||
map(([reportEnabled, isSiteAdmin]: [boolean, boolean]) => { | ||
return { | ||
visible: isSiteAdmin && reportEnabled, | ||
model: { | ||
type: MenuItemType.TEXT, | ||
text: 'menu.section.reports', | ||
} as TextMenuItemModel, | ||
icon: 'file-alt', | ||
}; | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.