From 228ba4d49f68668ebdbed0c44b12b211f25cddb7 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 19 Oct 2023 08:55:04 +0200 Subject: [PATCH 1/3] lib: Fix Dialog error prop type In `Dialog`, the `error` property is always a string, as `show_modal_dialog()`'s `set_error` call already stringifies objects. Hence they can never actually have a `.details` field, and our code also does not set this anywhere. This fixes a lot of property type warnings. --- pkg/lib/cockpit-components-dialog.jsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/lib/cockpit-components-dialog.jsx b/pkg/lib/cockpit-components-dialog.jsx index 9883aaca8b38..041a5694195a 100644 --- a/pkg/lib/cockpit-components-dialog.jsx +++ b/pkg/lib/cockpit-components-dialog.jsx @@ -235,8 +235,7 @@ class Dialog extends React.Component { ; const error = this.props.error || this.props.static_error; - const error_alert = error && - {error.details}; + const error_alert = error && ; return ( Date: Thu, 19 Oct 2023 14:41:41 +0200 Subject: [PATCH 2/3] storaged: Use Dialog.titleIconVariant property Dialog.title must be a `string`. PatternFly's modal has a `titleIconVariant` property for this use case, which is exposed by our Dialog component. Use that instead. Adjust the pixel references for the slightly changed title layout. --- pkg/storaged/dialog.jsx | 6 ++---- test/reference | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/storaged/dialog.jsx b/pkg/storaged/dialog.jsx index 1a9fb46dad98..927a5db28151 100644 --- a/pkg/storaged/dialog.jsx +++ b/pkg/storaged/dialog.jsx @@ -354,12 +354,10 @@ export const dialog_open = (def) => { }; const props = () => { - const title = (def.Action && (def.Action.Danger || def.Action.DangerButton) - ? <> {def.Title} - : def.Title); return { id: "dialog", - title, + title: def.Title, + titleIconVariant: (def.Action && (def.Action.Danger || def.Action.DangerButton)) ? "warning" : null, body: Date: Thu, 19 Oct 2023 08:58:57 +0200 Subject: [PATCH 3/3] test: Stop ignoring proptype warnings The previous commits fix all of them. --- test/common/testlib.py | 1 - 1 file changed, 1 deletion(-) diff --git a/test/common/testlib.py b/test/common/testlib.py index 077f8d5ad79e..cad853fe7ebb 100644 --- a/test/common/testlib.py +++ b/test/common/testlib.py @@ -1704,7 +1704,6 @@ def login_and_go(self, path: Optional[str] = None, user: Optional[str] = None, h default_allowed_console_errors = [ # HACK: Fix these ASAP, these are major bugs "Warning: validateDOMNesting.*cannot appear as a", - "Warning: Failed.*type.*prop Invalid prop", "Warning: React does not recognize the.*prop on a DOM element", "Warning: .*prop on .* should not be null", # HACK: These should be fixed, but debugging these is not trivial, and the impact is very low