Skip to content

Commit

Permalink
Merge branch 'main' into edit_title_6308
Browse files Browse the repository at this point in the history
  • Loading branch information
ichim-david authored Oct 25, 2024
2 parents bca33bc + 67a4446 commit 26871f9
Show file tree
Hide file tree
Showing 226 changed files with 4,828 additions and 8,297 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -105,7 +105,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -153,7 +153,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -201,7 +201,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -249,7 +249,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -296,7 +296,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -344,7 +344,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -392,7 +392,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -440,7 +440,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
node-version: [22.x]
# python-version: [3.7]
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -489,7 +489,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
env:
generator-directory: ./packages/generator-volto
project-directory: ./my-volto-app
Expand Down Expand Up @@ -597,7 +597,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -647,7 +647,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x]
node-version: [22.x]
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

env:
node-version: 20.x
node-version: 22.x

jobs:
towncrier:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code Analysis Check
on: [push, pull_request]

env:
node-version: 20.x
node-version: 22.x

jobs:
prettier:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deployment_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deployment Tests
on: [push, pull_request]

env:
node-version: 20.x
node-version: 22.x

jobs:
vitessr:
Expand Down
18 changes: 7 additions & 11 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Unit Tests
on: [push, pull_request]

env:
node-version: 20.x
node-version: 22.x

jobs:
volto:
Expand All @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -77,16 +77,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ env.node-version }}

- name: Enable corepack
run: corepack enable
Expand Down Expand Up @@ -152,16 +150,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v4

# node setup
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: ${{ env.node-version }}

- name: Enable corepack
run: corepack enable
Expand Down
5 changes: 5 additions & 0 deletions apps/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This is a proof of concept of a [Next.js](https://nextjs.org) app, using the app router and the `@plone/client` and `@plone/components` library. This is intended to serve as both a playground for the development of both packages and as demo of Plone using Next.js.

> [!WARNING]
> This package or app is experimental.
> The community offers no support whatsoever for it.
> Breaking changes may occur without notice.
## Development

To start, from the root of the monorepo:
Expand Down
3 changes: 3 additions & 0 deletions apps/nextjs/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import path from 'path';

/** @type {import('next').NextConfig} */
const nextConfig = {
typescript: {
ignoreBuildErrors: true,
},
// sassOptions: {
// includePaths: [path.join(__dirname, 'src/lib/components/src/styles')],
// },
Expand Down
53 changes: 38 additions & 15 deletions apps/nextjs/src/app/Providers.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
'use client';
import React from 'react';
import { useRouter } from 'next/navigation';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { PloneClientProvider } from '@plone/providers';
import {
useRouter,
usePathname,
useSearchParams,
useParams,
} from 'next/navigation';
import { QueryClient } from '@tanstack/react-query';
import { PloneProvider } from '@plone/providers';
import PloneClient from '@plone/client';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { RouterProvider } from 'react-aria-components';
import { FlattenToAppURLProvider } from '@plone/components';
import { flattenToAppURL } from './utils';
import config from './config';

// Custom hook to unify the location object between NextJS and Plone
function useLocation() {
const pathname = usePathname();
const search = useSearchParams();

return {
pathname,
search,
searchStr: '',
hash: (typeof window !== 'undefined' && window.location.hash) || '',
href: (typeof window !== 'undefined' && window.location.href) || '',
};
}

const Providers: React.FC<{
children?: React.ReactNode;
}> = ({ children }) => {
Expand Down Expand Up @@ -39,16 +56,22 @@ const Providers: React.FC<{
const router = useRouter();

return (
<RouterProvider navigate={router.push}>
<PloneClientProvider client={ploneClient}>
<QueryClientProvider client={queryClient}>
<FlattenToAppURLProvider flattenToAppURL={flattenToAppURL}>
{children}
<ReactQueryDevtools initialIsOpen={false} />
</FlattenToAppURLProvider>
</QueryClientProvider>
</PloneClientProvider>
</RouterProvider>
<PloneProvider
ploneClient={ploneClient}
queryClient={queryClient}
// NextJS doesn't have a useLocation hook, so we need to unify this
// in a custom hook
useLocation={useLocation}
navigate={(to) => {
router.push(to);
}}
useParams={useParams}
useHref={(to) => flattenToAppURL(to)}
flattenToAppURL={flattenToAppURL}
>
{children}
<ReactQueryDevtools initialIsOpen={false} />
</PloneProvider>
);
};

Expand Down
13 changes: 10 additions & 3 deletions apps/nextjs/src/app/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import config from '@plone/registry';
import { slate } from '@plone/blocks';
import { blocksConfig } from '@plone/blocks';

const settings = {
apiPath: process.env.NEXT_PUBLIC_VERCEL_URL
? // Vercel does not prepend the schema to the NEXT_PUBLIC_VERCEL_URL automatic env var
`https://${process.env.NEXT_PUBLIC_VERCEL_URL}`
: 'http://localhost:3000',
slate,
};

const config = {
settings,
};
// @ts-expect-error Improve typings
config.set('settings', settings);

// @ts-expect-error Improve typings
config.set('blocks', { blocksConfig });

export default config;
32 changes: 8 additions & 24 deletions apps/nextjs/src/app/content.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
'use client';

import { useQuery } from '@tanstack/react-query';
import { usePathname } from 'next/navigation';
import Link from 'next/link';
import { flattenToAppURL } from './utils';
import { usePloneClient } from '@plone/providers';
import { Breadcrumbs } from '@plone/components';
import { Breadcrumbs, RenderBlocks } from '@plone/components';
import config from '@plone/registry';

import '@plone/components/dist/basic.css';

export default function Content() {
Expand All @@ -16,31 +15,16 @@ export default function Content() {
if (data) {
return (
<div style={{ fontSize: '20px' }}>
<h1>{data.title}</h1>
{/* <Input
name="field1"
title="field 1 title"
placeholder="Type something…"
description="Optional help text"
isRequired
/> */}
<Breadcrumbs
items={data['@components'].breadcrumbs.items || []}
root={data['@components'].breadcrumbs.root}
includeRoot
/>
<ul>
{data?.['@components']?.navigation?.items?.map((item) => (
<li key={item['@id']}>
<Link href={flattenToAppURL(item['@id'])}>
{flattenToAppURL(item['@id'])}
</Link>
</li>
))}
</ul>
<div>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
<RenderBlocks
content={data}
blocksConfig={config.blocks.blocksConfig}
pathname={pathname}
/>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Providers from './Providers';
const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = {
title: 'NextJS-powered Plone',
title: 'Next.js app powered by Plone',
description: '',
};

Expand Down
Loading

0 comments on commit 26871f9

Please sign in to comment.