Skip to content

Commit 518b9de

Browse files
Merge pull request #28 from flotiq/feature/27220-refactor-form-plugins-to-new-form-api
#27220 refactor form events to use new form API
2 parents 7e3c5d7 + 319dd0c commit 518b9de

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.1.1]
9+
### Changed
10+
* refactor form events to use new form API #27220
11+
812
## [1.1.0]
913
### Added
1014
* Changelog

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"type": "module",
33
"license": "MIT",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"scripts": {
66
"build": "node esbuild.config.js",
77
"start": "node esbuild.config.js --watch"

plugin-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "flotiq.custom-links",
33
"name": "Custom Links",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"description": "This plugin will display a button with a link in the edit content object. The link will be supplemented with data from the currently edited object. Thanks to this link, you will be able to get easy access to the preview of where the content is used.",
66
"repository": "https://github.com/flotiq/flotiq-ui-plugins-custom-links",
77
"url": "https://localhost:3053/index.js",

plugins/index.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@ const loadStyles = () => {
1515
}
1616
};
1717

18-
registerFn(pluginInfo, (handler, _client, { getLanguage }) => {
19-
loadStyles();
18+
registerFn(
19+
pluginInfo,
20+
(handler, _client, { getLanguage, getPluginSettings }) => {
21+
loadStyles();
2022

21-
handler.on('flotiq.plugins.manage::form-schema', (data) =>
22-
handleManagePlugin(data, pluginInfo, getLanguage),
23-
);
24-
handler.on('flotiq.form.sidebar-panel::add', (data) =>
25-
handlePanelPlugin(data, pluginInfo),
26-
);
27-
});
23+
handler.on('flotiq.plugins.manage::form-schema', (data) =>
24+
handleManagePlugin(data, pluginInfo, getLanguage),
25+
);
26+
handler.on('flotiq.form.sidebar-panel::add', (data) =>
27+
handlePanelPlugin(data, pluginInfo, getPluginSettings),
28+
);
29+
},
30+
);
2831

2932
const pluginManagePreviewRoot = document.getElementById('manage-preview-root');
3033
const pluginPanelPreviewRoot = document.getElementById('panel-preview-root');

plugins/panelPlugin/panelPlugin.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
addElementToCache,
33
getCachedElement,
4-
deepReadKeyValue
4+
deepReadKeyValue,
55
} from '../../common/plugin-helpers';
66

77
const onClick = (e) => {
@@ -11,23 +11,21 @@ const onClick = (e) => {
1111
};
1212

1313
export const handlePanelPlugin = (
14-
{ contentType, contentObject, duplicate, create, userPlugins },
14+
{ contentType, contentObject, duplicate, create },
1515
pluginInfo,
16+
getPluginSettings,
1617
) => {
17-
const customLinksSettings = userPlugins?.find(
18-
({ id }) => id === pluginInfo.id,
19-
)?.settings;
20-
18+
const pluginSettings = getPluginSettings();
2119
if (
2220
!contentObject ||
2321
!contentType?.name ||
2422
create ||
2523
duplicate ||
26-
!customLinksSettings
24+
!pluginSettings
2725
)
2826
return null;
2927

30-
const settingsForCtd = JSON.parse(customLinksSettings)?.settings?.filter(
28+
const settingsForCtd = JSON.parse(pluginSettings)?.settings?.filter(
3129
(plugin) =>
3230
plugin.content_types.length === 0 ||
3331
plugin.content_types.find((ctd) => ctd === contentType.name),
@@ -93,16 +91,11 @@ export const loadPanelPlugin = (pluginPanelPreviewRoot) => {
9391
contentObject: { id: 'id', name: 'co name' },
9492
duplicate: false,
9593
create: false,
96-
userPlugins: [
97-
{
98-
id: 'plugin-id',
99-
settings:
100-
// eslint-disable-next-line max-len
101-
'{"settings":[{"url_template":"example.com","link_template":"Link","content_types":[]}, {"url_template":"example.com","link_template":"Link to {name}","content_types":[]}]}',
102-
},
103-
],
10494
},
10595
{ id: 'plugin-id' },
96+
() =>
97+
// eslint-disable-next-line max-len
98+
'{"settings":[{"url_template":"example.com","link_template":"Link","content_types":[]}, {"url_template":"example.com","link_template":"Link to {name}","content_types":[]}]}',
10699
);
107100

108101
element.style.border = '1px solid #DAE3F2';

0 commit comments

Comments
 (0)