Browse Source

Fix nodes actions toolbar

An additional span inside the nodes toolbar, added by the i18n
FormattedMessage component, breaks the toolbar by changing the click
event target to the span element; because the span element doesn't
contain the "name" attribute needed to determine the appropriate action.

This patch adds a small method to lookup the closest name attribute
(either on the element or the parent elements), so both buttons with and
without a FormattedMessage of them will work.

Change-Id: I7c565da8bf2f5040ff99b13f02cb0a7f4c07637f
Closes-Bug: #1671100
(cherry picked from commit 8d40ed773b)
tags/3.2.0
Florian Fuchs 2 years ago
parent
commit
a2225d5141
3 changed files with 14 additions and 1 deletions
  1. +5
    -0
      releasenotes/notes/fix-nodes-actions-d2edbcf9d959fa35.yaml
  2. +2
    -1
      src/js/components/nodes/RegisteredNodesTabPane.js
  3. +7
    -0
      src/js/components/utils/Dom.js

+ 5
- 0
releasenotes/notes/fix-nodes-actions-d2edbcf9d959fa35.yaml View File

@@ -0,0 +1,5 @@
fixes:
- |
Fixes `bug 1671100 <https://launchpad.net/bugs/1671100>`__
Fixes a bug in the nodes table toolbar which made the introspect and
provide buttons unclickable

+ 2
- 1
src/js/components/nodes/RegisteredNodesTabPane.js View File

@@ -15,6 +15,7 @@ import FormErrorList from '../ui/forms/FormErrorList';
import NodesActions from '../../actions/NodesActions';
import NodesTable from './NodesTable';
import TagNodesModal from './tag_nodes/TagNodesModal';
import { findClosestWithAttribute } from '../utils/Dom';

const messages = defineMessages({
introspectNodes: {
@@ -126,7 +127,7 @@ class RegisteredNodesTabPane extends React.Component {

multipleSubmit(e) {
this.setState({
submitType: e.target.name
submitType: findClosestWithAttribute(e.target, 'name')
}, this.refs.registeredNodesTableForm.submit);
}


+ 7
- 0
src/js/components/utils/Dom.js View File

@@ -0,0 +1,7 @@
export function findClosestWithAttribute(element, attrName) {
// If the element has a name attr, return it.
// Otherwise try the parent element.
if(element) {
return element[attrName] || findClosestWithAttribute(element.parentElement, attrName);
}
}

Loading…
Cancel
Save