Skip to content

Commit 488fedc

Browse files
authored
Merge pull request #7 from kitconcept/newFields
add new fields, move isValidUrl function, refactor & improve
2 parents d93882e + 2d0d645 commit 488fedc

File tree

16 files changed

+4869
-6983
lines changed

16 files changed

+4869
-6983
lines changed

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: prettier
5+
name: prettier
6+
entry: pnpm exec prettier --write
7+
language: system
8+
files: '^packages/.*/src/.*/?.*.(js|jsx|ts|tsx)$'
9+
types: [file]
10+
- id: eslint
11+
name: eslint
12+
entry: bash -c "VOLTOCONFIG=$(pwd)/volto.config.js pnpm exec eslint --max-warnings=0 --fix"
13+
language: system
14+
files: '^packages/.*/src/.*/?.*.(js|jsx|ts|tsx)$'
15+
types: [file]
16+
- id: stylelint
17+
name: stylelint
18+
entry: pnpm exec stylelint --fix
19+
language: system
20+
files: '^packages/.*/src/.*/?.*.(css|scss|less)$'
21+
types: [file]
22+
- id: i18n
23+
name: i18n
24+
entry: make ci-i18n
25+
language: system
26+
files: '^packages/.*/src/.*/?.*.(js|jsx|ts|tsx)$'
27+
types: [file]

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ help: ## Show this help
3333

3434
# Dev Helpers
3535

36+
.PHONY: clean
37+
clean: ## Remove old artifacts
38+
@echo "$(RED)==> Cleaning frontend environment and build$(RESET)"
39+
rm -Rf core node_modules packages/volto-iframe-block/node_modules
40+
3641
.PHONY: install
3742
install: ## Installs the add-on in a development environment
3843
@echo "$(GREEN)Install$(RESET)"

packages/volto-iframe-block/locales/de/LC_MESSAGES/volto.po

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ msgstr ""
1111
"Content-Transfer-Encoding: \n"
1212
"Plural-Forms: \n"
1313

14+
#. Default: "Credit"
15+
#: components/schema
16+
msgid "Credit"
17+
msgstr "Credit"
18+
19+
#. Default: "Description"
20+
#: components/schema
21+
msgid "Description"
22+
msgstr "Beschreibung"
23+
1424
#. Default: "Error"
1525
#: components/Edit
1626
msgid "Error"

packages/volto-iframe-block/locales/en/LC_MESSAGES/volto.po

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ msgstr ""
1111
"Content-Transfer-Encoding: \n"
1212
"Plural-Forms: \n"
1313

14+
#. Default: "Credit"
15+
#: components/schema
16+
msgid "Credit"
17+
msgstr ""
18+
19+
#. Default: "Description"
20+
#: components/schema
21+
msgid "Description"
22+
msgstr ""
23+
1424
#. Default: "Error"
1525
#: components/Edit
1626
msgid "Error"

packages/volto-iframe-block/locales/es/LC_MESSAGES/volto.po

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ msgstr ""
1818
"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"
1919
"X-Generator: Poedit 2.2.1\n"
2020

21+
#. Default: "Credit"
22+
#: components/schema
23+
msgid "Credit"
24+
msgstr ""
25+
26+
#. Default: "Description"
27+
#: components/schema
28+
msgid "Description"
29+
msgstr ""
30+
2131
#. Default: "Error"
2232
#: components/Edit
2333
msgid "Error"

packages/volto-iframe-block/locales/pt_BR/LC_MESSAGES/volto.po

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ msgstr ""
1616
"Preferred-Encodings: utf-8\n"
1717
"Domain: volto\n"
1818

19+
#. Default: "Credit"
20+
#: components/schema
21+
msgid "Credit"
22+
msgstr ""
23+
24+
#. Default: "Description"
25+
#: components/schema
26+
msgid "Description"
27+
msgstr ""
28+
1929
#. Default: "Error"
2030
#: components/Edit
2131
msgid "Error"

packages/volto-iframe-block/locales/volto.pot

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Plone\n"
4-
"POT-Creation-Date: 2024-07-05T08:15:02.107Z\n"
4+
"POT-Creation-Date: 2025-02-18T09:54:00.232Z\n"
55
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
66
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
77
"Content-Type: text/plain; charset=utf-8\n"
@@ -13,6 +13,16 @@ msgstr ""
1313
"Preferred-Encodings: utf-8\n"
1414
"Domain: volto\n"
1515

