Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DS-4515: Start new submission via Search or ID Lookup (i.e. submit external source) #715

Merged
merged 39 commits into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fb40b8f
Submission from an external source initial commit
sourcedump Jun 18, 2020
63cff33
Fixed scrollable dropdown
atarix83 Jun 18, 2020
e7ef9da
External source items import code completed
sourcedump Jun 22, 2020
2f04b6a
External source items import new files
sourcedump Jun 22, 2020
b4ec056
Removing file for conflicts
sourcedump Jun 22, 2020
0e29fbc
Fixed conflicts after merge
sourcedump Jun 22, 2020
c2c650f
External import button added
sourcedump Jun 22, 2020
43f5e08
External source import completed with tests
sourcedump Jun 24, 2020
0b85880
Merge branch 'master' into DS-4515_submit-external-source
sourcedump Jun 24, 2020
1f54094
Fixed components import
atarix83 Jun 24, 2020
0f4e881
Merge branch 'DS-4515_submit-external-source' of github.com:4Science/…
atarix83 Jun 24, 2020
74d1e0b
Fixed issue with spyOn
atarix83 Jun 24, 2020
c25085b
Lint errors fixed
sourcedump Jun 24, 2020
ba46f24
Test fix for CI
sourcedump Jun 24, 2020
9ada61d
Multiple call to external source service fix
sourcedump Jun 25, 2020
97b4b90
Additional fix for CI tests
sourcedump Jun 26, 2020
e094663
Additional fix for CI tests
sourcedump Jun 26, 2020
bcb1682
Merge branch 'master' into DS-4515_submit-external-source
sourcedump Jun 29, 2020
4370f19
Merge branch 'master' into DS-4515_submit-external-source
sourcedump Jul 2, 2020
e36cb83
Additional fix for CI tests
sourcedump Jul 2, 2020
d6a5d9d
CI test fix, buttons and searchbar style fix and service methods removed
sourcedump Jul 6, 2020
633dfaa
Merge branch 'master' into DS-4515_submit-external-source
sourcedump Jul 6, 2020
9ec5709
CI test fix using TestScheduler
sourcedump Jul 6, 2020
7c36051
fixed travis failure
atarix83 Jul 6, 2020
a38e5cf
fixed travis failure
atarix83 Jul 6, 2020
b8abedb
Fixed test
atarix83 Jul 16, 2020
57f436e
Merge branch 'DS-4515_submit-external-source' of github.com:4Science/…
atarix83 Jul 16, 2020
9225819
[CST-3092] Removed label from New submission and Import buttons
atarix83 Jul 16, 2020
1c31deb
[CST-3092] fixed style issue with external source search bar
atarix83 Jul 16, 2020
c48b817
[CST-3092] Changed start message from external source page
atarix83 Jul 16, 2020
5950fb2
Merge remote-tracking branch 'remotes/github4science/master' into DS-…
atarix83 Jul 16, 2020
2529c91
Merge remote-tracking branch 'remotes/DSpacegithub/main' into DS-4515…
atarix83 Jul 27, 2020
3f77ffa
[CST-3092] remove margin bottom
atarix83 Jul 27, 2020
4779dd2
[CST-3092] fix context
atarix83 Jul 27, 2020
25d912b
Merge with main
sourcedump Aug 11, 2020
94b4115
Removed unintentional fdescribe
atarix83 Aug 26, 2020
ab190e3
Fixed test
atarix83 Aug 26, 2020
67bd19a
Fixed template
atarix83 Aug 26, 2020
ee2f11f
Fixed template
atarix83 Aug 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ds-submission-import-external></ds-submission-import-external>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ImportExternalPageComponent } from './import-external-page.component';

describe('ImportExternalPageComponent', () => {
let component: ImportExternalPageComponent;
let fixture: ComponentFixture<ImportExternalPageComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ImportExternalPageComponent ],
schemas: [NO_ERRORS_SCHEMA]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ImportExternalPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create ImportExternalPageComponent', () => {
expect(component).toBeTruthy();
});
});
13 changes: 13 additions & 0 deletions src/app/+import-external-page/import-external-page.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from '@angular/core';

/**
* Component representing the external import page of the submission.
*/
@Component({
selector: 'ds-import-external-page',
templateUrl: './import-external-page.component.html',
styleUrls: ['./import-external-page.component.scss']
})
export class ImportExternalPageComponent {

}
29 changes: 29 additions & 0 deletions src/app/+import-external-page/import-external-page.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { SharedModule } from '../shared/shared.module';
import { CoreModule } from '../core/core.module';
import { ImportExternalRoutingModule } from './import-external-routing.module';
import { SubmissionModule } from '../submission/submission.module';
import { ImportExternalPageComponent } from './import-external-page.component';

@NgModule({
imports: [
CommonModule,
SharedModule,
CoreModule.forRoot(),
ImportExternalRoutingModule,
SubmissionModule,
],
declarations: [
ImportExternalPageComponent
],
entryComponents: [ ]
})

