Skip to content

Commit

Permalink
Merge branch 'betterproviders' into slots-base
Browse files Browse the repository at this point in the history
* betterproviders:
  Fix linting
  Changelog
  Latest touches
  Better branding here
  Apply suggestions from code review
  Return whole context instead of only useLocation
  Adjust the path to perform a proper `git diff` between the cached and… (#6410)
  Test whether commenting out the `ignore` command has any affect on the Netlify build.
  Better admonitions format for experimental notices.
  support depth in getNavigationQuery (#6400)
  Update caniuse Oct24 (#6408)
  Upgraded nextjs deps and configuration (#6388)
  • Loading branch information
sneridagh committed Oct 17, 2024
2 parents 21de7e2 + a9802d2 commit 4a0f3f5
Show file tree
Hide file tree
Showing 44 changed files with 628 additions and 407 deletions.
10 changes: 0 additions & 10 deletions apps/nextjs/.eslintrc.js

This file was deleted.

9 changes: 9 additions & 0 deletions apps/nextjs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["next/core-web-vitals", "next/typescript"],
"ignorePatterns": [".next/**", "dist/**", "node_modules/**"],
"settings": {
"next": {
"rootDir": "apps/nextjs/"
}
}
}
1 change: 1 addition & 0 deletions apps/nextjs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Plone Foundation
Copyright (c) 2024 Plone Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 4 additions & 5 deletions apps/nextjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

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.

## EXPERIMENTAL

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

Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/next.config.js → apps/nextjs/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path');
import path from 'path';

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand Down Expand Up @@ -49,4 +49,4 @@ const nextConfig = {
},
};

module.exports = nextConfig;
export default nextConfig;
11 changes: 6 additions & 5 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
"@plone/blocks": "workspace: *",
"@plone/client": "workspace: *",
"@plone/components": "workspace: *",
"@plone/registry": "workspace: *",
"@plone/providers": "workspace: *",
"@tanstack/react-query": "^5.37.1",
"next": "14.2.15",
"@plone/registry": "workspace: *",
"@tanstack/react-query": "^5.59.0",
"next": "14.2.14",
"react": "^18",
"react-aria-components": "^1.4.0",
"react-dom": "^18"
},
"devDependencies": {
"@tanstack/react-query-devtools": "^5.37.1",
"@plone/types": "workspace: *",
"@tanstack/react-query-devtools": "^5.59.0",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.2",
"eslint-config-next": "14.2.14",
"typescript": "^5.6.3"
}
}
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import config from './config';

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

return {
pathname,
Expand Down Expand Up @@ -53,7 +53,7 @@ const Providers: React.FC<{
}),
);

let router = useRouter();
const router = useRouter();

