Skip to content

Commit 1091780

Browse files
committed
chore: update app-runtime
1 parent d9edcd9 commit 1091780

File tree

2 files changed

+60
-14
lines changed

2 files changed

+60
-14
lines changed

patches/@dhis2+app-service-plugin+3.12.0.patch

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/node_modules/@dhis2/app-service-plugin/build/cjs/Plugin.js b/node_modules/@dhis2/app-service-plugin/build/cjs/Plugin.js
2-
index ffd1cf0..e9515dd 100644
2+
index ffd1cf0..9994d97 100644
33
--- a/node_modules/@dhis2/app-service-plugin/build/cjs/Plugin.js
44
+++ b/node_modules/@dhis2/app-service-plugin/build/cjs/Plugin.js
55
@@ -38,6 +38,8 @@ const Plugin = _ref3 => {
@@ -11,17 +11,38 @@ index ffd1cf0..e9515dd 100644
1111
...propsToPassNonMemoized
1212
} = _ref3;
1313
const iframeRef = (0, _react.useRef)(null);
14-
@@ -79,7 +81,8 @@ const Plugin = _ref3 => {
14+
@@ -54,7 +56,14 @@ const Plugin = _ref3 => {
15+
const [communicationReceived, setCommunicationReceived] = (0, _react.useState)(false);
16+
const [prevCommunicationReceived, setPrevCommunicationReceived] = (0, _react.useState)(false);
17+
const [inErrorState, setInErrorState] = (0, _react.useState)(false);
18+
+ // height and width values to be set by callbacks passed to the plugin
19+
+ // (these default sizes will be quickly overwritten by the plugin)
20+
+ // in order to behave like a normal block element, by default, the height
21+
+ // will be set by plugin contents, this state will be used
22+
const [resizedHeight, setPluginHeight] = (0, _react.useState)(150);
23+
+ // ...and by default, plugin width will be defined by the container
24+
+ // (width = 100%), so this state won't be used unless the `clientWidth`
25+
+ // prop is used to have plugin width defined by plugin contents
26+
const [resizedWidth, setPluginWidth] = (0, _react.useState)(500);
27+
28+
// since we do not know what props are passed, the dependency array has to be keys of whatever is standard prop
29+
@@ -76,10 +85,13 @@ const Plugin = _ref3 => {
30+
const iframeProps = {
31+
...memoizedPropsToPass,
32+
alertsAdd,
33+
+ // if a dimension is specified or container driven, don't send
34+
+ // a resize callback to the plugin
1535
setPluginHeight: !height ? setPluginHeight : null,
16-
setPluginWidth: !width ? setPluginWidth : null,
36+
- setPluginWidth: !width ? setPluginWidth : null,
37+
+ setPluginWidth: !width && clientWidth ? setPluginWidth : null,
1738
setInErrorState,
1839
- setCommunicationReceived
1940
+ setCommunicationReceived,
2041
+ clientWidth
2142
};
2243

2344
// if iframe has not sent initial request, set up a listener
24-
@@ -112,17 +115,18 @@ const Plugin = _ref3 => {
45+
@@ -112,17 +124,21 @@ const Plugin = _ref3 => {
2546
appShortName: pluginShortName
2647
});
2748
}
@@ -42,9 +63,12 @@ index ffd1cf0..e9515dd 100644
4263
+ return /*#__PURE__*/_react.default.createElement("iframe", {
4364
+ ref: iframeRef,
4465
+ src: pluginSource,
45-
+ className: className,
66+
+ className: className
67+
+ // if clientWidth is set, then we want width to be set by plugin.
68+
+ // otherwise,
69+
+ ,
4670
+ width: clientWidth ? resizedWidth : width !== null && width !== void 0 ? width : '100%',
47-
+ height: height !== null && height !== void 0 ? height : resizedHeight + 'px',
71+
+ height: height !== null && height !== void 0 ? height : resizedHeight,
4872
+ style: {
4973
+ border: 'none'
5074
+ }
@@ -53,7 +77,7 @@ index ffd1cf0..e9515dd 100644
5377
exports.Plugin = Plugin;
5478
\ No newline at end of file
5579
diff --git a/node_modules/@dhis2/app-service-plugin/build/es/Plugin.js b/node_modules/@dhis2/app-service-plugin/build/es/Plugin.js
56-
index f3d29cd..6470e0f 100644
80+
index f3d29cd..9878c4c 100644
5781
--- a/node_modules/@dhis2/app-service-plugin/build/es/Plugin.js
5882
+++ b/node_modules/@dhis2/app-service-plugin/build/es/Plugin.js
5983
@@ -29,6 +29,8 @@ export const Plugin = _ref3 => {
@@ -65,17 +89,38 @@ index f3d29cd..6470e0f 100644
6589
...propsToPassNonMemoized
6690
} = _ref3;
6791
const iframeRef = useRef(null);
68-
@@ -70,7 +72,8 @@ export const Plugin = _ref3 => {
92+
@@ -45,7 +47,14 @@ export const Plugin = _ref3 => {
93+
const [communicationReceived, setCommunicationReceived] = useState(false);
94+
const [prevCommunicationReceived, setPrevCommunicationReceived] = useState(false);
95+
const [inErrorState, setInErrorState] = useState(false);
96+
+ // height and width values to be set by callbacks passed to the plugin
97+
+ // (these default sizes will be quickly overwritten by the plugin)
98+
+ // in order to behave like a normal block element, by default, the height
99+
+ // will be set by plugin contents, this state will be used
100+
const [resizedHeight, setPluginHeight] = useState(150);
101+
+ // ...and by default, plugin width will be defined by the container
102+
+ // (width = 100%), so this state won't be used unless the `clientWidth`
103+
+ // prop is used to have plugin width defined by plugin contents
104+
const [resizedWidth, setPluginWidth] = useState(500);
105+
106+
// since we do not know what props are passed, the dependency array has to be keys of whatever is standard prop
107+
@@ -67,10 +76,13 @@ export const Plugin = _ref3 => {
108+
const iframeProps = {
109+
...memoizedPropsToPass,
110+
alertsAdd,
111+
+ // if a dimension is specified or container driven, don't send
112+
+ // a resize callback to the plugin
69113
setPluginHeight: !height ? setPluginHeight : null,
70-
setPluginWidth: !width ? setPluginWidth : null,
114+
- setPluginWidth: !width ? setPluginWidth : null,
115+
+ setPluginWidth: !width && clientWidth ? setPluginWidth : null,
71116
setInErrorState,
72117
- setCommunicationReceived
73118
+ setCommunicationReceived,
74119
+ clientWidth
75120
};
76121

77122
// if iframe has not sent initial request, set up a listener
78-
@@ -103,16 +106,17 @@ export const Plugin = _ref3 => {
123+
@@ -103,16 +115,20 @@ export const Plugin = _ref3 => {
79124
appShortName: pluginShortName
80125
});
81126
}
@@ -96,9 +141,12 @@ index f3d29cd..6470e0f 100644
96141
+ return /*#__PURE__*/React.createElement("iframe", {
97142
+ ref: iframeRef,
98143
+ src: pluginSource,
99-
+ className: className,
144+
+ className: className
145+
+ // if clientWidth is set, then we want width to be set by plugin.
146+
+ // otherwise,
147+
+ ,
100148
+ width: clientWidth ? resizedWidth : width !== null && width !== void 0 ? width : '100%',
101-
+ height: height !== null && height !== void 0 ? height : resizedHeight + 'px',
149+
+ height: height !== null && height !== void 0 ? height : resizedHeight,
102150
+ style: {
103151
+ border: 'none'
104152
+ }

shell/src/PluginLoader.jsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,6 @@ export const PluginLoader = ({ config, requiredProps, D2App }) => {
169169
setShowAlertsInPlugin(Boolean(showAlertsInPlugin))
170170
}
171171

172-
console.log({ width, height })
173-
174172
// if these resize callbacks are defined, then that dimension isn't
175173
// fixed or container-driven; add them to the props list here
176174
// It will be called by a resize observer in ResizePluginInner

0 commit comments

Comments
 (0)