Skip to content
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

[slots] @plone/slots first developments #6409

Merged
merged 79 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
eb1ae1a
Improve and group providers
sneridagh Jun 5, 2024
b2838b3
Polish
sneridagh Jun 5, 2024
a6c2c68
Changelog
sneridagh Jun 5, 2024
02ec9a6
Merge branch 'main' into betterproviders
sneridagh Jun 17, 2024
aab9efa
Complete the AppRouter with all the needed props
sneridagh Jun 17, 2024
f773a6a
Apply suggestions from code review
sneridagh Oct 14, 2024
bcc5c08
WIP
sneridagh Jun 18, 2024
b800ec8
WIP2
sneridagh Jun 18, 2024
2e568f4
Merge branch 'main' into betterproviders
sneridagh Oct 14, 2024
2960884
Fix remix data loading, update NextJS and remix versions
sneridagh Oct 14, 2024
5558b83
Ugrade vite TSR, fix useParams and useLocation types
sneridagh Oct 15, 2024
77b7ba9
Merge branch 'main' into betterproviders
sneridagh Oct 15, 2024
9686d57
Missing remix change
sneridagh Oct 15, 2024
2921cec
Fix TSR in SSR
sneridagh Oct 15, 2024
2aa4f36
READMEs to experimental packages
sneridagh Oct 15, 2024
f362f06
Fix ESlint
sneridagh Oct 15, 2024
f53004e
Ignore TS errors on build for now
sneridagh Oct 15, 2024
c2bf16a
WIP
sneridagh Oct 15, 2024
21de7e2
lock
sneridagh Oct 15, 2024
dab7b8e
Better admonitions format for experimental notices.
sneridagh Oct 16, 2024
905de9e
Return whole context instead of only useLocation
sneridagh Oct 16, 2024
1c8c099
Apply suggestions from code review
sneridagh Oct 16, 2024
2d3c2f2
Merge branch 'main' into betterproviders
sneridagh Oct 16, 2024
eb10805
Better branding here
sneridagh Oct 16, 2024
b97f9a9
Latest touches
sneridagh Oct 16, 2024
e07972f
Changelog
sneridagh Oct 16, 2024
a9802d2
Fix linting
sneridagh Oct 16, 2024
fb339b4
Apply suggestions from code review
sneridagh Oct 17, 2024
4a0f3f5
Merge branch 'betterproviders' into slots-base
sneridagh Oct 17, 2024
fa68738
Merge branch 'betterproviders' into slots-base
sneridagh Oct 17, 2024
e2aa8ba
Better SlotRenderer based on @pnicolli suggestion
sneridagh Oct 17, 2024
f320e47
Fix SlotRenderers
sneridagh Oct 17, 2024
9ffe034
Moved to a flat module package organization
sneridagh Oct 17, 2024
c3bad2b
Merge branch 'main' into slots-base
sneridagh Oct 17, 2024
5aede14
Merge branch 'main' into slots-base
sneridagh Oct 25, 2024
3bb80e9
Add storybook a bit of move around things
sneridagh Oct 26, 2024
4fa8e43
Merge branch 'main' into slots-base
sneridagh Oct 26, 2024
6cc4cb3
Logo component :) with Storybook
sneridagh Oct 26, 2024
8ca5305
WIP, Navigation
sneridagh Oct 27, 2024
91e0f1d
Merge branch 'main' into slots-base
sneridagh Oct 27, 2024
5b2db11
lock
sneridagh Oct 27, 2024
3accc47
WIP Navigation and Main slot
sneridagh Oct 28, 2024
699b79f
Merge branch 'main' into slots-base
sneridagh Oct 28, 2024
61ca316
Progress in contentarea and footer
sneridagh Oct 29, 2024
e47c771
Merge branch 'main' into slots-base
sneridagh Nov 1, 2024
d19bb68
Footer
sneridagh Nov 1, 2024
d7a3000
Move to full add-ons for slots and blocks
sneridagh Nov 1, 2024
cb9034a
Simple image component
sneridagh Nov 1, 2024
25719a8
Merge branch 'main' into slots-base
sneridagh Nov 2, 2024
f89b43b
Proper proxy for Remix app, proper @plone/registry config. Basic teaser.
sneridagh Nov 3, 2024
e3e70ec
Merge branch 'main' into slots-base
sneridagh Nov 6, 2024
2d02a4a
Proper data acquire in Remix PoC. Better name in vite-plugin. Add ful…
sneridagh Nov 7, 2024
3cde909
New theming package, fix routes in Remix, layers in theming, add reset.
sneridagh Nov 7, 2024
9976619
Add layers to the @plone/components styles
sneridagh Nov 8, 2024
f512b88
Move RenderBlocks and related to @plone/blocks
sneridagh Nov 8, 2024
403d318
Introduce @plone/theming
sneridagh Nov 8, 2024
1e11ff1
Docs 6472 tidy (#6475)
stevepiercy Nov 8, 2024
f062cee
Dutch Translations update. (#6476)
fredvd Nov 8, 2024
6f3bb71
fix locales
davisagli Nov 8, 2024
6532984
Add missing style Helmet serialization in the HTML component to make …
sneridagh Nov 11, 2024
f532b56
Release @plone/slate 18.0.1
sneridagh Nov 11, 2024
ee02c44
Release 18.1.0
sneridagh Nov 11, 2024
d356de3
Base styles, various improvements
sneridagh Nov 14, 2024
53cec1b
Improve deployment settings, add apiPath/internalApiPath detection
sneridagh Nov 18, 2024
c26f77c
Revamp the RR7 app, fix all the problems related to deployments.
sneridagh Nov 19, 2024
ad15951
Improve proxy, missing code from last commit
sneridagh Nov 19, 2024
83b1246
Merge branch 'main' into slots-base
sneridagh Nov 21, 2024
f47a8d0
Use a scale in Image and Teaser blocks for now
sneridagh Nov 24, 2024
c32e2c6
Merge branch 'main' into slots-base
sneridagh Dec 7, 2024
364b9b6
Fix lint on `@plone/registry/addons-loader`
sneridagh Dec 7, 2024
f815e15
Fix vite PoC
sneridagh Dec 8, 2024
2e2bb47
Merge branch 'main' into slots-base
sneridagh Dec 8, 2024
bae8ba7
Rename deployment tests, disable NextJS for now, make them conditionals
sneridagh Dec 8, 2024
7775c11
Added changelog and prepare all the new packages
sneridagh Dec 8, 2024
ceb876c
REmove pasta
sneridagh Dec 8, 2024
d569eb8
Fix tests, add PLONE_API_PATH=http://localhost:8080/Plone
sneridagh Dec 8, 2024
81df480
Disable Nextjs tests for now
sneridagh Dec 8, 2024
e1aea1a
Apply suggestions from code review
sneridagh Dec 8, 2024
5682b38
Merge branch 'main' into slots-base
sneridagh Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,49 @@
name: Deployment Tests
name: API-first story Tests
on: [push, pull_request]

env:
node-version: 22.x

jobs:
vitessr:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
config:
runs-on: ubuntu-latest
outputs:
ENVIRONMENT: ${{ steps.vars.outputs.ENVIRONMENT }}
STACK_NAME: ${{ steps.vars.outputs.STACK_NAME }}
nextjs: ${{ steps.filter.outputs.nextjs }}
remix: ${{ steps.filter.outputs.remix }}
rr7: ${{ steps.filter.outputs.rr7 }}
tss: ${{ steps.filter.outputs.tss }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set Env Vars
id: vars
run: |
ENVIRONMENT=${{ vars.LIVE_ENV }}
echo "ENVIRONMENT=${ENVIRONMENT}" >> $GITHUB_OUTPUT
echo "STACK_NAME=${ENVIRONMENT//./-}" >> $GITHUB_OUTPUT

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
nextjs:
- 'apps/nextjs/**'
- '.github/workflows/api-first.yml'
remix:
- 'apps/remix/**'
- '.github/workflows/api-first.yml'
rr7:
- 'apps/rr7/**'
- '.github/workflows/api-first.yml'
tss:
- 'apps/vite-ssr/**'
- '.github/workflows/api-first.yml'

tss:
if: ${{ needs.config.outputs.tss == 'true' }} && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
runs-on: ubuntu-latest
name: Vite SSR
timeout-minutes: 5
Expand Down Expand Up @@ -68,7 +105,8 @@ jobs:
run: make backend-docker-detached-stop

nextjs:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
# if: ${{ needs.config.outputs.nextjs == 'true' }} && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
if: false
runs-on: ubuntu-latest
name: Next.JS
timeout-minutes: 5
Expand Down Expand Up @@ -130,7 +168,7 @@ jobs:
run: make backend-docker-detached-stop

remix:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
if: ${{ needs.config.outputs.remix == 'true' }} && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
runs-on: ubuntu-latest
name: Remix
timeout-minutes: 5
Expand Down Expand Up @@ -174,7 +212,63 @@ jobs:
run: pnpm --filter plone-remix build

- name: Start server
run: nohup pnpm --filter plone-remix start:prod &
run: PLONE_API_PATH=http://localhost:8080/Plone nohup pnpm --filter plone-remix start:prod &

- name: Wait
run: packages/scripts/node_modules/.bin/wait-on --httpTimeout 20000 http-get://127.0.0.1:8080/Plone

- name: Run tests
run: node packages/scripts/check_deployment.js

- name: Stop backend
run: make backend-docker-detached-stop

rr7:
if: ${{ needs.config.outputs.rr7 == 'true' }} && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name)
runs-on: ubuntu-latest
name: ReactRouter 7
timeout-minutes: 5
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4

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

- name: Enable corepack
run: corepack enable

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build dependencies
run: pnpm build:all

- name: Start backend
run: make backend-docker-detached-start

- name: Build
run: pnpm --filter plone-rr7 build

- name: Start server
run: PLONE_API_PATH=http://localhost:8080/Plone nohup pnpm --filter plone-rr7 start:prod &

- name: Wait
run: packages/scripts/node_modules/.bin/wait-on --httpTimeout 20000 http-get://127.0.0.1:8080/Plone
Expand Down
32 changes: 31 additions & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install towncrier
run: pip install towncrier

- uses: dorny/paths-filter@v2
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
Expand All @@ -42,6 +42,12 @@ jobs:
- 'packages/scripts/**'
voltoSlate:
- 'packages/volto-slate/**'
blocks:
- 'packages/blocks/**'
slots:
- 'packages/slots/**'
theming:
- 'packages/theming/**'
wrongNews:
- added|modified: 'news/**'

Expand Down Expand Up @@ -120,6 +126,30 @@ jobs:
env:
BASE_BRANCH: ${{ github.base_ref }}

- name: Blocks changelog check
if: steps.filter.outputs.blocks == 'true'
run: |
git fetch --no-tags origin main
towncrier check --compare-with origin/main --dir packages/blocks
env:
BASE_BRANCH: ${{ github.base_ref }}

- name: Slots changelog check
if: steps.filter.outputs.slots == 'true'
run: |
git fetch --no-tags origin main
towncrier check --compare-with origin/main --dir packages/slots
env:
BASE_BRANCH: ${{ github.base_ref }}

- name: Theming changelog check
if: steps.filter.outputs.theming == 'true'
run: |
git fetch --no-tags origin main
towncrier check --compare-with origin/main --dir packages/theming
env:
BASE_BRANCH: ${{ github.base_ref }}

- name: Wrong location of news changelog check
if: steps.filter.outputs.wrongNews == 'true'
run: echo "News items should be moved from the repository root to the appropriate package root in `packages/package-name`." && exit 1
Expand Down
3 changes: 3 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
dist
docs
node_modules
packages/registry/lib
1 change: 1 addition & 0 deletions apps/remix/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules
/build
/public/build
.env
.registry.loader.js
2 changes: 1 addition & 1 deletion apps/remix/app/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ploneClient from '@plone/client';
import config from '@plone/registry';

const cli = ploneClient.initialize({
apiPath: config.settings.apiPath,
apiPath: config.settings.internalApiPath || config.settings.apiPath,
});

export { cli as ploneClient };
28 changes: 14 additions & 14 deletions apps/remix/app/config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import config from '@plone/registry';
import { blocksConfig, slate } from '@plone/blocks';

const settings = {
apiPath: 'http://localhost:8080/Plone',
slate,
};

// @ts-expect-error We need to fix typing
config.set('settings', settings);

// @ts-expect-error We need to fix typing
config.set('blocks', { blocksConfig });

export default config;
import applyAddonConfiguration from '@plone/registry/addons-loader';

export default function install() {
applyAddonConfiguration(config);
config.settings.apiPath =
process.env.PLONE_API_PATH || 'http://localhost:3000';
config.settings.internalApiPath = process.env.PLONE_INTERNAL_API_PATH || '';
console.log('API_PATH is:', config.settings.apiPath);
console.log(
'INTERNAL_API_PATH is:',
config.settings.internalApiPath || 'not set',
);
return config;
}
34 changes: 14 additions & 20 deletions apps/remix/app/routes/_index.tsx → apps/remix/app/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ import {
dehydrate,
QueryClient,
HydrationBoundary,
useQueryClient,
useQuery,
} from '@tanstack/react-query';
import { flattenToAppURL } from '../utils';
import { flattenToAppURL } from './utils';
import { useLoaderData, useLocation } from '@remix-run/react';
import { usePloneClient } from '@plone/providers';
import { Breadcrumbs, RenderBlocks } from '@plone/components';
import config from '@plone/registry';
import { ploneClient } from '../client';
// import { Breadcrumbs, RenderBlocks } from '@plone/components';
// import config from '@plone/registry';
import { ploneClient } from './client';
import App from '@plone/slots/components/App';

export const meta: MetaFunction = () => {
return [
Expand All @@ -23,7 +25,7 @@ export const meta: MetaFunction = () => {
];
};

const expand = ['breadcrumbs', 'navigation'];
const expand = ['navroot', 'breadcrumbs', 'navigation'];

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const loader = async ({ params, request }: LoaderFunctionArgs) => {
Expand All @@ -40,39 +42,31 @@ export const loader = async ({ params, request }: LoaderFunctionArgs) => {
const { getContentQuery } = ploneClient;

await queryClient.prefetchQuery(
getContentQuery({ path: flattenToAppURL(request.url), expand }),
getContentQuery({ path: flattenToAppURL(request.url || '/'), expand }),
);

return json({ dehydratedState: dehydrate(queryClient) });
};

function Page() {
const { getContentQuery } = usePloneClient();
const pathname = useLocation().pathname;
const { data } = useQuery(getContentQuery({ path: pathname, expand }));
const { pathname } = useLocation();
const { data } = useQuery(getContentQuery({ path: pathname || '/', expand }));

if (!data) return null;
return (
<>
<Breadcrumbs
items={data['@components'].breadcrumbs.items || []}
root={data['@components'].breadcrumbs.root}
includeRoot
/>
<RenderBlocks
content={data}
blocksConfig={config.blocks.blocksConfig}
pathname="/"
/>
<App content={data} location={{ pathname: '/' }} />
</>
);
}

export default function Index() {
export default function Content() {
const { dehydratedState } = useLoaderData<typeof loader>();
const queryClient = useQueryClient();

return (
<HydrationBoundary state={dehydratedState}>
<HydrationBoundary state={dehydratedState} queryClient={queryClient}>
<Page />
</HydrationBoundary>
);
Expand Down
5 changes: 3 additions & 2 deletions apps/remix/app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal` ✨
* For more information, see https://remix.run/file-conventions/entry.client
*/

import install from './config';
import { RemixBrowser } from '@remix-run/react';
import { startTransition, StrictMode } from 'react';
import { hydrateRoot } from 'react-dom/client';
import './config';

install();

startTransition(() => {
hydrateRoot(
Expand Down
4 changes: 3 additions & 1 deletion apps/remix/app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import { createReadableStreamFromReadable } from '@remix-run/node';
import { RemixServer } from '@remix-run/react';
import { isbot } from 'isbot';
import { renderToPipeableStream } from 'react-dom/server';
import './config';
import install from './config';

const ABORT_DELAY = 5_000;

install();

export default function handleRequest(
request: Request,
responseStatusCode: number,
Expand Down
11 changes: 7 additions & 4 deletions apps/remix/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ import PloneClient from '@plone/client';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

import '@plone/components/dist/basic.css';
import '@plone/slots/main.css';
import { flattenToAppURL } from './utils';
import { PloneProvider } from '@plone/providers';

import config from '@plone/registry';

export const links: LinksFunction = () => [
...(cssBundleHref ? [{ rel: 'stylesheet', href: cssBundleHref }] : []),
];

function useHrefLocal(to: string) {
return useHref(flattenToAppURL(to));
}

export default function App() {
const [queryClient] = useState(
() =>
Expand All @@ -55,6 +53,10 @@ export default function App() {
return RRNavigate(flattenToAppURL(to));
};

function useHrefLocal(to: string) {
return useHref(flattenToAppURL(to));
}

return (
<html lang="en">
<head>
Expand All @@ -71,6 +73,7 @@ export default function App() {
useParams={useParams}
useHref={useHrefLocal}
navigate={navigate}
flattenToAppURL={flattenToAppURL}
>
<Outlet />
<ScrollRestoration />
Expand Down
Loading
Loading