@regioneer/volto-collective-rercaptcha 1.0.0-alpha.3
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.draft +7 -0
- package/.release-it.json +34 -0
- package/CHANGELOG.md +15 -0
- package/README.md +195 -0
- package/babel.config.js +17 -0
- package/locales/de/LC_MESSAGES/volto.po +17 -0
- package/locales/en/LC_MESSAGES/volto.po +17 -0
- package/locales/es/LC_MESSAGES/volto.po +24 -0
- package/locales/pt_BR/LC_MESSAGES/volto.po +22 -0
- package/locales/volto.pot +19 -0
- package/news/.gitkeep +0 -0
- package/package.json +46 -0
- package/public/.gitkeep +0 -0
- package/src/components/.gitkeep +0 -0
- package/src/components/Blocks/CaptchaTest/Edit.tsx +80 -0
- package/src/components/Blocks/CaptchaTest/View.tsx +117 -0
- package/src/components/Blocks/index.ts +4 -0
- package/src/components/Widget/CapJsWidget.tsx +167 -0
- package/src/components/Widget/FormWidget/RerCaptchaWidget.tsx +149 -0
- package/src/components/index.ts +5 -0
- package/src/config/settings.ts +10 -0
- package/src/customizations/design-comuni-plone-theme/components/ItaliaTheme/CustomerSatisfaction/FeedbackForm.jsx +492 -0
- package/src/customizations/volto-form-block/components/Widget/Captcha.jsx +144 -0
- package/src/index.ts +30 -0
- package/towncrier.toml +33 -0
- package/tsconfig.json +30 -0
package/.changelog.draft
ADDED
package/.release-it.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": {
|
|
3
|
+
"../../core/packages/scripts/prepublish.js": {}
|
|
4
|
+
},
|
|
5
|
+
"hooks": {
|
|
6
|
+
"after:bump": [
|
|
7
|
+
"pipx run towncrier build --draft --yes --version ${version} > .changelog.draft",
|
|
8
|
+
"pipx run towncrier build --yes --version ${version}",
|
|
9
|
+
"cp ../../README.md ./ && cp CHANGELOG.md ../../CHANGELOG.md",
|
|
10
|
+
"python3 -c 'import json; data = json.load(open(\"../../package.json\")); data[\"version\"] = \"${version}\"; json.dump(data, open(\"../../package.json\", \"w\"), indent=2)'",
|
|
11
|
+
"git add ../../CHANGELOG.md ../../package.json"
|
|
12
|
+
],
|
|
13
|
+
"after:release": "rm .changelog.draft README.md"
|
|
14
|
+
},
|
|
15
|
+
"npm": {
|
|
16
|
+
"publish": false
|
|
17
|
+
},
|
|
18
|
+
"plonePrePublish": {
|
|
19
|
+
"publish": false
|
|
20
|
+
},
|
|
21
|
+
"git": {
|
|
22
|
+
"changelog": "pipx run towncrier build --draft --yes --version 0.0.0",
|
|
23
|
+
"requireUpstream": false,
|
|
24
|
+
"requireCleanWorkingDir": false,
|
|
25
|
+
"commitMessage": "Release ${version}",
|
|
26
|
+
"tagName": "${version}",
|
|
27
|
+
"tagAnnotation": "Release ${version}"
|
|
28
|
+
},
|
|
29
|
+
"github": {
|
|
30
|
+
"release": false,
|
|
31
|
+
"releaseName": "${version}",
|
|
32
|
+
"releaseNotes": "cat .changelog.draft"
|
|
33
|
+
}
|
|
34
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!-- You should *NOT* be adding new change log entries to this file.
|
|
4
|
+
You should create a file in the news directory instead.
|
|
5
|
+
For helpful instructions, please see:
|
|
6
|
+
https://6.docs.plone.org/contributing/index.html#contributing-change-log-label
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
<!-- towncrier release notes start -->
|
|
10
|
+
|
|
11
|
+
## 1.0.0-alpha.3 (2026-03-30)
|
|
12
|
+
|
|
13
|
+
### Feature
|
|
14
|
+
|
|
15
|
+
- Implementation for customer satisfaction rercaptcha. @giulio-red-turtle [#3](https://github.com/collective/collective-rercaptcha/issue/3)
|
package/README.md
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# collective-rercaptcha (volto-collective-rercaptcha)
|
|
2
|
+
|
|
3
|
+
Integration with rercaptcha in Plone
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/volto-collective-rercaptcha)
|
|
6
|
+
[](https://collective.github.io/volto-collective-rercaptcha/)
|
|
7
|
+
[](https://github.com/collective/collective-rercaptcha/actions/workflows/main.yml)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
<!-- List your awesome features here -->
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
To install your project, you must choose the method appropriate to your version of Volto.
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Volto 18 and later
|
|
20
|
+
|
|
21
|
+
Add `volto-collective-rercaptcha` to your `package.json`.
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"volto-collective-rercaptcha": "*"
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Add `volto-collective-rercaptcha` to your `volto.config.js`.
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
const addons = ['volto-collective-rercaptcha'];
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
If this package provides a Volto theme, and you want to activate it, then add the following to your `volto.config.js`.
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
const theme = 'volto-collective-rercaptcha';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Volto 17 and earlier
|
|
42
|
+
|
|
43
|
+
Create a new Volto project.
|
|
44
|
+
You can skip this step if you already have one.
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
npm install -g yo @plone/generator-volto
|
|
48
|
+
yo @plone/volto my-volto-project --addon volto-collective-rercaptcha
|
|
49
|
+
cd my-volto-project
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Add `volto-collective-rercaptcha` to your `package.json`.
|
|
53
|
+
|
|
54
|
+
```JSON
|
|
55
|
+
"addons": [
|
|
56
|
+
"volto-collective-rercaptcha"
|
|
57
|
+
],
|
|
58
|
+
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"volto-collective-rercaptcha": "*"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Download and install the new add-on.
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
yarn install
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Start Volto.
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
yarn start
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Test installation
|
|
77
|
+
|
|
78
|
+
Visit http://localhost:3000/ in a browser, login, and check the awesome new features.
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
The development of this add-on is done in isolation using pnpm workspaces, the latest `mrs-developer`, and other Volto core improvements.
|
|
84
|
+
For these reasons, it only works with pnpm and Volto 18.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Prerequisites ✅
|
|
88
|
+
|
|
89
|
+
- An [operating system](https://6.docs.plone.org/install/create-project-cookieplone.html#prerequisites-for-installation) that runs all the requirements mentioned.
|
|
90
|
+
- [nvm](https://6.docs.plone.org/install/create-project-cookieplone.html#nvm)
|
|
91
|
+
- [Node.js and pnpm](https://6.docs.plone.org/install/create-project.html#node-js) 22
|
|
92
|
+
- [Make](https://6.docs.plone.org/install/create-project-cookieplone.html#make)
|
|
93
|
+
- [Git](https://6.docs.plone.org/install/create-project-cookieplone.html#git)
|
|
94
|
+
- [Docker](https://docs.docker.com/get-started/get-docker/) (optional)
|
|
95
|
+
|
|
96
|
+
### Installation 🔧
|
|
97
|
+
|
|
98
|
+
1. Clone this repository, then change your working directory.
|
|
99
|
+
|
|
100
|
+
```shell
|
|
101
|
+
git clone git@github.com:collective/collective-rercaptcha.git
|
|
102
|
+
cd collective-rercaptcha/frontend
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
2. Install this code base.
|
|
106
|
+
|
|
107
|
+
```shell
|
|
108
|
+
make install
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
### Make convenience commands
|
|
113
|
+
|
|
114
|
+
Run `make help` to list the available Make commands.
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
### Set up development environment
|
|
118
|
+
|
|
119
|
+
Install package requirements.
|
|
120
|
+
|
|
121
|
+
```shell
|
|
122
|
+
make install
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Start developing
|
|
126
|
+
|
|
127
|
+
Start the backend.
|
|
128
|
+
|
|
129
|
+
```shell
|
|
130
|
+
make backend-docker-start
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
In a separate terminal session, start the frontend.
|
|
134
|
+
|
|
135
|
+
```shell
|
|
136
|
+
make start
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Lint code
|
|
140
|
+
|
|
141
|
+
Run ESlint, Prettier, and Stylelint in analyze mode.
|
|
142
|
+
|
|
143
|
+
```shell
|
|
144
|
+
make lint
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Format code
|
|
148
|
+
|
|
149
|
+
Run ESlint, Prettier, and Stylelint in fix mode.
|
|
150
|
+
|
|
151
|
+
```shell
|
|
152
|
+
make format
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### i18n
|
|
156
|
+
|
|
157
|
+
Extract the i18n messages to locales.
|
|
158
|
+
|
|
159
|
+
```shell
|
|
160
|
+
make i18n
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Unit tests
|
|
164
|
+
|
|
165
|
+
Run unit tests.
|
|
166
|
+
|
|
167
|
+
```shell
|
|
168
|
+
make test
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Run Cypress tests
|
|
172
|
+
|
|
173
|
+
Run each of these steps in separate terminal sessions.
|
|
174
|
+
|
|
175
|
+
In the first session, start the frontend in development mode.
|
|
176
|
+
|
|
177
|
+
```shell
|
|
178
|
+
make acceptance-frontend-dev-start
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
In the second session, start the backend acceptance server.
|
|
182
|
+
|
|
183
|
+
```shell
|
|
184
|
+
make acceptance-backend-start
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
In the third session, start the Cypress interactive test runner.
|
|
188
|
+
|
|
189
|
+
```shell
|
|
190
|
+
make acceptance-test
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
The project is licensed under the MIT license.
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = function (api) {
|
|
2
|
+
api.cache(true);
|
|
3
|
+
const presets = ['razzle'];
|
|
4
|
+
const plugins = [
|
|
5
|
+
[
|
|
6
|
+
'react-intl', // React Intl extractor, required for the whole i18n infrastructure to work
|
|
7
|
+
{
|
|
8
|
+
messagesDir: './build/messages/',
|
|
9
|
+
},
|
|
10
|
+
],
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
plugins,
|
|
15
|
+
presets,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: \n"
|
|
4
|
+
"Report-Msgid-Bugs-To: \n"
|
|
5
|
+
"POT-Creation-Date: \n"
|
|
6
|
+
"PO-Revision-Date: \n"
|
|
7
|
+
"Last-Translator: \n"
|
|
8
|
+
"Language: de\n"
|
|
9
|
+
"Language-Team: \n"
|
|
10
|
+
"Content-Type: \n"
|
|
11
|
+
"Content-Transfer-Encoding: \n"
|
|
12
|
+
"Plural-Forms: \n"
|
|
13
|
+
|
|
14
|
+
#. Default: "Errore nella verifica del captcha"
|
|
15
|
+
#: components/Widget/FormWidget/RerCaptchaWidget
|
|
16
|
+
msgid "rercaptcha_error"
|
|
17
|
+
msgstr ""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: \n"
|
|
4
|
+
"Report-Msgid-Bugs-To: \n"
|
|
5
|
+
"POT-Creation-Date: \n"
|
|
6
|
+
"PO-Revision-Date: \n"
|
|
7
|
+
"Last-Translator: \n"
|
|
8
|
+
"Language: en\n"
|
|
9
|
+
"Language-Team: \n"
|
|
10
|
+
"Content-Type: \n"
|
|
11
|
+
"Content-Transfer-Encoding: \n"
|
|
12
|
+
"Plural-Forms: \n"
|
|
13
|
+
|
|
14
|
+
#. Default: "Errore nella verifica del captcha"
|
|
15
|
+
#: components/Widget/FormWidget/RerCaptchaWidget
|
|
16
|
+
msgid "rercaptcha_error"
|
|
17
|
+
msgstr ""
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: Plone\n"
|
|
4
|
+
"Report-Msgid-Bugs-To: \n"
|
|
5
|
+
"POT-Creation-Date: 2023-05-09 11:45-0400\n"
|
|
6
|
+
"PO-Revision-Date: 2023-05-10 11:34-0400\n"
|
|
7
|
+
"Last-Translator: Leonardo J. Caballero G. <leonardocaballero@gmail.com>\n"
|
|
8
|
+
"Language: es\n"
|
|
9
|
+
"Language-Team: ES <LL@li.org>\n"
|
|
10
|
+
"Content-Type: text/plain; charset=utf-8\n"
|
|
11
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
12
|
+
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
|
13
|
+
"Preferred-Encodings: utf-8\n"
|
|
14
|
+
"MIME-Version: 1.0\n"
|
|
15
|
+
"Language-Code: es\n"
|
|
16
|
+
"Language-Name: Español\n"
|
|
17
|
+
"Domain: volto\n"
|
|
18
|
+
"X-Is-Fallback-For: es-ar es-bo es-cl es-co es-cr es-do es-ec es-es es-sv es-gt es-hn es-mx es-ni es-pa es-py es-pe es-pr es-us es-uy es-ve\n"
|
|
19
|
+
"X-Generator: Poedit 2.2.1\n"
|
|
20
|
+
|
|
21
|
+
#. Default: "Errore nella verifica del captcha"
|
|
22
|
+
#: components/Widget/FormWidget/RerCaptchaWidget
|
|
23
|
+
msgid "rercaptcha_error"
|
|
24
|
+
msgstr ""
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: Plone\n"
|
|
4
|
+
"Report-Msgid-Bugs-To: \n"
|
|
5
|
+
"POT-Creation-Date: 2023-04-06T16:01:32.969Z\n"
|
|
6
|
+
"PO-Revision-Date: \n"
|
|
7
|
+
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
8
|
+
"Language: \n"
|
|
9
|
+
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
10
|
+
"Content-Type: text/plain; charset=utf-8\n"
|
|
11
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
12
|
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
13
|
+
"MIME-Version: 1.0\n"
|
|
14
|
+
"Language-Code: pt_BR\n"
|
|
15
|
+
"Language-Name: Português do Brasil\n"
|
|
16
|
+
"Preferred-Encodings: utf-8\n"
|
|
17
|
+
"Domain: volto\n"
|
|
18
|
+
|
|
19
|
+
#. Default: "Errore nella verifica del captcha"
|
|
20
|
+
#: components/Widget/FormWidget/RerCaptchaWidget
|
|
21
|
+
msgid "rercaptcha_error"
|
|
22
|
+
msgstr ""
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
msgid ""
|
|
2
|
+
msgstr ""
|
|
3
|
+
"Project-Id-Version: Plone\n"
|
|
4
|
+
"POT-Creation-Date: 2026-03-24T10:57:51.169Z\n"
|
|
5
|
+
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
6
|
+
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
7
|
+
"Content-Type: text/plain; charset=utf-8\n"
|
|
8
|
+
"Content-Transfer-Encoding: 8bit\n"
|
|
9
|
+
"Plural-Forms: nplurals=1; plural=0;\n"
|
|
10
|
+
"MIME-Version: 1.0\n"
|
|
11
|
+
"Language-Code: en\n"
|
|
12
|
+
"Language-Name: English\n"
|
|
13
|
+
"Preferred-Encodings: utf-8\n"
|
|
14
|
+
"Domain: volto\n"
|
|
15
|
+
|
|
16
|
+
#. Default: "Errore nella verifica del captcha"
|
|
17
|
+
#: components/Widget/FormWidget/RerCaptchaWidget
|
|
18
|
+
msgid "rercaptcha_error"
|
|
19
|
+
msgstr ""
|
package/news/.gitkeep
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@regioneer/volto-collective-rercaptcha",
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
|
+
"description": "Integration with rercaptcha in Plone",
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"volto-addon",
|
|
9
|
+
"volto",
|
|
10
|
+
"plone",
|
|
11
|
+
"react"
|
|
12
|
+
],
|
|
13
|
+
"author": "RedTurtle Technology",
|
|
14
|
+
"homepage": "https://github.com/collective/collective-rercaptcha#readme",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git@github.com:collective/collective-rercaptcha"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"addons": [],
|
|
23
|
+
"theme": "",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@plone/scripts": "^3.6.2",
|
|
26
|
+
"release-it": "^19.0.6"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"design-react-kit": "5.0.0-1",
|
|
30
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
31
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
32
|
+
"reactstrap": "^9.1.4",
|
|
33
|
+
"volto-feedback": "0.7.2",
|
|
34
|
+
"volto-form-block": "3.17.1"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@cap.js/widget": "^0.1.41"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"i18n": "rm -rf build/messages && NODE_ENV=production i18n --addon",
|
|
41
|
+
"dry-release": "release-it --dry-run",
|
|
42
|
+
"release": "release-it",
|
|
43
|
+
"release-major-alpha": "release-it major --preRelease=alpha",
|
|
44
|
+
"release-alpha": "release-it --preRelease=alpha"
|
|
45
|
+
}
|
|
46
|
+
}
|
package/public/.gitkeep
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SidebarPortal } from '@plone/volto/components';
|
|
3
|
+
import View from './View';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Props per il componente Edit del blocco CaptchaTestBlock.
|
|
7
|
+
*/
|
|
8
|
+
interface CaptchaTestEditProps {
|
|
9
|
+
/** Stato interno del blocco in Volto */
|
|
10
|
+
data: {
|
|
11
|
+
endpoint?: string;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
/** Funzione per salvare le modifiche al blocco */
|
|
15
|
+
onChangeBlock: (blockId: string, newData: any) => void;
|
|
16
|
+
/** Identificativo univoco del blocco nella pagina */
|
|
17
|
+
block: string;
|
|
18
|
+
/** Indica se il blocco è attualmente selezionato dall'utente */
|
|
19
|
+
selected: boolean;
|
|
20
|
+
/** Proprietà extra di Volto */
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* CaptchaTestEdit: Configurazione laterale (sidebar) del blocco di test.
|
|
26
|
+
*
|
|
27
|
+
* SCELTE TECNICHE:
|
|
28
|
+
* - Uso di SidebarPortal per inserire la configurazione nella barra laterale di Volto.
|
|
29
|
+
* - Sostituzione di Semantic UI con classi standard Volto (field, segment, group)
|
|
30
|
+
* per evitare problemi di tipizzazione JSX complessi.
|
|
31
|
+
*/
|
|
32
|
+
const Edit: React.FC<CaptchaTestEditProps> = (props) => {
|
|
33
|
+
const { data, onChangeBlock, block, selected } = props;
|
|
34
|
+
|
|
35
|
+
/** Gestisce il cambiamento dell'endpoint nella sidebar */
|
|
36
|
+
const handleEndpointChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
37
|
+
const { name, value } = e.target;
|
|
38
|
+
onChangeBlock(block, {
|
|
39
|
+
...data,
|
|
40
|
+
[name]: value,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
{/* Visualizza l'anteprima del blocco nell'editor centrale */}
|
|
47
|
+
<View {...props} isEdit={true} />
|
|
48
|
+
|
|
49
|
+
{/* Pannello laterale per la configurazione dell'endpoint */}
|
|
50
|
+
<SidebarPortal selected={selected}>
|
|
51
|
+
<div className="ui segment-group" style={{ padding: '10px' }}>
|
|
52
|
+
<div className="ui segment">
|
|
53
|
+
<h4>Configurazione Test Captcha PoW</h4>
|
|
54
|
+
<div className="field">
|
|
55
|
+
<label htmlFor="endpoint">URL Endpoint API Captcha</label>
|
|
56
|
+
<input
|
|
57
|
+
id="endpoint"
|
|
58
|
+
name="endpoint"
|
|
59
|
+
type="text"
|
|
60
|
+
className="ui input"
|
|
61
|
+
value={data.endpoint || ''}
|
|
62
|
+
placeholder="https://captcha.gurl.eu.org/api/"
|
|
63
|
+
onChange={handleEndpointChange}
|
|
64
|
+
/>
|
|
65
|
+
<p
|
|
66
|
+
className="help-text"
|
|
67
|
+
style={{ fontSize: '0.9em', color: '#666', marginTop: '5px' }}
|
|
68
|
+
>
|
|
69
|
+
Inserisci l'URL dell'API del servizio captcha che genera la
|
|
70
|
+
sfida SHA-256.
|
|
71
|
+
</p>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</SidebarPortal>
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default Edit;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { RerCapWidget } from '../../index';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Interfaccia per i dati salvati nel blocco CaptchaTest.
|
|
6
|
+
*/
|
|
7
|
+
interface CaptchaTestData {
|
|
8
|
+
/** URL dell'endpoint API configurato tramite la sidebar */
|
|
9
|
+
endpoint?: string;
|
|
10
|
+
/** Altri campi potenziali salvati nel blocco */
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Props ricevute dal componente View del blocco Volto.
|
|
16
|
+
*/
|
|
17
|
+
interface CaptchaTestViewProps {
|
|
18
|
+
/** Oggetto contenente la configurazione del blocco */
|
|
19
|
+
data: CaptchaTestData;
|
|
20
|
+
/** Identificativo univoco del blocco nella pagina */
|
|
21
|
+
id?: string;
|
|
22
|
+
/** Indica se il componente è renderizzato all'interno dell'editor */
|
|
23
|
+
isEdit?: boolean;
|
|
24
|
+
/** Proprietà della pagina corrente (metadata) */
|
|
25
|
+
properties?: any;
|
|
26
|
+
/** Percorso corrente della pagina */
|
|
27
|
+
path?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* CaptchaTestView: Componente di visualizzazione del blocco di test.
|
|
32
|
+
*
|
|
33
|
+
* Utilizza le props tipizzate per gestire la configurazione dell'endpoint
|
|
34
|
+
* e visualizzare il progresso del calcolo PoW.
|
|
35
|
+
*/
|
|
36
|
+
const View: React.FC<CaptchaTestViewProps> = (props) => {
|
|
37
|
+
const { data } = props;
|
|
38
|
+
const [status, setStatus] = useState<string>('In attesa di avvio...');
|
|
39
|
+
const [token, setToken] = useState<string>('');
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Determinazione dell'endpoint:
|
|
43
|
+
* 1. Valore salvato nel blocco (data.endpoint)
|
|
44
|
+
* 2. Fallback su un endpoint di test pubblico se vuoto.
|
|
45
|
+
*/
|
|
46
|
+
const endpoint = data?.endpoint || 'https://captcha.gurl.eu.org/api/';
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
className="captcha-test-block-view"
|
|
51
|
+
style={{
|
|
52
|
+
padding: '20px',
|
|
53
|
+
border: '1px solid #ccc',
|
|
54
|
+
margin: '10px 0',
|
|
55
|
+
borderRadius: '4px',
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<h4 style={{ marginTop: 0 }}>Test PoW Captcha (Invisibile)</h4>
|
|
59
|
+
<p style={{ fontSize: '0.95em' }}>
|
|
60
|
+
Questo blocco carica un componente <strong>RerCapWidget</strong> che
|
|
61
|
+
esegue un calcolo Proof of Work (SHA-256) in background tramite
|
|
62
|
+
WebWorkers.
|
|
63
|
+
</p>
|
|
64
|
+
|
|
65
|
+
<div
|
|
66
|
+
style={{
|
|
67
|
+
backgroundColor: '#f9f9f9',
|
|
68
|
+
padding: '10px',
|
|
69
|
+
borderRadius: '4px',
|
|
70
|
+
}}
|
|
71
|
+
>
|
|
72
|
+
<p style={{ margin: '0 0 10px 0' }}>
|
|
73
|
+
<strong>Stato Esecuzione:</strong>{' '}
|
|
74
|
+
<span style={{ color: token ? '#21ba45' : '#4183c4' }}>{status}</span>
|
|
75
|
+
</p>
|
|
76
|
+
{token && (
|
|
77
|
+
<p style={{ margin: 0 }}>
|
|
78
|
+
<strong>Token Ricevuto:</strong> <br />
|
|
79
|
+
<code
|
|
80
|
+
style={{
|
|
81
|
+
display: 'block',
|
|
82
|
+
padding: '8px',
|
|
83
|
+
backgroundColor: '#eee',
|
|
84
|
+
marginTop: '5px',
|
|
85
|
+
wordBreak: 'break-all',
|
|
86
|
+
fontSize: '0.85em',
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{token}
|
|
90
|
+
</code>
|
|
91
|
+
</p>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
{/*
|
|
96
|
+
Integrazione del componente core invisibile.
|
|
97
|
+
Passiamo le callback per aggiornare lo stato locale di questa vista.
|
|
98
|
+
*/}
|
|
99
|
+
<RerCapWidget
|
|
100
|
+
endpoint={endpoint}
|
|
101
|
+
onSolve={(t: string) => {
|
|
102
|
+
setStatus('Risolto con successo!');
|
|
103
|
+
setToken(t);
|
|
104
|
+
// eslint-disable-next-line no-console
|
|
105
|
+
console.log('RerCapWidget: Token generato e pronto.', t);
|
|
106
|
+
}}
|
|
107
|
+
onError={(err: string) => {
|
|
108
|
+
setStatus('Errore: ' + err);
|
|
109
|
+
// eslint-disable-next-line no-console
|
|
110
|
+
console.error('RerCapWidget: Errore durante il test:', err);
|
|
111
|
+
}}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export default View;
|