#50968 Issue 50966 - UI - Database indexes not using typeAhead correctly
Closed 3 years ago by spichugi. Opened 4 years ago by mreynolds.
mreynolds/389-ds-base issue50966  into  master

@@ -412,7 +412,7 @@ 

                          <Form horizontal autoComplete="off">

                              <div className="ds-modal-spinner">

                                  <Spinner loading inline size="lg" /> Indexing <b>{msg}</b> ...

-                                 <p><font size="1">(You can safely close this window)</font></p>

+                                 <p className="ds-margin-top-lg"><font size="1">(You can safely close this window)</font></p>

                              </div>

                          </Form>

                      </Modal.Body>

@@ -92,8 +92,8 @@ 

                      const mrContent = JSON.parse(content);

                      let mrs = [];

                      for (let i = 0; i < mrContent['items'].length; i++) {

-                         if (mrContent['items'][i].name != "") {

-                             mrs.push(mrContent['items'][i].name);

+                         if (mrContent['items'][i].name[0] != "") {

+                             mrs.push(mrContent['items'][i].name[0]);

                          }

                      }

  
@@ -118,10 +118,10 @@ 

                                              const attrContent = JSON.parse(content);

                                              let attrs = [];

                                              for (let content of attrContent['items']) {

-                                                 if (indexList.indexOf(content.name) == -1) {

+                                                 if (indexList.indexOf(content.name[0]) == -1) {

                                                      // Attribute is not a current index, add it to the list

                                                      // of available attributes to index

-                                                     attrs.push(content.name);

+                                                     attrs.push(content.name[0]);

                                                  }

                                              }

                                              if (this.state._isMounted) {
@@ -205,7 +205,7 @@ 

  

          let cmd = [

              "dsconf", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket",

-             "backend", "index", "add", "--attr=" + this.state.addIndexName[0].id,

+             "backend", "index", "add", "--attr=" + this.state.addIndexName[0],

              this.props.suffix,

          ];

  
@@ -222,7 +222,7 @@ 

              cmd.push('--index-type=approx');

          }

          for (let i = 0; i < this.state.mrs.length; i++) {

-             cmd.push('--matching-rule=' + this.state.mrs[i].id);

+             cmd.push('--matching-rule=' + this.state.mrs[i]);

          }

          if (this.state.reindexOnAdd) {

              cmd.push('--reindex');
@@ -236,7 +236,7 @@ 

                      this.props.reload(this.props.suffix);

                      this.closeIndexModal();

                      if (this.state.reindexOnAdd) {

-                         this.reindexAttr(this.state.addIndexName[0].id);

+                         this.reindexAttr(this.state.addIndexName[0]);

                      }

                      this.props.addNotification(

                          "success",
@@ -262,12 +262,10 @@ 

              item.matchingrules[0].length > 0) {

              let parts = item.matchingrules[0].split(",").map(item => item.trim());

              for (let part of parts) {

-                 currentMRS.push({

-                     id: part,

-                     label: part

-                 });

+                 currentMRS.push(part);

              }

          }

+ 

          this.setState({

              editIndexName: item.name[0],

              types: item.types,
@@ -312,10 +310,9 @@ 

          ];

  

          // Open spinner modal

-         const msg = <p>Indexing attribute:  <b>{attr}</b> ...</p>;

          this.setState({

              showReindexModal: true,

-             reindexMsg: msg

+             reindexMsg: attr

          });

          log_cmd("reindexAttr", "index attribute", reindex_cmd);

          cockpit
@@ -361,27 +358,27 @@ 

          for (let newMR of newMRS) {

              let found = false;

              for (let origMR of origMRS) {

-                 if (origMR.id == newMR.id) {

+                 if (origMR == newMR) {

                      found = true;

                      break;

                  }

              }

              if (!found) {

-                 cmd.push('--add-mr=' + newMR.id);

+                 cmd.push('--add-mr=' + newMR);

              }

          }

          // Check if we have to remove mrs

          for (let origMR of origMRS) {

              let found = false;

              for (let newMR of newMRS) {

-                 if (newMR.id == origMR.id) {

+                 if (newMR == origMR) {

                      console.log("Found mr no need to delete");

                      found = true;

                      break;

                  }

              }

              if (!found) {

-                 cmd.push('--del-mr=' + origMR.id);

+                 cmd.push('--del-mr=' + origMR);

              }

          }

  
@@ -437,7 +434,7 @@ 

  

      showConfirmReindex(item) {

          this.setState({

-             reindexAttrName: item.name,

+             reindexAttrName: item.name[0],

              showConfirmReindex: true

          });

      }
@@ -451,7 +448,7 @@ 

  

      showConfirmDeleteIndex(item) {

          this.setState({

-             deleteAttrName: item.name,

+             deleteAttrName: item.name[0],

              showConfirmDeleteIndex: true

          });

      }
@@ -600,11 +597,11 @@ 

  

          let availMR = [];

          for (let mr of matchingRules) {

-             availMR.push(mr[0]);

+             availMR.push(mr);

          }

          let availAttrs = [];

          for (let attr of attributes) {

-             availAttrs.push(attr[0]);

+             availAttrs.push(attr);

          }

  

          return (
@@ -637,7 +634,7 @@ 

                                  placeholder="Type a attribute name to index..."

                              />

                              <p className="ds-margin-top"><b>Index Types</b></p>

-                             <div className="ds-indent">

+                             <div className="ds-indent ds-margin-top">

                                  <Row>

                                      <Col sm={5}>

                                          <Checkbox id="addIndexTypeEq" onChange={handleChange}> Equailty Indexing</Checkbox>
@@ -662,7 +659,7 @@ 

                              <Row className="ds-margin-top-lg">

                                  <Col sm={12} title="List of matching rules separated by a 'space'">

                                      <p><b>Matching Rules</b></p>

-                                     <div className="ds-indent">

+                                     <div className="ds-indent ds-margin-top">

                                          <Typeahead

                                              multiple

                                              id="matchingRules"
@@ -735,13 +732,7 @@ 

          }

  

          const currentMrs = mrs;

-         let availMR = [];

-         for (let mr of matchingRules) {

-             availMR.push({

-                 id: mr,

-                 label: mr

-             });

-         }

+         let availMR = matchingRules;

  

          // Default settings

          let eq = <div>
@@ -807,7 +798,7 @@ 

                              <p><Icon type="pf" style={{'marginRight': '15px'}} name="edit" /><font size="4"><b>{indexName}</b></font></p>

                              <hr />

                              <p><b>Index Types</b></p>

-                             <div className="ds-indent">

+                             <div className="ds-indent ds-margin-top">

                                  <Row>

                                      <Col sm={9}>

                                          {eq}
@@ -832,7 +823,7 @@ 

                              <Row className="ds-margin-top-lg">

                                  <Col sm={12}>

                                      <p><b>Matching Rules</b></p>

-                                     <div className="ds-indent">

+                                     <div className="ds-indent ds-margin-top">

                                          <Typeahead

                                              multiple

                                              id="matchingRulesEdit"

Description:

The attribute indexes were using the wrong format for the typeAhead fields which results in console crashes, and invalid indexes.

relates: https://pagure.io/389-ds-base/issue/50966

rebased onto 4cf9431

4 years ago

Pull-Request has been merged by mreynolds

4 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/4021

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago