@eeacms/volto-clms-theme 1.0.71 → 1.0.72

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.
package/CHANGELOG.md CHANGED
@@ -4,8 +4,17 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [1.0.72](https://github.com/eea/volto-clms-theme/compare/1.0.71...1.0.72)
8
+
9
+ - fix tests [`8d68b8d`](https://github.com/eea/volto-clms-theme/commit/8d68b8d9f013f469d6f1138f5301055175344ab6)
10
+ - add edit button for editors at documents listing [`7e81f0b`](https://github.com/eea/volto-clms-theme/commit/7e81f0b920db84c47f3354a9a6d5736213746dea)
11
+ - add default link if has no files to download [`f45842d`](https://github.com/eea/volto-clms-theme/commit/f45842d9a19cab1333cb31843fb5fe5b1e2b15db)
12
+
7
13
  #### [1.0.71](https://github.com/eea/volto-clms-theme/compare/1.0.70...1.0.71)
8
14
 
15
+ > 21 February 2022
16
+
17
+ - Taxonomy widget [`#209`](https://github.com/eea/volto-clms-theme/pull/209)
9
18
  - Taxonomy widget [`#208`](https://github.com/eea/volto-clms-theme/pull/208)
10
19
  - merge conflicts [`c714434`](https://github.com/eea/volto-clms-theme/commit/c714434f91ce01b9dc82014b32d2c9c34fbe1308)
11
20
  - add download link to technical library objects at listing [`455a6dc`](https://github.com/eea/volto-clms-theme/commit/455a6dc6c4cf38f5018582d11b90f156232f1d99)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.0.71",
3
+ "version": "1.0.72",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -4,6 +4,7 @@ import { ConditionalLink } from '@plone/volto/components';
4
4
  import { flattenToAppURL } from '@plone/volto/helpers';
5
5
 
6
6
  import { isInternalURL } from '@plone/volto/helpers/Url/Url';
7
+ import { useSelector } from 'react-redux';
7
8
 
8
9
  import CclCard from '@eeacms/volto-clms-theme/components/CclCard/CclCard';
9
10
 
@@ -11,7 +12,7 @@ const CclListingCards = (props) => {
11
12
  const { items, linkHref, linkTitle, isEditMode, variation = 'doc' } = props;
12
13
  let link = null;
13
14
  let href = linkHref?.[0]?.['@id'] || '';
14
-
15
+ const user = useSelector((state) => state.users.user);
15
16
  if (isInternalURL(href)) {
16
17
  link = (
17
18
  <ConditionalLink to={flattenToAppURL(href)} condition={!isEditMode}>
@@ -21,7 +22,6 @@ const CclListingCards = (props) => {
21
22
  } else if (href) {
22
23
  link = <a href={href}>{linkTitle || href}</a>;
23
24
  }
24
-
25
25
  let containerClass = '';
26
26
  if (['news', 'event'].includes(variation)) {
27
27
  containerClass = 'ccl-container';
@@ -33,7 +33,12 @@ const CclListingCards = (props) => {
33
33
  <div className={containerClass}>
34
34
  {items && items.length > 0
35
35
  ? items.map((item, index) => (
36
- <CclCard key={index} type={variation} card={item} />
36
+ <CclCard
37
+ key={index}
38
+ type={variation}
39
+ card={item}
40
+ showEditor={user?.roles?.includes('Manager')}
41
+ />
37
42
  ))
38
43
  : 'There are no items to display'}
39
44
  </div>
@@ -10,19 +10,26 @@ import configureStore from 'redux-mock-store';
10
10
  Enzyme.configure({ adapter: new Adapter() });
11
11
 
12
12
  const mockStore = configureStore();
13
+ const store = mockStore({
14
+ content: {
15
+ create: {},
16
+ data: {},
17
+ },
18
+ intl: {
19
+ locale: 'en',
20
+ messages: {},
21
+ },
22
+ users: {
23
+ user: {
24
+ roles: ['Manager'],
25
+ },
26
+ },
27
+ });
28
+ const internalLink = [{ '@id': '/news' }];
29
+ const externalLink = [{ '@id': 'https://wwww.google.com' }];
13
30
 
14
31
  describe('CclListingCards', () => {
15
32
  it('News listing card internal link', () => {
16
- const store = mockStore({
17
- content: {
18
- create: {},
19
- data: {},
20
- },
21
- intl: {
22
- locale: 'en',
23
- messages: {},
24
- },
25
- });
26
33
  const items = [
27
34
  {
28
35
  title: 'Card Title',
@@ -33,7 +40,6 @@ describe('CclListingCards', () => {
33
40
  },
34
41
  },
35
42
  ];
36
- const linkHref = [{ '@id': '/news' }];
37
43
  const linkTitle = 'More news';
38
44
  const isEditMode = true;
39
45
  const variation = 'CclCardsnews';
@@ -42,7 +48,7 @@ describe('CclListingCards', () => {
42
48
  <MemoryRouter>
43
49
  <CclListingCards
44
50
  items={items}
45
- linkHref={linkHref}
51
+ linkHref={internalLink}
46
52
  linkTitle={linkTitle}
47
53
  isEditMode={isEditMode}
48
54
  variation={variation}
@@ -53,16 +59,6 @@ describe('CclListingCards', () => {
53
59
  expect(component).toBeDefined();
54
60
  });
55
61
  it('Line-color listing card external link', () => {
56
- const store = mockStore({
57
- content: {
58
- create: {},
59
- data: {},
60
- },
61
- intl: {
62
- locale: 'en',
63
- messages: {},
64
- },
65
- });
66
62
  const items = [
67
63
  {
68
64
  title: 'Card Title',
@@ -73,7 +69,6 @@ describe('CclListingCards', () => {
73
69
  },
74
70
  },
75
71
  ];
76
- const linkHref = [{ '@id': 'https://wwww.google.com' }];
77
72
  const linkTitle = 'More line-color';
78
73
  const isEditMode = true;
79
74
  const variation = 'CclCardsline-color';
@@ -82,7 +77,7 @@ describe('CclListingCards', () => {
82
77
  <MemoryRouter>
83
78
  <CclListingCards
84
79
  items={items}
85
- linkHref={linkHref}
80
+ linkHref={externalLink}
86
81
  linkTitle={linkTitle}
87
82
  isEditMode={isEditMode}
88
83
  variation={variation}
@@ -93,16 +88,6 @@ describe('CclListingCards', () => {
93
88
  expect(component).toBeDefined();
94
89
  });
95
90
  it('line listing card external link', () => {
96
- const store = mockStore({
97
- content: {
98
- create: {},
99
- data: {},
100
- },
101
- intl: {
102
- locale: 'en',
103
- messages: {},
104
- },
105
- });
106
91
  const items = [
107
92
  {
108
93
  title: 'Card Title',
@@ -113,7 +98,6 @@ describe('CclListingCards', () => {
113
98
  },
114
99
  },
115
100
  ];
116
- const linkHref = [{ '@id': 'https://wwww.google.com' }];
117
101
  const linkTitle = 'More line';
118
102
  const isEditMode = true;
119
103
  const variation = 'CclCardsline';
@@ -122,7 +106,7 @@ describe('CclListingCards', () => {
122
106
  <MemoryRouter>
123
107
  <CclListingCards
124
108
  items={items}
125
- linkHref={linkHref}
109
+ linkHref={externalLink}
126
110
  linkTitle={linkTitle}
127
111
  isEditMode={isEditMode}
128
112
  variation={variation}
@@ -133,16 +117,6 @@ describe('CclListingCards', () => {
133
117
  expect(component).toBeDefined();
134
118
  });
135
119
  it('without linkHref', () => {
136
- const store = mockStore({
137
- content: {
138
- create: {},
139
- data: {},
140
- },
141
- intl: {
142
- locale: 'en',
143
- messages: {},
144
- },
145
- });
146
120
  const items = [
147
121
  {
148
122
  title: 'Card Title',
@@ -169,16 +143,6 @@ describe('CclListingCards', () => {
169
143
  expect(component).toBeDefined();
170
144
  });
171
145
  it('internal link without linkTitle', () => {
172
- const store = mockStore({
173
- content: {
174
- create: {},
175
- data: {},
176
- },
177
- intl: {
178
- locale: 'en',
179
- messages: {},
180
- },
181
- });
182
146
  const items = [
183
147
  {
184
148
  title: 'Card Title',
@@ -189,7 +153,6 @@ describe('CclListingCards', () => {
189
153
  },
190
154
  },
191
155
  ];
192
- const linkHref = [{ '@id': '/news' }];
193
156
  const isEditMode = true;
194
157
  const variation = 'CclCardsnews';
195
158
  const component = mount(
@@ -197,7 +160,7 @@ describe('CclListingCards', () => {
197
160
  <MemoryRouter>
198
161
  <CclListingCards
199
162
  items={items}
200
- linkHref={linkHref}
163
+ linkHref={internalLink}
201
164
  isEditMode={isEditMode}
202
165
  variation={variation}
203
166
  ></CclListingCards>
@@ -207,16 +170,6 @@ describe('CclListingCards', () => {
207
170
  expect(component).toBeDefined();
208
171
  });
209
172
  it('External link without linkTitle', () => {
210
- const store = mockStore({
211
- content: {
212
- create: {},
213
- data: {},
214
- },
215
- intl: {
216
- locale: 'en',
217
- messages: {},
218
- },
219
- });
220
173
  const items = [
221
174
  {
222
175
  title: 'Card Title',
@@ -227,7 +180,6 @@ describe('CclListingCards', () => {
227
180
  },
228
181
  },
229
182
  ];
230
- const linkHref = [{ '@id': 'https://www.google.com' }];
231
183
  const isEditMode = true;
232
184
  const variation = 'CclCardsnews';
233
185
  const component = mount(
@@ -235,7 +187,7 @@ describe('CclListingCards', () => {
235
187
  <MemoryRouter>
236
188
  <CclListingCards
237
189
  items={items}
238
- linkHref={linkHref}
190
+ linkHref={externalLink}
239
191
  isEditMode={isEditMode}
240
192
  variation={variation}
241
193
  ></CclListingCards>
@@ -9,6 +9,8 @@ import React from 'react';
9
9
  import { When } from '@plone/volto/components/theme/View/EventDatesInfo';
10
10
  import { Label } from 'semantic-ui-react';
11
11
  import { portal_types_labels } from '../Blocks/CustomTemplates/VoltoSearchBlock';
12
+ import penSVG from '@plone/volto/icons/pen.svg';
13
+ import { Icon } from '@plone/volto/components';
12
14
 
13
15
  function bytesToSize(bytes) {
14
16
  var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
@@ -17,7 +19,7 @@ function bytesToSize(bytes) {
17
19
  return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
18
20
  }
19
21
  function CclCard(props) {
20
- const { type, children, card } = props;
22
+ const { type, children, card, showEditor = false } = props;
21
23
  let url = '/';
22
24
  let content_type = '';
23
25
  if (card) {
@@ -49,7 +51,17 @@ function CclCard(props) {
49
51
  {card?.file?.download ? (
50
52
  <a href={card.file.download}>{card?.title}</a>
51
53
  ) : (
52
- card?.title
54
+ <Link to={url}>{card?.title}</Link>
55
+ )}
56
+ {card?.file?.download && showEditor && (
57
+ <Link to={`${url}/edit`}>
58
+ <Icon
59
+ name={penSVG}
60
+ size="15px"
61
+ className="circled"
62
+ title={'Edit'}
63
+ />
64
+ </Link>
53
65
  )}
54
66
  </div>
55
67
  <div className="card-doc-text">