/**
* This module handles all components that are necessary for the submission external import page
*/
export class ImportExternalPageModule {

}
24 changes: 24 additions & 0 deletions src/app/+import-external-page/import-external-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { AuthenticatedGuard } from '../core/auth/authenticated.guard';
import { SubmissionImportExternalComponent } from '../submission/import-external/submission-import-external.component';

@NgModule({
imports: [
RouterModule.forChild([
{
canActivate: [ AuthenticatedGuard ],
path: '',
component: SubmissionImportExternalComponent,
pathMatch: 'full',
data: {
title: 'submission.import-external.page.title'
}
}
])
],
providers: [ ]
})
export class ImportExternalRoutingModule {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@

</div>
<div class="add">
<button class="btn btn-lg btn-primary mt-1 ml-2" (click)="openDialog()" role="button">
<i class="fa fa-plus-circle" aria-hidden="true"></i> {{'mydspace.new-submission' | translate}}
<button class="btn btn-lg btn-primary mt-1 ml-2" (click)="openDialog()" role="button" title="{{'mydspace.new-submission' | translate}}">
<i class="fa fa-plus-circle" aria-hidden="true"></i>
</button>
</div>
<div class="add">
<a class="btn btn-lg btn-primary mt-1 ml-2" [routerLink]="['/import-external']" role="button" title="{{'mydspace.new-submission-external' | translate}}">
<i class="fa fa-file-import" aria-hidden="true"></i>
</a>
</div>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { getMockScrollToService } from '../../shared/mocks/scroll-to-service.moc
import { UploaderService } from '../../shared/uploader/uploader.service';
import { By } from '@angular/platform-browser';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { HostWindowService } from '../../shared/host-window.service';
import { HostWindowServiceStub } from '../../shared/testing/host-window-service.stub';

describe('MyDSpaceNewSubmissionComponent test', () => {

Expand Down Expand Up @@ -63,7 +65,8 @@ describe('MyDSpaceNewSubmissionComponent test', () => {
},
ChangeDetectorRef,
MyDSpaceNewSubmissionComponent,
UploaderService
UploaderService,
{ provide: HostWindowService, useValue: new HostWindowServiceStub(800) },
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ChangeDetectorRef, Component, EventEmitter, OnDestroy, OnInit, Output } from '@angular/core';
import { Router } from '@angular/router';

import { Subscription } from 'rxjs';
import { first } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { TranslateService } from '@ngx-translate/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';

import { SubmissionState } from '../../submission/submission.reducers';
import { AuthService } from '../../core/auth/auth.service';
Expand All @@ -15,9 +17,7 @@ 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 { Router } from '@angular/router';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { CreateItemParentSelectorComponent } from 'src/app/shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component';
import { CreateItemParentSelectorComponent } from '../../shared/dso-selector/modal-wrappers/create-item-parent-selector/create-item-parent-selector.component';

/**
* This component represents the whole mydspace page header
Expand Down Expand Up @@ -52,6 +52,8 @@ export class MyDSpaceNewSubmissionComponent implements OnDestroy, OnInit {
* @param {NotificationsService} notificationsService
* @param {Store<SubmissionState>} store
* @param {TranslateService} translate
* @param {Router} router
* @param {NgbModal} modalService
*/
constructor(private authService: AuthService,
private changeDetectorRef: ChangeDetectorRef,
Expand Down
1 change: 1 addition & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function getUnauthorizedPath() {
{ path: 'login', loadChildren: './+login-page/login-page.module#LoginPageModule' },
{ path: 'logout', loadChildren: './+logout-page/logout-page.module#LogoutPageModule' },
{ path: 'submit', loadChildren: './+submit-page/submit-page.module#SubmitPageModule' },
{ path: 'import-external', loadChildren: './+import-external-page/import-external-page.module#ImportExternalPageModule' },
{
path: 'workspaceitems',
loadChildren: './+workspaceitems-edit-page/workspaceitems-edit-page.module#WorkspaceitemsEditPageModule'
Expand Down
1 change: 1 addition & 0 deletions src/app/core/data/external-source.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { RemoteData } from './remote-data';
import { PaginatedList } from './paginated-list';
import { ExternalSourceEntry } from '../shared/external-source-entry.model';
import { DefaultChangeAnalyzer } from './default-change-analyzer.service';
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';

/**
* A service handling all external source requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface CollectionListEntryItem {
/**
* An interface to represent an entry in the collection list
*/
interface CollectionListEntry {
export interface CollectionListEntry {
communities: CollectionListEntryItem[],
collection: CollectionListEntryItem
}
Expand Down
59 changes: 59 additions & 0 deletions src/app/shared/mocks/external-source.service.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { ExternalSourceService } from '../../core/data/external-source.service';
import { ExternalSource } from '../../core/shared/external-source.model';
import { ResourceType } from '../../core/shared/resource-type';

export const externalSourceOrcid: ExternalSource = {
type: new ResourceType('externalsource'),
id: 'orcid',
name: 'orcid',
hierarchical: false,
_links: {
entries: {
href: 'https://dspace7.4science.cloud/server/api/integration/externalsources/orcid/entries'
},
self: {
href: 'https://dspace7.4science.cloud/server/api/integration/externalsources/orcid'
}
}
};

export const externalSourceCiencia: ExternalSource = {
type: new ResourceType('externalsource'),
id: 'ciencia',
name: 'ciencia',
hierarchical: false,
_links: {
entries: {
href: 'https://dspace7.4science.cloud/server/api/integration/externalsources/ciencia/entries'
},
self: {
href: 'https://dspace7.4science.cloud/server/api/integration/externalsources/ciencia'
}
}
};

export const externalSourceMyStaffDb: ExternalSource = {
type: new ResourceType('externalsource'),
id: 'my_staff_db',
name: 'my_staff_db',
hierarchical: false,
_links: {
entries: {
href: 'https://dspace7.4science.cloud/server/api/integration/externalsources/my_staff_db/entries'
},
self: {
href: 'https://dspace7.4science.cloud/server/api/integration/externalsources/my_staff_db'
}
}
};

/**
* Mock for [[ExternalSourceService]]
*/
export function getMockExternalSourceService():
ExternalSourceService {
return jasmine.createSpyObj('ExternalSourceService', {
findAll: jasmine.createSpy('findAll'),
getExternalSourceEntries: jasmine.createSpy('getExternalSourceEntries'),
});
}
3 changes: 2 additions & 1 deletion src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ const ENTRY_COMPONENTS = [
ClaimedTaskActionsRejectComponent,
ClaimedTaskActionsReturnToPoolComponent,
ClaimedTaskActionsEditMetadataComponent,
FileDownloadLinkComponent,
CollectionDropdownComponent,
FileDownloadLinkComponent
];

const SHARED_ITEM_PAGE_COMPONENTS = [
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/testing/submission-service.stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export class SubmissionServiceStub {

changeSubmissionCollection = jasmine.createSpy('changeSubmissionCollection');
createSubmission = jasmine.createSpy('createSubmission');
createSubmissionFromExternalSource = jasmine.createSpy('createSubmissionFromExternalSource');
depositSubmission = jasmine.createSpy('depositSubmission');
discardSubmission = jasmine.createSpy('discardSubmission');
dispatchInit = jasmine.createSpy('dispatchInit');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div>
<div class="modal-header">{{'dso-selector.create.collection.head' | translate}}
<button type="button" class="close" (click)="closeCollectionModal()" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<ds-collection-dropdown (selectionChange)="selectObject($event)">
</ds-collection-dropdown>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.close:focus {
outline: none !important;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { Component, NO_ERRORS_SCHEMA, EventEmitter } from '@angular/core';
import { async, TestBed, ComponentFixture, inject } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
import { createTestComponent } from '../../../shared/testing/utils.test';
import { SubmissionImportExternalCollectionComponent } from './submission-import-external-collection.component';
import { CollectionListEntry } from '../../../shared/collection-dropdown/collection-dropdown.component';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';

describe('SubmissionImportExternalCollectionComponent test suite', () => {
let comp: SubmissionImportExternalCollectionComponent;
let compAsAny: any;
let fixture: ComponentFixture<SubmissionImportExternalCollectionComponent>;

beforeEach(async (() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
],
declarations: [
SubmissionImportExternalCollectionComponent,
TestComponent,
],
providers: [
NgbActiveModal,
SubmissionImportExternalCollectionComponent
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents().then();
}));

// First test to check the correct component creation
describe('', () => {
let testComp: TestComponent;
let testFixture: ComponentFixture<TestComponent>;

// synchronous beforeEach
beforeEach(() => {
const html = `
<ds-submission-import-external-collection></ds-submission-import-external-collection>`;
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
testComp = testFixture.componentInstance;
});

afterEach(() => {
testFixture.destroy();
});

it('should create SubmissionImportExternalCollectionComponent', inject([SubmissionImportExternalCollectionComponent], (app: SubmissionImportExternalCollectionComponent) => {
expect(app).toBeDefined();
}));
});

describe('', () => {
beforeEach(() => {
fixture = TestBed.createComponent(SubmissionImportExternalCollectionComponent);
comp = fixture.componentInstance;
compAsAny = comp;
});

afterEach(() => {
fixture.destroy();
comp = null;
compAsAny = null;
});

it('The variable \'selectedEvent\' should be assigned', () => {
const event = new EventEmitter<CollectionListEntry>();
comp.selectObject(event);

expect(comp.selectedEvent).toEqual(event);
});

it('The variable \'selectedEvent\' should be assigned', () => {
spyOn(compAsAny.activeModal, 'dismiss');
comp.closeCollectionModal();

expect(compAsAny.activeModal.dismiss).toHaveBeenCalled();
});
});
});

// declare a test component
@Component({
selector: 'ds-test-cmp',
template: ``
})
class TestComponent {

}
Loading