return (
<PloneProvider
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const settings = {
slate,
};

//@ts-ignore
// @ts-expect-error Improve typings
config.set('settings', settings);

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

export default config;
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/content.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import { useQuery } from '@tanstack/react-query';
import { usePathname } from 'next/navigation';
import { usePloneClient, usePloneProvider } from '@plone/providers';
import { usePloneClient } from '@plone/providers';
import { Breadcrumbs, RenderBlocks } from '@plone/components';
import config from '@plone/registry';

Expand All @@ -10,7 +10,7 @@ import '@plone/components/dist/basic.css';
export default function Content() {
const { getContentQuery } = usePloneClient();
const pathname = usePathname();
const { data, isLoading } = useQuery(getContentQuery({ path: pathname }));
const { data } = useQuery(getContentQuery({ path: pathname }));

if (data) {
return (
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 app powered by Plone',
title: 'Next.js app powered by Plone',
description: '',
};

Expand Down
3 changes: 0 additions & 3 deletions apps/nextjs/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

export function middleware(request: NextRequest) {
// Clone the request headers and set a new header `x-hello-from-middleware1`
const requestHeaders = new Headers(request.headers);
// console.log(request.nextUrl.pathname);
// requestHeaders.set('x-hello-from-middleware1', 'hello');

// You can also set request headers in NextResponse.rewrite
const response = NextResponse.next({
Expand Down
66 changes: 31 additions & 35 deletions apps/nextjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
]
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jx",
".next/types/**/*.ts"
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"exclude": [
"node_modules",
]
"paths": {
"@/*": ["./src/*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx",
".next/types/**/*.ts"
],
"exclude": ["node_modules"]
}
9 changes: 4 additions & 5 deletions apps/remix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
This is a proof of concept of a [Remix](https://remix.run) app, using the `@plone/client` and `@plone/components` libraries.
This is intended to serve as both a playground for the development of both packages and as a demo of Plone using Remix.

## EXPERIMENTAL

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

Expand Down
4 changes: 2 additions & 2 deletions apps/remix/app/routes/$.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { ploneClient } from '../client';

export const meta: MetaFunction = () => {
return [
{ title: 'New Remix App' },
{ name: 'description', content: 'Welcome to Remix!' },
{ title: 'Plone on Remix' },
{ name: 'description', content: 'Welcome to Plone on Remix!' },
];
};

Expand Down
4 changes: 2 additions & 2 deletions apps/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
"@remix-run/node": "^2.13.1",
"@remix-run/react": "^2.13.1",
"@remix-run/serve": "^2.13.1",
"@tanstack/react-query": "^5.37.1",
"@tanstack/react-query": "^5.59.0",
"isbot": "^4.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@remix-run/dev": "^2.13.1",
"@tanstack/react-query-devtools": "^5.37.1",
"@tanstack/react-query-devtools": "^5.59.0",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"typescript": "^5.6.3",
Expand Down
9 changes: 4 additions & 5 deletions apps/vite-ssr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ This is intended to serve as both a playground for the development of both packa

It also uses [TanStack Router](https://tanstack.com/router/latest/docs/framework/react/overview) for its routing library.

## EXPERIMENTAL

This package or app is experimental.
The community offers no support whatsoever for it.
Breaking changes may occur without notice.
> [!WARNING]
> This package or app is experimental.
> The community offers no support whatsoever for it.
> Breaking changes may occur without notice.
4 changes: 2 additions & 2 deletions apps/vite-ssr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@plone/providers": "workspace:*",
"@plone/registry": "workspace:*",
"@plone/blocks": "workspace:*",
"@tanstack/react-query": "^5.37.1",
"@tanstack/react-query": "^5.59.0",
"@tanstack/react-router": "^1.34.9",
"@tanstack/start": "^1.34.9",
"@tanstack/router-vite-plugin": "^1.34.8",
Expand All @@ -33,7 +33,7 @@
"@babel/generator": "^7.23.6",
"@plone/types": "workspace:*",
"@rollup/plugin-babel": "^6.0.4",
"@tanstack/react-query-devtools": "^5.37.1",
"@tanstack/react-query-devtools": "^5.59.0",
"@tanstack/router-devtools": "^1.34.9",
"@types/express": "^4.17.21",
"@types/react": "^18.2.55",
Expand Down
5 changes: 5 additions & 0 deletions apps/vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ This is a proof of concept of a [Vite](https://vite.dev/) build, using `@plone/c
This is intended to serve as both a playground for the development of both packages and as a demo of Plone using Vite.

It also uses [TanStack Router](https://tanstack.com/router/latest/docs/framework/react/overview) for its routing library.

> [!WARNING]
> This package or app is experimental.
> The community offers no support whatsoever for it.
> Breaking changes may occur without notice.
9 changes: 4 additions & 5 deletions packages/blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ It's one of the Plone frontend strategic packages and part of the headless CMS s

`@plone/blocks` is not part of Volto, and thus, is not used by it.

## EXPERIMENTAL

This package or app is experimental.
The community offers no support whatsoever for it.
Breaking changes may occur without notice.
> [!WARNING]
> This package or app is experimental.
> The community offers no support whatsoever for it.
> Breaking changes may occur without notice.
1 change: 1 addition & 0 deletions packages/client/news/6069.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade @tanstack/react-query @sneridagh
1 change: 1 addition & 0 deletions packages/client/news/6400.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for the `depth` parameter on `getNavigationQuery`. @ebrehault
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"wait-on": "^7.2.0"
},
"dependencies": {
"@tanstack/react-query": "^5.37.1",
"@tanstack/react-query": "^5.59.0",
"axios": "^1.6.7",
"debug": "4.3.4",
"query-string": "^9.0.0",
Expand Down
35 changes: 35 additions & 0 deletions packages/client/src/restapi/content/add.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { beforeEach } from 'vitest';
import { expect, test } from 'vitest';
import PloneClient from '../../client';
import { CreateContentArgs } from './add';
import { createContent } from '../content/add';

const cli = PloneClient.initialize({
apiPath: 'http://localhost:55001/plone',
Expand Down Expand Up @@ -46,6 +47,40 @@ describe('[POST] Content', () => {
expect(result.current.data?.title).toBe('My Page');
});

test('Hook - create content in path', async () => {
const myPageData = {
'@type': 'Document',
title: 'My Page',
};

await createContent({
path: '/',
data: myPageData,
config: cli.config,
});

const path = '/my-page';
const data: CreateContentArgs['data'] = {
'@type': 'Document',
title: 'My nested Page',
};

const { result } = renderHook(() => useMutation(createContentMutation()), {
wrapper: createWrapper(),
});

act(() => {
result.current.mutate({ path, data });
});

await waitFor(() => expect(result.current.isSuccess).toBe(true));

expect(result.current.data?.['@id']).toBe(
'http://localhost:55001/plone/my-page/my-nested-page',
);
expect(result.current.data?.title).toBe('My nested Page');
});

test('Hook - Successful - setup/tearingDown setup', async () => {
const path = '/';
const data: CreateContentArgs['data'] = {
Expand Down
Loading

0 comments on commit 4a0f3f5

Please sign in to comment.