@plone/volto 18.20.0 → 19.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,137 @@
1
+ import { injectIntl } from 'react-intl';
2
+ import ContentsDeleteModalComponent from './ContentsDeleteModal';
3
+ import { RealStoreWrapper as Wrapper } from '@plone/volto/storybook';
4
+
5
+ const IntlContentsDeleteModal = injectIntl(ContentsDeleteModalComponent);
6
+
7
+ function StoryComponent(args) {
8
+ const { locale = 'en' } = args; // Default to 'en' if locale is not provided
9
+ const messages =
10
+ {
11
+ [locale]: require(`@plone/volto/../locales/${locale}.json`),
12
+ }[locale] || {};
13
+
14
+ return (
15
+ <Wrapper
16
+ customStore={{
17
+ linkIntegrity: {
18
+ result: args.linkIntegrityResult,
19
+ loading: args.loading,
20
+ },
21
+ intl: {
22
+ locale,
23
+ messages,
24
+ },
25
+ }}
26
+ >
27
+ <div id="toolbar" style={{ display: 'none' }} />
28
+ <div>{locale}</div>
29
+ <IntlContentsDeleteModal {...args} />
30
+ </Wrapper>
31
+ );
32
+ }
33
+
34
+ export const Default = StoryComponent.bind({});
35
+ Default.args = {
36
+ locale: 'en',
37
+ open: true,
38
+ items: [
39
+ { '@id': '/news', UID: '123', title: 'News' },
40
+ { '@id': '/blog', UID: '456', title: 'Blog' },
41
+ { '@id': '/extra', UID: '789', title: 'Extra' },
42
+ ],
43
+ itemsToDelete: [{ UID: '456' }],
44
+ linkIntegrityResult: [
45
+ {
46
+ '@id': '/blog',
47
+ title: 'Blog',
48
+ items_total: 2,
49
+ breaches: [{ uid: '123', title: 'News', '@id': '/news' }],
50
+ },
51
+ ],
52
+ loading: false,
53
+ onOk: () => {},
54
+ onCancel: () => {},
55
+ };
56
+
57
+ export const DeleteMoreThanOne = StoryComponent.bind({});
58
+ DeleteMoreThanOne.args = {
59
+ ...Default.args,
60
+ itemsToDelete: [{ UID: '456' }, { UID: '789' }],
61
+ };
62
+
63
+ export const NoContainedItems = StoryComponent.bind({});
64
+ NoContainedItems.args = {
65
+ ...Default.args,
66
+ linkIntegrityResult: [
67
+ {
68
+ '@id': '/blog',
69
+ title: 'Blog',
70
+ items_total: 0,
71
+ breaches: [{ uid: '123', title: 'News', '@id': '/news' }],
72
+ },
73
+ ],
74
+ };
75
+
76
+ export const MultipleLinkIntegrityResults = StoryComponent.bind({});
77
+ MultipleLinkIntegrityResults.args = {
78
+ ...Default.args,
79
+ itemsToDelete: [{ UID: '456' }, { UID: '789' }],
80
+ linkIntegrityResult: [
81
+ {
82
+ '@id': '/blog',
83
+ title: 'Blog',
84
+ items_total: 1,
85
+ breaches: [{ uid: '123', title: 'News', '@id': '/news' }],
86
+ },
87
+ {
88
+ '@id': '/extra',
89
+ title: 'Extra',
90
+ items_total: 0,
91
+ breaches: [{ uid: '123', title: 'News', '@id': '/news' }],
92
+ },
93
+ ],
94
+ };
95
+
96
+ export const MultipleBreaches = StoryComponent.bind({});
97
+ MultipleBreaches.args = {
98
+ ...Default.args,
99
+ itemsToDelete: [{ UID: '789' }],
100
+ linkIntegrityResult: [
101
+ {
102
+ '@id': '/extra',
103
+ title: 'Extra',
104
+ items_total: 0,
105
+ breaches: [
106
+ { uid: '123', title: 'News', '@id': '/news' },
107
+ { uid: '456', title: 'Blog', '@id': '/blog' },
108
+ ],
109
+ },
110
+ ],
111
+ };
112
+
113
+ export const WithoutLinkIntegrityBreaches = StoryComponent.bind({});
114
+ WithoutLinkIntegrityBreaches.args = {
115
+ ...Default.args,
116
+ linkIntegrityResult: [],
117
+ };
118
+
119
+ export default {
120
+ title: 'Public components/Contents/Contents Delete Modal',
121
+ component: Default,
122
+ decorators: [
123
+ (Story) => (
124
+ <div className="ui segment form attached" style={{ width: '400px' }}>
125
+ <Story />
126
+ </div>
127
+ ),
128
+ ],
129
+ argTypes: {
130
+ locale: {
131
+ options: ['en', 'fr', 'de', 'it', 'eu'],
132
+ control: {
133
+ type: 'radio',
134
+ },
135
+ },
136
+ },
137
+ };
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
2
  import { Provider } from 'react-intl-redux';
3
3
  import { render, waitFor } from '@testing-library/react';
