Skip to content

Commit

Permalink
Merge branch 'main' into a11y-notes
Browse files Browse the repository at this point in the history
  • Loading branch information
stevepiercy authored Oct 3, 2024
2 parents 6ecb214 + 52a23bd commit f40f7c0
Show file tree
Hide file tree
Showing 23 changed files with 103 additions and 48 deletions.
4 changes: 2 additions & 2 deletions docs/source/contributing/developing-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ Volto has the following folder structure.
```


## Development pre-requisites
## Development prerequisites

To set up a Volto core development environment, your system must satisfy the following pre-requisites.
To set up a Volto core development environment, your system must satisfy the following prerequisites.

```{include} ./install-operating-system.md
```
Expand Down
2 changes: 1 addition & 1 deletion docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ If you shadowed the module {file}`packages/volto/src/helpers/FormValidation/Form
This prop must be assigned with the new prop passed down from the blocks engine `blocksErrors`.
If not passed down, the block can't display any field validation error.

```tsx
```jsx
// More component code above here

const {
Expand Down
1 change: 1 addition & 0 deletions packages/client/news/6349.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed client copy mutation, cleanup up move mutation for consistency @pnicolli
4 changes: 2 additions & 2 deletions packages/client/src/restapi/copymove/copy.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('[POST] Copy', () => {
});

act(() => {
result.current.mutate({ data: copyData });
result.current.mutate({ path: '/', data: copyData });
});

await waitFor(() => expect(result.current.isSuccess).toBe(true));
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('[POST] Copy', () => {
});

act(() => {
result.current.mutate({ data: copyMultipleData });
result.current.mutate({ path: '/', data: copyMultipleData });
});

await waitFor(() => expect(result.current.isSuccess).toBe(true));
Expand Down
28 changes: 13 additions & 15 deletions packages/client/src/restapi/copymove/copy.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
import { z } from 'zod';
import { ApiRequestParams, apiRequest } from '../../API';
import {
PloneClientConfig,
PloneClientConfigSchema,
} from '../../validation/config';
import { PloneClientConfig } from '../../validation/config';
import { copyMoveDataSchema as copyDataSchema } from '../../validation/copymove';
import { CopyMoveResponse as CopyResponse } from '@plone/types';

export const copyArgsSchema = z.object({
data: copyDataSchema,
config: PloneClientConfigSchema,
});

export type CopyArgs = z.infer<typeof copyArgsSchema>;
export type CopyArgs = z.infer<typeof copyDataSchema> & {
config: PloneClientConfig;
};

export const copy = async ({
path,
data,
config,
}: CopyArgs): Promise<CopyResponse> => {
const validatedArgs = copyArgsSchema.parse({
const validatedArgs = copyDataSchema.parse({
path,
data,
config,
});

const options: ApiRequestParams = {
config,
data: validatedArgs.data,
config: validatedArgs.config,
};

return apiRequest('post', '/@copy', options);
const copyPath = `${validatedArgs.path}/@copy`;

return apiRequest('post', copyPath, options);
};

export const copyMutation = ({ config }: { config: PloneClientConfig }) => ({
mutationKey: ['post', 'copy'],
mutationFn: ({ data }: Omit<CopyArgs, 'config'>) => copy({ data, config }),
mutationFn: ({ path, data }: Omit<CopyArgs, 'config'>) =>
copy({ path, data, config }),
});
22 changes: 7 additions & 15 deletions packages/client/src/restapi/copymove/move.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,29 @@
import { z } from 'zod';
import { ApiRequestParams, apiRequest } from '../../API';
import {
PloneClientConfig,
PloneClientConfigSchema,
} from '../../validation/config';
import { PloneClientConfig } from '../../validation/config';
import { copyMoveDataSchema as moveDataSchema } from '../../validation/copymove';
import { CopyMoveResponse as MoveResponse } from '@plone/types';

export const MoveArgsSchema = z.object({
path: z.string(),
data: moveDataSchema,
config: PloneClientConfigSchema,
});

export type MoveArgs = z.infer<typeof MoveArgsSchema>;
export type MoveArgs = z.infer<typeof moveDataSchema> & {
config: PloneClientConfig;
};

export const move = async ({
path,
data,
config,
}: MoveArgs): Promise<MoveResponse> => {
const validatedArgs = MoveArgsSchema.parse({
const validatedArgs = moveDataSchema.parse({
path,
data,
config,
});

const options: ApiRequestParams = {
config,
data: validatedArgs.data,
config: validatedArgs.config,
};

const movePath = `/${validatedArgs.path}/@move`;
const movePath = `${validatedArgs.path}/@move`;

return apiRequest('post', movePath, options);
};
Expand Down
5 changes: 4 additions & 1 deletion packages/client/src/validation/copymove.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { z } from 'zod';

export const copyMoveDataSchema = z.object({
source: z.union([z.string(), z.array(z.string())]),
path: z.string(),
data: z.object({
source: z.union([z.string(), z.array(z.string())]),
}),
});
1 change: 1 addition & 0 deletions packages/scripts/news/6354.documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added the configuration for VSCode not to reformat Markdown and MyST files. @aadityaforwork
16 changes: 12 additions & 4 deletions packages/scripts/vscodesettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ if (fs.existsSync('.vscode')) {

if (!vscodeSettingsJSON['eslint.workingDirectories']) {
vscodeSettingsJSON['eslint.workingDirectories'] = [{ mode: 'auto' }];
}

fs.writeFileSync(
'.vscode/settings.json',
`${stringify(vscodeSettingsJSON, null, 2)}`,
);
if (!vscodeSettingsJSON['[markdown]']) {
vscodeSettingsJSON['[markdown]'] = {
'editor.formatOnSave': false,
};
} else {
vscodeSettingsJSON['[markdown]']['editor.formatOnSave'] = false;
}

fs.writeFileSync(
'.vscode/settings.json',
`${stringify(vscodeSettingsJSON, null, 2)}`,
);
1 change: 1 addition & 0 deletions packages/volto-slate/news/6293.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fetch `user` before pass it to the `restricted` function of the block settings. @wesleybl
4 changes: 2 additions & 2 deletions packages/volto-slate/src/blocks/Text/SlashMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { filter, isEmpty } from 'lodash';
import { Menu } from 'semantic-ui-react';
import { useIntl, FormattedMessage } from 'react-intl';
import { Icon } from '@plone/volto/components';
import { useSelector } from 'react-redux';
import { useUser } from '@plone/volto/hooks';

const emptySlateBlock = () => ({
value: [
Expand Down Expand Up @@ -111,7 +111,7 @@ const PersistentSlashMenu = ({ editor }) => {
} = props;
const disableNewBlocks = data?.disableNewBlocks || detached;

const user = useSelector((state) => state.users?.user);
const user = useUser();

const [slashMenuSelected, setSlashMenuSelected] = React.useState(0);

Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/6259.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed build style classnames in edit mode. Also use buildStyleClassNamesExtenders. @giuliaghisini
1 change: 1 addition & 0 deletions packages/volto/news/6293.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fetch `user` before pass it to the `restricted` function of the block settings. @wesleybl
1 change: 1 addition & 0 deletions packages/volto/news/6313.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed toolbar buttons not having a focus outline. @JeffersonBledsoe
1 change: 1 addition & 0 deletions packages/volto/news/6362.documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed spelling of prerequisites. @stevepiercy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { useUser } from '@plone/volto/hooks';
import PropTypes from 'prop-types';
import { filter, map, groupBy, isEmpty } from 'lodash';
import { Accordion, Button } from 'semantic-ui-react';
Expand Down Expand Up @@ -36,7 +36,7 @@ const BlockChooser = ({
contentType,
}) => {
const intl = useIntl();
const user = useSelector((state) => state.users?.user);
const user = useUser();
const hasAllowedBlocks = !isEmpty(allowedBlocks);

const filteredBlocksConfig = filter(blocksConfig, (item) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Provider } from 'react-intl-redux';
import configureStore from 'redux-mock-store';
import BlockChooser from './BlockChooser';
import config from '@plone/volto/registry';
import jwt from 'jsonwebtoken';

const blockSVG = {};

Expand Down Expand Up @@ -121,6 +122,9 @@ const store = mockStore({
locale: 'en',
messages: {},
},
userSession: {
token: jwt.sign({ fullname: 'John Doe' }, 'secret'),
},
});

describe('BlocksChooser', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
blockHasValue,
buildStyleClassNamesFromData,
buildStyleObjectFromData,
buildStyleClassNamesExtenders,
} from '@plone/volto/helpers';
import dragSVG from '@plone/volto/icons/drag.svg';
import { Button } from 'semantic-ui-react';
Expand Down Expand Up @@ -61,7 +62,12 @@ const EditBlockWrapper = (props) => {
? data.required
: includes(config.blocks.requiredBlocks, type);

const classNames = buildStyleClassNamesFromData(data.styles);
let classNames = buildStyleClassNamesFromData(data.styles);
classNames = buildStyleClassNamesExtenders({
block,
data,
classNames,
});
const style = buildStyleObjectFromData(data.styles);

// We need to merge the StyleWrapper styles with the draggable props from b-D&D
Expand Down
1 change: 1 addition & 0 deletions packages/volto/src/hooks/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as useClipboard } from '@plone/volto/hooks/clipboard/useClipboard';
export { useClient } from '@plone/volto/hooks/client/useClient';
export { default as useUser } from '@plone/volto/hooks/user/useUser';
23 changes: 23 additions & 0 deletions packages/volto/src/hooks/user/useUser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import jwtDecode from 'jwt-decode';
import { getUser } from '@plone/volto/actions';

const useUser = () => {
const users = useSelector((state) => state.users);
const user = users?.user;
const userId = useSelector((state) =>
state.userSession.token ? jwtDecode(state.userSession.token).sub : '',
);
const dispatch = useDispatch();

useEffect(() => {
if (!user?.id && users?.get.loading === false) {
dispatch(getUser(userId));
}
}, [dispatch, userId, user, users?.get.loading]);

return user;
};

export default useUser;
16 changes: 14 additions & 2 deletions packages/volto/theme/themes/pastanaga/extras/toolbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,28 @@ body:not(.has-sidebar):not(.has-sidebar-collapsed) {

.toolbar-content,
.toolbar {
button {
button,
a {
// Default reset for button
padding: 0;
border: 0;
background: transparent;
box-shadow: unset !important; // Some buttons have double outlines due to default styles. Safely disable those styles here.
cursor: pointer;
text-align: initial;

svg {
display: block; // SVGs are inline by default, causing the spacing to be odd
margin: 0; // Some SVGs have margin set by default styles.
}

&:focus-visible {
outline: 1px auto;
outline: 2px solid black;
outline-offset: 2px;

&:has(.circled) {
border-radius: 50%;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions styles/Vocab/Plone/reject.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[^.]js
NodeJS
[Pp]re-requisite

0 comments on commit f40f7c0

Please sign in to comment.