Skip to content

Commit

Permalink
Merge branch 'main' into 5697-slate-img-paste-fix
Browse files Browse the repository at this point in the history
* main: (42 commits)
  Release 18.0.0-alpha.35
  Release @plone/types 1.0.0-alpha.16
  (fix): export getFieldURL from Url.js in helpers (plone#6100)
  Improve container detection, `config.settings.containerBlockTypes` is no longer needed (plone#6099)
  Support nested directories in public folder add-on sync folders both … (plone#6098)
  Release 18.0.0-alpha.34
  Add generated new declarations for a34, just in case (plone#6097)
  Release @plone/slate 18.0.0-alpha.13
  Release @plone/registry 1.6.0
  Release @plone/types 1.0.0-alpha.15
  Add support for reading the add-ons `tsconfig.json` paths (plone#6096)
  Fixes plone#6046 pass proper defaults to align and size fields of Image block (plone#6093)
  bug fix. relations control panel. Restrict eglible relation targets a… (plone#6092)
  Fix Uncaught RangeError: date value is not finite in DateTimeFormat.format (plone#6088)
  Add optional `token` parameter to ploneClient initialization (plone#6077)
  Blocks Layout Navigator (plone#5642)
  Fix internalUrl  Widget to Reflect Prop Changes via onChangeBlock (plone#6036)
  [types] Improve styleClassNameExtenders types, Icon component JSDoc t… (plone#6095)
  Fix link in pop-up RelationsMatrix.jsx (plone#6085)
  Fix deselecting lists. (plone#6080)
  ...
  • Loading branch information
sneridagh committed Jun 15, 2024
2 parents f98ddb0 + b629e5a commit 8c489ad
Show file tree
Hide file tree
Showing 144 changed files with 3,729 additions and 945 deletions.
1 change: 1 addition & 0 deletions docs/source/addons/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ myst:
i18n
best-practices
theme
public-folder
```

There are several advanced scenarios where we might want to have more control
Expand Down
29 changes: 29 additions & 0 deletions docs/source/addons/public-folder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
myst:
html_meta:
"description": "How to add static served files from your add-on to your build"
"property=og:description": "How to add static served files to the build from an add-on"
"property=og:title": "Add static files from your add-on to your build"
"keywords": "Volto, Plone, Semantic UI, CSS, Volto theme, add-on, static, assets, files, build"
---

# Add static files from your add-on to your build

In the Volto build process, you can add static files to your build, then serve them along with the compiled files.
Static files are not transformed or compiled by the build process.
They are served as is from the root of the Volto site.
It is useful to define static files such as the following:

- {file}`robots.txt`
- favicon files
- manifest files
- any other static files


## Procedure to include static files

Create a folder named `public` at the root of your add-on, and add the static files to it.
The build process will copy the files, taking into account all add-ons' defined order.
The build process copies first the static files defined by Volto, then the static files from add-ons as defined by their configuration order.
The last defined file overwrites any previously defined files.

2 changes: 2 additions & 0 deletions docs/source/client/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import ploneClient from '@plone/client';

const client = ploneClient.initialize({
apiPath: 'http://localhost:8080/Plone',
token: '', // Optional: auth_token to authorize the user
});
```

Expand Down Expand Up @@ -64,6 +65,7 @@ import { usePathname } from 'next/navigation';

const client = ploneClient.initialize({
apiPath: 'http://localhost:8080/Plone',
token: '', // Optional: auth_token to authorize the user
});

export default function Title() {
Expand Down
7 changes: 0 additions & 7 deletions docs/source/configuration/settings-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,4 @@ criticalCssPath
this file exists it is loaded and its content is embedded inline into the
generated HTML. By default this path is `public/critical.css`. See the
{doc}`../deploying/performance` section for more details.
extractScripts
An object that allows you to configure the insertion of scripts on the page
in some particular cases.
For the moment it admits only one property: `errorPages` whose value is a Boolean.
If `extractScripts.errorPages` is `true`, the JS will be inserted into the error page.
```
22 changes: 15 additions & 7 deletions docs/source/configuration/slots.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ You can also create custom predicate helpers.

```ts
export function RouteCondition(path: string, exact?: boolean) {
return ({ pathname }: { pathname: string }) =>
Boolean(matchPath(pathname, { path, exact }));
return ({ location }: { location: Location }) =>
Boolean(matchPath(location.pathname, { path, exact }));
}
```

Expand All @@ -246,21 +246,29 @@ It accepts the following parameters.

```ts
export function ContentTypeCondition(contentType: string[]) {
return ({ content }: { content: Content }) =>
contentType.includes(content['@type']);
return ({ content, location }: { content: Content; location: Location }) => {
return (
contentType.includes(content?.['@type']) ||
contentType.some((type) => {
return location.search.includes(`type=${encodeURIComponent(type)}`);
})
);
};
}
```

The `ContentTypeCondition` helper predicate allows you to render a slot when the given content type matches the current content type.
It accepts a list of possible content types.

It supports the `Add` form and can detect which content type you add.

##### Custom predicates

You can create your own predicate helpers to determine whether your slot component should render.
The `SlotRenderer` will pass down the current `content` and the `pathname` into your custom predicate helper.
The `SlotRenderer` will pass down the current `content`, the `location` object, and the current `navRoot` object into your custom predicate helper.
You can also tailor your own `SlotRenderer`s, or shadow the original `SlotRenderer`, to satisfy your requirements.

```{versionchanged} 18.0.0-alpha.33
Now `config.getSlots` in the configuration registry takes the argument `location` instead of `pathname`.
```

(slots-getSlot-label)=

Expand Down
58 changes: 58 additions & 0 deletions docs/source/release-notes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,64 @@ myst:

<!-- towncrier release notes start -->

## 18.0.0-alpha.35 (2024-06-13)

### Breaking

- Improve container detection, `config.settings.containerBlockTypes` is no longer needed @sneridagh [#6099](https://github.com/plone/volto/issues/6099)

### Bugfix

- Support nested directories in public folder add-on sync folders both in dev and build mode @sneridagh [#6098](https://github.com/plone/volto/issues/6098)
- export getFieldURL from Url.js in helpers @dobri1408 [#6100](https://github.com/plone/volto/issues/6100)

## 18.0.0-alpha.34 (2024-06-13)

### Feature

- Added blocks layout navigator @robgietema @sneridagh [#5642](https://github.com/plone/volto/issues/5642)
- Add support for reading the add-ons `tsconfig.json` paths and add them to the build resolve aliases @sneridagh [#6096](https://github.com/plone/volto/issues/6096)

### Bugfix

- Fix internalUrl Widget to Reflect Prop Changes via onChangeBlock @dorbi1408 @ichim-david [#6036](https://github.com/plone/volto/issues/6036)
- Add default 'l' and 'center' values to size and align fields of `Image` block.
This fixes data not having any value adding proper options to the `Image` block. @ichim-david [#6046](https://github.com/plone/volto/issues/6046)
- Fix public folder in dev mode, now it starts by default with the default Volto core defined public files @sneridagh [#6081](https://github.com/plone/volto/issues/6081)
- Fix link in pop-up in `RelationsMatrix.jsx`. @stevepiercy [#6085](https://github.com/plone/volto/issues/6085)
- Fix Uncaught RangeError: date value is not finite in DateTimeFormat.format. @mauritsvanrees [#6087](https://github.com/plone/volto/issues/6087)
- relations control panel. Restrict eglible relation targets according relation constraints of fields vocabulary. @ksuess [#6091](https://github.com/plone/volto/issues/6091)
- Better `Icon` component JSDoc typings @sneridagh [#6095](https://github.com/plone/volto/issues/6095)

## 18.0.0-alpha.33 (2024-06-06)

### Breaking

- Fix JavaScript events association on error pages. Also remove settings `config.settings.serverConfig.extractScripts.errorPages`. Now scripts are added to error pages, regardless of whether we are in production mode or not. @wesleybl [#6048](https://github.com/plone/volto/issues/6048)
- Breaking from the original slots implementation:
Now `config.getSlots` in the configuration registry takes the argument `location` instead of `pathname`.
This allows to have more expressive conditions, and fulfill the use case of the `Add` form.
@sneridagh [#6063](https://github.com/plone/volto/issues/6063)

### Feature

- Added object browser icon view @robgietema [#5279](https://github.com/plone/volto/issues/5279)
- Refactor TextWidget. @Tishasoumya-02 [#6020](https://github.com/plone/volto/issues/6020)
- Refactor IdWidget -@Tishasoumya-02 [#6027](https://github.com/plone/volto/issues/6027)
- The `ContentTypeCondition` now supports the `Add` form, and detects when you create a content type that is set in the condition. @sneridagh
Added a new `BodyClass` helper while adding a new content type of the form `is-adding-contenttype-mycontenttype`. @sneridagh [#6063](https://github.com/plone/volto/issues/6063)
- Add support for configurable `public` directory defined per add-on. @sneridagh [#6072](https://github.com/plone/volto/issues/6072)

### Bugfix

- Fix block chooser search is not focusable when clicked on add button @iRohitSingh [#5866](https://github.com/plone/volto/issues/5866)
- Fixed skiplink links not tracking focus correctly @JeffersonBledsoe [#5959](https://github.com/plone/volto/issues/5959)
- Remove left and right padding from _Event > Edit recurrence > Repeat on_ buttons when repeating for weekly or yearly events for big fonts, preventing overflow. @sabrina-bongiovanni [#6070](https://github.com/plone/volto/issues/6070)

### Internal

- Fix test script in monorepo root @sneridagh [#6051](https://github.com/plone/volto/issues/6051)

## 18.0.0-alpha.32 (2024-05-23)

### Feature
Expand Down
17 changes: 17 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ For this purpose, we have developed a {ref}`new utility <upgrade-guide-new-depen
It is mandatory that you run the utility to make Volto version 18.0.0-alpha.21 or later work in your projects.
This opens the door to use {term}`pnpm` in projects, too, and other goodies.

```{versionremoved} 18.0.0-alpha.33
The setting `config.settings.serverConfig.extractScripts.errorPages` has been removed.
```

Now scripts are added to error pages, regardless of whether they are in production mode.
This setting is no longer necessary.


(upgrade-guide-new-dependencies-synchronizer-label)=

### New dependencies synchronizer
Expand Down Expand Up @@ -224,6 +232,15 @@ There was a bug where a fieldset's generated value would be not valid.
This has been fixed by passing down the `id` instead of the `title` to the fieldset's value.
If your tests rely on the old fieldset's generated value for selecting fields, your tests could break, in which case you should amend them to use the updated fieldset's value instead.

### Changes from the original slots feature

Now `config.getSlots` in the configuration registry takes the argument `location` instead of `pathname`.
This allows more expressive conditions to fulfill the use case of the `Add` form.

### Improve container detection

The mechanism to detect if a block is a container or not has been improved and the config setting `config.settings.containerBlockTypes` is no longer needed, and core won't check for it anymore.

(volto-upgrade-guide-17.x.x)=

## Upgrading to Volto 17.x.x
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"start:project": "pnpm --filter plone run start",
"lint": "pnpm build:all && eslint --max-warnings=0 '{apps,packages}/**/*.{js,jsx,ts,tsx}'",
"lint:volto": "pnpm --filter @plone/volto run lint",
"test": "pnpm --filter @plone/volto run test:ci",
"test": "pnpm --filter @plone/volto run test",
"test:ci": "pnpm --filter @plone/volto run test:ci",
"i18n": "pnpm --filter @plone/volto run i18n",
"i18n:ci": "pnpm --filter @plone/volto i18n:ci",
"prettier": "prettier --check '{apps,packages}/**/*.{js,jsx,ts,tsx}'",
Expand Down
11 changes: 11 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@

<!-- towncrier release notes start -->

## 1.0.0-alpha.16 (2024-06-06)

### Bugfix

- Fixed querystring search query type @pnicolli [#6034](https://github.com/plone/volto/pull/6034)
- Fixed login mutation @sneridagh [#6053](https://github.com/plone/volto/pull/6053)

### Internal

- Remove custom test runner, using `vitest` config instead @sneridagh [#6056](https://github.com/plone/volto/pull/6056)

## 1.0.0-alpha.15 (2024-05-23)

### Breaking
Expand Down
1 change: 0 additions & 1 deletion packages/client/news/6034.bugfix

This file was deleted.

1 change: 1 addition & 0 deletions packages/client/news/6076.documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add documentation about optional `token` parameter for `ploneClient` initialization. @MAX-786
5 changes: 2 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
}
],
"license": "MIT",
"version": "1.0.0-alpha.15",
"version": "1.0.0-alpha.16",
"repository": {
"type": "git",
"url": "git@github.com:plone/volto.git"
Expand Down Expand Up @@ -48,8 +48,7 @@
"scripts": {
"build": "parcel build",
"build:force": "parcel build --no-cache",
"test": "node testRunner.js",
"vitest": "vitest",
"test": "vitest",
"check-ts": "tsc --project tsconfig.json",
"coverage": "vitest run --coverage --no-threads",
"dry-release": "release-it --dry-run",
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
loginQuery as _loginQuery,
loginMutation as _loginMutation,
login as _login,
} from './restapi/login/post';
import type { LoginArgs } from './restapi/login/post';
Expand Down Expand Up @@ -145,7 +145,7 @@ export default class PloneClient {
/*
Initialization queries
*/
loginQuery = queryWithConfig(_loginQuery, this.getConfig);
loginMutation = mutationWithConfig(_loginMutation, this.getConfig);

/*
Content queries
Expand Down Expand Up @@ -546,7 +546,7 @@ export default class PloneClient {
Initialization hooks
*/

useLogin = queryHookFromQuery(this.loginQuery);
useLogin = mutationHookFromMutation(this.loginMutation);

/*
Actions hooks
Expand Down
46 changes: 46 additions & 0 deletions packages/client/src/restapi/login/post.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { setup, teardown } from '../../resetFixture';
import { beforeEach } from 'vitest';
import { expect, test } from 'vitest';
import PloneClient from '../../client';
import { login, loginMutation } from './post';

const cli = PloneClient.initialize({
apiPath: 'http://localhost:55001/plone',
});

beforeEach(async () => {
await setup();
});

afterEach(async () => {
await teardown();
});

describe('Login', () => {
test('login request function', async () => {
const options = loginMutation({ config: cli.config });
expect(options.mutationKey).toEqual(['login']);
expect(options.mutationFn).toBeTypeOf('function');

const result = await login({
username: 'admin',
password: 'secret',
config: cli.config,
});
expect(result).toBeTypeOf('object');
expect(result.token).toBeTypeOf('string');
});

test('loginMutation options factories', async () => {
const options = loginMutation({ config: cli.config });
expect(options.mutationKey).toEqual(['login']);
expect(options.mutationFn).toBeTypeOf('function');

const login = await options.mutationFn({
username: 'admin',
password: 'secret',
});
expect(login).toBeTypeOf('object');
expect(login.token).toBeTypeOf('string');
});
});
12 changes: 8 additions & 4 deletions packages/client/src/restapi/login/post.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Login } from '@plone/types';
import { apiRequest, ApiRequestParams } from '../../API';
import { z } from 'zod';
import { PloneClientConfigSchema } from '../../validation/config';
import {
PloneClientConfig,
PloneClientConfigSchema,
} from '../../validation/config';

export const loginArgsSchema = z.object({
username: z.string(),
Expand Down Expand Up @@ -32,7 +35,8 @@ export const login = ({
return apiRequest('post', '/@login', options);
};

export const loginQuery = ({ username, password, config }: LoginArgs) => ({
queryKey: [username, 'login'],
queryFn: () => login({ username, password, config }),
export const loginMutation = ({ config }: { config: PloneClientConfig }) => ({
mutationKey: ['login'],
mutationFn: ({ username, password }: Omit<LoginArgs, 'config'>) =>
login({ username, password, config }),
});
Loading

0 comments on commit 8c489ad

Please sign in to comment.