-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
30 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"noPermissionTitle": { | ||
"message": "You do not have permission to view this page" | ||
}, | ||
"shouldHaveAccess": { | ||
"message": "If you think you should have access, please <contact>get in touch</contact>." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,23 @@ | ||
import { StatusCodes } from 'http-status-codes' | ||
import { html, plainText } from '../html.js' | ||
import { html, plainText, rawHtml } from '../html.js' | ||
import { type SupportedLocale, translate } from '../locales/index.js' | ||
import { PageResponse } from '../response.js' | ||
|
||
export const createNoPermissionPage = (): PageResponse => | ||
export const createNoPermissionPage = (locale: SupportedLocale): PageResponse => | ||
PageResponse({ | ||
status: StatusCodes.FORBIDDEN, | ||
title: plainText`You do not have permission to view this page`, | ||
title: plainText(translate(locale, 'no-permission-page', 'noPermissionTitle')()), | ||
main: html` | ||
<h1>You do not have permission to view this page</h1> | ||
<h1>${translate(locale, 'no-permission-page', 'noPermissionTitle')()}</h1> | ||
<p>If you think you should have access, please <a href="mailto:help@prereview.org">get in touch</a>.</p> | ||
<p> | ||
${rawHtml( | ||
translate( | ||
locale, | ||
'no-permission-page', | ||
'shouldHaveAccess', | ||
)({ contact: text => html`<a href="mailto:help@prereview.org">${text}</a>`.toString() }), | ||
)} | ||
</p> | ||
`, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import { Effect } from 'effect' | ||
import { Locale } from '../Context.js' | ||
import type { PageResponse } from '../response.js' | ||
import { createNoPermissionPage } from './NoPermissionPage.js' | ||
|
||
export const NoPermissionPage: Effect.Effect<PageResponse> = Effect.sync(createNoPermissionPage) | ||
export const NoPermissionPage: Effect.Effect<PageResponse, never, Locale> = Effect.andThen( | ||
Locale, | ||
createNoPermissionPage, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { DefaultLocale } from '../../src/locales/index.js' | ||
import { createNoPermissionPage } from '../../src/NoPermissionPage/NoPermissionPage.js' | ||
import { expect, test } from '../base.js' | ||
|
||
test('content looks right', async ({ showPage }) => { | ||
const content = await showPage(createNoPermissionPage()) | ||
const content = await showPage(createNoPermissionPage(DefaultLocale)) | ||
|
||
await expect(content).toHaveScreenshot() | ||
}) |