From fc497c1a6a4ee32235acdb45ae5ee5fbd329c4d1 Mon Sep 17 00:00:00 2001 From: NazarMykhalkevych Date: Thu, 31 Jul 2025 20:36:45 +0300 Subject: [PATCH] feat(registry): archiving message --- src/app/core/interceptors/auth.interceptor.ts | 4 +- .../components/review/review.component.ts | 4 +- .../registries/store/registries.selectors.ts | 15 ++- .../archiving-message.component.html | 55 ++++++++ .../archiving-message.component.scss | 0 .../archiving-message.component.spec.ts | 22 +++ .../archiving-message.component.ts | 28 ++++ src/app/features/registry/components/index.ts | 1 + .../mappers/registry-metadata.mapper.ts | 1 + .../mappers/registry-overview.mapper.ts | 1 + .../get-registry-overview-json-api.model.ts | 1 + .../models/registry-overview.models.ts | 1 + .../registry-overview.component.html | 125 +++++++++--------- .../registry-overview.component.ts | 3 +- src/assets/i18n/en.json | 7 + src/environments/environment.ts | 2 +- 16 files changed, 205 insertions(+), 65 deletions(-) create mode 100644 src/app/features/registry/components/archiving-message/archiving-message.component.html create mode 100644 src/app/features/registry/components/archiving-message/archiving-message.component.scss create mode 100644 src/app/features/registry/components/archiving-message/archiving-message.component.spec.ts create mode 100644 src/app/features/registry/components/archiving-message/archiving-message.component.ts diff --git a/src/app/core/interceptors/auth.interceptor.ts b/src/app/core/interceptors/auth.interceptor.ts index aaaee6079..73550d3a2 100644 --- a/src/app/core/interceptors/auth.interceptor.ts +++ b/src/app/core/interceptors/auth.interceptor.ts @@ -2,6 +2,8 @@ import { Observable } from 'rxjs'; import { HttpEvent, HttpHandlerFn, HttpInterceptorFn, HttpRequest } from '@angular/common/http'; +import { environment } from 'src/environments/environment'; + export const authInterceptor: HttpInterceptorFn = ( req: HttpRequest, next: HttpHandlerFn @@ -12,7 +14,7 @@ export const authInterceptor: HttpInterceptorFn = ( // yZ485nN6MfhqvGrfU4Xk5BEnq0T6LM50nQ6H9VrYaMTaZUQNTuxnIwlp0Wpz879RCsK9GQ NM stage3 const localStorageToken = localStorage.getItem('authToken'); const token = localStorageToken || authToken; - if (token) { + if (token && !environment.production) { if (!req.url.includes('/api.crossref.org/funders')) { const authReq = req.clone({ setHeaders: { diff --git a/src/app/features/registries/components/review/review.component.ts b/src/app/features/registries/components/review/review.component.ts index 2489e0495..56d545832 100644 --- a/src/app/features/registries/components/review/review.component.ts +++ b/src/app/features/registries/components/review/review.component.ts @@ -71,6 +71,7 @@ export class ReviewComponent { protected readonly subjects = select(SubjectsSelectors.getSelectedSubjects); protected readonly components = select(RegistriesSelectors.getRegistrationComponents); protected readonly license = select(RegistriesSelectors.getRegistrationLicense); + protected readonly newRegistration = select(RegistriesSelectors.getRegistration); private readonly OSF_PROVIDER_ID = 'osf'; protected readonly FieldType = FieldType; @@ -192,8 +193,7 @@ export class ReviewComponent { .onClose.subscribe((res) => { if (res) { this.toastService.showSuccess('registries.review.confirmation.successMessage'); - // [NM] TODO: Navigate to the newly created registration page - this.router.navigate([`registries/my-registrations`]); + this.router.navigate([`registries/${this.newRegistration()?.id}/overview`]); } else { if (this.components()?.length) { this.openSelectComponentsForRegistrationDialog(); diff --git a/src/app/features/registries/store/registries.selectors.ts b/src/app/features/registries/store/registries.selectors.ts index ebcc0cdf6..596bdc737 100644 --- a/src/app/features/registries/store/registries.selectors.ts +++ b/src/app/features/registries/store/registries.selectors.ts @@ -1,6 +1,14 @@ import { Selector } from '@ngxs/store'; -import { DraftRegistrationModel, License, OsfFile, RegistrationCard, Resource, SchemaResponse } from '@shared/models'; +import { + DraftRegistrationModel, + License, + OsfFile, + RegistrationCard, + RegistrationModel, + Resource, + SchemaResponse, +} from '@shared/models'; import { PageSchema, Project, ProviderSchema } from '../models'; @@ -98,6 +106,11 @@ export class RegistriesSelectors { return state.registration.isSubmitting || false; } + @Selector([RegistriesState]) + static getRegistration(state: RegistriesStateModel): RegistrationModel | null { + return state.registration.data; + } + @Selector([RegistriesState]) static getDraftRegistrations(state: RegistriesStateModel): RegistrationCard[] { return state.draftRegistrations.data; diff --git a/src/app/features/registry/components/archiving-message/archiving-message.component.html b/src/app/features/registry/components/archiving-message/archiving-message.component.html new file mode 100644 index 000000000..8564719a9 --- /dev/null +++ b/src/app/features/registry/components/archiving-message/archiving-message.component.html @@ -0,0 +1,55 @@ + +
+
+

+ + {{ 'registry.archiving.title' | translate }} +

+

{{ 'registry.archiving.pleaseNote' | translate }}

+

+ {{ 'registry.archiving.description' | translate }} + support.osf.io + {{ 'registry.archiving.descriptionEnd' | translate }} +

+
+
+
diff --git a/src/app/features/registry/components/archiving-message/archiving-message.component.scss b/src/app/features/registry/components/archiving-message/archiving-message.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/features/registry/components/archiving-message/archiving-message.component.spec.ts b/src/app/features/registry/components/archiving-message/archiving-message.component.spec.ts new file mode 100644 index 000000000..41f1fde2f --- /dev/null +++ b/src/app/features/registry/components/archiving-message/archiving-message.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ArchivingMessageComponent } from './archiving-message.component'; + +describe('ArchivingMessageComponent', () => { + let component: ArchivingMessageComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [ArchivingMessageComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(ArchivingMessageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/features/registry/components/archiving-message/archiving-message.component.ts b/src/app/features/registry/components/archiving-message/archiving-message.component.ts new file mode 100644 index 000000000..dabeadd87 --- /dev/null +++ b/src/app/features/registry/components/archiving-message/archiving-message.component.ts @@ -0,0 +1,28 @@ +import { TranslatePipe } from '@ngx-translate/core'; + +import { Card } from 'primeng/card'; +import { Divider } from 'primeng/divider'; + +import { ChangeDetectionStrategy, Component, input } from '@angular/core'; + +import { IconComponent } from '@osf/shared/components'; + +import { RegistryOverview } from '../../models'; + +import { environment } from 'src/environments/environment'; + +@Component({ + selector: 'osf-archiving-message', + imports: [TranslatePipe, Card, IconComponent, Divider], + templateUrl: './archiving-message.component.html', + styleUrl: './archiving-message.component.scss', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class ArchivingMessageComponent { + registration = input.required(); + protected readonly environment = environment; + + get associatedProjectUrl(): string { + return `${this.environment.webUrl}/${this.registration().associatedProjectId}`; + } +} diff --git a/src/app/features/registry/components/index.ts b/src/app/features/registry/components/index.ts index 0ee64872d..0155fd53e 100644 --- a/src/app/features/registry/components/index.ts +++ b/src/app/features/registry/components/index.ts @@ -1,4 +1,5 @@ export * from './add-resource-dialog/add-resource-dialog.component'; +export * from './archiving-message/archiving-message.component'; export * from './edit-resource-dialog/edit-resource-dialog.component'; export * from './registration-links-card/registration-links-card.component'; export * from './registry-revisions/registry-revisions.component'; diff --git a/src/app/features/registry/mappers/registry-metadata.mapper.ts b/src/app/features/registry/mappers/registry-metadata.mapper.ts index 557c72c33..73a67f562 100644 --- a/src/app/features/registry/mappers/registry-metadata.mapper.ts +++ b/src/app/features/registry/mappers/registry-metadata.mapper.ts @@ -115,6 +115,7 @@ export class RegistryMetadataMapper { links: { files: '', }, + archiving: attributes['archiving'] as boolean, } as RegistryOverview; } diff --git a/src/app/features/registry/mappers/registry-overview.mapper.ts b/src/app/features/registry/mappers/registry-overview.mapper.ts index d6f417103..a9456bb44 100644 --- a/src/app/features/registry/mappers/registry-overview.mapper.ts +++ b/src/app/features/registry/mappers/registry-overview.mapper.ts @@ -67,5 +67,6 @@ export function MapRegistryOverview(data: RegistryOverviewJsonApiData): Registry links: { files: data?.embeds?.files?.data?.[0]?.relationships?.files?.links?.related?.href, }, + archiving: data.attributes.archiving, } as RegistryOverview; } diff --git a/src/app/features/registry/models/get-registry-overview-json-api.model.ts b/src/app/features/registry/models/get-registry-overview-json-api.model.ts index d0ccd9e0b..1a5348469 100644 --- a/src/app/features/registry/models/get-registry-overview-json-api.model.ts +++ b/src/app/features/registry/models/get-registry-overview-json-api.model.ts @@ -47,6 +47,7 @@ export interface RegistryOverviewJsonApiAttributes { revision_state: RevisionReviewStates; reviews_state: RegistrationReviewStates; embargoed: boolean; + archiving: boolean; } export type RegistrationQuestions = Record; diff --git a/src/app/features/registry/models/registry-overview.models.ts b/src/app/features/registry/models/registry-overview.models.ts index 4ae8bb2ce..41aff0158 100644 --- a/src/app/features/registry/models/registry-overview.models.ts +++ b/src/app/features/registry/models/registry-overview.models.ts @@ -65,4 +65,5 @@ export interface RegistryOverview { links: { files: string; }; + archiving: boolean; } diff --git a/src/app/features/registry/pages/registry-overview/registry-overview.component.html b/src/app/features/registry/pages/registry-overview/registry-overview.component.html index 2e614bdba..96f7a70c6 100644 --- a/src/app/features/registry/pages/registry-overview/registry-overview.component.html +++ b/src/app/features/registry/pages/registry-overview/registry-overview.component.html @@ -3,72 +3,79 @@ class="flex flex-column justify-content-center md:flex-row md:gap-4 md:justify-content-between md:align-items-center" > - -
- -
+ @if (!registry()?.archiving) { +
+ +
+ } -
- + @if (registry()?.archiving) { +
+ +
+ } @else { +
+ -
-
-
- - - -
-
- @for (block of mappedSchemaBlocks(); track $index) { - @if (block.type === 'file-input' && block.files) { - - } @else if (block.type === 'multi-select-input' && block.values) { -
- @for (value of block.values; track $index) { - @if (value) { -

{{ value }}

+
+
+
+ + + +
+
+ @for (block of mappedSchemaBlocks(); track $index) { + @if (block.type === 'file-input' && block.files) { +
    + @for (file of block.files; track $index) { +
  • + {{ file.name }} +
  • } - } -
- } @else if (block.type === 'page-heading' && block.value) { -

{{ block.value }}

- } @else if ((block.type === 'subsection-heading' || block.type === 'question-label') && block.value) { -

{{ block.value }}

- } @else if (block.value && block.value !== 'select-input-option') { -

{{ block.value }}

+ + } @else if (block.type === 'multi-select-input' && block.values) { +
+ @for (value of block.values; track $index) { + @if (value) { +

{{ value }}

+ } + } +
+ } @else if (block.type === 'page-heading' && block.value) { +

{{ block.value }}

+ } @else if ((block.type === 'subsection-heading' || block.type === 'question-label') && block.value) { +

{{ block.value }}

+ } @else if (block.value && block.value !== 'select-input-option') { +

{{ block.value }}

+ } } - } +
+
+
+
-
-
-
-
+ } } @else {
diff --git a/src/app/features/registry/pages/registry-overview/registry-overview.component.ts b/src/app/features/registry/pages/registry-overview/registry-overview.component.ts index ed6f98509..ba5e85e9f 100644 --- a/src/app/features/registry/pages/registry-overview/registry-overview.component.ts +++ b/src/app/features/registry/pages/registry-overview/registry-overview.component.ts @@ -17,7 +17,7 @@ import { MapRegistryOverview } from '@osf/shared/mappers'; import { ToolbarResource } from '@osf/shared/models'; import { GetBookmarksCollectionId } from '@shared/stores'; -import { RegistryRevisionsComponent, RegistryStatusesComponent } from '../../components'; +import { ArchivingMessageComponent, RegistryRevisionsComponent, RegistryStatusesComponent } from '../../components'; import { MapViewSchemaBlock } from '../../mappers'; import { RegistrationQuestions } from '../../models'; import { @@ -39,6 +39,7 @@ import { RegistryRevisionsComponent, RegistryStatusesComponent, DataResourcesComponent, + ArchivingMessageComponent, ], templateUrl: './registry-overview.component.html', styleUrl: './registry-overview.component.scss', diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index 06bdcbcdf..2a6510049 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -2097,6 +2097,13 @@ "components": { "title": "Components", "noComponentsFound": "No components found" + }, + "archiving": { + "title": "This registration is currently archiving, and no changes can be made at this time.", + "pleaseNote": "Please note", + "description": "Changes to any files (1) in the projects or components being registered, (2) uploaded or selected as prompt responses, including those connected through add-ons during archiving will result in archiving failure and loss of your registration timestamp. Please do not modify your files until after you have received email confirmation of archiving completion. If this registration has been archiving for more than 72 hours, please email ", + "descriptionEnd": " for assistance.", + "createdDate": "Date created" } }, "truncatedText": { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 418d0467a..23e6e468d 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -1,5 +1,5 @@ export const environment = { - production: false, + production: true, webUrl: 'https://staging4.osf.io', downloadUrl: 'https://staging4.osf.io/download', apiUrl: 'https://api.staging4.osf.io/v2',