Merge branch 'master' into 13883-arrow-animation-is-not-working-after-loading
authorPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Thu, 26 Jul 2018 07:22:44 +0000 (09:22 +0200)
committerPawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>
Thu, 26 Jul 2018 07:22:44 +0000 (09:22 +0200)
refs #13883

Arvados-DCO-1.1-Signed-off-by: Pawel Kowalczyk <pawel.kowalczyk@contractors.roche.com>

1  2 
src/components/tree/tree.tsx
src/store/navigation/navigation-action.ts
src/store/project/project-reducer.test.ts
src/store/project/project-reducer.ts

index 0ff7f2d0ea7278cf2d9abcd81f74e672158a23db,604ba4923b47b085432da100b580349f8f9079c5..e24c1443a039332313371d6916c27c206bce740a
@@@ -44,9 -44,9 +44,9 @@@ const styles: StyleRulesCallback<CssRul
  });
  
  export enum TreeItemStatus {
-     Initial,
-     Pending,
-     Loaded
+     INITIAL,
+     PENDING,
+     LOADED
  }
  
  export interface TreeItem<T> {
@@@ -55,6 -55,7 +55,6 @@@
      open: boolean;
      active: boolean;
      status: TreeItemStatus;
 -    toggled?: boolean;
      items?: Array<TreeItem<T>>;
  }
  
@@@ -79,12 -80,12 +79,12 @@@ export const Tree = withStyles(styles)
                          <ListItem button className={list} style={{ paddingLeft: (level + 1) * 20 }}
                              onClick={() => toggleItemActive(it.id, it.status)}
                              onContextMenu={this.handleRowContextMenu(it)}>
-                             {it.status === TreeItemStatus.Pending ?
+                             {it.status === TreeItemStatus.PENDING ?
                                  <CircularProgress size={10} className={loader} /> : null}
                              <i onClick={() => this.props.toggleItemOpen(it.id, it.status)}
                                  className={toggableIconContainer}>
                                  <ListItemIcon className={this.getToggableIconClassNames(it.open, it.active)}>
 -                                    {it.toggled && it.items && it.items.length === 0 ? <span /> : <SidePanelRightArrowIcon />}
 +                                    {it.status !== TreeItemStatus.Initial && it.items && it.items.length === 0 ? <span /> : <SidePanelRightArrowIcon />}
                                  </ListItemIcon>
                              </i>
                              {render(it, level)}
index edb03682bd69b4451d19476d9f427be2cc7d09ff,f3f9cafe7f268aa3fed71cff37494218917fd71c..52086231742d8d9f37925c11cd41e95ef4395603
@@@ -14,8 -14,8 +14,8 @@@ import { Resource, ResourceKind } from 
  
  export const getResourceUrl = <T extends Resource>(resource: T): string => {
      switch (resource.kind) {
-         case ResourceKind.Project: return `/projects/${resource.uuid}`;
-         case ResourceKind.Collection: return `/collections/${resource.uuid}`;
+         case ResourceKind.PROJECT: return `/projects/${resource.uuid}`;
+         case ResourceKind.COLLECTION: return `/collections/${resource.uuid}`;
          default: return resource.href;
      }
  };
@@@ -33,6 -33,10 +33,6 @@@ export const setProjectItem = (itemId: 
  
          if (treeItem) {
  
 -            if (itemMode === ItemMode.OPEN || itemMode === ItemMode.BOTH) {
 -                dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(treeItem.data.uuid));
 -            }
 -
              const resourceUrl = getResourceUrl(treeItem.data);
  
              if (itemMode === ItemMode.ACTIVE || itemMode === ItemMode.BOTH) {
                  dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_ACTIVE(treeItem.data.uuid));
              }
  
-             const promise = treeItem.status === TreeItemStatus.Loaded
+             const promise = treeItem.status === TreeItemStatus.LOADED
                  ? Promise.resolve()
                  : dispatch<any>(getProjectList(itemId));
  
              promise
                  .then(() => dispatch<any>(() => {
 +                    if (itemMode === ItemMode.OPEN || itemMode === ItemMode.BOTH) {
 +                        dispatch(projectActions.TOGGLE_PROJECT_TREE_ITEM_OPEN(treeItem.data.uuid));
 +                    }
                      dispatch(dataExplorerActions.RESET_PAGINATION({id: PROJECT_PANEL_ID}));
                      dispatch(dataExplorerActions.REQUEST_ITEMS({id: PROJECT_PANEL_ID}));
                  }));
index 48a5c7b83f9b7f94a05fdc4713025d609cecd7cf,ca139e66117fd070c03c6e5846b0a6a50dfc6da9..76c8edc13e9a92698d6c4e69b4b2635b1a55dd5d
@@@ -28,7 -28,7 +28,7 @@@ describe('project-reducer', () => 
                  id: "2",
                  items: [],
                  data: mockProjectResource({ uuid: "2" }),
 -                status: 0
 +                status: TreeItemStatus.Initial
              }
              ],
              currentItemId: "",
