diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.html b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.html
new file mode 100644
index 0000000000..141e628ac0
--- /dev/null
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.scss b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.scss
new file mode 100644
index 0000000000..a156132e3f
--- /dev/null
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.scss
@@ -0,0 +1,16 @@
+.parent {
+ display: flex;
+}
+
+.upload {
+ flex: auto;
+}
+
+.add {
+ flex: initial;
+}
+
+#entityControlsDropdownMenu {
+ min-width: 18rem;
+ box-shadow: $btn-focus-box-shadow;
+}
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.spec.ts b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.spec.ts
new file mode 100644
index 0000000000..aa223fc10e
--- /dev/null
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.spec.ts
@@ -0,0 +1,189 @@
+import { Component, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
+import { Router } from '@angular/router';
+import { By } from '@angular/platform-browser';
+import { CommonModule } from '@angular/common';
+import { TranslateModule } from '@ngx-translate/core';
+import { of as observableOf } from 'rxjs';
+import { createPaginatedList, createTestComponent } from '../../../shared/testing/utils.test';
+import { MyDSpaceNewExternalDropdownComponent } from './my-dspace-new-external-dropdown.component';
+import { EntityTypeService } from '../../../core/data/entity-type.service';
+import { ItemType } from '../../../core/shared/item-relationships/item-type.model';
+import { ResourceType } from '../../../core/shared/resource-type';
+import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
+import { PageInfo } from '../../../core/shared/page-info.model';
+import { RouterStub } from '../../../shared/testing/router.stub';
+
+export function getMockEntityTypeService(): EntityTypeService {
+ const pageInfo = { elementsPerPage: 20, totalElements: 4, totalPages: 1, currentPage: 0 } as PageInfo;
+ const type1: ItemType = {
+ id: '1',
+ label: 'Publication',
+ uuid: '1',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+ const type2: ItemType = {
+ id: '2',
+ label: 'Journal',
+ uuid: '2',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+ const type3: ItemType = {
+ id: '2',
+ label: 'DataPackage',
+ uuid: '2',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+ const rd$ = createSuccessfulRemoteDataObject$(createPaginatedList([type1, type2, type3]));
+ return jasmine.createSpyObj('entityTypeService', {
+ getAllAuthorizedRelationshipTypeImport: rd$,
+ hasMoreThanOneAuthorizedImport: observableOf(true)
+ });
+}
+
+export function getMockEmptyEntityTypeService(): EntityTypeService {
+ const pageInfo = { elementsPerPage: 20, totalElements: 1, totalPages: 1, currentPage: 0 } as PageInfo;
+ const type1: ItemType = {
+ id: '1',
+ label: 'Publication',
+ uuid: '1',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+ const rd$ = createSuccessfulRemoteDataObject$(createPaginatedList([type1]));
+ return jasmine.createSpyObj('entityTypeService', {
+ getAllAuthorizedRelationshipTypeImport: rd$,
+ hasMoreThanOneAuthorizedImport: observableOf(false)
+ });
+}
+
+describe('MyDSpaceNewExternalDropdownComponent test', () => {
+ let testComp: TestComponent;
+ let testFixture: ComponentFixture;
+ let submissionComponent: MyDSpaceNewExternalDropdownComponent;
+ let submissionComponentFixture: ComponentFixture;
+
+ const entityType1: ItemType = {
+ id: '1',
+ label: 'Publication',
+ uuid: '1',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+
+ describe('With only one Entity', () => {
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CommonModule,
+ TranslateModule.forRoot(),
+ ],
+ declarations: [
+ MyDSpaceNewExternalDropdownComponent,
+ TestComponent
+ ],
+ providers: [
+ { provide: EntityTypeService, useValue: getMockEmptyEntityTypeService() },
+ { provide: Router, useValue: new RouterStub() },
+ MyDSpaceNewExternalDropdownComponent
+ ],
+ schemas: [NO_ERRORS_SCHEMA]
+ }).compileComponents();
+
+ const html = ``;
+
+ testFixture = createTestComponent(html, TestComponent) as ComponentFixture;
+ testComp = testFixture.componentInstance;
+
+ submissionComponentFixture = TestBed.createComponent(MyDSpaceNewExternalDropdownComponent);
+ submissionComponent = submissionComponentFixture.componentInstance;
+ submissionComponentFixture.detectChanges();
+ }));
+
+ afterEach(() => {
+ testFixture.destroy();
+ submissionComponentFixture.destroy();
+ });
+
+ it('should create MyDSpaceNewExternalDropdownComponent', inject([MyDSpaceNewExternalDropdownComponent], (app: MyDSpaceNewExternalDropdownComponent) => {
+ expect(app).toBeDefined();
+ }));
+
+ it('should be a single button', inject([MyDSpaceNewExternalDropdownComponent], (app: MyDSpaceNewExternalDropdownComponent) => {
+ submissionComponentFixture.detectChanges();
+ const addDivElement: DebugElement = submissionComponentFixture.debugElement.query(By.css('.add'));
+ const addDiv = addDivElement.nativeElement;
+ expect(addDiv.innerHTML).toBeDefined();
+ const buttonElement: DebugElement = addDivElement.query(By.css('.btn'));
+ const button = buttonElement.nativeElement;
+ expect(button.innerHTML).toBeDefined();
+ const dropdownElement: DebugElement = submissionComponentFixture.debugElement.query(By.css('.dropdown-menu'));
+ expect(dropdownElement).toBeNull();
+ }));
+ });
+
+ describe('With more than one Entity', () => {
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CommonModule,
+ TranslateModule.forRoot(),
+ ],
+ declarations: [
+ MyDSpaceNewExternalDropdownComponent,
+ TestComponent
+ ],
+ providers: [
+ { provide: EntityTypeService, useValue: getMockEntityTypeService() },
+ { provide: Router, useValue: new RouterStub() },
+ MyDSpaceNewExternalDropdownComponent
+ ],
+ schemas: [NO_ERRORS_SCHEMA]
+ }).compileComponents();
+
+ const html = ``;
+
+ testFixture = createTestComponent(html, TestComponent) as ComponentFixture;
+ testComp = testFixture.componentInstance;
+
+ submissionComponentFixture = TestBed.createComponent(MyDSpaceNewExternalDropdownComponent);
+ submissionComponent = submissionComponentFixture.componentInstance;
+ submissionComponentFixture.detectChanges();
+ }));
+
+ afterEach(() => {
+ testFixture.destroy();
+ submissionComponentFixture.destroy();
+ });
+
+ it('should create MyDSpaceNewExternalDropdownComponent', inject([MyDSpaceNewExternalDropdownComponent], (app: MyDSpaceNewExternalDropdownComponent) => {
+ expect(app).toBeDefined();
+ }));
+
+ it('should be a dropdown button', inject([MyDSpaceNewExternalDropdownComponent], (app: MyDSpaceNewExternalDropdownComponent) => {
+ const dropdownElement: DebugElement = submissionComponentFixture.debugElement.query(By.css('.dropdown-menu'));
+ const dropdown = dropdownElement.nativeElement;
+ expect(dropdown.innerHTML).toBeDefined();
+ }));
+
+ it('should invoke modalService.open', () => {
+ submissionComponent.openPage(entityType1);
+
+ expect((submissionComponent as any).router.navigate).toHaveBeenCalled();
+ });
+ });
+});
+
+// declare a test component
+@Component({
+ selector: 'ds-test-cmp',
+ template: ``
+})
+class TestComponent {
+ reload = (event) => {
+ return;
+ }
+}
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.ts b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.ts
new file mode 100644
index 0000000000..e806f162f4
--- /dev/null
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component.ts
@@ -0,0 +1,106 @@
+import { Component, OnDestroy, OnInit } from '@angular/core';
+import { Router } from '@angular/router';
+
+import { Observable, of as observableOf, Subscription } from 'rxjs';
+import { map, mergeMap, take } from 'rxjs/operators';
+
+import { EntityTypeService } from '../../../core/data/entity-type.service';
+import { ItemType } from '../../../core/shared/item-relationships/item-type.model';
+import { FindListOptions } from '../../../core/data/request.models';
+import { hasValue } from '../../../shared/empty.util';
+import { RemoteData } from '../../../core/data/remote-data';
+import { PaginatedList } from '../../../core/data/paginated-list.model';
+
+/**
+ * This component represents the 'Import metadata from external source' dropdown menu
+ */
+@Component({
+ selector: 'ds-my-dspace-new-external-dropdown',
+ styleUrls: ['./my-dspace-new-external-dropdown.component.scss'],
+ templateUrl: './my-dspace-new-external-dropdown.component.html'
+})
+export class MyDSpaceNewExternalDropdownComponent implements OnInit, OnDestroy {
+
+ /**
+ * Used to verify if there are one or more entities available
+ */
+ public moreThanOne$: Observable;
+
+ /**
+ * The entity observble (only if there is only one entity available)
+ */
+ public singleEntity$: Observable;
+
+ /**
+ * The entity object (only if there is only one entity available)
+ */
+ public singleEntity: ItemType;
+
+ /**
+ * TRUE if the page is initialized
+ */
+ public initialized$: Observable;
+
+ /**
+ * Array to track all subscriptions and unsubscribe them onDestroy
+ * @type {Array}
+ */
+ public subs: Subscription[] = [];
+
+ /**
+ * Initialize instance variables
+ *
+ * @param {EntityTypeService} entityTypeService
+ * @param {Router} router
+ */
+ constructor(private entityTypeService: EntityTypeService,
+ private router: Router) { }
+
+ /**
+ * Initialize entity type list
+ */
+ ngOnInit() {
+ this.initialized$ = observableOf(false);
+ this.moreThanOne$ = this.entityTypeService.hasMoreThanOneAuthorizedImport();
+ this.singleEntity$ = this.moreThanOne$.pipe(
+ mergeMap((response: boolean) => {
+ if (!response) {
+ const findListOptions: FindListOptions = {
+ elementsPerPage: 1,
+ currentPage: 1
+ };
+ return this.entityTypeService.getAllAuthorizedRelationshipTypeImport(findListOptions).pipe(
+ map((entities: RemoteData>) => {
+ this.initialized$ = observableOf(true);
+ return entities.payload.page[0];
+ }),
+ take(1)
+ );
+ } else {
+ this.initialized$ = observableOf(true);
+ return observableOf(null);
+ }
+ }),
+ take(1)
+ );
+ this.subs.push(
+ this.singleEntity$.subscribe((result) => this.singleEntity = result )
+ );
+ }
+
+ /**
+ * Method called on clicking the button 'Import metadata from external source'. It opens the page of the external import.
+ */
+ openPage(entity: ItemType) {
+ this.router.navigate(['/import-external'], { queryParams: { entity: entity.label } });
+ }
+
+ /**
+ * Unsubscribe from the subscription
+ */
+ ngOnDestroy(): void {
+ this.subs
+ .filter((subscription) => hasValue(subscription))
+ .forEach((subscription) => subscription.unsubscribe());
+ }
+}
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.html b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.html
new file mode 100644
index 0000000000..ac40bbb005
--- /dev/null
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.scss b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.scss
new file mode 100644
index 0000000000..a156132e3f
--- /dev/null
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.scss
@@ -0,0 +1,16 @@
+.parent {
+ display: flex;
+}
+
+.upload {
+ flex: auto;
+}
+
+.add {
+ flex: initial;
+}
+
+#entityControlsDropdownMenu {
+ min-width: 18rem;
+ box-shadow: $btn-focus-box-shadow;
+}
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.spec.ts b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.spec.ts
new file mode 100644
index 0000000000..2e7361c560
--- /dev/null
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.spec.ts
@@ -0,0 +1,194 @@
+import { Component, DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
+import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
+import { By } from '@angular/platform-browser';
+import { CommonModule } from '@angular/common';
+import { TranslateModule } from '@ngx-translate/core';
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
+import { of as observableOf } from 'rxjs';
+import { createPaginatedList, createTestComponent } from '../../../shared/testing/utils.test';
+import { MyDSpaceNewSubmissionDropdownComponent } from './my-dspace-new-submission-dropdown.component';
+import { EntityTypeService } from '../../../core/data/entity-type.service';
+import { ItemType } from '../../../core/shared/item-relationships/item-type.model';
+import { ResourceType } from '../../../core/shared/resource-type';
+import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
+import { PageInfo } from '../../../core/shared/page-info.model';
+
+export function getMockEntityTypeService(): EntityTypeService {
+ const type1: ItemType = {
+ id: '1',
+ label: 'Publication',
+ uuid: '1',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+ const type2: ItemType = {
+ id: '2',
+ label: 'Journal',
+ uuid: '2',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+ const type3: ItemType = {
+ id: '2',
+ label: 'DataPackage',
+ uuid: '2',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+ const rd$ = createSuccessfulRemoteDataObject$(createPaginatedList([type1, type2, type3]));
+ return jasmine.createSpyObj('entityTypeService', {
+ getAllAuthorizedRelationshipType: rd$,
+ hasMoreThanOneAuthorized: observableOf(true)
+ });
+}
+
+export function getMockEmptyEntityTypeService(): EntityTypeService {
+ const pageInfo = { elementsPerPage: 20, totalElements: 1, totalPages: 1, currentPage: 0 } as PageInfo;
+ const type1: ItemType = {
+ id: '1',
+ label: 'Publication',
+ uuid: '1',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+ const rd$ = createSuccessfulRemoteDataObject$(createPaginatedList([type1]));
+ return jasmine.createSpyObj('entityTypeService', {
+ getAllAuthorizedRelationshipType: rd$,
+ hasMoreThanOneAuthorized: observableOf(false)
+ });
+}
+
+describe('MyDSpaceNewSubmissionDropdownComponent test', () => {
+ let testComp: TestComponent;
+ let testFixture: ComponentFixture;
+ let submissionComponent: MyDSpaceNewSubmissionDropdownComponent;
+ let submissionComponentFixture: ComponentFixture;
+
+ const entityType1: ItemType = {
+ id: '1',
+ label: 'Publication',
+ uuid: '1',
+ type: new ResourceType('entitytype'),
+ _links: undefined
+ };
+
+ const modalStub = {
+ open: () => null,
+ close: () => null,
+ dismiss: () => null
+ };
+
+ describe('With only one Entity', () => {
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CommonModule,
+ TranslateModule.forRoot(),
+ ],
+ declarations: [
+ MyDSpaceNewSubmissionDropdownComponent,
+ TestComponent
+ ],
+ providers: [
+ { provide: EntityTypeService, useValue: getMockEmptyEntityTypeService() },
+ { provide: NgbModal, useValue: modalStub },
+ MyDSpaceNewSubmissionDropdownComponent
+ ],
+ schemas: [NO_ERRORS_SCHEMA]
+ }).compileComponents();
+
+ const html = ``;
+
+ testFixture = createTestComponent(html, TestComponent) as ComponentFixture;
+ testComp = testFixture.componentInstance;
+
+ submissionComponentFixture = TestBed.createComponent(MyDSpaceNewSubmissionDropdownComponent);
+ submissionComponent = submissionComponentFixture.componentInstance;
+ submissionComponentFixture.detectChanges();
+ }));
+
+ afterEach(() => {
+ testFixture.destroy();
+ submissionComponentFixture.destroy();
+ });
+
+ it('should create MyDSpaceNewSubmissionDropdownComponent', inject([MyDSpaceNewSubmissionDropdownComponent], (app: MyDSpaceNewSubmissionDropdownComponent) => {
+ expect(app).toBeDefined();
+ }));
+
+ it('should be a single button', inject([MyDSpaceNewSubmissionDropdownComponent], (app: MyDSpaceNewSubmissionDropdownComponent) => {
+ submissionComponentFixture.detectChanges();
+ const addDivElement: DebugElement = submissionComponentFixture.debugElement.query(By.css('.add'));
+ const addDiv = addDivElement.nativeElement;
+ expect(addDiv.innerHTML).toBeDefined();
+ const buttonElement: DebugElement = addDivElement.query(By.css('.btn'));
+ const button = buttonElement.nativeElement;
+ expect(button.innerHTML).toBeDefined();
+ const dropdownElement: DebugElement = submissionComponentFixture.debugElement.query(By.css('.dropdown-menu'));
+ expect(dropdownElement).toBeNull();
+ }));
+ });
+
+ describe('With more than one Entity', () => {
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CommonModule,
+ TranslateModule.forRoot(),
+ ],
+ declarations: [
+ MyDSpaceNewSubmissionDropdownComponent,
+ TestComponent
+ ],
+ providers: [
+ { provide: EntityTypeService, useValue: getMockEntityTypeService() },
+ { provide: NgbModal, useValue: modalStub },
+ MyDSpaceNewSubmissionDropdownComponent
+ ],
+ schemas: [NO_ERRORS_SCHEMA]
+ }).compileComponents();
+
+ const html = ``;
+
+ testFixture = createTestComponent(html, TestComponent) as ComponentFixture;
+ testComp = testFixture.componentInstance;
+
+ submissionComponentFixture = TestBed.createComponent(MyDSpaceNewSubmissionDropdownComponent);
+ submissionComponent = submissionComponentFixture.componentInstance;
+ submissionComponentFixture.detectChanges();
+ }));
+
+ afterEach(() => {
+ testFixture.destroy();
+ submissionComponentFixture.destroy();
+ });
+
+ it('should create MyDSpaceNewSubmissionDropdownComponent', inject([MyDSpaceNewSubmissionDropdownComponent], (app: MyDSpaceNewSubmissionDropdownComponent) => {
+ expect(app).toBeDefined();
+ }));
+
+ it('should be a dropdown button', inject([MyDSpaceNewSubmissionDropdownComponent], (app: MyDSpaceNewSubmissionDropdownComponent) => {
+ const dropdownElement: DebugElement = submissionComponentFixture.debugElement.query(By.css('.dropdown-menu'));
+ const dropdown = dropdownElement.nativeElement;
+ expect(dropdown.innerHTML).toBeDefined();
+ }));
+
+ it('should invoke modalService.open', () => {
+ spyOn((submissionComponent as any).modalService, 'open').and.returnValue({ componentInstance: { } });
+ submissionComponent.openDialog(entityType1);
+
+ expect((submissionComponent as any).modalService.open).toHaveBeenCalled();
+ });
+ });
+});
+
+// declare a test component
+@Component({
+ selector: 'ds-test-cmp',
+ template: ``
+})
+class TestComponent {
+ reload = (event) => {
+ return;
+ }
+}
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.ts b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.ts
new file mode 100644
index 0000000000..0ff363b164
--- /dev/null
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.ts
@@ -0,0 +1,109 @@
+import { Component, OnDestroy, OnInit } from '@angular/core';
+
+import { Observable, of as observableOf, Subscription } from 'rxjs';
+import { map, mergeMap, take } from 'rxjs/operators';
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
+
+import { EntityTypeService } from '../../../core/data/entity-type.service';
+import { ItemType } from '../../../core/shared/item-relationships/item-type.model';
+import { FindListOptions } from '../../../core/data/request.models';
+import { hasValue } from '../../../shared/empty.util';
+import { CreateItemParentSelectorComponent } from '../../../shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component';
+import { RemoteData } from '../../../core/data/remote-data';
+import { PaginatedList } from '../../../core/data/paginated-list.model';
+
+/**
+ * This component represents the new submission dropdown
+ */
+@Component({
+ selector: 'ds-my-dspace-new-submission-dropdown',
+ styleUrls: ['./my-dspace-new-submission-dropdown.component.scss'],
+ templateUrl: './my-dspace-new-submission-dropdown.component.html'
+})
+export class MyDSpaceNewSubmissionDropdownComponent implements OnInit, OnDestroy {
+
+ /**
+ * Used to verify if there are one or more entities available
+ */
+ public moreThanOne$: Observable;
+
+ /**
+ * The entity observble (only if there is only one entity available)
+ */
+ public singleEntity$: Observable;
+
+ /**
+ * The entity object (only if there is only one entity available)
+ */
+ public singleEntity: ItemType;
+
+ /**
+ * TRUE if the page is initialized
+ */
+ public initialized$: Observable;
+
+ /**
+ * Array to track all subscriptions and unsubscribe them onDestroy
+ * @type {Array}
+ */
+ public subs: Subscription[] = [];
+
+ /**
+ * Initialize instance variables
+ *
+ * @param {EntityTypeService} entityTypeService
+ * @param {NgbModal} modalService
+ */
+ constructor(private entityTypeService: EntityTypeService,
+ private modalService: NgbModal) { }
+
+ /**
+ * Initialize entity type list
+ */
+ ngOnInit() {
+ this.initialized$ = observableOf(false);
+ this.moreThanOne$ = this.entityTypeService.hasMoreThanOneAuthorized();
+ this.singleEntity$ = this.moreThanOne$.pipe(
+ mergeMap((response: boolean) => {
+ if (!response) {
+ const findListOptions: FindListOptions = {
+ elementsPerPage: 1,
+ currentPage: 1
+ };
+ return this.entityTypeService.getAllAuthorizedRelationshipType(findListOptions).pipe(
+ map((entities: RemoteData>) => {
+ this.initialized$ = observableOf(true);
+ return entities.payload.page[0];
+ }),
+ take(1)
+ );
+ } else {
+ this.initialized$ = observableOf(true);
+ return observableOf(null);
+ }
+ }),
+ take(1)
+ );
+ this.subs.push(
+ this.singleEntity$.subscribe((result) => this.singleEntity = result )
+ );
+ }
+
+ /**
+ * Method called on clicking the button "New Submition", It opens a dialog for
+ * select a collection.
+ */
+ openDialog(entity: ItemType) {
+ const modalRef = this.modalService.open(CreateItemParentSelectorComponent);
+ modalRef.componentInstance.entityType = entity.label;
+ }
+
+ /**
+ * Unsubscribe from the subscription
+ */
+ ngOnDestroy(): void {
+ this.subs
+ .filter((subscription) => hasValue(subscription))
+ .forEach((subscription) => subscription.unsubscribe());
+ }
+}
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.html b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.html
index 028b7df5a5..d0052b9355 100644
--- a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.html
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.html
@@ -8,14 +8,10 @@
-
+
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.spec.ts b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.spec.ts
index 7c6d8918cb..fb8ecbf65c 100644
--- a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.spec.ts
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.spec.ts
@@ -1,7 +1,6 @@
import { ChangeDetectorRef, Component, NO_ERRORS_SCHEMA } from '@angular/core';
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
-import { By } from '@angular/platform-browser';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
@@ -25,6 +24,8 @@ import { HttpXsrfTokenExtractor } from '@angular/common/http';
import { CookieService } from '../../core/services/cookie.service';
import { CookieServiceMock } from '../../shared/mocks/cookie.service.mock';
import { HttpXsrfTokenExtractorMock } from '../../shared/mocks/http-xsrf-token-extractor.mock';
+import { getMockEntityTypeService } from './my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component.spec';
+import { EntityTypeService } from '../../core/data/entity-type.service';
describe('MyDSpaceNewSubmissionComponent test', () => {
@@ -62,6 +63,7 @@ describe('MyDSpaceNewSubmissionComponent test', () => {
{ provide: HttpXsrfTokenExtractor, useValue: new HttpXsrfTokenExtractorMock('mock-token') },
{ provide: CookieService, useValue: new CookieServiceMock() },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(800) },
+ { provide: EntityTypeService, useValue: getMockEntityTypeService() },
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
@@ -104,20 +106,6 @@ describe('MyDSpaceNewSubmissionComponent test', () => {
comp.uploaderComponent.uploader = uploader;
});
- it('should call app.openDialog', (done) => {
- spyOn(comp, 'openDialog');
- const submissionButton = fixture.debugElement.query(By.css('button.btn-primary'));
- submissionButton.triggerEventHandler('click', null);
-
- fixture.detectChanges();
-
- fixture.whenStable().then(() => {
- expect(comp.openDialog).toHaveBeenCalled();
- done();
- });
-
- });
-
it('should show a collection selector if only one file are uploaded', (done) => {
spyOn((comp as any).modalService, 'open').and.returnValue({ result: new Promise((res, rej) => {/****/}) });
comp.afterFileLoaded(['']);
diff --git a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts
index c1e67561b2..580afd8ad4 100644
--- a/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts
+++ b/src/app/my-dspace-page/my-dspace-new-submission/my-dspace-new-submission.component.ts
@@ -14,7 +14,6 @@ import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
import { NotificationType } from '../../shared/notifications/models/notification-type';
import { hasValue } from '../../shared/empty.util';
import { SearchResult } from '../../shared/search/search-result.model';
-import { CreateItemParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component';
import { CollectionSelectorComponent } from '../collection-selector/collection-selector.component';
import { UploaderComponent } from '../../shared/uploader/uploader.component';
import { UploaderError } from '../../shared/uploader/uploader-error.model';
@@ -118,14 +117,6 @@ export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit {
this.notificationsService.error(null, this.translate.get(errorMessageKey));
}
- /**
- * Method called on clicking the button "New Submition", It opens a dialog for
- * select a collection.
- */
- openDialog() {
- this.modalService.open(CreateItemParentSelectorComponent);
- }
-
/**
* Method invoked after all file are loaded from upload plugin
*/
diff --git a/src/app/my-dspace-page/my-dspace-page.module.ts b/src/app/my-dspace-page/my-dspace-page.module.ts
index 52c80c90b0..a5a18effbc 100644
--- a/src/app/my-dspace-page/my-dspace-page.module.ts
+++ b/src/app/my-dspace-page/my-dspace-page.module.ts
@@ -11,6 +11,8 @@ import { MyDSpaceGuard } from './my-dspace.guard';
import { MyDSpaceConfigurationService } from './my-dspace-configuration.service';
import { CollectionSelectorComponent } from './collection-selector/collection-selector.component';
import { MyDspaceSearchModule } from './my-dspace-search.module';
+import { MyDSpaceNewSubmissionDropdownComponent } from './my-dspace-new-submission/my-dspace-new-submission-dropdown/my-dspace-new-submission-dropdown.component';
+import { MyDSpaceNewExternalDropdownComponent } from './my-dspace-new-submission/my-dspace-new-external-dropdown/my-dspace-new-external-dropdown.component';
import { ThemedMyDSpacePageComponent } from './themed-my-dspace-page.component';
const DECLARATIONS = [
@@ -18,7 +20,9 @@ const DECLARATIONS = [
ThemedMyDSpacePageComponent,
MyDSpaceResultsComponent,
MyDSpaceNewSubmissionComponent,
- CollectionSelectorComponent
+ CollectionSelectorComponent,
+ MyDSpaceNewSubmissionDropdownComponent,
+ MyDSpaceNewExternalDropdownComponent
];
@NgModule({