context-menus-in-public-favorite-panel
[arvados-workbench2.git] / src / store / public-favorites / public-favorites-actions.ts
index ae6815b61e002325a36227fe903457e6ac30cad6..b5aa9fcef70d202bd0ddb2244577b2de86020ebb 100644 (file)
@@ -9,6 +9,8 @@ import { checkPublicFavorite } from "./public-favorites-reducer";
 import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
 import { ServiceRepository } from "~/services/services";
 import { progressIndicatorActions } from "~/store/progress-indicator/progress-indicator-actions";
+import { getResource } from '~/store/resources/resources';
+import { LinkResource } from "~/models/link";
 
 export const publicFavoritesActions = unionize({
     TOGGLE_PUBLIC_FAVORITE: ofType<{ resourceUuid: string }>(),
@@ -66,3 +68,15 @@ export const updatePublicFavorites = (resourceUuids: string[]) =>
                 dispatch(publicFavoritesActions.UPDATE_PUBLIC_FAVORITES(results));
             });
     };
+
+export const getHeadUuid = (uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const resource = getResource<LinkResource>(uuid)(getState().resources);
+        return resource!.headUuid;
+    };
+
+export const getIsAdmin = () =>
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        const resource = getState().auth.user!.isAdmin;
+        return resource;
+    };