From 5526fc1aa47279c1dccbff7137c1fe14841ff63f Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Mon, 25 Aug 2025 14:04:08 -0400 Subject: [PATCH 1/3] feat(preprint): add preprint warning banner --- ...osf-preprint-warning-banner.component.html | 8 ++++++++ ...osf-preprint-warning-banner.component.scss | 4 ++++ .../osf-preprint-warning-banner.component.ts | 19 +++++++++++++++++++ .../preprint-details.component.html | 3 +++ .../preprint-details.component.ts | 7 +++++++ src/assets/i18n/en.json | 1 + 6 files changed, 42 insertions(+) create mode 100644 src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.html create mode 100644 src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss create mode 100644 src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts diff --git a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.html b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.html new file mode 100644 index 000000000..0d791843e --- /dev/null +++ b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss new file mode 100644 index 000000000..aa013c425 --- /dev/null +++ b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss @@ -0,0 +1,4 @@ +.banner-container { + --p-button-padding-y: 0; + --p-button-padding-x: 0; +} diff --git a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts new file mode 100644 index 000000000..fddb8a68a --- /dev/null +++ b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts @@ -0,0 +1,19 @@ +import { TranslatePipe } from '@ngx-translate/core'; + +import { Message } from 'primeng/message'; + +// import { TitleCasePipe } from '@angular/common'; +import { ChangeDetectionStrategy, Component } from '@angular/core'; + +import { IconComponent } from '@shared/components'; + +@Component({ + selector: 'osf-preprint-warning-banner', + imports: [TranslatePipe, Message, IconComponent], + templateUrl: './osf-preprint-warning-banner.component.html', + styleUrl: './osf-preprint-warning-banner.component.scss', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class OsfPreprintWarningBannerComponent { + // +} diff --git a/src/app/features/preprints/pages/preprint-details/preprint-details.component.html b/src/app/features/preprints/pages/preprint-details/preprint-details.component.html index b135a1a31..0fab57054 100644 --- a/src/app/features/preprints/pages/preprint-details/preprint-details.component.html +++ b/src/app/features/preprints/pages/preprint-details/preprint-details.component.html @@ -46,6 +46,9 @@

{{ preprint()!.title }}

