Skip to content

Commit

Permalink
fix(code/frontend): should disable structure tree in directory history (
Browse files Browse the repository at this point in the history
  • Loading branch information
WangQianliang authored Jul 18, 2019
1 parent fab0cdb commit 48c97fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface Props extends RouteComponentProps<MainRouteParams> {
repoStatus?: RepoStatus;
tree: FileTree;
file: FetchFileResponse | undefined;
currentTree: FileTree | undefined;
currentTree: FileTree | null;
commits: CommitInfo[];
branches: ReferenceInfo[];
hasMoreCommits: boolean;
Expand Down
6 changes: 5 additions & 1 deletion x-pack/legacy/plugins/code/public/components/main/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ import { MainRouteParams } from '../../common/types';
import { ShortcutsProvider } from '../shortcuts';
import { Content } from './content';
import { SideTabs } from './side_tabs';
import { structureSelector } from '../../selectors';
import { structureSelector, currentTreeSelector } from '../../selectors';
import { RootState } from '../../reducers';
import { FileTree } from '../../../model';

interface Props extends RouteComponentProps<MainRouteParams> {
loadingFileTree: boolean;
loadingStructureTree: boolean;
hasStructure: boolean;
languageServerInitializing: boolean;
currentTree: FileTree | null;
}

class CodeMain extends React.Component<Props> {
Expand Down Expand Up @@ -60,6 +62,7 @@ class CodeMain extends React.Component<Props> {
<div className="codeContainer__rootInner">
<React.Fragment>
<SideTabs
currentTree={this.props.currentTree}
loadingFileTree={loadingFileTree}
loadingStructureTree={loadingStructureTree}
hasStructure={hasStructure}
Expand All @@ -79,6 +82,7 @@ const mapStateToProps = (state: RootState) => ({
loadingStructureTree: state.symbol.loading,
hasStructure: structureSelector(state).length > 0 && !state.symbol.error,
languageServerInitializing: state.symbol.languageServerInitializing,
currentTree: currentTreeSelector(state),
});

export const Main = connect(mapStateToProps)(CodeMain);
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import { parse as parseQuery } from 'querystring';
import React from 'react';
import { RouteComponentProps, withRouter } from 'react-router-dom';
import { QueryString } from 'ui/utils/query_string';
import { MainRouteParams, PathTypes } from '../../common/types';
import { MainRouteParams } from '../../common/types';
import { FileTree } from '../file_tree/file_tree';
import { Shortcut } from '../shortcuts';
import { SymbolTree } from '../symbol_tree/symbol_tree';
import { FileTree as IFileTree, FileTreeItemType } from '../../../model';

enum Tabs {
file = 'file',
Expand All @@ -24,6 +25,7 @@ interface Props extends RouteComponentProps<MainRouteParams> {
loadingStructureTree: boolean;
hasStructure: boolean;
languageServerInitializing: boolean;
currentTree: IFileTree | null;
}

class CodeSideTabs extends React.PureComponent<Props> {
Expand Down Expand Up @@ -77,7 +79,9 @@ class CodeSideTabs extends React.PureComponent<Props> {
id: Tabs.structure,
name: 'Structure',
content: structureTabContent,
disabled: this.props.match.params.pathType === PathTypes.tree || !this.props.hasStructure,
disabled:
!(this.props.currentTree && this.props.currentTree.type === FileTreeItemType.File) ||
!this.props.hasStructure,
'data-test-subj': 'codeStructureTreeTab',
},
];
Expand Down

0 comments on commit 48c97fb

Please sign in to comment.