diff --git a/config/config.example.yml b/config/config.example.yml index 154b0dea47a..56ed7b940b2 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -449,7 +449,7 @@ themes: # The default bundles that should always be displayed as suggestions when you upload a new bundle bundle: - standardBundles: [ ORIGINAL, THUMBNAIL, LICENSE ] + standardBundles: [ ORIGINAL, THUMBNAIL, LICENSE, CC-LICENSE ] # Whether to enable media viewer for image and/or video Bitstreams (i.e. Bitstreams whose MIME type starts with 'image' or 'video'). # For images, this enables a gallery viewer where you can zoom or page through images. diff --git a/src/app/item-page/bitstreams/upload/upload-bitstream.component.spec.ts b/src/app/item-page/bitstreams/upload/upload-bitstream.component.spec.ts index 6a57c6d4b59..bf7d3b6c2d1 100644 --- a/src/app/item-page/bitstreams/upload/upload-bitstream.component.spec.ts +++ b/src/app/item-page/bitstreams/upload/upload-bitstream.component.spec.ts @@ -14,6 +14,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { TranslateModule } from '@ngx-translate/core'; import { of as observableOf } from 'rxjs'; +import { DefaultAppConfig } from '../../../../config/default-app-config'; import { environment } from '../../../../environments/environment'; import { AuthService } from '../../../core/auth/auth.service'; import { BundleDataService } from '../../../core/data/bundle-data.service'; @@ -281,6 +282,48 @@ describe('UploadBitstreamComponent', () => { }); }); + describe('when the shipped default bundle configuration is used', () => { + const shippedStandardBundles = new DefaultAppConfig().bundle.standardBundles; + let originalStandardBundles: string[]; + + beforeEach(() => { + originalStandardBundles = environment.bundle.standardBundles; + environment.bundle.standardBundles = shippedStandardBundles; + }); + + afterEach(() => { + environment.bundle.standardBundles = originalStandardBundles; + }); + + describe('and the item has no bundles yet', () => { + beforeEach(waitForAsync(() => { + createUploadBitstreamTestingModule({}); + jasmine.getEnv().allowRespy(true); + mockItemDataService.getBundles.and.returnValue(createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), []))); + loadFixtureAndComp(); + })); + + it('should offer CC-LICENSE as a bundle to upload a bitstream to', () => { + // noinspection JSDeprecatedSymbols + expect(comp.bundles.map((suggestion: Bundle) => suggestion.name)).toContain('CC-LICENSE'); + }); + }); + + describe('and the item already has other bundles', () => { + beforeEach(waitForAsync(() => { + createUploadBitstreamTestingModule({}); + jasmine.getEnv().allowRespy(true); + mockItemDataService.getBundles.and.returnValue(createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [bundle]))); + loadFixtureAndComp(); + })); + + it('should offer CC-LICENSE as a bundle to upload a bitstream to', () => { + // noinspection JSDeprecatedSymbols + expect(comp.bundles.map((suggestion: Bundle) => suggestion.name)).toContain('CC-LICENSE'); + }); + }); + }); + /** * Setup an UploadBitstreamComponent testing module with custom queryParams for the route * @param queryParams diff --git a/src/config/default-app-config.spec.ts b/src/config/default-app-config.spec.ts new file mode 100644 index 00000000000..d0a759b3f45 --- /dev/null +++ b/src/config/default-app-config.spec.ts @@ -0,0 +1,21 @@ +import { DefaultAppConfig } from './default-app-config'; + +describe('DefaultAppConfig', () => { + describe('bundle.standardBundles', () => { + let standardBundles: string[]; + + beforeEach(() => { + standardBundles = new DefaultAppConfig().bundle.standardBundles; + }); + + it('should keep offering the out-of-the-box DSpace bundles', () => { + expect(standardBundles).toContain('ORIGINAL'); + expect(standardBundles).toContain('THUMBNAIL'); + expect(standardBundles).toContain('LICENSE'); + }); + + it('should offer CC-LICENSE, so a Creative Commons licence can be added to an item', () => { + expect(standardBundles).toContain('CC-LICENSE'); + }); + }); +}); diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index fcc8eb1b86c..845d7702d62 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -458,7 +458,7 @@ export class DefaultAppConfig implements AppConfig { // The default bundles that should always be displayed when you edit or add a bundle even when no bundle has been // added to the item yet. bundle: BundleConfig = { - standardBundles: ['ORIGINAL', 'THUMBNAIL', 'LICENSE'], + standardBundles: ['ORIGINAL', 'THUMBNAIL', 'LICENSE', 'CC-LICENSE'], }; // Whether to enable media viewer for image and/or video Bitstreams (i.e. Bitstreams whose MIME type starts with "image" or "video"). // For images, this enables a gallery viewer where you can zoom or page through images.