import { rootProjectActionSet } from "./views-components/context-menu/action-sets/root-project-action-set";
import { projectActionSet } from "./views-components/context-menu/action-sets/project-action-set";
import { resourceActionSet } from './views-components/context-menu/action-sets/resource-action-set';
+import { favoriteActionSet } from "./views-components/context-menu/action-sets/favorite-action-set";
addMenuActionSet(ContextMenuKind.RootProject, rootProjectActionSet);
addMenuActionSet(ContextMenuKind.Project, projectActionSet);
addMenuActionSet(ContextMenuKind.Resource, resourceActionSet);
+addMenuActionSet(ContextMenuKind.Favorite, favoriteActionSet);
fetchConfig()
.then(config => {
export type FavoritesAction = UnionOf<typeof favoritesActions>;
export const toggleFavorite = (resource: { uuid: string; name: string }) =>
- (dispatch: Dispatch, getState: () => RootState) => {
+ (dispatch: Dispatch, getState: () => RootState): Promise<any> => {
const userUuid = getState().auth.user!.uuid;
dispatch(favoritesActions.TOGGLE_FAVORITE({ resourceUuid: resource.uuid }));
const isFavorite = checkFavorite(resource.uuid, getState().favorites);
? favoriteService.delete({ userUuid, resourceUuid: resource.uuid })
: favoriteService.create({ userUuid, resource });
- promise
+ return promise
.then(fav => {
dispatch(favoritesActions.UPDATE_FAVORITES({ [resource.uuid]: !isFavorite }));
});
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { ContextMenuActionSet } from "../context-menu-action-set";
+import { ToggleFavoriteAction } from "./favorite-action";
+import { toggleFavorite } from "../../../store/favorites/favorites-actions";
+import { dataExplorerActions } from "../../../store/data-explorer/data-explorer-action";
+import { FAVORITE_PANEL_ID } from "../../../views/favorite-panel/favorite-panel";
+
+export const favoriteActionSet: ContextMenuActionSet = [[{
+ component: ToggleFavoriteAction,
+ execute: (dispatch, resource) => {
+ debugger;
+ dispatch<any>(toggleFavorite(resource)).then(() => {
+ dispatch<any>(dataExplorerActions.REQUEST_ITEMS({ id : FAVORITE_PANEL_ID }));
+ });
+ }
+}]];
export enum ContextMenuKind {
RootProject = "RootProject",
Project = "Project",
- Resource = "Resource"
+ Resource = "Resource",
+ Favorite = "Favorite"
}
renderFavoritePanel = (props: RouteComponentProps<{ id: string }>) => <FavoritePanel
onItemRouteChange={itemId => this.props.dispatch<any>(setFavoriteItem(itemId, ItemMode.ACTIVE))}
onContextMenu={(event, item) => {
- const kind = item.kind === ResourceKind.Project ? ContextMenuKind.Project : ContextMenuKind.Resource;
this.openContextMenu(event, {
uuid: item.uuid,
name: item.name,
- kind,
+ kind: ContextMenuKind.Favorite,
});
}}
onDialogOpen={this.handleCreationDialogOpen}