Skip to content

Commit

Permalink
Merge pull request #14 from RedSparr0w/comments
Browse files Browse the repository at this point in the history
Add comment icon to files with comments
  • Loading branch information
berzniz authored May 8, 2018
2 parents 07df680 + efbb61a commit 013ae48
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/js/components/branch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react'
import TreeView from 'react-treeview'
import File from './file'

const Branch = ({ nodeLabel, list, href }) => {
const Branch = ({ nodeLabel, list, href, has_comments }) => {
if (href) {
return <File name={nodeLabel} href={href} />
return <File name={nodeLabel} href={href} has_comments={has_comments}/>
}

return (
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/file.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import fileIcons from 'file-icons-js'

const File = ({ name, href }) => {
const File = ({ name, href, has_comments }) => {
const className = fileIcons.getClassWithColor(name)
return (
<div className='github-pr-file'>
<span className={`icon ${className}`} />
<a href={href} className='link-gray-dark'>{name}</a>
<a href={href} className='link-gray-dark'>{name}{has_comments ? ' 💬' : ''}</a>
</div>
)
}
Expand Down
5 changes: 3 additions & 2 deletions src/js/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ export const createFileTree = () => {
list: []
}

files.forEach(({ parts, href }) => {
files.forEach(({ parts, href }, index) => {
let has_comments = !!document.getElementsByClassName('diff-table')[index].querySelectorAll('.inline-comments').length;
let location = tree
parts.forEach((part, index) => {
let node = location.list.find(node => node.nodeLabel === part)
if (!node) {
node = { nodeLabel: part, list: [], href: (index === parts.length - 1) ? href : null }
node = { nodeLabel: part, list: [], href: (index === parts.length - 1) ? href : null, has_comments }
location.list.push(node)
}
location.list = location.list.sort(sorter)
Expand Down

0 comments on commit 013ae48

Please sign in to comment.