Skip to content

Commit

Permalink
fix topic requesting new data even if same one clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
nahuelarjonadev committed Sep 7, 2019
1 parent d0c0c03 commit 83c560a
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions client/src/app/containers/TopicPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ class TopicPage extends React.Component {

// Called when topic is clicked in order to show partitions
showPartitions(event) {
const element = event.target;
const { lastElement } = this.state;
if (lastElement === element) return;

if (lastElement) lastElement.classList.remove('highlight-this');
element.classList.add('highlight-this');

const topicName = element.getAttribute('topicname');
const topicIndex = element.id;
const { topicList } = this.props;
const topicName = event.target.getAttribute('topicname');
const topicIndex = parseInt(event.target.id, 10);
const topicInfo = topicList[topicIndex];

topicInfo.showPartitions = !topicInfo.showPartitions;
Expand All @@ -62,33 +69,30 @@ class TopicPage extends React.Component {

const newState = this.state;

const { showingPartitionMetadata } = this.state;
if (showingPartitionMetadata === true) newState.showingPartitionMetadata = false;

newState.showingPartitionMetadata = false;
newState.currentTopicMetadata = topicInfo;
newState.loadingData = true;
newState.lastElement = element;

return this.setState(newState);
this.setState(newState);
}

showMessages(event) {
const element = event.target;
const newTopicName = element.getAttribute('topicname');
const newPartitionId = element.id;
const { lastElement } = this.state;

logger.log('newTopicName from the partition div:', newTopicName);
logger.log('newPartitionId:', newPartitionId);

const { lastElement, partitionId, topicName } = this.state;
const { uri: kafkaHostURI } = this.props;

if (newPartitionId === partitionId && newTopicName === topicName && lastElement === element)
return;
if (lastElement === element) return;

if (lastElement) lastElement.classList.remove('highlight-this');

element.classList.add('highlight-this');

const { uri: kafkaHostURI } = this.props;

this.setState(
{
messages: [],
Expand Down Expand Up @@ -126,11 +130,11 @@ class TopicPage extends React.Component {
} = this.state;

const shouldDisplayPartitionMetadata =
showingPartitionMetadata === true &&
showingPartitionMetadata &&
Object.keys(currentPartitionMetadata).length &&
messages.length > 0;

const shouldDisplayMessageInfo = showingPartitionMetadata === true && messages.length > 0;
const shouldDisplayMessageInfo = showingPartitionMetadata && messages.length > 0;

const Topics = topicList.map((topicInfo, i) => (
<Topic
Expand Down

0 comments on commit 83c560a

Please sign in to comment.