Skip to content

Commit 5ba7c26

Browse files
committed
CONSOLE-4407: Update to PF CodeEditor prerelease
Also - merge remote-tracking branch 'upstream/main' into CONSOLE-4407-monaco - limit the width of the yaml editor container
2 parents c14790b + 12fa88b commit 5ba7c26

File tree

66 files changed

+791
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+791
-554
lines changed

dynamic-demo-plugin/console-extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
},
197197
"page": {
198198
"name": "Demo Plugin",
199-
"href": "/demo-plugin"
199+
"href": "demo-plugin"
200200
},
201201
"component": { "$codeRef": "projectTabContent" }
202202
}

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
"@patternfly/quickstarts": "^6.2.0-prerelease.4",
138138
"@patternfly/react-catalog-view-extension": "^6.1.0-prerelease.3",
139139
"@patternfly/react-charts": "^8.2.0-prerelease.13",
140-
"@patternfly/react-code-editor": "^6.1.0",
140+
"@patternfly/react-code-editor": "^6.2.0-prerelease.21",
141141
"@patternfly/react-component-groups": "^6.2.0-prerelease.4",
142142
"@patternfly/react-console": "^6.0.0",
143143
"@patternfly/react-core": "^6.2.0-prerelease.15",

frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-core.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
# Changelog for `@openshift-console/dynamic-plugin-sdk`
22

