Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -35,10 +35,12 @@ export class RegistryRevisionsComponent {

revisions = computed(() => {
let schemaResponses = this.registry()?.schemaResponses || [];

if (this.registryAcceptedUnapproved) {
this.unApprovedRevisionId =
schemaResponses.find((response) => response.reviewsState === RevisionReviewStates.Unapproved)?.id || null;
}

schemaResponses = this.isModeration()
? schemaResponses
: schemaResponses.filter((r) => r.reviewsState === RevisionReviewStates.Approved);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@
<p-accordion-content>
<div class="flex flex-column pt-4 gap-2">
<h3 class="font-normal">{{ 'registry.overview.statuses.' + registry()?.status + '.short' | translate }}</h3>
<p>
{{
'registry.overview.statuses.' + registry()?.status + '.long' | translate: { embargoEndDate: embargoEndDate }
}}
</p>
<div class="flex">
<p>
{{
'registry.overview.statuses.' + registry()?.status + '.long'
| translate: { embargoEndDate: embargoEndDate }
}}
</p>

@if (isAccepted()) {
<a class="font-bold ml-1" [routerLink]="['/', registry()?.associatedProjectId]">
{{ 'registry.overview.statuses.accepted.project' | translate }}</a
>.
}
</div>

@if (canEdit()) {
@if (canWithdraw()) {
<p-button
Expand All @@ -21,6 +31,7 @@ <h3 class="font-normal">{{ 'registry.overview.statuses.' + registry()?.status +
styleClass="w-full mt-2"
></p-button>
}

@if (isEmbargo()) {
<p-button
(onClick)="openEndEmbargoDialog()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Button } from 'primeng/button';
import { DialogService } from 'primeng/dynamicdialog';

import { ChangeDetectionStrategy, Component, computed, HostBinding, inject, input } from '@angular/core';
import { RouterLink } from '@angular/router';

import { RegistrationReviewStates, RegistryStatus, RevisionReviewStates } from '@osf/shared/enums';
import { CustomConfirmationService } from '@osf/shared/services';
Expand All @@ -17,7 +18,7 @@ import { WithdrawDialogComponent } from '../withdraw-dialog/withdraw-dialog.comp

@Component({
selector: 'osf-registry-statuses',
imports: [Accordion, AccordionContent, AccordionHeader, AccordionPanel, TranslatePipe, Button],
imports: [Accordion, AccordionContent, AccordionHeader, AccordionPanel, TranslatePipe, Button, RouterLink],
templateUrl: './registry-statuses.component.html',
styleUrl: './registry-statuses.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -36,13 +37,12 @@ export class RegistryStatusesComponent {
readonly customConfirmationService = inject(CustomConfirmationService);
readonly actions = createDispatchMap({ makePublic: MakePublic });

canWithdraw = computed(() => {
return this.registry()?.reviewsState === RegistrationReviewStates.Accepted && !this.isModeration();
});
canWithdraw = computed(
() => this.registry()?.reviewsState === RegistrationReviewStates.Accepted && !this.isModeration()
);

isEmbargo = computed(() => {
return this.registry()?.status === RegistryStatus.Embargo;
});
isAccepted = computed(() => this.registry()?.reviewsState === RegistrationReviewStates.Accepted);
isEmbargo = computed(() => this.registry()?.status === RegistryStatus.Embargo);

get embargoEndDate() {
const embargoEndDate = this.registry()?.embargoEndDate;
Expand Down
49 changes: 25 additions & 24 deletions src/app/features/registry/mappers/registry-overview.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { RegistryOverview, RegistryOverviewJsonApiData } from '@osf/features/registry/models';
import { MapRegistryStatus, ReviewPermissionsMapper } from '@osf/shared/mappers';
import { RegistrationMapper } from '@osf/shared/mappers/registration';
import { IdentifiersMapper, LicensesMapper } from '@osf/shared/mappers';
import { MapRegistryStatus, RegistrationMapper, RegistrationNodeMapper } from '@osf/shared/mappers/registration';

import { RegistryOverview, RegistryOverviewJsonApiData } from '../models';

export function MapRegistryOverview(data: RegistryOverviewJsonApiData): RegistryOverview | null {
return {
Expand All @@ -16,16 +17,15 @@ export function MapRegistryOverview(data: RegistryOverviewJsonApiData): Registry
category: data.attributes?.category,
customCitation: data.attributes?.custom_citation,
isFork: data.attributes?.fork,
accessRequestsEnabled: data.attributes?.accessRequestsEnabled,
accessRequestsEnabled: data.attributes?.access_requests_enabled,
nodeLicense: data.attributes.node_license
? {
copyrightHolders: data.attributes.node_license.copyright_holders,
year: data.attributes.node_license.year,
}
: undefined,
license: data.embeds?.license?.data?.attributes,
registrationType: data.attributes?.registration_supplement,
doi: data.attributes?.doi,
doi: data.attributes?.article_doi,
tags: data.attributes?.tags,
contributors: data.embeds?.bibliographic_contributors?.data.map((contributor) => ({
id: contributor?.embeds?.users?.data?.id,
Expand All @@ -35,46 +35,47 @@ export function MapRegistryOverview(data: RegistryOverviewJsonApiData): Registry
middleName: contributor?.embeds?.users?.data?.attributes?.middle_names,
type: contributor?.embeds?.users?.data?.type,
})),
identifiers: data.embeds?.identifiers?.data.map((identifier) => ({
id: identifier.id,
type: identifier.type,
value: identifier.attributes.value,
category: identifier.attributes.category,
})),
analyticsKey: data.attributes?.analyticsKey,
identifiers: IdentifiersMapper.fromJsonApi(data.embeds.identifiers),
analyticsKey: data.attributes?.analytics_key,
currentUserCanComment: data.attributes.current_user_can_comment,
currentUserPermissions: data.attributes.current_user_permissions,
currentUserIsContributor: data.attributes.current_user_is_contributor,
currentUserIsContributorOrGroupMember: data.attributes.current_user_is_contributor_or_group_member,
citation: data.relationships?.citation?.data?.id,
wikiEnabled: data.attributes.wikiEnabled,
wikiEnabled: data.attributes.wiki_enabled,
region: data.relationships.region?.data,
hasData: data.attributes.has_data,
hasAnalyticCode: data.attributes.has_analytic_code,
hasMaterials: data.attributes.has_materials,
hasPapers: data.attributes.has_papers,
hasSupplements: data.attributes.has_supplements,
questions: data.attributes.registration_responses,
license: LicensesMapper.fromLicenseDataJsonApi(data.embeds.license.data),
registrationSchemaLink: data.relationships.registration_schema.links.related.href,
associatedProjectId: data.relationships?.registered_from?.data?.id,
schemaResponses: data.embeds?.schema_responses?.data?.map((item) => RegistrationMapper.fromSchemaResponse(item)),
provider: {
id: data.embeds?.provider.data.id,
name: data.embeds?.provider.data.attributes.name,
permissions: data.embeds?.provider.data.attributes.permissions,
},
provider: RegistrationNodeMapper.getRegistrationProviderShortInfo(data.embeds.provider.data),
status: MapRegistryStatus(data.attributes),
revisionStatus: data.attributes.revision_state,
reviewsState: data.attributes.reviews_state,
links: {
files: data?.embeds?.files?.data?.[0]?.relationships?.files?.links?.related?.href,
},
archiving: data.attributes.archiving,
currentUserIsModerator: ReviewPermissionsMapper.fromProviderResponse(data.embeds?.provider.data),
withdrawn: data.attributes.withdrawn || false,
withdrawalJustification: data.attributes.withdrawal_justification,
dateWithdrawn: data.attributes.date_withdrawn || null,
embargoEndDate: data.attributes.embargo_end_date || null,
rootParentId: data.relationships.root?.data?.id,
} as RegistryOverview;
}

export function MapRegistrationOverview(data: RegistryOverviewJsonApiData) {
const registrationAttributes = RegistrationNodeMapper.getRegistrationNodeAttributes(data.id, data.attributes);
const providerInfo = RegistrationNodeMapper.getRegistrationProviderShortInfo(data.embeds.provider.data);
const identifiers = IdentifiersMapper.fromJsonApi(data.embeds.identifiers);
const license = LicensesMapper.fromLicenseDataJsonApi(data.embeds.license.data);

return {
...registrationAttributes,
provider: providerInfo,
identifiers: identifiers,
license: license,
};
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { RegistrationReviewStates, RevisionReviewStates } from '@osf/shared/enums';
import {
ApiData,
IdentifiersJsonApiData,
JsonApiResponseWithMeta,
LicenseDataJsonApi,
MetaAnonymousJsonApi,
ProviderDataJsonApi,
RegistrationNodeAttributesJsonApi,
RegistryProviderDetailsJsonApi,
ResponseJsonApi,
SchemaResponseDataJsonApi,
} from '@osf/shared/models';

Expand All @@ -14,7 +18,7 @@ export type GetRegistryOverviewJsonApi = JsonApiResponseWithMeta<
>;

export type RegistryOverviewJsonApiData = ApiData<
RegistryOverviewJsonApiAttributes,
RegistrationNodeAttributesJsonApi,
RegistryOverviewJsonApiEmbed,
RegistryOverviewJsonApiRelationships,
null
Expand Down Expand Up @@ -87,26 +91,9 @@ export interface RegistryOverviewJsonApiEmbed {
}[];
};
license: {
data: {
id: string;
type: string;
attributes: {
name: string;
text: string;
url: string;
};
};
};
identifiers: {
data: {
id: string;
type: string;
attributes: {
category: string;
value: string;
};
}[];
data: LicenseDataJsonApi;
};
identifiers: ResponseJsonApi<IdentifiersJsonApiData[]>;
schema_responses: {
data: SchemaResponseDataJsonApi[];
};
Expand All @@ -124,7 +111,7 @@ export interface RegistryOverviewJsonApiEmbed {
};
}[];
};
provider: { data: ProviderDataJsonApi };
provider: { data: RegistryProviderDetailsJsonApi };
}

export interface RegistryOverviewJsonApiRelationships {
Expand Down
30 changes: 18 additions & 12 deletions src/app/features/registry/models/registry-overview.models.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { ProjectOverviewContributor } from '@osf/features/project/overview/models';
import { RegistrationQuestions } from '@osf/features/registry/models';
import {
Identifier,
IdTypeModel,
LicenseModel,
LicensesOption,
MetaAnonymousJsonApi,
ProviderShortInfoModel,
RegistrationNodeModel,
RegistrationResponses,
SchemaResponse,
SubjectModel,
} from '@osf/shared/models';
Expand Down Expand Up @@ -33,12 +35,7 @@ export interface RegistryOverview {
nodeLicense?: LicensesOption;
license?: LicenseModel;
licenseUrl?: string;
identifiers?: {
id: string;
type: string;
category: string;
value: string;
}[];
identifiers?: Identifier[];
analyticsKey: string;
currentUserCanComment: boolean;
currentUserPermissions: UserPermissions[];
Expand All @@ -53,25 +50,34 @@ export interface RegistryOverview {
hasMaterials: boolean;
hasPapers: boolean;
hasSupplements: boolean;
questions: RegistrationQuestions;
questions: RegistrationResponses;
registrationSchemaLink: string;
associatedProjectId: string;
schemaResponses: SchemaResponse[];
status: RegistryStatus;
revisionStatus: RevisionReviewStates;
reviewsState?: RegistrationReviewStates;
links: {
files: string;
};
archiving: boolean;
embargoEndDate: string;
currentUserIsModerator: boolean;
withdrawn: boolean;
withdrawalJustification?: string;
dateWithdrawn: string | null;
rootParentId: string | null;
}

export interface RegistrationOverviewModel extends RegistrationNodeModel {
type: string;
registrationSchemaLink: string;
associatedProjectId: string;
citation: string;
provider?: ProviderShortInfoModel;
contributors: ProjectOverviewContributor[];
license?: LicenseModel;
identifiers?: Identifier[];
schemaResponses: SchemaResponse[];
status: RegistryStatus;
}

export interface RegistryOverviewWithMeta {
registry: RegistryOverview | null;
meta?: MetaAnonymousJsonApi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ export class RegistryOverviewComponent {
this.areSubjectsLoading()
);

canMakeDecision = computed(() => {
return !this.registry()?.archiving && !this.registry()?.withdrawn && this.isModeration;
});
canMakeDecision = computed(() => !this.registry()?.archiving && !this.registry()?.withdrawn && this.isModeration);

isRootRegistration = computed(() => {
const rootId = this.registry()?.rootParentId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { RegistrationQuestions } from '@osf/shared/models';
import { ReviewActionPayload } from '@osf/shared/models/review-action';

export class GetRegistryById {
Expand All @@ -16,10 +15,7 @@ export class GetRegistryInstitutions {
export class GetSchemaBlocks {
static readonly type = '[Registry Overview] Get Schema Blocks';

constructor(
public schemaLink: string,
public questions: RegistrationQuestions
) {}
constructor(public schemaLink: string) {}
}

export class WithdrawRegistration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export class RegistryOverviewState {
isAnonymous: response.meta?.anonymous ?? false,
});

if (registryOverview?.registrationSchemaLink && registryOverview?.questions) {
ctx.dispatch(new GetSchemaBlocks(registryOverview.registrationSchemaLink, registryOverview.questions));
if (registryOverview?.registrationSchemaLink) {
ctx.dispatch(new GetSchemaBlocks(registryOverview.registrationSchemaLink));
}
}),
catchError((error) => handleSectionError(ctx, 'registry', error))
Expand Down Expand Up @@ -142,8 +142,8 @@ export class RegistryOverviewState {
},
});

if (registryOverview?.registrationSchemaLink && registryOverview?.questions) {
ctx.dispatch(new GetSchemaBlocks(registryOverview.registrationSchemaLink, registryOverview.questions));
if (registryOverview?.registrationSchemaLink) {
ctx.dispatch(new GetSchemaBlocks(registryOverview.registrationSchemaLink));
}
}),
catchError((error) => handleSectionError(ctx, 'registry', error))
Expand All @@ -169,8 +169,9 @@ export class RegistryOverviewState {
error: null,
},
});
if (registryOverview?.registrationSchemaLink && registryOverview?.questions) {
ctx.dispatch(new GetSchemaBlocks(registryOverview.registrationSchemaLink, registryOverview.questions));

if (registryOverview?.registrationSchemaLink) {
ctx.dispatch(new GetSchemaBlocks(registryOverview.registrationSchemaLink));
}
}),
catchError((error) => handleSectionError(ctx, 'registry', error))
Expand Down
3 changes: 1 addition & 2 deletions src/app/shared/mappers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@ export * from './emails.mapper';
export * from './files/files.mapper';
export * from './filters/filter-option.mapper';
export * from './filters/reusable-filter.mapper';
export * from './identifiers.mapper';
export * from './institutions';
export * from './licenses.mapper';
export * from './nodes';
export * from './notification-subscription.mapper';
export * from './registration-provider.mapper';
export * from './registry';
export * from './resource-overview.mappers';
export * from './review-actions.mapper';
export * from './review-permissions.mapper';
export * from './subjects';
export * from './user';
export * from './user-related-counts';
Expand Down
2 changes: 2 additions & 0 deletions src/app/shared/mappers/registration/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export * from './map-registry-status.mapper';
export * from './page-schema.mapper';
export * from './registration.mapper';
export * from './registration-node.mapper';
Loading
Loading