Blame SOURCES/0007-Issue-5399-UI-LDAP-Editor-is-not-updated-when-we-swi.patch

cb1cc6
From 108dd02791da19915beb29c872516c52a74fc637 Mon Sep 17 00:00:00 2001
cb1cc6
From: Simon Pichugin <spichugi@redhat.com>
cb1cc6
Date: Fri, 5 Aug 2022 10:08:45 -0700
cb1cc6
Subject: [PATCH 3/5] Issue 5399 - UI - LDAP Editor is not updated when we
cb1cc6
 switch instances (#5400)
cb1cc6
cb1cc6
Description: We don't refresh LDAP Editor when we switch instances.
cb1cc6
It may lead to unpleasant errors.
cb1cc6
cb1cc6
Add componentDidUpdate function with the appropriate processing and
cb1cc6
properties.
cb1cc6
cb1cc6
Fixes: https://github.com/389ds/389-ds-base/issues/5399
cb1cc6
cb1cc6
Reviewed by: @mreynolds389 (Thanks!)
cb1cc6
---
cb1cc6
 src/cockpit/389-console/src/LDAPEditor.jsx | 19 +++++++++++++++++++
cb1cc6
 src/cockpit/389-console/src/ds.jsx         |  1 +
cb1cc6
 2 files changed, 20 insertions(+)
cb1cc6
cb1cc6
diff --git a/src/cockpit/389-console/src/LDAPEditor.jsx b/src/cockpit/389-console/src/LDAPEditor.jsx
cb1cc6
index 70324be39..04fc97d41 100644
cb1cc6
--- a/src/cockpit/389-console/src/LDAPEditor.jsx
cb1cc6
+++ b/src/cockpit/389-console/src/LDAPEditor.jsx
cb1cc6
@@ -60,6 +60,7 @@ export class LDAPEditor extends React.Component {
cb1cc6
 
cb1cc6
         this.state = {
cb1cc6
             activeTabKey: 0,
cb1cc6
+            firstLoad: true,
cb1cc6
             keyIndex: 0,
cb1cc6
             suffixList: [],
cb1cc6
             changeLayout: false,
cb1cc6
@@ -249,6 +250,12 @@ export class LDAPEditor extends React.Component {
cb1cc6
             baseDn: this.state.baseDN
cb1cc6
         };
cb1cc6
 
cb1cc6
+        if (this.state.firstLoad) {
cb1cc6
+            this.setState({
cb1cc6
+                firstLoad: false
cb1cc6
+            });
cb1cc6
+        }
cb1cc6
+
cb1cc6
         this.setState({
cb1cc6
             searching: true,
cb1cc6
             loading: refresh
cb1cc6
@@ -361,6 +368,18 @@ export class LDAPEditor extends React.Component {
cb1cc6
         });
cb1cc6
     }
cb1cc6
 
cb1cc6
+    componentDidUpdate(prevProps) {
cb1cc6
+        if (this.props.wasActiveList.includes(7)) {
cb1cc6
+            if (this.state.firstLoad) {
cb1cc6
+                this.handleReload(true);
cb1cc6
+            } else {
cb1cc6
+                if (this.props.serverId !== prevProps.serverId) {
cb1cc6
+                    this.handleReload(true);
cb1cc6
+                }
cb1cc6
+            }
cb1cc6
+        }
cb1cc6
+    }
cb1cc6
+
cb1cc6
     getPageData (page, perPage) {
cb1cc6
         if (page === 1) {
cb1cc6
             const pagedRows = this.state.rows.slice(0, 2 * perPage); // Each parent has a single child.
cb1cc6
diff --git a/src/cockpit/389-console/src/ds.jsx b/src/cockpit/389-console/src/ds.jsx
cb1cc6
index e88915e41..de4385292 100644
cb1cc6
--- a/src/cockpit/389-console/src/ds.jsx
cb1cc6
+++ b/src/cockpit/389-console/src/ds.jsx
cb1cc6
@@ -764,6 +764,7 @@ export class DSInstance extends React.Component {
cb1cc6
                                     key="ldap-editor"
cb1cc6
                                     addNotification={this.addNotification}
cb1cc6
                                     serverId={this.state.serverId}
cb1cc6
+                                    wasActiveList={this.state.wasActiveList}
cb1cc6
                                     setPageSectionVariant={this.setPageSectionVariant}
cb1cc6
                                 />
cb1cc6
                             </Tab>
cb1cc6
-- 
cb1cc6
2.37.1
cb1cc6