-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from codecentric/fix-tree-not-updating-after-a…
…ction Update tree after action but keep toggled nodes stable
- Loading branch information
Showing
17 changed files
with
412 additions
and
207 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,18 @@ | ||
import * as React from 'react' | ||
|
||
import Gopass from '../../secrets/Gopass' | ||
import TreeComponent, { Tree } from '../../components/tree/TreeComponent' | ||
import SecretsFilterService from './SecretsFilterService' | ||
import SecretsDirectoryService from './SecretsDirectoryService' | ||
|
||
export interface SecretTreeViewerProps { | ||
onSecretClick: (name: string) => void | ||
searchValue: string | ||
tree: Tree | ||
} | ||
|
||
export default class SecretTreeViewer extends React.Component<SecretTreeViewerProps, { tree: Tree, secretNames: string[] }> { | ||
constructor(props: any) { | ||
super(props) | ||
this.state = { | ||
tree: { | ||
name: 'Stores', | ||
toggled: true, | ||
children: [] | ||
}, | ||
secretNames: [] | ||
} | ||
} | ||
|
||
public async componentDidMount() { | ||
const secretNames = await Gopass.getAllSecretNames() | ||
this.setState({ secretNames }) | ||
await this.calculateAndSetTreeState(this.props.searchValue) | ||
} | ||
|
||
public async componentWillReceiveProps(newProps: SecretTreeViewerProps) { | ||
|
||
if (newProps.searchValue !== this.props.searchValue) { | ||
await this.calculateAndSetTreeState(newProps.searchValue) | ||
} | ||
} | ||
|
||
export default class SecretTreeViewer extends React.Component<SecretTreeViewerProps, {}> { | ||
public render() { | ||
return ( | ||
<TreeComponent | ||
tree={this.state.tree} | ||
tree={this.props.tree} | ||
onLeafClick={this.props.onSecretClick} | ||
/> | ||
) | ||
} | ||
|
||
private async calculateAndSetTreeState(searchValue: string) { | ||
const filteredSecretNames = SecretsFilterService.filterBySearch(this.state.secretNames, searchValue) | ||
const tree: Tree = SecretsDirectoryService.secretPathsToTree(filteredSecretNames) | ||
this.setState({ ...this.state, tree }) | ||
} | ||
} |
Oops, something went wrong.