Skip to content

Commit

Permalink
Fix freezing Settings > Access page #337
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Aug 30, 2017
1 parent 5881299 commit fe541ac
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions web/app/components/Settings/AccessSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ApiNode extends React.Component {
super(props);

this.state = {
hovered: false
hovered: false
};
}

Expand Down Expand Up @@ -61,10 +61,10 @@ class ApiNode extends React.Component {
{!up && <span style={{color: "red"}}>__</span>}
</div>

return <div
className="api-node"
style={{border: "1px solid #fff", position: "relative", padding: "0.5em 1em 0.5em 1em"}}
onMouseEnter={this.setHovered.bind(this)}
return <div
className="api-node"
style={{border: "1px solid #fff", position: "relative", padding: "0.5em 1em 0.5em 1em"}}
onMouseEnter={this.setHovered.bind(this)}
onMouseLeave={this.clearHovered.bind(this)}
>
<h3 style={{marginBottom: 0, marginTop: 0}}>{name}</h3>
Expand All @@ -74,7 +74,7 @@ class ApiNode extends React.Component {

{allowActivation && !automatic && !state.hovered && Status}

{(allowActivation || allowRemoval) && state.hovered &&
{(allowActivation || allowRemoval) && state.hovered &&
<div style={{position: "absolute", right: "1em", top: "1.2em"}}>
{allowRemoval && <div className="button" onClick={this.remove.bind(this, url, name)}><Translate id="remove" content="settings.remove" /></div>}
{allowActivation && <div className="button" onClick={this.activate.bind(this)}><Translate content="settings.activate" /></div>}
Expand Down Expand Up @@ -134,11 +134,11 @@ class AccessSettings extends React.Component {
const { props } = this;

return {
name: node.location,
name: node.location || "Unknown location",
url: node.url,
up: node.url in props.apiLatencies,
ping: props.apiLatencies[node.url]
}
};
}

renderNode(node, allowActivation){
Expand All @@ -148,7 +148,7 @@ class AccessSettings extends React.Component {

let displayUrl = automatic ? "..." : node.url;

let name = typeof(node.name) === "object" ? <Translate component="span" content={node.name.translate} /> : node.name;
let name = !!node.name && typeof(node.name) === "object" && ("translate" in node.name) ? <Translate component="span" content={node.name.translate} /> : node.name;

let allowRemoval = (!automatic && !this.isDefaultNode[node.url]) ? true : false;

Expand All @@ -157,8 +157,8 @@ class AccessSettings extends React.Component {

render(){
const { props } = this;
let getNode = this.getNode.bind(this);
let renderNode = this.renderNode.bind(this);
let getNode = this.getNode.bind(this);
let renderNode = this.renderNode.bind(this);
let currentNodeIndex = this.getCurrentNodeIndex.call(this);

let nodes = props.nodes.map((node)=>{
Expand Down Expand Up @@ -202,13 +202,13 @@ class AccessSettings extends React.Component {
<span onClick={props.triggerModal.bind(this)} style={{cursor: "pointer", position: "absolute", right: 0, top: "5px", color: "#4A90E2"}} >
<Translate id="add" component="span" content="settings.add_api" />
</span>
{
nodes.map((node)=>{
{
nodes.map((node)=>{
return renderNode(node, true);
})
}
</div>
</div>
</div>
}
}

Expand Down

0 comments on commit fe541ac

Please sign in to comment.