Skip to content

Commit

Permalink
Merge branch 'main' into refactor-register
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishasoumya-02 authored Aug 7, 2024
2 parents 6586eb5 + ac85e20 commit ba6a04c
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/source/contributing/acceptance-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ dispatch(
```
```{seealso}
[Testing Redux Store](https://www.cypress.io/blog/2018/11/14/testing-redux-store/)
[Testing Redux Store](https://www.cypress.io/blog/testing-redux-store)
```
Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/6186.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved URL regex to allow non-public or intranet URLs, such as `https://intranet/` or `file://server/share`. @mamico
1 change: 1 addition & 0 deletions packages/volto/news/6235.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Return a 302 response for server-side rendering of the Link view for unauthenticated users. @davisagli
1 change: 1 addition & 0 deletions packages/volto/news/6237.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix loading of .cjs in webpack. @davisagli
1 change: 1 addition & 0 deletions packages/volto/news/6239.documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix redirect of link in documentation to testing Redux store blog post. @stevepiercy
2 changes: 2 additions & 0 deletions packages/volto/news/6240.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fixed change of form.ui.hovered when editing blocks, because if you have a FormBlock component inside another one,
onMouseOver fires for all stacked blocks and you cannot use the nested form. @giuliaghisini
2 changes: 1 addition & 1 deletion packages/volto/razzle.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ const defaultModify = ({
// Don't load SVGs from ./src/icons with file-loader
const fileLoader = config.module.rules.find(fileLoaderFinder);
fileLoader.exclude = [
/\.(config|variables|overrides)$/,
/\.(config|variables|overrides|cjs)$/,
/icons\/.*\.svg$/,
...fileLoader.exclude,
];
Expand Down
32 changes: 24 additions & 8 deletions packages/volto/src/components/manage/Blocks/Block/Edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ export class Edit extends Component {
{Block !== null ? (
<div
role="presentation"
onMouseOver={() => {
onMouseEnter={(e) => {
e.preventDefault();
e.stopPropagation();
if (this.props.hovered !== this.props.id) {
this.props.setUIState({ hovered: this.props.id });
}
}}
onFocus={() => {
onFocus={(e) => {
// TODO: This `onFocus` steals somehow the focus from the slate block
// we have to investigate why this is happening
// Apparently, I can't see any difference in the behavior
Expand All @@ -158,7 +160,11 @@ export class Edit extends Component {
// this.props.setUIState({ hovered: this.props.id });
// }
}}
onMouseLeave={() => this.props.setUIState({ hovered: null })}
onMouseLeave={(e) => {
e.preventDefault();
e.stopPropagation();
this.props.setUIState({ hovered: null });
}}
onClick={(e) => {
const isMultipleSelection = e.shiftKey || e.ctrlKey || e.metaKey;
!this.props.selected &&
Expand Down Expand Up @@ -207,11 +213,21 @@ export class Edit extends Component {
) : (
<div
role="presentation"
onMouseOver={() =>
this.props.setUIState({ hovered: this.props.id })
}
onFocus={() => this.props.setUIState({ hovered: this.props.id })}
onMouseLeave={() => this.props.setUIState({ hovered: null })}
onMouseEnter={(e) => {
e.preventDefault();
e.stopPropagation();
this.props.setUIState({ hovered: this.props.id });
}}
onFocus={(e) => {
e.preventDefault();
e.stopPropagation();
this.props.setUIState({ hovered: this.props.id });
}}
onMouseLeave={(e) => {
e.preventDefault();
e.stopPropagation();
this.props.setUIState({ hovered: null });
}}
onClick={() =>
!this.props.selected && this.props.onSelectBlock(this.props.id)
}
Expand Down
4 changes: 4 additions & 0 deletions packages/volto/src/components/theme/View/LinkView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useHistory } from 'react-router-dom';
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
import { Container as SemanticContainer } from 'semantic-ui-react';
import { UniversalLink } from '@plone/volto/components';
import { Redirect } from 'react-router-dom';
import { FormattedMessage } from 'react-intl';
import config from '@plone/volto/registry';

Expand All @@ -19,6 +20,9 @@ const LinkView = ({ token, content }) => {
}
}
}, [content, history, token]);
if (__SERVER__ && !token && content.remoteUrl) {
return <Redirect to={content.remoteUrl} />;
}
const { title, description, remoteUrl } = content;
const { openExternalLinkInNewTab } = config.settings;
const Container =
Expand Down
2 changes: 2 additions & 0 deletions packages/volto/src/components/theme/View/LinkView.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import LinkView from './LinkView';

const mockStore = configureStore();

global.__SERVER__ = false; // eslint-disable-line no-underscore-dangle

const store = mockStore({
userSession: {
token: null,
Expand Down
17 changes: 15 additions & 2 deletions packages/volto/src/helpers/Url/Url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,24 @@ describe('Url', () => {
});
it('isUrl test 4', () => {
const href = `https://www`;
expect(isUrl(href)).toBe(false);
expect(isUrl(href)).toBe(true);
});
it('isUrl test 5', () => {
const href = `https://www/foo/bar`;
expect(isUrl(href)).toBe(true);
});
it('isUrl test 6', () => {
// at the end of the day, this is a strange, but valid, URL
const href = `www.e`;
expect(isUrl(href)).toBe(false);
expect(isUrl(href)).toBe(true);
});
it('isUrl test 7', () => {
const href = `file://server/folder/file.txt`;
expect(isUrl(href)).toBe(true);
});
it('isUrl test 8', () => {
const href = `file://server.dir.internal/folder/file.txt`;
expect(isUrl(href)).toBe(true);
});
});
describe('getFieldURL', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/volto/src/helpers/Url/urlRegex.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const urlRegex = (_opts) => {
})\\.?`;
const port = '(?::\\d{2,5})?';
const path = '(?:[/?#][^\\s"]*)?';
const regex = `(?:${protocol}|www\\.)${auth}(?:localhost|${ip}|${host}${domain}${tld})${port}${path}`;
const regex = `(?:${protocol}|www\\.)${auth}(?:localhost|${ip}|${host}${domain}${tld}|${host})${port}${path}`;

return opts.exact
? new RegExp(`(?:^${regex}$)`, 'i')
Expand Down

0 comments on commit ba6a04c

Please sign in to comment.