+ @if (isOsfPreprint()) { + + } @if (statusBannerVisible()) { { + return this.providerId() === 'osf'; + }); + statusBannerVisible = computed(() => { const provider = this.preprintProvider(); const preprint = this.preprint(); diff --git a/src/assets/i18n/en.json b/src/assets/i18n/en.json index c5b082c64..b7e06d988 100644 --- a/src/assets/i18n/en.json +++ b/src/assets/i18n/en.json @@ -2069,6 +2069,7 @@ "moderatorFeedback": "Moderator Feedback", "showModeratorFeedback": "Show moderator feedback" }, + "warningBanner": "OSF preprints are not peer reviewed and acceptance into OSF preprints is not an indicator of scholarly merit.", "withdrawDialog": { "title": "Withdraw {{preprintWord}}", "withdrawalExplanation": "You are about to withdraw this version of your {{singularPreprintWord}}. Withdrawing a version will remove it from public view but will not affect other versions of this {{singularPreprintWord}}, if available.", From 9a51c375741ac779618eab010cb4c3e6d757cf5a Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Mon, 25 Aug 2025 14:21:36 -0400 Subject: [PATCH 2/3] feat(preprint): remove unused styles --- .../osf-preprint-warning-banner.component.scss | 4 ---- .../osf-preprint-warning-banner.component.ts | 1 - 2 files changed, 5 deletions(-) diff --git a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss index aa013c425..e69de29bb 100644 --- a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss +++ b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss @@ -1,4 +0,0 @@ -.banner-container { - --p-button-padding-y: 0; - --p-button-padding-x: 0; -} diff --git a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts index fddb8a68a..a04726e0a 100644 --- a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts +++ b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts @@ -2,7 +2,6 @@ import { TranslatePipe } from '@ngx-translate/core'; import { Message } from 'primeng/message'; -// import { TitleCasePipe } from '@angular/common'; import { ChangeDetectionStrategy, Component } from '@angular/core'; import { IconComponent } from '@shared/components'; From 3214ed81c0321d9db768fbd8fc59646c4baddb24 Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Tue, 26 Aug 2025 11:54:33 -0400 Subject: [PATCH 3/3] feat(preprint): CR followup --- ...osf-preprint-warning-banner.component.html | 8 ----- ...osf-preprint-warning-banner.component.scss | 0 .../preprint-warning-banner.component.html | 3 ++ .../preprint-warning-banner.component.spec.ts | 36 +++++++++++++++++++ .../preprint-warning-banner.component.ts} | 9 ++--- .../preprint-details.component.spec.ts | 4 +++ .../preprint-details.component.ts | 7 ++-- 7 files changed, 50 insertions(+), 17 deletions(-) delete mode 100644 src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.html delete mode 100644 src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss create mode 100644 src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.html create mode 100644 src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.spec.ts rename src/app/features/preprints/components/preprint-details/{osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts => preprint-warning-banner/preprint-warning-banner.component.ts} (50%) diff --git a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.html b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.html deleted file mode 100644 index 0d791843e..000000000 --- a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - diff --git a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss b/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.html b/src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.html new file mode 100644 index 000000000..b27d02381 --- /dev/null +++ b/src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.html @@ -0,0 +1,3 @@ + + {{ 'preprints.details.warningBanner' | translate }} + diff --git a/src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.spec.ts b/src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.spec.ts new file mode 100644 index 000000000..759457a40 --- /dev/null +++ b/src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.spec.ts @@ -0,0 +1,36 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { provideNoopAnimations } from '@angular/platform-browser/animations'; + +import { PreprintWarningBannerComponent } from './preprint-warning-banner.component'; + +import { OSFTestingModule } from '@testing/osf.testing.module'; + +describe('PreprintWarningBannerComponent', () => { + let component: PreprintWarningBannerComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [PreprintWarningBannerComponent, OSFTestingModule], + providers: [provideNoopAnimations()], + }).compileComponents(); + + fixture = TestBed.createComponent(PreprintWarningBannerComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should show correct icon and text', () => { + const banner: HTMLElement = fixture.nativeElement; + const icon = banner.querySelector('i'); + const text = banner.querySelector('span'); + expect(icon).toBeDefined(); + expect(text).toBeDefined(); + expect(icon?.getAttribute('ng-reflect-ng-class')).toEqual('fas fa-triangle-exclamation'); + expect(text?.textContent?.trim()).toEqual('preprints.details.warningBanner'); + }); +}); diff --git a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts b/src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.ts similarity index 50% rename from src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts rename to src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.ts index a04726e0a..c37710873 100644 --- a/src/app/features/preprints/components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component.ts +++ b/src/app/features/preprints/components/preprint-details/preprint-warning-banner/preprint-warning-banner.component.ts @@ -4,15 +4,12 @@ import { Message } from 'primeng/message'; import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { IconComponent } from '@shared/components'; - @Component({ selector: 'osf-preprint-warning-banner', - imports: [TranslatePipe, Message, IconComponent], - templateUrl: './osf-preprint-warning-banner.component.html', - styleUrl: './osf-preprint-warning-banner.component.scss', + imports: [TranslatePipe, Message], + templateUrl: './preprint-warning-banner.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class OsfPreprintWarningBannerComponent { +export class PreprintWarningBannerComponent { // } diff --git a/src/app/features/preprints/pages/preprint-details/preprint-details.component.spec.ts b/src/app/features/preprints/pages/preprint-details/preprint-details.component.spec.ts index ccfbb8673..bf49a36ec 100644 --- a/src/app/features/preprints/pages/preprint-details/preprint-details.component.spec.ts +++ b/src/app/features/preprints/pages/preprint-details/preprint-details.component.spec.ts @@ -69,4 +69,8 @@ describe.skip('PreprintDetailsComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('isOsfPreprint should be true if providerId === osf', () => { + expect(component.isOsfPreprint()).toBeTruthy(); + }); }); diff --git a/src/app/features/preprints/pages/preprint-details/preprint-details.component.ts b/src/app/features/preprints/pages/preprint-details/preprint-details.component.ts index 6ff3dab74..adc514452 100644 --- a/src/app/features/preprints/pages/preprint-details/preprint-details.component.ts +++ b/src/app/features/preprints/pages/preprint-details/preprint-details.component.ts @@ -49,7 +49,8 @@ import { IS_MEDIUM, pathJoin } from '@osf/shared/helpers'; import { ReviewPermissions, UserPermissions } from '@shared/enums'; import { MetaTagsService } from '@shared/services'; import { ContributorsSelectors } from '@shared/stores'; -import { OsfPreprintWarningBannerComponent } from '../../components/preprint-details/osf-preprint-warning-banner/osf-preprint-warning-banner.component'; + +import { PreprintWarningBannerComponent } from '../../components/preprint-details/preprint-warning-banner/preprint-warning-banner.component'; import { environment } from 'src/environments/environment'; @@ -65,7 +66,7 @@ import { environment } from 'src/environments/environment'; StatusBannerComponent, TranslatePipe, PreprintTombstoneComponent, - OsfPreprintWarningBannerComponent, + PreprintWarningBannerComponent, ModerationStatusBannerComponent, MakeDecisionComponent, ], @@ -239,7 +240,7 @@ export class PreprintDetailsComponent implements OnInit, OnDestroy { isOsfPreprint = computed(() => { return this.providerId() === 'osf'; - }; + }); moderationStatusBannerVisible = computed(() => { return (