diff --git a/config/config.example.yml b/config/config.example.yml index c87f94284c..671e15c1b2 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -229,10 +229,8 @@ themes: href: assets/dspace/images/favicons/manifest.webmanifest # The default bundles that should always be displayed as suggestions when you upload a new bundle -standardBundles: - - bundle: ORIGINAL - - bundle: THUMBNAIL - - bundle: LICENSE +bundle: + - standardBundles: [ ORIGINAL, THUMBNAIL, 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.ts b/src/app/item-page/bitstreams/upload/upload-bitstream.component.ts index 47e55e34dc..d825a40174 100644 --- a/src/app/item-page/bitstreams/upload/upload-bitstream.component.ts +++ b/src/app/item-page/bitstreams/upload/upload-bitstream.component.ts @@ -19,7 +19,6 @@ import { RequestService } from '../../../core/data/request.service'; import { getBitstreamModuleRoute } from '../../../app-routing-paths'; import { getEntityEditRoute } from '../../item-page-routing-paths'; import { environment } from '../../../../environments/environment'; -import { StandardBundleConfig } from '../../../../config/standard-bundle-config.interface'; @Component({ selector: 'ds-upload-bitstream', @@ -115,29 +114,27 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy { if (remoteData.hasSucceeded) { if (remoteData.payload.page) { this.bundles = remoteData.payload.page; - } else if (environment.standardBundles) { - this.bundles = environment.standardBundles.map((defaultBundle: StandardBundleConfig) => Object.assign(new Bundle(), { - _name: defaultBundle.bundle, - type: 'bundle' - }) - ); - } - if (remoteData.payload.page && environment.standardBundles) { - for (const defaultBundle of environment.standardBundles) { + for (const defaultBundle of environment.bundle.standardBundles) { let check = true; remoteData.payload.page.forEach((bundle: Bundle) => { // noinspection JSDeprecatedSymbols - if (defaultBundle.bundle === bundle.name) { + if (defaultBundle === bundle.name) { check = false; } }); if (check) { this.bundles.push(Object.assign(new Bundle(), { - _name: defaultBundle.bundle, + _name: defaultBundle, type: 'bundle' })); } } + } else { + this.bundles = environment.bundle.standardBundles.map((defaultBundle: string) => Object.assign(new Bundle(), { + _name: defaultBundle, + type: 'bundle' + }) + ); } return observableOf(remoteData.payload.page); } @@ -232,7 +229,9 @@ export class UploadBitstreamComponent implements OnInit, OnDestroy { onClick(bundle: Bundle) { this.selectedBundleId = bundle.id; this.selectedBundleName = bundle.name; - this.setUploadUrl(); + if (bundle.id) { + this.setUploadUrl(); + } } /** diff --git a/src/config/app-config.interface.ts b/src/config/app-config.interface.ts index 1355e5cb46..a41ec05b82 100644 --- a/src/config/app-config.interface.ts +++ b/src/config/app-config.interface.ts @@ -14,7 +14,7 @@ import { AuthConfig } from './auth-config.interfaces'; import { UIServerConfig } from './ui-server-config.interface'; import { MediaViewerConfig } from './media-viewer-config.interface'; import { BrowseByConfig } from './browse-by-config.interface'; -import { StandardBundleConfig } from './standard-bundle-config.interface'; +import { BundleConfig } from './bundle-config.interface'; interface AppConfig extends Config { ui: UIServerConfig; @@ -33,7 +33,7 @@ interface AppConfig extends Config { collection: CollectionPageConfig; themes: ThemeConfig[]; mediaViewer: MediaViewerConfig; - standardBundles: StandardBundleConfig[]; + bundle: BundleConfig; } const APP_CONFIG = new InjectionToken('APP_CONFIG'); diff --git a/src/config/bundle-config.interface.ts b/src/config/bundle-config.interface.ts new file mode 100644 index 0000000000..5ffef2156a --- /dev/null +++ b/src/config/bundle-config.interface.ts @@ -0,0 +1,11 @@ +import { Config } from './config.interface'; + +export interface BundleConfig extends Config { + + /** + * List of standard bundles to select in adding bitstreams to items + * Used by {@link UploadBitstreamComponent}. + */ + standardBundles: string[]; + +} diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index 886242adf9..9409ac173a 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -14,6 +14,7 @@ import { ServerConfig } from './server-config.interface'; import { SubmissionConfig } from './submission-config.interface'; import { ThemeConfig } from './theme.model'; import { UIServerConfig } from './ui-server-config.interface'; +import { BundleConfig } from './bundle-config.interface'; export class DefaultAppConfig implements AppConfig { production = false; @@ -301,11 +302,9 @@ 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. - standardBundles: [ - { bundle: 'ORIGINAL' }, - { bundle: 'THUMBNAIL' }, - { bundle: 'LICENSE' } - ]; + bundle: BundleConfig = { + standardBundles: ['ORIGINAL', 'THUMBNAIL', '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. // For videos, this enables embedded video streaming diff --git a/src/config/standard-bundle-config.interface.ts b/src/config/standard-bundle-config.interface.ts deleted file mode 100644 index 6567454603..0000000000 --- a/src/config/standard-bundle-config.interface.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Config } from './config.interface'; - -export interface StandardBundleConfig extends Config { - - /** - * Used by {@link UploadBitstreamComponent}. - */ - bundle: string; - -} diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index 23c41a6cf6..c21f19fd45 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -224,11 +224,9 @@ export const environment: BuildConfig = { name: 'base', }, ], - standardBundles: [ - { bundle: 'ORIGINAL' }, - { bundle: 'THUMBNAIL' }, - { bundle: 'LICENSE' } - ], + bundle: { + standardBundles: ['ORIGINAL', 'THUMBNAIL', 'LICENSE'], + }, mediaViewer: { image: true, video: true