mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Expand all links by default
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
830eac3952
commit
662cb25787
@ -5,6 +5,7 @@ import { Icon } from "../icon";
|
||||
import TreeView from "@material-ui/lab/TreeView";
|
||||
import TreeItem from "@material-ui/lab/TreeItem";
|
||||
import { cssNames } from "../../utils";
|
||||
import flattenDeep from "lodash/flattenDeep";
|
||||
|
||||
export interface NavigationTree {
|
||||
id: string;
|
||||
@ -31,9 +32,20 @@ export function RecursiveTreeView({ data }: Props) {
|
||||
));
|
||||
};
|
||||
|
||||
const getAllNodeIds = (nodes: NavigationTree[]): string[] => {
|
||||
return flattenDeep(nodes.map(node => {
|
||||
return [node.id, ...node.children.map(item => getAllNodeIds([item]))];
|
||||
}));
|
||||
};
|
||||
|
||||
if (!data.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<TreeView
|
||||
className="TreeView"
|
||||
defaultExpanded={getAllNodeIds(data)}
|
||||
defaultCollapseIcon={<Icon material="expand_more"/>}
|
||||
defaultExpandIcon={<Icon material="chevron_right" />}
|
||||
>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user