16+
#. Default: "Credit"
17+
#: components/schema
18+
msgid "Credit"
19+
msgstr ""
20+
21+
#. Default: "Description"
22+
#: components/schema
23+
msgid "Description"
24+
msgstr ""
25+
1626
#. Default: "Error"
1727
#: components/Edit
1828
msgid "Error"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Move isValidUrl to helper function so it can be shadowed. [@jnptk]
2+
Add description and credit fields. [@jnptk]
3+
Clear all fields including the input when the reset button is clicked. [@jnptk]
4+
Show title, description, and credit in the View component. [@jnptk]

packages/volto-iframe-block/src/components/Data.jsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react';
2-
import Icon from '@plone/volto/components/theme/Icon/Icon';
31
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
4-
import { defineMessages } from 'react-intl';
5-
import { IframeBlockSchema } from './schema';
6-
2+
import Icon from '@plone/volto/components/theme/Icon/Icon';
73
import applicationSVG from '@plone/volto/icons/application.svg';
84
import trashSVG from '@plone/volto/icons/delete.svg';
5+
import React from 'react';
6+
import { defineMessages } from 'react-intl';
7+
8+
import { IframeBlockSchema } from '@kitconcept/volto-iframe-block/components/schema';
99

1010
const messages = defineMessages({
1111
Iframe: {
@@ -19,16 +19,20 @@ const messages = defineMessages({
1919
});
2020

2121
const IframeSidebar = (props) => {
22-
const { intl, data, block, onChangeBlock } = props;
22+
const { intl, data, block, onChangeBlock, resetSubmitUrl } = props;
2323
const schema = IframeBlockSchema({ ...props, intl });
2424

2525
const resetBlock = () => {
2626
onChangeBlock(block, {
2727
...data,
28-
src: '',
29-
title: '',
30-
align: '',
28+
src: undefined,
29+
title: undefined,
30+
description: undefined,
31+
align: undefined,
32+
height: undefined,
33+
credit: undefined,
3134
});
35+
resetSubmitUrl();
3236
};
3337

3438
return (
@@ -52,7 +56,7 @@ const IframeSidebar = (props) => {
5256
formData={data}
5357
block={block}
5458
headerActions={
55-
<button onClick={resetBlock}>
59+
<button type="button" onClick={resetBlock}>
5660
<Icon name={trashSVG} size="24px" color="red" />
5761
</button>
5862
}

packages/volto-iframe-block/src/components/Edit.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import React, { useState } from 'react';
2-
import { toast } from 'react-toastify';
1+
import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
32
import Toast from '@plone/volto/components/manage/Toast/Toast';
4-
5-
import { defineMessages } from 'react-intl';
63
import Icon from '@plone/volto/components/theme/Icon/Icon';
7-
import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
8-
import clearSVG from '@plone/volto/icons/clear.svg';
94
import aheadSVG from '@plone/volto/icons/ahead.svg';
105
import applicationSVG from '@plone/volto/icons/application.svg';
11-
import IframeView from './View';
12-
import IframeSidebar from './Data';
13-
import { isValidUrl } from './schema';
6+
import clearSVG from '@plone/volto/icons/clear.svg';
7+
import React, { useState } from 'react';
8+
import { defineMessages } from 'react-intl';
9+
import { toast } from 'react-toastify';
10+
11+
import { isValidUrl } from '@kitconcept/volto-iframe-block/helpers/isValidUrl';
12+
import IframeSidebar from '@kitconcept/volto-iframe-block/components/Data';
13+
import IframeView from '@kitconcept/volto-iframe-block/components/View';
1414

1515
const messages = defineMessages({
1616
InputPlaceholder: {
@@ -84,6 +84,7 @@ const IframeEdit = (props) => {
8484
{url && (
8585
<div>
8686
<button
87+
type="button"
8788
className="cancel"
8889
onClick={(e) => {
8990
e.stopPropagation();
@@ -96,6 +97,7 @@ const IframeEdit = (props) => {
9697
)}
9798
<div>
9899
<button
100+
type="button"
99101
disabled={!url}
100102
onClick={(e) => {
101103
e.stopPropagation();
@@ -116,7 +118,7 @@ const IframeEdit = (props) => {
116118
)}
117119

118120
<SidebarPortal selected={props.selected}>
119-
<IframeSidebar {...props} />
121+
<IframeSidebar {...props} resetSubmitUrl={resetSubmitUrl} />
120122
</SidebarPortal>
121123
</div>
122124
);

0 commit comments

Comments
 (0)