From 2189238bf831f3ad39dffc8162add92837b336f7 Mon Sep 17 00:00:00 2001 From: nsemets Date: Tue, 9 Sep 2025 19:52:02 +0300 Subject: [PATCH 1/7] fix(add): updated add project and component dialog --- src/app/core/constants/index.ts | 1 - .../constants/storage-locations.constant.ts | 8 -- .../add-component-dialog.component.html | 94 +++++--------- .../add-component-dialog.component.ts | 115 +++++++++--------- .../add-project-form.component.scss | 10 -- .../add-project-form.component.ts | 10 +- .../shared/stores/regions/regions.state.ts | 2 +- 7 files changed, 92 insertions(+), 148 deletions(-) delete mode 100644 src/app/core/constants/storage-locations.constant.ts diff --git a/src/app/core/constants/index.ts b/src/app/core/constants/index.ts index b97b14391..54e8fcb58 100644 --- a/src/app/core/constants/index.ts +++ b/src/app/core/constants/index.ts @@ -2,4 +2,3 @@ export * from './error-messages'; export * from './nav-items.constant'; export * from './ngxs-states.constant'; export * from './social-icons.constant'; -export * from './storage-locations.constant'; diff --git a/src/app/core/constants/storage-locations.constant.ts b/src/app/core/constants/storage-locations.constant.ts deleted file mode 100644 index 0a38c5df1..000000000 --- a/src/app/core/constants/storage-locations.constant.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { CustomOption } from '@osf/shared/models'; - -export const STORAGE_LOCATIONS: CustomOption[] = [ - { label: 'United States', value: 'us' }, - { label: 'Canada - Montréal', value: 'ca-1' }, - { label: 'Germany - Frankfurt', value: 'de-1' }, - { label: 'Australia - Sydney', value: 'de-1' }, -]; diff --git a/src/app/features/project/overview/components/add-component-dialog/add-component-dialog.component.html b/src/app/features/project/overview/components/add-component-dialog/add-component-dialog.component.html index 5dc3ca672..9f40bc758 100644 --- a/src/app/features/project/overview/components/add-component-dialog/add-component-dialog.component.html +++ b/src/app/features/project/overview/components/add-component-dialog/add-component-dialog.component.html @@ -7,45 +7,16 @@ @if (currentProject()?.affiliatedInstitutions?.length) { -
-
-

- {{ 'project.overview.dialog.addComponent.affiliation.title' | translate }} -

-
- - - - -
-
+
+

+ {{ 'myProjects.createProject.affiliation.title' | translate }} +

-
- @for (affiliation of currentProject()?.affiliatedInstitutions; track affiliation.id) { -
- - Institution Logo -
- } -
+
} @@ -55,42 +26,35 @@

- @@ -69,11 +67,11 @@

{{ 'files.emptyState' | translate }} - + diff --git a/src/app/features/files/components/move-file-dialog/move-file-dialog.component.scss b/src/app/features/files/components/move-file-dialog/move-file-dialog.component.scss index c63d56e96..cc3971c72 100644 --- a/src/app/features/files/components/move-file-dialog/move-file-dialog.component.scss +++ b/src/app/features/files/components/move-file-dialog/move-file-dialog.component.scss @@ -1,4 +1,3 @@ -@use "styles/variables" as var; @use "styles/mixins" as mix; :host { @@ -7,12 +6,12 @@ } .files-table { - border: 1px solid var.$grey-2; + border: 1px solid var(--grey-2); border-radius: mix.rem(8px); &-row { - border-bottom: 1px solid var.$grey-2; - color: var.$dark-blue-1; + border-bottom: 1px solid var(--grey-2); + color: var(--dark-blue-1); } &-row:last-child { @@ -26,7 +25,7 @@ cursor: pointer; &.disabled { - color: var.$grey-1; + color: var(--grey-1); cursor: not-allowed; } @@ -35,6 +34,12 @@ } } +.link-btn-no-padding { + --p-button-label-font-weight: 400; + --p-button-link-hover-color: var(--dark-blue-1); + --p-button-link-color: var(--dark-blue-1); +} + .disabled-icon { - color: var.$grey-1; + color: var(--grey-1); } From 02cff8eea5bfdb6626c47fa21cd2a78c7930ed52 Mon Sep 17 00:00:00 2001 From: nsemets Date: Wed, 10 Sep 2025 11:37:26 +0300 Subject: [PATCH 3/7] fix(overview): updated project overview --- .../overview-collections.component.html | 3 +- .../overview-collections.component.ts | 24 ++++++--- .../overview/project-overview.component.html | 5 +- .../overview/project-overview.component.scss | 2 + .../overview/project-overview.component.ts | 31 +++++------- .../resource-metadata.component.html | 49 ++++++++----------- .../resource-metadata.component.ts | 10 ++-- src/app/shared/constants/index.ts | 1 - .../constants/osf-resource-types.const.ts | 4 -- 9 files changed, 62 insertions(+), 67 deletions(-) delete mode 100644 src/app/shared/constants/osf-resource-types.const.ts diff --git a/src/app/features/project/overview/components/overview-collections/overview-collections.component.html b/src/app/features/project/overview/components/overview-collections/overview-collections.component.html index df41395ef..fd87c2aee 100644 --- a/src/app/features/project/overview/components/overview-collections/overview-collections.component.html +++ b/src/app/features/project/overview/components/overview-collections/overview-collections.component.html @@ -17,8 +17,9 @@

{{ 'project.overview.metadata.collection' | translate }}