3-
Refer to [Console dynamic plugins README](./README.md) for OpenShift Console version vs SDK package
4-
version and PatternFly version compatibility.
3+
Console plugin SDK packages follow a semver scheme where the major and minor version number indicates
4+
the earliest supported OCP Console version, and the patch version number indicates the release of that
5+
particular package.
6+
7+
For released (GA) versions of Console, use `4.x.z` packages.
8+
For current development version of Console, use `4.x.0-prerelease.n` packages.
9+
10+
For 1.x plugin SDK packages, refer to "OpenShift Console Versions vs SDK Versions" compatibility table
11+
in [Console dynamic plugins README](./README.md).
12+
13+
## 4.19.0-prerelease.1 - 2025-02-14
14+
15+
- Remove Console provided PatternFly 4 shared modules ([CONSOLE-4379], [#14615])
16+
- Add `customData` prop to `HorizontalNav` component ([OCPBUGS-45319], [#14575])
17+
- Allow custom popover description in extension type `console.resource/details-item` ([CONSOLE-4269], [#14487])
18+
- Change generated JS build target from `es2016` to `es2021` ([CONSOLE-4400], [#14620])
519

620
## 1.8.0 - 2024-11-04
721

@@ -63,6 +77,9 @@ version and PatternFly version compatibility.
6377
[CONSOLE-4097]: https://issues.redhat.com/browse/CONSOLE-4097
6478
[CONSOLE-4185]: https://issues.redhat.com/browse/CONSOLE-4185
6579
[CONSOLE-4263]: https://issues.redhat.com/browse/CONSOLE-4263
80+
[CONSOLE-4269]: https://issues.redhat.com/browse/CONSOLE-4269
81+
[CONSOLE-4379]: https://issues.redhat.com/browse/CONSOLE-4379
82+
[CONSOLE-4400]: https://issues.redhat.com/browse/CONSOLE-4400
6683
[OCPBUGS-19048]: https://issues.redhat.com/browse/OCPBUGS-19048
6784
[OCPBUGS-30077]: https://issues.redhat.com/browse/OCPBUGS-30077
6885
[OCPBUGS-31355]: https://issues.redhat.com/browse/OCPBUGS-31355
@@ -74,6 +91,7 @@ version and PatternFly version compatibility.
7491
[OCPBUGS-37426]: https://issues.redhat.com/browse/OCPBUGS-37426
7592
[OCPBUGS-43538]: https://issues.redhat.com/browse/OCPBUGS-43538
7693
[OCPBUGS-43998]: https://issues.redhat.com/browse/OCPBUGS-43998
94+
[OCPBUGS-45319]: https://issues.redhat.com/browse/OCPBUGS-45319
7795
[ODC-7425]: https://issues.redhat.com/browse/ODC-7425
7896
[#12983]: https://github.com/openshift/console/pull/12983
7997
[#13233]: https://github.com/openshift/console/pull/13233
@@ -96,3 +114,7 @@ version and PatternFly version compatibility.
96114
[#14156]: https://github.com/openshift/console/pull/14156
97115
[#14421]: https://github.com/openshift/console/pull/14421
98116
[#14447]: https://github.com/openshift/console/pull/14447
117+
[#14487]: https://github.com/openshift/console/pull/14487
118+
[#14575]: https://github.com/openshift/console/pull/14575
119+
[#14615]: https://github.com/openshift/console/pull/14615
120+
[#14620]: https://github.com/openshift/console/pull/14620

frontend/packages/console-dynamic-plugin-sdk/CHANGELOG-webpack.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
# Changelog for `@openshift-console/dynamic-plugin-sdk-webpack`
22

3-
Refer to [Console dynamic plugins README](./README.md) for OpenShift Console version vs SDK package
4-
version and PatternFly version compatibility.
3+
Console plugin SDK packages follow a semver scheme where the major and minor version number indicates
4+
the earliest supported OCP Console version, and the patch version number indicates the release of that
5+
particular package.
6+
7+
For released (GA) versions of Console, use `4.x.z` packages.
8+
For current development version of Console, use `4.x.0-prerelease.n` packages.
9+
10+
For 1.x plugin SDK packages, refer to "OpenShift Console Versions vs SDK Versions" compatibility table
11+
in [Console dynamic plugins README](./README.md).
12+
13+
## 4.19.0-prerelease.1 - 2025-02-14
14+
15+
- Remove Console provided PatternFly 4 shared modules ([CONSOLE-4379], [#14615])
16+
- Change generated JS build target from `es2016` to `es2021` ([CONSOLE-4400], [#14620])
517

618
## 1.3.0 - 2024-10-31
719

@@ -39,6 +51,8 @@ version and PatternFly version compatibility.
3951

4052
[CONSOLE-3705]: https://issues.redhat.com/browse/CONSOLE-3705
4153
[CONSOLE-3853]: https://issues.redhat.com/browse/CONSOLE-3853
54+
[CONSOLE-4379]: https://issues.redhat.com/browse/CONSOLE-4379
55+
[CONSOLE-4400]: https://issues.redhat.com/browse/CONSOLE-4400
4256
[OCPBUGS-30762]: https://issues.redhat.com/browse/OCPBUGS-30762
4357
[OCPBUGS-30824]: https://issues.redhat.com/browse/OCPBUGS-30824
4458
[OCPBUGS-31901]: https://issues.redhat.com/browse/OCPBUGS-31901
@@ -58,3 +72,5 @@ version and PatternFly version compatibility.
5872
[#13992]: https://github.com/openshift/console/pull/13992
5973
[#14167]: https://github.com/openshift/console/pull/14167
6074
[#14300]: https://github.com/openshift/console/pull/14300
75+
[#14615]: https://github.com/openshift/console/pull/14615
76+
[#14620]: https://github.com/openshift/console/pull/14620

frontend/packages/console-dynamic-plugin-sdk/README.md

Lines changed: 59 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,22 @@ used with multiple versions of OpenShift Console but don't provide any backwards
7676

7777
## OpenShift Console Versions vs SDK Versions
7878

79-
Not all NPM packages are fully compatible with all versions of the Console. This table will help align
80-
compatible versions of distributable SDK packages to versions of the OpenShift Console.
79+
Console plugin SDK packages follow a semver scheme where the major and minor version number indicates
80+
the earliest supported OCP Console version, and the patch version number indicates the release of that
81+
particular package.
82+
83+
During development, we will publish prerelease versions of plugin SDK packages, e.g. `4.19.0-prerelease.1`.
84+
Once the given Console version is released (GA), we will publish corresponding plugin SDK packages without
85+
the prerelease tag, e.g. `4.19.0`.
86+
87+
For older 1.x plugin SDK packages, refer to the following version compatibility table:
8188

8289
| Console Version | SDK Package | Last Package Version |
8390
| --------------- | ----------------------------------------------- | -------------------- |
84-
| 4.17.x | `@openshift-console/dynamic-plugin-sdk` | Latest |
85-
| | `@openshift-console/dynamic-plugin-sdk-webpack` | Latest |
91+
| 4.18.x | `@openshift-console/dynamic-plugin-sdk` | 1.8.0 |
92+
| | `@openshift-console/dynamic-plugin-sdk-webpack` | 1.3.0 |
93+
| 4.17.x | `@openshift-console/dynamic-plugin-sdk` | 1.6.0 |
94+
| | `@openshift-console/dynamic-plugin-sdk-webpack` | 1.2.0 |
8695
| 4.16.x | `@openshift-console/dynamic-plugin-sdk` | 1.4.0 |
8796
| | `@openshift-console/dynamic-plugin-sdk-webpack` | 1.1.1 |
8897
| 4.15.x | `@openshift-console/dynamic-plugin-sdk` | 1.0.0 |
@@ -156,21 +165,21 @@ This section documents notable changes in the Console provided shared modules ac
156165

157166
#### Console 4.19.x
158167

168+
- Removed PatternFly 4.x shared modules. Console now uses PatternFly 6.x and provides PatternFly 5.x
169+
styles for compatibility with existing plugins.
159170
- Removed `@fortawesome/font-awesome` and `openshift-logos-icon`. Plugins should use PatternFly icons
160171
from `@patternfly/react-icons` instead. The `fa-spin` class remains but is deprecated and will be
161172
removed in the future. Plugins should provide their own CSS to spin icons if needed.
162-
- Upgraded `monaco-editor` to version `0.52.2`.
163-
- Removed PatternFly 4.x shared modules.
164-
- Upgraded PatternFly to v6.
165-
- Removed styling for generic HTML heading elements (e.g., `<h1>`). Use PatternFly components to achieve correct styling.
173+
- Upgraded `monaco-editor` to version `0.51.0`.
174+
- Removed styling for generic HTML heading elements (e.g., `<h1>`). Use PatternFly components to achieve
175+
correct styling.
166176

167-
### PatternFly dynamic modules
177+
### PatternFly 5+ dynamic modules
168178

169-
Newer versions of `@openshift-console/dynamic-plugin-sdk-webpack` package (1.0.0 and higher) include
170-
support for automatic detection and sharing of individual PatternFly 5.x dynamic modules.
179+
Newer versions of `@openshift-console/dynamic-plugin-sdk-webpack` package include support for automatic
180+
detection and sharing of individual PatternFly 5+ dynamic modules.
171181

172-
Plugins using PatternFly 5.x dependencies should generally avoid non-index imports for any PatternFly
173-
packages, for example:
182+
Plugins using PatternFly 5.x and newer should avoid non-index imports, for example:
174183

175184
```ts
176185
// Do _not_ do this:
@@ -187,20 +196,51 @@ Console application uses [Content Security Policy](https://developer.mozilla.org
187196
includes the document origin `'self'` and Console webpack dev server when running off-cluster.
188197

189198
All dynamic plugin assets _should_ be loaded using `/api/plugins/<plugin-name>` Bridge endpoint which
190-
matches the `'self'` CSP source of Console application.
199+
matches the `'self'` CSP source for all Console assets served via Bridge.
191200

192-
See `cspSources` and `cspDirectives` in
193-
[`pkg/server/server.go`](https://github.com/openshift/console/blob/master/pkg/server/server.go)
201+
Refer to `BuildCSPDirectives` function in
202+
[`pkg/utils/utils.go`](https://github.com/openshift/console/blob/master/pkg/utils/utils.go)
194203
for details on the current Console CSP implementation.
195204

205+
Refer to [Dynamic Plugins feature page][console-doc-feature-page] section on Content Security Policy
206+
for more details.
207+
196208
### Changes in Console CSP
197209

198-
This section documents notable changes in the Console Content Security Policy.
210+
This section documents notable changes in the Console Content Security Policy implementation.
199211

200212
#### Console 4.18.x
201213

202-
Console CSP is deployed in report-only mode. CSP violations will be logged in the browser console
203-
but the associated CSP directives will not be enforced.
214+
Console CSP feature is disabled by default. To test your plugins with CSP, enable the
215+
`ConsolePluginContentSecurityPolicy` feature gate on a test cluster. This feature gate
216+
should **not** be enabled on production clusters. Enabling this feature gate allows you
217+
to set `spec.contentSecurityPolicy` in your `ConsolePlugin` resource to extend existing
218+
CSP directives, for example:
219+
220+
```yaml
221+
apiVersion: console.openshift.io/v1
222+
kind: ConsolePlugin
223+
metadata:
224+
name: cron-tab
225+
spec:
226+
displayName: 'Cron Tab'
227+
contentSecurityPolicy:
228+
- directive: 'ScriptSrc'
229+
values:
230+
- 'https://example1.com/'
231+
- 'https://example2.com/'
232+
```
233+
234+
When enabled, Console CSP operates in report-only mode; CSP violations will be logged in
235+
the browser and CSP violation data will be reported through telemetry service in production
236+
deployments.
237+
238+
In a future release, Console will begin enforcing CSP. Consider testing and preparing your
239+
plugins now to avoid CSP related issues in future.
240+
241+
#### Console 4.19.x
242+
243+
The CSP feature is enabled by default. CSP implementation remains in report-only mode.
204244
205245
## Plugin metadata
206246
Lines changed: 27 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as React from 'react';
22
import { loader, Monaco } from '@monaco-editor/react';
33
import { CodeEditor } from '@patternfly/react-code-editor';
4-
import { getResizeObserver } from '@patternfly/react-core';
54
import classNames from 'classnames';
65
import * as monaco from 'monaco-editor';
76
import { useTranslation } from 'react-i18next';
87
import { BasicCodeEditorProps } from '@console/dynamic-plugin-sdk';
8+
import { ErrorBoundaryInline } from '@console/shared/src/components/error';
99
import { useConsoleMonacoTheme } from './theme';
1010
import './BasicCodeEditor.scss';
1111

@@ -24,46 +24,32 @@ export const BasicCodeEditor: React.FC<BasicCodeEditorProps> = (props) => {
2424
const [monacoRef, setMonacoRef] = React.useState<Monaco | null>(null);
2525
useConsoleMonacoTheme(monacoRef?.editor);
2626

27-
// TODO(PF6): remove this when https://github.com/patternfly/patternfly-react/issues/11531 is fixed
28-
const handleResize = React.useCallback(() => {
29-
monacoRef?.editor?.getEditors()?.forEach((editor) => {
30-
editor.layout({ width: 0, height: 0 });
31-
editor.layout();
32-
});
33-
}, [monacoRef]);
34-
35-
React.useEffect(() => {
36-
const observer = getResizeObserver(undefined, handleResize, true);
37-
38-
return () => {
39-
observer();
40-
};
41-
}, [handleResize]);
42-
4327
return (
44-
<CodeEditor
45-
copyButtonAriaLabel={t('Copy code to clipboard')}
46-
copyButtonSuccessTooltipText={t('Content copied to clipboard')}
47-
copyButtonToolTipText={t('Copy code to clipboard')}
48-
downloadButtonAriaLabel={t('Download code')}
49-
downloadButtonToolTipText={t('Download code')}
50-
shortcutsPopoverButtonText={t('Shortcuts')}
51-
uploadButtonAriaLabel={t('Upload code')}
52-
uploadButtonToolTipText={t('Upload code')}
53-
emptyStateBody={t('Drag and drop a file or upload one.')}
54-
emptyStateButton={t('Browse')}
55-
emptyStateLink={t('Start from scratch')}
56-
emptyStateTitle={t('Start editing')}
57-
{...props}
58-
className={classNames('co-code-editor', props.className)}
59-
editorProps={{
60-
...props?.editorProps,
61-
beforeMount: (monacoInstance) => {
62-
setMonacoRef(monacoInstance);
63-
window.monaco = monacoInstance; // for e2e tests
64-
props?.editorProps?.beforeMount?.(monacoInstance);
65-
},
66-
}}
67-
/>
28+
<ErrorBoundaryInline>
29+
<CodeEditor
30+
copyButtonAriaLabel={t('Copy code to clipboard')}
31+
copyButtonSuccessTooltipText={t('Content copied to clipboard')}
32+
copyButtonToolTipText={t('Copy code to clipboard')}
33+
downloadButtonAriaLabel={t('Download code')}
34+
downloadButtonToolTipText={t('Download code')}
35+
shortcutsPopoverButtonText={t('Shortcuts')}
36+
uploadButtonAriaLabel={t('Upload code')}
37+
uploadButtonToolTipText={t('Upload code')}
38+
emptyStateBody={t('Drag and drop a file or upload one.')}
39+
emptyStateButton={t('Browse')}
40+
emptyStateLink={t('Start from scratch')}
41+
emptyStateTitle={t('Start editing')}
42+
{...props}
43+
className={classNames('co-code-editor', props.className)}
44+
editorProps={{
45+
...props?.editorProps,
46+
beforeMount: (monacoInstance) => {
47+
setMonacoRef(monacoInstance);
48+
window.monaco = monacoInstance; // for e2e tests
49+
props?.editorProps?.beforeMount?.(monacoInstance);
50+
},
51+
}}
52+
/>
53+
</ErrorBoundaryInline>
6854
);
6955
};

frontend/packages/console-shared/src/components/editor/CodeEditor.scss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
@import '../../../../../public/style/vars';
22

33
.ocs-yaml-editor {
4+
// ensure editor stays fills the parent container while remaining in bounds
5+
flex-grow: 1;
6+
display: flex;
7+
flex-direction: column;
8+
9+
.co-code-editor {
10+
flex-grow: 1;
11+
}
12+
413
.monaco-editor {
514
.monaco-hover-content .markdown-hover {
615
// matches tooltip styling seen back in OpenShift 4.18
@@ -45,7 +54,7 @@
4554

4655
/* Accessibility shortcuts hint styling */
4756
.ocs-yaml-editor-toolbar__shortcuts {
48-
padding: var(--pf-t--global--spacer--md) var(--pf-v6-global-gutter);
57+
padding: var(--pf-t--global--spacer--sm);
4958

5059
.ocs-yaml-editor-shortcut__text {
5160
color: var(--pf-t--global--text--color--subtle);

0 commit comments

Comments
 (0)