-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filter by whole file path instead of file name #176
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ const fullScreenStorageKey = '__better_github_pr_full_screen' | |
class Tree extends React.Component { | ||
constructor (props) { | ||
super(props) | ||
this.onReloadTree = this.props.reloadTree | ||
this.handleReloadTree = this.props.reloadTree | ||
|
||
this.handleClose = this.handleClose.bind(this) | ||
this.onScroll = this.onScroll.bind(this) | ||
|
@@ -174,12 +174,14 @@ class Tree extends React.Component { | |
} | ||
|
||
render () { | ||
const { root, filter, show, visibleElement } = this.state | ||
const { filter, show, visibleElement } = this.state | ||
|
||
if (!show) { | ||
return null | ||
} | ||
|
||
const filtered = createFileTree(filter).tree | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally I didn't have this here, but when the tree was reloaded for a reason other than the filter changing (e.g. sync button pressed, or "viewed" checkbox clicked) it would add back folders that should not be visible. Not sure if this is the best way to address that, but it seems to work fine. |
||
|
||
return ( | ||
<div> | ||
<div className='_better_github_pr_resizer' ref={node => { this.resizer = node }} /> | ||
|
@@ -189,11 +191,11 @@ class Tree extends React.Component { | |
onFullWidth={this.handleFullWidth} | ||
onOptions={this.handleOptions} | ||
onClose={this.handleClose} | ||
onReloadTree={this.onReloadTree} | ||
onReloadTree={this.handleReloadTree} | ||
berzniz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/> | ||
<div className='file-container'> | ||
<div> | ||
{root.list.map(node => ( | ||
{filtered.list.map(node => ( | ||
<span key={node.nodeLabel}> | ||
{createTree({ ...node, visibleElement, filter })} | ||
</span> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,9 +126,9 @@ export const createFileTree = (filter = EMPTY_FILTER) => { | |
diffElements: [] | ||
} | ||
|
||
files.forEach(({ parts, href }) => { | ||
files.forEach(({ title, parts, href }) => { | ||
let location = tree | ||
if (filterItem(parts[parts.length - 1], filter)) { | ||
if (filterItem(title, filter)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the main change, I haven't made it optional but I'm happy to if you'd like |
||
parts.forEach((part, index) => { | ||
let node = location.list.find(node => node.nodeLabel === part) | ||
if (!node) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did try and move this to the shared
lib.js
but it didn't work because of the React stuff, so settled for just having a copy in Folder