Skip to content

Commit cf4942a

Browse files
committed
[DURACOM-327] Reorganize code to remove dependency between core and app classes
1 parent 5f7ff24 commit cf4942a

23 files changed

Lines changed: 105 additions & 108 deletions

src/app/core/end-user-agreement/end-user-agreement.guard.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {
1111
Observable,
1212
of,
1313
} from 'rxjs';
14+
import { map } from 'rxjs/operators';
1415

15-
import { returnEndUserAgreementUrlTreeOnFalse } from '../shared/authorized.operators';
16+
import { getEndUserAgreementPath } from '../../info/info-routing-paths';
1617

1718
export declare type HasAcceptedGuardParamFn = () => Observable<boolean>;
1819
/**
@@ -32,3 +33,18 @@ export const endUserAgreementGuard = (
3233
);
3334
};
3435
};
36+
37+
/**
38+
* Operator that returns a UrlTree to the unauthorized page when the boolean received is false
39+
* @param router Router
40+
* @param redirect Redirect URL to add to the UrlTree. This is used to redirect back to the original route after the
41+
* user accepts the agreement.
42+
*/
43+
export const returnEndUserAgreementUrlTreeOnFalse = (router: Router, redirect: string) =>
44+
(source: Observable<boolean>): Observable<boolean | UrlTree> =>
45+
source.pipe(
46+
map((hasAgreed: boolean) => {
47+
const queryParams = { redirect: encodeURIComponent(redirect) };
48+
return hasAgreed ? hasAgreed : router.createUrlTree([getEndUserAgreementPath()], { queryParams });
49+
}),
50+
);

src/app/core/notifications/qa/events/quality-assurance-event-data.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ import {
4545
take,
4646
} from 'rxjs/operators';
4747

48-
import { QualityAssuranceEventData } from '../../../../notifications/qa/project-entry-import-modal/project-entry-import-modal.component';
4948
import { NotificationsService } from '../../../notification-system/notifications.service';
5049
import { QualityAssuranceEventObject } from '../models/quality-assurance-event.model';
50+
import { QualityAssuranceEventData } from '../models/quality-assurance-event-data.model';
5151

5252
/**
5353
* The service handling all Quality Assurance topic REST requests.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Item } from '../../../shared/item.model';
2+
import { QualityAssuranceEventObject } from './quality-assurance-event.model';
3+
4+
/**
5+
* The possible types of import for the external entry
6+
*/
7+
export enum ImportType {
8+
None = 'None',
9+
LocalEntity = 'LocalEntity',
10+
LocalAuthority = 'LocalAuthority',
11+
NewEntity = 'NewEntity',
12+
NewAuthority = 'NewAuthority'
13+
}
14+
15+
/**
16+
* The data type passed from the parent page
17+
*/
18+
export interface QualityAssuranceEventData {
19+
/**
20+
* The Quality Assurance event
21+
*/
22+
event: QualityAssuranceEventObject;
23+
/**
24+
* The Quality Assurance event Id (uuid)
25+
*/
26+
id: string;
27+
/**
28+
* The publication title
29+
*/
30+
title: string;
31+
/**
32+
* Contains the boolean that indicates if a project is present
33+
*/
34+
hasProject: boolean;
35+
/**
36+
* The project title, if present
37+
*/
38+
projectTitle: string;
39+
/**
40+
* The project id (uuid), if present
41+
*/
42+
projectId: string;
43+
/**
44+
* The project handle, if present
45+
*/
46+
handle: string;
47+
/**
48+
* The reject/discard reason
49+
*/
50+
reason: string;
51+
/**
52+
* Contains the boolean that indicates if there is a running operation (REST call)
53+
*/
54+
isRunning: boolean;
55+
/**
56+
* The related publication DSpace item
57+
*/
58+
target?: Item;
59+
}

src/app/core/shared/authorized.operators.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
withLatestFrom,
1414
} from 'rxjs/operators';
1515

16-
import { getEndUserAgreementPath } from '../../info/info-routing-paths';
1716
import { AuthService } from '../auth/auth.service';
1817
import { RemoteData } from '../data/remote-data';
1918
import {
@@ -90,16 +89,3 @@ export const returnForbiddenUrlTreeOrLoginOnAllFalse = (router: Router, authServ
9089
}
9190
}
9291
}));
93-
/**
94-
* Operator that returns a UrlTree to the unauthorized page when the boolean received is false
95-
* @param router Router
96-
* @param redirect Redirect URL to add to the UrlTree. This is used to redirect back to the original route after the
97-
* user accepts the agreement.
98-
*/
99-
export const returnEndUserAgreementUrlTreeOnFalse = (router: Router, redirect: string) =>
100-
(source: Observable<boolean>): Observable<boolean | UrlTree> =>
101-
source.pipe(
102-
map((hasAgreed: boolean) => {
103-
const queryParams = { redirect: encodeURIComponent(redirect) };
104-
return hasAgreed ? hasAgreed : router.createUrlTree([getEndUserAgreementPath()], { queryParams });
105-
}));

