15803: Add checks that user uuid (from getUserUuid) is defined
[arvados-workbench2.git] / src / store / project-tree-picker / project-tree-picker-actions.ts
index 31110175412f32c8dc1363677a223c60e2306e2b..d05e2dc7a1c73e10eff89b3420248836132f913e 100644 (file)
@@ -4,22 +4,23 @@
 
 import { Dispatch } from "redux";
 import { RootState } from "~/store/store";
+import { getUserUuid } from "~/common/getuser";
 import { ServiceRepository } from "~/services/services";
 import { mockProjectResource } from "~/models/test-utils";
 import { treePickerActions, receiveTreePickerProjectsData } from "~/store/tree-picker/tree-picker-actions";
 import { TreePickerId } from '~/models/tree';
 
 export const resetPickerProjectTree = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.PROJECTS}));
-    dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.SHARED_WITH_ME}));
-    dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.FAVORITES}));
+    dispatch<any>(treePickerActions.RESET_TREE_PICKER({ pickerId: TreePickerId.PROJECTS }));
+    dispatch<any>(treePickerActions.RESET_TREE_PICKER({ pickerId: TreePickerId.SHARED_WITH_ME }));
+    dispatch<any>(treePickerActions.RESET_TREE_PICKER({ pickerId: TreePickerId.FAVORITES }));
 
     dispatch<any>(initPickerProjectTree());
 };
 
 export const initPickerProjectTree = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    const uuid = services.authService.getUuid();
-
+    const uuid = getUserUuid(getState());
+    if (!uuid) { return; }
     dispatch<any>(getPickerTreeProjects(uuid));
     dispatch<any>(getSharedWithMeProjectsPickerTree(uuid));
     dispatch<any>(getFavoritesProjectsPickerTree(uuid));
@@ -43,4 +44,4 @@ const getProjectsPickerTree = (uuid: string, kind: string) => {
         [mockProjectResource({ uuid, name: kind })],
         kind
     );
-};
\ No newline at end of file
+};