Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions x-pack/plugins/code/public/components/file_tree/file_tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,10 @@ export class CodeFileTree extends React.Component<Props> {
}
};

public toggleTree = (path: string, isDir: boolean) => {
public toggleTree = (path: string) => {
if (this.isPathOpen(path)) {
this.props.closeTreePath(path);
} else {
this.fetchTree(path, isDir);
this.props.openTreePath(path);
}
};
Expand All @@ -104,7 +103,7 @@ export class CodeFileTree extends React.Component<Props> {
}
const onClick = () => {
const path = flattenFrom ? flattenFrom.path! : node.path!;
this.toggleTree(path, node.type === FileTreeItemType.Directory);
this.toggleTree(path);
this.onClick(node);
};
switch (node.type) {
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/code/public/components/main/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@
.code-link {
&:focus {
box-shadow: none;
outline: none;
animation: none;
}
}

Expand Down
22 changes: 12 additions & 10 deletions x-pack/plugins/code/public/components/main/side_tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,28 @@ class CodeSideTabs extends React.PureComponent<Props> {
}

public get tabs() {
const fileTabContent = this.props.loadingFileTree ? (
this.renderLoadingSpinner('file')
) : (
<div className="codeFileTree--container">{<FileTree />}</div>
);
const structureTabContent = this.props.loadingStructureTree ? (
this.renderLoadingSpinner('structure')
) : (
<SymbolTree />
);
return [
{
id: Tabs.file,
name: 'File',
content: (
<div className="codeFileTree--container">
{this.props.loadingFileTree ? this.renderLoadingSpinner('file') : <FileTree />}
</div>
),
content: fileTabContent,
isSelected: Tabs.file === this.sideTab,
'data-test-subj': 'codeFileTreeTab',
},
{
id: Tabs.structure,
name: 'Structure',
content: this.props.loadingFileTree ? (
this.renderLoadingSpinner('structure')
) : (
<SymbolTree />
),
content: structureTabContent,
isSelected: Tabs.structure === this.sideTab,
disabled: this.props.match.params.pathType === PathTypes.tree,
'data-test-subj': 'codeStructureTreeTab',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class CodeSymbolTree extends React.PureComponent<Props, { activePath?: st
public getClickHandler = (path: string) => () => {
this.setState({ activePath: path });
};

public getStructureTreeItemRenderer = (
location: Location,
name: string,
Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/code/public/reducers/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const initialState: FileState = {
type: FileTreeItemType.Directory,
},
openedPaths: [],
loading: false,
loading: true,
branches: [],
tags: [],
commits: [],
Expand Down Expand Up @@ -108,9 +108,6 @@ export const file = handleActions(
[String(fetchRepoTree)]: (state: FileState, action: any) =>
produce(state, draft => {
draft.currentPath = action.payload.path;
if (action.payload.parents) {
draft.loading = true;
}
}),
[String(fetchRepoTreeSuccess)]: (state: FileState, action: Action<RepoTreePayload>) =>
produce<FileState>(state, (draft: FileState) => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/code/public/reducers/symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const generateStructureTree: (symbols: SymbolInformation[]) => any = symbols =>
container.members = [{ ...s, path: `${container.path}/${s.name}` }];
}
} else {
structureTree.push(s);
structureTree.push({ ...s, path: s.name });
}
});

Expand Down
10 changes: 5 additions & 5 deletions x-pack/plugins/code/public/sagas/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ function* handleMainRouteChange(action: Action<Match>) {
isDir: pathType === PathTypes.tree,
})
);
const uri = toCanonicalUrl({
repoUri,
file,
revision,
});
if (file && pathType === PathTypes.blob) {
const uri = toCanonicalUrl({
repoUri,
file,
revision,
});
if (lastRequestPath !== uri) {
yield put(loadStructure(uri!));
}
Expand Down