Skip to content

Commit 224879b

Browse files
committed
fix(datacite-tracker): reverted undesired refactor
1 parent 9ae4195 commit 224879b

18 files changed

Lines changed: 71 additions & 64 deletions

src/app/features/preprints/mappers/preprints.mapper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { LicensesMapper } from '@osf/shared/mappers';
22
import { ApiData, JsonApiResponseWithMeta, ResponseJsonApi } from '@osf/shared/models';
33
import { StringOrNull } from '@shared/helpers';
4-
import { IdentifiersMapper } from '@shared/mappers/identifiers.mapper';
54

65
import {
76
Preprint,
@@ -137,7 +136,12 @@ export class PreprintsMapper {
137136
views: meta.metrics.views,
138137
},
139138
embeddedLicense: LicensesMapper.fromLicenseDataJsonApi(data.embeds.license.data),
140-
identifiers: IdentifiersMapper.fromEmbeds(data.embeds.identifiers),
139+
identifiers: data.embeds.identifiers?.data.map((identifier) => ({
140+
id: identifier.id,
141+
type: identifier.type,
142+
value: identifier.attributes.value,
143+
category: identifier.attributes.category,
144+
})),
141145
preprintDoiLink: links.preprint_doi,
142146
articleDoiLink: links.doi,
143147
};

src/app/features/preprints/models/preprint-json-api.models.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { UserPermissions } from '@osf/shared/enums';
22
import { BooleanOrNull, StringOrNull } from '@osf/shared/helpers';
33
import { ContributorResponse, LicenseRecordJsonApi, LicenseResponseJsonApi } from '@osf/shared/models';
4-
import { IdentifiersEmbedJsonApiResponse } from '@shared/models/identifiers/identifier-json-api';
54

65
import { ApplicabilityStatus, PreregLinkInfo, ReviewsState } from '../enums';
76

@@ -70,7 +69,16 @@ export interface PreprintEmbedsJsonApi {
7069
data: ContributorResponse[];
7170
};
7271
license: LicenseResponseJsonApi;
73-
identifiers: IdentifiersEmbedJsonApiResponse;
72+
identifiers: {
73+
data: {
74+
id: string;
75+
type: string;
76+
attributes: {
77+
category: string;
78+
value: string;
79+
};
80+
}[];
81+
};
7482
}
7583

