Skip to content

Commit 4bea808

Browse files
authored
[ENG-9198] redirect to info page if preprint is undermoderation and is accessed by not contributor (#835)
- Ticket: https://openscience.atlassian.net/browse/ENG-9198 - Feature flag: n/a ## Purpose Angular FE should not show page not found for preprint that’s pending moderation. ## Summary of Changes Implementing redirection mechanics if 'This preprint is pending moderation and is not yet publicly available.' for not contributor user
1 parent 0447ae9 commit 4bea808

File tree

7 files changed

+72
-0
lines changed

7 files changed

+72
-0
lines changed

src/app/app.routes.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ export const routes: Routes = [
156156
import('./core/components/forbidden-page/forbidden-page.component').then((mod) => mod.ForbiddenPageComponent),
157157
data: { skipBreadcrumbs: true },
158158
},
159+
{
160+
path: 'preprints/:providerId/:id/pending-moderation',
161+
loadComponent: () =>
162+
import(
163+
'@osf/features/preprints/pages/preprint-pending-moderation/preprint-pending-moderation.component'
164+
).then((mod) => mod.PreprintPendingModerationComponent),
165+
},
159166
{
160167
path: 'request-access/:id',
161168
loadComponent: () =>

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,15 @@ export class PreprintDetailsComponent implements OnInit, OnDestroy {
383383
}
384384
}
385385
},
386+
error: (error) => {
387+
if (
388+
error instanceof HttpErrorResponse &&
389+
error.status === 403 &&
390+
error?.error?.errors[0]?.detail === 'This preprint is pending moderation and is not yet publicly available.'
391+
) {
392+
this.router.navigate(['/preprints', this.providerId(), preprintId, 'pending-moderation']);
393+
}
394+
},
386395
});
387396
}
388397

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<section class="container text-center flex flex-column flex-1 my-7 mx-3 p-3 md:p-4">
2+
<h2>{{ 'preprints.details.moderationStatusBanner.pendingDetails.title' | translate }}</h2>
3+
<p class="mt-4">{{ 'preprints.details.moderationStatusBanner.pendingDetails.body' | translate }}</p>
4+
</section>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@use "styles/mixins" as mix;
2+
3+
:host {
4+
@include mix.flex-center;
5+
flex: 1;
6+
background: var(--gradient-3);
7+
}
8+
9+
.container {
10+
max-width: mix.rem(448px);
11+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { PreprintPendingModerationComponent } from './preprint-pending-moderation.component';
4+
5+
import { OSFTestingModule } from '@testing/osf.testing.module';
6+
7+
describe('PreprintPendingModerationComponent', () => {
8+
let component: PreprintPendingModerationComponent;
9+
let fixture: ComponentFixture<PreprintPendingModerationComponent>;
10+
11+
beforeEach(async () => {
12+
await TestBed.configureTestingModule({
13+
imports: [PreprintPendingModerationComponent, OSFTestingModule],
14+
}).compileComponents();
15+
16+
fixture = TestBed.createComponent(PreprintPendingModerationComponent);
17+
component = fixture.componentInstance;
18+
fixture.detectChanges();
19+
});
20+
21+
it('should create', () => {
22+
expect(component).toBeTruthy();
23+
});
24+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { TranslatePipe } from '@ngx-translate/core';
2+
3+
import { ChangeDetectionStrategy, Component } from '@angular/core';
4+
5+
@Component({
6+
selector: 'osf-preprint-pending-moderation',
7+
templateUrl: './preprint-pending-moderation.component.html',
8+
styleUrl: './preprint-pending-moderation.component.scss',
9+
changeDetection: ChangeDetectionStrategy.OnPush,
10+
imports: [TranslatePipe],
11+
})
12+
export class PreprintPendingModerationComponent {}

src/assets/i18n/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,7 @@
21162116
"poweredBy": "Powered by OSF Preprints",
21172117
"searchPlaceholder": "Search {{preprintWord}}...",
21182118
"showExample": "Show an example",
2119+
21192120
"browseBySubjects": {
21202121
"title": "Browse By Subjects"
21212122
},
@@ -2401,6 +2402,10 @@
24012402
"noModerationNotice": "<strong>{{pluralCapitalizedPreprintWord}} are a permanent part of the scholarly record. Withdrawal requests are subject to this service’s policy on {{singularPreprintWord}} version removal and at the discretion of the moderators.</strong><br>This request will be submitted to <a href=\"mailto:{{supportEmail}}\" target=\"_blank\">{{supportEmail}}</a> for review and removal. If the request is approved, this {{singularPreprintWord}} version will be replaced by a tombstone page with metadata and the reason for withdrawal. This {{singularPreprintWord}} version will still be searchable by other users after removal."
24022403
},
24032404
"moderationStatusBanner": {
2405+
"pendingDetails": {
2406+
"title": "This Preprint Is Pending Moderation At OSF Preprints",
2407+
"body": "This preprint was submitted for review. It won't be available until it is accepted by the provider. Please check back later."
2408+
},
24042409
"recentActivity": {
24052410
"pending": "submitted this {{documentType}} on",
24062411
"accepted": "accepted this {{documentType}} on",

0 commit comments

Comments
 (0)