diff --git a/src/app/features/project/overview/components/overview-collections/overview-collections.component.ts b/src/app/features/project/overview/components/overview-collections/overview-collections.component.ts index 220def59a..b85f48c30 100644 --- a/src/app/features/project/overview/components/overview-collections/overview-collections.component.ts +++ b/src/app/features/project/overview/components/overview-collections/overview-collections.component.ts @@ -12,30 +12,41 @@ import { Router } from '@angular/router'; import { collectionFilterNames } from '@osf/features/collections/constants'; import { SubmissionReviewStatus } from '@osf/features/moderation/enums'; +import { StopPropagationDirective } from '@osf/shared/directives'; import { CollectionSubmission, ResourceOverview } from '@osf/shared/models'; import { CollectionsSelectors, GetProjectSubmissions } from '@osf/shared/stores'; @Component({ selector: 'osf-overview-collections', - imports: [Accordion, AccordionPanel, AccordionHeader, AccordionContent, TranslatePipe, Skeleton, Tag, Button], + imports: [ + Accordion, + AccordionPanel, + AccordionHeader, + AccordionContent, + TranslatePipe, + Skeleton, + Tag, + Button, + StopPropagationDirective, + ], templateUrl: './overview-collections.component.html', styleUrl: './overview-collections.component.scss', changeDetection: ChangeDetectionStrategy.OnPush, }) export class OverviewCollectionsComponent { private readonly router = inject(Router); - protected readonly SubmissionReviewStatus = SubmissionReviewStatus; + readonly SubmissionReviewStatus = SubmissionReviewStatus; currentProject = input.required(); projectSubmissions = select(CollectionsSelectors.getCurrentProjectSubmissions); isProjectSubmissionsLoading = select(CollectionsSelectors.getCurrentProjectSubmissionsLoading); - protected projectId = computed(() => { + projectId = computed(() => { const resource = this.currentProject(); return resource ? resource.id : null; }); - protected actions = createDispatchMap({ getProjectSubmissions: GetProjectSubmissions }); + actions = createDispatchMap({ getProjectSubmissions: GetProjectSubmissions }); constructor() { effect(() => { @@ -47,7 +58,7 @@ export class OverviewCollectionsComponent { }); } - protected get submissionAttributes() { + get submissionAttributes() { return (submission: CollectionSubmission) => { if (!submission) return []; @@ -60,8 +71,7 @@ export class OverviewCollectionsComponent { }; } - navigateToCollection($event: Event, submission: CollectionSubmission) { - $event.stopPropagation(); + navigateToCollection(submission: CollectionSubmission) { this.router.navigate([`collections/${submission.collectionId}/`]); } } diff --git a/src/app/features/project/overview/project-overview.component.html b/src/app/features/project/overview/project-overview.component.html index 9bd5c4508..39dae20c9 100644 --- a/src/app/features/project/overview/project-overview.component.html +++ b/src/app/features/project/overview/project-overview.component.html @@ -28,9 +28,8 @@ link [label]="'moderation.makeDecision.goBackLink' | translate" class="link-btn-no-padding font-bold" - (click)="goBack()" - > - + (onClick)="goBack()" + /> @if (status && isCollectionsRoute() && collectionProvider()) { @switch (status) { diff --git a/src/app/features/project/overview/project-overview.component.scss b/src/app/features/project/overview/project-overview.component.scss index fbe6efa4b..c5b7870c4 100644 --- a/src/app/features/project/overview/project-overview.component.scss +++ b/src/app/features/project/overview/project-overview.component.scss @@ -4,6 +4,7 @@ width: 23rem; border: 1px solid var(--grey-2); border-radius: 12px; + @media (max-width: var.$breakpoint-lg) { width: 100%; } @@ -11,6 +12,7 @@ .left-section { width: calc(100% - 23rem - 1.5rem); + @media (max-width: var.$breakpoint-lg) { width: 100%; } diff --git a/src/app/features/project/overview/project-overview.component.ts b/src/app/features/project/overview/project-overview.component.ts index 804aa7f4d..31b5b3ae6 100644 --- a/src/app/features/project/overview/project-overview.component.ts +++ b/src/app/features/project/overview/project-overview.component.ts @@ -143,9 +143,11 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement getConfiguredStorageAddons: GetConfiguredStorageAddons, }); - readonly isCollectionsRoute = computed(() => { - return this.router.url.includes('/collections'); - }); + currentProject = select(ProjectOverviewSelectors.getProject); + isAnonymous = select(ProjectOverviewSelectors.isProjectAnonymous); + private currentProject$ = toObservable(this.currentProject); + + readonly isCollectionsRoute = computed(() => this.router.url.includes('/collections')); readonly isModerationMode = computed(() => { const mode = this.route.snapshot.queryParams['mode']; @@ -153,9 +155,7 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement return mode === Mode.Moderation; }); - submissionReviewStatus = computed(() => { - return this.currentReviewAction()?.toState; - }); + submissionReviewStatus = computed(() => this.currentReviewAction()?.toState); showDecisionButton = computed(() => { return ( @@ -165,17 +165,8 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement ); }); - currentProject = select(ProjectOverviewSelectors.getProject); - private currentProject$ = toObservable(this.currentProject); - isAnonymous = select(ProjectOverviewSelectors.isProjectAnonymous); - - userPermissions = computed(() => { - return this.currentProject()?.currentUserPermissions || []; - }); - - hasViewOnly = computed(() => { - return hasViewOnlyParam(this.router); - }); + userPermissions = computed(() => this.currentProject()?.currentUserPermissions || []); + hasViewOnly = computed(() => hasViewOnlyParam(this.router)); get isAdmin(): boolean { return this.userPermissions().includes(UserPermissions.Admin); @@ -193,9 +184,9 @@ export class ProjectOverviewComponent extends DataciteTrackerComponent implement return null; }); - isLoading = computed(() => { - return this.isProjectLoading() || this.isCollectionProviderLoading() || this.isReviewActionsLoading(); - }); + isLoading = computed( + () => this.isProjectLoading() || this.isCollectionProviderLoading() || this.isReviewActionsLoading() + ); currentResource = computed(() => { const project = this.currentProject(); diff --git a/src/app/shared/components/resource-metadata/resource-metadata.component.html b/src/app/shared/components/resource-metadata/resource-metadata.component.html index 68131c9cd..7a13b18f4 100644 --- a/src/app/shared/components/resource-metadata/resource-metadata.component.html +++ b/src/app/shared/components/resource-metadata/resource-metadata.component.html @@ -21,7 +21,7 @@

{{ 'project.overview.metadata.contributors' | translate }}

@if (!resource.isAnonymous) { @for (contributor of resource.contributors; track contributor.id) { } @@ -40,7 +40,7 @@

{{ 'project.overview.metadata.description' | translate }}

/> - @if (resource.type === resourceTypes.Projects) { + @if (isProject()) {

{{ 'project.overview.metadata.supplements' | translate }}

@@ -48,9 +48,9 @@

{{ 'project.overview.metadata.supplements' | translate }}

@for (supplement of resource.supplements; track supplement.id) {

{{ 'project.overview.metadata.supplementsText1' | translate }} - {{ - supplement.title + ', ' + (supplement.dateCreated | date: 'MMMM d, y') - }} + + {{ supplement.title + ', ' + (supplement.dateCreated | date: 'MMMM d, y') }} + {{ 'project.overview.metadata.supplementsText2' | translate }}

} @@ -60,7 +60,7 @@

{{ 'project.overview.metadata.supplements' | translate }}

} - @if (resource.type === resourceTypes.Registrations) { + @if (isRegistration()) {

{{ 'registry.overview.metadata.type' | translate }}

{{ resource.registrationType }}

@@ -70,9 +70,9 @@

{{ 'registry.overview.metadata.type' | translate }}

{{ 'registry.overview.metadata.associatedProject' | translate }}

- {{ - 'osf.io/' + resource.associatedProjectId - }} + + {{ 'osf.io/' + resource.associatedProjectId }} +
} } @@ -80,18 +80,18 @@

{{ 'registry.overview.metadata.associatedProject' | translate }}

{{ 'project.overview.metadata.dateCreated' | translate }}

-

{{ resource.dateCreated | date: 'MMM d, y, h:mm a' }}

+

{{ resource.dateCreated | date: dateFormat }}

- @if (resource.type !== resourceTypes.Registrations) { + @if (isProject()) {

{{ 'project.overview.metadata.dateUpdated' | translate }}

-

{{ resource.dateModified | date: 'MMM d, y, h:mm a' }}

+

{{ resource.dateModified | date: dateFormat }}

} @else {

{{ 'registry.overview.metadata.registeredDate' | translate }}

-

{{ resource.dateRegistered | date: 'MMM d, y, h:mm a' }}

+

{{ resource.dateRegistered | date: dateFormat }}

}
@@ -104,24 +104,16 @@

{{ 'project.overview.metadata.license' | translate }}

@if (!resource.isAnonymous) {
- @if (resource.type !== resourceTypes.Registrations) { -

{{ 'project.overview.metadata.publication' | translate }}

- } @else { -

{{ 'registry.overview.metadata.doi' | translate }}

- } +

+ {{ (isProject() ? 'project.overview.metadata.publication' : 'registry.overview.metadata.doi') | translate }} +

@if (resource.identifiers?.length) { @for (identifier of resource.identifiers; track identifier.id) { @if (identifier.category === 'doi') { - @if (resource.type !== resourceTypes.Registrations) { - - {{ identifier.value }} - - } @else { - - {{ 'https://doi.org/' + identifier.value }} - - } + + {{ identifier.value }} + } } } @else { @@ -134,7 +126,7 @@

{{ 'registry.overview.metadata.doi' | translate }}

} - @if (resource.type === resourceTypes.Projects) { + @if (isProject()) { } @@ -165,6 +157,7 @@

{{ 'project.overview.metadata.tags' | translate }}

{{ 'project.overview.metadata.noTags' | translate }}

}
+ @if (!resource.isAnonymous) { (false); canWrite = input.required(); - protected readonly resourceTypes = OsfResourceTypes; + readonly resourceTypes = CurrentResourceType; + readonly dateFormat = 'MMM d, y, h:mm a'; + + isProject = computed(() => this.currentResource()?.type === CurrentResourceType.Projects); + isRegistration = computed(() => this.currentResource()?.type === CurrentResourceType.Registrations); onCustomCitationUpdated(citation: string): void { this.customCitationUpdated.emit(citation); diff --git a/src/app/shared/constants/index.ts b/src/app/shared/constants/index.ts index 5d262e421..23069ad60 100644 --- a/src/app/shared/constants/index.ts +++ b/src/app/shared/constants/index.ts @@ -9,7 +9,6 @@ export * from './input-validation-messages.const'; export * from './language.const'; export * from './meetings-table.constants'; export * from './my-projects-table.constants'; -export * from './osf-resource-types.const'; export * from './pie-chart-palette'; export * from './pie-chart-palette'; export * from './registry-services-icons.const'; diff --git a/src/app/shared/constants/osf-resource-types.const.ts b/src/app/shared/constants/osf-resource-types.const.ts deleted file mode 100644 index 14707ddae..000000000 --- a/src/app/shared/constants/osf-resource-types.const.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const OsfResourceTypes = { - Projects: 'nodes', - Registrations: 'registrations', -}; From 4064074ebf40bbb15ec49343cf68c57388add39d Mon Sep 17 00:00:00 2001 From: nsemets Date: Wed, 10 Sep 2025 13:40:34 +0300 Subject: [PATCH 4/7] fix(updates): clean up some code --- .../institutions-list.component.ts | 2 +- .../institutions-search.component.ts | 5 ++--- .../registry-submission-item.component.html | 2 +- .../registries-landing.component.html | 4 ++-- .../registries-landing.component.scss | 8 +------- .../registries-provider-search.model.ts | 11 ++++++++++- .../registries-provider-search.state.ts | 13 +++++-------- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/app/features/institutions/pages/institutions-list/institutions-list.component.ts b/src/app/features/institutions/pages/institutions-list/institutions-list.component.ts index 4c9b1516c..bca6e1bf7 100644 --- a/src/app/features/institutions/pages/institutions-list/institutions-list.component.ts +++ b/src/app/features/institutions/pages/institutions-list/institutions-list.component.ts @@ -30,7 +30,7 @@ import { import { TABLE_PARAMS } from '@osf/shared/constants'; import { parseQueryFilterParams } from '@osf/shared/helpers'; import { QueryParams } from '@osf/shared/models'; -import { FetchInstitutions, InstitutionsSelectors } from '@osf/shared/stores/institutions'; +import { FetchInstitutions, InstitutionsSelectors } from '@osf/shared/stores'; @Component({ selector: 'osf-institutions-list', diff --git a/src/app/features/institutions/pages/institutions-search/institutions-search.component.ts b/src/app/features/institutions/pages/institutions-search/institutions-search.component.ts index c8b66b63e..dd6f8583b 100644 --- a/src/app/features/institutions/pages/institutions-search/institutions-search.component.ts +++ b/src/app/features/institutions/pages/institutions-search/institutions-search.component.ts @@ -7,11 +7,10 @@ import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/cor import { FormsModule } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; -import { LoadingSpinnerComponent } from '@osf/shared/components'; +import { GlobalSearchComponent, LoadingSpinnerComponent } from '@osf/shared/components'; import { SEARCH_TAB_OPTIONS } from '@osf/shared/constants'; +import { SetDefaultFilterValue } from '@osf/shared/stores/global-search'; import { FetchInstitutionById, InstitutionsSearchSelectors } from '@osf/shared/stores/institutions-search'; -import { GlobalSearchComponent } from '@shared/components'; -import { SetDefaultFilterValue } from '@shared/stores/global-search'; @Component({ selector: 'osf-institutions-search', diff --git a/src/app/features/moderation/components/registry-submission-item/registry-submission-item.component.html b/src/app/features/moderation/components/registry-submission-item/registry-submission-item.component.html index 55c570e5c..418a9957b 100644 --- a/src/app/features/moderation/components/registry-submission-item/registry-submission-item.component.html +++ b/src/app/features/moderation/components/registry-submission-item/registry-submission-item.component.html @@ -6,7 +6,7 @@ class="link-btn-no-padding" link [label]="submission().title" - [routerLink]="[submission().id, 'overview']" + [routerLink]="['/', submission().id, 'overview']" [queryParams]="{ mode: 'moderator', revisionId: isPendingModeration && !isPending ? submission().revisionId : null, diff --git a/src/app/features/registries/pages/registries-landing/registries-landing.component.html b/src/app/features/registries/pages/registries-landing/registries-landing.component.html index c3e8bbcde..800b3548f 100644 --- a/src/app/features/registries/pages/registries-landing/registries-landing.component.html +++ b/src/app/features/registries/pages/registries-landing/registries-landing.component.html @@ -27,7 +27,7 @@

{{ 'registries.browse' | translate }}

styleClass="hidden sm:block sm:w-auto" [label]="'registries.seeMore' | translate" severity="secondary" - (click)="redirectToSearchPageRegistrations()" + (onClick)="redirectToSearchPageRegistrations()" />
@@ -44,7 +44,7 @@

{{ 'registries.browse' | translate }}

styleClass="block w-full sm:hidden" [label]="'registries.seeMore' | translate" severity="secondary" - (click)="redirectToSearchPageRegistrations()" + (onClick)="redirectToSearchPageRegistrations()" /> diff --git a/src/app/features/registries/pages/registries-landing/registries-landing.component.scss b/src/app/features/registries/pages/registries-landing/registries-landing.component.scss index 4f4c2e9be..201936eb4 100644 --- a/src/app/features/registries/pages/registries-landing/registries-landing.component.scss +++ b/src/app/features/registries/pages/registries-landing/registries-landing.component.scss @@ -1,9 +1,3 @@ -@use "styles/variables" as var; - -.subheader { - color: var.$dark-blue-1; -} - .registries { - background: var.$white; + background: var(--white); } diff --git a/src/app/features/registries/store/registries-provider-search/registries-provider-search.model.ts b/src/app/features/registries/store/registries-provider-search/registries-provider-search.model.ts index 786d6d349..87598b29e 100644 --- a/src/app/features/registries/store/registries-provider-search/registries-provider-search.model.ts +++ b/src/app/features/registries/store/registries-provider-search/registries-provider-search.model.ts @@ -1,6 +1,15 @@ -import { RegistryProviderDetails } from '@osf/features/registries/models/registry-provider.model'; import { AsyncStateModel } from '@shared/models'; +import { RegistryProviderDetails } from '../../models'; + export interface RegistriesProviderSearchStateModel { currentBrandedProvider: AsyncStateModel; } + +export const REGISTRIES_PROVIDER_SEARCH_STATE_DEFAULTS: RegistriesProviderSearchStateModel = { + currentBrandedProvider: { + data: null, + isLoading: false, + error: null, + }, +}; diff --git a/src/app/features/registries/store/registries-provider-search/registries-provider-search.state.ts b/src/app/features/registries/store/registries-provider-search/registries-provider-search.state.ts index b27830222..fd72025f3 100644 --- a/src/app/features/registries/store/registries-provider-search/registries-provider-search.state.ts +++ b/src/app/features/registries/store/registries-provider-search/registries-provider-search.state.ts @@ -6,20 +6,17 @@ import { catchError, tap } from 'rxjs'; import { inject, Injectable } from '@angular/core'; import { ProvidersService } from '@osf/features/registries/services'; -import { RegistriesProviderSearchStateModel } from '@osf/features/registries/store/registries-provider-search/registries-provider-search.model'; import { handleSectionError } from '@shared/helpers'; import { GetRegistryProviderBrand } from './registries-provider-search.actions'; +import { + REGISTRIES_PROVIDER_SEARCH_STATE_DEFAULTS, + RegistriesProviderSearchStateModel, +} from './registries-provider-search.model'; @State({ name: 'registryProviderSearch', - defaults: { - currentBrandedProvider: { - data: null, - isLoading: false, - error: null, - }, - }, + defaults: REGISTRIES_PROVIDER_SEARCH_STATE_DEFAULTS, }) @Injectable() export class RegistriesProviderSearchState { From 3eae6afdd620524a2a07629266509fb21efcda76 Mon Sep 17 00:00:00 2001 From: nsemets Date: Wed, 10 Sep 2025 14:13:44 +0300 Subject: [PATCH 5/7] fix(regions): updated regions state and removed duplication --- src/app/features/registries/models/index.ts | 1 - .../models/projects-json-api.model.ts | 13 ---------- .../account-settings.component.spec.ts | 3 ++- .../account-settings.component.ts | 5 ++-- ...default-storage-location.component.spec.ts | 7 +++--- .../default-storage-location.component.ts | 5 ++-- .../account-settings/mappers/index.ts | 1 - .../mappers/regions.mapper.ts | 18 ------------- .../responses/get-regions-response.model.ts | 4 --- .../models/responses/index.ts | 1 - .../services/account-settings.service.ts | 11 ++------ .../store/account-settings.actions.ts | 4 --- .../store/account-settings.model.ts | 4 +-- .../store/account-settings.selectors.ts | 7 +----- .../store/account-settings.state.ts | 9 ------- .../constants/my-projects-table.constants.ts | 2 +- .../shared/mappers/regions/regions-mapper.ts | 3 +-- src/app/shared/models/index.ts | 1 + .../models/regions/regions.json-api.model.ts | 25 +++++++++++++------ 19 files changed, 36 insertions(+), 88 deletions(-) delete mode 100644 src/app/features/registries/models/projects-json-api.model.ts delete mode 100644 src/app/features/settings/account-settings/mappers/regions.mapper.ts delete mode 100644 src/app/features/settings/account-settings/models/responses/get-regions-response.model.ts diff --git a/src/app/features/registries/models/index.ts b/src/app/features/registries/models/index.ts index abedd2a68..3b045981b 100644 --- a/src/app/features/registries/models/index.ts +++ b/src/app/features/registries/models/index.ts @@ -1,5 +1,4 @@ export * from './project'; -export * from './projects-json-api.model'; export * from './provider-schema.model'; export * from './registry-provider.model'; export * from './registry-provider-json-api.model'; diff --git a/src/app/features/registries/models/projects-json-api.model.ts b/src/app/features/registries/models/projects-json-api.model.ts deleted file mode 100644 index 468e34c0c..000000000 --- a/src/app/features/registries/models/projects-json-api.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ApiData, MetaJsonApi, PaginationLinksJsonApi } from '@osf/shared/models'; - -export interface ProjectsResponseJsonApi { - data: ProjectsDataJsonApi[]; - meta: MetaJsonApi; - links: PaginationLinksJsonApi; -} - -export type ProjectsDataJsonApi = ApiData; - -interface ProjectsAttributesJsonApi { - title: string; -} diff --git a/src/app/features/settings/account-settings/account-settings.component.spec.ts b/src/app/features/settings/account-settings/account-settings.component.spec.ts index 05f487342..f67cf0770 100644 --- a/src/app/features/settings/account-settings/account-settings.component.spec.ts +++ b/src/app/features/settings/account-settings/account-settings.component.spec.ts @@ -21,6 +21,7 @@ import { } from '@osf/features/settings/account-settings/components'; import { AccountSettingsSelectors } from '@osf/features/settings/account-settings/store'; import { SubHeaderComponent } from '@osf/shared/components'; +import { RegionsSelectors } from '@osf/shared/stores'; import { MOCK_STORE, MOCK_USER, MockCustomConfirmationServiceProvider, TranslateServiceMock } from '@shared/mocks'; import { ToastService } from '@shared/services'; @@ -43,7 +44,7 @@ describe('AccountSettingsComponent', () => { case AccountSettingsSelectors.getExternalIdentities: return () => null; - case AccountSettingsSelectors.getRegions: + case RegionsSelectors.getRegions: return () => null; case AccountSettingsSelectors.getUserInstitutions: diff --git a/src/app/features/settings/account-settings/account-settings.component.ts b/src/app/features/settings/account-settings/account-settings.component.ts index f20f47fba..a905f49e8 100644 --- a/src/app/features/settings/account-settings/account-settings.component.ts +++ b/src/app/features/settings/account-settings/account-settings.component.ts @@ -10,6 +10,7 @@ import { ReactiveFormsModule } from '@angular/forms'; import { GetEmails } from '@core/store/user-emails'; import { UserSelectors } from '@osf/core/store/user'; import { SubHeaderComponent } from '@osf/shared/components'; +import { FetchRegions } from '@osf/shared/stores'; import { AffiliatedInstitutionsComponent, @@ -21,7 +22,7 @@ import { ShareIndexingComponent, TwoFactorAuthComponent, } from './components'; -import { GetAccountSettings, GetExternalIdentities, GetRegions, GetUserInstitutions } from './store'; +import { GetAccountSettings, GetExternalIdentities, GetUserInstitutions } from './store'; @Component({ selector: 'osf-account-settings', @@ -48,7 +49,7 @@ export class AccountSettingsComponent { getAccountSettings: GetAccountSettings, getEmails: GetEmails, getExternalIdentities: GetExternalIdentities, - getRegions: GetRegions, + getRegions: FetchRegions, getUserInstitutions: GetUserInstitutions, }); readonly currentUser = select(UserSelectors.getCurrentUser); diff --git a/src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.spec.ts b/src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.spec.ts index db7e0d94c..615039bac 100644 --- a/src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.spec.ts +++ b/src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.spec.ts @@ -9,10 +9,11 @@ import { signal } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { UserSelectors, UserState } from '@osf/core/store/user'; +import { RegionsSelectors, RegionsState } from '@osf/shared/stores'; import { MOCK_STORE } from '@shared/mocks'; import { LoaderService, ToastService } from '@shared/services'; -import { AccountSettingsSelectors, AccountSettingsState } from '../../store'; +import { AccountSettingsState } from '../../store'; import { DefaultStorageLocationComponent } from './default-storage-location.component'; @@ -37,7 +38,7 @@ describe('DefaultStorageLocationComponent', () => { if (selector === UserSelectors.getCurrentUser) { return () => signal(mockUser); } - if (selector === AccountSettingsSelectors.getRegions) { + if (selector === RegionsSelectors.getRegions) { return () => signal(mockRegions); } return () => signal(null); @@ -48,7 +49,7 @@ describe('DefaultStorageLocationComponent', () => { providers: [ MockProvider(ToastService), MockProvider(LoaderService, mockLoaderService), - provideStore([AccountSettingsState, UserState]), + provideStore([AccountSettingsState, UserState, RegionsState]), provideHttpClient(), provideHttpClientTesting(), ], diff --git a/src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.ts b/src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.ts index 87f0df057..c3cfff597 100644 --- a/src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.ts +++ b/src/app/features/settings/account-settings/components/default-storage-location/default-storage-location.component.ts @@ -14,8 +14,9 @@ import { FormsModule } from '@angular/forms'; import { UserSelectors } from '@osf/core/store/user'; import { IdName } from '@osf/shared/models'; import { LoaderService, ToastService } from '@osf/shared/services'; +import { RegionsSelectors } from '@osf/shared/stores/regions'; -import { AccountSettingsSelectors, UpdateRegion } from '../../store'; +import { UpdateRegion } from '../../store'; @Component({ selector: 'osf-default-storage-location', @@ -30,7 +31,7 @@ export class DefaultStorageLocationComponent { private readonly toastService = inject(ToastService); readonly currentUser = select(UserSelectors.getCurrentUser); - readonly regions = select(AccountSettingsSelectors.getRegions); + readonly regions = select(RegionsSelectors.getRegions); selectedRegion = signal(undefined); constructor() { diff --git a/src/app/features/settings/account-settings/mappers/index.ts b/src/app/features/settings/account-settings/mappers/index.ts index 8c3358f1a..aeb229f85 100644 --- a/src/app/features/settings/account-settings/mappers/index.ts +++ b/src/app/features/settings/account-settings/mappers/index.ts @@ -1,3 +1,2 @@ export * from './account-settings.mapper'; export * from './external-identities.mapper'; -export * from './regions.mapper'; diff --git a/src/app/features/settings/account-settings/mappers/regions.mapper.ts b/src/app/features/settings/account-settings/mappers/regions.mapper.ts deleted file mode 100644 index b817a06f6..000000000 --- a/src/app/features/settings/account-settings/mappers/regions.mapper.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ApiData, IdName } from '@osf/shared/models'; - -export function MapRegions(data: ApiData<{ name: string }, null, null, null>[]): IdName[] { - const regions: IdName[] = []; - - for (const region of data) { - regions.push(MapRegion(region)); - } - - return regions; -} - -export function MapRegion(data: ApiData<{ name: string }, null, null, null>): IdName { - return { - id: data.id, - name: data.attributes.name, - }; -} diff --git a/src/app/features/settings/account-settings/models/responses/get-regions-response.model.ts b/src/app/features/settings/account-settings/models/responses/get-regions-response.model.ts deleted file mode 100644 index c6a709b32..000000000 --- a/src/app/features/settings/account-settings/models/responses/get-regions-response.model.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ApiData, JsonApiResponse } from '@osf/shared/models'; - -export type GetRegionsResponseJsonApi = JsonApiResponse[], null>; -export type GetRegionResponseJsonApi = JsonApiResponse, null>; diff --git a/src/app/features/settings/account-settings/models/responses/index.ts b/src/app/features/settings/account-settings/models/responses/index.ts index 8cfd8da94..58d4c1bdb 100644 --- a/src/app/features/settings/account-settings/models/responses/index.ts +++ b/src/app/features/settings/account-settings/models/responses/index.ts @@ -1,3 +1,2 @@ export * from './get-account-settings-response.model'; -export * from './get-regions-response.model'; export * from './list-identities-response.model'; diff --git a/src/app/features/settings/account-settings/services/account-settings.service.ts b/src/app/features/settings/account-settings/services/account-settings.service.ts index a64e5aaa3..344cd799a 100644 --- a/src/app/features/settings/account-settings/services/account-settings.service.ts +++ b/src/app/features/settings/account-settings/services/account-settings.service.ts @@ -3,15 +3,14 @@ import { map, Observable } from 'rxjs'; import { inject, Injectable } from '@angular/core'; import { UserMapper } from '@osf/shared/mappers'; -import { IdName, JsonApiResponse, User, UserDataJsonApi } from '@osf/shared/models'; +import { JsonApiResponse, User, UserDataJsonApi } from '@osf/shared/models'; import { JsonApiService } from '@osf/shared/services'; -import { MapAccountSettings, MapExternalIdentities, MapRegions } from '../mappers'; +import { MapAccountSettings, MapExternalIdentities } from '../mappers'; import { AccountSettings, ExternalIdentity, GetAccountSettingsResponseJsonApi, - GetRegionsResponseJsonApi, ListIdentitiesResponseJsonApi, } from '../models'; @@ -24,12 +23,6 @@ export class AccountSettingsService { private readonly jsonApiService = inject(JsonApiService); private readonly apiUrl = `${environment.apiDomainUrl}/v2`; - getRegions(): Observable { - return this.jsonApiService - .get(`${this.apiUrl}/regions/`) - .pipe(map((response) => MapRegions(response.data))); - } - updateLocation(userId: string, locationId: string): Observable { const body = { data: { diff --git a/src/app/features/settings/account-settings/store/account-settings.actions.ts b/src/app/features/settings/account-settings/store/account-settings.actions.ts index 91722ee51..f05e37a82 100644 --- a/src/app/features/settings/account-settings/store/account-settings.actions.ts +++ b/src/app/features/settings/account-settings/store/account-settings.actions.ts @@ -1,7 +1,3 @@ -export class GetRegions { - static readonly type = '[AccountSettings] Get Regions'; -} - export class UpdateRegion { static readonly type = '[AccountSettings] Update Region'; diff --git a/src/app/features/settings/account-settings/store/account-settings.model.ts b/src/app/features/settings/account-settings/store/account-settings.model.ts index fd9409d2b..dd1164e0b 100644 --- a/src/app/features/settings/account-settings/store/account-settings.model.ts +++ b/src/app/features/settings/account-settings/store/account-settings.model.ts @@ -1,16 +1,14 @@ -import { IdName, Institution } from '@shared/models'; +import { Institution } from '@shared/models'; import { AccountSettings, ExternalIdentity } from '../models'; export interface AccountSettingsStateModel { - regions: IdName[]; externalIdentities: ExternalIdentity[]; accountSettings: AccountSettings; userInstitutions: Institution[]; } export const ACCOUNT_SETTINGS_STATE_DEFAULTS: AccountSettingsStateModel = { - regions: [], externalIdentities: [], accountSettings: { twoFactorEnabled: false, diff --git a/src/app/features/settings/account-settings/store/account-settings.selectors.ts b/src/app/features/settings/account-settings/store/account-settings.selectors.ts index bc19d6481..ff561bd65 100644 --- a/src/app/features/settings/account-settings/store/account-settings.selectors.ts +++ b/src/app/features/settings/account-settings/store/account-settings.selectors.ts @@ -1,6 +1,6 @@ import { Selector } from '@ngxs/store'; -import { IdName, Institution } from '@shared/models'; +import { Institution } from '@shared/models'; import { AccountSettings, ExternalIdentity } from '../models'; @@ -8,11 +8,6 @@ import { AccountSettingsStateModel } from './account-settings.model'; import { AccountSettingsState } from './account-settings.state'; export class AccountSettingsSelectors { - @Selector([AccountSettingsState]) - static getRegions(state: AccountSettingsStateModel): IdName[] { - return state.regions; - } - @Selector([AccountSettingsState]) static getExternalIdentities(state: AccountSettingsStateModel): ExternalIdentity[] { return state.externalIdentities; diff --git a/src/app/features/settings/account-settings/store/account-settings.state.ts b/src/app/features/settings/account-settings/store/account-settings.state.ts index fb57cac16..2448b3a23 100644 --- a/src/app/features/settings/account-settings/store/account-settings.state.ts +++ b/src/app/features/settings/account-settings/store/account-settings.state.ts @@ -18,7 +18,6 @@ import { EnableTwoFactorAuth, GetAccountSettings, GetExternalIdentities, - GetRegions, GetUserInstitutions, UpdateAccountSettings, UpdateIndexing, @@ -38,14 +37,6 @@ export class AccountSettingsState { private readonly institutionsService = inject(InstitutionsService); private readonly store = inject(Store); - @Action(GetRegions) - getRegions(ctx: StateContext) { - return this.accountSettingsService.getRegions().pipe( - tap((regions) => ctx.patchState({ regions: regions })), - catchError((error) => throwError(() => error)) - ); - } - @Action(UpdateRegion) updateRegion(ctx: StateContext, action: UpdateRegion) { const currentUser = this.store.selectSnapshot(UserSelectors.getCurrentUser); diff --git a/src/app/shared/constants/my-projects-table.constants.ts b/src/app/shared/constants/my-projects-table.constants.ts index 802623a75..a3d485202 100644 --- a/src/app/shared/constants/my-projects-table.constants.ts +++ b/src/app/shared/constants/my-projects-table.constants.ts @@ -1,4 +1,4 @@ -import { TableParameters } from '@osf/shared/models/table-parameters.model'; +import { TableParameters } from '../models'; export const MY_PROJECTS_TABLE_PARAMS: TableParameters = { rows: 10, diff --git a/src/app/shared/mappers/regions/regions-mapper.ts b/src/app/shared/mappers/regions/regions-mapper.ts index 5bfdaddfa..41399c48f 100644 --- a/src/app/shared/mappers/regions/regions-mapper.ts +++ b/src/app/shared/mappers/regions/regions-mapper.ts @@ -1,5 +1,4 @@ -import { IdName } from '@osf/shared/models'; -import { RegionsResponseJsonApi } from '@osf/shared/models/regions'; +import { IdName, RegionsResponseJsonApi } from '@osf/shared/models'; export class RegionsMapper { static fromRegionsResponseJsonApi(response: RegionsResponseJsonApi): IdName[] { diff --git a/src/app/shared/models/index.ts b/src/app/shared/models/index.ts index fb9df110d..395386811 100644 --- a/src/app/shared/models/index.ts +++ b/src/app/shared/models/index.ts @@ -35,6 +35,7 @@ export * from './project-metadata-update-payload.model'; export * from './projects'; export * from './provider'; export * from './query-params.model'; +export * from './regions'; export * from './registration'; export * from './resource-metadata.model'; export * from './resource-overview.model'; diff --git a/src/app/shared/models/regions/regions.json-api.model.ts b/src/app/shared/models/regions/regions.json-api.model.ts index 305c32a53..290151b26 100644 --- a/src/app/shared/models/regions/regions.json-api.model.ts +++ b/src/app/shared/models/regions/regions.json-api.model.ts @@ -1,9 +1,18 @@ -export interface RegionsResponseJsonApi { - data: { - id: string; - type: 'regions'; - attributes: { - name: string; - }; - }[]; +import { ResponseJsonApi } from '../common'; + +export type RegionsResponseJsonApi = ResponseJsonApi; + +export interface RegionDataJsonApi { + id: string; + type: 'regions'; + attributes: RegionAttributesJsonApi; + links: RegionLinksJsonApi; +} + +export interface RegionAttributesJsonApi { + name: string; +} + +export interface RegionLinksJsonApi { + self: string; } From ca8e4c5d5ef421f3efb5e181f0cbec6dd329c297 Mon Sep 17 00:00:00 2001 From: nsemets Date: Wed, 10 Sep 2025 16:26:28 +0300 Subject: [PATCH 6/7] fix(providers): updated models for providers --- src/app/core/constants/nav-items.constant.ts | 6 +- ...preprint-provider-moderation-info.model.ts | 4 +- .../preprint-related-count-json-api.model.ts | 10 +-- .../registry-provider-hero.component.scss | 4 +- .../registry-services.component.html | 4 +- .../registries/mappers/providers.mapper.ts | 5 +- .../registry-provider-json-api.model.ts | 7 +- .../models/registry-provider.model.ts | 2 + .../registries-landing.component.ts | 21 ++---- .../registries-provider-search.component.ts | 17 +++-- src/app/features/registries/services/index.ts | 1 - .../registries/services/projects.service.ts | 28 ------- .../services/registration-files.service.ts | 12 --- .../registries/services/registries.service.ts | 5 +- .../registries/store/default.state.ts | 73 ------------------- .../store/handlers/projects.handlers.ts | 7 +- .../store/handlers/providers.handlers.ts | 7 +- .../registries-provider-search.state.ts | 3 +- .../registries/store/registries.model.ts | 72 ++++++++++++++++++ .../registries/store/registries.state.ts | 7 +- .../provider/base-provider-json-api.model.ts | 19 +++++ src/app/shared/models/provider/index.ts | 3 + .../preprints-provider-json-api.model.ts | 17 +++++ .../registration-provider-json-api.model.ts | 16 ++++ 24 files changed, 175 insertions(+), 175 deletions(-) delete mode 100644 src/app/features/registries/services/projects.service.ts delete mode 100644 src/app/features/registries/services/registration-files.service.ts delete mode 100644 src/app/features/registries/store/default.state.ts create mode 100644 src/app/shared/models/provider/base-provider-json-api.model.ts create mode 100644 src/app/shared/models/provider/preprints-provider-json-api.model.ts create mode 100644 src/app/shared/models/provider/registration-provider-json-api.model.ts diff --git a/src/app/core/constants/nav-items.constant.ts b/src/app/core/constants/nav-items.constant.ts index 0ce0a1e9c..32d862a4d 100644 --- a/src/app/core/constants/nav-items.constant.ts +++ b/src/app/core/constants/nav-items.constant.ts @@ -261,14 +261,14 @@ export const MENU_ITEMS: MenuItem[] = [ routerLink: '/registries/discover', label: 'navigation.discover', visible: true, - routerLinkActiveOptions: { exact: true }, + routerLinkActiveOptions: { exact: false }, }, { id: 'registries-moderation', - routerLink: '/registries/osf/moderation', + routerLink: '/registries', label: 'navigation.moderation', visible: false, - routerLinkActiveOptions: { exact: true }, + routerLinkActiveOptions: { exact: false }, }, { id: 'registry-details', diff --git a/src/app/features/moderation/models/preprint-provider-moderation-info.model.ts b/src/app/features/moderation/models/preprint-provider-moderation-info.model.ts index 62ea85ef4..af069ba44 100644 --- a/src/app/features/moderation/models/preprint-provider-moderation-info.model.ts +++ b/src/app/features/moderation/models/preprint-provider-moderation-info.model.ts @@ -4,6 +4,6 @@ export interface PreprintProviderModerationInfo { submissionCount?: number; reviewsCommentsAnonymous: boolean; reviewsCommentsPrivate: boolean; - reviewsWorkflow: boolean; - supportEmail?: string; + reviewsWorkflow: string; + supportEmail: string | null; } diff --git a/src/app/features/moderation/models/preprint-related-count-json-api.model.ts b/src/app/features/moderation/models/preprint-related-count-json-api.model.ts index e288a496b..9524c1bfd 100644 --- a/src/app/features/moderation/models/preprint-related-count-json-api.model.ts +++ b/src/app/features/moderation/models/preprint-related-count-json-api.model.ts @@ -1,12 +1,8 @@ +import { PreprintProviderAttributesJsonApi } from '@osf/shared/models'; + export interface PreprintRelatedCountJsonApi { id: string; - attributes: { - name: string; - reviews_comments_anonymous: boolean; - reviews_comments_private: boolean; - reviews_workflow: boolean; - email_support?: string; - }; + attributes: PreprintProviderAttributesJsonApi; relationships: { preprints: { links: { diff --git a/src/app/features/registries/components/registry-provider-hero/registry-provider-hero.component.scss b/src/app/features/registries/components/registry-provider-hero/registry-provider-hero.component.scss index 96a95bbdd..e84a2dfaf 100644 --- a/src/app/features/registries/components/registry-provider-hero/registry-provider-hero.component.scss +++ b/src/app/features/registries/components/registry-provider-hero/registry-provider-hero.component.scss @@ -1,10 +1,8 @@ -@use "styles/mixins" as mix; - .registries-hero-container { background-image: var(--branding-hero-background-image-url); color: var(--white); .provider-description { - line-height: mix.rem(24px); + line-height: 1.5rem; } } diff --git a/src/app/features/registries/components/registry-services/registry-services.component.html b/src/app/features/registries/components/registry-services/registry-services.component.html index 832caae5d..5c94dde52 100644 --- a/src/app/features/registries/components/registry-services/registry-services.component.html +++ b/src/app/features/registries/components/registry-services/registry-services.component.html @@ -7,7 +7,7 @@

{{ 'registries.services.title' | translate }} @for (registryService of registryServices; track $index) { {{ 'registries.services.title' | translate }} diff --git a/src/app/features/registries/mappers/providers.mapper.ts b/src/app/features/registries/mappers/providers.mapper.ts index 46139e7b6..593984a46 100644 --- a/src/app/features/registries/mappers/providers.mapper.ts +++ b/src/app/features/registries/mappers/providers.mapper.ts @@ -1,8 +1,6 @@ -import { RegistryProviderDetails } from '@osf/features/registries/models/registry-provider.model'; -import { RegistryProviderDetailsJsonApi } from '@osf/features/registries/models/registry-provider-json-api.model'; import { ProvidersResponseJsonApi } from '@osf/shared/models'; -import { ProviderSchema } from '../models'; +import { ProviderSchema, RegistryProviderDetails, RegistryProviderDetailsJsonApi } from '../models'; export class ProvidersMapper { static fromProvidersResponse(response: ProvidersResponseJsonApi): ProviderSchema[] { @@ -18,6 +16,7 @@ export class ProvidersMapper { id: response.id, name: response.attributes.name, descriptionHtml: response.attributes.description, + permissions: response.attributes.permissions, brand: { id: brandRaw.id, name: brandRaw.attributes.name, diff --git a/src/app/features/registries/models/registry-provider-json-api.model.ts b/src/app/features/registries/models/registry-provider-json-api.model.ts index d74327e65..e0e451f9d 100644 --- a/src/app/features/registries/models/registry-provider-json-api.model.ts +++ b/src/app/features/registries/models/registry-provider-json-api.model.ts @@ -1,12 +1,9 @@ -import { BrandDataJsonApi } from '@shared/models'; +import { BrandDataJsonApi, RegistrationProviderAttributesJsonApi } from '@shared/models'; export interface RegistryProviderDetailsJsonApi { id: string; type: 'registration-providers'; - attributes: { - name: string; - description: string; - }; + attributes: RegistrationProviderAttributesJsonApi; embeds?: { brand: { data: BrandDataJsonApi; diff --git a/src/app/features/registries/models/registry-provider.model.ts b/src/app/features/registries/models/registry-provider.model.ts index 6d6673440..132be2d27 100644 --- a/src/app/features/registries/models/registry-provider.model.ts +++ b/src/app/features/registries/models/registry-provider.model.ts @@ -1,9 +1,11 @@ +import { ReviewPermissions } from '@osf/shared/enums'; import { Brand } from '@shared/models'; export interface RegistryProviderDetails { id: string; name: string; descriptionHtml: string; + permissions: ReviewPermissions[]; brand: Brand; iri: string; } diff --git a/src/app/features/registries/pages/registries-landing/registries-landing.component.ts b/src/app/features/registries/pages/registries-landing/registries-landing.component.ts index 9e79c0402..f446f4c94 100644 --- a/src/app/features/registries/pages/registries-landing/registries-landing.component.ts +++ b/src/app/features/registries/pages/registries-landing/registries-landing.component.ts @@ -8,15 +8,16 @@ import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/cor import { FormControl } from '@angular/forms'; import { Router } from '@angular/router'; -import { RegistryServicesComponent } from '@osf/features/registries/components'; -import { GetRegistries, RegistriesSelectors } from '@osf/features/registries/store'; import { LoadingSpinnerComponent, ResourceCardComponent, SearchInputComponent, SubHeaderComponent, -} from '@shared/components'; -import { ResourceType } from '@shared/enums'; +} from '@osf/shared/components'; +import { ResourceType } from '@osf/shared/enums'; + +import { RegistryServicesComponent } from '../../components'; +import { GetRegistries, RegistriesSelectors } from '../../store'; import { environment } from 'src/environments/environment'; @@ -40,9 +41,7 @@ export class RegistriesLandingComponent implements OnInit { searchControl = new FormControl(''); - private readonly actions = createDispatchMap({ - getRegistries: GetRegistries, - }); + private readonly actions = createDispatchMap({ getRegistries: GetRegistries }); registries = select(RegistriesSelectors.getRegistries); isRegistriesLoading = select(RegistriesSelectors.isRegistriesLoading); @@ -54,15 +53,11 @@ export class RegistriesLandingComponent implements OnInit { redirectToSearchPageWithValue(): void { const searchValue = this.searchControl.value; - this.router.navigate(['/search'], { - queryParams: { search: searchValue, tab: ResourceType.Registration }, - }); + this.router.navigate(['/search'], { queryParams: { search: searchValue, tab: ResourceType.Registration } }); } redirectToSearchPageRegistrations(): void { - this.router.navigate(['/search'], { - queryParams: { tab: ResourceType.Registration }, - }); + this.router.navigate(['/search'], { queryParams: { tab: ResourceType.Registration } }); } goToCreateRegistration(): void { diff --git a/src/app/features/registries/pages/registries-provider-search/registries-provider-search.component.ts b/src/app/features/registries/pages/registries-provider-search/registries-provider-search.component.ts index 3496032cb..dc80f2be6 100644 --- a/src/app/features/registries/pages/registries-provider-search/registries-provider-search.component.ts +++ b/src/app/features/registries/pages/registries-provider-search/registries-provider-search.component.ts @@ -6,14 +6,13 @@ import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/cor import { FormControl } from '@angular/forms'; import { ActivatedRoute } from '@angular/router'; -import { RegistryProviderHeroComponent } from '@osf/features/registries/components/registry-provider-hero/registry-provider-hero.component'; -import { - GetRegistryProviderBrand, - RegistriesProviderSearchSelectors, -} from '@osf/features/registries/store/registries-provider-search'; -import { GlobalSearchComponent } from '@shared/components'; -import { ResourceType } from '@shared/enums'; -import { SetDefaultFilterValue, SetResourceType } from '@shared/stores/global-search'; +import { SetCurrentProvider } from '@core/store/provider'; +import { GlobalSearchComponent } from '@osf/shared/components'; +import { ResourceType } from '@osf/shared/enums'; +import { SetDefaultFilterValue, SetResourceType } from '@osf/shared/stores/global-search'; + +import { RegistryProviderHeroComponent } from '../../components/registry-provider-hero/registry-provider-hero.component'; +import { GetRegistryProviderBrand, RegistriesProviderSearchSelectors } from '../../store/registries-provider-search'; @Component({ selector: 'osf-registries-provider-search', @@ -30,6 +29,7 @@ export class RegistriesProviderSearchComponent implements OnInit { getProvider: GetRegistryProviderBrand, setDefaultFilterValue: SetDefaultFilterValue, setResourceType: SetResourceType, + setCurrentProvider: SetCurrentProvider, }); provider = select(RegistriesProviderSearchSelectors.getBrandedProvider); @@ -44,6 +44,7 @@ export class RegistriesProviderSearchComponent implements OnInit { next: () => { this.actions.setDefaultFilterValue('publisher', this.provider()!.iri!); this.actions.setResourceType(ResourceType.Registration); + this.actions.setCurrentProvider(this.provider()!); }, }); } diff --git a/src/app/features/registries/services/index.ts b/src/app/features/registries/services/index.ts index 3aed2743d..66cd5ab89 100644 --- a/src/app/features/registries/services/index.ts +++ b/src/app/features/registries/services/index.ts @@ -1,4 +1,3 @@ export * from './licenses.service'; export * from './providers.service'; -export * from './registration-files.service'; export * from './registries.service'; diff --git a/src/app/features/registries/services/projects.service.ts b/src/app/features/registries/services/projects.service.ts deleted file mode 100644 index f33232e1f..000000000 --- a/src/app/features/registries/services/projects.service.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { map, Observable } from 'rxjs'; - -import { inject, Injectable } from '@angular/core'; - -import { ProjectsMapper } from '@osf/shared/mappers/projects'; -import { ProjectsResponseJsonApi } from '@osf/shared/models/projects'; -import { JsonApiService } from '@osf/shared/services'; - -import { Project } from '../models'; - -import { environment } from 'src/environments/environment'; - -@Injectable({ - providedIn: 'root', -}) -export class ProjectsService { - private readonly jsonApiService = inject(JsonApiService); - private readonly apiUrl = `${environment.apiDomainUrl}/v2`; - - getProjects(): Observable { - const params: Record = { - 'filter[current_user_permissions]': 'admin', - }; - return this.jsonApiService - .get(`${this.apiUrl}/users/me/nodes/`, params) - .pipe(map((response) => ProjectsMapper.fromGetAllProjectsResponse(response))); - } -} diff --git a/src/app/features/registries/services/registration-files.service.ts b/src/app/features/registries/services/registration-files.service.ts deleted file mode 100644 index 85866e099..000000000 --- a/src/app/features/registries/services/registration-files.service.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { inject, Injectable } from '@angular/core'; - -import { FilesService } from '@osf/shared/services'; -import { JsonApiService } from '@shared/services'; - -@Injectable({ - providedIn: 'root', -}) -export class RegistrationFilesService { - private filesService = inject(FilesService); - private jsonApiService = inject(JsonApiService); -} diff --git a/src/app/features/registries/services/registries.service.ts b/src/app/features/registries/services/registries.service.ts index 1cbff264e..52653f7f2 100644 --- a/src/app/features/registries/services/registries.service.ts +++ b/src/app/features/registries/services/registries.service.ts @@ -9,6 +9,7 @@ import { DraftRegistrationRelationshipsJsonApi, DraftRegistrationResponseJsonApi, PageSchema, + PaginatedData, RegistrationAttributesJsonApi, RegistrationCard, RegistrationDataJsonApi, @@ -90,7 +91,7 @@ export class RegistriesService { id, attributes, relationships, - type: 'draft_registrations', // force the correct type + type: 'draft_registrations', }, }; const params = { @@ -125,7 +126,7 @@ export class RegistriesService { .pipe(map((response) => PageSchemaMapper.fromSchemaBlocksResponse(response))); } - getDraftRegistrations(page: number, pageSize: number): Observable<{ data: RegistrationCard[]; totalCount: number }> { + getDraftRegistrations(page: number, pageSize: number): Observable> { const params = { page, 'page[size]': pageSize, diff --git a/src/app/features/registries/store/default.state.ts b/src/app/features/registries/store/default.state.ts deleted file mode 100644 index d2a0e0c42..000000000 --- a/src/app/features/registries/store/default.state.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { RegistriesStateModel } from './registries.model'; - -export const DefaultState: RegistriesStateModel = { - providerSchemas: { - data: [], - isLoading: false, - error: null, - }, - projects: { - data: [], - isLoading: false, - error: null, - }, - draftRegistration: { - isLoading: false, - data: null, - isSubmitting: false, - error: null, - }, - registries: { - data: [], - isLoading: false, - error: null, - }, - licenses: { - data: [], - isLoading: false, - error: null, - }, - pagesSchema: { - data: [], - isLoading: false, - error: null, - }, - stepsValidation: {}, - registration: { - data: null, - isLoading: false, - isSubmitting: false, - error: null, - }, - draftRegistrations: { - data: [], - isLoading: false, - error: null, - totalCount: 0, - }, - submittedRegistrations: { - data: [], - isLoading: false, - error: null, - totalCount: 0, - }, - files: { - data: [], - isLoading: false, - error: null, - totalCount: 0, - }, - currentFolder: null, - moveFileCurrentFolder: null, - rootFolders: { - data: null, - isLoading: false, - error: null, - }, - schemaResponse: { - data: null, - isLoading: false, - error: null, - }, - updatedFields: {}, -}; diff --git a/src/app/features/registries/store/handlers/projects.handlers.ts b/src/app/features/registries/store/handlers/projects.handlers.ts index ba013df93..612749344 100644 --- a/src/app/features/registries/store/handlers/projects.handlers.ts +++ b/src/app/features/registries/store/handlers/projects.handlers.ts @@ -5,8 +5,7 @@ import { inject, Injectable } from '@angular/core'; import { ProjectsService } from '@osf/shared/services/projects.service'; import { Project } from '../../models'; -import { DefaultState } from '../default.state'; -import { RegistriesStateModel } from '../registries.model'; +import { REGISTRIES_STATE_DEFAULTS, RegistriesStateModel } from '../registries.model'; @Injectable() export class ProjectsHandlers { @@ -20,7 +19,7 @@ export class ProjectsHandlers { patchState({ projects: { - ...DefaultState.projects, + ...REGISTRIES_STATE_DEFAULTS.projects, isLoading: true, }, }); @@ -36,7 +35,7 @@ export class ProjectsHandlers { }, error: (error) => { patchState({ - projects: { ...DefaultState.projects, isLoading: false, error }, + projects: { ...REGISTRIES_STATE_DEFAULTS.projects, isLoading: false, error }, }); }, }); diff --git a/src/app/features/registries/store/handlers/providers.handlers.ts b/src/app/features/registries/store/handlers/providers.handlers.ts index 8b68e2a05..3e0a513e8 100644 --- a/src/app/features/registries/store/handlers/providers.handlers.ts +++ b/src/app/features/registries/store/handlers/providers.handlers.ts @@ -3,8 +3,7 @@ import { StateContext } from '@ngxs/store'; import { inject, Injectable } from '@angular/core'; import { ProvidersService } from '../../services'; -import { DefaultState } from '../default.state'; -import { RegistriesStateModel } from '../registries.model'; +import { REGISTRIES_STATE_DEFAULTS, RegistriesStateModel } from '../registries.model'; @Injectable() export class ProvidersHandlers { @@ -13,7 +12,7 @@ export class ProvidersHandlers { getProviderSchemas({ patchState }: StateContext, providerId: string) { patchState({ providerSchemas: { - ...DefaultState.providerSchemas, + ...REGISTRIES_STATE_DEFAULTS.providerSchemas, isLoading: true, }, }); @@ -30,7 +29,7 @@ export class ProvidersHandlers { error: (error) => { patchState({ providerSchemas: { - ...DefaultState.providerSchemas, + ...REGISTRIES_STATE_DEFAULTS.providerSchemas, isLoading: false, error, }, diff --git a/src/app/features/registries/store/registries-provider-search/registries-provider-search.state.ts b/src/app/features/registries/store/registries-provider-search/registries-provider-search.state.ts index fd72025f3..14af12034 100644 --- a/src/app/features/registries/store/registries-provider-search/registries-provider-search.state.ts +++ b/src/app/features/registries/store/registries-provider-search/registries-provider-search.state.ts @@ -5,9 +5,10 @@ import { catchError, tap } from 'rxjs'; import { inject, Injectable } from '@angular/core'; -import { ProvidersService } from '@osf/features/registries/services'; import { handleSectionError } from '@shared/helpers'; +import { ProvidersService } from '../../services'; + import { GetRegistryProviderBrand } from './registries-provider-search.actions'; import { REGISTRIES_PROVIDER_SEARCH_STATE_DEFAULTS, diff --git a/src/app/features/registries/store/registries.model.ts b/src/app/features/registries/store/registries.model.ts index 4ebee0edb..7c6f5e421 100644 --- a/src/app/features/registries/store/registries.model.ts +++ b/src/app/features/registries/store/registries.model.ts @@ -31,3 +31,75 @@ export interface RegistriesStateModel { schemaResponse: AsyncStateModel; updatedFields: Record; } + +export const REGISTRIES_STATE_DEFAULTS: RegistriesStateModel = { + providerSchemas: { + data: [], + isLoading: false, + error: null, + }, + projects: { + data: [], + isLoading: false, + error: null, + }, + draftRegistration: { + isLoading: false, + data: null, + isSubmitting: false, + error: null, + }, + registries: { + data: [], + isLoading: false, + error: null, + }, + licenses: { + data: [], + isLoading: false, + error: null, + }, + pagesSchema: { + data: [], + isLoading: false, + error: null, + }, + stepsValidation: {}, + registration: { + data: null, + isLoading: false, + isSubmitting: false, + error: null, + }, + draftRegistrations: { + data: [], + isLoading: false, + error: null, + totalCount: 0, + }, + submittedRegistrations: { + data: [], + isLoading: false, + error: null, + totalCount: 0, + }, + files: { + data: [], + isLoading: false, + error: null, + totalCount: 0, + }, + currentFolder: null, + moveFileCurrentFolder: null, + rootFolders: { + data: null, + isLoading: false, + error: null, + }, + schemaResponse: { + data: null, + isLoading: false, + error: null, + }, + updatedFields: {}, +}; diff --git a/src/app/features/registries/store/registries.state.ts b/src/app/features/registries/store/registries.state.ts index eeb5f0982..e0d11a646 100644 --- a/src/app/features/registries/store/registries.state.ts +++ b/src/app/features/registries/store/registries.state.ts @@ -14,7 +14,6 @@ import { FilesHandlers } from './handlers/files.handlers'; import { LicensesHandlers } from './handlers/licenses.handlers'; import { ProjectsHandlers } from './handlers/projects.handlers'; import { ProvidersHandlers } from './handlers/providers.handlers'; -import { DefaultState } from './default.state'; import { ClearState, CreateDraft, @@ -45,13 +44,13 @@ import { UpdateSchemaResponse, UpdateStepValidation, } from './registries.actions'; -import { RegistriesStateModel } from './registries.model'; +import { REGISTRIES_STATE_DEFAULTS, RegistriesStateModel } from './registries.model'; import { environment } from 'src/environments/environment'; @State({ name: 'registries', - defaults: { ...DefaultState }, + defaults: REGISTRIES_STATE_DEFAULTS, }) @Injectable() export class RegistriesState { @@ -339,7 +338,7 @@ export class RegistriesState { @Action(ClearState) clearState(ctx: StateContext) { - ctx.setState({ ...DefaultState }); + ctx.setState(REGISTRIES_STATE_DEFAULTS); } @Action(GetFiles) diff --git a/src/app/shared/models/provider/base-provider-json-api.model.ts b/src/app/shared/models/provider/base-provider-json-api.model.ts new file mode 100644 index 000000000..74ce19065 --- /dev/null +++ b/src/app/shared/models/provider/base-provider-json-api.model.ts @@ -0,0 +1,19 @@ +import { ReviewPermissions } from '@osf/shared/enums'; + +export interface BaseProviderAttributesJsonApi { + name: string; + description: string; + advisory_board: string; + example: string | null; + domain: string; + domain_redirect_enabled: boolean; + footer_links: string; + email_support: string | null; + facebook_app_id: string | null; + allow_submissions: boolean; + allow_commenting: boolean; + share_source: string; + share_publish_type: string; + permissions: ReviewPermissions[]; + reviews_workflow: string; +} diff --git a/src/app/shared/models/provider/index.ts b/src/app/shared/models/provider/index.ts index d98dc5cfd..7750fce62 100644 --- a/src/app/shared/models/provider/index.ts +++ b/src/app/shared/models/provider/index.ts @@ -1,2 +1,5 @@ +export * from './base-provider-json-api.model'; +export * from './preprints-provider-json-api.model'; export * from './provider.model'; export * from './providers-json-api.model'; +export * from './registration-provider-json-api.model'; diff --git a/src/app/shared/models/provider/preprints-provider-json-api.model.ts b/src/app/shared/models/provider/preprints-provider-json-api.model.ts new file mode 100644 index 000000000..4bd8d70a2 --- /dev/null +++ b/src/app/shared/models/provider/preprints-provider-json-api.model.ts @@ -0,0 +1,17 @@ +import { BaseProviderAttributesJsonApi } from './base-provider-json-api.model'; + +export interface PreprintProviderAttributesJsonApi extends BaseProviderAttributesJsonApi { + assets: PreprintProviderAssetsJsonApi; + preprint_word: string; + additional_providers: string[]; + assertions_enabled: boolean; + advertise_on_discover_page: boolean; + reviews_comments_private: boolean; + reviews_comments_anonymous: boolean; +} + +export interface PreprintProviderAssetsJsonApi { + favicon: string; + wide_white: string; + square_color_no_transparent: string; +} diff --git a/src/app/shared/models/provider/registration-provider-json-api.model.ts b/src/app/shared/models/provider/registration-provider-json-api.model.ts new file mode 100644 index 000000000..9d865b1dc --- /dev/null +++ b/src/app/shared/models/provider/registration-provider-json-api.model.ts @@ -0,0 +1,16 @@ +import { BaseProviderAttributesJsonApi } from './base-provider-json-api.model'; + +export interface RegistrationProviderAttributesJsonApi extends BaseProviderAttributesJsonApi { + assets: RegistrationAssetsJsonApi; + branded_discovery_page: boolean; + reviews_comments_anonymous: boolean | null; + allow_updates: boolean; + allow_bulk_uploads: boolean; + registration_word: string; +} + +export interface RegistrationAssetsJsonApi { + square_color_no_transparent: string; + square_color_transparent: string; + wide_color: string; +} From 207a64af05edca713981e4758950ef54ea44d1d9 Mon Sep 17 00:00:00 2001 From: nsemets Date: Wed, 10 Sep 2025 16:45:30 +0300 Subject: [PATCH 7/7] fix(test): fixed unit test --- .../add-project-form.component.spec.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/shared/components/add-project-form/add-project-form.component.spec.ts b/src/app/shared/components/add-project-form/add-project-form.component.spec.ts index ae7baf785..d9ab2dc53 100644 --- a/src/app/shared/components/add-project-form/add-project-form.component.spec.ts +++ b/src/app/shared/components/add-project-form/add-project-form.component.spec.ts @@ -7,12 +7,15 @@ import { DynamicDialogRef } from 'primeng/dynamicdialog'; import { provideHttpClient } from '@angular/common/http'; import { provideHttpClientTesting } from '@angular/common/http/testing'; +import { signal } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { UserSelectors, UserState } from '@core/store/user'; import { MY_PROJECTS_TABLE_PARAMS } from '@osf/shared/constants/my-projects-table.constants'; import { ProjectFormControls } from '@osf/shared/enums/create-project-form-controls.enum'; import { CustomValidators } from '@osf/shared/helpers'; +import { MOCK_STORE, MOCK_USER } from '@osf/shared/mocks'; import { ProjectForm } from '@osf/shared/models'; import { Project } from '@osf/shared/models/projects'; import { GetMyProjects, MyResourcesState } from '@osf/shared/stores'; @@ -66,6 +69,11 @@ describe('AddProjectFormComponent', () => { }); beforeEach(async () => { + MOCK_STORE.selectSignal.mockImplementation((selector) => { + if (selector === UserSelectors.getCurrentUser) return () => signal(MOCK_USER); + return () => null; + }); + await TestBed.configureTestingModule({ imports: [ AddProjectFormComponent, @@ -73,11 +81,12 @@ describe('AddProjectFormComponent', () => { MockComponents(ProjectSelectorComponent, AffiliatedInstitutionSelectComponent), ], providers: [ - provideStore([MyResourcesState, InstitutionsState, RegionsState]), + provideStore([MyResourcesState, InstitutionsState, RegionsState, UserState]), provideHttpClient(), provideHttpClientTesting(), MockProvider(DynamicDialogRef, { close: jest.fn() }), MockProvider(TranslateService), + MockProvider(Store, MOCK_STORE), ], }).compileComponents();