4
- import configureStore from 'redux-mock-store';
4
+ import configureMockStore from 'redux-mock-store';
5
+ import thunk from 'redux-thunk';
5
6
  import config from '@plone/volto/registry';
6
7
 
7
8
  import IdWidget from './IdWidget';
8
9
 
9
- const mockStore = configureStore();
10
+ const middlewares = [thunk];
11
+ const mockStore = configureMockStore(middlewares);
10
12
 
11
13
  describe('IdWidget', () => {
12
14
  test('renders an empty id widget component', async () => {
@@ -1,4 +1,5 @@
1
1
  import { useEffect } from 'react';
2
+ import { useSelector } from 'react-redux';
2
3
  import PropTypes from 'prop-types';
3
4
  import { useHistory } from 'react-router-dom';
4
5
  import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers/Url/Url';
@@ -8,10 +9,15 @@ import { Redirect } from 'react-router-dom';
8
9
  import { FormattedMessage } from 'react-intl';
9
10
  import config from '@plone/volto/registry';
10
11
 
11
- const LinkView = ({ token, content }) => {
12
+ const LinkView = ({ content }) => {
12
13
  const history = useHistory();
14
+ const userCanEdit = useSelector(
15
+ (state) =>
16
+ !!state.actions.actions.object.find((action) => action.id === 'edit'),
17
+ );
18
+
13
19
  useEffect(() => {
14
- if (!token) {
20
+ if (!userCanEdit) {
15
21
  const { remoteUrl } = content;
16
22
  if (isInternalURL(remoteUrl)) {
17
23
  history.replace(flattenToAppURL(remoteUrl));
@@ -19,8 +25,8 @@ const LinkView = ({ token, content }) => {
19
25
  window.location.href = flattenToAppURL(remoteUrl);
20
26
  }
21
27
  }
22
- }, [content, history, token]);
23
- if (__SERVER__ && !token && content.remoteUrl) {
28
+ }, [content, history, userCanEdit]);
29
+ if (__SERVER__ && !userCanEdit && content.remoteUrl) {
24
30
  return <Redirect to={content.remoteUrl} />;
25
31
  }
26
32
  const { title, description, remoteUrl } = content;
@@ -17,6 +17,15 @@ const store = mockStore({
17
17
  locale: 'en',
18
18
  messages: {},
19
19
  },
20
+ actions: {
21
+ actions: {
22
+ object: [
23
+ {
24
+ id: 'edit',
25
+ },
26
+ ],
27
+ },
28
+ },
20
29
  });
21
30
 
22
31
  test('renders a link view component', () => {
@@ -24,7 +33,6 @@ test('renders a link view component', () => {
24
33
  <Provider store={store}>
25
34
  <MemoryRouter>
26
35
  <LinkView
27
- token="1234"
28
36
  content={{
29
37
  title: 'Hello World!',
30
38
  description: 'Hi',
@@ -527,7 +527,7 @@ blocksConfig.gridBlock.blocksConfig.teaser.schemaEnhancer =
527
527
  blocksConfig.gridBlock.blocksConfig.image.schemaEnhancer =
528
528
  gridImageDisableSizeAndPositionHandlersSchema;
529
529
 
530
- const requiredBlocks = ['title'];
530
+ const requiredBlocks = [];
531
531
 
532
532
  const initialBlocks = {};
533
533
  const initialBlocksFocus = {}; //{Document:'title'}
@@ -17,6 +17,9 @@
17
17
 
18
18
  body {
19
19
  display: flex;
20
+ // react-aria-components popovers have problems with the default declaration
21
+ // in Semantic UI that forces `overflow-x: hidden` on the body.
22
+ overflow-x: initial;
20
23
 
21
24
  @media only screen and (max-width: @largestMobileScreen) {
22
25
  flex-direction: column;
@@ -0,0 +1,20 @@
1
+ export const Default: any;
2
+ export const DeleteMoreThanOne: any;
3
+ export const NoContainedItems: any;
4
+ export const MultipleLinkIntegrityResults: any;
5
+ export const MultipleBreaches: any;
6
+ export const WithoutLinkIntegrityBreaches: any;
7
+ declare namespace _default {
8
+ export let title: string;
9
+ export { Default as component };
10
+ export let decorators: ((Story: any) => import("react/jsx-runtime").JSX.Element)[];
11
+ export namespace argTypes {
12
+ namespace locale {
13
+ let options: string[];
14
+ namespace control {
15
+ let type: string;
16
+ }
17
+ }
18
+ }
19
+ }
20
+ export default _default;
@@ -1,6 +1,5 @@
1
1
  export default LinkView;
2
- declare function LinkView({ token, content }: {
3
- token: any;
2
+ declare function LinkView({ content }: {
4
3
  content: any;
5
4
  }): import("react/jsx-runtime").JSX.Element;
6
5
  declare namespace LinkView {
@@ -3,7 +3,7 @@ export const groupBlocksOrder: {
3
3
  id: string;
4
4
  title: string;
5
5
  }[];
6
- export const requiredBlocks: string[];
6
+ export const requiredBlocks: any[];
7
7
  export namespace blocksConfig {
8
8
  namespace gridBlock {
9
9
  namespace blocksConfig {