@eeacms/volto-slate-footnote 6.1.4 → 6.1.5

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,2 @@
1
+ [ -n "$CI" ] && exit 0
2
+ yarn lint-staged
package/CHANGELOG.md CHANGED
@@ -4,6 +4,19 @@ 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
+ ### [6.1.5](https://github.com/eea/volto-slate-footnote/compare/6.1.4...6.1.5) - 19 September 2023
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: index not showing on diff - refs #257191 [dobri1408 - [`bd6eb19`](https://github.com/eea/volto-slate-footnote/commit/bd6eb197213e23420fdd2f185447cb92a8156fc9)]
12
+
13
+ #### :house: Internal changes
14
+
15
+ - style: lint-staged reorder in package.json [Alin Voinea - [`c618c3c`](https://github.com/eea/volto-slate-footnote/commit/c618c3c12a878cc87fb9c3fd658eeb5d1241e871)]
16
+
17
+ #### :hammer_and_wrench: Others
18
+
19
+ - test: EN locales, pre-commit fix, feature PRs checks Refs #257193 [valentinab25 - [`6886cf7`](https://github.com/eea/volto-slate-footnote/commit/6886cf796c58d38fcce7c515bda1d3586420a58a)]
7
20
  ### [6.1.4](https://github.com/eea/volto-slate-footnote/compare/6.1.3...6.1.4) - 1 September 2023
8
21
 
9
22
  #### :bug: Bug Fixes
package/Jenkinsfile CHANGED
@@ -62,11 +62,17 @@ pipeline {
62
62
 
63
63
  stage('Tests') {
64
64
  when {
65
- allOf {
66
- environment name: 'CHANGE_ID', value: ''
67
- anyOf {
68
- not { changelog '.*^Automated release [0-9\\.]+$' }
69
- branch 'master'
65
+ anyOf {
66
+ allOf {
67
+ not { environment name: 'CHANGE_ID', value: '' }
68
+ environment name: 'CHANGE_TARGET', value: 'develop'
69
+ }
70
+ allOf {
71
+ environment name: 'CHANGE_ID', value: ''
72
+ anyOf {
73
+ not { changelog '.*^Automated release [0-9\\.]+$' }
74
+ branch 'master'
75
+ }
70
76
  }
71
77
  }
72
78
  }
@@ -110,11 +116,17 @@ pipeline {
110
116
 
111
117
  stage('Integration tests') {
112
118
  when {
113
- allOf {
114
- environment name: 'CHANGE_ID', value: ''
115
- anyOf {
116
- not { changelog '.*^Automated release [0-9\\.]+$' }
117
- branch 'master'
119
+ anyOf {
120
+ allOf {
121
+ not { environment name: 'CHANGE_ID', value: '' }
122
+ environment name: 'CHANGE_TARGET', value: 'develop'
123
+ }
124
+ allOf {
125
+ environment name: 'CHANGE_ID', value: ''
126
+ anyOf {
127
+ not { changelog '.*^Automated release [0-9\\.]+$' }
128
+ branch 'master'
129
+ }
118
130
  }
119
131
  }
120
132
  }
@@ -167,13 +179,19 @@ pipeline {
167
179
 
168
180
  stage('Report to SonarQube') {
169
181
  when {
170
- allOf {
171
- environment name: 'CHANGE_ID', value: ''
172
- anyOf {
173
- branch 'master'
174
- allOf {
175
- branch 'develop'
176
- not { changelog '.*^Automated release [0-9\\.]+$' }
182
+ anyOf {
183
+ allOf {
184
+ not { environment name: 'CHANGE_ID', value: '' }
185
+ environment name: 'CHANGE_TARGET', value: 'develop'
186
+ }
187
+ allOf {
188
+ environment name: 'CHANGE_ID', value: ''
189
+ anyOf {
190
+ allOf {
191
+ branch 'develop'
192
+ not { changelog '.*^Automated release [0-9\\.]+$' }
193
+ }
194
+ branch 'master'
177
195
  }
178
196
  }
179
197
  }
@@ -199,10 +217,16 @@ pipeline {
199
217
 
200
218
  stage('SonarQube compare to master') {
201
219
  when {
202
- allOf {
203
- environment name: 'CHANGE_ID', value: ''
204
- branch 'develop'
205
- not { changelog '.*^Automated release [0-9\\.]+$' }
220
+ anyOf {
221
+ allOf {
222
+ not { environment name: 'CHANGE_ID', value: '' }
223
+ environment name: 'CHANGE_TARGET', value: 'develop'
224
+ }
225
+ allOf {
226
+ environment name: 'CHANGE_ID', value: ''
227
+ branch 'develop'
228
+ not { changelog '.*^Automated release [0-9\\.]+$' }
229
+ }
206
230
  }
207
231
  }
208
232
  steps {
package/cypress.config.js CHANGED
@@ -2,12 +2,12 @@ const { defineConfig } = require('cypress');
2
2
 
3
3
  module.exports = defineConfig({
4
4
  viewportWidth: 1280,
5
- defaultCommandTimeout: 8888,
5
+ defaultCommandTimeout: 5000,
6
6
  chromeWebSecurity: false,
7
7
  reporter: 'junit',
8
8
  video: true,
9
9
  retries: {
10
- runMode: 8,
10
+ runMode: 1,
11
11
  openMode: 0,
12
12
  },
13
13
  reporterOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-slate-footnote",
3
- "version": "6.1.4",
3
+ "version": "6.1.5",
4
4
  "description": "volto-slate-footnote: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -23,8 +23,31 @@
23
23
  "@cypress/code-coverage": "^3.10.0",
24
24
  "@plone/scripts": "*",
25
25
  "babel-plugin-transform-class-properties": "^6.24.1",
26
+ "husky": "*",
27
+ "lint-staged": "*",
26
28
  "md5": "^2.3.0"
27
29
  },
30
+ "lint-staged": {
31
+ "src/**/*.{js,jsx,ts,tsx,json}": [
32
+ "make lint-fix",
33
+ "make prettier-fix"
34
+ ],
35
+ "src/**/*.{jsx}": [
36
+ "make i18n"
37
+ ],
38
+ "theme/**/*.{css,less}": [
39
+ "make stylelint-fix"
40
+ ],
41
+ "src/**/*.{css,less}": [
42
+ "make stylelint-fix"
43
+ ],
44
+ "theme/**/*.overrides": [
45
+ "make stylelint-fix"
46
+ ],
47
+ "src/**/*.overrides": [
48
+ "make stylelint-fix"
49
+ ]
50
+ },
28
51
  "scripts": {
29
52
  "release": "release-it",
30
53
  "release-major-beta": "release-it major --preRelease=beta",
@@ -42,6 +65,7 @@
42
65
  "lint:fix": "make lint-fix",
43
66
  "i18n": "make i18n",
44
67
  "cypress:run": "make cypress-run",
45
- "cypress:open": "make cypress-open"
68
+ "cypress:open": "make cypress-open",
69
+ "prepare": "husky install"
46
70
  }
47
71
  }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import SearchWidget from './SearchWidget';
4
+ describe('Test SearchWidget', () => {
5
+ it('check html content', () => {
6
+ const component = renderer.create(<SearchWidget />);
7
+ const json = component.toJSON();
8
+ expect(json).toMatchSnapshot();
9
+ });
10
+ });
@@ -0,0 +1,72 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Test SearchWidget check html content 1`] = `
4
+ <div
5
+ id="blockform-fieldset-default"
6
+ >
7
+ <div
8
+ className="ui segment attached"
9
+ fluid={true}
10
+ >
11
+ <div
12
+ className="ui fluid card"
13
+ onClick={[Function]}
14
+ >
15
+ <div
16
+ className="content"
17
+ fluid={true}
18
+ >
19
+ <div
20
+ className="header"
21
+ >
22
+ Citation
23
+ </div>
24
+ <div
25
+ className="description"
26
+ fluid={true}
27
+ >
28
+ <div
29
+ className="ui fluid search"
30
+ onBlur={[Function]}
31
+ onFocus={[Function]}
32
+ onMouseDown={[Function]}
33
+ >
34
+ <div
35
+ className="ui fluid right icon input"
36
+ >
37
+ <input
38
+ autoComplete="off"
39
+ className="prompt"
40
+ id="field-footnote"
41
+ onChange={[Function]}
42
+ onClick={[Function]}
43
+ tabIndex="0"
44
+ type="text"
45
+ value=""
46
+ />
47
+ <i
48
+ aria-hidden="true"
49
+ className="search icon"
50
+ onClick={[Function]}
51
+ />
52
+ </div>
53
+ <div
54
+ className="results transition"
55
+ >
56
+ <div
57
+ className="message empty"
58
+ >
59
+ <div
60
+ className="header"
61
+ >
62
+ No results found.
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ `;
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React from 'react';
2
2
  import { Popup, List } from 'semantic-ui-react';
3
3
  import { useEditorContext } from '@plone/volto-slate/hooks';
4
4
  import { getAllBlocksAndSlateFields } from '@eeacms/volto-slate-footnote/editor/utils';
@@ -24,71 +24,61 @@ export const FootnoteElement = (props) => {
24
24
  const { data = {} } = element;
25
25
  const { uid, zoteroId } = data;
26
26
  const editor = useEditorContext();
27
- const [citationIndice, setCitationIndice] = useState(null); // list of indices to reference
28
- const [citationRefId, setCitationRefId] = useState(null); // indice of element to be referenced
29
- const initialFormData = useSelector((state) => state?.content?.data || {});
30
-
31
- useEffect(() => {
32
- const blockProps = editor?.getBlockProps ? editor.getBlockProps() : null;
33
- const metadata = blockProps
34
- ? blockProps.metadata || blockProps.properties
35
- : extras?.metadata || {};
36
- const blocks = getAllBlocksAndSlateFields(metadata);
37
- const storeBlocks = getAllBlocksAndSlateFields(initialFormData);
38
27
 
39
- const notesObjResult = isEmpty(metadata)
40
- ? makeFootnoteListOfUniqueItems(storeBlocks)
41
- : makeFootnoteListOfUniqueItems(blocks);
28
+ const initialFormData = useSelector((state) => state?.content?.data || {});
29
+ const blockProps = editor?.getBlockProps ? editor.getBlockProps() : null;
30
+ const metadata = blockProps
31
+ ? blockProps.metadata || blockProps.properties
32
+ : extras?.metadata || {};
33
+ const blocks = getAllBlocksAndSlateFields(metadata);
34
+ const storeBlocks = getAllBlocksAndSlateFields(initialFormData);
42
35
 
43
- // will cosider zotero citations and footnote
44
- // notesObjResult contains all zotero/footnote as unique, and contain refs for other zotero/footnote
45
- const indiceIfZoteroId = data.extra
46
- ? [
47
- `[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`, // parent footnote
48
- ...data.extra.map(
49
- // citations from extra
50
- (zoteroObj, _index) =>
51
- // all zotero citation are indexed by zoteroId in notesObjResult
52
- `[${
53
- Object.keys(notesObjResult).indexOf(zoteroObj.zoteroId) + 1
54
- }]`,
55
- ),
56
- ].join('')
57
- : // no extra citations (no multiples)
58
- `[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`;
36
+ const notesObjResult = isEmpty(metadata)
37
+ ? makeFootnoteListOfUniqueItems(storeBlocks)
38
+ : makeFootnoteListOfUniqueItems(blocks);
59
39
 
60
- const indice = zoteroId // ZOTERO
61
- ? indiceIfZoteroId
62
- : // FOOTNOTES
63
- // parent footnote
64
- [data, ...(data.extra || [])]
65
- .map((footnoteObj, _index) => {
66
- return `[${
67
- Object.keys(notesObjResult).indexOf(
68
- Object.keys(notesObjResult).find(
69
- (key) =>
70
- notesObjResult[key].footnote === footnoteObj.footnote,
71
- ),
72
- ) + 1
73
- }]`;
74
- })
75
- .join('');
40
+ // will cosider zotero citations and footnote
41
+ // notesObjResult contains all zotero/footnote as unique, and contain refs for other zotero/footnote
42
+ const indiceIfZoteroId = data.extra
43
+ ? [
44
+ `[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`, // parent footnote
45
+ ...data.extra.map(
46
+ // citations from extra
47
+ (zoteroObj, _index) =>
48
+ // all zotero citation are indexed by zoteroId in notesObjResult
49
+ `[${Object.keys(notesObjResult).indexOf(zoteroObj.zoteroId) + 1}]`,
50
+ ),
51
+ ].join('')
52
+ : // no extra citations (no multiples)
53
+ `[${Object.keys(notesObjResult).indexOf(zoteroId) + 1}]`;
76
54
 
77
- const findReferenceId =
78
- // search within parent citations first, otherwise the uid might be inside a refs obj that comes before
79
- Object.keys(notesObjResult).find(
80
- (noteKey) => notesObjResult[noteKey].uid === uid,
81
- ) ||
82
- // if not found in parent, search in refs, it might be a footnote references multiple times
83
- Object.keys(notesObjResult).find(
84
- (noteKey) =>
85
- notesObjResult[noteKey].uid === uid ||
86
- (notesObjResult[noteKey].refs && notesObjResult[noteKey].refs[uid]),
87
- );
55
+ const citationIndice = zoteroId // ZOTERO
56
+ ? indiceIfZoteroId
57
+ : // FOOTNOTES
58
+ // parent footnote
59
+ [data, ...(data.extra || [])]
60
+ .map((footnoteObj, _index) => {
61
+ return `[${
62
+ Object.keys(notesObjResult).indexOf(
63
+ Object.keys(notesObjResult).find(
64
+ (key) => notesObjResult[key].footnote === footnoteObj.footnote,
65
+ ),
66
+ ) + 1
67
+ }]`;
68
+ })
69
+ .join('');
88
70
 
89
- setCitationIndice(indice);
90
- setCitationRefId(findReferenceId);
91
- }, [editor, element, children]); // eslint-disable-line
71
+ const citationRefId =
72
+ // search within parent citations first, otherwise the uid might be inside a refs obj that comes before
73
+ Object.keys(notesObjResult).find(
74
+ (noteKey) => notesObjResult[noteKey].uid === uid,
75
+ ) ||
76
+ // if not found in parent, search in refs, it might be a footnote references multiple times
77
+ Object.keys(notesObjResult).find(
78
+ (noteKey) =>
79
+ notesObjResult[noteKey].uid === uid ||
80
+ (notesObjResult[noteKey].refs && notesObjResult[noteKey].refs[uid]),
81
+ );
92
82
 
93
83
  return (
94
84
  <>