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

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