src/app/core/submission/models/submission-error.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SubmissionSectionError } from '../../../submission/objects/submission-section-error.model';
1+
import { SubmissionSectionError } from './submission-section-error.model';
22

33
/**
44
* An interface to represent section error

src/app/submission/objects/submission-section-error.model.ts renamed to src/app/core/submission/models/submission-section-error.model.ts

File renamed without changes.

src/app/submission/objects/submission-section-object.model.ts renamed to src/app/core/submission/models/submission-section-object.model.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
import { SectionsType } from '../sections-type';
12
import {
23
SectionScope,
34
SectionVisibility,
4-
} from '@dspace/core/submission/models/section-visibility.model';
5-
import { WorkspaceitemSectionDataType } from '@dspace/core/submission/models/workspaceitem-sections.model';
6-
import { SectionsType } from '@dspace/core/submission/sections-type';
7-
5+
} from './section-visibility.model';
86
import { SubmissionSectionError } from './submission-section-error.model';
7+
import { WorkspaceitemSectionDataType } from './workspaceitem-sections.model';
98

109
/**
1110
* An interface to represent section object state

src/app/notifications/qa/events/quality-assurance-events.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { buildPaginatedList } from '@dspace/core/data/paginated-list.model';
2121
import { NotificationsService } from '@dspace/core/notification-system/notifications.service';
2222
import { QualityAssuranceEventDataService } from '@dspace/core/notifications/qa/events/quality-assurance-event-data.service';
2323
import { QualityAssuranceEventObject } from '@dspace/core/notifications/qa/models/quality-assurance-event.model';
24+
import { QualityAssuranceEventData } from '@dspace/core/notifications/qa/models/quality-assurance-event-data.model';
2425
import { PaginationService } from '@dspace/core/pagination/pagination.service';
2526
import { PaginationComponentOptions } from '@dspace/core/pagination/pagination-component-options.model';
2627
import { followLink } from '@dspace/core/shared/follow-link-config.model';
@@ -56,7 +57,6 @@ import {
5657
import { of } from 'rxjs';
5758
import { TestScheduler } from 'rxjs/testing';
5859

59-
import { QualityAssuranceEventData } from '../project-entry-import-modal/project-entry-import-modal.component';
6060
import { QualityAssuranceEventsComponent } from './quality-assurance-events.component';
6161

6262
describe('QualityAssuranceEventsComponent test suite', () => {

src/app/notifications/qa/events/quality-assurance-events.component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
QualityAssuranceEventObject,
2525
SourceQualityAssuranceEventMessageObject,
2626
} from '@dspace/core/notifications/qa/models/quality-assurance-event.model';
27+
import { QualityAssuranceEventData } from '@dspace/core/notifications/qa/models/quality-assurance-event-data.model';
2728
import { PaginationService } from '@dspace/core/pagination/pagination.service';
2829
import { PaginationComponentOptions } from '@dspace/core/pagination/pagination-component-options.model';
2930
import { getItemPageRoute } from '@dspace/core/router/utils/dso-route.utils';
@@ -69,10 +70,7 @@ import { AlertComponent } from '../../../shared/alert/alert.component';
6970
import { BtnDisabledDirective } from '../../../shared/btn-disabled.directive';
7071
import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.component';
7172
import { PaginationComponent } from '../../../shared/pagination/pagination.component';
72-
import {
73-
ProjectEntryImportModalComponent,
74-
QualityAssuranceEventData,
75-
} from '../project-entry-import-modal/project-entry-import-modal.component';
73+
import { ProjectEntryImportModalComponent } from '../project-entry-import-modal/project-entry-import-modal.component';
7674
import { EPersonDataComponent } from './ePerson-data/ePerson-data.component';
7775

7876
/**

src/app/notifications/qa/project-entry-import-modal/project-entry-import-modal.component.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
} from '@angular/core/testing';
1212
import { ActivatedRoute } from '@angular/router';
1313
import { buildPaginatedList } from '@dspace/core/data/paginated-list.model';
14+
import { ImportType } from '@dspace/core/notifications/qa/models/quality-assurance-event-data.model';
1415
import { PaginationComponentOptions } from '@dspace/core/pagination/pagination-component-options.model';
1516
import { Item } from '@dspace/core/shared/item.model';
1617
import { PageInfo } from '@dspace/core/shared/page-info.model';
@@ -33,10 +34,7 @@ import { ThemedLoadingComponent } from '../../../shared/loading/themed-loading.c
3334
import { SelectableListService } from '../../../shared/object-list/selectable-list/selectable-list.service';
3435
import { SearchService } from '../../../shared/search/search.service';
3536
import { ThemedSearchResultsComponent } from '../../../shared/search/search-results/themed-search-results.component';
36-
import {
37-
ImportType,
38-
ProjectEntryImportModalComponent,
39-
} from './project-entry-import-modal.component';
37+
import { ProjectEntryImportModalComponent } from './project-entry-import-modal.component';
4038

4139
const eventData = {
4240
event: qualityAssuranceEventObjectMissingProjectFound,

0 commit comments

Comments
 (0)