-
-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial push of the Plone 7 base package #6599
Draft
sneridagh
wants to merge
17
commits into
main
Choose a base branch
from
revolto
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2353602
WIP
sneridagh 2a6282b
Initial push for the Plone 7 app package
sneridagh b7ac12a
Added changelog check
sneridagh b768340
Changelog
sneridagh 634798c
New react router package
sneridagh 0ccc7ea
Tests
sneridagh 1c33595
Merge branch 'main' into revolto
sneridagh 93a7754
Change the folder name to voltotng :)
sneridagh 2e64350
Routes from add-ons PoC
sneridagh 8320b3c
Fix lint for @plone/react-router, adding it to the build
sneridagh 81e2c44
ESlint import no unresolved
sneridagh 20d4dfa
Added Cypress tests for Plone 7
sneridagh 712f3cd
Fix lint
sneridagh 7a89823
Changelog
sneridagh 609dfe3
Fix command line
sneridagh 765e6e8
Fix dep on wait-on
sneridagh a9ac42d
Remove dangling test code
sneridagh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
dist/ |
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,6 @@ | ||
news | ||
towncrier.toml | ||
.changelog.draft | ||
node_modules/ | ||
.release-it.json | ||
.eslintrc.js |
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,28 @@ | ||
{ | ||
"plugins": { | ||
"../scripts/prepublish.js": {} | ||
}, | ||
"hooks": { | ||
"after:bump": [ | ||
"pipx run towncrier build --draft --yes --version ${version} > .changelog.draft && pipx run towncrier build --yes --version ${version}", | ||
"pnpm build:force" | ||
], | ||
"after:release": "rm .changelog.draft" | ||
}, | ||
"npm": { | ||
"publish": false | ||
}, | ||
"git": { | ||
"changelog": "pipx run towncrier build --draft --yes --version 0.0.0", | ||
"requireUpstream": false, | ||
"requireCleanWorkingDir": false, | ||
"commitMessage": "Release @plone/react-router ${version}", | ||
"tagName": "plone-react-router-${version}", | ||
"tagAnnotation": "Release @plone/react-router ${version}" | ||
}, | ||
"github": { | ||
"release": true, | ||
"releaseName": "@plone/react-router ${version}", | ||
"releaseNotes": "cat .changelog.draft" | ||
} | ||
} |
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,59 @@ | ||
# @plone/providers Release Notes | ||
|
||
<!-- Do *NOT* add new change log entries to this file. | ||
You should create a file in the news directory instead. | ||
For helpful instructions, please see: | ||
https://6.docs.plone.org/contributing/index.html#contributing-change-log-label | ||
--> | ||
|
||
<!-- towncrier release notes start --> | ||
|
||
## 1.0.0-alpha.6 (2024-11-21) | ||
|
||
### Feature | ||
|
||
- Update RAC to 1.5.0 @sneridagh [#6498](https://github.com/plone/volto/issues/6498) | ||
|
||
## 1.0.0-alpha.5 (2024-11-05) | ||
|
||
### Internal | ||
|
||
- Improve packaging. @sneridagh | ||
|
||
## 1.0.0-alpha.4 (2024-11-05) | ||
|
||
### Internal | ||
|
||
- Bump local `typescript` version. @sneridagh [#6461](https://github.com/plone/volto/issues/6461) | ||
- Replace `parcel` with `tsup`. Better types, better tsconfig. Move to ESM. @sneridagh [#6468](https://github.com/plone/volto/issues/6468) | ||
|
||
## 1.0.0-alpha.3 (2024-10-18) | ||
|
||
## 1.0.0-alpha.2 (2024-10-18) | ||
|
||
### Breaking | ||
|
||
- Improve and group providers. @sneridagh | ||
Breaking: | ||
- The interface of the providers has changed. Please check the new one, and adapt your apps accordingly. [#6069](https://github.com/plone/volto/issues/6069) | ||
|
||
### Internal | ||
|
||
- Update typescript and vitest everywhere @sneridagh [#6407](https://github.com/plone/volto/issues/6407) | ||
|
||
## 1.0.0-alpha.1 (2024-05-23) | ||
|
||
### Internal | ||
|
||
- Cleanup imports in RouterLocation provider @pnicolli [#6029](https://github.com/plone/volto/issues/6029) | ||
|
||
## 1.0.0-alpha.0 (2024-05-13) | ||
|
||
### Feature | ||
|
||
- Initial implementation @sneridagh [#5887](https://github.com/plone/volto/issues/5887) | ||
|
||
### Internal | ||
|
||
- Improvements to the monorepo setup with utilities, especially ESLint. Build cached option to speedup operations. @sneridagh [#5969](https://github.com/plone/volto/issues/5969) | ||
- Saner defaults for building deps, switch default to cached, add `build:force` command @sneridagh [#5980](https://github.com/plone/volto/issues/5980) |
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,188 @@ | ||
# `@plone/providers` | ||
|
||
This package contains utility providers for Plone React components. | ||
The main purpose is to provide dependency injection of common required artifacts needed by any app. | ||
These artifacts include: | ||
- Router related | ||
- Plone Client | ||
- URL handling methods | ||
|
||
> [!WARNING] | ||
> This package or app is experimental. | ||
> The community offers no support whatsoever for it. | ||
> Breaking changes may occur without notice. | ||
|
||
## `PloneProvider` | ||
|
||
It provides all the necessary artifacts that an app can need grouped in a single provider. | ||
|
||
```ts | ||
interface PloneProvider { | ||
ploneClient: InstanceType<typeof PloneClient>; | ||
queryClient: QueryClient; | ||
useLocation: () => Location | undefined; | ||
useParams: (opts?: any) => Record<string, string>; | ||
navigate: (path: string) => void; | ||
useHref: (to: string, options?: any) => string; | ||
flattenToAppURL: (path: string | undefined) => string | undefined; | ||
} | ||
``` | ||
|
||
It should be instantiated at the top of your app. | ||
You have to provide the required props depending on the framework and the router used. | ||
This is the example for a Next.js app. | ||
Please refer to the {file}`apps` folder of the Volto repository for more examples of the usage of `PloneProvider` in different React frameworks. | ||
|
||
```tsx | ||
'use client'; | ||
import React from 'react'; | ||
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 { flattenToAppURL } from './utils'; | ||
import config from './config'; | ||
|
||
// Custom hook to unify the location object between NextJS and Plone | ||
function useLocation() { | ||
let pathname = usePathname(); | ||
let 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 }) => { | ||
// Creating the clients at the file root level makes the cache shared | ||
// between all requests and means _all_ data gets passed to _all_ users. | ||
// Besides being bad for performance, this also leaks any sensitive data. | ||
// We use this pattern to ensure that every client gets its own clients | ||
const [queryClient] = React.useState( | ||
() => | ||
new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
// With SSR, we usually want to set some default staleTime | ||
// above 0 to avoid refetching immediately on the client | ||
staleTime: 60 * 1000, | ||
}, | ||
}, | ||
}), | ||
); | ||
|
||
const [ploneClient] = React.useState(() => | ||
PloneClient.initialize({ | ||
apiPath: config.settings.apiPath, | ||
}), | ||
); | ||
|
||
const router = useRouter(); | ||
|
||
return ( | ||
<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> | ||
); | ||
}; | ||
|
||
export default Providers; | ||
|
||
``` | ||
|
||
You can use it anywhere in your app by using the hook `usePloneProvider`. | ||
|
||
```tsx | ||
import { usePloneProvider } from '@plone/providers'; | ||
|
||
const { ploneClient } = usePloneProvider() | ||
``` | ||
|
||
Alternatively, you can use it in any other context property. | ||
|
||
```tsx | ||
const { navigate } = usePloneProvider() | ||
``` | ||
|
||
## `PloneClientProvider` | ||
|
||
`PloneProvider` in a group of other smaller providers. | ||
You can also instantiate and use them as standalone providers. | ||
However, you should do this only if the framework has some limitation on using the bulk `PloneClientProvider`. | ||
|
||
The following snippets show its usage. | ||
First, instantiate the provider. | ||
|
||
```ts | ||
export type PloneClientProviderProps = { | ||
client: InstanceType<typeof PloneClient>; | ||
queryClient: QueryClient; | ||
children?: React.ReactNode; | ||
}; | ||
``` | ||
|
||
Second, use its related hook through either of the following examples. | ||
|
||
```tsx | ||
import { usePloneClient } from '@plone/providers'; | ||
|
||
const client = usePloneClient() | ||
``` | ||
|
||
or | ||
|
||
```tsx | ||
const { getContentQuery } = usePloneClient() | ||
``` | ||
|
||
## `AppRouterProvider` | ||
|
||
This provider is included also in `PloneProvider`. | ||
You can also instantiate and use it as a standalone provider. | ||
However, you should do this only if the framework has some limitation on using the bulk `PloneClientProvider`. | ||
|
||
The following code example shows its usage. | ||
|
||
```ts | ||
interface AppRouterProps { | ||
useLocation: () => Location | undefined; | ||
useParams: (opts?: any) => Record<string, string>; | ||
navigate: (path: string) => void; | ||
useHref?: (to: string, options?: any) => string; | ||
flattenToAppURL: (path: string | undefined) => string | undefined; | ||
children: ReactNode; | ||
} | ||
``` | ||
|
||
The following code sample shows its related hook. | ||
|
||
```tsx | ||
import { useAppRouter } from '@plone/providers'; | ||
|
||
const { useLocation } = useAppRouter() | ||
``` |
File renamed without changes.
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,77 @@ | ||
{ | ||
"name": "@plone/react-router", | ||
"description": "Plone React Router integration package", | ||
"maintainers": [ | ||
{ | ||
"name": "Plone Foundation", | ||
"url": "https://plone.org" | ||
} | ||
], | ||
"funding": "https://github.com/sponsors/plone", | ||
"license": "MIT", | ||
"version": "0.0.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/plone/volto.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/plone/volto/issues" | ||
}, | ||
"homepage": "https://plone.org", | ||
"keywords": [ | ||
"volto", | ||
"plone", | ||
"plone6", | ||
"react", | ||
"helpers" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"type": "module", | ||
"files": [ | ||
"dist", | ||
"README.md" | ||
], | ||
"main": "./dist/index.js", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"import": "./dist/index.js", | ||
"default": "./dist/index.cjs" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"build:force": "tsup", | ||
"check:exports": "attw --pack .", | ||
"test": "vitest", | ||
"dry-release": "release-it --dry-run", | ||
"release": "release-it", | ||
"release-major-alpha": "release-it major --preRelease=alpha", | ||
"release-alpha": "release-it --preRelease=alpha" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0", | ||
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"react-dom": { | ||
"optional": true | ||
} | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "^0.16.4", | ||
"@plone/types": "workspace:*", | ||
"@react-router/dev": "7.1.2", | ||
"@types/node": "22.10.7", | ||
"@types/react": "^18", | ||
"@types/react-dom": "^18", | ||
"release-it": "17.1.1", | ||
"tsconfig": "workspace:*", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.6.3", | ||
"vitest": "^2.1.3" | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you pronounce that? 😝
I still like "DEVOlto" better. Are we not men? We are DEVOlto!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stevepiercy tip: you don't, because you'll never need to pronounce it. ;) We are bad ass trekkies, at most :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sneridagh looks like Klingon to me.