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

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