[ARVADOS-WORKBENCH2] updated: 1.1.4-33-g250d01c
Git user
git at public.curoverse.com
Mon Jun 18 04:13:02 EDT 2018
Summary of changes:
src/components/project-tree/project-tree.test.tsx | 8 ++--
src/components/tree/tree.test.tsx | 10 ++---
src/components/tree/tree.tsx | 47 +++++++++++++----------
3 files changed, 35 insertions(+), 30 deletions(-)
via 250d01c990a4f47bfdaa31ef9d3d7b79e602cb2c (commit)
from 9999a9db9fede0e1971dc792389982b428a1bb19 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 250d01c990a4f47bfdaa31ef9d3d7b79e602cb2c
Author: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
Date: Mon Jun 18 10:12:44 2018 +0200
expand tree component after click on ARROW
Feature #13618
Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk at contractors.roche.com>
diff --git a/src/components/project-tree/project-tree.test.tsx b/src/components/project-tree/project-tree.test.tsx
index e88e55a..932a29c 100644
--- a/src/components/project-tree/project-tree.test.tsx
+++ b/src/components/project-tree/project-tree.test.tsx
@@ -34,7 +34,7 @@ describe("ProjectTree component", () => {
};
const wrapper = mount(<ProjectTree projects={[project]} toggleProjectTreeItem={() => { }} />);
- expect(wrapper.find(ListItemIcon).length).toEqual(1);
+ expect(wrapper.find(ListItemIcon)).toHaveLength(1);
});
it("should render 2 ListItemIcons", () => {
@@ -70,7 +70,7 @@ describe("ProjectTree component", () => {
];
const wrapper = mount(<ProjectTree projects={project} toggleProjectTreeItem={() => { }} />);
- expect(wrapper.find(ListItemIcon).length).toEqual(2);
+ expect(wrapper.find(ListItemIcon)).toHaveLength(2);
});
it("should render Collapse", () => {
@@ -108,7 +108,7 @@ describe("ProjectTree component", () => {
];
const wrapper = mount(<ProjectTree projects={project} toggleProjectTreeItem={() => { }} />);
- expect(wrapper.find(Collapse).length).toEqual(1);
+ expect(wrapper.find(Collapse)).toHaveLength(1);
});
it("should render CircularProgress", () => {
@@ -128,6 +128,6 @@ describe("ProjectTree component", () => {
};
const wrapper = mount(<ProjectTree projects={[project]} toggleProjectTreeItem={() => { }} />);
- expect(wrapper.find(CircularProgress).length).toEqual(1);
+ expect(wrapper.find(CircularProgress)).toHaveLength(1);
});
});
diff --git a/src/components/tree/tree.test.tsx b/src/components/tree/tree.test.tsx
index 0fab2f3..bb0499f 100644
--- a/src/components/tree/tree.test.tsx
+++ b/src/components/tree/tree.test.tsx
@@ -13,7 +13,7 @@ import Tree, {TreeItem} from './tree';
import { Project } from '../../models/project';
Enzyme.configure({ adapter: new Adapter() });
-describe("ProjectTree component", () => {
+describe("Tree component", () => {
it("should render ListItem", () => {
const project: TreeItem<Project> = {
@@ -28,10 +28,10 @@ describe("ProjectTree component", () => {
id: "3",
open: true,
active: true,
- loading: true,
+ status: 1,
};
const wrapper = mount(<Tree render={project => <div/>} toggleItem={() => { }} items={[project]}/>)
- expect(wrapper.find(ListItem).length).toEqual(1);
+ expect(wrapper.find(ListItem)).toHaveLength(1);
});
it("should render arrow", () => {
@@ -47,9 +47,9 @@ describe("ProjectTree component", () => {
id: "3",
open: true,
active: true,
- loading: true,
+ status: 1,
};
const wrapper = mount(<Tree render={project => <div/>} toggleItem={() => { }} items={[project]}/>)
- expect(wrapper.find('i').length).toEqual(1);
+ expect(wrapper.find('i')).toHaveLength(1);
});
});
diff --git a/src/components/tree/tree.tsx b/src/components/tree/tree.tsx
index 936c596..21c4bc7 100644
--- a/src/components/tree/tree.tsx
+++ b/src/components/tree/tree.tsx
@@ -25,7 +25,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
inactiveArrow: {
position: 'absolute',
},
- arrowTransition: {
+ arrowTransition: {
transition: 'all 0.1s ease',
},
arrowRotate: {
@@ -38,7 +38,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: Theme) => ({
loader: {
position: 'absolute',
transform: 'translate(0px)',
- top: '3px'
+ top: '3px'
}
});
@@ -66,30 +66,35 @@ interface TreeProps<T> {
}
class Tree<T> extends React.Component<TreeProps<T> & WithStyles<CssRules>, {}> {
- renderArrow (status: TreeItemStatus, arrowClass: string, open: boolean){
- return <i className={`${arrowClass} ${status === TreeItemStatus.Pending ? this.props.classes.arrowVisibility : ''} ${open ? `fas fa-caret-down ${this.props.classes.arrowTransition}` : `fas fa-caret-down ${this.props.classes.arrowRotate}`}`} />
+ renderArrow(status: TreeItemStatus, arrowClass: string, open: boolean, id: string) {
+ return <i
+ onClick={() => this.props.toggleItem(id, status)}
+ className={`
+ ${arrowClass}
+ ${status === TreeItemStatus.Pending ? this.props.classes.arrowVisibility : ''}
+ ${open ? `fas fa-caret-down ${this.props.classes.arrowTransition}` : `fas fa-caret-down ${this.props.classes.arrowRotate}`}`} />
}
render(): ReactElement<any> {
const level = this.props.level ? this.props.level : 0;
- const {classes, render, toggleItem, items} = this.props;
- const {list, inactiveArrow, activeArrow, loader} = classes;
+ const { classes, render, toggleItem, items } = this.props;
+ const { list, inactiveArrow, activeArrow, loader } = classes;
return <List component="div" className={list}>
{items && items.map((it: TreeItem<T>, idx: number) =>
- <div key={`item/${level}/${idx}`}>
- <ListItem button onClick={() => toggleItem(it.id, it.status)} className={list} style={{paddingLeft: (level + 1) * 20}}>
- {it.status === TreeItemStatus.Pending ? <CircularProgress size={10} className={loader}/> : null}
- {it.toggled && it.items && it.items.length === 0 ? null : this.renderArrow(it.status, it.active ? activeArrow : inactiveArrow, it.open)}
- {render(it, level)}
- </ListItem>
- {it.items && it.items.length > 0 &&
- <Collapse in={it.open} timeout="auto" unmountOnExit>
- <StyledTree
- items={it.items}
- render={render}
- toggleItem={toggleItem}
- level={level + 1}/>
- </Collapse>}
- </div>)}
+ <div key={`item/${level}/${idx}`}>
+ <ListItem button className={list} style={{ paddingLeft: (level + 1) * 20 }}>
+ {it.status === TreeItemStatus.Pending ? <CircularProgress size={10} className={loader} /> : null}
+ {it.toggled && it.items && it.items.length === 0 ? null : this.renderArrow(it.status, it.active ? activeArrow : inactiveArrow, it.open, it.id)}
+ {render(it, level)}
+ </ListItem>
+ {it.items && it.items.length > 0 &&
+ <Collapse in={it.open} timeout="auto" unmountOnExit>
+ <StyledTree
+ items={it.items}
+ render={render}
+ toggleItem={toggleItem}
+ level={level + 1} />
+ </Collapse>}
+ </div>)}
</List>
}
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list