7684
export interface PreprintMetaJsonApi {

src/app/features/preprints/models/preprint.models.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { ProjectIdentifiers } from '@osf/features/project/overview/models';
12
import { UserPermissions } from '@osf/shared/enums';
23
import { BooleanOrNull, StringOrNull } from '@osf/shared/helpers';
34
import { IdName, License, LicenseOptions } from '@osf/shared/models';
4-
import { Identifier } from '@shared/models/identifiers/indentifier.model';
55

66
import { ApplicabilityStatus, PreregLinkInfo, ReviewsState } from '../enums';
77

@@ -44,7 +44,7 @@ export interface Preprint {
4444
embeddedLicense?: License;
4545
preprintDoiLink?: string;
4646
articleDoiLink?: string;
47-
identifiers?: Identifier[];
47+
identifiers?: ProjectIdentifiers[];
4848
}
4949

5050
export interface PreprintFilesLinks {

src/app/features/preprints/pages/preprint-details/preprint-details.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ import {
4545
} from '@osf/features/preprints/store/preprint';
4646
import { GetPreprintProviderById, PreprintProvidersSelectors } from '@osf/features/preprints/store/preprint-providers';
4747
import { CreateNewVersion, PreprintStepperSelectors } from '@osf/features/preprints/store/preprint-stepper';
48+
import { ProjectIdentifiers } from '@osf/features/project/overview/models';
4849
import { IS_MEDIUM, pathJoin } from '@osf/shared/helpers';
4950
import { DataciteTrackerComponent } from '@shared/components/datacite-tracker/datacite-tracker.component';
5051
import { ReviewPermissions, UserPermissions } from '@shared/enums';
51-
import { Identifier } from '@shared/models';
5252
import { MetaTagsService } from '@shared/services';
5353
import { ContributorsSelectors } from '@shared/stores';
5454

@@ -291,7 +291,7 @@ export class PreprintDetailsComponent extends DataciteTrackerComponent implement
291291
this.actions.resetState();
292292
}
293293

294-
protected override get trackable(): Observable<{ identifiers?: Identifier[] } | null> {
294+
protected override get trackable(): Observable<{ identifiers?: ProjectIdentifiers[] } | null> {
295295
return this.preprint$;
296296
}
297297

src/app/features/project/overview/mappers/project-overview.mapper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { InstitutionsMapper } from '@shared/mappers';
2-
import { IdentifiersMapper } from '@shared/mappers/identifiers.mapper';
32
import { License } from '@shared/models';
43

54
import { ProjectOverview, ProjectOverviewGetResponseJsoApi } from '../models';
@@ -47,7 +46,12 @@ export class ProjectOverviewMapper {
4746
type: contributor.embeds.users.data.type,
4847
})),
4948
affiliatedInstitutions: InstitutionsMapper.fromInstitutionsResponse(response.embeds.affiliated_institutions),
50-
identifiers: IdentifiersMapper.fromEmbeds(response.embeds.identifiers),
49+
identifiers: response.embeds.identifiers?.data.map((identifier) => ({
50+
id: identifier.id,
51+
type: identifier.type,
52+
value: identifier.attributes.value,
53+
category: identifier.attributes.category,
54+
})),
5155
...(response.embeds.storage?.data &&
5256
!response.embeds.storage?.errors && {
5357
storage: {

src/app/features/project/overview/models/project-overview.models.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { UserPermissions } from '@osf/shared/enums';
2-
import { Identifier, Institution, InstitutionsJsonApiResponse, JsonApiResponse, License } from '@osf/shared/models';
3-
import { IdentifiersEmbedJsonApiResponse } from '@shared/models/identifiers/identifier-json-api';
2+
import { Institution, InstitutionsJsonApiResponse, JsonApiResponse, License } from '@osf/shared/models';
43

54
export interface ProjectOverviewContributor {
65
familyName: string;
@@ -39,7 +38,7 @@ export interface ProjectOverview {
3938
storageLimitStatus: string;
4039
storageUsage: string;
4140
};
42-
identifiers?: Identifier[];
41+
identifiers?: ProjectIdentifiers[];
4342
supplements?: ProjectSupplements[];
4443
analyticsKey: string;
4544
currentUserCanComment: boolean;
@@ -101,7 +100,16 @@ export interface ProjectOverviewGetResponseJsoApi {
101100
};
102101
embeds: {
103102
affiliated_institutions: InstitutionsJsonApiResponse;
104-
identifiers: IdentifiersEmbedJsonApiResponse;
103+
identifiers: {
104+
data: {
105+
id: string;
106+
type: string;
107+
attributes: {
108+
category: string;
109+
value: string;
110+
};
111+
}[];
112+
};
105113
bibliographic_contributors: {
106114
data: {
107115
embeds: {
@@ -200,6 +208,13 @@ export interface ProjectOverviewResponseJsonApi extends JsonApiResponse<ProjectO
200208
data: ProjectOverviewGetResponseJsoApi;
201209
}
202210

211+
export interface ProjectIdentifiers {
212+
id: string;
213+
type: string;
214+
category: string;
215+
value: string;
216+
}
217+
203218
export interface ProjectSupplements {
204219
id: string;
205220
type: string;

src/app/features/project/overview/project-overview.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { FormsModule } from '@angular/forms';
2525
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
2626

2727
import { SubmissionReviewStatus } from '@osf/features/moderation/enums';
28+
import { ProjectIdentifiers } from '@osf/features/project/overview/models';
2829
import { IS_XSMALL } from '@osf/shared/helpers';
2930
import {
3031
LoadingSpinnerComponent,
@@ -35,7 +36,6 @@ import {
3536
import { DataciteTrackerComponent } from '@shared/components/datacite-tracker/datacite-tracker.component';
3637
import { Mode, ResourceType, UserPermissions } from '@shared/enums';
3738
import { MapProjectOverview } from '@shared/mappers/resource-overview.mappers';
38-
import { Identifier } from '@shared/models';
3939
import { ToastService } from '@shared/services';
4040
import {
4141
ClearWiki,
@@ -192,7 +192,7 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement
192192
return null;
193193
});
194194

195-
protected override get trackable(): Observable<{ identifiers?: Identifier[] } | null> {
195+
protected override get trackable(): Observable<{ identifiers?: ProjectIdentifiers[] } | null> {
196196
return this.currentProject$;
197197
}
198198

src/app/features/registry/mappers/registry-overview.mapper.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { RegistryOverview, RegistryOverviewJsonApiData } from '@osf/features/registry/models';
22
import { ReviewPermissionsMapper } from '@osf/shared/mappers';
33
import { RegistrationMapper } from '@osf/shared/mappers/registration';
4-
import { IdentifiersMapper } from '@shared/mappers/identifiers.mapper';
54
import { MapRegistryStatus } from '@shared/mappers/registry/map-registry-status.mapper';
65

76
export function MapRegistryOverview(data: RegistryOverviewJsonApiData): RegistryOverview | null {
@@ -37,7 +36,12 @@ export function MapRegistryOverview(data: RegistryOverviewJsonApiData): Registry
3736
middleName: contributor?.embeds?.users?.data?.attributes?.middle_names,
3837
type: contributor?.embeds?.users?.data?.type,
3938
})),
40-
identifiers: IdentifiersMapper.fromEmbeds(data.embeds.identifiers),
39+
identifiers: data.embeds.identifiers?.data.map((identifier) => ({
40+
id: identifier.id,
41+
type: identifier.type,
42+
value: identifier.attributes.value,
43+
category: identifier.attributes.category,
44+
})),
4145
analyticsKey: data.attributes?.analyticsKey,
4246
currentUserCanComment: data.attributes.current_user_can_comment,
4347
currentUserPermissions: data.attributes.current_user_permissions,

src/app/features/registry/models/get-registry-overview-json-api.model.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { RegistrationReviewStates, RevisionReviewStates } from '@osf/shared/enums';
22
import { ApiData, JsonApiResponse, ProviderDataJsonApi, SchemaResponseDataJsonApi } from '@osf/shared/models';
3-
import { IdentifiersEmbedJsonApiResponse } from '@shared/models/identifiers/identifier-json-api';
43

54
export type GetRegistryOverviewJsonApi = JsonApiResponse<RegistryOverviewJsonApiData, null>;
65

@@ -88,7 +87,16 @@ export interface RegistryOverviewJsonApiEmbed {
8887
};
8988
};
9089
};
91-
identifiers: IdentifiersEmbedJsonApiResponse;
90+
identifiers: {
91+
data: {
92+
id: string;
93+
type: string;
94+
attributes: {
95+
category: string;
96+
value: string;
97+
};
98+
}[];
99+
};
92100
schema_responses: {
93101
data: SchemaResponseDataJsonApi[];
94102
};

src/app/features/registry/registry.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import { ChangeDetectionStrategy, Component, effect, HostBinding, inject } from
77
import { toObservable } from '@angular/core/rxjs-interop';
88
import { RouterOutlet } from '@angular/router';
99

10+
import { ProjectIdentifiers } from '@osf/features/project/overview/models';
1011
import { pathJoin } from '@osf/shared/helpers';
1112
import { MetaTagsService } from '@osf/shared/services';
1213
import { DataciteTrackerComponent } from '@shared/components/datacite-tracker/datacite-tracker.component';
13-
import { Identifier } from '@shared/models';
1414

1515
import { RegistryOverviewSelectors } from './store/registry-overview';
1616

@@ -43,7 +43,7 @@ export class RegistryComponent extends DataciteTrackerComponent {
4343
this.setupDataciteViewTrackerEffect().subscribe();
4444
}
4545

46-
protected override get trackable(): Observable<{ identifiers?: Identifier[] } | null> {
46+
protected override get trackable(): Observable<{ identifiers?: ProjectIdentifiers[] } | null> {
4747
return this.registry$;
4848
}
4949

0 commit comments

Comments
 (0)