[ARVADOS-WORKBENCH2] updated: 1.1.4-419-g5e198d5

Git user git at public.curoverse.com
Tue Jul 24 09:20:20 EDT 2018


Summary of changes:
 src/store/favorites/favorites-actions.ts   | 9 +++++++++
 src/views-components/snackbar/snackbar.tsx | 8 +++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

       via  5e198d5ecf8dc37ab6d063631b567527c39fb9b5 (commit)
      from  6d5feaa5d8ab29f14efd5d6d60154248a1c14c73 (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 5e198d5ecf8dc37ab6d063631b567527c39fb9b5
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date:   Tue Jul 24 15:20:02 2018 +0200

    Integrate favorites with snackbar
    
    Feature #13886
    
    Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>

diff --git a/src/store/favorites/favorites-actions.ts b/src/store/favorites/favorites-actions.ts
index 33fc7e3..eb4f649 100644
--- a/src/store/favorites/favorites-actions.ts
+++ b/src/store/favorites/favorites-actions.ts
@@ -7,6 +7,7 @@ import { Dispatch } from "redux";
 import { favoriteService } from "../../services/services";
 import { RootState } from "../store";
 import { checkFavorite } from "./favorites-reducer";
+import { snackbarActions } from "../snackbar/snackbar-actions";
 
 export const favoritesActions = unionize({
     TOGGLE_FAVORITE: ofType<{ resourceUuid: string }>(),
@@ -20,6 +21,7 @@ export const toggleFavorite = (resource: { uuid: string; name: string }) =>
     (dispatch: Dispatch, getState: () => RootState): Promise<any> => {
         const userUuid = getState().auth.user!.uuid;
         dispatch(favoritesActions.TOGGLE_FAVORITE({ resourceUuid: resource.uuid }));
+        dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Working..." }));
         const isFavorite = checkFavorite(resource.uuid, getState().favorites);
         const promise: any = isFavorite
             ? favoriteService.delete({ userUuid, resourceUuid: resource.uuid })
@@ -28,6 +30,13 @@ export const toggleFavorite = (resource: { uuid: string; name: string }) =>
         return promise
             .then(() => {
                 dispatch(favoritesActions.UPDATE_FAVORITES({ [resource.uuid]: !isFavorite }));
+                dispatch(snackbarActions.CLOSE_SNACKBAR());
+                dispatch(snackbarActions.OPEN_SNACKBAR({
+                    message: isFavorite
+                        ? "Removed from favorites"
+                        : "Added to favorites",
+                    hideDuration: 2000
+                }));
             });
     };
 
diff --git a/src/views-components/snackbar/snackbar.tsx b/src/views-components/snackbar/snackbar.tsx
index d83d701..c65d364 100644
--- a/src/views-components/snackbar/snackbar.tsx
+++ b/src/views-components/snackbar/snackbar.tsx
@@ -10,15 +10,17 @@ import { Dispatch } from "redux";
 import { snackbarActions } from "../../store/snackbar/snackbar-actions";
 
 const mapStateToProps = (state: RootState): SnackbarProps => ({
-    anchorOrigin: { vertical: "bottom", horizontal: "left" },
+    anchorOrigin: { vertical: "bottom", horizontal: "center" },
     open: state.snackbar.open,
     message: <span>{state.snackbar.message}</span>,
     autoHideDuration: state.snackbar.hideDuration
 });
 
 const mapDispatchToProps = (dispatch: Dispatch): Pick<SnackbarProps, "onClose"> => ({
-    onClose: () => {
-        dispatch(snackbarActions.CLOSE_SNACKBAR());
+    onClose: (event: any, reason: string) => {
+        if (reason !== "clickaway") {
+            dispatch(snackbarActions.CLOSE_SNACKBAR());
+        }
     }
 });
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list