@@@ -47,7 -47,7 +47,7 @@@
                  id: "1",
                  open: true,
                  active: true,
 -                status: 1
 +                status: TreeItemStatus.Pending
              }],
              currentItemId: "1",
              creator: { opened: false, pending: false, ownerUuid: "" },
@@@ -58,7 -58,7 +58,7 @@@
                  id: "1",
                  open: true,
                  active: false,
 -                status: 1
 +                status: TreeItemStatus.Pending
              }],
              currentItemId: "",
              creator: { opened: false, pending: false, ownerUuid: "" },
@@@ -75,7 -75,7 +75,7 @@@
                  id: "1",
                  open: true,
                  active: false,
 -                status: 1
 +                status: TreeItemStatus.Pending
              }],
              currentItemId: "1",
              creator: { opened: false, pending: false, ownerUuid: "" }
@@@ -86,7 -86,8 +86,7 @@@
                  id: "1",
                  open: true,
                  active: true,
 -                status: 1,
 -                toggled: true
 +                status: TreeItemStatus.Pending,
              }],
              currentItemId: "1",
              creator: { opened: false, pending: false, ownerUuid: "" },
                  id: "1",
                  open: true,
                  active: false,
 -                status: 1,
 -                toggled: false,
 +                status: TreeItemStatus.Pending,
              }],
              currentItemId: "1",
              creator: { opened: false, pending: false, ownerUuid: "" }
                  id: "1",
                  open: false,
                  active: false,
 -                status: 1,
 -                toggled: true
 +                status: TreeItemStatus.Pending,
              }],
              currentItemId: "1",
              creator: { opened: false, pending: false, ownerUuid: "" },
@@@ -133,7 -136,7 +133,7 @@@ describe("findTreeBranch", () => 
          active: false,
          data: "",
          open: false,
-         status: TreeItemStatus.Initial
+         status: TreeItemStatus.INITIAL
      });
  
      it("should return an array that matches path to the given item", () => {
index 163e687e614787c2a2069681c43d2457f1fbf1fc,fa92f5f2349d8185992a8dcdefff9f1c063258f5..45e0e19527253ea03e39603a673e8e477232c484
@@@ -73,14 -73,14 +73,14 @@@ function updateProjectTree(tree: Array<
      if (parentItemId) {
          treeItem = findTreeItem(tree, parentItemId);
          if (treeItem) {
-             treeItem.status = TreeItemStatus.Loaded;
+             treeItem.status = TreeItemStatus.LOADED;
          }
      }
      const items = projects.map(p => ({
          id: p.uuid,
          open: false,
          active: false,
-         status: TreeItemStatus.Initial,
+         status: TreeItemStatus.INITIAL,
          data: p,
          items: []
      } as TreeItem<ProjectResource>));
@@@ -123,7 -123,7 +123,7 @@@ export const projectsReducer = (state: 
              const items = _.cloneDeep(state.items);
              const item = findTreeItem(items, itemId);
              if (item) {
-                 item.status = TreeItemStatus.Pending;
+                 item.status = TreeItemStatus.PENDING;
                  state.items = items;
              }
              return { ...state, items };
              const items = _.cloneDeep(state.items);
              const item = findTreeItem(items, itemId);
              if (item) {
 -                item.toggled = true;
                  item.open = !item.open;
              }
              return {
              resetTreeActivity(items);
              const item = findTreeItem(items, itemId);
              if (item) {
 -                item.toggled = true;
                  item.active = true;
              }
              return {