@plone/aurora 1.0.0-alpha.26 → 1.0.0-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.json +73 -0
- package/dist/preset.d.ts +25 -0
- package/dist/preset.js +14 -0
- package/dist/registry-publicui.config.d.ts +8 -0
- package/dist/registry-publicui.config.js +14 -0
- package/dist/registry.config.d.ts +16 -0
- package/dist/registry.config.js +17 -0
- package/dist/routes.d.ts +25 -0
- package/dist/routes.js +23 -0
- package/dist/vite.d.ts +24 -0
- package/dist/vite.js +135 -0
- package/package.json +93 -46
- package/pnpmfile.cjs +20 -0
- package/server.js +2 -1
- package/{app → src/app}/config/index.ts +1 -2
- package/{app → src/app}/config/server.server.ts +2 -4
- package/{app → src/app}/entry.client.tsx +12 -1
- package/{app → src/app}/entry.server.tsx +7 -0
- package/{app → src/app}/i18next.server.test.ts +48 -1
- package/{app → src/app}/i18next.server.ts +22 -14
- package/{app → src/app}/middleware.server.test.ts +0 -68
- package/{app → src/app}/middleware.server.ts +32 -40
- package/src/app/root.server.ts +124 -0
- package/{app → src/app}/root.test.tsx +36 -7
- package/src/app/root.tsx +101 -0
- package/.release-it.json +0 -32
- package/.stylelintrc +0 -8
- package/CHANGELOG.md +0 -450
- package/Makefile +0 -82
- package/acceptance/tests/anonymous-401-redirect.test.ts +0 -75
- package/acceptance/tests/basic.test.ts +0 -14
- package/acceptance/tests/hydration.test.ts +0 -106
- package/acceptance/tests/multilingual-root-redirect.test.ts +0 -45
- package/app/root.tsx +0 -191
- package/app/routes.ts +0 -20
- package/news/.gitkeep +0 -0
- package/public/favicon.ico +0 -0
- package/public/icon.svg +0 -13
- package/react-router.config.ts +0 -11
- package/registry-publicui.config.ts +0 -11
- package/registry.config.ts +0 -16
- package/tests/setup.ts +0 -6
- package/tests/testHelpers.tsx +0 -29
- package/towncrier.toml +0 -33
- package/tsconfig.json +0 -35
- package/vite.config.ts +0 -117
- package/vitest.config.ts +0 -32
- /package/{app → src/app}/config/index.test.ts +0 -0
- /package/{app → src/app}/config/server/content-migrations.server.test.ts +0 -0
- /package/{app → src/app}/config/server/content-migrations.server.ts +0 -0
- /package/{app → src/app}/config/server/migrations.server.ts +0 -0
- /package/{app → src/app}/config/server.server.test.ts +0 -0
- /package/{app → src/app}/config/types.ts +0 -0
- /package/{app → src/app}/i18n.ts +0 -0
- /package/{app → src/app}/okroute.test.tsx +0 -0
- /package/{app → src/app}/okroute.tsx +0 -0
- /package/{app → src/app}/reset-fetcher.test.tsx +0 -0
- /package/{app → src/app}/reset-fetcher.tsx +0 -0
package/Makefile
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# Volto development
|
|
2
|
-
|
|
3
|
-
# Project settings (read from repo root)
|
|
4
|
-
include ../../variables.mk
|
|
5
|
-
|
|
6
|
-
# Allow setting the language for backend-docker-start. Default is `en`.
|
|
7
|
-
LANGUAGE ?=en
|
|
8
|
-
|
|
9
|
-
# Recipe snippets for reuse
|
|
10
|
-
|
|
11
|
-
CHECKOUT_BASENAME="$(shell basename $(shell realpath ./))"
|
|
12
|
-
CHECKOUT_BRANCH=$(shell git branch --show-current)
|
|
13
|
-
CHECKOUT_TMP=../$(CHECKOUT_BASENAME).tmp
|
|
14
|
-
CHECKOUT_TMP_ABS="$(shell realpath $(CHECKOUT_TMP))"
|
|
15
|
-
|
|
16
|
-
CURRENT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
|
17
|
-
|
|
18
|
-
# Top-level targets
|
|
19
|
-
|
|
20
|
-
.PHONY: all
|
|
21
|
-
all: help
|
|
22
|
-
|
|
23
|
-
# Add the following 'help' target to your Makefile
|
|
24
|
-
# and add help text after each target name starting with ' ##'
|
|
25
|
-
# to return a pretty list of targets and their descriptions.
|
|
26
|
-
.PHONY: help
|
|
27
|
-
help: ## This help message
|
|
28
|
-
@echo -e "$$(grep -hE '^\S+:.*##' $(MAKEFILE_LIST) | sed -e 's/:.*##\s*/:/' -e 's/^\(.\+\):\(.*\)/$(CYAN)\1$(RESET):\2/' | column -c2 -t -s :)"
|
|
29
|
-
|
|
30
|
-
.PHONY: start
|
|
31
|
-
start: ## Starts Plone 7 in development mode
|
|
32
|
-
pnpm start
|
|
33
|
-
|
|
34
|
-
.PHONY: build
|
|
35
|
-
build: ## Build a production bundle for distribution
|
|
36
|
-
pnpm build
|
|
37
|
-
|
|
38
|
-
.PHONY: test
|
|
39
|
-
test: ## Run unit tests
|
|
40
|
-
pnpm test
|
|
41
|
-
|
|
42
|
-
.PHONY: clean
|
|
43
|
-
clean: ## Clean development environment
|
|
44
|
-
rm -rf node_modules
|
|
45
|
-
|
|
46
|
-
##### Build
|
|
47
|
-
|
|
48
|
-
../../packages/registry/dist: $(shell find ../../packages/registry/src -type f)
|
|
49
|
-
(cd ../../ && pnpm build:registry)
|
|
50
|
-
|
|
51
|
-
../../packages/components/dist: $(shell find ../../packages/components/src -type f)
|
|
52
|
-
(cd ../../ && pnpm build:components)
|
|
53
|
-
|
|
54
|
-
../../packages/client/dist: $(shell find ../../packages/client/src -type f)
|
|
55
|
-
(cd ../../ && pnpm build:client)
|
|
56
|
-
|
|
57
|
-
../../packages/helpers/dist: $(shell find ../../packages/helpers/src -type f)
|
|
58
|
-
(cd ../../ && pnpm build:helpers)
|
|
59
|
-
|
|
60
|
-
../../packages/react-router/dist: $(shell find ../../packages/react-router/src -type f)
|
|
61
|
-
(cd ../../ && pnpm build:react-router)
|
|
62
|
-
|
|
63
|
-
.PHONY: build-deps
|
|
64
|
-
build-deps: ../../packages/registry/dist ../../packages/components/dist ../../packages/client/dist ../../packages/react-router/dist ../../packages/helpers/dist ## Build dependencies
|
|
65
|
-
|
|
66
|
-
## Storybook
|
|
67
|
-
|
|
68
|
-
.PHONY: storybook-start
|
|
69
|
-
storybook-start: ## Start Storybook server on port 6006
|
|
70
|
-
@echo "$(GREEN)==> Start Storybook$(RESET)"
|
|
71
|
-
pnpm run storybook
|
|
72
|
-
|
|
73
|
-
.PHONY: storybook-build
|
|
74
|
-
storybook-build: build-deps ## Build Storybook
|
|
75
|
-
pnpm build-storybook -o ../../docs/_build/html/storybook
|
|
76
|
-
|
|
77
|
-
##### Release (it runs the one inside)
|
|
78
|
-
|
|
79
|
-
.PHONY: release-notes-copy-to-docs
|
|
80
|
-
release-notes-copy-to-docs: ## Copy release notes into documentation
|
|
81
|
-
cp CHANGELOG.md ../../docs/source/release-notes/index.md
|
|
82
|
-
git add ../../docs/source/release-notes/index.md
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContent,
|
|
3
|
-
setWorkflowSeven,
|
|
4
|
-
} from '../../../../packages/tooling/playwright/content';
|
|
5
|
-
import {
|
|
6
|
-
expect,
|
|
7
|
-
test,
|
|
8
|
-
} from '../../../../packages/tooling/playwright/multilingual';
|
|
9
|
-
|
|
10
|
-
test.describe('Anonymous 401 redirect', () => {
|
|
11
|
-
test('a private page sends an anonymous visitor to the login page', async ({
|
|
12
|
-
page,
|
|
13
|
-
request,
|
|
14
|
-
}) => {
|
|
15
|
-
// New content is private until published.
|
|
16
|
-
await createContent(request, {
|
|
17
|
-
contentType: 'Document',
|
|
18
|
-
contentId: 'internal',
|
|
19
|
-
contentTitle: 'Internal page',
|
|
20
|
-
path: 'en',
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
await page.goto('/en/internal');
|
|
24
|
-
await expect(page).toHaveURL(/\/login\?return_url=%2Fen%2Finternal$/);
|
|
25
|
-
await expect(page.getByLabel('username')).toBeVisible();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('a private language root sends an anonymous visitor to the login page', async ({
|
|
29
|
-
page,
|
|
30
|
-
request,
|
|
31
|
-
}) => {
|
|
32
|
-
await setWorkflowSeven(request, { path: 'en', review_state: 'retract' });
|
|
33
|
-
|
|
34
|
-
await page.goto('/en');
|
|
35
|
-
await expect(page).toHaveURL(/\/login\?return_url=%2Fen$/);
|
|
36
|
-
await expect(page.getByLabel('username')).toBeVisible();
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('the site root does not loop when the default language root is private', async ({
|
|
40
|
-
page,
|
|
41
|
-
request,
|
|
42
|
-
}) => {
|
|
43
|
-
await setWorkflowSeven(request, { path: 'en', review_state: 'retract' });
|
|
44
|
-
|
|
45
|
-
// / → /en (the multilingual root redirect) → /login?return_url=/en,
|
|
46
|
-
// never back to /.
|
|
47
|
-
const response = await page.goto('/');
|
|
48
|
-
expect(response?.ok()).toBe(true);
|
|
49
|
-
await expect(page).toHaveURL(/\/login\?return_url=%2Fen$/);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('a signed-in editor is not redirected from a page they can see', async ({
|
|
53
|
-
page,
|
|
54
|
-
request,
|
|
55
|
-
}) => {
|
|
56
|
-
await createContent(request, {
|
|
57
|
-
contentType: 'Document',
|
|
58
|
-
contentId: 'internal',
|
|
59
|
-
contentTitle: 'Internal page',
|
|
60
|
-
path: 'en',
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
await page.goto('/login', { waitUntil: 'networkidle' });
|
|
64
|
-
await page.getByLabel('username').fill('admin');
|
|
65
|
-
await page.getByLabel('password').fill('secret');
|
|
66
|
-
await page.getByRole('button', { name: /sign in/i }).click();
|
|
67
|
-
await expect(page).toHaveURL(/\/en$/);
|
|
68
|
-
|
|
69
|
-
await page.goto('/en/internal');
|
|
70
|
-
await expect(page).toHaveURL(/\/en\/internal$/);
|
|
71
|
-
await expect(
|
|
72
|
-
page.getByRole('heading', { name: 'Internal page' }),
|
|
73
|
-
).toBeVisible();
|
|
74
|
-
});
|
|
75
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { expect, test } from '../../../../packages/tooling/playwright/test';
|
|
2
|
-
|
|
3
|
-
test.describe('Basic Playwright Test', () => {
|
|
4
|
-
test('should visit the root URL', async ({ page }) => {
|
|
5
|
-
await page.goto('/');
|
|
6
|
-
await expect(page).toHaveURL(/\/$/);
|
|
7
|
-
await expect(page.getByText('Home')).toBeVisible();
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
test('html tag has the lang attr', async ({ page }) => {
|
|
11
|
-
await page.goto('/');
|
|
12
|
-
await expect(page.locator('html')).toHaveAttribute('lang', 'en');
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { expect, test } from '../../../../packages/tooling/playwright/test';
|
|
2
|
-
import type { Page } from '@playwright/test';
|
|
3
|
-
import { PLONE_BLOCK_TYPE } from '@plone/helpers';
|
|
4
|
-
import { createContent } from '../../../../packages/tooling/playwright/content';
|
|
5
|
-
|
|
6
|
-
// If the server and client renders differ, React discards the server-rendered
|
|
7
|
-
// DOM on hydration and renders it again on the client. Any element a test (or
|
|
8
|
-
// script) grabbed before that is then detached and measures 0x0.
|
|
9
|
-
|
|
10
|
-
const PAGE_ID = 'hydration-page';
|
|
11
|
-
const IMAGE_ID = 'hydration-image';
|
|
12
|
-
|
|
13
|
-
async function setupImageBlockPage(page: Page) {
|
|
14
|
-
await createContent(page, {
|
|
15
|
-
contentType: 'Image',
|
|
16
|
-
contentId: IMAGE_ID,
|
|
17
|
-
contentTitle: 'Hydration image',
|
|
18
|
-
image: {
|
|
19
|
-
sourceFilename: 'halfdome2022.jpg',
|
|
20
|
-
filename: 'halfdome2022.jpg',
|
|
21
|
-
'content-type': 'image/jpeg',
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
await createContent(page, {
|
|
25
|
-
contentType: 'Document',
|
|
26
|
-
contentId: PAGE_ID,
|
|
27
|
-
contentTitle: 'Hydration page',
|
|
28
|
-
transition: 'publish',
|
|
29
|
-
bodyModifier: (body) => ({
|
|
30
|
-
...body,
|
|
31
|
-
blocks: {
|
|
32
|
-
main: {
|
|
33
|
-
'@type': 'plate',
|
|
34
|
-
value: [
|
|
35
|
-
{ type: 'title', children: [{ text: 'Hydration page' }] },
|
|
36
|
-
{ type: 'p', children: [{ text: 'Text before image' }] },
|
|
37
|
-
{
|
|
38
|
-
type: PLONE_BLOCK_TYPE,
|
|
39
|
-
'@type': 'image',
|
|
40
|
-
url: `/${IMAGE_ID}`,
|
|
41
|
-
align: 'left',
|
|
42
|
-
size: 'l',
|
|
43
|
-
blockWidth: 'default',
|
|
44
|
-
children: [{ text: '' }],
|
|
45
|
-
},
|
|
46
|
-
{ type: 'p', children: [{ text: 'Text after image' }] },
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
}),
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
test.describe('Hydration', () => {
|
|
55
|
-
test('the server renders translated messages', async ({ page }) => {
|
|
56
|
-
const html = await (await page.request.get('/')).text();
|
|
57
|
-
expect(
|
|
58
|
-
html.includes('layout.slots.headertools.anonymousTools.login'),
|
|
59
|
-
'the server rendered a raw message key',
|
|
60
|
-
).toBe(false);
|
|
61
|
-
expect(html.includes('>Log In<'), 'the server rendered "Log In"').toBe(
|
|
62
|
-
true,
|
|
63
|
-
);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('the server-rendered image block survives hydration', async ({
|
|
67
|
-
page,
|
|
68
|
-
}) => {
|
|
69
|
-
await setupImageBlockPage(page);
|
|
70
|
-
|
|
71
|
-
// Keep a reference to the server-rendered node, before React hydrates.
|
|
72
|
-
await page.addInitScript(() => {
|
|
73
|
-
document.addEventListener('DOMContentLoaded', () => {
|
|
74
|
-
(window as any).__ssrImageBlock = document.querySelector(
|
|
75
|
-
'.block-image__frame',
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
await page.goto(`/${PAGE_ID}`);
|
|
80
|
-
|
|
81
|
-
// Wait until React owns the current `.block-image__frame`, i.e. hydration (or a
|
|
82
|
-
// client re-render after a failed hydration) has finished.
|
|
83
|
-
await expect
|
|
84
|
-
.poll(() =>
|
|
85
|
-
page.evaluate(() => {
|
|
86
|
-
const el = document.querySelector('.block-image__frame');
|
|
87
|
-
return (
|
|
88
|
-
!!el && Object.keys(el).some((k) => k.startsWith('__reactFiber'))
|
|
89
|
-
);
|
|
90
|
-
}),
|
|
91
|
-
)
|
|
92
|
-
.toBe(true);
|
|
93
|
-
|
|
94
|
-
const result = await page.evaluate(() => {
|
|
95
|
-
const ssr = (window as any).__ssrImageBlock as HTMLElement | null;
|
|
96
|
-
return {
|
|
97
|
-
found: !!ssr,
|
|
98
|
-
connected: !!ssr?.isConnected,
|
|
99
|
-
same: ssr === document.querySelector('.block-image__frame'),
|
|
100
|
-
width: ssr?.getBoundingClientRect().width ?? 0,
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
expect(result).toMatchObject({ found: true, connected: true, same: true });
|
|
104
|
-
expect(result.width).toBeGreaterThan(0);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
expect,
|
|
3
|
-
test,
|
|
4
|
-
} from '../../../../packages/tooling/playwright/multilingual';
|
|
5
|
-
|
|
6
|
-
test.describe('Multilingual root redirect', () => {
|
|
7
|
-
test('a full load of the site root lands on the default language root', async ({
|
|
8
|
-
page,
|
|
9
|
-
}) => {
|
|
10
|
-
await page.goto('/');
|
|
11
|
-
await expect(page).toHaveURL(/\/en$/);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('a client-side navigation to the site root lands on the default language root', async ({
|
|
15
|
-
page,
|
|
16
|
-
}) => {
|
|
17
|
-
// The login action redirects to the site root once signed in. That is a
|
|
18
|
-
// client-side navigation, which fetches /_.data, not /.
|
|
19
|
-
await page.goto('/login', { waitUntil: 'networkidle' });
|
|
20
|
-
await page.getByLabel('username').fill('admin');
|
|
21
|
-
await page.getByLabel('password').fill('secret');
|
|
22
|
-
|
|
23
|
-
const rootData = page.waitForRequest((request) =>
|
|
24
|
-
/^\/_[^/]*\.data$/.test(new URL(request.url()).pathname),
|
|
25
|
-
);
|
|
26
|
-
await page.getByRole('button', { name: /sign in/i }).click();
|
|
27
|
-
await rootData;
|
|
28
|
-
|
|
29
|
-
await expect(page).toHaveURL(/\/en$/);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('a language root is not redirected', async ({ page }) => {
|
|
33
|
-
await page.goto('/de');
|
|
34
|
-
await expect(page).toHaveURL(/\/de$/);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test.describe('Multilingual root redirect with another default language', () => {
|
|
39
|
-
test.use({ languages: ['de', 'en'] });
|
|
40
|
-
|
|
41
|
-
test('the site root lands on the default language root', async ({ page }) => {
|
|
42
|
-
await page.goto('/');
|
|
43
|
-
await expect(page).toHaveURL(/\/de$/);
|
|
44
|
-
});
|
|
45
|
-
});
|
package/app/root.tsx
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { useEffect, type PropsWithChildren } from 'react';
|
|
2
|
-
import { data, isRouteErrorResponse, useRouteLoaderData } from 'react-router';
|
|
3
|
-
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { i18nextMiddleware, getLocale } from './i18next.server';
|
|
5
|
-
import type { Route } from './+types/root';
|
|
6
|
-
import config from '@plone/registry';
|
|
7
|
-
import {
|
|
8
|
-
ploneClearAuthCookieContext,
|
|
9
|
-
fetchPloneContent,
|
|
10
|
-
getAPIResourceWithAuth,
|
|
11
|
-
contentResourceMiddleware,
|
|
12
|
-
installServerMiddleware,
|
|
13
|
-
PloneClientMiddleware,
|
|
14
|
-
otherResources,
|
|
15
|
-
ploneClientContext,
|
|
16
|
-
ploneContentContext,
|
|
17
|
-
ploneSiteContext,
|
|
18
|
-
ploneUserContext,
|
|
19
|
-
linkMiddleware,
|
|
20
|
-
} from './middleware.server';
|
|
21
|
-
import { getClearAuthCookieHeader } from '@plone/react-router';
|
|
22
|
-
|
|
23
|
-
export const middleware = [
|
|
24
|
-
// Install the configuration first: the i18next middleware reads the
|
|
25
|
-
// supported languages from it.
|
|
26
|
-
installServerMiddleware,
|
|
27
|
-
i18nextMiddleware,
|
|
28
|
-
PloneClientMiddleware,
|
|
29
|
-
otherResources,
|
|
30
|
-
getAPIResourceWithAuth,
|
|
31
|
-
contentResourceMiddleware,
|
|
32
|
-
fetchPloneContent,
|
|
33
|
-
linkMiddleware,
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
export async function loader({ params, request, context }: Route.LoaderArgs) {
|
|
37
|
-
const locale = getLocale(context);
|
|
38
|
-
|
|
39
|
-
const cli = context.get(ploneClientContext);
|
|
40
|
-
const content = context.get(ploneContentContext);
|
|
41
|
-
const site = context.get(ploneSiteContext);
|
|
42
|
-
const user = context.get(ploneUserContext);
|
|
43
|
-
|
|
44
|
-
const path = `/${params['*'] || ''}`;
|
|
45
|
-
|
|
46
|
-
const rootLoaderDataUtilities = config.getUtilities({
|
|
47
|
-
type: 'rootLoaderData',
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const rootContentSubRequests = config.getUtilities({
|
|
51
|
-
type: 'rootContentSubRequest',
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
try {
|
|
55
|
-
for (const utility of rootContentSubRequests) {
|
|
56
|
-
await utility.method({
|
|
57
|
-
cli,
|
|
58
|
-
content,
|
|
59
|
-
request,
|
|
60
|
-
path,
|
|
61
|
-
params,
|
|
62
|
-
locale,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const rootLoaderDataUtilitiesData = await Promise.all([
|
|
67
|
-
...rootLoaderDataUtilities.map((utility) =>
|
|
68
|
-
utility.method({
|
|
69
|
-
cli,
|
|
70
|
-
content,
|
|
71
|
-
request,
|
|
72
|
-
path,
|
|
73
|
-
params,
|
|
74
|
-
locale,
|
|
75
|
-
}),
|
|
76
|
-
),
|
|
77
|
-
]);
|
|
78
|
-
|
|
79
|
-
const loaderData = {
|
|
80
|
-
content,
|
|
81
|
-
site,
|
|
82
|
-
locale,
|
|
83
|
-
isAuthenticated: user !== null,
|
|
84
|
-
// Each `rootLoaderData` utility returns a `{ status, data }` envelope
|
|
85
|
-
// (see `config/types.ts`). Merge each utility's `data` into the root
|
|
86
|
-
// loader data; utilities namespace their `data` to avoid clobbering.
|
|
87
|
-
// TODO: act on `status` (e.g. propagate a non-2xx to the response).
|
|
88
|
-
...rootLoaderDataUtilitiesData
|
|
89
|
-
.filter((item) => item)
|
|
90
|
-
.reduce(
|
|
91
|
-
(acc, item) => ({
|
|
92
|
-
...acc,
|
|
93
|
-
...(item.data as Record<string, unknown>),
|
|
94
|
-
}),
|
|
95
|
-
{},
|
|
96
|
-
),
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
return data(loaderData, {
|
|
100
|
-
headers: context.get(ploneClearAuthCookieContext)
|
|
101
|
-
? {
|
|
102
|
-
'Set-Cookie': await getClearAuthCookieHeader(),
|
|
103
|
-
}
|
|
104
|
-
: undefined,
|
|
105
|
-
});
|
|
106
|
-
} catch (error: any) {
|
|
107
|
-
throw data('Content Not Found', {
|
|
108
|
-
status: typeof error.status === 'number' ? error.status : 500,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export type RootLoader = typeof loader;
|
|
114
|
-
|
|
115
|
-
export const handle = {
|
|
116
|
-
// In the handle export, we can add a i18n key with namespaces our route
|
|
117
|
-
// will need to load. This key can be a single string or an array of strings.
|
|
118
|
-
// TIP: In most cases, you should set this to your defaultNS from your i18n config
|
|
119
|
-
// or if you did not set one, set it to the i18next default namespace "translation"
|
|
120
|
-
i18n: 'common',
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export function Layout({ children }: PropsWithChildren) {
|
|
124
|
-
// React Router doesn't pass the loader data to `Layout`, and it can be
|
|
125
|
-
// undefined in case of an error
|
|
126
|
-
const loaderData = useRouteLoaderData<RootLoader>('root');
|
|
127
|
-
const locale = loaderData?.locale || 'en';
|
|
128
|
-
|
|
129
|
-
// Sync the i18n instance's language to the locale detected by the loader,
|
|
130
|
-
// this way, when we do something to change the language, this locale will
|
|
131
|
-
// change and i18next will load the correct translation files
|
|
132
|
-
const { i18n } = useTranslation();
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
if (i18n.language !== locale) i18n.changeLanguage(locale);
|
|
135
|
-
}, [locale, i18n]);
|
|
136
|
-
|
|
137
|
-
return children;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// ToDo: improve error page and error handling
|
|
141
|
-
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
|
|
142
|
-
let message = 'Oops!';
|
|
143
|
-
let details = 'An unexpected error occurred.';
|
|
144
|
-
let stack: string | undefined;
|
|
145
|
-
|
|
146
|
-
if (isRouteErrorResponse(error)) {
|
|
147
|
-
switch (error.status) {
|
|
148
|
-
case 404:
|
|
149
|
-
message = '404';
|
|
150
|
-
details = 'The requested page could not be found.';
|
|
151
|
-
break;
|
|
152
|
-
case 401:
|
|
153
|
-
message = '401';
|
|
154
|
-
details = 'You are not authorized to view this page.';
|
|
155
|
-
break;
|
|
156
|
-
case 500:
|
|
157
|
-
message = '500';
|
|
158
|
-
details =
|
|
159
|
-
'The server encountered an internal error. Did you start the backend?';
|
|
160
|
-
break;
|
|
161
|
-
default:
|
|
162
|
-
message = 'Error ' + error.status;
|
|
163
|
-
details = error.statusText || details;
|
|
164
|
-
break;
|
|
165
|
-
}
|
|
166
|
-
} else if (import.meta.env.DEV && error && error instanceof Error) {
|
|
167
|
-
details = error.message;
|
|
168
|
-
stack = error.stack;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<html lang="en">
|
|
173
|
-
<head>
|
|
174
|
-
<meta charSet="utf-8" />
|
|
175
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
176
|
-
<meta name="mobile-web-app-capable" content="yes" />
|
|
177
|
-
</head>
|
|
178
|
-
<body>
|
|
179
|
-
<main className="container mx-auto p-4 pt-16">
|
|
180
|
-
<h1>{message}</h1>
|
|
181
|
-
<p>{details}</p>
|
|
182
|
-
{stack && (
|
|
183
|
-
<pre className="w-full overflow-x-auto p-4">
|
|
184
|
-
<code>{stack}</code>
|
|
185
|
-
</pre>
|
|
186
|
-
)}
|
|
187
|
-
</main>
|
|
188
|
-
</body>
|
|
189
|
-
</html>
|
|
190
|
-
);
|
|
191
|
-
}
|
package/app/routes.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { RouteConfig } from '@react-router/dev/routes';
|
|
2
|
-
import type { ReactRouterRouteEntry } from '@plone/types';
|
|
3
|
-
import { route } from '@react-router/dev/routes';
|
|
4
|
-
import { getAddonRoutesConfig } from '@plone/react-router';
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line import/no-unresolved
|
|
7
|
-
import addonsRoutes from '../.plone/registry.routes.json';
|
|
8
|
-
// eslint-disable-next-line import/no-unresolved
|
|
9
|
-
import addonsInfo from '../.plone/registry.addonsInfo.json';
|
|
10
|
-
|
|
11
|
-
const routes: RouteConfig = [
|
|
12
|
-
route('ok', 'okroute.tsx', { id: 'ok' }),
|
|
13
|
-
route('@reset-fetcher', 'reset-fetcher.tsx', { id: 'reset-fetcher' }),
|
|
14
|
-
...getAddonRoutesConfig(
|
|
15
|
-
(addonsRoutes as ReactRouterRouteEntry[]) || [],
|
|
16
|
-
addonsInfo,
|
|
17
|
-
),
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
export default routes;
|
package/news/.gitkeep
DELETED
|
File without changes
|
package/public/favicon.ico
DELETED
|
Binary file
|
package/public/icon.svg
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<svg width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<g clip-path="url(#clip0_1_2)">
|
|
3
|
-
<path d="M17.717 15.963C20.1482 15.963 22.119 13.9922 22.119 11.561C22.119 9.12984 20.1482 7.159 17.717 7.159C15.2858 7.159 13.315 9.12984 13.315 11.561C13.315 13.9922 15.2858 15.963 17.717 15.963Z" fill="#0083BE"/>
|
|
4
|
-
<path d="M31.069 20.355C31.069 22.791 29.1 24.756 26.669 24.756C24.239 24.756 22.269 22.786 22.269 20.355C22.269 17.922 24.247 15.957 26.669 15.957C29.101 15.954 31.069 17.924 31.069 20.355Z" fill="#0083BE"/>
|
|
5
|
-
<path d="M17.702 33.578C20.1331 33.578 22.104 31.6071 22.104 29.176C22.104 26.7448 20.1331 24.774 17.702 24.774C15.2708 24.774 13.3 26.7448 13.3 29.176C13.3 31.6071 15.2708 33.578 17.702 33.578Z" fill="#0083BE"/>
|
|
6
|
-
<path d="M20.343 0C9.108 0.001 0.001 9.107 0 20.343C0.001 31.577 9.105 40.684 20.343 40.686C31.578 40.684 40.684 31.582 40.686 20.343C40.684 9.107 31.578 0.001 20.343 0ZM31.792 31.792C28.854 34.726 24.816 36.534 20.341 36.535C15.862 36.534 11.828 34.723 8.891 31.792C5.958 28.854 4.15 24.816 4.149 20.343C4.15 15.865 5.96 11.83 8.892 8.893C11.83 5.959 15.864 4.151 20.342 4.15C24.82 4.151 28.855 5.962 31.792 8.893C34.727 11.831 36.534 15.869 36.536 20.343C36.535 24.819 34.726 28.854 31.792 31.792Z" fill="#0083BE"/>
|
|
7
|
-
</g>
|
|
8
|
-
<defs>
|
|
9
|
-
<clipPath id="clip0_1_2">
|
|
10
|
-
<rect width="40.686" height="40.686" fill="white"/>
|
|
11
|
-
</clipPath>
|
|
12
|
-
</defs>
|
|
13
|
-
</svg>
|
package/react-router.config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Config } from '@react-router/dev/config';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
ssr: true,
|
|
5
|
-
// The build directory may be named by the environment, so a deployment can build
|
|
6
|
-
// ASIDE into a versioned directory (for example build.live-<stamp>) and then swap a
|
|
7
|
-
// symlink, instead of writing into the directory a running server is serving from —
|
|
8
|
-
// `react-router build` removes its build directory before it writes. Unset, the
|
|
9
|
-
// default `build` is unchanged.
|
|
10
|
-
buildDirectory: process.env.REACT_ROUTER_BUILD_DIR || 'build',
|
|
11
|
-
} satisfies Config;
|
package/registry.config.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const addons = [
|
|
2
|
-
'@plone/theming',
|
|
3
|
-
'@plone/plate',
|
|
4
|
-
'@plone/blocks',
|
|
5
|
-
'@plone/layout',
|
|
6
|
-
'@plone/cmsui',
|
|
7
|
-
'@plone/publicui',
|
|
8
|
-
'@plone/contents',
|
|
9
|
-
'@plone/controlpanels',
|
|
10
|
-
'@plone/agave',
|
|
11
|
-
// Blocks and fields for the acceptance and visual regression tests only.
|
|
12
|
-
...(process.env.PLONE_TEST_ADDON ? ['@plone/test-addon'] : []),
|
|
13
|
-
];
|
|
14
|
-
const theme = '';
|
|
15
|
-
|
|
16
|
-
export { addons, theme };
|
package/tests/setup.ts
DELETED
package/tests/testHelpers.tsx
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import i18next from 'i18next';
|
|
3
|
-
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { I18nextProvider, initReactI18next } from 'react-i18next';
|
|
6
|
-
|
|
7
|
-
import { getI18nOptions } from '../app/i18n';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Use this function to render a component with the i18next provider
|
|
11
|
-
* @param children The route Stub to render
|
|
12
|
-
*/
|
|
13
|
-
export async function renderWithI18n(children: React.ReactNode) {
|
|
14
|
-
await i18next
|
|
15
|
-
.use(initReactI18next)
|
|
16
|
-
.use(LanguageDetector)
|
|
17
|
-
.init({
|
|
18
|
-
...getI18nOptions(),
|
|
19
|
-
ns: ['common'],
|
|
20
|
-
detection: {
|
|
21
|
-
order: ['htmlTag'],
|
|
22
|
-
caches: [],
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
const result = render(
|
|
26
|
-
<I18nextProvider i18n={i18next}>{children}</I18nextProvider>,
|
|
27
|
-
);
|
|
28
|
-
return result;
|
|
29
|
-
}
|
package/towncrier.toml
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
[tool.towncrier]
|
|
2
|
-
filename = "CHANGELOG.md"
|
|
3
|
-
directory = "news/"
|
|
4
|
-
title_format = "## {version} ({project_date})"
|
|
5
|
-
underlines = ["", "", ""]
|
|
6
|
-
template = "../../packages/scripts/templates/towncrier_template.jinja"
|
|
7
|
-
start_string = "<!-- towncrier release notes start -->\n"
|
|
8
|
-
issue_format = "[#{issue}](https://github.com/plone/aurora/issues/{issue})"
|
|
9
|
-
|
|
10
|
-
[[tool.towncrier.type]]
|
|
11
|
-
directory = "breaking"
|
|
12
|
-
name = "Breaking"
|
|
13
|
-
showcontent = true
|
|
14
|
-
|
|
15
|
-
[[tool.towncrier.type]]
|
|
16
|
-
directory = "feature"
|
|
17
|
-
name = "Feature"
|
|
18
|
-
showcontent = true
|
|
19
|
-
|
|
20
|
-
[[tool.towncrier.type]]
|
|
21
|
-
directory = "bugfix"
|
|
22
|
-
name = "Bugfix"
|
|
23
|
-
showcontent = true
|
|
24
|
-
|
|
25
|
-
[[tool.towncrier.type]]
|
|
26
|
-
directory = "internal"
|
|
27
|
-
name = "Internal"
|
|
28
|
-
showcontent = true
|
|
29
|
-
|
|
30
|
-
[[tool.towncrier.type]]
|
|
31
|
-
directory = "documentation"
|
|
32
|
-
name = "Documentation"
|
|
33
|
-
showcontent = true
|