Skip to content

Commit

Permalink
[Code] fix tree loading when jumping between different repos
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedragon committed Mar 8, 2019
1 parent 6e66615 commit 5c5ffdc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions x-pack/plugins/code/public/components/file_tree/file_tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@ interface Props extends RouteComponentProps<MainRouteParams> {
openTreePath: (paths: string) => void;
fetchRepoTree: (p: FetchRepoTreePayload) => void;
openedPaths: string[];
treeLoading?: boolean;
}

export class CodeFileTree extends React.Component<Props> {
public componentDidUpdate(prevProps: Readonly<Props>): void {
const { openedPaths, match, treeLoading } = this.props;
const path = match.params.path;
if (prevProps.match.params.path !== path || prevProps.treeLoading !== treeLoading) {
if (!openedPaths.includes(path)) {
this.props.openTreePath(path);
}
}
}

public componentDidMount(): void {
const { path } = this.props.match.params;
if (path) {
Expand Down Expand Up @@ -242,6 +253,7 @@ export class CodeFileTree extends React.Component<Props> {
const mapStateToProps = (state: RootState) => ({
node: state.file.tree,
openedPaths: state.file.openedPaths,
treeLoading: state.file.loading,
});

const mapDispatchToProps = {
Expand Down

0 comments on commit 5c5ffdc

Please sign in to comment.