Skip to content

Commit

Permalink
Merge pull request #83 from nahuelarjonadev/master
Browse files Browse the repository at this point in the history
performance improvement on reclicking topics, improved ux in TopicPage
  • Loading branch information
nahuelarjonadev authored Sep 7, 2019
2 parents d36e907 + 1a53635 commit 989aa49
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 24 deletions.
3 changes: 2 additions & 1 deletion client/src/app/components/ConnectionPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import '../css/ConnectionPage.scss';
import lensIcon from '../../../../assets/images/lens-icon.png';
import nullableProp from '../../utils/nullableProp';
import { version } from '../../../../package.json';

const ConnectionPage = ({
isFetching,
Expand Down Expand Up @@ -53,7 +54,7 @@ const ConnectionPage = ({
{/* Loading bars here */}
<div className="loading-bars">{loading}</div>
<footer className="footer">
<p className="FooterText">© Kafka Lens Version 2.0 </p>
<p className="FooterText">© Kafka Lens Version {version} </p>
</footer>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/components/Topic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Topic = ({ id, topicInfo, showPartitions, showMessages }) => (
>
{topicInfo.topicName}
</div>
{topicInfo.showPartitions === true ? (
{topicInfo.showPartitions ? (
<PartitionList showMessages={showMessages} topicInfo={topicInfo} />
) : (
''
Expand Down
37 changes: 22 additions & 15 deletions client/src/app/containers/TopicPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,23 @@ 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;
const { topicList } = this.props;
const topicName = event.target.getAttribute('topicname');
const topicIndex = parseInt(event.target.id, 10);
const topicName = element.getAttribute('topicname');
const topicIndex = element.id;
const topicInfo = topicList[topicIndex];

topicInfo.showPartitions = !topicInfo.showPartitions;

if (lastElement === element) {
logger.log('clicked same element');
this.setState({ currentPartitionMetadata: topicInfo });
return;
}

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

const { uri: kafkaHostURI } = this.props;
ipcRenderer.send('partition:getMessages', {
kafkaHostURI,
Expand All @@ -62,33 +72,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 +133,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
8 changes: 1 addition & 7 deletions client/src/app/css/Partition.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@
font-size: 16px;
}

.single-partition:hover {
.single-partition:hover, .single-partition:focus {
background-color: $highlight-bar-color;
color: white;
cursor: pointer;
}

.single-partition:focus {
background-color: black;
}

5 changes: 5 additions & 0 deletions client/src/app/css/Topic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@

.topic-padding {
padding-left: 56px;
}

.topic-padding:hover, .topic-padding:focus {
background-color: $highlight-bar-color;
cursor: pointer;
}
4 changes: 4 additions & 0 deletions client/src/app/css/TopicPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
color: $base-font-color;
}

.highlight-this {
color: yellow;
}

// DO NOT REMOVE (scroll bar style)
// ::-webkit-scrollbar {
// background-color: $new-bg-blue;
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@
"icon": "icon.png"
},
"win": {
"icon": "icon.ico",
"target": [
"nsis",
"msi"
]
},
"linux": {
"icon": "icon.png",
"target": [
"deb",
"rpm",
Expand Down

0 comments on commit 989aa49

Please sign in to comment.