mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 05:23:06 +00:00
[CST-4248] bitstream authorizations page
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<div class="container">
|
||||
<ds-resource-policies [resourceType]="'bitstream'" [resourceUUID]="(dsoRD$ | async)?.payload?.id"></ds-resource-policies>
|
||||
<div class="button-row bottom">
|
||||
<div class="text-right">
|
||||
<a [routerLink]="['/bitstreams', (dsoRD$ | async)?.payload?.id, 'edit']" role="button" class="btn btn-outline-secondary mr-1">
|
||||
<i class="fas fa-arrow-left"></i> {{'bitstream.edit.return' | translate}}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,84 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ChangeDetectorRef, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { cold } from 'jasmine-marbles';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations.component';
|
||||
import { Bitstream } from '../../core/shared/bitstream.model';
|
||||
import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils';
|
||||
import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock';
|
||||
|
||||
describe('BitstreamAuthorizationsComponent', () => {
|
||||
let comp: BitstreamAuthorizationsComponent<DSpaceObject>;
|
||||
let fixture: ComponentFixture<BitstreamAuthorizationsComponent<any>>;
|
||||
|
||||
const bitstream = Object.assign(new Bitstream(), {
|
||||
sizeBytes: 10000,
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
value: 'file name',
|
||||
language: null
|
||||
}
|
||||
]
|
||||
},
|
||||
_links: {
|
||||
content: { href: 'file-selflink' }
|
||||
}
|
||||
});
|
||||
|
||||
const bitstreamRD = createSuccessfulRemoteDataObject(bitstream);
|
||||
|
||||
const routeStub = {
|
||||
data: observableOf({
|
||||
bitstream: bitstreamRD
|
||||
})
|
||||
};
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
TranslateModule.forRoot({
|
||||
loader: {
|
||||
provide: TranslateLoader,
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
})
|
||||
],
|
||||
declarations: [BitstreamAuthorizationsComponent],
|
||||
providers: [
|
||||
{ provide: ActivatedRoute, useValue: routeStub },
|
||||
ChangeDetectorRef,
|
||||
BitstreamAuthorizationsComponent,
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(BitstreamAuthorizationsComponent);
|
||||
comp = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
comp = null;
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(comp).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should init dso remote data properly', (done) => {
|
||||
const expected = cold('(a|)', { a: bitstreamRD });
|
||||
expect(comp.dsoRD$).toBeObservable(expected);
|
||||
done();
|
||||
});
|
||||
});
|
@@ -0,0 +1,40 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { first, map } from 'rxjs/operators';
|
||||
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-collection-authorizations',
|
||||
templateUrl: './bitstream-authorizations.component.html',
|
||||
})
|
||||
/**
|
||||
* Component that handles the Collection Authorizations
|
||||
*/
|
||||
export class BitstreamAuthorizationsComponent<TDomain extends DSpaceObject> implements OnInit {
|
||||
|
||||
/**
|
||||
* The initial DSO object
|
||||
*/
|
||||
public dsoRD$: Observable<RemoteData<TDomain>>;
|
||||
|
||||
/**
|
||||
* Initialize instance variables
|
||||
*
|
||||
* @param {ActivatedRoute} route
|
||||
*/
|
||||
constructor(
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the component, setting up the collection
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.dsoRD$ = this.route.data.pipe(first(), map((data) => data.bitstream));
|
||||
}
|
||||
}
|
@@ -4,8 +4,14 @@ import { EditBitstreamPageComponent } from './edit-bitstream-page/edit-bitstream
|
||||
import { AuthenticatedGuard } from '../core/auth/authenticated.guard';
|
||||
import { BitstreamPageResolver } from './bitstream-page.resolver';
|
||||
import { BitstreamDownloadPageComponent } from '../shared/bitstream-download-page/bitstream-download-page.component';
|
||||
import { ResourcePolicyTargetResolver } from '../shared/resource-policies/resolvers/resource-policy-target.resolver';
|
||||
import { ResourcePolicyCreateComponent } from '../shared/resource-policies/create/resource-policy-create.component';
|
||||
import { ResourcePolicyResolver } from '../shared/resource-policies/resolvers/resource-policy.resolver';
|
||||
import { ResourcePolicyEditComponent } from '../shared/resource-policies/edit/resource-policy-edit.component';
|
||||
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component';
|
||||
|
||||
const EDIT_BITSTREAM_PATH = ':id/edit';
|
||||
const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations';
|
||||
|
||||
/**
|
||||
* Routing module to help navigate Bitstream pages
|
||||
@@ -27,6 +33,36 @@ const EDIT_BITSTREAM_PATH = ':id/edit';
|
||||
bitstream: BitstreamPageResolver
|
||||
},
|
||||
canActivate: [AuthenticatedGuard]
|
||||
},
|
||||
{
|
||||
path: EDIT_BITSTREAM_AUTHORIZATIONS_PATH,
|
||||
|
||||
children: [
|
||||
{
|
||||
path: 'create',
|
||||
resolve: {
|
||||
resourcePolicyTarget: ResourcePolicyTargetResolver
|
||||
},
|
||||
component: ResourcePolicyCreateComponent,
|
||||
data: { title: 'resource-policies.create.page.title', showBreadcrumbs: true }
|
||||
},
|
||||
{
|
||||
path: 'edit',
|
||||
resolve: {
|
||||
resourcePolicy: ResourcePolicyResolver
|
||||
},
|
||||
component: ResourcePolicyEditComponent,
|
||||
data: { title: 'resource-policies.edit.page.title', showBreadcrumbs: true }
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
resolve: {
|
||||
bitstream: BitstreamPageResolver
|
||||
},
|
||||
component: BitstreamAuthorizationsComponent,
|
||||
data: { title: 'bitstream.edit.authorizations.title', showBreadcrumbs: true }
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
],
|
||||
|
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
import { EditBitstreamPageComponent } from './edit-bitstream-page/edit-bitstream-page.component';
|
||||
import { BitstreamPageRoutingModule } from './bitstream-page-routing.module';
|
||||
import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component';
|
||||
|
||||
/**
|
||||
* This module handles all components that are necessary for Bitstream related pages
|
||||
@@ -14,6 +15,7 @@ import { BitstreamPageRoutingModule } from './bitstream-page-routing.module';
|
||||
BitstreamPageRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
BitstreamAuthorizationsComponent,
|
||||
EditBitstreamPageComponent
|
||||
]
|
||||
})
|
||||
|
@@ -530,6 +530,12 @@
|
||||
|
||||
|
||||
|
||||
"bitstream.edit.authorizations.link": "Edit bitstream's Policies",
|
||||
|
||||
"bitstream.edit.authorizations.title": "Edit bitstream's Policies",
|
||||
|
||||
"bitstream.edit.return": "Back",
|
||||
|
||||
"bitstream.edit.bitstream": "Bitstream: ",
|
||||
|
||||
"bitstream.edit.form.description.hint": "Optionally, provide a brief description of the file, for example \"<i>Main article</i>\" or \"<i>Experiment data readings</i>\".",
|
||||
@@ -1817,8 +1823,6 @@
|
||||
|
||||
"item.page.description": "Description",
|
||||
|
||||
"item.page.edit": "Edit this item",
|
||||
|
||||
"item.page.journal-issn": "Journal ISSN",
|
||||
|
||||
"item.page.journal-title": "Journal Title",
|
||||
|
Reference in New Issue
Block a user